Switch to a different tick event due to unpredictable behavior in enchantments
This commit is contained in:
parent
2713961cdf
commit
bbda4b4787
2 changed files with 7 additions and 12 deletions
|
@ -48,7 +48,7 @@ mod_name=Thresholds
|
||||||
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
|
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
|
||||||
mod_license=GPLv3
|
mod_license=GPLv3
|
||||||
# The mod version. See https://semver.org/
|
# The mod version. See https://semver.org/
|
||||||
mod_version=1201.4.040124.1700
|
mod_version=1201.4.040224.1407
|
||||||
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
|
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
|
||||||
# This should match the base package used for the mod sources.
|
# This should match the base package used for the mod sources.
|
||||||
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
|
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||||
|
|
|
@ -6,23 +6,22 @@ import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraftforge.event.TickEvent;
|
import net.minecraftforge.event.TickEvent;
|
||||||
import net.minecraftforge.event.entity.living.LivingEvent;
|
import net.minecraftforge.event.entity.living.LivingEvent;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
|
import net.minecraftforge.fml.LogicalSide;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
import net.minecraftforge.server.ServerLifecycleHooks;
|
import net.minecraftforge.server.ServerLifecycleHooks;
|
||||||
|
|
||||||
@Mod.EventBusSubscriber
|
@Mod.EventBusSubscriber
|
||||||
public class EnchantmentEvents
|
public class EnchantmentEvents
|
||||||
{
|
{
|
||||||
private static int TICKS = 0;
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onServerTick(TickEvent.ServerTickEvent event)
|
public static void handleEnchantmentTicks(TickEvent.PlayerTickEvent event)
|
||||||
{
|
{
|
||||||
MinecraftServer server = ServerLifecycleHooks.getCurrentServer();
|
if(event.side == LogicalSide.CLIENT) return;
|
||||||
if(server.getPlayerCount() == 0) return;
|
|
||||||
|
|
||||||
if(TICKS >= 20)
|
if(event.phase == TickEvent.Phase.END)
|
||||||
{
|
{
|
||||||
|
if(event.player instanceof ServerPlayer sp)
|
||||||
for(ServerPlayer sp : server.getPlayerList().getPlayers())
|
|
||||||
{
|
{
|
||||||
FlightEnchantment.runEntityTick(sp);
|
FlightEnchantment.runEntityTick(sp);
|
||||||
ConsumptionMending.onEntityTick(sp);
|
ConsumptionMending.onEntityTick(sp);
|
||||||
|
@ -30,10 +29,6 @@ public class EnchantmentEvents
|
||||||
WaterBreathingEnchantment.runEntityTick(sp);
|
WaterBreathingEnchantment.runEntityTick(sp);
|
||||||
}
|
}
|
||||||
|
|
||||||
TICKS=0;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TICKS++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in a new issue