multiple client sync update

This commit is contained in:
Azanor committed 2014-05-06 07:34:45 +02:00
1 parent 4ac84fbbd4
commit d788b1b697
6 files changed
+12 -39

No files matched your search

+1 -1
View File
@@ -17,7 +17,7 @@ buildscript {
apply plugin: 'forge'
version = "1.7.2-1.0.0.10"
version = "1.7.2-1.0.0.11"
group= "com.azanor.baubles"
archivesBaseName = "Baubles"
+1 -1
View File
@@ -26,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.0.10";
public static final String VERSION = "1.0.0.11";
@SidedProxy(clientSide = "baubles.client.ClientProxy", serverSide = "baubles.common.CommonProxy")
public static CommonProxy proxy;
@@ -99,7 +99,7 @@ public class InventoryBaubles implements IInventory {
}
if (eventHandler!=null) this.eventHandler.onCraftMatrixChanged(this);
syncSlotToClient(par1);
syncSlotToClients(par1);
return itemstack;
} else {
itemstack = this.stackList[par1].splitStack(par2);
@@ -112,7 +112,7 @@ public class InventoryBaubles implements IInventory {
((IBauble)itemstack.getItem()).onUnequipped(itemstack, player.get());
}
if (eventHandler!=null) this.eventHandler.onCraftMatrixChanged(this);
syncSlotToClient(par1);
syncSlotToClients(par1);
return itemstack;
}
} else {
@@ -131,7 +131,7 @@ public class InventoryBaubles implements IInventory {
((IBauble)stack.getItem()).onEquipped(stack, player.get());
}
if (eventHandler!=null) this.eventHandler.onCraftMatrixChanged(this);
syncSlotToClient(par1);
syncSlotToClients(par1);
}
/**
@@ -234,15 +234,15 @@ public class InventoryBaubles implements IInventory {
if (this.stackList[i] != null) {
player.dropPlayerItemWithRandomChoice(this.stackList[i], true);
this.stackList[i] = null;
syncSlotToClient(i);
syncSlotToClients(i);
}
}
}
public void syncSlotToClient(int slot) {
public void syncSlotToClients(int slot) {
try {
if (Baubles.proxy.getClientWorld()==null)
Baubles.packetPipeline.sendTo(new PacketSyncBauble(player.get(),slot), (EntityPlayerMP) player.get());
Baubles.packetPipeline.sendToAll(new PacketSyncBauble(player.get(),slot));
} catch (Exception e) { e.printStackTrace(); }
}
}
@@ -100,34 +100,6 @@ public class PlayerHandler {
playerBaubles.put(player.getCommandSenderName(), inventory);
if (save) savePlayerBaubles(player);
}
// if (file1 == null || !file1.exists())
// {
// Baubles.log.warn("Baubles inventory not found for "+player.getCommandSenderName()+". Trying to load backup baubles data.");
// file1 = getBackupFileFromPlayer(player);
// }
// if (file1 != null && file1.exists())
// {
// FileInputStream fileinputstream = new FileInputStream(file1);
// NBTTagCompound data = CompressedStreamTools.readCompressed(fileinputstream);
// fileinputstream.close();
//
// InventoryBaubles inventory = new InventoryBaubles(player);
// inventory.readNBT(data);
// playerBaubles.put(player.getCommandSenderName(), inventory);
//
// } else { //legacy data
// Baubles.log.warn("Baubles inventory not found for "+player.getCommandSenderName()+". Trying to load legacy baubles data.");
// NBTTagCompound data = player.getEntityData();
// if (!data.hasKey("Baubles")) {
// data.setTag("Baubles", new NBTTagCompound());
// }
// InventoryBaubles inventory = new InventoryBaubles(player);
// inventory.readNBT(player);
// playerBaubles.put(player.getCommandSenderName(), inventory);
// savePlayerBaubles(player);
// }
}
catch (Exception exception1)
{
@@ -1,7 +1,5 @@
package baubles.common.network;
import java.util.HashMap;
import baubles.common.lib.PlayerHandler;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
@@ -16,7 +14,7 @@ public class EventHandlerNetwork {
if (side == Side.SERVER) {
PlayerHandler.loadPlayerBaubles(event.player);
for (int a=0;a<4;a++)
PlayerHandler.getPlayerBaubles(event.player).syncSlotToClient(a);
PlayerHandler.getPlayerBaubles(event.player).syncSlotToClients(a);
}
}
+3
View File
@@ -1,3 +1,6 @@
1.0.0.11
- baubles are now synced to all clients on a server, allowing modders to add visual components or other client-side stuff for baubles.
1.0.0.10
- moved baubles data from player data to custom savefiles (*.baub)
- a backup file is also saved each time in case the main one becomes corrupt.