mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-14 01:04:12 +00:00
Move PacketHelper methods into DataStreams
This commit is contained in:
1 parent
ff97fd8067
commit
fa092e2a1b
57 files changed
+459
-508
No files matched your search
@@ -10,8 +10,6 @@
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.gadgets;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedList;
|
||||
@@ -34,6 +32,8 @@ import forestry.core.config.ForestryBlock;
|
||||
import forestry.core.gadgets.TileForestry;
|
||||
import forestry.core.inventory.FakeInventoryAdapter;
|
||||
import forestry.core.inventory.IInventoryAdapter;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.proxy.Proxies;
|
||||
|
||||
import buildcraft.api.statements.ITriggerExternal;
|
||||
@@ -108,23 +108,23 @@ public abstract class TileAlveary extends TileForestry implements IAlvearyCompon
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeData(DataOutputStream data) throws IOException {
|
||||
public void writeData(DataOutputStreamForestry data) throws IOException {
|
||||
super.writeData(data);
|
||||
data.writeBoolean(isMaster);
|
||||
|
||||
// so the client can know if it is part of an integrated structure
|
||||
data.writeShort(masterY);
|
||||
data.writeVarInt(masterY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(DataInputStream data) throws IOException {
|
||||
public void readData(DataInputStreamForestry data) throws IOException {
|
||||
super.readData(data);
|
||||
if (data.readBoolean()) {
|
||||
makeMaster();
|
||||
}
|
||||
|
||||
// so the client can know if it is part of an integrated structure
|
||||
masterY = data.readShort();
|
||||
masterY = data.readVarInt();
|
||||
}
|
||||
|
||||
/* ITILESTRUCTURE */
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.gadgets;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -21,6 +19,8 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||
import forestry.api.apiculture.IAlvearyComponent;
|
||||
import forestry.apiculture.network.PacketActiveUpdate;
|
||||
import forestry.core.interfaces.IActivatable;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.energy.EnergyManager;
|
||||
|
||||
@@ -117,13 +117,13 @@ public abstract class TileAlvearyClimatiser extends TileAlveary implements IEner
|
||||
|
||||
/* NETWORK */
|
||||
@Override
|
||||
public void writeData(DataOutputStream data) throws IOException {
|
||||
public void writeData(DataOutputStreamForestry data) throws IOException {
|
||||
super.writeData(data);
|
||||
data.writeBoolean(active);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(DataInputStream data) throws IOException {
|
||||
public void readData(DataInputStreamForestry data) throws IOException {
|
||||
super.readData(data);
|
||||
setActive(data.readBoolean());
|
||||
}
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.gadgets;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
@@ -51,10 +49,9 @@ import forestry.core.interfaces.IHintSource;
|
||||
import forestry.core.inventory.IInventoryAdapter;
|
||||
import forestry.core.inventory.InvTools;
|
||||
import forestry.core.inventory.TileInventoryAdapter;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.network.GuiId;
|
||||
import forestry.core.network.PacketHelper;
|
||||
import forestry.core.network.PacketId;
|
||||
import forestry.core.network.PacketInventoryStack;
|
||||
import forestry.core.proxy.Proxies;
|
||||
|
||||
public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IBeeHousing, IClimatised, IHintSource, IActivatable {
|
||||
@@ -127,21 +124,21 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeData(DataOutputStream data) throws IOException {
|
||||
public void writeData(DataOutputStreamForestry data) throws IOException {
|
||||
super.writeData(data);
|
||||
data.writeBoolean(active);
|
||||
if (active) {
|
||||
ItemStack queen = getStackInSlot(SLOT_QUEEN);
|
||||
PacketHelper.writeItemStack(queen, data);
|
||||
data.writeItemStack(queen);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(DataInputStream data) throws IOException {
|
||||
public void readData(DataInputStreamForestry data) throws IOException {
|
||||
super.readData(data);
|
||||
active = data.readBoolean();
|
||||
if (active) {
|
||||
ItemStack queen = PacketHelper.readItemStack(data);
|
||||
ItemStack queen = data.readItemStack();
|
||||
setInventorySlotContents(SLOT_QUEEN, queen);
|
||||
}
|
||||
}
|
||||
@@ -502,9 +499,6 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
|
||||
return;
|
||||
}
|
||||
|
||||
PacketInventoryStack packet = new PacketInventoryStack(PacketId.IINVENTORY_STACK, xCoord, yCoord, zCoord, SLOT_QUEEN, queenStack);
|
||||
Proxies.net.sendNetworkPacket(packet);
|
||||
|
||||
for (IBeeListener eventHandler : eventHandlers) {
|
||||
eventHandler.onQueenChange(queenStack);
|
||||
}
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.gadgets;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Stack;
|
||||
@@ -36,6 +34,8 @@ import forestry.core.interfaces.IActivatable;
|
||||
import forestry.core.inventory.TileInventoryAdapter;
|
||||
import forestry.core.inventory.wrappers.IInvSlot;
|
||||
import forestry.core.inventory.wrappers.InventoryIterator;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.network.GuiId;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.StackUtils;
|
||||
@@ -151,13 +151,13 @@ public class TileAlvearySwarmer extends TileAlveary implements ISidedInventory,
|
||||
/* NETWORK */
|
||||
|
||||
@Override
|
||||
public void writeData(DataOutputStream data) throws IOException {
|
||||
public void writeData(DataOutputStreamForestry data) throws IOException {
|
||||
super.writeData(data);
|
||||
data.writeBoolean(active);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(DataInputStream data) throws IOException {
|
||||
public void readData(DataInputStreamForestry data) throws IOException {
|
||||
super.readData(data);
|
||||
boolean active = data.readBoolean();
|
||||
if (this.active != active) {
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.gadgets;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -44,8 +42,9 @@ import forestry.core.interfaces.IActivatable;
|
||||
import forestry.core.interfaces.IClimatised;
|
||||
import forestry.core.inventory.InvTools;
|
||||
import forestry.core.inventory.TileInventoryAdapter;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.network.GuiId;
|
||||
import forestry.core.network.PacketHelper;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.GuiUtil;
|
||||
|
||||
@@ -99,21 +98,21 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeData(DataOutputStream data) throws IOException {
|
||||
public void writeData(DataOutputStreamForestry data) throws IOException {
|
||||
super.writeData(data);
|
||||
data.writeBoolean(active);
|
||||
if (active) {
|
||||
ItemStack queen = getStackInSlot(SLOT_QUEEN);
|
||||
PacketHelper.writeItemStack(queen, data);
|
||||
data.writeItemStack(queen);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(DataInputStream data) throws IOException {
|
||||
public void readData(DataInputStreamForestry data) throws IOException {
|
||||
super.readData(data);
|
||||
active = data.readBoolean();
|
||||
if (active) {
|
||||
ItemStack queen = PacketHelper.readItemStack(data);
|
||||
ItemStack queen = data.readItemStack();
|
||||
setInventorySlotContents(SLOT_QUEEN, queen);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,14 +10,14 @@
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.network;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import forestry.core.gadgets.TileForestry;
|
||||
import forestry.core.interfaces.IActivatable;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.network.PacketCoordinates;
|
||||
import forestry.core.network.PacketId;
|
||||
import forestry.core.proxy.Proxies;
|
||||
@@ -26,11 +26,11 @@ public class PacketActiveUpdate extends PacketCoordinates {
|
||||
|
||||
private IActivatable activatable;
|
||||
|
||||
public static void onPacketData(DataInputStream data) throws IOException {
|
||||
public static void onPacketData(DataInputStreamForestry data) throws IOException {
|
||||
new PacketActiveUpdate(data);
|
||||
}
|
||||
|
||||
private PacketActiveUpdate(DataInputStream data) throws IOException {
|
||||
private PacketActiveUpdate(DataInputStreamForestry data) throws IOException {
|
||||
super(data);
|
||||
}
|
||||
|
||||
@@ -40,13 +40,13 @@ public class PacketActiveUpdate extends PacketCoordinates {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeData(DataOutputStream data) throws IOException {
|
||||
protected void writeData(DataOutputStreamForestry data) throws IOException {
|
||||
super.writeData(data);
|
||||
data.writeBoolean(activatable.isActive());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readData(DataInputStream data) throws IOException {
|
||||
protected void readData(DataInputStreamForestry data) throws IOException {
|
||||
super.readData(data);
|
||||
|
||||
boolean active = data.readBoolean();
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.network;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -18,6 +17,7 @@ import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import forestry.apiculture.gadgets.TileCandle;
|
||||
import forestry.apiculture.gui.ContainerImprinter;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.IPacketHandler;
|
||||
import forestry.core.network.PacketCoordinates;
|
||||
import forestry.core.network.PacketId;
|
||||
@@ -26,7 +26,7 @@ import forestry.core.proxy.Proxies;
|
||||
public class PacketHandlerApiculture implements IPacketHandler {
|
||||
|
||||
@Override
|
||||
public boolean onPacketData(PacketId packetID, DataInputStream data, EntityPlayer player) throws IOException {
|
||||
public boolean onPacketData(PacketId packetID, DataInputStreamForestry data, EntityPlayer player) throws IOException {
|
||||
|
||||
switch (packetID) {
|
||||
case HABITAT_BIOME_POINTER: {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package forestry.apiculture.network;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import forestry.apiculture.gadgets.TileCandle;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.network.PacketCoordinates;
|
||||
import forestry.core.network.PacketId;
|
||||
|
||||
@@ -13,7 +13,7 @@ public class PacketUpdateCandle extends PacketCoordinates {
|
||||
private int colour;
|
||||
private boolean lit;
|
||||
|
||||
public PacketUpdateCandle(DataInputStream data) throws IOException {
|
||||
public PacketUpdateCandle(DataInputStreamForestry data) throws IOException {
|
||||
super(data);
|
||||
}
|
||||
|
||||
@@ -25,14 +25,14 @@ public class PacketUpdateCandle extends PacketCoordinates {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeData(DataOutputStream data) throws IOException {
|
||||
public void writeData(DataOutputStreamForestry data) throws IOException {
|
||||
super.writeData(data);
|
||||
data.writeInt(colour);
|
||||
data.writeBoolean(lit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(DataInputStream data) throws IOException {
|
||||
public void readData(DataInputStreamForestry data) throws IOException {
|
||||
super.readData(data);
|
||||
colour = data.readInt();
|
||||
lit = data.readBoolean();
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
******************************************************************************/
|
||||
package forestry.arboriculture.gadgets;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -32,6 +30,8 @@ import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.IFruitBearer;
|
||||
import forestry.api.genetics.IFruitFamily;
|
||||
import forestry.arboriculture.network.PacketRipeningUpdate;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.network.IStreamable;
|
||||
import forestry.core.network.PacketTileStream;
|
||||
import forestry.core.proxy.Proxies;
|
||||
@@ -176,7 +176,7 @@ public class TileFruitPod extends TileEntity implements IFruitBearer, IStreamabl
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeData(DataOutputStream data) throws IOException {
|
||||
public void writeData(DataOutputStreamForestry data) throws IOException {
|
||||
data.writeShort(maturity);
|
||||
data.writeShort(indices.length);
|
||||
for (int i : indices) {
|
||||
@@ -185,7 +185,7 @@ public class TileFruitPod extends TileEntity implements IFruitBearer, IStreamabl
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(DataInputStream data) throws IOException {
|
||||
public void readData(DataInputStreamForestry data) throws IOException {
|
||||
maturity = data.readShort();
|
||||
int indicesLength = data.readShort();
|
||||
indices = new int[indicesLength];
|
||||
|
||||
@@ -12,8 +12,6 @@ package forestry.arboriculture.gadgets;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
@@ -60,6 +58,8 @@ import forestry.api.lepidopterology.IButterflyRoot;
|
||||
import forestry.arboriculture.network.PacketRipeningUpdate;
|
||||
import forestry.core.EnumErrorCode;
|
||||
import forestry.core.genetics.alleles.Allele;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.network.PacketTileStream;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.render.TextureManager;
|
||||
@@ -356,7 +356,7 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru
|
||||
private static final short isPollinatedFlag = 1 << 1;
|
||||
|
||||
@Override
|
||||
public void writeData(DataOutputStream data) throws IOException {
|
||||
public void writeData(DataOutputStreamForestry data) throws IOException {
|
||||
super.writeData(data);
|
||||
|
||||
byte leafState = 0;
|
||||
@@ -382,7 +382,7 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(DataInputStream data) throws IOException {
|
||||
public void readData(DataInputStreamForestry data) throws IOException {
|
||||
|
||||
String speciesUID = data.readUTF(); // this is called instead of super.readData, be careful!
|
||||
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
******************************************************************************/
|
||||
package forestry.arboriculture.gadgets;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -19,6 +17,8 @@ import net.minecraft.network.Packet;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import forestry.arboriculture.WoodType;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.network.IStreamable;
|
||||
import forestry.core.network.PacketTileStream;
|
||||
import forestry.core.proxy.Proxies;
|
||||
@@ -76,13 +76,13 @@ public class TileStairs extends TileEntity implements IStreamable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeData(DataOutputStream data) throws IOException {
|
||||
data.writeShort(woodType.ordinal());
|
||||
public void writeData(DataOutputStreamForestry data) throws IOException {
|
||||
data.writeVarInt(woodType.ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(DataInputStream data) throws IOException {
|
||||
short woodTypeOrdinal = data.readShort();
|
||||
public void readData(DataInputStreamForestry data) throws IOException {
|
||||
int woodTypeOrdinal = data.readVarInt();
|
||||
woodType = WoodType.values()[woodTypeOrdinal];
|
||||
worldObj.func_147479_m(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
******************************************************************************/
|
||||
package forestry.arboriculture.gadgets;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -26,6 +24,8 @@ import forestry.api.arboriculture.ITree;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.arboriculture.genetics.Tree;
|
||||
import forestry.core.interfaces.IOwnable;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.network.IStreamable;
|
||||
import forestry.core.utils.PlayerUtil;
|
||||
import forestry.plugins.PluginArboriculture;
|
||||
@@ -69,7 +69,7 @@ public abstract class TileTreeContainer extends TileEntity implements IStreamabl
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeData(DataOutputStream data) throws IOException {
|
||||
public void writeData(DataOutputStreamForestry data) throws IOException {
|
||||
String speciesUID = "";
|
||||
ITree tree = getTree();
|
||||
if (tree != null) {
|
||||
@@ -79,7 +79,7 @@ public abstract class TileTreeContainer extends TileEntity implements IStreamabl
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(DataInputStream data) throws IOException {
|
||||
public void readData(DataInputStreamForestry data) throws IOException {
|
||||
String speciesUID = data.readUTF();
|
||||
ITree tree = getTree(speciesUID);
|
||||
setTree(tree);
|
||||
|
||||
@@ -10,13 +10,13 @@
|
||||
******************************************************************************/
|
||||
package forestry.arboriculture.network;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import forestry.arboriculture.gadgets.TileLeaves;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.IPacketHandler;
|
||||
import forestry.core.network.PacketId;
|
||||
import forestry.core.proxy.Proxies;
|
||||
@@ -24,7 +24,7 @@ import forestry.core.proxy.Proxies;
|
||||
public class PacketHandlerArboriculture implements IPacketHandler {
|
||||
|
||||
@Override
|
||||
public boolean onPacketData(PacketId packetID, DataInputStream data, EntityPlayer player) throws IOException {
|
||||
public boolean onPacketData(PacketId packetID, DataInputStreamForestry data, EntityPlayer player) throws IOException {
|
||||
|
||||
switch (packetID) {
|
||||
case RIPENING_UPDATE: {
|
||||
|
||||
@@ -10,12 +10,12 @@
|
||||
******************************************************************************/
|
||||
package forestry.arboriculture.network;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import forestry.arboriculture.gadgets.TileFruitPod;
|
||||
import forestry.arboriculture.gadgets.TileLeaves;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.network.PacketCoordinates;
|
||||
import forestry.core.network.PacketId;
|
||||
|
||||
@@ -23,7 +23,7 @@ public class PacketRipeningUpdate extends PacketCoordinates {
|
||||
|
||||
private int value;
|
||||
|
||||
public PacketRipeningUpdate(DataInputStream data) throws IOException {
|
||||
public PacketRipeningUpdate(DataInputStreamForestry data) throws IOException {
|
||||
super(data);
|
||||
}
|
||||
|
||||
@@ -38,13 +38,13 @@ public class PacketRipeningUpdate extends PacketCoordinates {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeData(DataOutputStream data) throws IOException {
|
||||
public void writeData(DataOutputStreamForestry data) throws IOException {
|
||||
super.writeData(data);
|
||||
data.writeInt(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(DataInputStream data) throws IOException {
|
||||
public void readData(DataInputStreamForestry data) throws IOException {
|
||||
super.readData(data);
|
||||
value = data.readInt();
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ import forestry.core.gadgets.TileForestry;
|
||||
import forestry.core.gadgets.TileNaturalistChest;
|
||||
import forestry.core.gui.ContainerNaturalistInventory;
|
||||
import forestry.core.gui.GuiNaturalistInventory;
|
||||
import forestry.core.network.PacketTileGuiOpened;
|
||||
import forestry.core.proxy.Proxies;
|
||||
|
||||
public abstract class GuiHandlerBase implements IGuiHandler {
|
||||
@@ -35,7 +34,7 @@ public abstract class GuiHandlerBase implements IGuiHandler {
|
||||
}
|
||||
|
||||
if (tileForestry != null && !world.isRemote) {
|
||||
tileForestry.sendGuiUpdate(player);
|
||||
tileForestry.sendGuiOpened(player);
|
||||
}
|
||||
|
||||
return tileForestry;
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.gadgets;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
@@ -29,6 +27,8 @@ import forestry.core.EnumErrorCode;
|
||||
import forestry.core.TemperatureState;
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.interfaces.IActivatable;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.BlockUtil;
|
||||
import forestry.energy.EnergyManager;
|
||||
@@ -286,7 +286,7 @@ public abstract class Engine extends TileBase implements IEnergyConnection, IAct
|
||||
|
||||
/* NETWORK */
|
||||
@Override
|
||||
public void writeData(DataOutputStream data) throws IOException {
|
||||
public void writeData(DataOutputStreamForestry data) throws IOException {
|
||||
super.writeData(data);
|
||||
data.writeBoolean(active);
|
||||
data.writeInt(heat);
|
||||
@@ -295,7 +295,7 @@ public abstract class Engine extends TileBase implements IEnergyConnection, IAct
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(DataInputStream data) throws IOException {
|
||||
public void readData(DataInputStreamForestry data) throws IOException {
|
||||
super.readData(data);
|
||||
active = data.readBoolean();
|
||||
heat = data.readInt();
|
||||
|
||||
@@ -10,10 +10,11 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.gadgets;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
|
||||
public abstract class Mill extends TileBase {
|
||||
|
||||
public int charge = 0;
|
||||
@@ -36,7 +37,7 @@ public abstract class Mill extends TileBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeData(DataOutputStream data) throws IOException {
|
||||
public void writeData(DataOutputStreamForestry data) throws IOException {
|
||||
super.writeData(data);
|
||||
data.writeInt(charge);
|
||||
data.writeFloat(speed);
|
||||
@@ -44,7 +45,7 @@ public abstract class Mill extends TileBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(DataInputStream data) throws IOException {
|
||||
public void readData(DataInputStreamForestry data) throws IOException {
|
||||
super.readData(data);
|
||||
charge = data.readInt();
|
||||
speed = data.readFloat();
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.gadgets;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -28,8 +26,9 @@ import forestry.api.core.INBTTagable;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.network.IStreamable;
|
||||
import forestry.core.network.PacketHelper;
|
||||
import forestry.core.utils.StringUtil;
|
||||
import forestry.core.utils.Utils;
|
||||
|
||||
@@ -86,21 +85,19 @@ public class NaturalistGame implements INBTTagable, IStreamable {
|
||||
|
||||
/* NETWORK */
|
||||
@Override
|
||||
public void writeData(DataOutputStream data) throws IOException {
|
||||
public void writeData(DataOutputStreamForestry data) throws IOException {
|
||||
data.writeBoolean(isFailed);
|
||||
data.writeBoolean(isProbed);
|
||||
data.writeBoolean(isRevealed);
|
||||
|
||||
PacketHelper.writeItemStack(tokenStack, data);
|
||||
data.writeItemStack(tokenStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(DataInputStream data) throws IOException {
|
||||
public void readData(DataInputStreamForestry data) throws IOException {
|
||||
isFailed = data.readBoolean();
|
||||
isProbed = data.readBoolean();
|
||||
isRevealed = data.readBoolean();
|
||||
|
||||
tokenStack = PacketHelper.readItemStack(data);
|
||||
tokenStack = data.readItemStack();
|
||||
}
|
||||
|
||||
public boolean isVisible() {
|
||||
@@ -195,22 +192,22 @@ public class NaturalistGame implements INBTTagable, IStreamable {
|
||||
|
||||
/* NETWORK */
|
||||
@Override
|
||||
public void writeData(DataOutputStream data) throws IOException {
|
||||
public void writeData(DataOutputStreamForestry data) throws IOException {
|
||||
data.writeBoolean(isEnded);
|
||||
data.writeInt(bountyLevel);
|
||||
data.writeLong(lastUpdate);
|
||||
|
||||
List<GameToken> gameTokensList = gameTokens == null ? null : Arrays.asList(gameTokens);
|
||||
PacketHelper.writeStreamables(gameTokensList, data);
|
||||
data.writeStreamables(gameTokensList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(DataInputStream data) throws IOException {
|
||||
public void readData(DataInputStreamForestry data) throws IOException {
|
||||
isEnded = data.readBoolean();
|
||||
bountyLevel = data.readInt();
|
||||
lastUpdate = data.readLong();
|
||||
|
||||
List<GameToken> gameTokensList = PacketHelper.readStreamables(GameToken.class, data);
|
||||
List<GameToken> gameTokensList = data.readStreamables(GameToken.class);
|
||||
if (gameTokensList != null) {
|
||||
this.gameTokens = gameTokensList.toArray(new GameToken[gameTokensList.size()]);
|
||||
}
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.gadgets;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
@@ -47,6 +45,8 @@ import forestry.core.inventory.TileInventoryAdapter;
|
||||
import forestry.core.inventory.wrappers.IInvSlot;
|
||||
import forestry.core.inventory.wrappers.InventoryIterator;
|
||||
import forestry.core.inventory.wrappers.InventoryMapper;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.network.GuiId;
|
||||
import forestry.core.utils.GeneticsUtil;
|
||||
import forestry.core.utils.GuiUtil;
|
||||
@@ -199,7 +199,7 @@ public class TileAnalyzer extends TilePowered implements ISidedInventory, ILiqui
|
||||
|
||||
/* Network */
|
||||
@Override
|
||||
public void writeData(DataOutputStream data) throws IOException {
|
||||
public void writeData(DataOutputStreamForestry data) throws IOException {
|
||||
super.writeData(data);
|
||||
ItemStack displayStack = getIndividualOnDisplay();
|
||||
if (displayStack == null) {
|
||||
@@ -217,7 +217,7 @@ public class TileAnalyzer extends TilePowered implements ISidedInventory, ILiqui
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(DataInputStream data) throws IOException {
|
||||
public void readData(DataInputStreamForestry data) throws IOException {
|
||||
super.readData(data);
|
||||
|
||||
ItemStack newIndividualOnDisplay = null;
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.gadgets;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -28,6 +26,8 @@ import forestry.core.interfaces.ICrafter;
|
||||
import forestry.core.interfaces.IRenderableMachine;
|
||||
import forestry.core.inventory.InvTools;
|
||||
import forestry.core.inventory.TileInventoryAdapter;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.network.GuiId;
|
||||
import forestry.core.network.PacketTileStream;
|
||||
import forestry.core.proxy.Proxies;
|
||||
@@ -112,13 +112,13 @@ public class TileEscritoire extends TileBase implements ISidedInventory, IRender
|
||||
/* NETWORK */
|
||||
|
||||
@Override
|
||||
public void writeData(DataOutputStream data) throws IOException {
|
||||
public void writeData(DataOutputStreamForestry data) throws IOException {
|
||||
super.writeData(data);
|
||||
game.writeData(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(DataInputStream data) throws IOException {
|
||||
public void readData(DataInputStreamForestry data) throws IOException {
|
||||
super.readData(data);
|
||||
game.readData(data);
|
||||
}
|
||||
|
||||
@@ -12,8 +12,6 @@ package forestry.core.gadgets;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
@@ -50,6 +48,8 @@ import forestry.core.interfaces.ILiquidTankContainer;
|
||||
import forestry.core.interfaces.IRestrictedAccess;
|
||||
import forestry.core.inventory.FakeInventoryAdapter;
|
||||
import forestry.core.inventory.IInventoryAdapter;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.network.IStreamable;
|
||||
import forestry.core.network.PacketTileGuiOpened;
|
||||
import forestry.core.network.PacketTileStream;
|
||||
@@ -203,7 +203,7 @@ public abstract class TileForestry extends TileEntity implements IStreamable, IR
|
||||
Proxies.net.sendNetworkPacket(packet);
|
||||
}
|
||||
|
||||
public void writeData(DataOutputStream data) throws IOException {
|
||||
public void writeData(DataOutputStreamForestry data) throws IOException {
|
||||
data.writeByte(orientation.ordinal());
|
||||
|
||||
if (this instanceof ILiquidTankContainer) {
|
||||
@@ -214,7 +214,7 @@ public abstract class TileForestry extends TileEntity implements IStreamable, IR
|
||||
}
|
||||
}
|
||||
|
||||
public void readData(DataInputStream data) throws IOException {
|
||||
public void readData(DataInputStreamForestry data) throws IOException {
|
||||
orientation = ForgeDirection.getOrientation(data.readByte());
|
||||
|
||||
if (this instanceof ILiquidTankContainer) {
|
||||
@@ -225,14 +225,14 @@ public abstract class TileForestry extends TileEntity implements IStreamable, IR
|
||||
}
|
||||
}
|
||||
|
||||
public final void writeErrorData(DataOutputStream data) throws IOException {
|
||||
public final void writeErrorData(DataOutputStreamForestry data) throws IOException {
|
||||
data.writeShort(errorStates.size());
|
||||
for (IErrorState errorState : errorStates) {
|
||||
data.writeShort(errorState.getID());
|
||||
}
|
||||
}
|
||||
|
||||
public final void readErrorData(DataInputStream data) throws IOException {
|
||||
public final void readErrorData(DataInputStreamForestry data) throws IOException {
|
||||
errorStates.clear();
|
||||
|
||||
short errorStateCount = data.readShort();
|
||||
@@ -243,12 +243,12 @@ public abstract class TileForestry extends TileEntity implements IStreamable, IR
|
||||
}
|
||||
}
|
||||
|
||||
public final void sendGuiUpdate(EntityPlayer player) {
|
||||
public final void sendGuiOpened(EntityPlayer player) {
|
||||
PacketTileGuiOpened packet = new PacketTileGuiOpened(this);
|
||||
Proxies.net.sendToPlayer(packet, player);
|
||||
}
|
||||
|
||||
public final void writeGuiData(DataOutputStream data) throws IOException {
|
||||
public final void writeGuiData(DataOutputStreamForestry data) throws IOException {
|
||||
writeErrorData(data);
|
||||
|
||||
if (owner == null) {
|
||||
@@ -261,7 +261,7 @@ public abstract class TileForestry extends TileEntity implements IStreamable, IR
|
||||
}
|
||||
}
|
||||
|
||||
public final void readGuiData(DataInputStream data) throws IOException {
|
||||
public final void readGuiData(DataInputStreamForestry data) throws IOException {
|
||||
readErrorData(data);
|
||||
|
||||
byte accessOrdinal = data.readByte();
|
||||
@@ -406,7 +406,7 @@ public abstract class TileForestry extends TileEntity implements IStreamable, IR
|
||||
int ordinal = (access.ordinal() + 1) % EnumAccess.values().length;
|
||||
access = EnumAccess.values()[ordinal];
|
||||
if (!this.worldObj.isRemote) {
|
||||
sendGuiUpdate(player);
|
||||
sendGuiOpened(player);
|
||||
|
||||
boolean canPipesConnect = allowsPipeConnections();
|
||||
if (couldPipesConnect != canPipesConnect) {
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.inventory;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -21,8 +19,9 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.network.IStreamable;
|
||||
import forestry.core.network.PacketHelper;
|
||||
import forestry.core.utils.PlainInventory;
|
||||
|
||||
/**
|
||||
@@ -214,12 +213,12 @@ public class InventoryAdapter implements IInventoryAdapter, IStreamable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeData(DataOutputStream data) throws IOException {
|
||||
PacketHelper.writeInventory(inventory, data);
|
||||
public void writeData(DataOutputStreamForestry data) throws IOException {
|
||||
data.writeInventory(inventory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(DataInputStream data) throws IOException {
|
||||
PacketHelper.readInventory(inventory, data);
|
||||
public void readData(DataInputStreamForestry data) throws IOException {
|
||||
data.readInventory(inventory);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
package forestry.core.network;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompressedStreamTools;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import cpw.mods.fml.common.registry.GameData;
|
||||
|
||||
import forestry.core.proxy.Proxies;
|
||||
|
||||
public class DataInputStreamForestry extends DataInputStream {
|
||||
|
||||
public DataInputStreamForestry(InputStream in) {
|
||||
super(in);
|
||||
}
|
||||
|
||||
public ItemStack readItemStack() throws IOException {
|
||||
ItemStack itemstack = null;
|
||||
String itemName = readUTF();
|
||||
|
||||
if (!itemName.isEmpty()) {
|
||||
Item item = GameData.getItemRegistry().getRaw(itemName);
|
||||
byte stackSize = readByte();
|
||||
int meta = readVarInt();
|
||||
itemstack = new ItemStack(item, stackSize, meta);
|
||||
|
||||
if (item.isDamageable() || item.getShareTag()) {
|
||||
itemstack.stackTagCompound = readNBTTagCompound();
|
||||
}
|
||||
}
|
||||
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
public ItemStack[] readItemStacks() throws IOException {
|
||||
int stackCount = readVarInt();
|
||||
|
||||
ItemStack[] itemStacks = new ItemStack[stackCount];
|
||||
for (int i = 0; i < stackCount; i++) {
|
||||
itemStacks[i] = readItemStack();
|
||||
}
|
||||
|
||||
return itemStacks;
|
||||
}
|
||||
|
||||
public void readInventory(IInventory inventory) throws IOException {
|
||||
int size = readVarInt();
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
ItemStack stack = readItemStack();
|
||||
inventory.setInventorySlotContents(i, stack);
|
||||
}
|
||||
}
|
||||
|
||||
public <T extends IStreamable> T readStreamable(Class<T> streamableClass) throws IOException {
|
||||
if (readBoolean()) {
|
||||
try {
|
||||
T streamable = streamableClass.newInstance();
|
||||
streamable.readData(this);
|
||||
return streamable;
|
||||
} catch (ReflectiveOperationException e) {
|
||||
Proxies.log.severe("Failed to read Streamable for class " + streamableClass + " with error " + e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public <T extends IStreamable> List<T> readStreamables(Class<T> streamableClass) throws IOException {
|
||||
int length = readVarInt();
|
||||
List<T> streamables = new ArrayList<T>(length);
|
||||
if (length > 0) {
|
||||
for (int i = 0; i < length; i++) {
|
||||
T streamable = readStreamable(streamableClass);
|
||||
streamables.add(streamable);
|
||||
}
|
||||
}
|
||||
return streamables;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a compressed int from the buffer. To do so it maximally reads 5 byte-sized chunks whose most significant
|
||||
* bit dictates whether another byte should be read.
|
||||
*/
|
||||
public int readVarInt() throws IOException {
|
||||
int varInt = 0;
|
||||
int size = 0;
|
||||
byte b0;
|
||||
|
||||
do {
|
||||
b0 = readByte();
|
||||
varInt |= (b0 & 127) << size++ * 7;
|
||||
|
||||
if (size > 5) {
|
||||
throw new RuntimeException("VarInt too big");
|
||||
}
|
||||
} while ((b0 & 128) == 128);
|
||||
|
||||
return varInt;
|
||||
}
|
||||
|
||||
public NBTTagCompound readNBTTagCompound() throws IOException {
|
||||
int length = readVarInt();
|
||||
|
||||
if (length < 0) {
|
||||
return null;
|
||||
} else {
|
||||
byte[] compressed = new byte[length];
|
||||
readFully(compressed);
|
||||
return CompressedStreamTools.readCompressed(new ByteArrayInputStream(compressed));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
package forestry.core.network;
|
||||
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompressedStreamTools;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import cpw.mods.fml.common.registry.GameData;
|
||||
|
||||
public class DataOutputStreamForestry extends DataOutputStream {
|
||||
|
||||
public DataOutputStreamForestry(OutputStream out) {
|
||||
super(out);
|
||||
}
|
||||
|
||||
public void writeItemStack(ItemStack itemstack) throws IOException {
|
||||
if (itemstack == null) {
|
||||
writeUTF("");
|
||||
} else {
|
||||
writeUTF(GameData.getItemRegistry().getNameForObject(itemstack.getItem()));
|
||||
writeByte(itemstack.stackSize);
|
||||
writeVarInt(itemstack.getItemDamage());
|
||||
|
||||
if (itemstack.getItem().isDamageable() || itemstack.getItem().getShareTag()) {
|
||||
writeNBTTagCompound(itemstack.stackTagCompound);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void writeItemStacks(ItemStack[] itemStacks) throws IOException {
|
||||
writeVarInt(itemStacks.length);
|
||||
for (ItemStack itemstack : itemStacks) {
|
||||
writeItemStack(itemstack);
|
||||
}
|
||||
}
|
||||
|
||||
public void writeInventory(IInventory inventory) throws IOException {
|
||||
int size = inventory.getSizeInventory();
|
||||
writeVarInt(size);
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
ItemStack stack = inventory.getStackInSlot(i);
|
||||
writeItemStack(stack);
|
||||
}
|
||||
}
|
||||
|
||||
public void writeStreamable(IStreamable streamable) throws IOException {
|
||||
if (streamable != null) {
|
||||
writeBoolean(true);
|
||||
streamable.writeData(this);
|
||||
} else {
|
||||
writeBoolean(false);
|
||||
}
|
||||
}
|
||||
|
||||
public <T extends IStreamable> void writeStreamables(List<T> streamables) throws IOException {
|
||||
if (streamables == null) {
|
||||
writeVarInt(0);
|
||||
} else {
|
||||
writeVarInt(streamables.size());
|
||||
for (IStreamable streamable : streamables) {
|
||||
writeStreamable(streamable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a compressed int to the buffer. The smallest number of bytes to fit the passed int will be written. Of
|
||||
* each such byte only 7 bits will be used to describe the actual value since its most significant bit dictates
|
||||
* whether the next byte is part of that same int. Micro-optimization for int values that are expected to have
|
||||
* values below 128.
|
||||
*/
|
||||
public void writeVarInt(int varInt) throws IOException {
|
||||
while ((varInt & -128) != 0) {
|
||||
writeByte(varInt & 127 | 128);
|
||||
varInt >>>= 7;
|
||||
}
|
||||
|
||||
writeByte(varInt);
|
||||
}
|
||||
|
||||
public void writeNBTTagCompound(NBTTagCompound nbttagcompound) throws IOException {
|
||||
if (nbttagcompound == null) {
|
||||
writeVarInt(-1);
|
||||
} else {
|
||||
byte[] compressed = CompressedStreamTools.compress(nbttagcompound);
|
||||
writeVarInt((short) compressed.length);
|
||||
write(compressed);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,8 +11,6 @@
|
||||
package forestry.core.network;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import cpw.mods.fml.common.network.internal.FMLProxyPacket;
|
||||
@@ -24,7 +22,7 @@ public class ForestryPacket {
|
||||
protected static final String channel = "FOR";
|
||||
private final PacketId id;
|
||||
|
||||
public ForestryPacket(DataInputStream data) throws IOException {
|
||||
public ForestryPacket(DataInputStreamForestry data) throws IOException {
|
||||
this.id = PacketId.INVALID;
|
||||
readData(data);
|
||||
}
|
||||
@@ -35,7 +33,7 @@ public class ForestryPacket {
|
||||
|
||||
public final FMLProxyPacket getPacket() {
|
||||
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
|
||||
DataOutputStream data = new DataOutputStream(bytes);
|
||||
DataOutputStreamForestry data = new DataOutputStreamForestry(bytes);
|
||||
|
||||
try {
|
||||
data.writeByte(id.ordinal());
|
||||
@@ -47,9 +45,9 @@ public class ForestryPacket {
|
||||
return new FMLProxyPacket(Unpooled.wrappedBuffer(bytes.toByteArray()), channel);
|
||||
}
|
||||
|
||||
protected void writeData(DataOutputStream data) throws IOException {
|
||||
protected void writeData(DataOutputStreamForestry data) throws IOException {
|
||||
}
|
||||
|
||||
protected void readData(DataInputStream data) throws IOException {
|
||||
protected void readData(DataInputStreamForestry data) throws IOException {
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,6 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.network;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -18,6 +17,6 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
public interface IPacketHandler {
|
||||
|
||||
/** Returns true if the packet has been handled */
|
||||
boolean onPacketData(PacketId packetID, DataInputStream data, EntityPlayer player) throws IOException;
|
||||
boolean onPacketData(PacketId packetID, DataInputStreamForestry data, EntityPlayer player) throws IOException;
|
||||
|
||||
}
|
||||
@@ -10,11 +10,10 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.network;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public interface IStreamable {
|
||||
void writeData(DataOutputStream data) throws IOException;
|
||||
void readData(DataInputStream data) throws IOException;
|
||||
void writeData(DataOutputStreamForestry data) throws IOException;
|
||||
|
||||
void readData(DataInputStreamForestry data) throws IOException;
|
||||
}
|
||||
@@ -10,8 +10,6 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.network;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
@@ -24,7 +22,7 @@ public class PacketCoordinates extends ForestryPacket implements ILocatedPacket
|
||||
private int posY;
|
||||
private int posZ;
|
||||
|
||||
public PacketCoordinates(DataInputStream data) throws IOException {
|
||||
public PacketCoordinates(DataInputStreamForestry data) throws IOException {
|
||||
super(data);
|
||||
}
|
||||
|
||||
@@ -44,17 +42,17 @@ public class PacketCoordinates extends ForestryPacket implements ILocatedPacket
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeData(DataOutputStream data) throws IOException {
|
||||
data.writeInt(posX);
|
||||
data.writeInt(posY);
|
||||
data.writeInt(posZ);
|
||||
protected void writeData(DataOutputStreamForestry data) throws IOException {
|
||||
data.writeVarInt(posX);
|
||||
data.writeVarInt(posY);
|
||||
data.writeVarInt(posZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readData(DataInputStream data) throws IOException {
|
||||
posX = data.readInt();
|
||||
posY = data.readInt();
|
||||
posZ = data.readInt();
|
||||
protected void readData(DataInputStreamForestry data) throws IOException {
|
||||
posX = data.readVarInt();
|
||||
posY = data.readVarInt();
|
||||
posZ = data.readVarInt();
|
||||
}
|
||||
|
||||
public final ChunkCoordinates getCoordinates() {
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.network;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
@@ -23,7 +21,11 @@ public class PacketErrorUpdate extends PacketCoordinates {
|
||||
|
||||
private TileForestry tileForestry;
|
||||
|
||||
public PacketErrorUpdate(DataInputStream data) throws IOException {
|
||||
public static void onPacketData(DataInputStreamForestry data) throws IOException {
|
||||
new PacketErrorUpdate(data);
|
||||
}
|
||||
|
||||
public PacketErrorUpdate(DataInputStreamForestry data) throws IOException {
|
||||
super(data);
|
||||
}
|
||||
|
||||
@@ -33,13 +35,13 @@ public class PacketErrorUpdate extends PacketCoordinates {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeData(DataOutputStream data) throws IOException {
|
||||
protected void writeData(DataOutputStreamForestry data) throws IOException {
|
||||
super.writeData(data);
|
||||
tileForestry.writeErrorData(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readData(DataInputStream data) throws IOException {
|
||||
protected void readData(DataInputStreamForestry data) throws IOException {
|
||||
super.readData(data);
|
||||
|
||||
TileEntity tile = getTarget(Proxies.common.getRenderWorld());
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.network;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
@@ -46,7 +44,7 @@ public class PacketFXSignal extends PacketCoordinates {
|
||||
private Block block;
|
||||
private int meta;
|
||||
|
||||
public PacketFXSignal(DataInputStream data) throws IOException {
|
||||
public PacketFXSignal(DataInputStreamForestry data) throws IOException {
|
||||
super(data);
|
||||
}
|
||||
|
||||
@@ -67,7 +65,7 @@ public class PacketFXSignal extends PacketCoordinates {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeData(DataOutputStream data) throws IOException {
|
||||
public void writeData(DataOutputStreamForestry data) throws IOException {
|
||||
super.writeData(data);
|
||||
data.writeShort(visualFX.ordinal());
|
||||
data.writeShort(soundFX.ordinal());
|
||||
@@ -76,7 +74,7 @@ public class PacketFXSignal extends PacketCoordinates {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readData(DataInputStream data) throws IOException {
|
||||
protected void readData(DataInputStreamForestry data) throws IOException {
|
||||
super.readData(data);
|
||||
this.visualFX = VisualFXType.values()[data.readShort()];
|
||||
this.soundFX = SoundFXType.values()[data.readShort()];
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.network;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.client.entity.EntityClientPlayerMP;
|
||||
@@ -26,7 +24,7 @@ public class PacketGuiInteger extends ForestryPacket {
|
||||
|
||||
private int windowId, dataId, value;
|
||||
|
||||
public PacketGuiInteger(DataInputStream data) throws IOException {
|
||||
public PacketGuiInteger(DataInputStreamForestry data) throws IOException {
|
||||
super(data);
|
||||
}
|
||||
|
||||
@@ -38,14 +36,14 @@ public class PacketGuiInteger extends ForestryPacket {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeData(DataOutputStream data) throws IOException {
|
||||
public void writeData(DataOutputStreamForestry data) throws IOException {
|
||||
data.writeByte(windowId);
|
||||
data.writeByte(dataId);
|
||||
data.writeInt(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readData(DataInputStream data) throws IOException {
|
||||
protected void readData(DataInputStreamForestry data) throws IOException {
|
||||
windowId = data.readByte();
|
||||
dataId = data.readByte();
|
||||
value = data.readInt();
|
||||
|
||||
@@ -10,15 +10,13 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.network;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class PacketGuiSelect extends ForestryPacket {
|
||||
private int primaryIndex;
|
||||
private int secondaryIndex;
|
||||
|
||||
public PacketGuiSelect(DataInputStream data) throws IOException {
|
||||
public PacketGuiSelect(DataInputStreamForestry data) throws IOException {
|
||||
super(data);
|
||||
}
|
||||
|
||||
@@ -29,14 +27,14 @@ public class PacketGuiSelect extends ForestryPacket {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeData(DataOutputStream data) throws IOException {
|
||||
public void writeData(DataOutputStreamForestry data) throws IOException {
|
||||
super.writeData(data);
|
||||
data.writeInt(primaryIndex);
|
||||
data.writeInt(secondaryIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readData(DataInputStream data) throws IOException {
|
||||
protected void readData(DataInputStreamForestry data) throws IOException {
|
||||
super.readData(data);
|
||||
primaryIndex = data.readInt();
|
||||
secondaryIndex = data.readInt();
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.network;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.InputStream;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -69,7 +68,7 @@ public class PacketHandler {
|
||||
/** Returns true if the packet has been handled */
|
||||
private static boolean onPacketData(FMLProxyPacket fmlPacket, EntityPlayerMP player) {
|
||||
InputStream is = new ByteBufInputStream(fmlPacket.payload());
|
||||
DataInputStream data = new DataInputStream(is);
|
||||
DataInputStreamForestry data = new DataInputStreamForestry(is);
|
||||
|
||||
try {
|
||||
int packetIdOrdinal = data.readByte();
|
||||
@@ -81,11 +80,11 @@ public class PacketHandler {
|
||||
switch (packetId) {
|
||||
|
||||
case TILE_FORESTRY_UPDATE: {
|
||||
PacketTileStream packet = new PacketTileStream(data);
|
||||
PacketTileStream.onPacketData(data);
|
||||
return true;
|
||||
}
|
||||
case TILE_FORESTRY_ERROR_UPDATE: {
|
||||
PacketErrorUpdate packet = new PacketErrorUpdate(data);
|
||||
PacketErrorUpdate.onPacketData(data);
|
||||
return true;
|
||||
}
|
||||
case TILE_FORESTRY_GUI_OPENED: {
|
||||
@@ -101,11 +100,6 @@ public class PacketHandler {
|
||||
onSocketUpdate(packetS);
|
||||
return true;
|
||||
}
|
||||
case IINVENTORY_STACK: {
|
||||
PacketInventoryStack packet = new PacketInventoryStack(data);
|
||||
onInventoryStack(packet);
|
||||
return true;
|
||||
}
|
||||
case FX_SIGNAL: {
|
||||
PacketFXSignal packet = new PacketFXSignal(data);
|
||||
packet.executeFX();
|
||||
@@ -242,18 +236,6 @@ public class PacketHandler {
|
||||
}
|
||||
}
|
||||
|
||||
private static void onInventoryStack(PacketInventoryStack packet) {
|
||||
|
||||
TileEntity tile = packet.getTarget(Proxies.common.getRenderWorld());
|
||||
if (tile == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (tile instanceof IInventory) {
|
||||
((IInventory) tile).setInventorySlotContents(packet.slotIndex, packet.itemstack);
|
||||
}
|
||||
}
|
||||
|
||||
private static void onChipsetClick(PacketSlotClick packet, EntityPlayer player) {
|
||||
assert FMLCommonHandler.instance().getEffectiveSide().isServer();
|
||||
|
||||
|
||||
@@ -1,161 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.core.network;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompressedStreamTools;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import cpw.mods.fml.common.registry.GameData;
|
||||
|
||||
import forestry.core.proxy.Proxies;
|
||||
|
||||
public class PacketHelper {
|
||||
|
||||
public static ItemStack readItemStack(DataInputStream data) throws IOException {
|
||||
ItemStack itemstack = null;
|
||||
String itemName = data.readUTF();
|
||||
|
||||
if (!itemName.isEmpty()) {
|
||||
Item item = GameData.getItemRegistry().getRaw(itemName);
|
||||
byte stackSize = data.readByte();
|
||||
short meta = data.readShort();
|
||||
itemstack = new ItemStack(item, stackSize, meta);
|
||||
|
||||
if (item.isDamageable() || item.getShareTag()) {
|
||||
itemstack.stackTagCompound = readNBTTagCompound(data);
|
||||
}
|
||||
}
|
||||
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
public static void writeItemStack(ItemStack itemstack, DataOutputStream data) throws IOException {
|
||||
|
||||
if (itemstack == null) {
|
||||
data.writeUTF("");
|
||||
} else {
|
||||
data.writeUTF(GameData.getItemRegistry().getNameForObject(itemstack.getItem()));
|
||||
data.writeByte(itemstack.stackSize);
|
||||
data.writeShort(itemstack.getItemDamage());
|
||||
|
||||
if (itemstack.getItem().isDamageable() || itemstack.getItem().getShareTag()) {
|
||||
writeNBTTagCompound(itemstack.stackTagCompound, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static ItemStack[] readItemStacks(DataInputStream data) throws IOException {
|
||||
int stackCount = data.readShort();
|
||||
ItemStack[] itemStacks = new ItemStack[stackCount];
|
||||
for (int i = 0; i < stackCount; i++) {
|
||||
itemStacks[i] = PacketHelper.readItemStack(data);
|
||||
}
|
||||
return itemStacks;
|
||||
}
|
||||
|
||||
public static void writeItemStacks(ItemStack[] itemStacks, DataOutputStream data) throws IOException {
|
||||
data.writeShort(itemStacks.length);
|
||||
for (ItemStack itemstack : itemStacks) {
|
||||
PacketHelper.writeItemStack(itemstack, data);
|
||||
}
|
||||
}
|
||||
|
||||
public static void writeInventory(IInventory inventory, DataOutputStream data) throws IOException {
|
||||
int size = inventory.getSizeInventory();
|
||||
data.writeShort(size);
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
ItemStack stack = inventory.getStackInSlot(i);
|
||||
PacketHelper.writeItemStack(stack, data);
|
||||
}
|
||||
}
|
||||
|
||||
public static void readInventory(IInventory inventory, DataInputStream data) throws IOException {
|
||||
int size = data.readShort();
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
ItemStack stack = PacketHelper.readItemStack(data);
|
||||
inventory.setInventorySlotContents(i, stack);
|
||||
}
|
||||
}
|
||||
|
||||
public static <T extends IStreamable> void writeStreamables(List<T> streamables, DataOutputStream data) throws IOException {
|
||||
if (streamables == null) {
|
||||
data.writeInt(0);
|
||||
} else {
|
||||
data.writeInt(streamables.size());
|
||||
for (IStreamable streamable : streamables) {
|
||||
if (streamable != null) {
|
||||
data.writeBoolean(true);
|
||||
streamable.writeData(data);
|
||||
} else {
|
||||
data.writeBoolean(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static <T extends IStreamable> List<T> readStreamables(Class<T> streamableClass, DataInputStream data) throws IOException {
|
||||
int length = data.readInt();
|
||||
List<T> streamables = new ArrayList<T>(length);
|
||||
|
||||
try {
|
||||
if (length > 0) {
|
||||
for (int i = 0; i < length; i++) {
|
||||
if (data.readBoolean()) {
|
||||
T streamable = streamableClass.newInstance();
|
||||
streamable.readData(data);
|
||||
streamables.add(streamable);
|
||||
} else {
|
||||
streamables.add(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (ReflectiveOperationException e) {
|
||||
Proxies.log.severe("Failed to read Streamables for class " + streamableClass + " with error " + e);
|
||||
}
|
||||
return streamables;
|
||||
}
|
||||
|
||||
private static NBTTagCompound readNBTTagCompound(DataInputStream data) throws IOException {
|
||||
|
||||
short length = data.readShort();
|
||||
|
||||
if (length < 0) {
|
||||
return null;
|
||||
} else {
|
||||
byte[] compressed = new byte[length];
|
||||
data.readFully(compressed);
|
||||
return CompressedStreamTools.readCompressed(new ByteArrayInputStream(compressed));
|
||||
}
|
||||
}
|
||||
|
||||
private static void writeNBTTagCompound(NBTTagCompound nbttagcompound, DataOutputStream data) throws IOException {
|
||||
|
||||
if (nbttagcompound == null) {
|
||||
data.writeShort(-1);
|
||||
} else {
|
||||
byte[] compressed = CompressedStreamTools.compress(nbttagcompound);
|
||||
data.writeShort((short) compressed.length);
|
||||
data.write(compressed);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,6 @@ public enum PacketId {
|
||||
TILE_FORESTRY_ERROR_UPDATE,
|
||||
TILE_FORESTRY_GUI_OPENED,
|
||||
TILE_FORESTRY_ACTIVE,
|
||||
IINVENTORY_STACK,
|
||||
FX_SIGNAL,
|
||||
|
||||
WORKTABLE_MEMORY_UPDATE,
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.core.network;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class PacketInventoryStack extends PacketCoordinates {
|
||||
|
||||
public int slotIndex;
|
||||
public ItemStack itemstack;
|
||||
|
||||
public PacketInventoryStack(DataInputStream data) throws IOException {
|
||||
super(data);
|
||||
}
|
||||
|
||||
public PacketInventoryStack(PacketId id, int posX, int posY, int posZ, int slotIndex, ItemStack itemstack) {
|
||||
super(id, posX, posY, posZ);
|
||||
this.slotIndex = slotIndex;
|
||||
this.itemstack = itemstack;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeData(DataOutputStream data) throws IOException {
|
||||
super.writeData(data);
|
||||
data.writeInt(slotIndex);
|
||||
PacketHelper.writeItemStack(itemstack, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readData(DataInputStream data) throws IOException {
|
||||
super.readData(data);
|
||||
slotIndex = data.readInt();
|
||||
itemstack = PacketHelper.readItemStack(data);
|
||||
}
|
||||
}
|
||||
@@ -10,19 +10,15 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.network;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.nbt.CompressedStreamTools;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class PacketNBT extends ForestryPacket {
|
||||
|
||||
protected NBTTagCompound nbttagcompound;
|
||||
|
||||
public PacketNBT(DataInputStream data) throws IOException {
|
||||
public PacketNBT(DataInputStreamForestry data) throws IOException {
|
||||
super(data);
|
||||
}
|
||||
|
||||
@@ -32,18 +28,13 @@ public class PacketNBT extends ForestryPacket {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeData(DataOutputStream data) throws IOException {
|
||||
byte[] compressed = CompressedStreamTools.compress(nbttagcompound);
|
||||
data.writeShort(compressed.length);
|
||||
data.write(compressed);
|
||||
public void writeData(DataOutputStreamForestry data) throws IOException {
|
||||
data.writeNBTTagCompound(nbttagcompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readData(DataInputStream data) throws IOException {
|
||||
short length = data.readShort();
|
||||
byte[] compressed = new byte[length];
|
||||
data.readFully(compressed);
|
||||
this.nbttagcompound = CompressedStreamTools.readCompressed(new ByteArrayInputStream(compressed));
|
||||
protected void readData(DataInputStreamForestry data) throws IOException {
|
||||
this.nbttagcompound = data.readNBTTagCompound();
|
||||
}
|
||||
|
||||
public NBTTagCompound getTagCompound() {
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.network;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
@@ -19,7 +17,7 @@ import net.minecraft.tileentity.TileEntity;
|
||||
public class PacketSlotClick extends PacketCoordinates {
|
||||
private int slot;
|
||||
|
||||
public PacketSlotClick(DataInputStream data) throws IOException {
|
||||
public PacketSlotClick(DataInputStreamForestry data) throws IOException {
|
||||
super(data);
|
||||
}
|
||||
|
||||
@@ -29,15 +27,15 @@ public class PacketSlotClick extends PacketCoordinates {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readData(DataInputStream data) throws IOException {
|
||||
protected void readData(DataInputStreamForestry data) throws IOException {
|
||||
super.readData(data);
|
||||
this.slot = data.readInt();
|
||||
this.slot = data.readVarInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeData(DataOutputStream data) throws IOException {
|
||||
protected void writeData(DataOutputStreamForestry data) throws IOException {
|
||||
super.writeData(data);
|
||||
data.writeInt(slot);
|
||||
data.writeVarInt(slot);
|
||||
}
|
||||
|
||||
public int getSlot() {
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.network;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -23,7 +21,7 @@ public class PacketSocketUpdate extends PacketCoordinates {
|
||||
|
||||
public ItemStack[] itemStacks;
|
||||
|
||||
public PacketSocketUpdate(DataInputStream data) throws IOException {
|
||||
public PacketSocketUpdate(DataInputStreamForestry data) throws IOException {
|
||||
super(data);
|
||||
}
|
||||
|
||||
@@ -37,16 +35,16 @@ public class PacketSocketUpdate extends PacketCoordinates {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeData(DataOutputStream data) throws IOException {
|
||||
protected void writeData(DataOutputStreamForestry data) throws IOException {
|
||||
super.writeData(data);
|
||||
|
||||
PacketHelper.writeItemStacks(itemStacks, data);
|
||||
data.writeItemStacks(itemStacks);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readData(DataInputStream data) throws IOException {
|
||||
protected void readData(DataInputStreamForestry data) throws IOException {
|
||||
super.readData(data);
|
||||
|
||||
itemStacks = PacketHelper.readItemStacks(data);
|
||||
itemStacks = data.readItemStacks();
|
||||
}
|
||||
}
|
||||
@@ -10,15 +10,13 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.network;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class PacketString extends ForestryPacket {
|
||||
|
||||
private String string;
|
||||
|
||||
public PacketString(DataInputStream data) throws IOException {
|
||||
public PacketString(DataInputStreamForestry data) throws IOException {
|
||||
super(data);
|
||||
}
|
||||
|
||||
@@ -28,13 +26,13 @@ public class PacketString extends ForestryPacket {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeData(DataOutputStream data) throws IOException {
|
||||
protected void writeData(DataOutputStreamForestry data) throws IOException {
|
||||
super.writeData(data);
|
||||
data.writeUTF(string);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readData(DataInputStream data) throws IOException {
|
||||
protected void readData(DataInputStreamForestry data) throws IOException {
|
||||
super.readData(data);
|
||||
string = data.readUTF();
|
||||
}
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.network;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
@@ -23,11 +21,11 @@ public class PacketTileGuiOpened extends PacketCoordinates {
|
||||
|
||||
private TileForestry tileForestry;
|
||||
|
||||
public static void onPacketData(DataInputStream data) throws IOException {
|
||||
public static void onPacketData(DataInputStreamForestry data) throws IOException {
|
||||
new PacketTileGuiOpened(data);
|
||||
}
|
||||
|
||||
private PacketTileGuiOpened(DataInputStream data) throws IOException {
|
||||
private PacketTileGuiOpened(DataInputStreamForestry data) throws IOException {
|
||||
super(data);
|
||||
}
|
||||
|
||||
@@ -37,13 +35,13 @@ public class PacketTileGuiOpened extends PacketCoordinates {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeData(DataOutputStream data) throws IOException {
|
||||
protected void writeData(DataOutputStreamForestry data) throws IOException {
|
||||
super.writeData(data);
|
||||
tileForestry.writeGuiData(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readData(DataInputStream data) throws IOException {
|
||||
protected void readData(DataInputStreamForestry data) throws IOException {
|
||||
super.readData(data);
|
||||
|
||||
TileEntity tile = getTarget(Proxies.common.getRenderWorld());
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.network;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
@@ -22,7 +20,11 @@ public class PacketTileStream extends PacketCoordinates {
|
||||
|
||||
private IStreamable streamable;
|
||||
|
||||
public PacketTileStream(DataInputStream data) throws IOException {
|
||||
public static void onPacketData(DataInputStreamForestry data) throws IOException {
|
||||
new PacketTileStream(data);
|
||||
}
|
||||
|
||||
public PacketTileStream(DataInputStreamForestry data) throws IOException {
|
||||
super(data);
|
||||
}
|
||||
|
||||
@@ -32,13 +34,13 @@ public class PacketTileStream extends PacketCoordinates {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeData(DataOutputStream data) throws IOException {
|
||||
protected void writeData(DataOutputStreamForestry data) throws IOException {
|
||||
super.writeData(data);
|
||||
streamable.writeData(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readData(DataInputStream data) throws IOException {
|
||||
protected void readData(DataInputStreamForestry data) throws IOException {
|
||||
super.readData(data);
|
||||
|
||||
TileEntity tile = getTarget(Proxies.common.getRenderWorld());
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package forestry.energy;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -10,6 +8,8 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import forestry.core.GameMode;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.network.IStreamable;
|
||||
import forestry.core.utils.BlockUtil;
|
||||
|
||||
@@ -85,13 +85,13 @@ public class EnergyManager implements IEnergyHandler, IStreamable {
|
||||
|
||||
/* Packets */
|
||||
@Override
|
||||
public void writeData(DataOutputStream data) throws IOException {
|
||||
public void writeData(DataOutputStreamForestry data) throws IOException {
|
||||
int energyStored = energyStorage.getEnergyStored();
|
||||
data.writeInt(energyStored);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(DataInputStream data) throws IOException {
|
||||
public void readData(DataInputStreamForestry data) throws IOException {
|
||||
int energyStored = data.readInt();
|
||||
energyStorage.setEnergyStored(energyStored);
|
||||
}
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
******************************************************************************/
|
||||
package forestry.energy.gadgets;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -43,6 +41,8 @@ import forestry.core.gadgets.TileBase;
|
||||
import forestry.core.interfaces.ILiquidTankContainer;
|
||||
import forestry.core.inventory.IInventoryAdapter;
|
||||
import forestry.core.inventory.TileInventoryAdapter;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.network.GuiId;
|
||||
|
||||
public class EngineBronze extends Engine implements ISidedInventory, ILiquidTankContainer {
|
||||
@@ -283,13 +283,13 @@ public class EngineBronze extends Engine implements ISidedInventory, ILiquidTank
|
||||
|
||||
/* NETWORK */
|
||||
@Override
|
||||
public void writeData(DataOutputStream data) throws IOException {
|
||||
public void writeData(DataOutputStreamForestry data) throws IOException {
|
||||
super.writeData(data);
|
||||
data.writeBoolean(shutdown);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(DataInputStream data) throws IOException {
|
||||
public void readData(DataInputStreamForestry data) throws IOException {
|
||||
super.readData(data);
|
||||
shutdown = data.readBoolean();
|
||||
}
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
******************************************************************************/
|
||||
package forestry.factory.gadgets;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -27,8 +25,9 @@ import forestry.core.interfaces.ICrafter;
|
||||
import forestry.core.inventory.InvTools;
|
||||
import forestry.core.inventory.InventoryAdapter;
|
||||
import forestry.core.inventory.TileInventoryAdapter;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.network.GuiId;
|
||||
import forestry.core.network.PacketTileStream;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.GuiUtil;
|
||||
import forestry.core.utils.RecipeUtil;
|
||||
@@ -80,7 +79,7 @@ public class TileWorktable extends TileBase implements ICrafter {
|
||||
|
||||
/* NETWORK */
|
||||
@Override
|
||||
public void writeData(DataOutputStream data) throws IOException {
|
||||
public void writeData(DataOutputStreamForestry data) throws IOException {
|
||||
super.writeData(data);
|
||||
|
||||
craftingInventory.writeData(data);
|
||||
@@ -88,7 +87,7 @@ public class TileWorktable extends TileBase implements ICrafter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(DataInputStream data) throws IOException {
|
||||
public void readData(DataInputStreamForestry data) throws IOException {
|
||||
super.readData(data);
|
||||
|
||||
craftingInventory.readData(data);
|
||||
|
||||
@@ -10,18 +10,18 @@
|
||||
******************************************************************************/
|
||||
package forestry.factory.network;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.IPacketHandler;
|
||||
import forestry.core.network.PacketId;
|
||||
|
||||
public class PacketHandlerFactory implements IPacketHandler {
|
||||
|
||||
@Override
|
||||
public boolean onPacketData(PacketId packetID, DataInputStream data, EntityPlayer player) throws IOException {
|
||||
public boolean onPacketData(PacketId packetID, DataInputStreamForestry data, EntityPlayer player) throws IOException {
|
||||
|
||||
switch (packetID) {
|
||||
case WORKTABLE_MEMORY_UPDATE: {
|
||||
|
||||
@@ -10,12 +10,12 @@
|
||||
******************************************************************************/
|
||||
package forestry.factory.network;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.network.PacketCoordinates;
|
||||
import forestry.core.network.PacketId;
|
||||
import forestry.core.proxy.Proxies;
|
||||
@@ -26,11 +26,11 @@ public class PacketWorktableMemoryUpdate extends PacketCoordinates {
|
||||
|
||||
private RecipeMemory recipeMemory;
|
||||
|
||||
public static void onPacketData(DataInputStream data) throws IOException {
|
||||
public static void onPacketData(DataInputStreamForestry data) throws IOException {
|
||||
new PacketWorktableMemoryUpdate(data);
|
||||
}
|
||||
|
||||
private PacketWorktableMemoryUpdate(DataInputStream data) throws IOException {
|
||||
private PacketWorktableMemoryUpdate(DataInputStreamForestry data) throws IOException {
|
||||
super(data);
|
||||
}
|
||||
|
||||
@@ -40,13 +40,13 @@ public class PacketWorktableMemoryUpdate extends PacketCoordinates {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeData(DataOutputStream data) throws IOException {
|
||||
protected void writeData(DataOutputStreamForestry data) throws IOException {
|
||||
super.writeData(data);
|
||||
recipeMemory.writeData(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readData(DataInputStream data) throws IOException {
|
||||
protected void readData(DataInputStreamForestry data) throws IOException {
|
||||
super.readData(data);
|
||||
|
||||
TileEntity tile = getTarget(Proxies.common.getRenderWorld());
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
******************************************************************************/
|
||||
package forestry.factory.recipes;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
@@ -31,8 +29,9 @@ import net.minecraft.world.World;
|
||||
import forestry.api.core.INBTTagable;
|
||||
import forestry.core.gui.ContainerDummy;
|
||||
import forestry.core.inventory.InventoryAdapter;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.network.IStreamable;
|
||||
import forestry.core.network.PacketHelper;
|
||||
import forestry.core.utils.PlainInventory;
|
||||
|
||||
public class RecipeMemory implements INBTTagable, IStreamable {
|
||||
@@ -115,7 +114,7 @@ public class RecipeMemory implements INBTTagable, IStreamable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeData(DataOutputStream data) throws IOException {
|
||||
public void writeData(DataOutputStreamForestry data) throws IOException {
|
||||
sanitizeMatrix();
|
||||
matrix.writeData(data);
|
||||
data.writeLong(lastUsed);
|
||||
@@ -123,7 +122,7 @@ public class RecipeMemory implements INBTTagable, IStreamable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(DataInputStream data) throws IOException {
|
||||
public void readData(DataInputStreamForestry data) throws IOException {
|
||||
matrix = new InventoryAdapter(new InventoryCrafting(DUMMY_CONTAINER, 3, 3));
|
||||
matrix.readData(data);
|
||||
sanitizeMatrix();
|
||||
@@ -301,14 +300,14 @@ public class RecipeMemory implements INBTTagable, IStreamable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeData(DataOutputStream data) throws IOException {
|
||||
PacketHelper.writeStreamables(recipes, data);
|
||||
public void writeData(DataOutputStreamForestry data) throws IOException {
|
||||
data.writeStreamables(recipes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(DataInputStream data) throws IOException {
|
||||
public void readData(DataInputStreamForestry data) throws IOException {
|
||||
recipes.clear();
|
||||
List<Recipe> newRecipes = PacketHelper.readStreamables(Recipe.class, data);
|
||||
List<Recipe> newRecipes = data.readStreamables(Recipe.class);
|
||||
recipes.addAll(newRecipes);
|
||||
}
|
||||
}
|
||||
@@ -10,8 +10,6 @@
|
||||
******************************************************************************/
|
||||
package forestry.farming.gadgets;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -30,6 +28,8 @@ import forestry.api.farming.IFarmComponent;
|
||||
import forestry.api.farming.IFarmListener;
|
||||
import forestry.core.gadgets.TileForestry;
|
||||
import forestry.core.inventory.IInventoryAdapter;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.network.GuiId;
|
||||
|
||||
public abstract class TileFarm extends TileForestry implements IFarmComponent {
|
||||
@@ -133,7 +133,7 @@ public abstract class TileFarm extends TileForestry implements IFarmComponent {
|
||||
/* TILEFORESTRY */
|
||||
|
||||
@Override
|
||||
public void writeData(DataOutputStream data) throws IOException {
|
||||
public void writeData(DataOutputStreamForestry data) throws IOException {
|
||||
super.writeData(data);
|
||||
data.writeShort(farmBlock.ordinal());
|
||||
data.writeBoolean(isMaster());
|
||||
@@ -143,7 +143,7 @@ public abstract class TileFarm extends TileForestry implements IFarmComponent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(DataInputStream data) throws IOException {
|
||||
public void readData(DataInputStreamForestry data) throws IOException {
|
||||
super.readData(data);
|
||||
short farmBlockOrdinal = data.readShort();
|
||||
EnumFarmBlock farmType = EnumFarmBlock.values()[farmBlockOrdinal];
|
||||
|
||||
@@ -10,12 +10,12 @@
|
||||
******************************************************************************/
|
||||
package forestry.mail;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.IPacketHandler;
|
||||
import forestry.core.network.PacketId;
|
||||
import forestry.core.network.PacketString;
|
||||
@@ -31,7 +31,7 @@ import forestry.mail.network.PacketRequestLetterInfo;
|
||||
public class PacketHandlerMail implements IPacketHandler {
|
||||
|
||||
@Override
|
||||
public boolean onPacketData(PacketId packetID, DataInputStream data, EntityPlayer player) throws IOException {
|
||||
public boolean onPacketData(PacketId packetID, DataInputStreamForestry data, EntityPlayer player) throws IOException {
|
||||
|
||||
switch (packetID) {
|
||||
case LETTER_INFO: {
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
******************************************************************************/
|
||||
package forestry.mail.gadgets;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedList;
|
||||
@@ -34,6 +32,8 @@ import forestry.api.mail.PostManager;
|
||||
import forestry.core.EnumErrorCode;
|
||||
import forestry.core.gadgets.TileBase;
|
||||
import forestry.core.inventory.IInventoryAdapter;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.network.GuiId;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.StackUtils;
|
||||
@@ -92,13 +92,13 @@ public class MachineTrader extends TileBase {
|
||||
/* NETWORK */
|
||||
|
||||
@Override
|
||||
public void writeData(DataOutputStream data) throws IOException {
|
||||
public void writeData(DataOutputStreamForestry data) throws IOException {
|
||||
super.writeData(data);
|
||||
data.writeUTF(address.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(DataInputStream data) throws IOException {
|
||||
public void readData(DataInputStreamForestry data) throws IOException {
|
||||
super.readData(data);
|
||||
String address = data.readUTF();
|
||||
this.address = PostManager.postRegistry.getMailAddress(address);
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
******************************************************************************/
|
||||
package forestry.mail.network;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
|
||||
@@ -23,8 +21,9 @@ import forestry.api.mail.EnumAddressee;
|
||||
import forestry.api.mail.IMailAddress;
|
||||
import forestry.api.mail.PostManager;
|
||||
import forestry.api.mail.TradeStationInfo;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.network.ForestryPacket;
|
||||
import forestry.core.network.PacketHelper;
|
||||
import forestry.core.network.PacketId;
|
||||
import forestry.mail.EnumStationState;
|
||||
|
||||
@@ -34,7 +33,7 @@ public class PacketLetterInfo extends ForestryPacket {
|
||||
public TradeStationInfo tradeInfo;
|
||||
public IMailAddress address;
|
||||
|
||||
public PacketLetterInfo(DataInputStream data) throws IOException {
|
||||
public PacketLetterInfo(DataInputStreamForestry data) throws IOException {
|
||||
super(data);
|
||||
}
|
||||
|
||||
@@ -49,7 +48,7 @@ public class PacketLetterInfo extends ForestryPacket {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeData(DataOutputStream data) throws IOException {
|
||||
public void writeData(DataOutputStreamForestry data) throws IOException {
|
||||
|
||||
if (type == null) {
|
||||
data.writeShort(-1);
|
||||
@@ -88,15 +87,15 @@ public class PacketLetterInfo extends ForestryPacket {
|
||||
data.writeLong(tradeInfo.owner.getId().getLeastSignificantBits());
|
||||
data.writeUTF(tradeInfo.owner.getName());
|
||||
|
||||
PacketHelper.writeItemStack(tradeInfo.tradegood, data);
|
||||
PacketHelper.writeItemStacks(tradeInfo.required, data);
|
||||
data.writeItemStack(tradeInfo.tradegood);
|
||||
data.writeItemStacks(tradeInfo.required);
|
||||
|
||||
data.writeShort(tradeInfo.state.ordinal());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(DataInputStream data) throws IOException {
|
||||
public void readData(DataInputStreamForestry data) throws IOException {
|
||||
|
||||
if (data.readShort() < 0) {
|
||||
return;
|
||||
@@ -120,8 +119,8 @@ public class PacketLetterInfo extends ForestryPacket {
|
||||
ItemStack tradegood;
|
||||
ItemStack[] required;
|
||||
|
||||
tradegood = PacketHelper.readItemStack(data);
|
||||
required = PacketHelper.readItemStacks(data);
|
||||
tradegood = data.readItemStack();
|
||||
required = data.readItemStacks();
|
||||
|
||||
this.tradeInfo = new TradeStationInfo(address, owner, tradegood, required, EnumStationState.values()[data.readShort()]);
|
||||
}
|
||||
|
||||
@@ -10,10 +10,10 @@
|
||||
******************************************************************************/
|
||||
package forestry.mail.network;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.network.ForestryPacket;
|
||||
import forestry.core.network.PacketId;
|
||||
import forestry.mail.POBoxInfo;
|
||||
@@ -22,7 +22,7 @@ public class PacketPOBoxInfo extends ForestryPacket {
|
||||
|
||||
public POBoxInfo poboxInfo;
|
||||
|
||||
public PacketPOBoxInfo(DataInputStream data) throws IOException {
|
||||
public PacketPOBoxInfo(DataInputStreamForestry data) throws IOException {
|
||||
super(data);
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ public class PacketPOBoxInfo extends ForestryPacket {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeData(DataOutputStream data) throws IOException {
|
||||
protected void writeData(DataOutputStreamForestry data) throws IOException {
|
||||
if (poboxInfo == null) {
|
||||
data.writeShort(-1);
|
||||
return;
|
||||
@@ -44,7 +44,7 @@ public class PacketPOBoxInfo extends ForestryPacket {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readData(DataInputStream data) throws IOException {
|
||||
protected void readData(DataInputStreamForestry data) throws IOException {
|
||||
|
||||
short isNotNull = data.readShort();
|
||||
if (isNotNull < 0) {
|
||||
|
||||
@@ -10,11 +10,11 @@
|
||||
******************************************************************************/
|
||||
package forestry.mail.network;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import forestry.api.mail.EnumAddressee;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.network.ForestryPacket;
|
||||
import forestry.core.network.PacketId;
|
||||
|
||||
@@ -23,7 +23,7 @@ public class PacketRequestLetterInfo extends ForestryPacket {
|
||||
private String recipientName;
|
||||
private short addressType;
|
||||
|
||||
public PacketRequestLetterInfo(DataInputStream data) throws IOException {
|
||||
public PacketRequestLetterInfo(DataInputStreamForestry data) throws IOException {
|
||||
super(data);
|
||||
}
|
||||
|
||||
@@ -34,14 +34,14 @@ public class PacketRequestLetterInfo extends ForestryPacket {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeData(DataOutputStream data) throws IOException {
|
||||
protected void writeData(DataOutputStreamForestry data) throws IOException {
|
||||
super.writeData(data);
|
||||
data.writeUTF(recipientName);
|
||||
data.writeShort(addressType);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readData(DataInputStream data) throws IOException {
|
||||
protected void readData(DataInputStreamForestry data) throws IOException {
|
||||
super.readData(data);
|
||||
recipientName = data.readUTF();
|
||||
addressType = data.readShort();
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
******************************************************************************/
|
||||
package forestry.pipes.network;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
@@ -20,6 +18,8 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.network.PacketCoordinates;
|
||||
import forestry.core.network.PacketId;
|
||||
|
||||
@@ -30,7 +30,7 @@ public class PacketGenomeFilterChange extends PacketCoordinates {
|
||||
private int allele;
|
||||
private String species;
|
||||
|
||||
public PacketGenomeFilterChange(DataInputStream data) throws IOException {
|
||||
public PacketGenomeFilterChange(DataInputStreamForestry data) throws IOException {
|
||||
super(data);
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ public class PacketGenomeFilterChange extends PacketCoordinates {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeData(DataOutputStream data) throws IOException {
|
||||
public void writeData(DataOutputStreamForestry data) throws IOException {
|
||||
super.writeData(data);
|
||||
data.writeShort(orientation);
|
||||
data.writeShort(pattern);
|
||||
@@ -57,7 +57,7 @@ public class PacketGenomeFilterChange extends PacketCoordinates {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readData(DataInputStream data) throws IOException {
|
||||
protected void readData(DataInputStreamForestry data) throws IOException {
|
||||
super.readData(data);
|
||||
orientation = data.readShort();
|
||||
pattern = data.readShort();
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
******************************************************************************/
|
||||
package forestry.pipes.network;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -15,6 +14,7 @@ import net.minecraft.inventory.Container;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.ILocatedPacket;
|
||||
import forestry.core.network.IPacketHandler;
|
||||
import forestry.core.network.PacketCoordinates;
|
||||
@@ -40,7 +40,7 @@ public class PacketHandlerPipes implements IPacketHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPacketData(PacketId packetID, DataInputStream data, EntityPlayer player) throws IOException {
|
||||
public boolean onPacketData(PacketId packetID, DataInputStreamForestry data, EntityPlayer player) throws IOException {
|
||||
|
||||
switch (packetID) {
|
||||
// CLIENT
|
||||
|
||||
@@ -10,14 +10,14 @@
|
||||
******************************************************************************/
|
||||
package forestry.pipes.network;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.network.PacketCoordinates;
|
||||
import forestry.core.network.PacketId;
|
||||
import forestry.pipes.EnumFilterType;
|
||||
@@ -27,7 +27,7 @@ public class PacketTypeFilterChange extends PacketCoordinates {
|
||||
private int orientation;
|
||||
private int filter;
|
||||
|
||||
public PacketTypeFilterChange(DataInputStream data) throws IOException {
|
||||
public PacketTypeFilterChange(DataInputStreamForestry data) throws IOException {
|
||||
super(data);
|
||||
}
|
||||
|
||||
@@ -38,14 +38,14 @@ public class PacketTypeFilterChange extends PacketCoordinates {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeData(DataOutputStream data) throws IOException {
|
||||
protected void writeData(DataOutputStreamForestry data) throws IOException {
|
||||
super.writeData(data);
|
||||
data.writeShort(orientation);
|
||||
data.writeShort(filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readData(DataInputStream data) throws IOException {
|
||||
protected void readData(DataInputStreamForestry data) throws IOException {
|
||||
super.readData(data);
|
||||
orientation = data.readShort();
|
||||
filter = data.readShort();
|
||||
|
||||
Reference in new issue
Block a user