Issue with doubling enchantment and negative values

Started by tt007 on

Topic category: Help with modding (Java Edition)

Last seen on 14:01, 29. Jun 2021
Joined May 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Issue with doubling enchantment and negative values

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.

https://flic.kr/p/2kWyhvd

https://flic.kr/p/2kWHn4r

Last seen on 14:01, 29. Jun 2021
Joined May 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
(No subject)
Tue, 05/04/2021 - 14:53

Procedure

Last seen on 14:01, 29. Jun 2021
Joined May 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
(No subject)
Tue, 05/04/2021 - 14:55

In game enchantment issue level 1000

Last seen on 14:01, 29. Jun 2021
Joined May 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
package net.mcreator.modtest…
Tue, 05/04/2021 - 14:56

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);
    }
}
 

Last seen on 14:01, 29. Jun 2021
Joined May 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Guys please help! 
Tue, 05/04/2021 - 22:58

Guys please help! 

Last seen on 00:59, 19. Oct 2022
Joined Feb 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
it may work with commands  
Sat, 05/08/2021 - 00:56

it may work with commands

 
Last seen on 14:01, 29. Jun 2021
Joined May 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
What kind of command? You…
Mon, 05/10/2021 - 03:12

What kind of command? You mean commands that adding tools? But I need to make mod with default system craft with adding enchantment