mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-19 03:49:29 +00:00
Beta 1
This commit is contained in:
1 parent
a87babcf0b
commit
a6fa0576ab
29 files changed
+506
-117
No files matched your search
@@ -4,11 +4,13 @@ import java.io.ByteArrayInputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import net.minecraft.network.packet.Packet250CustomPayload;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import tinker.common.InventoryLogic;
|
||||
import tinker.tconstruct.logic.ToolStationLogic;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.network.IPacketHandler;
|
||||
@@ -32,34 +34,51 @@ public class TConstructPacketHandler implements IPacketHandler
|
||||
{
|
||||
DataInputStream inputStream = new DataInputStream(new ByteArrayInputStream(packet.data));
|
||||
|
||||
byte packetID;
|
||||
int dimension;
|
||||
int x;
|
||||
int y;
|
||||
int z;
|
||||
String toolName;
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
packetID = inputStream.readByte();
|
||||
dimension = inputStream.readInt();
|
||||
x = inputStream.readInt();
|
||||
y = inputStream.readInt();
|
||||
z = inputStream.readInt();
|
||||
toolName = inputStream.readUTF();
|
||||
|
||||
WorldServer world = DimensionManager.getWorld(dimension);
|
||||
TileEntity te = world.getBlockTileEntity(x, y, z);
|
||||
|
||||
if (packetID == 1)
|
||||
{
|
||||
String toolName = inputStream.readUTF();
|
||||
if (te instanceof ToolStationLogic)
|
||||
{
|
||||
((ToolStationLogic)te).setToolname(toolName);
|
||||
}
|
||||
}
|
||||
else if (packetID == 2)
|
||||
{
|
||||
Short itemID = inputStream.readShort();
|
||||
Short itemDamage = inputStream.readShort();
|
||||
if (te instanceof InventoryLogic)
|
||||
{
|
||||
((InventoryLogic)te).setInventorySlotContents(1, new ItemStack(itemID, 1, itemDamage));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
System.out.println("Failed at reading packet");
|
||||
System.out.println("Failed at reading packet for TConstruct. Blarrrrrrrrrgh");
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
|
||||
WorldServer world = DimensionManager.getWorld(dimension);
|
||||
TileEntity te = world.getBlockTileEntity(x, y, z);
|
||||
if (te instanceof ToolStationLogic)
|
||||
{
|
||||
((ToolStationLogic)te).setToolname(toolName);
|
||||
System.out.println("Successfully processed packet");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user