Package net.minecraft.world.effect
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 int
private final Map
<Holder<Attribute>, MobEffect.AttributeTemplate> Contains a Map of the AttributeModifiers registered by potionsprivate int
private int
private int
private final MobEffectCategory
private final int
private String
private final Function
<MobEffectInstance, ParticleOptions> private FeatureFlagSet
private Optional
<SoundEvent> static final StreamCodec
<RegistryFriendlyByteBuf, Holder<MobEffect>> Fields inherited from interface net.minecraft.world.flag.FeatureElement
FILTERED_REGISTRIES
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
MobEffect
(MobEffectCategory pCategory, int pColor) protected
MobEffect
(MobEffectCategory pCategory, int pColor, Function<MobEffectInstance, ParticleOptions> particleFactory) Neo: Constructor that can take in the particle factory as a function of theMobEffectInstance
.protected
MobEffect
(MobEffectCategory pCategory, int pColor, ParticleOptions pParticle) -
Method Summary
Modifier and TypeMethodDescriptionaddAttributeModifier
(Holder<Attribute> pAttribute, ResourceLocation pId, double pAmount, AttributeModifier.Operation pOperation) addAttributeModifier
(Holder<Attribute> attribute, ResourceLocation 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.void
addAttributeModifiers
(AttributeMap pAttributeMap, int pAmplifier) boolean
applyEffectTick
(ServerLevel pLevel, LivingEntity pEntity, int pAmplifier) void
applyInstantenousEffect
(ServerLevel pLevel, Entity pSource, Entity pIndirectSource, LivingEntity pEntity, int pAmplifier, double pHealth) void
createModifiers
(int pAmplifier, BiConsumer<Holder<Attribute>, AttributeModifier> pOutput) createParticleOptions
(MobEffectInstance pEffect) int
int
int
int
getColor()
protected String
boolean
boolean
void
onEffectAdded
(LivingEntity pEntity, int pAmplifier) void
onEffectStarted
(LivingEntity pEntity, int pAmplifier) void
onMobHurt
(ServerLevel pLevel, LivingEntity pEntity, int pAmplifier, DamageSource pDamageSource, float pAmount) void
onMobRemoved
(ServerLevel pLevel, LivingEntity pEntity, int pAmplifier, Entity.RemovalReason pReason) void
removeAttributeModifiers
(AttributeMap pAttributeMap) requiredFeatures
(FeatureFlag... pRequiredFeatures) setBlendDuration
(int pBlendDuration) setBlendDuration
(int pBlendInDurationTicks, int pBlendOutDurationTicks, int pBlendOutAdvanceTicks) boolean
shouldApplyEffectTickThisTick
(int pDuration, int pAmplifier) withSoundOnAdded
(SoundEvent pSound) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.minecraft.world.flag.FeatureElement
isEnabled
Methods inherited from interface net.neoforged.neoforge.common.extensions.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 pCategory, int pColor, Function<MobEffectInstance, ParticleOptions> particleFactory) Neo: Constructor that can take in the particle factory as a function of theMobEffectInstance
. This should be used if the desiredParticleOptions
depends 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 pLevel, @Nullable Entity pSource, @Nullable Entity pIndirectSource, LivingEntity pEntity, int pAmplifier, double pHealth) -
shouldApplyEffectTickThisTick
public boolean shouldApplyEffectTickThisTick(int pDuration, int pAmplifier) -
onEffectStarted
-
onEffectAdded
-
onMobRemoved
public void onMobRemoved(ServerLevel pLevel, LivingEntity pEntity, int pAmplifier, Entity.RemovalReason pReason) -
onMobHurt
public void onMobHurt(ServerLevel pLevel, LivingEntity pEntity, int pAmplifier, DamageSource pDamageSource, float pAmount) -
isInstantenous
public boolean isInstantenous() -
getOrCreateDescriptionId
-
getDescriptionId
-
getDisplayName
-
getCategory
-
getColor
public int getColor() -
addAttributeModifier
public MobEffect addAttributeModifier(Holder<Attribute> pAttribute, ResourceLocation pId, double pAmount, AttributeModifier.Operation pOperation) -
addAttributeModifier
public MobEffect addAttributeModifier(Holder<Attribute> attribute, ResourceLocation 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
public MobEffect setBlendDuration(int pBlendInDurationTicks, int pBlendOutDurationTicks, int pBlendOutAdvanceTicks) -
createModifiers
public void createModifiers(int pAmplifier, BiConsumer<Holder<Attribute>, AttributeModifier> pOutput) -
removeAttributeModifiers
-
addAttributeModifiers
-
isBeneficial
public boolean isBeneficial() -
createParticleOptions
-
withSoundOnAdded
-
requiredFeatures
-
requiredFeatures
- Specified by:
requiredFeatures
in interfaceFeatureElement
-