mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-25 14:24:42 +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();
|
||||
|
||||
Reference in new issue
Block a user