Class TileEntityBarrel

java.lang.Object
net.neoforged.neoforge.attachment.AttachmentHolder
net.minecraft.world.level.block.entity.BlockEntity
com.minecolonies.api.tileentities.AbstractTileEntityBarrel
com.minecolonies.core.tileentities.TileEntityBarrel
All Implemented Interfaces:
ITickable, net.neoforged.neoforge.attachment.IAttachmentHolder, net.neoforged.neoforge.common.extensions.IBlockEntityExtension

public class TileEntityBarrel extends AbstractTileEntityBarrel implements ITickable
  • Nested Class Summary

    Nested classes/interfaces inherited from class net.minecraft.world.level.block.entity.BlockEntity

    net.minecraft.world.level.block.entity.BlockEntity.DataComponentInput

    Nested classes/interfaces inherited from class net.neoforged.neoforge.attachment.AttachmentHolder

    net.neoforged.neoforge.attachment.AttachmentHolder.AsField
  • 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 class net.neoforged.neoforge.attachment.AttachmentHolder

    ATTACHMENTS_NBT_KEY
  • 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
    getUpdateTag(net.minecraft.core.HolderLookup.Provider provider)
     
    final void
    handleUpdateTag(net.minecraft.nbt.CompoundTag tag, net.minecraft.core.HolderLookup.Provider provider)
     
    boolean
    Returns if the barrel has finished composting
    void
    loadAdditional(net.minecraft.nbt.CompoundTag compound, net.minecraft.core.HolderLookup.Provider provider)
     
    void
    onDataPacket(net.minecraft.network.Connection net, net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket packet, net.minecraft.core.HolderLookup.Provider provider)
     
    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, net.minecraft.core.HolderLookup.Provider provider)
     
    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, applyComponents, applyComponentsFromItemStack, applyImplicitComponents, clearRemoved, collectComponents, collectImplicitComponents, components, fillCrashReportCategory, getBlockPos, getBlockState, getLevel, getPersistentData, getPosFromTag, getType, hasLevel, isRemoved, isValidBlockState, loadCustomOnly, loadStatic, loadWithComponents, onlyOpCanSetNbt, parseCustomNameSafe, removeComponentsFromTag, removeData, saveCustomAndMetadata, saveCustomOnly, saveToItem, saveWithFullMetadata, saveWithId, saveWithoutMetadata, setBlockState, setChanged, setComponents, setData, setLevel, setRemoved, triggerEvent

    Methods inherited from class net.neoforged.neoforge.attachment.AttachmentHolder

    deserializeAttachments, getData, getExistingData, hasAttachments, hasData, serializeAttachments

    Methods inherited from class java.lang.Object

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

    Methods inherited from interface net.neoforged.neoforge.attachment.IAttachmentHolder

    getData, getExistingData, hasData, removeData, setData

    Methods inherited from interface net.neoforged.neoforge.common.extensions.IBlockEntityExtension

    getModelData, hasCustomOutlineRendering, invalidateCapabilities, onChunkUnloaded, onLoad, requestModelDataUpdate

    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, @NotNull net.minecraft.core.HolderLookup.Provider provider)
      Overrides:
      saveAdditional in class net.minecraft.world.level.block.entity.BlockEntity
    • loadAdditional

      public void loadAdditional(net.minecraft.nbt.CompoundTag compound, @NotNull net.minecraft.core.HolderLookup.Provider provider)
      Overrides:
      loadAdditional 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(@NotNull net.minecraft.core.HolderLookup.Provider provider)
      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, @NotNull net.minecraft.core.HolderLookup.Provider provider)
      Specified by:
      onDataPacket in interface net.neoforged.neoforge.common.extensions.IBlockEntityExtension
    • 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, @NotNull net.minecraft.core.HolderLookup.Provider provider)
      Specified by:
      handleUpdateTag in interface net.neoforged.neoforge.common.extensions.IBlockEntityExtension
    • 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.