Record Class BlocksAttacks
java.lang.Object
java.lang.Record
net.minecraft.world.item.component.BlocksAttacks
public record BlocksAttacks(float blockDelaySeconds, float disableCooldownScale, List<BlocksAttacks.DamageReduction> damageReductions, BlocksAttacks.ItemDamageFunction itemDamage, Optional<TagKey<DamageType>> bypassedBy, Optional<Holder<SoundEvent>> blockSound, Optional<Holder<SoundEvent>> disableSound)
extends Record
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordstatic final record -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final floatThe field for theblockDelaySecondsrecord component.private final Optional<Holder<SoundEvent>> The field for theblockSoundrecord component.private final Optional<TagKey<DamageType>> The field for thebypassedByrecord component.static final com.mojang.serialization.Codec<BlocksAttacks> private final List<BlocksAttacks.DamageReduction> The field for thedamageReductionsrecord component.private final floatThe field for thedisableCooldownScalerecord component.private final Optional<Holder<SoundEvent>> The field for thedisableSoundrecord component.private final BlocksAttacks.ItemDamageFunctionThe field for theitemDamagerecord component.static final StreamCodec<RegistryFriendlyByteBuf, BlocksAttacks> -
Constructor Summary
ConstructorsConstructorDescriptionBlocksAttacks(float blockDelaySeconds, float disableCooldownScale, List<BlocksAttacks.DamageReduction> damageReductions, BlocksAttacks.ItemDamageFunction itemDamage, Optional<TagKey<DamageType>> bypassedBy, Optional<Holder<SoundEvent>> blockSound, Optional<Holder<SoundEvent>> disableSound) Creates an instance of aBlocksAttacksrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfloatReturns the value of theblockDelaySecondsrecord component.intReturns the value of theblockSoundrecord component.Returns the value of thebypassedByrecord component.Returns the value of thedamageReductionsrecord component.voiddisable(ServerLevel pLevel, LivingEntity pEntity, float pDuration, ItemStack pStack) private intdisableBlockingForTicks(float pDuration) floatReturns the value of thedisableCooldownScalerecord component.Returns the value of thedisableSoundrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.voidhurtBlockingItem(Level pLevel, ItemStack pStack, LivingEntity pEntity, InteractionHand pHand, float pDamage) voidhurtBlockingItem(Level pLevel, ItemStack pStack, LivingEntity pEntity, InteractionHand pHand, float pDamage, int fixedDamage) Returns the value of theitemDamagerecord component.voidonBlocked(ServerLevel pLevel, LivingEntity pEntity) floatresolveBlockedDamage(DamageSource pDamageSource, float pDamageAmount, double pHorizontalAngle) final StringtoString()Returns a string representation of this record class.
-
Field Details
-
blockDelaySeconds
private final float blockDelaySecondsThe field for theblockDelaySecondsrecord component. -
disableCooldownScale
private final float disableCooldownScaleThe field for thedisableCooldownScalerecord component. -
damageReductions
The field for thedamageReductionsrecord component. -
itemDamage
The field for theitemDamagerecord component. -
bypassedBy
The field for thebypassedByrecord component. -
blockSound
The field for theblockSoundrecord component. -
disableSound
The field for thedisableSoundrecord component. -
CODEC
-
STREAM_CODEC
-
-
Constructor Details
-
BlocksAttacks
public BlocksAttacks(float blockDelaySeconds, float disableCooldownScale, List<BlocksAttacks.DamageReduction> damageReductions, BlocksAttacks.ItemDamageFunction itemDamage, Optional<TagKey<DamageType>> bypassedBy, Optional<Holder<SoundEvent>> blockSound, Optional<Holder<SoundEvent>> disableSound) Creates an instance of aBlocksAttacksrecord class.- Parameters:
blockDelaySeconds- the value for theblockDelaySecondsrecord componentdisableCooldownScale- the value for thedisableCooldownScalerecord componentdamageReductions- the value for thedamageReductionsrecord componentitemDamage- the value for theitemDamagerecord componentbypassedBy- the value for thebypassedByrecord componentblockSound- the value for theblockSoundrecord componentdisableSound- the value for thedisableSoundrecord component
-
-
Method Details
-
onBlocked
-
disable
-
hurtBlockingItem
public void hurtBlockingItem(Level pLevel, ItemStack pStack, LivingEntity pEntity, InteractionHand pHand, float pDamage) -
hurtBlockingItem
public void hurtBlockingItem(Level pLevel, ItemStack pStack, LivingEntity pEntity, InteractionHand pHand, float pDamage, int fixedDamage) -
disableBlockingForTicks
private int disableBlockingForTicks(float pDuration) -
blockDelayTicks
public int blockDelayTicks() -
resolveBlockedDamage
public float resolveBlockedDamage(DamageSource pDamageSource, float pDamageAmount, double pHorizontalAngle) -
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
blockDelaySeconds
public float blockDelaySeconds()Returns the value of theblockDelaySecondsrecord component.- Returns:
- the value of the
blockDelaySecondsrecord component
-
disableCooldownScale
public float disableCooldownScale()Returns the value of thedisableCooldownScalerecord component.- Returns:
- the value of the
disableCooldownScalerecord component
-
damageReductions
Returns the value of thedamageReductionsrecord component.- Returns:
- the value of the
damageReductionsrecord component
-
itemDamage
Returns the value of theitemDamagerecord component.- Returns:
- the value of the
itemDamagerecord component
-
bypassedBy
Returns the value of thebypassedByrecord component.- Returns:
- the value of the
bypassedByrecord component
-
blockSound
Returns the value of theblockSoundrecord component.- Returns:
- the value of the
blockSoundrecord component
-
disableSound
Returns the value of thedisableSoundrecord component.- Returns:
- the value of the
disableSoundrecord component
-