• Recently Browsing

    No registered users viewing this page.

  • Posts

    • This event would theoretically fire a lot. Why do you need this event?   And just a heads up: Saying that you are currently just coremodding to achieve this is not a good way to get your request accepted.
    • Hello! For my mod I need an event, that detects a change of the enchantments on an itemstack. This would include adding/removing enchantments, but also increasing a level of an enchantment. I've been working on this problem on my own forge branch, but I ran into some problems.   There seems to be two methods, that writes the nbt data of an itemstack directly. These are ItemStack#addEnchantment (called by EnchantmentContainer) and EnchantmentHelper#setEnchantment (called by RepairContainer and GrindstoneContainer). These methods would be a good place for the forge event hook, because then the event would also fire, if any other mod would change the enchantments (as long as they are using these vanilla methods). However for my actual problem of detecting enchantment changes, they are not working as I hoped.   Currently I have 2 new events on my branch. The first is EnchantmentAddEvent, whichs fires in ItemStack#addEnchantment. //the hook in ItemStack public void addEnchantment(Enchantment ench, int level) { net.minecraftforge.event.enchanting.EnchantmentAddEvent event = new net.minecraftforge.event.enchanting.EnchantmentAddEvent(this, ench, level); net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event); ... } //the event class public class EnchantmentAddEvent extends net.minecraftforge.eventbus.api.Event { private ItemStack itemstack; private Enchantment ench; private int level; public EnchantmentAddEvent(ItemStack itemstack, Enchantment ench, int level) { this.itemstack = itemstack; this.ench = ench; this.level = level; } } This way, one could check the current enchantments on the itemstacks, because the new one hasn't be written to it. Sadly, one would also have to check, if ench can even be applied to the itemstack. Maybe It would be better to move the hook a little bit further down the line, so the enchantments are already applied to the itemstack. However then I would also have to add a variable for the old enchantment map.   The second event is EnchantmentSetEvent //event hook in EnchantmentHelper public static void setEnchantments(Map<Enchantment, Integer> enchMap, ItemStack stack) { net.minecraftforge.event.enchanting.EnchantmentSetEvent event = new net.minecraftforge.event.enchanting.EnchantmentSetEvent(stack, enchMap); net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event); ... } //event public class EnchantmentSetEvent extends net.minecraftforge.eventbus.api.Event { @Nonnull private final ItemStack itemstack; private final Map<Enchantment, Integer> enchMap; public EnchantmentSetEvent(ItemStack itemstack, Map<Enchantment, Integer> enchMap) { this.itemstack = itemstack; Map<Enchantment, Integer> enchMapStack = EnchantmentHelper.getEnchantments(itemstack); this.enchMap = enchMap; } public ItemStack getItemStack() { return this.itemstack; } public Map<Enchantment, Integer> getEnchantments() { return enchMap; } } I noticed, that the setEnchantment method is called multiple times both on client and on server side (for both container) and I don't really get why this is happenning.   Currently I'm also missing a hook, that detects, if an enchantment gets removed. Looking at GrindstoneContainer#removeEnchantments I noticed, that enchantments can be removed, by deleting the childTag "Enchantments" (or "StorredEnchantments"). So I supposed I would have to add another hook in ItemStack#removeChildTag (together with checking the tag), right? Is it okay, if the patch includes an if statement?   To summerize: I want an event, that is essentially LivingEquipmentChangeEvent, but for ItemStacks. So the event would have 'Map<Enchantment, Integer> before' and 'Map<Enchantment, Integer> after' and the corresponding itemstack. This Event should then be fired, whenever the enchantment data of any ItemStack changes. Am I on the right track or should I tackle the problem completly differently?
    • bigest problem is Failed to find Minecraft resource version 1.15.2-20200515.085601 at C:\Program Files (x86)\Minecraft Launcher\Install\libraries\net\minecraftforge\forge\1.15.2-31.2.31\forge-1.15.2-31.2.31-client.jar
    • 23:36:45.643 [java.lang.ThreadGroup:uncaughtException:1052]: at net.minecraftforge.fml.loading.FMLCommonLaunchHandler.validatePaths(FMLCommonLaunchHandler.java:121) 23:36:45.643 [java.lang.ThreadGroup:uncaughtException:1052]: at net.minecraftforge.fml.loading.FMLLoader.setupLaunchHandler(FMLLoader.java:199) 23:36:45.643 [java.lang.ThreadGroup:uncaughtException:1052]: at net.minecraftforge.fml.loading.FMLServiceProvider.initialize(FMLServiceProvider.java:94) 23:36:45.643 [java.lang.ThreadGroup:uncaughtException:1052]: at cpw.mods.modlauncher.TransformationServiceDecorator.onInitialize(TransformationServiceDecorator.java:68) 23:36:45.643 [java.lang.ThreadGroup:uncaughtException:1052]: at cpw.mods.modlauncher.TransformationServicesHandler.lambda$initialiseTransformationServices$7(TransformationServicesHandler.java:107) 23:36:45.643 [java.lang.ThreadGroup:uncaughtException:1052]: at cpw.mods.modlauncher.TransformationServicesHandler$$Lambda$86/943870983.accept(Unknown Source) 23:36:45.644 [java.lang.ThreadGroup:uncaughtException:1052]: at java.util.HashMap$Values.forEach(HashMap.java:972) 23:36:45.644 [java.lang.ThreadGroup:uncaughtException:1052]: at cpw.mods.modlauncher.TransformationServicesHandler.initialiseTransformationServices(TransformationServicesHandler.java:107) 23:36:45.644 [java.lang.ThreadGroup:uncaughtException:1052]: at cpw.mods.modlauncher.TransformationServicesHandler.initializeTransformationServices(TransformationServicesHandler.java:59) 23:36:45.644 [java.lang.ThreadGroup:uncaughtException:1052]: at cpw.mods.modlauncher.Launcher.run(Launcher.java:75) 23:36:45.644 [java.lang.ThreadGroup:uncaughtException:1052]: at cpw.mods.modlauncher.Launcher.main(Launcher.java:65) 23:36:46.324 Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=256m; support was removed in 8.0 23:36:46.324 Process crashed with exit code 1 23:36:45.643 [java.lang.ThreadGroup:uncaughtException:1052]: at net.minecraftforge.fml.loading.FMLCommonLaunchHandler.validatePaths(FMLCommonLaunchHandler.java:121) 23:36:45.643 [java.lang.ThreadGroup:uncaughtException:1052]: at net.minecraftforge.fml.loading.FMLLoader.setupLaunchHandler(FMLLoader.java:199) 23:36:45.643 [java.lang.ThreadGroup:uncaughtException:1052]: at net.minecraftforge.fml.loading.FMLServiceProvider.initialize(FMLServiceProvider.java:94) 23:36:45.643 [java.lang.ThreadGroup:uncaughtException:1052]: at cpw.mods.modlauncher.TransformationServiceDecorator.onInitialize(TransformationServiceDecorator.java:68) 23:36:45.643 [java.lang.ThreadGroup:uncaughtException:1052]: at cpw.mods.modlauncher.TransformationServicesHandler.lambda$initialiseTransformationServices$7(TransformationServicesHandler.java:107) 23:36:45.643 [java.lang.ThreadGroup:uncaughtException:1052]: at cpw.mods.modlauncher.TransformationServicesHandler$$Lambda$86/943870983.accept(Unknown Source) 23:36:45.644 [java.lang.ThreadGroup:uncaughtException:1052]: at java.util.HashMap$Values.forEach(HashMap.java:972) 23:36:45.644 [java.lang.ThreadGroup:uncaughtException:1052]: at cpw.mods.modlauncher.TransformationServicesHandler.initialiseTransformationServices(TransformationServicesHandler.java:107) 23:36:45.644 [java.lang.ThreadGroup:uncaughtException:1052]: at cpw.mods.modlauncher.TransformationServicesHandler.initializeTransformationServices(TransformationServicesHandler.java:59) 23:36:45.644 [java.lang.ThreadGroup:uncaughtException:1052]: at cpw.mods.modlauncher.Launcher.run(Launcher.java:75) 23:36:45.644 [java.lang.ThreadGroup:uncaughtException:1052]: at cpw.mods.modlauncher.Launcher.main(Launcher.java:65) 23:36:46.324 Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=256m; support was removed in 8.0 23:36:46.324 Process crashed with exit code 1
  • Topics

  • Who's Online (See full list)