Stability fix for backup itemstack on catched null TE errors

This commit is contained in:
grimmauld 2020-09-02 10:23:56 +02:00
parent c81e105964
commit f1cad974aa

View File

@ -39,8 +39,7 @@ public class DispenserMovementBehaviour extends DropperMovementBehaviour {
return;
}
int count = itemstack.getCount();
ItemStack backup = itemstack.copy();
// If none is there, try vanilla registry
try {
Vec3d facingVec = new Vec3d(context.state.get(DispenserBlock.FACING).getDirectionVec());
@ -54,7 +53,7 @@ public class DispenserMovementBehaviour extends DropperMovementBehaviour {
return;
}
} catch (NullPointerException e) {
itemstack.setCount(count); // Something went wrong with the TE being null in ContraptionBlockSource, reset the stack
itemstack = backup; // Something went wrong with the TE being null in ContraptionBlockSource, reset the stack
}
defaultBehaviour.dispense(itemstack, context, pos); // the default: launch the item