Open jazzpi opened 7 years ago
The same issue also occurs when trying to autoplace a pedestal:
[20:48:46] [Server thread/WARN] [OpenComputers]: Unexpected error in Lua callback.
java.lang.NullPointerException
at net.minecraft.item.ItemBlock.func_180614_a(ItemBlock.java:49) ~[acl.class:?]
at mcjty.lib.compat.CompatItemBlock.clOnItemUse(CompatItemBlock.java:39) ~[CompatItemBlock.class:?]
at mcjty.lib.compat.CompatItemBlock.func_180614_a(CompatItemBlock.java:35) ~[CompatItemBlock.class:?]
at net.minecraftforge.common.ForgeHooks.onPlaceItemIntoWorld(ForgeHooks.java:780) ~[ForgeHooks.class:?]
at net.minecraft.item.ItemStack.func_179546_a(ItemStack.java:144) ~[adz.class:?]
at li.cil.oc.server.agent.Player.li$cil$oc$server$agent$Player$$tryPlaceBlockWhileHandlingFunnySpecialCases(Player.scala:475) ~[Player.class:?]
at li.cil.oc.server.agent.Player$$anonfun$placeBlock$1.apply(Player.scala:292) ~[Player$$anonfun$placeBlock$1.class:?]
at li.cil.oc.server.agent.Player$$anonfun$placeBlock$1.apply(Player.scala:287) ~[Player$$anonfun$placeBlock$1.class:?]
at li.cil.oc.server.agent.Player.callUsingItemInSlot(Player.scala:438) ~[Player.class:?]
at li.cil.oc.server.agent.Player.placeBlock(Player.scala:287) ~[Player.class:?]
at li.cil.oc.server.component.Agent$$anonfun$place$1.apply(Agent.scala:258) ~[Agent$$anonfun$place$1.class:?]
at li.cil.oc.server.component.Agent$$anonfun$place$1.apply(Agent.scala:252) ~[Agent$$anonfun$place$1.class:?]
at scala.collection.immutable.List.foreach(List.scala:383) ~[List.class:?]
at li.cil.oc.server.component.Agent$class.place(Agent.scala:252) ~[Agent$class.class:?]
at li.cil.oc.server.component.Drone.place(Drone.scala:27) ~[Drone.class:?]
at generated.li.cil.oc.CallWrapper_li_cil_oc_server_component_Drone_place.call(Unknown Source) ~[?:?]
at li.cil.oc.server.machine.Callbacks$ComponentCallback.apply(Callbacks.scala:123) ~[Callbacks$ComponentCallback.class:?]
at li.cil.oc.server.network.Component$class.invoke(Component.scala:112) ~[Component$class.class:?]
at li.cil.oc.server.network.Network$ComponentConnectorBuilder$$anon$1.invoke(Network.scala:623) ~[Network$ComponentConnectorBuilder$$anon$1.class:?]
at li.cil.oc.server.machine.Machine.invoke(Machine.scala:358) ~[Machine.class:?]
at li.cil.oc.server.machine.luac.ComponentAPI$$anonfun$initialize$5$$anonfun$apply$6.apply(ComponentAPI.scala:78) ~[ComponentAPI$$anonfun$initialize$5$$anonfun$apply$6.class:?]
at li.cil.oc.server.machine.luac.ComponentAPI$$anonfun$initialize$5$$anonfun$apply$6.apply(ComponentAPI.scala:78) ~[ComponentAPI$$anonfun$initialize$5$$anonfun$apply$6.class:?]
at li.cil.oc.server.machine.luac.NativeLuaArchitecture.invoke(NativeLuaArchitecture.scala:55) [NativeLuaArchitecture.class:?]
at li.cil.oc.server.machine.luac.ComponentAPI$$anonfun$initialize$5.apply(ComponentAPI.scala:78) [ComponentAPI$$anonfun$initialize$5.class:?]
at li.cil.oc.server.machine.luac.ComponentAPI$$anonfun$initialize$5.apply(ComponentAPI.scala:74) [ComponentAPI$$anonfun$initialize$5.class:?]
at li.cil.oc.util.ExtendedLuaState$ExtendedLuaState$$anon$1.invoke(ExtendedLuaState.scala:24) [ExtendedLuaState$ExtendedLuaState$$anon$1.class:?]
at li.cil.repack.com.naef.jnlua.LuaState.lua_pcall(Native Method) [LuaState.class:?]
at li.cil.repack.com.naef.jnlua.LuaState.call(LuaState.java:677) [LuaState.class:?]
at li.cil.oc.server.machine.luac.NativeLuaArchitecture.runSynchronized(NativeLuaArchitecture.scala:177) [NativeLuaArchitecture.class:?]
at li.cil.oc.server.machine.Machine.update(Machine.scala:562) [Machine.class:?]
at li.cil.oc.common.entity.Drone.func_70071_h_(Drone.scala:357) [Drone.class:?]
at net.minecraft.world.World.func_72866_a(World.java:1964) [aid.class:?]
at net.minecraft.world.WorldServer.func_72866_a(WorldServer.java:839) [ls.class:?]
at net.minecraft.world.World.func_72870_g(World.java:1934) [aid.class:?]
at net.minecraft.world.World.func_72939_s(World.java:1750) [aid.class:?]
at net.minecraft.world.WorldServer.func_72939_s(WorldServer.java:620) [ls.class:?]
at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:709) [MinecraftServer.class:?]
at net.minecraft.server.dedicated.DedicatedServer.func_71190_q(DedicatedServer.java:387) [ld.class:?]
at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:613) [MinecraftServer.class:?]
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:471) [MinecraftServer.class:?]
at java.lang.Thread.run(Thread.java:745) [?:1.8.0_121]
Sorry but report to those mod authors. The Pedestal is a basic block and doesn't have any placement logic. If those mods crash while trying to place that then it is most likely their fault. I leave this open for now because I'm not 100% certain but I really would like to hear what they say about this issue.
BTW, the pedestal itself can place crystals just fine
Here the referenz how ActuallyAdditions place the block: https://github.com/Ellpeck/ActuallyAdditions/blob/master/src/main/java/de/ellpeck/actuallyadditions/mod/util/WorldUtil.java#L242
Hmm, one thing I notice is that you are using the global FakePlayer instead of your own (i.e. you're using FakePlayerFactory.getMinecraft() instead of FakePlayerFactory.get()). That means your fake player can be using a different active hand. And in your code you use MAIN_HAND everywhere except for one place:
fake.getHeldItemMainhand().onItemUse(fake, world, offsetPos, **fake.getActiveHand()**, side.getOpposite(), 0.5F, 0.5F, 0.5F);
So if fake.getActiveHand() happens to be set to OFF_HAND by another mod then this will fail. Other then that I have no explanation.
I do recommend that you change your code to use MAIN_HAND instead of fake.getActiveHand() there though
It might also be a good idea to not use the global fake player but create a custom one using 'get' and your own UUID. I do that in rftools too
onItemUse() is a bit tricky. It got the hand parameter added to it when hands were introduced, but all vanilla items conform to the pattern "use the stack given as param, not what the player has in the given hand". So it'd not be unreasonable to call this the correct or expected behavior and your ignoring of the stack unexpected.
(Ender IO also expects the stack parameter to be honored and doesn't set the fake player's inventory in many cases.)
Edit: I'm referencing this: https://github.com/McJty/compatlayer/blob/1.10/src/main/java/mcjty/lib/compat/CompatItemBlock.java#L35-L39
Edit 2: AAs using of fake.getActiveHand() for the call when setting the item into MAIN_HAND is obviously wrong. Not arguing with that.
I have to ignore the stack because in 1.11 that stack parameter is gone. And to make my mods compatible with 1.10 and 1.11 I adapted to this in compatlayer. But that does mean that I cannot use the given stack parameter in my onItemUse implementations since I don't have that parameter
Seems you should have bounced the other way around... ;)
No, because the idea of compatlayer is to have code that is as close to 1.11 as possible while being compatible with 1.10. So if the stack parameter is gone in 1.11 then that's how my code should be too.
I'm using the Direwolf20 1.10 pack (version 1.5.1) with these mod versions:
Trying to auto-place resonant crystals both with OpenComputer drones and Actually Additions causes a NullPointerException and doesn't place the crystal (doesn't crash the game though):
OC:
Actually Additions: