diff --git a/build.gradle b/build.gradle index 4f55385..3086f74 100644 --- a/build.gradle +++ b/build.gradle @@ -17,7 +17,7 @@ buildscript { apply plugin: 'forge' -version = "1.7.10-1.0.1.5" +version = "1.7.10-1.0.1.6" group= "com.azanor.baubles" archivesBaseName = "Baubles" diff --git a/src/main/java/baubles/common/Baubles.java b/src/main/java/baubles/common/Baubles.java index 87e8fac..944af3d 100644 --- a/src/main/java/baubles/common/Baubles.java +++ b/src/main/java/baubles/common/Baubles.java @@ -8,7 +8,9 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import baubles.common.event.EventHandlerEntity; +import baubles.common.event.EventHandlerNetwork; import baubles.common.network.PacketHandler; +import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.Instance; @@ -24,7 +26,7 @@ public class Baubles { public static final String MODID = "Baubles"; public static final String MODNAME = "Baubles"; - public static final String VERSION = "1.0.1.5"; + public static final String VERSION = "1.0.1.6"; @SidedProxy(clientSide = "baubles.client.ClientProxy", serverSide = "baubles.common.CommonProxy") public static CommonProxy proxy; @@ -33,6 +35,7 @@ public class Baubles { public static Baubles instance; public EventHandlerEntity entityEventHandler; + public EventHandlerNetwork entityEventNetwork; public File modDir; public static final Logger log = LogManager.getLogger("Baubles"); @@ -54,8 +57,10 @@ public class Baubles { PacketHandler.init(); entityEventHandler = new EventHandlerEntity(); + entityEventNetwork = new EventHandlerNetwork(); MinecraftForge.EVENT_BUS.register(entityEventHandler); + FMLCommonHandler.instance().bus().register(entityEventNetwork); proxy.registerHandlers(); ///////////////////// diff --git a/src/main/java/baubles/common/event/EventHandlerEntity.java b/src/main/java/baubles/common/event/EventHandlerEntity.java index e7cbb4a..49d3668 100644 --- a/src/main/java/baubles/common/event/EventHandlerEntity.java +++ b/src/main/java/baubles/common/event/EventHandlerEntity.java @@ -65,13 +65,10 @@ public class EventHandlerEntity { } PlayerHandler.loadPlayerBaubles(event.entityPlayer, file1, event.getPlayerFile("baubback")); - - for (int a = 0; a < 4; a++) - PlayerHandler.getPlayerBaubles(event.entityPlayer) - .syncSlotToClients(a); - + EventHandlerNetwork.syncBaubles(event.entityPlayer); } + public static File getLegacyFileFromPlayer(EntityPlayer player) { try { diff --git a/src/main/java/baubles/common/event/EventHandlerNetwork.java b/src/main/java/baubles/common/event/EventHandlerNetwork.java new file mode 100644 index 0000000..413d83d --- /dev/null +++ b/src/main/java/baubles/common/event/EventHandlerNetwork.java @@ -0,0 +1,27 @@ +package baubles.common.event; + +import net.minecraft.entity.player.EntityPlayer; +import baubles.common.lib.PlayerHandler; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.PlayerEvent; +import cpw.mods.fml.relauncher.Side; + +public class EventHandlerNetwork { + + @SubscribeEvent + public void playerLoggedInEvent (PlayerEvent.PlayerLoggedInEvent event) { + Side side = FMLCommonHandler.instance().getEffectiveSide(); + if (side == Side.SERVER) { + syncBaubles(event.player); + } + } + + public static void syncBaubles(EntityPlayer player) { + for (int a = 0; a < 4; a++) { + PlayerHandler.getPlayerBaubles(player).syncSlotToClients(a); + } + } + + +} diff --git a/src/main/resources/changelog.txt b/src/main/resources/changelog.txt index 695c1c2..6dac950 100644 --- a/src/main/resources/changelog.txt +++ b/src/main/resources/changelog.txt @@ -1,3 +1,6 @@ +1.0.1.6 +- added a secondary client sync event in case a player logs off and then on again before his player gets unloaded from a server. + 1.0.1.5 - onUnequip will now only be called once if a bauble is removed via shift-click