Jump to content

[1.10.2] [Scala] IllegalAccessError with item attribute modifiers (Solved)


Recommended Posts

Posted

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!

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.