Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

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

Featured Replies

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.