Move PacketHelper methods into DataStreams

This commit is contained in:
mezz committed 2015-06-09 00:23:36 -07:00
1 parent ff97fd8067
commit fa092e2a1b
57 files changed
+459 -508

No files matched your search

@@ -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);
}
}