OSDN Git Service

guiの微調整 タブの同期
[chemicraft/chemicraft.git] / common / chemicraft / PacketHandler.java
index 53cdc38..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
@@ -18,95 +20,88 @@ import cpw.mods.fml.common.network.Player;
 \r
 /**\r
  * サーバーとクライアントのデータの同期に必要なクラス\r
- *\r
+ * \r
  * @author Lilly\r
- *\r
+ * \r
  */\r
 public class PacketHandler implements IPacketHandler {\r
 \r
-       @Override\r
-       public void onPacketData(NetworkManager manager, Packet250CustomPayload packet, Player player) {\r
-               if (packet.channel.equals("chemicraft")) {\r
-                       ByteArrayDataInput var1 = ByteStreams.newDataInput(packet.data);\r
-\r
-                       //TileEntityのx, y, z座標\r
-                       int x, y, z;\r
-<<<<<<< HEAD
-                       //activeTab\r
-                       String activeTab;\r
-=======
-                       String tab;\r
->>>>>>> 820e884ca2933199d4be03f7de49a491a7f9e93e
-\r
-                       //座標読み込み\r
-                       x = var1.readInt();\r
-                       y = var1.readInt();\r
-                       z = var1.readInt();\r
-<<<<<<< HEAD
-                       //activeTab読み込み\r
-                       activeTab = var1.readUTF();\r
-=======
-                       tab = var1.readUTF();\r
->>>>>>> 820e884ca2933199d4be03f7de49a491a7f9e93e
-\r
-                       // TileEntityを取得し読み込んだデータを送る\r
-                       World world = ChemiCraft.proxy.getClientWorld();\r
-                       TileEntity tileEntity = world.getBlockTileEntity(x, y, z);\r
-                       if (tileEntity instanceof TileEntityScienceCraftingTable) {\r
-                               TileEntityScienceCraftingTable var2 = (TileEntityScienceCraftingTable) tileEntity;\r
-<<<<<<< HEAD
-                               var2.setActiveTab(activeTab);\r
-=======
-                               var2.handlePacket(new Object[]{tab});\r
->>>>>>> 820e884ca2933199d4be03f7de49a491a7f9e93e
-                       }\r
-               }\r
+    @Override\r
+    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
+           // 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
+           // 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
+               var2 = (TileEntityScienceCraftingTable) tileEntity;\r
+               var2.handlePacket(new Object[] { activeTab });\r
+           }\r
        }\r
+    }\r
+\r
 \r
+    public static Packet getPacket(TileEntityScienceCraftingTable tileEntity) {\r
+       ByteArrayOutputStream var1 = new ByteArrayOutputStream(128);\r
+       DataOutputStream var2 = new DataOutputStream(var1);\r
 \r
-       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
-<<<<<<< HEAD
-               //activeTab\r
-               String activeTab;\r
-=======
-               String tab;\r
->>>>>>> 820e884ca2933199d4be03f7de49a491a7f9e93e
-\r
-               // x, y, z座標を代入\r
-               x = tileEntity.xCoord;\r
-               y = tileEntity.yCoord;\r
-               z = tileEntity.zCoord;\r
-<<<<<<< HEAD
-               //activeTabに代入\r
-               activeTab = tileEntity.getActiveTab();\r
-=======
-               tab = tileEntity.getActiveTab();\r
->>>>>>> 820e884ca2933199d4be03f7de49a491a7f9e93e
-\r
-               try {\r
-                       var2.writeInt(x);\r
-                       var2.writeInt(y);\r
-                       var2.writeInt(z);\r
-<<<<<<< HEAD
-                       var2.writeUTF(activeTab);\r
-=======
-                       var2.writeUTF(tab);\r
->>>>>>> 820e884ca2933199d4be03f7de49a491a7f9e93e
-               } catch (IOException e) {\r
-                       e.printStackTrace();\r
-               }\r
-\r
-               // パケットの作成\r
-               Packet250CustomPayload packet = new Packet250CustomPayload();\r
-               packet.channel = "chemicraft";\r
-               packet.data = var1.toByteArray();\r
-               packet.length = var1.size();\r
-               packet.isChunkDataPacket = true;\r
-               return packet;\r
+       // Blockのx, y, z座標\r
+       int x, y, z;\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
+\r
+       // パケットの作成\r
+       Packet250CustomPayload packet = new Packet250CustomPayload();\r
+       packet.channel = "chemicraft";\r
+       packet.data = var1.toByteArray();\r
+       packet.length = var1.size();\r
+       packet.isChunkDataPacket = true;\r
+       return packet;\r
+    }\r
 }\r