Started by
tt007
on
Topic category: Help with Minecraft modding (Java Edition)
Hello guys! I'm trying to make enchantment with level over 100. When I using this Mod in game, there is a problem with doubling of this enchantment, and also problem with negative values it marks level -24. What am I doing wrong? Please do not judge me stricly I'me new one here. There are screenshots, and I will send code at next message. Thank you in advance.
package net.mcreator.modtest.procedures;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.event.entity.player.PlayerEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraft.world.World;
import net.minecraft.item.ItemStack;
import net.minecraft.entity.Entity;
import net.minecraft.enchantment.Enchantments;
import net.mcreator.modtest.ModTestModElements;
import net.mcreator.modtest.ModTestMod;
import java.util.Map;
import java.util.HashMap;
@ModTestModElements.ModElement.Tag
public class Best_axe_CraftedProcedure extends ModTestModElements.ModElement {
public Best_axe_CraftedProcedure(ModTestModElements instance) {
super(instance, 1);
MinecraftForge.EVENT_BUS.register(this);
}
public static void executeProcedure(Map<String, Object> dependencies) {
if (dependencies.get("itemstack") == null) {
if (!dependencies.containsKey("itemstack"))
ModTestMod.LOGGER.warn("Failed to load dependency itemstack for procedure Best_axe_Crafted!");
return;
}
ItemStack itemstack = (ItemStack) dependencies.get("itemstack");
if ((true)) {
((itemstack)).addEnchantment(Enchantments.SHARPNESS, (int) 1000);
}
}
@SubscribeEvent
public void onItemCrafted(PlayerEvent.ItemCraftedEvent event) {
Entity entity = event.getPlayer();
World world = entity.world;
double i = entity.getPosX();
double j = entity.getPosY();
double k = entity.getPosZ();
ItemStack itemStack = event.getCrafting();
Map<String, Object> dependencies = new HashMap<>();
dependencies.put("x", i);
dependencies.put("y", j);
dependencies.put("z", k);
dependencies.put("world", world);
dependencies.put("entity", entity);
dependencies.put("itemstack", itemStack);
dependencies.put("event", event);
this.executeProcedure(dependencies);
}
}
Guys please help!
it may work with commands
What kind of command? You mean commands that adding tools? But I need to make mod with default system craft with adding enchantment