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
  • Field Details

    • blockDelaySeconds

      private final float blockDelaySeconds
      The field for the blockDelaySeconds record component.
    • disableCooldownScale

      private final float disableCooldownScale
      The field for the disableCooldownScale record component.
    • damageReductions

      private final List<BlocksAttacks.DamageReduction> damageReductions
      The field for the damageReductions record component.
    • itemDamage

      private final BlocksAttacks.ItemDamageFunction itemDamage
      The field for the itemDamage record component.
    • bypassedBy

      private final Optional<TagKey<DamageType>> bypassedBy
      The field for the bypassedBy record component.
    • blockSound

      private final Optional<Holder<SoundEvent>> blockSound
      The field for the blockSound record component.
    • disableSound

      private final Optional<Holder<SoundEvent>> disableSound
      The field for the disableSound record component.
    • CODEC

      public static final com.mojang.serialization.Codec<BlocksAttacks> CODEC
    • STREAM_CODEC

      public static final StreamCodec<RegistryFriendlyByteBuf,BlocksAttacks> 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 a BlocksAttacks record class.
      Parameters:
      blockDelaySeconds - the value for the blockDelaySeconds record component
      disableCooldownScale - the value for the disableCooldownScale record component
      damageReductions - the value for the damageReductions record component
      itemDamage - the value for the itemDamage record component
      bypassedBy - the value for the bypassedBy record component
      blockSound - the value for the blockSound record component
      disableSound - the value for the disableSound record component
  • Method Details

    • onBlocked

      public void onBlocked(ServerLevel pLevel, LivingEntity pEntity)
    • disable

      public void disable(ServerLevel pLevel, LivingEntity pEntity, float pDuration, ItemStack pStack)
    • 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

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • blockDelaySeconds

      public float blockDelaySeconds()
      Returns the value of the blockDelaySeconds record component.
      Returns:
      the value of the blockDelaySeconds record component
    • disableCooldownScale

      public float disableCooldownScale()
      Returns the value of the disableCooldownScale record component.
      Returns:
      the value of the disableCooldownScale record component
    • damageReductions

      public List<BlocksAttacks.DamageReduction> damageReductions()
      Returns the value of the damageReductions record component.
      Returns:
      the value of the damageReductions record component
    • itemDamage

      public BlocksAttacks.ItemDamageFunction itemDamage()
      Returns the value of the itemDamage record component.
      Returns:
      the value of the itemDamage record component
    • bypassedBy

      public Optional<TagKey<DamageType>> bypassedBy()
      Returns the value of the bypassedBy record component.
      Returns:
      the value of the bypassedBy record component
    • blockSound

      public Optional<Holder<SoundEvent>> blockSound()
      Returns the value of the blockSound record component.
      Returns:
      the value of the blockSound record component
    • disableSound

      public Optional<Holder<SoundEvent>> disableSound()
      Returns the value of the disableSound record component.
      Returns:
      the value of the disableSound record component