Class DamageableBlockEntity

java.lang.Object
net.minecraftforge.common.capabilities.CapabilityProvider<net.minecraft.world.level.block.entity.BlockEntity>
net.minecraft.world.level.block.entity.BlockEntity
tech.anonymoushacker1279.immersiveweapons.blockentity.DamageableBlockEntity
All Implemented Interfaces:
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 DamageableBlockEntity extends net.minecraft.world.level.block.entity.BlockEntity
  • 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 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
    DamageableBlockEntity(net.minecraft.core.BlockPos blockPos, net.minecraft.world.level.block.state.BlockState blockState)
     
    DamageableBlockEntity(net.minecraft.core.BlockPos blockPos, net.minecraft.world.level.block.state.BlockState blockState, int maxHealth, int stages)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    float
    calculateDamage(float startingDamage, float reductionPerStageMultiplier)
    Calculate the damage dealt by the block based on the starting damage and the reduction per stage.
    net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket
    Get the entity update packet.
    net.minecraft.nbt.CompoundTag
    Get the update tag.
    void
    load(net.minecraft.nbt.CompoundTag nbt)
    Load NBT data.
    boolean
    repair(net.minecraft.world.item.ItemStack repairStack, net.minecraft.world.item.Item repairItem, net.minecraft.world.level.block.state.BlockState state, net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, net.minecraft.world.entity.player.Player player, net.minecraft.world.level.block.state.properties.IntegerProperty damageStage)
    Repair the block if the given stack matches this block's repair item.
    protected void
    saveAdditional(net.minecraft.nbt.CompoundTag tag)
    Save NBT data.
    void
    takeDamage(net.minecraft.world.level.block.state.BlockState state, net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.properties.IntegerProperty damageStage)
    Damage the block, which takes care of stage changes and destruction.

    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, 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, handleUpdateTag, hasCustomOutlineRendering, onDataPacket, onLoad, requestModelDataUpdate, serializeNBT
  • Constructor Details

    • DamageableBlockEntity

      public DamageableBlockEntity(net.minecraft.core.BlockPos blockPos, net.minecraft.world.level.block.state.BlockState blockState, int maxHealth, int stages)
    • DamageableBlockEntity

      public DamageableBlockEntity(net.minecraft.core.BlockPos blockPos, net.minecraft.world.level.block.state.BlockState blockState)
  • Method Details

    • load

      public void load(net.minecraft.nbt.CompoundTag nbt)
      Load NBT data.
      Overrides:
      load in class net.minecraft.world.level.block.entity.BlockEntity
      Parameters:
      nbt - the CompoundNBT to load
    • saveAdditional

      protected void saveAdditional(net.minecraft.nbt.CompoundTag tag)
      Save NBT data.
      Overrides:
      saveAdditional in class net.minecraft.world.level.block.entity.BlockEntity
      Parameters:
      tag - the CompoundNBT to save
    • getUpdatePacket

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

      public net.minecraft.nbt.CompoundTag getUpdateTag()
      Get the update tag.
      Overrides:
      getUpdateTag in class net.minecraft.world.level.block.entity.BlockEntity
      Returns:
      CompoundTag
    • takeDamage

      public void takeDamage(net.minecraft.world.level.block.state.BlockState state, net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.properties.IntegerProperty damageStage)
      Damage the block, which takes care of stage changes and destruction.
      Parameters:
      state - the BlockState of the block
      level - the Level the block is in
      pos - the BlockPos the block is at
    • repair

      public boolean repair(net.minecraft.world.item.ItemStack repairStack, net.minecraft.world.item.Item repairItem, net.minecraft.world.level.block.state.BlockState state, net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, net.minecraft.world.entity.player.Player player, net.minecraft.world.level.block.state.properties.IntegerProperty damageStage)
      Repair the block if the given stack matches this block's repair item. Each use of the repair item will repair the block by one stage.
      Parameters:
      repairStack - the ItemStack to attempt to repair the block with
      repairItem - the Item which this block is repairable with
      state - the BlockState of the block
      level - the Level the block is in
      pos - the BlockPos the block is at
      damageStage - the IntegerProperty of the block's damage stage
      Returns:
      true if the block was repaired, false otherwise
    • calculateDamage

      public float calculateDamage(float startingDamage, float reductionPerStageMultiplier)
      Calculate the damage dealt by the block based on the starting damage and the reduction per stage.
      Parameters:
      startingDamage - the starting damage a block will deal (like wooden spikes)
      reductionPerStageMultiplier - the reduction in damage per stage (i.e. 33% less)
      Returns:
      the adjusted damage