tripl3dogdare Posted October 15, 2016 Posted October 15, 2016 When I attempt to use getAttributeModifiers to change the attributes of an item type defined as a Scala trait, the game crashes with an IllegalAccessError as such: net.minecraft.util.ReportedException: Ticking player at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:210) ~[NetworkSystem.class:?] at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:806) ~[MinecraftServer.class:?] at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:687) ~[MinecraftServer.class:?] at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:156) ~[integratedServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:536) [MinecraftServer.class:?] at java.lang.Thread.run(Unknown Source) [?:1.8.0_74] Caused by: java.lang.IllegalAccessError: tried to access field net.minecraft.item.Item.ATTACK_DAMAGE_MODIFIER from class chuunimod.item.ItemManaWeapon$class at chuunimod.item.ItemManaWeapon$class.getAttributeModifiers(ItemManaWeapon.scala:90) ~[itemManaWeapon$class.class:?] at chuunimod.item.ItemArmorPairingManaWeapon.getAttributeModifiers(ItemArmorPairingManaWeapon.scala:20) ~[itemArmorPairingManaWeapon.class:?] at net.minecraft.item.ItemStack.getAttributeModifiers(ItemStack.java:1043) ~[itemStack.class:?] at net.minecraft.entity.EntityLivingBase.onUpdate(EntityLivingBase.java:2187) ~[EntityLivingBase.class:?] at net.minecraft.entity.player.EntityPlayer.onUpdate(EntityPlayer.java:259) ~[EntityPlayer.class:?] at net.minecraft.entity.player.EntityPlayerMP.onUpdateEntity(EntityPlayerMP.java:341) ~[EntityPlayerMP.class:?] at net.minecraft.network.NetHandlerPlayServer.update(NetHandlerPlayServer.java:174) ~[NetHandlerPlayServer.class:?] at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher$1.update(NetworkDispatcher.java:216) ~[NetworkDispatcher$1.class:?] at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:308) ~[NetworkManager.class:?] at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:195) ~[NetworkSystem.class:?] ... 5 more The relevant trait: trait ItemManaWeapon extends ItemChuuniItem { //ItemChuuniItem directly extends net.minecraft.item.Item //omitted override def getAttributeModifiers(slot:EntityEquipmentSlot, stack:ItemStack) = FMLCommonHandler.instance.getEffectiveSide match { case Side.CLIENT => super.getAttributeModifiers(slot, stack) case Side.SERVER => { val map = super.getAttributeModifiers(slot, stack) if(slot == EntityEquipmentSlot.MAINHAND && stack.hasTagCompound && stack.getTagCompound.getBoolean("active")) { map.put(SharedMonsterAttributes.ATTACK_DAMAGE.getAttributeUnlocalizedName, new AttributeModifier(Item.ATTACK_DAMAGE_MODIFIER, "Weapon modifier", getAttackDmg(stack)-2, 0)) map.put(SharedMonsterAttributes.ATTACK_SPEED.getAttributeUnlocalizedName, new AttributeModifier(Item.ATTACK_SPEED_MODIFIER, "Weapon modifier", -(4-getAttackSpd(stack)), 0)) } map } } //omitted } The code is throwing an IllegalAccessError at "Item.ATTACK_DAMAGE_MODIFIER", and I have no idea why outside of some Java/Scala interop bull****. Please help! Quote Github: http://github.com/tripl3dogdare Youtube: http://youtube.com/tripl3dogdare Twitter: http://twitter.com/tripl3dogdare Twitter RP: http://twitter.com/TheWitchesEye
tripl3dogdare Posted October 15, 2016 Author Posted October 15, 2016 That's about what I figured. Do you know any way around it? I'd prefer not to make this an implementation detail of whatever mixes in the trait. Quote Github: http://github.com/tripl3dogdare Youtube: http://youtube.com/tripl3dogdare Twitter: http://twitter.com/tripl3dogdare Twitter RP: http://twitter.com/TheWitchesEye
tripl3dogdare Posted October 15, 2016 Author Posted October 15, 2016 *sigh* thought so. Won't be pretty, but then neither is this whole process. Thanks! Quote Github: http://github.com/tripl3dogdare Youtube: http://youtube.com/tripl3dogdare Twitter: http://twitter.com/tripl3dogdare Twitter RP: http://twitter.com/TheWitchesEye
tripl3dogdare Posted October 15, 2016 Author Posted October 15, 2016 That would be nice... Java/Scala interop always gets me down. "Seamless" my eye... Quote Github: http://github.com/tripl3dogdare Youtube: http://youtube.com/tripl3dogdare Twitter: http://twitter.com/tripl3dogdare Twitter RP: http://twitter.com/TheWitchesEye
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.