Class AbstractTileEntityRack
java.lang.Object
net.minecraftforge.common.capabilities.CapabilityProvider<net.minecraft.world.level.block.entity.BlockEntity>
net.minecraft.world.level.block.entity.BlockEntity
com.minecolonies.api.tileentities.AbstractTileEntityRack
- All Implemented Interfaces:
net.minecraft.world.inventory.MenuConstructor,net.minecraft.world.MenuProvider,net.minecraftforge.common.capabilities.ICapabilityProvider,net.minecraftforge.common.capabilities.ICapabilityProviderImpl<net.minecraft.world.level.block.entity.BlockEntity>,net.minecraftforge.common.capabilities.ICapabilitySerializable<net.minecraft.nbt.CompoundTag>,net.minecraftforge.common.extensions.IForgeBlockEntity,net.minecraftforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>
- Direct Known Subclasses:
TileEntityRack
public abstract class AbstractTileEntityRack
extends net.minecraft.world.level.block.entity.BlockEntity
implements net.minecraft.world.MenuProvider
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class net.minecraftforge.common.capabilities.CapabilityProvider
net.minecraftforge.common.capabilities.CapabilityProvider.AsField<B extends net.minecraftforge.common.capabilities.ICapabilityProviderImpl<B>> -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected net.minecraft.core.BlockPosPos of the owning building.protected net.minecraftforge.items.ItemStackHandlerThe inventory of the tileEntity.protected booleanwhether this rack is in a warehouse or not.Fields inherited from class net.minecraft.world.level.block.entity.BlockEntity
level, remove, worldPositionFields inherited from interface net.minecraftforge.common.extensions.IForgeBlockEntity
INFINITE_EXTENT_AABB -
Constructor Summary
ConstructorsConstructorDescriptionAbstractTileEntityRack(net.minecraft.world.level.block.entity.BlockEntityType<?> tileEntityTypeIn, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state) Create a new rack.AbstractTileEntityRack(net.minecraft.world.level.block.entity.BlockEntityType<?> tileEntityTypeIn, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state, int size) Create a rack with a specific inventory size. -
Method Summary
Modifier and TypeMethodDescriptionabstract net.minecraftforge.items.ItemStackHandlercreateInventory(int slots) Create the inventory that belongs to the rack.abstract intgetCount(ItemStorage storage) Check if a similar/same item as the stack is in the inventory.abstract intgetCount(net.minecraft.world.item.ItemStack stack, boolean ignoreDamageValue, boolean ignoreNBT) Check if a similar/same item as the stack is in the inventory.abstract intGet the amount of free slots in the inventory.net.minecraftforge.items.IItemHandlerModifiableabstract intgetItemCount(Predicate<net.minecraft.world.item.ItemStack> predicate) abstract AbstractTileEntityRackGet the other double chest or null.abstract intGet the upgrade size.abstract booleanhasItemStack(@NotNull Predicate<net.minecraft.world.item.ItemStack> itemStackSelectionPredicate) Check if a similar/same item as the stack is in the inventory.abstract booleanhasItemStack(net.minecraft.world.item.ItemStack stack, int count, boolean ignoreDamageValue) Check if a similar/same item as the stack is in the inventory.abstract booleanhasItemStorage(ItemStorage storage, int count) Check if the itemStorage exists in the inventory.abstract booleanhasSimilarStack(@NotNull net.minecraft.world.item.ItemStack stack) Check if a similar stack is in the rack.abstract booleanisEmpty()Checks if the chest is empty.voidsetBuildingPos(net.minecraft.core.BlockPos pos) Set the building pos it belongs to.abstract voidsetInWarehouse(Boolean isInWarehouse) Set the value for inWarehouseprotected abstract voidUpdate the blockState of the rack.abstract voidScans through the whole storage and updates it.voidupdateWarehouseIfAvailable(net.minecraft.world.item.ItemStack stack) Update the warehouse if available with the updated stack.abstract voidUpgrade the rack by 1.Methods inherited from class net.minecraft.world.level.block.entity.BlockEntity
addEntityType, clearRemoved, fillCrashReportCategory, getBlockPos, getBlockState, getLevel, getPersistentData, getPosFromTag, getType, getUpdatePacket, getUpdateTag, hasLevel, isRemoved, load, loadStatic, onChunkUnloaded, onlyOpCanSetNbt, saveAdditional, saveToItem, saveWithFullMetadata, saveWithId, saveWithoutMetadata, setBlockState, setChanged, setChanged, setLevel, setRemoved, triggerEventMethods inherited from class net.minecraftforge.common.capabilities.CapabilityProvider
areCapsCompatible, areCapsCompatible, deserializeCaps, gatherCapabilities, gatherCapabilities, gatherCapabilities, getCapabilities, getCapability, invalidateCaps, reviveCaps, serializeCapsMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.minecraftforge.common.capabilities.ICapabilityProvider
getCapability, getCapabilityMethods inherited from interface net.minecraftforge.common.extensions.IForgeBlockEntity
deserializeNBT, getModelData, getRenderBoundingBox, handleUpdateTag, hasCustomOutlineRendering, onDataPacket, onLoad, requestModelDataUpdate, serializeNBTMethods inherited from interface net.minecraft.world.inventory.MenuConstructor
createMenuMethods inherited from interface net.minecraft.world.MenuProvider
getDisplayName
-
Field Details
-
inWarehouse
protected boolean inWarehousewhether this rack is in a warehouse or not. defaults to not set by the warehouse building upon being built -
buildingPos
protected net.minecraft.core.BlockPos buildingPosPos of the owning building. -
inventory
protected net.minecraftforge.items.ItemStackHandler inventoryThe inventory of the tileEntity.
-
-
Constructor Details
-
AbstractTileEntityRack
public AbstractTileEntityRack(net.minecraft.world.level.block.entity.BlockEntityType<?> tileEntityTypeIn, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state) Create a new rack.- Parameters:
tileEntityTypeIn- the specific block entity type.pos- the position.state- its state.
-
AbstractTileEntityRack
public AbstractTileEntityRack(net.minecraft.world.level.block.entity.BlockEntityType<?> tileEntityTypeIn, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state, int size) Create a rack with a specific inventory size.- Parameters:
tileEntityTypeIn- the specific block entity type.pos- the position.state- its state.size- the ack size.
-
-
Method Details
-
createInventory
public abstract net.minecraftforge.items.ItemStackHandler createInventory(int slots) Create the inventory that belongs to the rack.- Parameters:
slots- the number of slots.- Returns:
- the created inventory,
-
updateWarehouseIfAvailable
public void updateWarehouseIfAvailable(net.minecraft.world.item.ItemStack stack) Update the warehouse if available with the updated stack.- Parameters:
stack- the incoming stack.
-
setInWarehouse
Set the value for inWarehouse- Parameters:
isInWarehouse- is this rack in a warehouse?
-
getFreeSlots
public abstract int getFreeSlots()Get the amount of free slots in the inventory. This method checks the content list, it is therefore extremely fast.- Returns:
- the amount of free slots (an integer).
-
hasItemStack
public abstract boolean hasItemStack(net.minecraft.world.item.ItemStack stack, int count, boolean ignoreDamageValue) Check if a similar/same item as the stack is in the inventory. This method checks the content list, it is therefore extremely fast.- Parameters:
stack- the stack to check.count- the min count it should have.ignoreDamageValue- ignore the damage value.- Returns:
- true if so.
-
hasItemStorage
Check if the itemStorage exists in the inventory. This method checks the content list, it is therefore extremely fast.- Parameters:
storage- the storage to check.count- the min count it should have.- Returns:
- true if so.
-
getCount
public abstract int getCount(net.minecraft.world.item.ItemStack stack, boolean ignoreDamageValue, boolean ignoreNBT) Check if a similar/same item as the stack is in the inventory. And return the count if so.- Parameters:
stack- the stack to check.ignoreDamageValue- ignore the damage value.ignoreNBT- if nbt should be ignored.- Returns:
- the quantity or 0.
-
getCount
Check if a similar/same item as the stack is in the inventory. And return the count if so.- Parameters:
storage- the storage to match.- Returns:
- the quantity or 0.
-
hasItemStack
public abstract boolean hasItemStack(@NotNull @NotNull Predicate<net.minecraft.world.item.ItemStack> itemStackSelectionPredicate) Check if a similar/same item as the stack is in the inventory. This method checks the content list, it is therefore extremely fast.- Parameters:
itemStackSelectionPredicate- the predicate to test the stack against.- Returns:
- true if so.
-
hasSimilarStack
public abstract boolean hasSimilarStack(@NotNull @NotNull net.minecraft.world.item.ItemStack stack) Check if a similar stack is in the rack.- Parameters:
stack- stack to check.- Returns:
- a set of different results depending on the similarity metric.
-
upgradeRackSize
public abstract void upgradeRackSize()Upgrade the rack by 1. This adds 9 more slots and copies the inventory to the new one. -
setBuildingPos
public void setBuildingPos(net.minecraft.core.BlockPos pos) Set the building pos it belongs to.- Parameters:
pos- the pos of the building.
-
getUpgradeSize
public abstract int getUpgradeSize()Get the upgrade size.- Returns:
- the upgrade size.
-
getItemCount
-
updateItemStorage
public abstract void updateItemStorage()Scans through the whole storage and updates it. -
updateBlockState
protected abstract void updateBlockState()Update the blockState of the rack. Switch between connected, single, full and empty texture. -
getOtherChest
Get the other double chest or null.- Returns:
- the tileEntity of the other half or null.
-
isEmpty
public abstract boolean isEmpty()Checks if the chest is empty. This method checks the content list, it is therefore extremely fast.- Returns:
- true if so.
-
getInventory
public net.minecraftforge.items.IItemHandlerModifiable getInventory()
-