OSDN Git Service

guiの微調整 タブの同期
[chemicraft/chemicraft.git] / common / chemicraft / PacketHandler.java
index a55e9c5..0fc00bf 100644 (file)
@@ -8,6 +8,8 @@ import java.io.IOException;
 import com.google.common.io.ByteArrayDataInput;\r
 import com.google.common.io.ByteStreams;\r
 \r
+import net.minecraft.src.EntityPlayer;\r
+import net.minecraft.src.EntityPlayerMP;\r
 import net.minecraft.src.NetworkManager;\r
 import net.minecraft.src.Packet;\r
 import net.minecraft.src.Packet250CustomPayload;\r
@@ -28,19 +30,38 @@ public class PacketHandler implements IPacketHandler {
     public void onPacketData(NetworkManager manager, Packet250CustomPayload packet, Player player) {\r
        if (packet.channel.equals("chemicraft")) {\r
            ByteArrayDataInput var1 = ByteStreams.newDataInput(packet.data);\r
+\r
+           World world;\r
+           TileEntity tileEntity;\r
+           TileEntityScienceCraftingTable var2;\r
+\r
+           // TileEntityのx, y, z座標\r
            int x, y, z;\r
 \r
-           // パケットからデータ読み込み\r
+           // activeTab\r
+           String activeTab;\r
+\r
+           // 座標読み込み\r
            x = var1.readInt();\r
            y = var1.readInt();\r
            z = var1.readInt();\r
+           // activeTab読み込み\r
+           activeTab = var1.readUTF();\r
 \r
            // TileEntityを取得し読み込んだデータを送る\r
-           World world = ChemiCraft.proxy.getClientWorld();\r
-           TileEntity tileEntity = world.getBlockTileEntity(x, y, z);\r
+           // from Server to Client\r
+           world = ChemiCraft.proxy.getClientWorld();\r
+           tileEntity = world.getBlockTileEntity(x, y, z);\r
+           if (tileEntity instanceof TileEntityScienceCraftingTable) {\r
+               var2 = (TileEntityScienceCraftingTable) tileEntity;\r
+               \r
+           }\r
+           // from Client to Server\r
+           world = ((EntityPlayer) player).worldObj;\r
+           tileEntity = world.getBlockTileEntity(x, y, z);\r
            if (tileEntity instanceof TileEntityScienceCraftingTable) {\r
-               TileEntityScienceCraftingTable var2 = (TileEntityScienceCraftingTable) tileEntity;\r
-               var2.handlePacket(null);\r
+               var2 = (TileEntityScienceCraftingTable) tileEntity;\r
+               var2.handlePacket(new Object[] { activeTab });\r
            }\r
        }\r
     }\r
@@ -49,17 +70,28 @@ public class PacketHandler implements IPacketHandler {
     public static Packet getPacket(TileEntityScienceCraftingTable tileEntity) {\r
        ByteArrayOutputStream var1 = new ByteArrayOutputStream(128);\r
        DataOutputStream var2 = new DataOutputStream(var1);\r
+\r
+       // Blockのx, y, z座標\r
        int x, y, z;\r
 \r
-       // データの用意\r
+       // activeTab\r
+       String activeTab;\r
+\r
+       // x, y, z座標を代入\r
        x = tileEntity.xCoord;\r
        y = tileEntity.yCoord;\r
        z = tileEntity.zCoord;\r
 \r
+       // activeTabに代入\r
+       activeTab = tileEntity.getActiveTab();\r
+\r
        try {\r
+           // 座標書き込み\r
            var2.writeInt(x);\r
            var2.writeInt(y);\r
            var2.writeInt(z);\r
+           // activeTab書き込み\r
+           var2.writeUTF(activeTab);\r
        } catch (IOException e) {\r
            e.printStackTrace();\r
        }\r