Topic category: Help with Minecraft modding (Java Edition)
Im trying to make a potion effect that is applied when you are hit with an item and it is applied for 10 seconds and cleanses all negative effects over those 10 seconds. I keep getting an error when I try to run the client and cant figure out why.
Error code:
Executing Gradle task: runClient
Build info: MCreator 2024.1.18518, forge-1.20.1, 64-bit, 65447 MB, Windows 11, JVM 17.0.10, JAVA_HOME: C:\Program Files\Pylo\MCreator\jdk, started on: 2024-06-19-18:01:55
> Task :compileJava FAILED
C:\Users\[REDACTED]\MCreatorWorkspaces\wip_mod\src\main\java\net\mcreator\wipmod\potion\CleanseMobEffect.java:22: error: cannot find symbol MobEffectUtil.removeAllBadEffects(player); // Remove all negative effects
^
symbol: method removeAllBadEffects(ServerPlayer)
location: class MobEffectUtil
1 error
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileJava'.
> Compilation failed; see the compiler error output for details.
* Try:
> Run with --info option to get more log output.
> Run with --scan to get full insights.
BUILD FAILED in 1s
1 actionable task: 1 executed
BUILD FAILED
Task completed in 2 seconds
CleanseMobEffect.java:
package net.mcreator.wipmod.potion;
import net.minecraft.world.effect.MobEffectCategory;
import net.minecraft.world.effect.MobEffect;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.effect.MobEffectUtil;
public class CleanseMobEffect extends MobEffect {
public CleanseMobEffect() {
super(MobEffectCategory.BENEFICIAL, 0x00FF00); // Set the color to green
}
@Override
public boolean isBeneficial() {
return true;
}
public void applyUpdateEffect(LivingEntity entity, int amplifier) {
if (entity instanceof ServerPlayer) {
ServerPlayer player = (ServerPlayer) entity;
MobEffectUtil.removeAllBadEffects(player); // Remove all negative effects
}
}
}
Is this custom code you have added? This may not be valid code for 1.20.1