Class DamageableBlockEntity
java.lang.Object
net.neoforged.neoforge.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.neoforged.neoforge.common.capabilities.ICapabilityProvider,net.neoforged.neoforge.common.capabilities.ICapabilityProviderImpl<net.minecraft.world.level.block.entity.BlockEntity>,net.neoforged.neoforge.common.capabilities.ICapabilitySerializable<net.minecraft.nbt.CompoundTag>,net.neoforged.neoforge.common.extensions.IBlockEntityExtension,net.neoforged.neoforge.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.neoforged.neoforge.common.capabilities.CapabilityProvider
net.neoforged.neoforge.common.capabilities.CapabilityProvider.AsField<B extends net.neoforged.neoforge.common.capabilities.ICapabilityProviderImpl<B>> -
Field Summary
Fields inherited from class net.minecraft.world.level.block.entity.BlockEntity
level, remove, worldPosition -
Constructor Summary
ConstructorsConstructorDescriptionDamageableBlockEntity(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 TypeMethodDescriptionfloatcalculateDamage(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.ClientboundBlockEntityDataPacketGet the entity update packet.net.minecraft.nbt.CompoundTagGet the update tag.voidload(net.minecraft.nbt.CompoundTag nbt) Load NBT data.booleanrepair(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 voidsaveAdditional(net.minecraft.nbt.CompoundTag tag) Save NBT data.voidtakeDamage(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, triggerEventMethods inherited from class net.neoforged.neoforge.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.neoforged.neoforge.common.extensions.IBlockEntityExtension
deserializeNBT, getModelData, handleUpdateTag, hasCustomOutlineRendering, onDataPacket, onLoad, requestModelDataUpdate, serializeNBTMethods inherited from interface net.neoforged.neoforge.common.capabilities.ICapabilityProvider
getCapability, getCapability
-
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:
loadin classnet.minecraft.world.level.block.entity.BlockEntity- Parameters:
nbt- theCompoundNBTto load
-
saveAdditional
protected void saveAdditional(net.minecraft.nbt.CompoundTag tag) Save NBT data.- Overrides:
saveAdditionalin classnet.minecraft.world.level.block.entity.BlockEntity- Parameters:
tag- theCompoundNBTto save
-
getUpdatePacket
public net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket getUpdatePacket()Get the entity update packet.- Overrides:
getUpdatePacketin classnet.minecraft.world.level.block.entity.BlockEntity- Returns:
- ClientboundBlockEntityDataPacket
-
getUpdateTag
public net.minecraft.nbt.CompoundTag getUpdateTag()Get the update tag.- Overrides:
getUpdateTagin classnet.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- theBlockStateof the blocklevel- theLevelthe block is inpos- theBlockPosthe 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- theItemStackto attempt to repair the block withrepairItem- theItemwhich this block is repairable withstate- theBlockStateof the blocklevel- theLevelthe block is inpos- theBlockPosthe block is atdamageStage- theIntegerPropertyof 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
-