Minecraft add potion effect, from custom potion effect

Currently trying to create a potion effect that once it runs out of time, applies other potion effects to the player. Seemed simple enough yet I found a few errors and bugs trying to accomplish this,

Directly trying to add the effect

@Override

public void performEffect(EntityLivingBase entity, int amplifier){

if (entity instanceof EntityPlayer)

{

EntityPlayer player = (EntityPlayer)entity;

if(player != null){

if(player.getActivePotionEffect(PotionRegistry.effectBuzz) != null){

int duraction = player.getActivePotionEffect(PotionRegistry.effectBuzz).getDuration();

if(duration <= 2){

player.addPotionEffect(new PotionEffect(MobEffects.WEAKNESS, 1200));

}

}

}

}

}

Needless to say this produces this error

[16:10:04] [Server thread/ERROR]: Encountered an unexpected exception

net.minecraft.util.ReportedException: Ticking player

at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:212) ~[NetworkSystem.class:?]

at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:807) ~[MinecraftServer.class:?]

at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:688) ~[MinecraftServer.class:?]

at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:156) ~[IntegratedServer.class:?]

at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:537) [MinecraftServer.class:?]

at java.lang.Thread.run(Unknown Source)...

Read More »

By: StackOverFlow - Monday, 16 April

Related Posts