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>

public class TileEntityBarrel extends AbstractTileEntityBarrel implements ITickable
  • 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_ITEMS

    Fields inherited from class net.minecraft.world.level.block.entity.BlockEntity

    level, remove, worldPosition

    Fields inherited from interface net.minecraftforge.common.extensions.IForgeBlockEntity

    INFINITE_EXTENT_AABB
  • Constructor Summary

    Constructors
    Constructor
    Description
    TileEntityBarrel(net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    addItem(net.minecraft.world.item.ItemStack item)
    Lets the AI insert items into the barrel.
    boolean
    Checks if the barrel is composting
    int
    Returns the number of items that the block contains
    net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket
     
    @NotNull net.minecraft.nbt.CompoundTag
     
    final void
    handleUpdateTag(net.minecraft.nbt.CompoundTag tag)
     
    boolean
    Returns if the barrel has finished composting
    void
    load(net.minecraft.nbt.CompoundTag compound)
     
    void
    onDataPacket(net.minecraft.network.Connection net, net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket packet)
     
    net.minecraft.world.item.ItemStack
    retrieveCompost(double multiplier)
    Lets the AI retrieve the compost when the barrel has done processing it.
    void
    saveAdditional(net.minecraft.nbt.CompoundTag compound)
     
    void
     
    void
    Update method to be called by Minecraft every tick
    void
    updateBlock(net.minecraft.world.level.Level worldIn)
    Updates the block between the server and the client
    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
    boolean
    useBarrel(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, triggerEvent

    Methods inherited from class net.minecraftforge.common.capabilities.CapabilityProvider

    areCapsCompatible, areCapsCompatible, deserializeCaps, gatherCapabilities, gatherCapabilities, gatherCapabilities, getCapabilities, getCapability, invalidateCaps, reviveCaps, serializeCaps

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface net.minecraftforge.common.capabilities.ICapabilityProvider

    getCapability, getCapability

    Methods inherited from interface net.minecraftforge.common.extensions.IForgeBlockEntity

    deserializeNBT, getModelData, getRenderBoundingBox, hasCustomOutlineRendering, onLoad, requestModelDataUpdate, serializeNBT

    Methods inherited from interface com.minecolonies.api.tileentities.ITickable

    tick
  • 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
      Specified by:
      tick in interface ITickable
    • 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 world
      pos - the position
      state - the state of the block
      rand - 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 player
      itemstack - the itemStack on the hand of the player
      hitFace - 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:
      saveAdditional in class net.minecraft.world.level.block.entity.BlockEntity
    • load

      public void load(net.minecraft.nbt.CompoundTag compound)
      Overrides:
      load in class net.minecraft.world.level.block.entity.BlockEntity
    • getUpdatePacket

      public net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket getUpdatePacket()
      Overrides:
      getUpdatePacket in class net.minecraft.world.level.block.entity.BlockEntity
    • getUpdateTag

      @NotNull public @NotNull net.minecraft.nbt.CompoundTag getUpdateTag()
      Overrides:
      getUpdateTag in class net.minecraft.world.level.block.entity.BlockEntity
    • onDataPacket

      public void onDataPacket(net.minecraft.network.Connection net, net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket packet)
      Specified by:
      onDataPacket in interface net.minecraftforge.common.extensions.IForgeBlockEntity
    • setChanged

      public void setChanged()
      Overrides:
      setChanged in class net.minecraft.world.level.block.entity.BlockEntity
    • handleUpdateTag

      public final void handleUpdateTag(net.minecraft.nbt.CompoundTag tag)
      Specified by:
      handleUpdateTag in interface net.minecraftforge.common.extensions.IForgeBlockEntity
    • getItems

      public int getItems()
      Returns the number of items that the block contains
      Specified by:
      getItems in class AbstractTileEntityBarrel
      Returns:
      the number of items
    • isDone

      public boolean isDone()
      Returns if the barrel has finished composting
      Specified by:
      isDone in class AbstractTileEntityBarrel
      Returns:
      true if done, false if not
    • checkIfWorking

      public boolean checkIfWorking()
      Checks if the barrel is composting
      Specified by:
      checkIfWorking in class AbstractTileEntityBarrel
      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:
      addItem in class AbstractTileEntityBarrel
      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:
      retrieveCompost in class AbstractTileEntityBarrel
      Returns:
      The generated compost. If the barrel is not ready yet to be harvested, it will return an empty itemStack.