Attempt to patch Flight sometimes randomly deactivating.
This commit is contained in:
parent
48c83245c9
commit
d4c8d0b732
3 changed files with 11 additions and 15 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.0514
|
mod_version=1201.4.040124.1700
|
||||||
# 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
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package dev.zontreck.otemod.enchantments;
|
package dev.zontreck.otemod.enchantments;
|
||||||
|
|
||||||
|
import dev.zontreck.libzontreck.util.ServerUtilities;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraftforge.event.TickEvent;
|
import net.minecraftforge.event.TickEvent;
|
||||||
|
@ -11,30 +12,25 @@ import net.minecraftforge.server.ServerLifecycleHooks;
|
||||||
@Mod.EventBusSubscriber
|
@Mod.EventBusSubscriber
|
||||||
public class EnchantmentEvents
|
public class EnchantmentEvents
|
||||||
{
|
{
|
||||||
private static boolean canTick = false;
|
private static int TICKS = 0;
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onServerTick(TickEvent.ServerTickEvent event)
|
public static void onServerTick(TickEvent.ServerTickEvent event)
|
||||||
{
|
{
|
||||||
if(event.phase == TickEvent.Phase.END)
|
MinecraftServer server = ServerLifecycleHooks.getCurrentServer();
|
||||||
{
|
if(server.getPlayerCount() == 0) return;
|
||||||
MinecraftServer server = ServerLifecycleHooks.getCurrentServer();
|
|
||||||
canTick = server!=null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SubscribeEvent
|
if(TICKS >= 20)
|
||||||
public static void onTick(LivingEvent.LivingTickEvent tick)
|
|
||||||
{
|
|
||||||
if(canTick)
|
|
||||||
{
|
{
|
||||||
// Process Enchantments
|
|
||||||
|
|
||||||
if(tick.getEntity() instanceof ServerPlayer sp)
|
for(ServerPlayer sp : server.getPlayerList().getPlayers())
|
||||||
{
|
{
|
||||||
FlightEnchantment.runEntityTick(sp);
|
FlightEnchantment.runEntityTick(sp);
|
||||||
ConsumptionMending.onEntityTick(sp);
|
ConsumptionMending.onEntityTick(sp);
|
||||||
NightVisionEnchantment.runEntityTick(sp);
|
NightVisionEnchantment.runEntityTick(sp);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TICKS++;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -87,7 +87,7 @@ public class FlightEnchantment extends Enchantment
|
||||||
MobEffectInstance inst = new MobEffectInstance(ModEffects.FLIGHT.get(), 60*20, 0, false, false, true);
|
MobEffectInstance inst = new MobEffectInstance(ModEffects.FLIGHT.get(), 60*20, 0, false, false, true);
|
||||||
MobEffectInstance existing = sp.getEffect(ModEffects.FLIGHT.get());
|
MobEffectInstance existing = sp.getEffect(ModEffects.FLIGHT.get());
|
||||||
|
|
||||||
if(existing!= null)
|
if(existing != null)
|
||||||
{
|
{
|
||||||
if(existing.getDuration() <= (30 * 20))
|
if(existing.getDuration() <= (30 * 20))
|
||||||
{
|
{
|
||||||
|
|
Reference in a new issue