public class HopperBlockEntity extends LootableContainerBlockEntity implements Hopper, Tickable
Modifier and Type | Field and Description |
---|---|
private DefaultedList<ItemStack> |
inventory |
private long |
lastTickTime |
private int |
transferCooldown |
lootTableId, lootTableSeed
pos, removed, world
ABOVE_SHAPE, INPUT_AREA_SHAPE, INSIDE_SHAPE
Constructor and Description |
---|
HopperBlockEntity() |
Modifier and Type | Method and Description |
---|---|
private static boolean |
canExtract(Inventory inv,
ItemStack stack,
int slot,
Direction facing) |
private static boolean |
canInsert(Inventory inventory,
ItemStack stack,
int slot,
Direction side) |
private static boolean |
canMergeItems(ItemStack first,
ItemStack second) |
protected ScreenHandler |
createScreenHandler(int syncId,
PlayerInventory playerInventory) |
static boolean |
extract(Hopper hopper) |
private static boolean |
extract(Hopper hopper,
Inventory inventory,
int slot,
Direction side) |
static boolean |
extract(Inventory inventory,
ItemEntity itemEntity) |
void |
fromTag(BlockState state,
CompoundTag tag) |
private static IntStream |
getAvailableSlots(Inventory inventory,
Direction side) |
protected Text |
getContainerName() |
double |
getHopperX() |
double |
getHopperY() |
double |
getHopperZ() |
static Inventory |
getInputInventory(Hopper hopper) |
static List<ItemEntity> |
getInputItemEntities(Hopper hopper) |
static Inventory |
getInventoryAt(World world,
BlockPos blockPos) |
static Inventory |
getInventoryAt(World world,
double x,
double y,
double z) |
protected DefaultedList<ItemStack> |
getInvStackList() |
private Inventory |
getOutputInventory() |
private boolean |
insert() |
private boolean |
insertAndExtract(Supplier<Boolean> extractMethod) |
private boolean |
isDisabled() |
private boolean |
isFull() |
private static boolean |
isInventoryEmpty(Inventory inv,
Direction facing) |
private boolean |
isInventoryFull(Inventory inv,
Direction direction) |
private boolean |
needsCooldown() |
void |
onEntityCollided(Entity entity) |
ItemStack |
removeStack(int slot,
int amount)
Removes a specific number of items from the given slot.
|
private void |
setCooldown(int cooldown) |
protected void |
setInvStackList(DefaultedList<ItemStack> list) |
void |
setStack(int slot,
ItemStack stack) |
int |
size() |
void |
tick() |
CompoundTag |
toTag(CompoundTag tag) |
static ItemStack |
transfer(Inventory from,
Inventory to,
ItemStack stack,
Direction side) |
private static ItemStack |
transfer(Inventory from,
Inventory to,
ItemStack stack,
int slot,
Direction direction) |
canPlayerUse, checkLootInteraction, checkUnlocked, clear, createMenu, deserializeLootTable, getStack, isEmpty, removeStack, serializeLootTable, setLootTable, setLootTable
checkUnlocked, getCustomName, getDisplayName, getName, setCustomName
applyMirror, applyRotation, cancelRemoval, copyItemDataRequiresOperator, createFromTag, getCachedState, getPos, getSquaredRenderDistance, getType, getWorld, hasWorld, isRemoved, markDirty, markInvalid, markRemoved, onSyncedBlockEvent, populateCrashReport, resetBlock, setLocation, setPos, toInitialChunkDataTag, toUpdatePacket
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getInputAreaShape, getWorld
canPlayerUse, containsAny, count, getMaxCountPerStack, getStack, isEmpty, isValid, markDirty, onClose, onOpen, removeStack
hasCustomName
private DefaultedList<ItemStack> inventory
private int transferCooldown
private long lastTickTime
public void fromTag(BlockState state, CompoundTag tag)
fromTag
in class LockableContainerBlockEntity
public CompoundTag toTag(CompoundTag tag)
toTag
in class LockableContainerBlockEntity
public ItemStack removeStack(int slot, int amount)
removeStack
in interface Inventory
removeStack
in class LootableContainerBlockEntity
public void setStack(int slot, ItemStack stack)
setStack
in interface Inventory
setStack
in class LootableContainerBlockEntity
protected Text getContainerName()
getContainerName
in class LockableContainerBlockEntity
private boolean isFull()
private boolean insert()
public static boolean extract(Hopper hopper)
private static boolean extract(Hopper hopper, Inventory inventory, int slot, Direction side)
public static boolean extract(Inventory inventory, ItemEntity itemEntity)
public static ItemStack transfer(@Nullable Inventory from, Inventory to, ItemStack stack, @Nullable Direction side)
private static boolean canInsert(Inventory inventory, ItemStack stack, int slot, @Nullable Direction side)
private static boolean canExtract(Inventory inv, ItemStack stack, int slot, Direction facing)
private static ItemStack transfer(@Nullable Inventory from, Inventory to, ItemStack stack, int slot, @Nullable Direction direction)
public static List<ItemEntity> getInputItemEntities(Hopper hopper)
@Nullable public static Inventory getInventoryAt(World world, double x, double y, double z)
public double getHopperX()
getHopperX
in interface Hopper
public double getHopperY()
getHopperY
in interface Hopper
public double getHopperZ()
getHopperZ
in interface Hopper
private void setCooldown(int cooldown)
private boolean needsCooldown()
private boolean isDisabled()
protected DefaultedList<ItemStack> getInvStackList()
getInvStackList
in class LootableContainerBlockEntity
protected void setInvStackList(DefaultedList<ItemStack> list)
setInvStackList
in class LootableContainerBlockEntity
public void onEntityCollided(Entity entity)
protected ScreenHandler createScreenHandler(int syncId, PlayerInventory playerInventory)
createScreenHandler
in class LockableContainerBlockEntity