Roll back fix
This commit is contained in:
parent
04ab8f8a11
commit
1d04b3eee7
4 changed files with 51 additions and 38 deletions
|
@ -5,5 +5,5 @@ org.gradle.daemon=false
|
||||||
|
|
||||||
mc_version=1.18.2
|
mc_version=1.18.2
|
||||||
forge_version=40.2.1
|
forge_version=40.2.1
|
||||||
myversion=1.0.5.0227232142
|
myversion=1.0.5.0227232154
|
||||||
parchment_version=2022.11.06
|
parchment_version=2022.11.06
|
|
@ -12,6 +12,7 @@ import org.slf4j.Logger;
|
||||||
|
|
||||||
import com.mojang.logging.LogUtils;
|
import com.mojang.logging.LogUtils;
|
||||||
|
|
||||||
|
import dev.zontreck.libzontreck.events.ForgeEventHandlers;
|
||||||
import dev.zontreck.libzontreck.events.PlayerChangedPositionEvent;
|
import dev.zontreck.libzontreck.events.PlayerChangedPositionEvent;
|
||||||
import dev.zontreck.libzontreck.events.ProfileLoadedEvent;
|
import dev.zontreck.libzontreck.events.ProfileLoadedEvent;
|
||||||
import dev.zontreck.libzontreck.memory.PlayerContainer;
|
import dev.zontreck.libzontreck.memory.PlayerContainer;
|
||||||
|
@ -67,6 +68,7 @@ public class LibZontreck {
|
||||||
|
|
||||||
MinecraftForge.EVENT_BUS.register(this);
|
MinecraftForge.EVENT_BUS.register(this);
|
||||||
MinecraftForge.EVENT_BUS.register(DelayedExecutorService.getInstance());
|
MinecraftForge.EVENT_BUS.register(DelayedExecutorService.getInstance());
|
||||||
|
MinecraftForge.EVENT_BUS.register(new ForgeEventHandlers());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setup(final FMLCommonSetupEvent event)
|
private void setup(final FMLCommonSetupEvent event)
|
||||||
|
@ -87,40 +89,4 @@ public class LibZontreck {
|
||||||
ALIVE=false;
|
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));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -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
|
# 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
|
# ${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
|
# 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
|
# A display name for the mod
|
||||||
displayName="LibZontreck" #mandatory
|
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/
|
# A URL to query for updates for this mod. See the JSON update specification https://mcforge.readthedocs.io/en/latest/gettingstarted/autoupdate/
|
||||||
|
|
Reference in a new issue