Fix enchantment problems

This commit is contained in:
zontreck 2024-04-01 02:00:34 -07:00
parent 7697043b79
commit a9608d867c
4 changed files with 58 additions and 65 deletions

View file

@ -15,10 +15,10 @@ public class EnchantmentEvents
@SubscribeEvent
public static void onServerTick(TickEvent.ServerTickEvent event)
{
if(event.phase == TickEvent.Phase.START)
if(event.phase == TickEvent.Phase.END)
{
MinecraftServer server = ServerLifecycleHooks.getCurrentServer();
canTick = server!=null && server.getTickCount()%20==0;
canTick = server!=null;
}
}
@ -33,6 +33,7 @@ public class EnchantmentEvents
{
FlightEnchantment.runEntityTick(sp);
ConsumptionMending.onEntityTick(sp);
NightVisionEnchantment.runEntityTick(sp);
}
}
}

View file

@ -65,7 +65,7 @@ public class FlightEnchantment extends Enchantment
{
if(ServerUtilities.isClient()) return;
if(TICKS.getAndIncrement() >= (5*20))
if(TICKS.getAndIncrement() >= 20)
{
TICKS.set(0);
@ -84,7 +84,17 @@ public class FlightEnchantment extends Enchantment
if(hasFlight)
{
MobEffectInstance inst = new MobEffectInstance(ModEffects.FLIGHT.get(), -1, 0, false, false, true);
MobEffectInstance inst = new MobEffectInstance(ModEffects.FLIGHT.get(), 60*20, 0, false, false, true);
MobEffectInstance existing = sp.getEffect(ModEffects.FLIGHT.get());
if(existing!= null)
{
if(existing.getDuration() <= (30 * 20))
{
sp.addEffect(inst);
return;
}else return;
}
sp.addEffect(inst);
}

View file

@ -74,6 +74,16 @@ public class NightVisionEnchantment extends Enchantment
{
MobEffectInstance inst = new MobEffectInstance(MobEffects.NIGHT_VISION, 60*20, 4, false, false, true);
MobEffectInstance existing = sp.getEffect(MobEffects.NIGHT_VISION);
if(existing != null)
{
if(existing.getDuration() <= (30*20))
{
sp.addEffect(inst);
return;
}else return;
}
sp.addEffect(inst);
}
}