From 2f93a3de229a3351d91708cf60fbc9ab7a1be97f Mon Sep 17 00:00:00 2001 From: OnyxDarkKnight Date: Thu, 11 Jun 2015 19:59:48 +0100 Subject: Improved color detection system by 10000000%! (not rly, but it's better than b4) --- .../network/PacketRequestLiquidData.java | 163 +++++++++-------- .../jewelrycraft/network/PacketSendLiquidData.java | 196 ++++++++++----------- 2 files changed, 177 insertions(+), 182 deletions(-) (limited to 'src/main/java/darkknight/jewelrycraft/network') diff --git a/src/main/java/darkknight/jewelrycraft/network/PacketRequestLiquidData.java b/src/main/java/darkknight/jewelrycraft/network/PacketRequestLiquidData.java index ebcfdf4..52440e2 100644 --- a/src/main/java/darkknight/jewelrycraft/network/PacketRequestLiquidData.java +++ b/src/main/java/darkknight/jewelrycraft/network/PacketRequestLiquidData.java @@ -1,82 +1,81 @@ -package darkknight.jewelrycraft.network; - -import io.netty.buffer.ByteBuf; -import cpw.mods.fml.common.network.simpleimpl.IMessage; -import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; -import cpw.mods.fml.common.network.simpleimpl.MessageContext; -import darkknight.jewelrycraft.JewelrycraftMod; - -public class PacketRequestLiquidData implements IMessage, IMessageHandler -{ - int dimID, x, y, z; - - /** - * - */ - public PacketRequestLiquidData() - {} - - /** - * @param dimID - * @param x - * @param y - * @param z - */ - public PacketRequestLiquidData(int dimID, int x, int y, int z) - { - this.dimID = dimID; - this.x = x; - this.y = y; - this.z = z; - } - - /** - * @param message - * @param ctx - * @return - */ - @Override - public IMessage onMessage(PacketRequestLiquidData message, MessageContext ctx) - { - String data = JewelrycraftMod.saveData.getString(message.x + " " + message.y + " " + message.z + " " + message.dimID); - String[] splitData = data.split(":"); - IMessage replyPacket = null; - if (splitData.length == 3){ - int itemID, itemDamage, color; - try{ - itemID = Integer.parseInt(splitData[0]); - itemDamage = Integer.parseInt(splitData[1]); - color = Integer.parseInt(splitData[2]); - replyPacket = new PacketSendLiquidData(message, itemID, itemDamage, color); - } - catch(Exception e){ - e.printStackTrace(); - } - } - return replyPacket; - } - - /** - * @param buf - */ - @Override - public void fromBytes(ByteBuf buf) - { - dimID = buf.readInt(); - x = buf.readInt(); - y = buf.readInt(); - z = buf.readInt(); - } - - /** - * @param buf - */ - @Override - public void toBytes(ByteBuf buf) - { - buf.writeInt(dimID); - buf.writeInt(x); - buf.writeInt(y); - buf.writeInt(z); - } -} +package darkknight.jewelrycraft.network; + +import io.netty.buffer.ByteBuf; +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; +import darkknight.jewelrycraft.JewelrycraftMod; + +public class PacketRequestLiquidData implements IMessage, IMessageHandler +{ + int dimID, x, y, z; + + /** + * + */ + public PacketRequestLiquidData() + {} + + /** + * @param dimID + * @param x + * @param y + * @param z + */ + public PacketRequestLiquidData(int dimID, int x, int y, int z) + { + this.dimID = dimID; + this.x = x; + this.y = y; + this.z = z; + } + + /** + * @param message + * @param ctx + * @return + */ + @Override + public IMessage onMessage(PacketRequestLiquidData message, MessageContext ctx) + { + String data = JewelrycraftMod.saveData.getString(message.x + " " + message.y + " " + message.z + " " + message.dimID); + String[] splitData = data.split(":"); + IMessage replyPacket = null; + if (splitData.length == 2){ + int itemID, itemDamage; + try{ + itemID = Integer.parseInt(splitData[0]); + itemDamage = Integer.parseInt(splitData[1]); + replyPacket = new PacketSendLiquidData(message, itemID, itemDamage); + } + catch(Exception e){ + e.printStackTrace(); + } + } + return replyPacket; + } + + /** + * @param buf + */ + @Override + public void fromBytes(ByteBuf buf) + { + dimID = buf.readInt(); + x = buf.readInt(); + y = buf.readInt(); + z = buf.readInt(); + } + + /** + * @param buf + */ + @Override + public void toBytes(ByteBuf buf) + { + buf.writeInt(dimID); + buf.writeInt(x); + buf.writeInt(y); + buf.writeInt(z); + } +} diff --git a/src/main/java/darkknight/jewelrycraft/network/PacketSendLiquidData.java b/src/main/java/darkknight/jewelrycraft/network/PacketSendLiquidData.java index bad14e7..dcb265b 100644 --- a/src/main/java/darkknight/jewelrycraft/network/PacketSendLiquidData.java +++ b/src/main/java/darkknight/jewelrycraft/network/PacketSendLiquidData.java @@ -1,100 +1,96 @@ -package darkknight.jewelrycraft.network; - -import io.netty.buffer.ByteBuf; -import net.minecraft.client.Minecraft; -import cpw.mods.fml.common.network.simpleimpl.IMessage; -import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; -import cpw.mods.fml.common.network.simpleimpl.MessageContext; -import darkknight.jewelrycraft.JewelrycraftMod; - -public class PacketSendLiquidData implements IMessage, IMessageHandler -{ - int dimID, x, y, z, itemID, itemMeta, color; - - /** - * - */ - public PacketSendLiquidData() - {} - - /** - * @param packet - * @param itemID - * @param itemMeta - * @param color - */ - public PacketSendLiquidData(PacketRequestLiquidData packet, int itemID, int itemMeta, int color) - { - dimID = packet.dimID; - x = packet.x; - y = packet.y; - z = packet.z; - this.itemID = itemID; - this.itemMeta = itemMeta; - this.color = color; - } - - /** - * @param dimID - * @param x - * @param y - * @param z - * @param itemID - * @param itemMeta - * @param color - */ - public PacketSendLiquidData(int dimID, int x, int y, int z, int itemID, int itemMeta, int color) - { - this.dimID = dimID; - this.x = x; - this.y = y; - this.z = z; - this.itemID = itemID; - this.itemMeta = itemMeta; - this.color = color; - } - - /** - * @param buf - */ - @Override - public void fromBytes(ByteBuf buf) - { - dimID = buf.readInt(); - x = buf.readInt(); - y = buf.readInt(); - z = buf.readInt(); - itemID = buf.readInt(); - itemMeta = buf.readInt(); - color = buf.readInt(); - } - - /** - * @param buf - */ - @Override - public void toBytes(ByteBuf buf) - { - buf.writeInt(dimID); - buf.writeInt(x); - buf.writeInt(y); - buf.writeInt(z); - buf.writeInt(itemID); - buf.writeInt(itemMeta); - buf.writeInt(color); - } - - /** - * @param message - * @param ctx - * @return - */ - @Override - public IMessage onMessage(PacketSendLiquidData message, MessageContext ctx) - { - JewelrycraftMod.clientData.setString(message.x + " " + message.y + " " + message.z + " " + message.dimID, message.itemID + ":" + message.itemMeta + ":" + message.color); - Minecraft.getMinecraft().theWorld.getBlock(message.x, message.y, message.z); - Minecraft.getMinecraft().theWorld.markBlockForUpdate(message.x, message.y, message.z); - return null; - } -} +package darkknight.jewelrycraft.network; + +import io.netty.buffer.ByteBuf; +import net.minecraft.client.Minecraft; +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; +import darkknight.jewelrycraft.JewelrycraftMod; + +public class PacketSendLiquidData implements IMessage, IMessageHandler +{ + int dimID, x, y, z, itemID, itemMeta; + + /** + * + */ + public PacketSendLiquidData() + {} + + /** + * @param packet + * @param itemID + * @param itemMeta + * @param color + */ + public PacketSendLiquidData(PacketRequestLiquidData packet, int itemID, int itemMeta) + { + dimID = packet.dimID; + x = packet.x; + y = packet.y; + z = packet.z; + this.itemID = itemID; + this.itemMeta = itemMeta; + } + + /** + * @param dimID + * @param x + * @param y + * @param z + * @param itemID + * @param itemMeta + * @param color + */ + public PacketSendLiquidData(int dimID, int x, int y, int z, int itemID, int itemMeta) + { + this.dimID = dimID; + this.x = x; + this.y = y; + this.z = z; + this.itemID = itemID; + this.itemMeta = itemMeta; + } + + /** + * @param buf + */ + @Override + public void fromBytes(ByteBuf buf) + { + dimID = buf.readInt(); + x = buf.readInt(); + y = buf.readInt(); + z = buf.readInt(); + itemID = buf.readInt(); + itemMeta = buf.readInt(); + } + + /** + * @param buf + */ + @Override + public void toBytes(ByteBuf buf) + { + buf.writeInt(dimID); + buf.writeInt(x); + buf.writeInt(y); + buf.writeInt(z); + buf.writeInt(itemID); + buf.writeInt(itemMeta); + } + + /** + * @param message + * @param ctx + * @return + */ + @Override + public IMessage onMessage(PacketSendLiquidData message, MessageContext ctx) + { + JewelrycraftMod.clientData.setString(message.x + " " + message.y + " " + message.z + " " + message.dimID, message.itemID + ":" + message.itemMeta); + Minecraft.getMinecraft().theWorld.getBlock(message.x, message.y, message.z); + Minecraft.getMinecraft().theWorld.markBlockForUpdate(message.x, message.y, message.z); + return null; + } +} -- cgit v1.2.3