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 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 category, int color) protected
MobEffect
(MobEffectCategory category, int color, ParticleOptions particle) -
Method Summary
Modifier and TypeMethodDescriptionaddAttributeModifier
(Holder<Attribute> attribute, ResourceLocation id, double amount, AttributeModifier.Operation operation) 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 attributeMap, int amplifier) boolean
applyEffectTick
(LivingEntity livingEntity, int amplifier) void
applyInstantenousEffect
(Entity source, Entity indirectSource, LivingEntity livingEntity, int amplifier, double health) void
createModifiers
(int amplifier, BiConsumer<Holder<Attribute>, AttributeModifier> output) int
int
getColor()
protected String
void
initializeClient
(Consumer<IClientMobEffectExtensions> consumer) Deprecated, for removal: This API element is subject to removal in a future version.boolean
boolean
void
onEffectAdded
(LivingEntity livingEntity, int amplifier) void
onEffectStarted
(LivingEntity livingEntity, int amplifier) void
onMobHurt
(LivingEntity livingEntity, int amplifier, DamageSource damageSource, float amount) void
onMobRemoved
(LivingEntity livingEntity, int amplifier, Entity.RemovalReason reason) void
removeAttributeModifiers
(AttributeMap attributeMap) requiredFeatures
(FeatureFlag... requiredFeatures) setBlendDuration
(int blendDuration) boolean
shouldApplyEffectTickThisTick
(int duration, int amplifier) withSoundOnAdded
(SoundEvent sound) 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
fillEffectCures, 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
-
blendDurationTicks
private int blendDurationTicks -
soundOnAdded
-
requiredFeatures
-
-
Constructor Details
-
MobEffect
-
MobEffect
-
-
Method Details
-
getBlendDurationTicks
public int getBlendDurationTicks() -
applyEffectTick
-
applyInstantenousEffect
public void applyInstantenousEffect(@Nullable Entity source, @Nullable Entity indirectSource, LivingEntity livingEntity, int amplifier, double health) -
shouldApplyEffectTickThisTick
public boolean shouldApplyEffectTickThisTick(int duration, int amplifier) -
onEffectStarted
-
onEffectAdded
-
onMobRemoved
-
onMobHurt
public void onMobHurt(LivingEntity livingEntity, int amplifier, DamageSource damageSource, float amount) -
isInstantenous
public boolean isInstantenous() -
getOrCreateDescriptionId
-
getDescriptionId
-
getDisplayName
-
getCategory
-
getColor
public int getColor() -
addAttributeModifier
public MobEffect addAttributeModifier(Holder<Attribute> attribute, ResourceLocation id, double amount, AttributeModifier.Operation operation) -
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
-
createModifiers
-
removeAttributeModifiers
-
addAttributeModifiers
-
isBeneficial
public boolean isBeneficial() -
createParticleOptions
-
withSoundOnAdded
-
requiredFeatures
-
requiredFeatures
- Specified by:
requiredFeatures
in interfaceFeatureElement
-
initializeClient
@Deprecated(forRemoval=true, since="1.21") public void initializeClient(Consumer<IClientMobEffectExtensions> consumer) Deprecated, for removal: This API element is subject to removal in a future version.UseRegisterClientExtensionsEvent
insteadNeo: Allowing mods to define client behavior for their MobEffects
-
RegisterClientExtensionsEvent
instead