CraftTweaker

CraftTweaker

151M Downloads

Additional ItemBlock spawned on player.give with ItemPhysic Full

Oethever opened this issue ยท 7 comments

commented

Issue Description:

I found a very specific behaviour that is probably not intended, and is related to the command player.give(IItemStack) and the mod ItemPhysic Full. Here are the steps to reproduce:

  1. Set ItemPhysic's general.despawnItem config entry to 6040.
  2. Use the recipe added by the ZenScript below on a crafting table (1 Glass as input, 1 Stick as output, and 2 Dirt given with player.give in the recipe function).

I case the problem is on ItemPhysic's end, I submitted an issue: CreativeMD/ItemPhysic#125

What happens:

This results in the 2 blocks of Dirt being given in the player's inventory, and a new itemblock (stack size of 1) of dirt being spawn next to the player. This itemblock has a lifetime that seems to be proportional to ItemPhysic's general.despawnItem config entry, minus 6000 (e.g. if we set general.despawnItem to 6040, this itemblock will last 2 seconds).

What you expected to happen:

No additional itemblock to be spawn.

Script used:

https://pastebin.com/BYcyLfWR

crafttweaker.log file:

https://pastebin.com/tJPEpryR

Affected Versions:

  • Minecraft: 1.12.2
  • Forge: 14.23.5.2854
  • Crafttweaker: 4.1.20.574
  • ItemPhysic Full: 1.4.34
  • Using a server: no
commented

It works like a charm, thanks for your quick help!

commented

No problem!

commented

Can you reproduce without item physics?

commented

No, it works as intended without ItemPhysic. Without ItemPhysic, I can brielfy see an item of dirt being spawned but disappearing immediately. I suppose ItemPhysic extends the lifetime of this item.

commented

Try:

if !player.world.isRemote {
player.give(<minecraft:dirt> * 2);
}
commented

I used instead

if !player.world.isRemote() {
player.give(<minecraft:dirt> * 2);
}

(otherwise I get a NullPointerException on the condition) but the behaviour is exactly the same as before.

As a temporary fix, I am able to spawn items manually:

if !player.world.isRemote() {
    player.world.spawnEntity((<minecraft:dirt> * 2).createEntityItem(
        player.world, player.position.x, player.position.y, player.position.z));
}