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.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 -
Field Summary
Fields inherited from class net.minecraft.world.level.block.entity.BlockEntity
level, remove, worldPositionFields inherited from class net.neoforged.neoforge.attachment.AttachmentHolder
ATTACHMENTS_NBT_KEY -
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.CompoundTaggetUpdateTag(net.minecraft.core.HolderLookup.Provider registries) voidloadAdditional(net.minecraft.world.level.storage.ValueInput valueInput) 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 ingredient matches this block's repair item.protected voidsaveAdditional(net.minecraft.world.level.storage.ValueOutput valueOutput) 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, applyComponents, applyComponentsFromItemStack, applyImplicitComponents, clearRemoved, collectComponents, collectImplicitComponents, components, fillCrashReportCategory, getBlockPos, getBlockState, getLevel, getNameForReporting, getPersistentData, getPosFromTag, getType, hasLevel, isRemoved, isValidBlockState, loadCustomOnly, loadStatic, loadWithComponents, parseCustomNameSafe, preRemoveSideEffects, problemPath, removeComponentsFromTag, removeData, saveCustomOnly, saveCustomOnly, saveWithFullMetadata, saveWithFullMetadata, saveWithId, saveWithoutMetadata, saveWithoutMetadata, setBlockState, setChanged, setChanged, setComponents, setData, setLevel, setRemoved, syncData, triggerEventMethods inherited from class net.neoforged.neoforge.attachment.AttachmentHolder
deserializeAttachments, getData, getExistingDataOrNull, hasAttachments, hasData, serializeAttachmentsMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.neoforged.neoforge.attachment.IAttachmentHolder
getData, getExistingData, getExistingData, getExistingDataOrNull, hasData, removeData, setData, syncDataMethods inherited from interface net.neoforged.neoforge.common.extensions.IBlockEntityExtension
getModelData, handleUpdateTag, invalidateCapabilities, onChunkUnloaded, onDataPacket, onLoad, requestModelDataUpdate
-
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:
loadAdditionalin classnet.minecraft.world.level.block.entity.BlockEntity
-
saveAdditional
protected void saveAdditional(net.minecraft.world.level.storage.ValueOutput valueOutput) - Overrides:
saveAdditionalin classnet.minecraft.world.level.block.entity.BlockEntity
-
getUpdateTag
public net.minecraft.nbt.CompoundTag getUpdateTag(net.minecraft.core.HolderLookup.Provider registries) - Overrides:
getUpdateTagin classnet.minecraft.world.level.block.entity.BlockEntity
-
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
-
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 ingredient 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
-