Class MobEffect
java.lang.Object
net.minecraft.world.effect.MobEffect
- All Implemented Interfaces:
FeatureElement, IMobEffectExtension
- Direct Known Subclasses:
AbsorptionMobEffect, BadOmenMobEffect, HungerMobEffect, InfestedMobEffect, InstantenousMobEffect, OozingMobEffect, PoisonMobEffect, RaidOmenMobEffect, RegenerationMobEffect, WeavingMobEffect, WindChargedMobEffect, WitherMobEffect
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intprivate final Map<Holder<Attribute>, MobEffect.AttributeTemplate> Contains a Map of the AttributeModifiers registered by potionsprivate intprivate intprivate intprivate final MobEffectCategoryprivate final intprivate @Nullable Stringprivate final Function<MobEffectInstance, ParticleOptions> private FeatureFlagSetprivate Optional<SoundEvent> static final StreamCodec<RegistryFriendlyByteBuf, Holder<MobEffect>> Fields inherited from interface FeatureElement
FILTERED_REGISTRIES -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedMobEffect(MobEffectCategory category, int color) protectedMobEffect(MobEffectCategory category, int color, Function<MobEffectInstance, ParticleOptions> particleFactory) Neo: Constructor that can take in the particle factory as a function of theMobEffectInstance.protectedMobEffect(MobEffectCategory category, int color, ParticleOptions particleOptions) -
Method Summary
Modifier and TypeMethodDescriptionaddAttributeModifier(Holder<Attribute> attribute, Identifier id, double amount, AttributeModifier.Operation operation) addAttributeModifier(Holder<Attribute> attribute, Identifier id, AttributeModifier.Operation operation, it.unimi.dsi.fastutil.ints.Int2DoubleFunction curve) Neo: attribute template with custom level curve, for mob effects providing non-linear attribute modifiers.voidaddAttributeModifiers(AttributeMap attributes, int amplifier) booleanapplyEffectTick(ServerLevel serverLevel, LivingEntity mob, int amplification) voidapplyInstantenousEffect(ServerLevel level, @Nullable Entity source, @Nullable Entity owner, LivingEntity mob, int amplification, double scale) voidcreateModifiers(int amplifier, BiConsumer<Holder<Attribute>, AttributeModifier> consumer) createParticleOptions(MobEffectInstance mobEffectInstance) intintintintgetColor()protected StringbooleanbooleanvoidonEffectAdded(LivingEntity mob, int amplifier) voidonEffectStarted(LivingEntity mob, int amplifier) voidonMobHurt(ServerLevel level, LivingEntity mob, int amplifier, DamageSource source, float damage) voidonMobRemoved(ServerLevel level, LivingEntity mob, int amplifier, Entity.RemovalReason reason) voidremoveAttributeModifiers(AttributeMap attributes) requiredFeatures(FeatureFlag... flags) setBlendDuration(int ticks) setBlendDuration(int inTicks, int outTicks, int outAdvanceTicks) booleanshouldApplyEffectTickThisTick(int tickCount, int amplification) withSoundOnAdded(SoundEvent soundEvent) Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface FeatureElement
isEnabledMethods inherited from interface IMobEffectExtension
getSortOrder
-
Field Details
-
CODEC
-
STREAM_CODEC
-
AMBIENT_ALPHA
private static final int AMBIENT_ALPHA -
attributeModifiers
Contains a Map of the AttributeModifiers registered by potions -
category
-
color
private final int color -
particleFactory
-
descriptionId
-
blendInDurationTicks
private int blendInDurationTicks -
blendOutDurationTicks
private int blendOutDurationTicks -
blendOutAdvanceTicks
private int blendOutAdvanceTicks -
soundOnAdded
-
requiredFeatures
-
-
Constructor Details
-
MobEffect
-
MobEffect
-
MobEffect
protected MobEffect(MobEffectCategory category, int color, Function<MobEffectInstance, ParticleOptions> particleFactory) Neo: Constructor that can take in the particle factory as a function of theMobEffectInstance. This should be used if the desiredParticleOptionsdepends on the presence of other registry entries.
-
-
Method Details
-
getBlendInDurationTicks
public int getBlendInDurationTicks() -
getBlendOutDurationTicks
public int getBlendOutDurationTicks() -
getBlendOutAdvanceTicks
public int getBlendOutAdvanceTicks() -
applyEffectTick
-
applyInstantenousEffect
public void applyInstantenousEffect(ServerLevel level, @Nullable Entity source, @Nullable Entity owner, LivingEntity mob, int amplification, double scale) -
shouldApplyEffectTickThisTick
public boolean shouldApplyEffectTickThisTick(int tickCount, int amplification) -
onEffectStarted
-
onEffectAdded
-
onMobRemoved
public void onMobRemoved(ServerLevel level, LivingEntity mob, int amplifier, Entity.RemovalReason reason) -
onMobHurt
public void onMobHurt(ServerLevel level, LivingEntity mob, int amplifier, DamageSource source, float damage) -
isInstantenous
public boolean isInstantenous() -
getOrCreateDescriptionId
-
getDescriptionId
-
getDisplayName
-
getCategory
-
getColor
public int getColor() -
addAttributeModifier
public MobEffect addAttributeModifier(Holder<Attribute> attribute, Identifier id, double amount, AttributeModifier.Operation operation) -
addAttributeModifier
public MobEffect addAttributeModifier(Holder<Attribute> attribute, Identifier id, AttributeModifier.Operation operation, it.unimi.dsi.fastutil.ints.Int2DoubleFunction curve) Neo: attribute template with custom level curve, for mob effects providing non-linear attribute modifiers.- Parameters:
attribute- The attribute of the modifierid- ID of the modifieroperation- Operation of the modifiercurve- A function mapping effect instance amplifier to modifier amount
-
setBlendDuration
-
setBlendDuration
-
createModifiers
public void createModifiers(int amplifier, BiConsumer<Holder<Attribute>, AttributeModifier> consumer) -
removeAttributeModifiers
-
addAttributeModifiers
-
isBeneficial
public boolean isBeneficial() -
createParticleOptions
-
withSoundOnAdded
-
requiredFeatures
-
requiredFeatures
- Specified by:
requiredFeaturesin interfaceFeatureElement
-