Class TileEntityBarrel
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.AbstractTileEntityBarrel
com.minecolonies.core.tileentities.TileEntityBarrel
- All Implemented Interfaces:
ITickable,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>
-
Nested Class Summary
Nested 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
Fields inherited from class com.minecolonies.api.tileentities.AbstractTileEntityBarrel
MAX_ITEMSFields 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
ConstructorsConstructorDescriptionTileEntityBarrel(net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state) -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddItem(net.minecraft.world.item.ItemStack item) Lets the AI insert items into the barrel.booleanChecks if the barrel is compostingintgetItems()Returns the number of items that the block containsnet.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket@NotNull net.minecraft.nbt.CompoundTagfinal voidhandleUpdateTag(net.minecraft.nbt.CompoundTag tag) booleanisDone()Returns if the barrel has finished compostingvoidload(net.minecraft.nbt.CompoundTag compound) voidonDataPacket(net.minecraft.network.Connection net, net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket packet) net.minecraft.world.item.ItemStackretrieveCompost(double multiplier) Lets the AI retrieve the compost when the barrel has done processing it.voidsaveAdditional(net.minecraft.nbt.CompoundTag compound) voidvoidtick()Update method to be called by Minecraft every tickvoidupdateBlock(net.minecraft.world.level.Level worldIn) Updates the block between the server and the clientvoidupdateTick(net.minecraft.world.level.Level worldIn, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state, Random rand) Method that does compost ticks if needed or spawns particles if finishedbooleanuseBarrel(net.minecraft.world.entity.player.Player playerIn, net.minecraft.world.item.ItemStack itemstack, @Nullable net.minecraft.core.Direction hitFace) Method called when a player uses the block.Methods inherited from class net.minecraft.world.level.block.entity.BlockEntity
addEntityType, clearRemoved, fillCrashReportCategory, getBlockPos, getBlockState, getLevel, getPersistentData, getPosFromTag, getType, hasLevel, isRemoved, loadStatic, onChunkUnloaded, onlyOpCanSetNbt, saveToItem, saveWithFullMetadata, saveWithId, saveWithoutMetadata, setBlockState, 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, hasCustomOutlineRendering, onLoad, requestModelDataUpdate, serializeNBT
-
Constructor Details
-
TileEntityBarrel
public TileEntityBarrel(net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state)
-
-
Method Details
-
tick
public void tick()Update method to be called by Minecraft every tick -
updateTick
public void updateTick(net.minecraft.world.level.Level worldIn, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state, Random rand) Method that does compost ticks if needed or spawns particles if finished- Parameters:
worldIn- the worldpos- the positionstate- the state of the blockrand- Random class
-
useBarrel
public boolean useBarrel(net.minecraft.world.entity.player.Player playerIn, net.minecraft.world.item.ItemStack itemstack, @Nullable @Nullable net.minecraft.core.Direction hitFace) Method called when a player uses the block. Takes the needed items from the player.- Parameters:
playerIn- the playeritemstack- the itemStack on the hand of the playerhitFace- the side of the barrel the player hit. Passing null when composting is complete will insert resulting compost directly into inventory, spawning overflow as an ItemEntity- Returns:
- if the barrel took any item
-
updateBlock
public void updateBlock(net.minecraft.world.level.Level worldIn) Updates the block between the server and the client- Parameters:
worldIn- the world
-
saveAdditional
public void saveAdditional(net.minecraft.nbt.CompoundTag compound) - Overrides:
saveAdditionalin classnet.minecraft.world.level.block.entity.BlockEntity
-
load
public void load(net.minecraft.nbt.CompoundTag compound) - Overrides:
loadin classnet.minecraft.world.level.block.entity.BlockEntity
-
getUpdatePacket
public net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket getUpdatePacket()- Overrides:
getUpdatePacketin classnet.minecraft.world.level.block.entity.BlockEntity
-
getUpdateTag
@NotNull public @NotNull net.minecraft.nbt.CompoundTag getUpdateTag()- Overrides:
getUpdateTagin classnet.minecraft.world.level.block.entity.BlockEntity
-
onDataPacket
public void onDataPacket(net.minecraft.network.Connection net, net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket packet) - Specified by:
onDataPacketin interfacenet.minecraftforge.common.extensions.IForgeBlockEntity
-
setChanged
public void setChanged()- Overrides:
setChangedin classnet.minecraft.world.level.block.entity.BlockEntity
-
handleUpdateTag
public final void handleUpdateTag(net.minecraft.nbt.CompoundTag tag) - Specified by:
handleUpdateTagin interfacenet.minecraftforge.common.extensions.IForgeBlockEntity
-
getItems
public int getItems()Returns the number of items that the block contains- Specified by:
getItemsin classAbstractTileEntityBarrel- Returns:
- the number of items
-
isDone
public boolean isDone()Returns if the barrel has finished composting- Specified by:
isDonein classAbstractTileEntityBarrel- Returns:
- true if done, false if not
-
checkIfWorking
public boolean checkIfWorking()Checks if the barrel is composting- Specified by:
checkIfWorkingin classAbstractTileEntityBarrel- Returns:
- true if the number of items is equal to the maximum. If not, false.
-
addItem
public boolean addItem(net.minecraft.world.item.ItemStack item) Lets the AI insert items into the barrel.- Specified by:
addItemin classAbstractTileEntityBarrel- Parameters:
item- the itemStack to be placed inside it.- Returns:
- false if the item couldn't be cosumed. True if it could
-
retrieveCompost
public net.minecraft.world.item.ItemStack retrieveCompost(double multiplier) Lets the AI retrieve the compost when the barrel has done processing it.- Specified by:
retrieveCompostin classAbstractTileEntityBarrel- Returns:
- The generated compost. If the barrel is not ready yet to be harvested, it will return an empty itemStack.
-