修复了集装箱的放置bug

This commit is contained in:
17146 2025-02-12 00:29:33 +08:00
parent a31702624f
commit 38b1ad9098

View file

@ -67,13 +67,15 @@ public class ContainerBlockItem extends BlockItem implements GeoItem {
public InteractionResult place(BlockPlaceContext pContext) { public InteractionResult place(BlockPlaceContext pContext) {
ItemStack stack = pContext.getItemInHand(); ItemStack stack = pContext.getItemInHand();
Player player = pContext.getPlayer(); Player player = pContext.getPlayer();
var res = super.place(pContext);
if (player != null) { if (player != null) {
var tag = BlockItem.getBlockEntityData(stack); var tag = BlockItem.getBlockEntityData(stack);
if (tag != null && tag.get("Entity") != null && pContext.canPlace()) { if (tag != null && tag.get("Entity") != null && res == InteractionResult.SUCCESS) {
player.getInventory().removeItem(stack); player.getInventory().removeItem(stack);
} }
} }
return super.place(pContext); return res;
} }
private PlayState predicate(AnimationState<ContainerBlockItem> event) { private PlayState predicate(AnimationState<ContainerBlockItem> event) {