package net.minecraft.world.entity.vehicle; import net.minecraft.core.Direction; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.monster.piglin.PiglinAi; import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Player; import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.inventory.ChestMenu; import net.minecraft.world.item.Item; import net.minecraft.world.item.Items; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.ChestBlock; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.gameevent.GameEvent; public class MinecartChest extends AbstractMinecartContainer { public MinecartChest(EntityType entityType, Level level) { super(entityType, level); } public MinecartChest(Level level, double x, double y, double z) { super(EntityType.CHEST_MINECART, x, y, z, level); } @Override protected Item getDropItem() { return Items.CHEST_MINECART; } @Override public int getContainerSize() { return 27; } @Override public AbstractMinecart.Type getMinecartType() { return AbstractMinecart.Type.CHEST; } @Override public BlockState getDefaultDisplayBlockState() { return Blocks.CHEST.defaultBlockState().setValue(ChestBlock.FACING, Direction.NORTH); } @Override public int getDefaultDisplayOffset() { return 8; } @Override public AbstractContainerMenu createMenu(int containerId, Inventory playerInventory) { return ChestMenu.threeRows(containerId, playerInventory, this); } @Override public void stopOpen(Player player) { this.level().gameEvent(GameEvent.CONTAINER_CLOSE, this.position(), GameEvent.Context.of(player)); } @Override public InteractionResult interact(Player player, InteractionHand hand) { InteractionResult interactionResult = this.interactWithContainerVehicle(player); if (interactionResult.consumesAction()) { this.gameEvent(GameEvent.CONTAINER_OPEN, player); PiglinAi.angerNearbyPiglins(player, true); } return interactionResult; } }