Class DamageableBlockEntity

java.lang.Object
net.neoforged.neoforge.attachment.AttachmentHolder
net.minecraft.world.level.block.entity.BlockEntity
tech.anonymoushacker1279.immersiveweapons.blockentity.DamageableBlockEntity
All Implemented Interfaces:
net.minecraft.core.TypedInstance<net.minecraft.world.level.block.entity.BlockEntityType<?>>, net.minecraft.util.debug.DebugValueSource, net.neoforged.neoforge.attachment.IAttachmentHolder, net.neoforged.neoforge.common.extensions.IBlockEntityExtension

public class DamageableBlockEntity extends net.minecraft.world.level.block.entity.BlockEntity
  • Nested Class Summary

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

    net.neoforged.neoforge.attachment.AttachmentHolder.AsField

    Nested classes/interfaces inherited from interface net.minecraft.util.debug.DebugValueSource

    net.minecraft.util.debug.DebugValueSource.Registration, net.minecraft.util.debug.DebugValueSource.ValueGetter<T>
  • Field Summary

    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
    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
    getUpdateTag(net.minecraft.core.HolderLookup.Provider registries)
     
    void
    loadAdditional(net.minecraft.world.level.storage.ValueInput valueInput)
     
    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 ingredient matches this block's repair item.
    protected void
    saveAdditional(net.minecraft.world.level.storage.ValueOutput valueOutput)
     
    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, applyComponents, applyComponentsFromItemStack, applyImplicitComponents, clearRemoved, collectComponents, collectImplicitComponents, components, fillCrashReportCategory, getAndClearAttachmentTypesToSync, getBlockPos, getBlockState, getLevel, getNameForReporting, getPersistentData, getPosFromTag, getType, hasLevel, isRemoved, isValidBlockState, loadCustomOnly, loadStatic, loadWithComponents, parseCustomNameSafe, preRemoveSideEffects, problemPath, registerDebugValues, removeComponentsFromTag, removeData, saveCustomOnly, saveCustomOnly, saveWithFullMetadata, saveWithFullMetadata, saveWithId, saveWithoutMetadata, saveWithoutMetadata, setBlockState, setChanged, setChanged, setComponents, setData, setLevel, setRemoved, syncData, triggerEvent, typeHolder

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

    deserializeAttachments, getData, getExistingDataOrNull, hasAttachments, hasData, serializeAttachments

    Methods inherited from class Object

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

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

    getData, getExistingData, getExistingData, getExistingDataOrNull, hasData, removeData, setData, syncData

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

    applyStructureRotation, getModelData, handleUpdateTag, hasCustomOutlineRendering, invalidateCapabilities, onChunkUnloaded, onDataPacket, onLoad, requestModelDataUpdate

    Methods inherited from interface net.minecraft.core.TypedInstance

    is, is, is, is, is, tags
  • 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

    • loadAdditional

      public void loadAdditional(net.minecraft.world.level.storage.ValueInput valueInput)
      Overrides:
      loadAdditional in class net.minecraft.world.level.block.entity.BlockEntity
    • saveAdditional

      protected void saveAdditional(net.minecraft.world.level.storage.ValueOutput valueOutput)
      Overrides:
      saveAdditional in class net.minecraft.world.level.block.entity.BlockEntity
    • getUpdateTag

      public net.minecraft.nbt.CompoundTag getUpdateTag(net.minecraft.core.HolderLookup.Provider registries)
      Overrides:
      getUpdateTag in class net.minecraft.world.level.block.entity.BlockEntity
    • 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
    • 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 ingredient 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