From 1d04b3eee74cf4025e554827685756b70c231871 Mon Sep 17 00:00:00 2001 From: Aria Date: Mon, 27 Feb 2023 22:06:56 -0700 Subject: [PATCH] Roll back fix --- gradle.properties | 2 +- .../dev/zontreck/libzontreck/LibZontreck.java | 38 +-------------- .../events/ForgeEventHandlers.java | 47 +++++++++++++++++++ src/main/resources/META-INF/mods.toml | 2 +- 4 files changed, 51 insertions(+), 38 deletions(-) create mode 100644 src/main/java/dev/zontreck/libzontreck/events/ForgeEventHandlers.java diff --git a/gradle.properties b/gradle.properties index ca855ea..0e176d2 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,5 +5,5 @@ org.gradle.daemon=false mc_version=1.18.2 forge_version=40.2.1 -myversion=1.0.5.0227232142 +myversion=1.0.5.0227232154 parchment_version=2022.11.06 \ No newline at end of file diff --git a/src/main/java/dev/zontreck/libzontreck/LibZontreck.java b/src/main/java/dev/zontreck/libzontreck/LibZontreck.java index 76768c3..03f4be7 100644 --- a/src/main/java/dev/zontreck/libzontreck/LibZontreck.java +++ b/src/main/java/dev/zontreck/libzontreck/LibZontreck.java @@ -12,6 +12,7 @@ import org.slf4j.Logger; import com.mojang.logging.LogUtils; +import dev.zontreck.libzontreck.events.ForgeEventHandlers; import dev.zontreck.libzontreck.events.PlayerChangedPositionEvent; import dev.zontreck.libzontreck.events.ProfileLoadedEvent; import dev.zontreck.libzontreck.memory.PlayerContainer; @@ -67,6 +68,7 @@ public class LibZontreck { MinecraftForge.EVENT_BUS.register(this); MinecraftForge.EVENT_BUS.register(DelayedExecutorService.getInstance()); + MinecraftForge.EVENT_BUS.register(new ForgeEventHandlers()); } private void setup(final FMLCommonSetupEvent event) @@ -87,40 +89,4 @@ public class LibZontreck { ALIVE=false; } - - @Mod.EventBusSubscriber(modid = LibZontreck.MOD_ID, bus = Mod.EventBusSubscriber.Bus.FORGE) - public static class ForgeEventBus - { - @SubscribeEvent - public void onPlayerTick(LivingUpdateEvent ev) - { - if(ev.getEntity().level.isClientSide)return; - - if(ev.getEntity() instanceof ServerPlayer) - { - ServerPlayer player = (ServerPlayer)ev.getEntity(); - PlayerContainer cont = LibZontreck.playerStorage.get(player.getUUID()); - - if(cont.player.positionChanged()) - { - cont.player.update(); - - PlayerChangedPositionEvent pcpe = new PlayerChangedPositionEvent(player, cont.player.position, cont.player.lastPosition); - MinecraftForge.EVENT_BUS.post(pcpe); - } - } - } - - - @SubscribeEvent - public void onPlayerJoin(PlayerEvent.PlayerLoggedInEvent ev) - { - if(ev.getEntity().level.isClientSide)return; - - ServerPlayer player = (ServerPlayer)ev.getPlayer(); - Profile prof = Profile.factory(player); - - MinecraftForge.EVENT_BUS.post(new ProfileLoadedEvent(prof)); - } - } } diff --git a/src/main/java/dev/zontreck/libzontreck/events/ForgeEventHandlers.java b/src/main/java/dev/zontreck/libzontreck/events/ForgeEventHandlers.java new file mode 100644 index 0000000..232d95f --- /dev/null +++ b/src/main/java/dev/zontreck/libzontreck/events/ForgeEventHandlers.java @@ -0,0 +1,47 @@ +package dev.zontreck.libzontreck.events; + +import dev.zontreck.libzontreck.LibZontreck; +import dev.zontreck.libzontreck.memory.PlayerContainer; +import dev.zontreck.libzontreck.profiles.Profile; +import net.minecraft.server.level.ServerPlayer; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent; +import net.minecraftforge.event.entity.player.PlayerEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraftforge.fml.common.Mod; + +@Mod.EventBusSubscriber(modid = LibZontreck.MOD_ID, bus=Mod.EventBusSubscriber.Bus.FORGE) +public class ForgeEventHandlers { + + @SubscribeEvent + public void onPlayerTick(LivingUpdateEvent ev) + { + if(ev.getEntity().level.isClientSide)return; + + if(ev.getEntity() instanceof ServerPlayer) + { + ServerPlayer player = (ServerPlayer)ev.getEntity(); + PlayerContainer cont = LibZontreck.playerStorage.get(player.getUUID()); + + if(cont.player.positionChanged()) + { + cont.player.update(); + + PlayerChangedPositionEvent pcpe = new PlayerChangedPositionEvent(player, cont.player.position, cont.player.lastPosition); + MinecraftForge.EVENT_BUS.post(pcpe); + } + } + } + + @SubscribeEvent + public void onPlayerJoin(PlayerEvent.PlayerLoggedInEvent ev) + { + if(ev.getEntity().level.isClientSide)return; + + ServerPlayer player = (ServerPlayer)ev.getPlayer(); + Profile prof = Profile.factory(player); + + MinecraftForge.EVENT_BUS.post(new ProfileLoadedEvent(prof)); + } + +} diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index 5106923..bf38124 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -19,7 +19,7 @@ modId="libzontreck" #mandatory # The version number of the mod - there's a few well known ${} variables useable here or just hardcode it # ${file.jarVersion} will substitute the value of the Implementation-Version as read from the mod's JAR file metadata # see the associated build.gradle script for how to populate this completely automatically during a build -version="1.0.5.0227232142" #mandatory +version="1.0.5.0227232154" #mandatory # A display name for the mod displayName="LibZontreck" #mandatory # A URL to query for updates for this mod. See the JSON update specification https://mcforge.readthedocs.io/en/latest/gettingstarted/autoupdate/