Botania

Botania

133M Downloads

[1.7.10] How do I get the item damage?

Eufranio opened this issue ยท 8 comments

commented

Like in #1899

I'm trying to protect my players claim. I gave up trying to protect mana bursts, then I decided to protect the breaking caused by Bore Lenses. So, I did a protection:

    {
      "class": "vazkii.botania.common.item.lens.ItemLens",
      "type": "item",
      "actions": "RIGHT_CLICK_BLOCK",
      "isAdjacent": false,
      "flags": "MODIFY",
      "condition": "itemDamage == 7",
      "itemDamage": [
        {
          "element": "itemDamage",
          "type": "FIELD"
        }
      ],
      "range": 64
    }

Every time a player RIGHT_CLICK a block (a mana spreader, in case) the mod will check if it is instance of vazkii.botania.common.item.lens.ItemLens. If it is, then it will proccess the code, but I don't need to protect all lenses. I want to protect ONLY bore lenses, because of the grief. Bore lenses have metadata 7. So, i did a condition, to get and check the meta of the lens. If meta = 7 it will check the item.

But I can't check the meta trough that element (itemDamage), I don't know why, maybe It's with Botania Item register. When I do it, I get a error:

[23:13:47 ERROR]: Encountered error when checking condition for ItemLens
[23:13:47 ERROR]: mytown.util.exceptions.GetterException: Failed to get field itemDamage in getter: itemDamage
        at mytown.protection.segment.getter.GetterDynamic.invoke(GetterDynamic.java:51)
        at mytown.protection.segment.Condition.execute(Condition.java:41)
        at mytown.protection.segment.Segment.shouldCheck(Segment.java:115)
        at mytown.protection.segment.SegmentItem.shouldInteract(SegmentItem.java:39)
        at mytown.protection.ProtectionManager.checkUsage(ProtectionManager.java:193)
        at mytown.protection.ProtectionHandlers.onPlayerInteract(ProtectionHandlers.java:228)
        at cpw.mods.fml.common.eventhandler.ASMEventHandler_437_ProtectionHandlers_onPlayerInteract_PlayerInteractEvent.invoke(.dynamic)
        at cpw.mods.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:54)
        at cpw.mods.fml.common.eventhandler.EventBus.post(EventBus.java:140)
        at net.minecraftforge.event.ForgeEventFactory.onPlayerBukkitInteract(ForgeEventFactory.java:306)
        at net.minecraft.server.management.ItemInWorldManager.func_73078_a(ItemInWorldManager.java:430)
        at net.minecraft.network.NetHandlerPlayServer.func_147346_a(NetHandlerPlayServer.java:861)
        at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.func_148833_a(SourceFile:60)
        at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.func_148833_a(SourceFile:9)
        at net.minecraft.network.NetworkManager.func_74428_b(NetworkManager.java:245)
        at net.minecraft.network.NetworkSystem.func_151269_c(NetworkSystem.java:181)
        at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:1023)
        at net.minecraft.server.dedicated.DedicatedServer.func_71190_q(DedicatedServer.java:432)
        at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:841)
        at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:693)
        at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NoSuchFieldException: itemDamage
        at java.lang.Class.getDeclaredField(Class.java:2070)
        at mytown.protection.segment.caller.reflect.ReflectCallerField.getField(ReflectCallerField.java:26)
        at mytown.protection.segment.caller.reflect.ReflectCallerField.invoke(ReflectCallerField.java:12)
        at mytown.protection.segment.caller.reflectasm.ASMCallerField.invoke(ASMCallerField.java:15)
        at mytown.protection.segment.getter.GetterDynamic.invoke(GetterDynamic.java:48)
        ... 20 more

Caused by: java.lang.NoSuchFieldException: itemDamage, the itemDamage is unknown in the code. Could you help me understanding this, or provide a equivalent method to get the metadata?

commented

ItemLens is an item, it doesn't even have the concept of damage. Sounds like you're using your protection plugin in an incorrect way, or the plugin should have a way of extracting the meta from the stack by default.

commented

This is nothing to do with Botania. I'd take this up with the authors of the plugin you're using.

commented

Is there a equivalent for itemDamage in Botania? Because that's the most common getter for damage that I know :/

commented

Do an item dump from nei

Find the bore lense class, that should have the info you are looking for.

And yes your using myTown wrong in this case.

commented

I know I am, but that's a try for a workaround. And Botania registers things in a different way, I can't do what I was planning. I blocked right-click of all lenses 64 blocks near a town.

commented

Can you dropbox your myTown protection config, and the item dump? Then ping me when you get it?

commented

My old file is here, in the post, and my new is here:
https://github.com/MagiTechServer/MyTown2-Protections/commit/36d3a0cf8a10f29349410d89a2bd3f09aa203c3f
The NEI dump I do later, and ping you

commented

Just did it, @bookerthegeek

Botania:lens,8213,false,Botania,vazkii.botania.common.item.lens.ItemLens

item.zip