Compare commits
4
Commits
fb5d5e1963
...
1.21.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
80822846f5
|
||
|
|
7f56bfabba
|
||
|
|
b80f430157
|
||
|
|
7c003642c5
|
No files matched your search
+7
-7
@@ -1,17 +1,17 @@
|
|||||||
org.gradle.jvmargs=-Xmx3G
|
org.gradle.jvmargs=-Xmx3G
|
||||||
org.gradle.daemon=false
|
org.gradle.daemon=false
|
||||||
# The Minecraft version must agree with the Forge version to get a valid artifact
|
# The Minecraft version must agree with the Forge version to get a valid artifact
|
||||||
minecraft_version=1.21.4
|
minecraft_version=1.21.1
|
||||||
# The Minecraft version range can use any release version of Minecraft as bounds.
|
# The Minecraft version range can use any release version of Minecraft as bounds.
|
||||||
# Snapshots, pre-releases, and release candidates are not guaranteed to sort properly
|
# Snapshots, pre-releases, and release candidates are not guaranteed to sort properly
|
||||||
# as they do not follow standard versioning conventions.
|
# as they do not follow standard versioning conventions.
|
||||||
minecraft_version_range=[1.21.4,1.22)
|
minecraft_version_range=[1.21.1]
|
||||||
# The Forge version must agree with the Minecraft version to get a valid artifact
|
# The Forge version must agree with the Minecraft version to get a valid artifact
|
||||||
forge_version=54.1.0
|
forge_version=52.0.57
|
||||||
# The Forge version range can use any version of Forge as bounds or match the loader version range
|
# The Forge version range can use any version of Forge as bounds or match the loader version range
|
||||||
forge_version_range=[54,)
|
forge_version_range=[52,)
|
||||||
# The loader version range can only use the major version of Forge/FML as bounds
|
# The loader version range can only use the major version of Forge/FML as bounds
|
||||||
loader_version_range=[54,)
|
loader_version_range=[52,)
|
||||||
# The mapping channel to use for mappings.
|
# The mapping channel to use for mappings.
|
||||||
# The default set of supported mapping channels are ["official", "snapshot", "snapshot_nodoc", "stable", "stable_nodoc"].
|
# The default set of supported mapping channels are ["official", "snapshot", "snapshot_nodoc", "stable", "stable_nodoc"].
|
||||||
# Additional mapping channels can be registered through the "channelProviders" extension in a Gradle plugin.
|
# Additional mapping channels can be registered through the "channelProviders" extension in a Gradle plugin.
|
||||||
@@ -29,7 +29,7 @@ loader_version_range=[54,)
|
|||||||
mapping_channel=official
|
mapping_channel=official
|
||||||
# The mapping version to query from the mapping channel.
|
# The mapping version to query from the mapping channel.
|
||||||
# This must match the format required by the mapping channel.
|
# This must match the format required by the mapping channel.
|
||||||
mapping_version=1.21.4
|
mapping_version=1.21.1
|
||||||
# The unique mod identifier for the mod. Must be lowercase in English locale. Must fit the regex [a-z][a-z0-9_]{1,63}
|
# The unique mod identifier for the mod. Must be lowercase in English locale. Must fit the regex [a-z][a-z0-9_]{1,63}
|
||||||
# Must match the String constant located in the main mod class annotated with @Mod.
|
# Must match the String constant located in the main mod class annotated with @Mod.
|
||||||
mod_id=xp2items
|
mod_id=xp2items
|
||||||
@@ -38,7 +38,7 @@ mod_name=XP -> items
|
|||||||
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
|
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
|
||||||
mod_license=All Rights Reserved
|
mod_license=All Rights Reserved
|
||||||
# The mod version. See https://semver.org/
|
# The mod version. See https://semver.org/
|
||||||
mod_version=0.1.0
|
mod_version=0.2.0
|
||||||
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
|
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
|
||||||
# This should match the base package used for the mod sources.
|
# This should match the base package used for the mod sources.
|
||||||
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
|
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||||
|
|||||||
+1
-1
@@ -13,4 +13,4 @@ plugins {
|
|||||||
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.7.0'
|
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.7.0'
|
||||||
}
|
}
|
||||||
|
|
||||||
rootProject.name = 'jonasmod'
|
rootProject.name = 'xp2items'
|
||||||
@@ -14,8 +14,8 @@ public class Xp2Items {
|
|||||||
|
|
||||||
public static final String MODID = "xp2items";
|
public static final String MODID = "xp2items";
|
||||||
|
|
||||||
public Xp2Items(FMLJavaModLoadingContext context) {
|
public Xp2Items() {
|
||||||
IEventBus modEventBus = context.getModEventBus();
|
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||||
|
|
||||||
items.register(modEventBus);
|
items.register(modEventBus);
|
||||||
creativeTab.register(modEventBus);
|
creativeTab.register(modEventBus);
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
package com.jenny.xp2items.items;
|
package com.jenny.xp2items.items;
|
||||||
|
|
||||||
import net.minecraft.core.registries.Registries;
|
|
||||||
import net.minecraft.resources.ResourceKey;
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
import net.minecraft.world.item.Item;
|
import net.minecraft.world.item.Item;
|
||||||
import net.minecraftforge.eventbus.api.IEventBus;
|
import net.minecraftforge.eventbus.api.IEventBus;
|
||||||
import net.minecraftforge.registries.DeferredRegister;
|
import net.minecraftforge.registries.DeferredRegister;
|
||||||
@@ -14,7 +11,7 @@ import static com.jenny.xp2items.Xp2Items.MODID;
|
|||||||
public class items {
|
public class items {
|
||||||
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID);
|
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID);
|
||||||
|
|
||||||
public static final RegistryObject<Item> XP_TALISMAN = ITEMS.register("xp_talisman", () -> new xpTalisman(new Item.Properties().setId(ResourceKey.create(Registries.ITEM, ResourceLocation.fromNamespaceAndPath(MODID, "xp_talisman"))).stacksTo(1)));
|
public static final RegistryObject<Item> XP_TALISMAN = ITEMS.register("xp_talisman", () -> new xpTalisman(new Item.Properties().stacksTo(1)));
|
||||||
|
|
||||||
public static void register(IEventBus bus) {
|
public static void register(IEventBus bus) {
|
||||||
ITEMS.register(bus);
|
ITEMS.register(bus);
|
||||||
|
|||||||
@@ -1,18 +1,19 @@
|
|||||||
package com.jenny.xp2items.items;
|
package com.jenny.xp2items.items;
|
||||||
|
|
||||||
import com.jenny.xp2items.config.ServerConfig;
|
import com.jenny.xp2items.config.ServerConfig;
|
||||||
import net.minecraft.server.commands.ExperienceCommand;
|
import net.minecraft.core.particles.ParticleTypes;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
|
import net.minecraft.sounds.SoundEvents;
|
||||||
|
import net.minecraft.sounds.SoundSource;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.world.InteractionResult;
|
import net.minecraft.world.InteractionResultHolder;
|
||||||
import net.minecraft.world.entity.item.ItemEntity;
|
import net.minecraft.world.entity.item.ItemEntity;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.item.Item;
|
import net.minecraft.world.item.Item;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraftforge.registries.ForgeRegistries;
|
import net.minecraftforge.registries.ForgeRegistries;
|
||||||
import org.apache.logging.log4j.core.jmx.Server;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -22,22 +23,13 @@ public class xpTalisman extends Item {
|
|||||||
super(properties);
|
super(properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private static int getPlayerXP(@NotNull ServerPlayer player) {
|
||||||
public @NotNull InteractionResult use(@NotNull Level level, @NotNull Player player, @NotNull InteractionHand interactionHand) {
|
return Mth.floor(player.experienceProgress * (float) player.getXpNeededForNextLevel());
|
||||||
if (!level.isClientSide) {
|
|
||||||
if (ServerConfig.C_XP_AMOUNT.get() > 0) { // xp amount mode
|
|
||||||
spawnItem(level, (ServerPlayer) player);
|
|
||||||
} else { // xp level mode
|
|
||||||
spawnItemLevels(level, (ServerPlayer) player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return InteractionResult.SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void spawnItem(Level level, ServerPlayer player) {
|
private static void spawnItem(Level level, ServerPlayer player) {
|
||||||
List<Item> itemList = ForgeRegistries.ITEMS.getValues().stream().toList();
|
List<Item> itemList = ForgeRegistries.ITEMS.getValues().stream().toList();
|
||||||
int xpNeeded = ServerConfig.C_XP_AMOUNT.get();
|
int xpNeeded = ServerConfig.C_XP_AMOUNT.get();
|
||||||
System.out.println(getPlayerXP(player));
|
|
||||||
while (true) {
|
while (true) {
|
||||||
int expLevelBefore = player.experienceLevel;
|
int expLevelBefore = player.experienceLevel;
|
||||||
float expProgressBefore = player.experienceProgress;
|
float expProgressBefore = player.experienceProgress;
|
||||||
@@ -53,8 +45,11 @@ public class xpTalisman extends Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int getPlayerXP(ServerPlayer player) {
|
private static void effects(@NotNull Level level, Player player) {
|
||||||
return Mth.floor(player.experienceProgress * (float) player.getXpNeededForNextLevel());
|
level.playSound(player, player.getX(), player.getY(), player.getZ(), SoundEvents.EXPERIENCE_ORB_PICKUP, SoundSource.PLAYERS, 1.0F, 1.0F);
|
||||||
|
for (int i = 0; i < 9; ++i) {
|
||||||
|
level.addParticle(ParticleTypes.PORTAL, player.getRandomX(0.5F), player.getRandomY() - (double) 0.25F, player.getRandomZ(0.5F), (player.getRandom().nextDouble() - (double) 0.5F) * (double) 2.0F, -player.getRandom().nextDouble(), (player.getRandom().nextDouble() - (double) 0.5F) * (double) 2.0F);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void spawnItemLevels(Level level, ServerPlayer player) {
|
private static void spawnItemLevels(Level level, ServerPlayer player) {
|
||||||
@@ -71,4 +66,18 @@ public class xpTalisman extends Item {
|
|||||||
player.setExperiencePoints(0);
|
player.setExperiencePoints(0);
|
||||||
player.giveExperiencePoints(xpPoints);
|
player.giveExperiencePoints(xpPoints);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public InteractionResultHolder<ItemStack> use(@NotNull Level level, @NotNull Player player, @NotNull InteractionHand interactionHand) {
|
||||||
|
if (!level.isClientSide) {
|
||||||
|
if (ServerConfig.C_XP_AMOUNT.get() > 0) { // xp amount mode
|
||||||
|
spawnItem(level, (ServerPlayer) player);
|
||||||
|
} else { // xp level mode
|
||||||
|
spawnItemLevels(level, (ServerPlayer) player);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
effects(level, player);
|
||||||
|
}
|
||||||
|
return InteractionResultHolder.success(player.getItemInHand(interactionHand));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user