progress made in MC 1.7 network support
This commit is contained in:
parent
13213cd59d
commit
14003341e3
41 changed files with 384 additions and 231 deletions
|
@ -64,6 +64,7 @@ import buildcraft.core.InterModComms;
|
|||
import buildcraft.core.Version;
|
||||
import buildcraft.core.blueprints.BptPlayerIndex;
|
||||
import buildcraft.core.blueprints.BptRootIndex;
|
||||
import buildcraft.core.network.PacketHandler;
|
||||
import buildcraft.core.proxy.CoreProxy;
|
||||
import buildcraft.core.utils.BCLog;
|
||||
import cpw.mods.fml.common.Mod;
|
||||
|
@ -79,9 +80,11 @@ import cpw.mods.fml.common.registry.GameRegistry;
|
|||
import cpw.mods.fml.common.registry.LanguageRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.LinkedList;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -93,8 +96,7 @@ import net.minecraftforge.common.config.Property;
|
|||
import net.minecraftforge.event.ForgeSubscribe;
|
||||
|
||||
@Mod(name = "BuildCraft Builders", version = Version.VERSION, useMetadata = false, modid = "BuildCraft|Builders", dependencies = DefaultProps.DEPENDENCY_CORE)
|
||||
@NetworkMod(channels = {DefaultProps.NET_CHANNEL_NAME}, packetHandler = PacketHandlerBuilders.class, clientSideRequired = true, serverSideRequired = true)
|
||||
public class BuildCraftBuilders {
|
||||
public class BuildCraftBuilders extends BuildCraftMod {
|
||||
|
||||
public static final int LIBRARY_PAGE_SIZE = 12;
|
||||
public static final int MAX_BLUEPRINTS_NAME_SIZE = 14;
|
||||
|
@ -118,8 +120,11 @@ public class BuildCraftBuilders {
|
|||
|
||||
@EventHandler
|
||||
public void init(FMLInitializationEvent evt) {
|
||||
channels = NetworkRegistry.INSTANCE.newChannel
|
||||
(DefaultProps.NET_CHANNEL_NAME + "-BUILDERS", new PacketHandlerBuilders());
|
||||
|
||||
// Register gui handler
|
||||
NetworkRegistry.instance().registerGuiHandler(instance, new GuiHandler());
|
||||
NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler());
|
||||
|
||||
// Register save handler
|
||||
MinecraftForge.EVENT_BUS.register(new EventHandlerBuilders());
|
||||
|
|
|
@ -8,15 +8,21 @@
|
|||
package buildcraft;
|
||||
|
||||
import static buildcraft.BuildCraftEnergy.spawnOilSprings;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.EnumMap;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockFluid;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import net.minecraftforge.common.IPlantable;
|
||||
|
@ -47,6 +53,7 @@ import buildcraft.core.SpringPopulate;
|
|||
import buildcraft.core.TickHandlerCoreClient;
|
||||
import buildcraft.core.Version;
|
||||
import buildcraft.core.blueprints.BptItem;
|
||||
import buildcraft.core.network.BuildCraftPacket;
|
||||
import buildcraft.core.network.EntityIds;
|
||||
import buildcraft.core.network.PacketHandler;
|
||||
import buildcraft.core.network.PacketUpdate;
|
||||
|
@ -76,7 +83,8 @@ import cpw.mods.fml.common.event.FMLInterModComms;
|
|||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLServerStartingEvent;
|
||||
import cpw.mods.fml.common.network.NetworkMod;
|
||||
import cpw.mods.fml.common.network.FMLEmbeddedChannel;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import cpw.mods.fml.common.registry.EntityRegistry;
|
||||
import cpw.mods.fml.common.registry.LanguageRegistry;
|
||||
import cpw.mods.fml.common.registry.TickRegistry;
|
||||
|
@ -84,11 +92,8 @@ import cpw.mods.fml.relauncher.Side;
|
|||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@Mod(name = "BuildCraft", version = Version.VERSION, useMetadata = false, modid = "BuildCraft|Core", acceptedMinecraftVersions = "[1.6.4,1.7)", dependencies = "required-after:Forge@[9.11.1.953,)")
|
||||
@NetworkMod(channels = {DefaultProps.NET_CHANNEL_NAME}, packetHandler = PacketHandler.class, clientSideRequired = true, serverSideRequired = true)
|
||||
public class BuildCraftCore {
|
||||
|
||||
public class BuildCraftCore extends BuildCraftMod {
|
||||
public static enum RenderMode {
|
||||
|
||||
Full, NoDynamic
|
||||
};
|
||||
public static RenderMode render = RenderMode.Full;
|
||||
|
@ -264,7 +269,9 @@ public class BuildCraftCore {
|
|||
|
||||
@EventHandler
|
||||
public void initialize(FMLInitializationEvent evt) {
|
||||
// MinecraftForge.registerConnectionHandler(new ConnectionHandler());
|
||||
channels = NetworkRegistry.INSTANCE.newChannel
|
||||
(DefaultProps.NET_CHANNEL_NAME + "-CORE", new PacketHandler());
|
||||
|
||||
ActionManager.registerTriggerProvider(new DefaultTriggerProvider());
|
||||
ActionManager.registerActionProvider(new DefaultActionProvider());
|
||||
|
||||
|
|
|
@ -62,8 +62,7 @@ import net.minecraftforge.fluids.FluidRegistry;
|
|||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
@Mod(name = "BuildCraft Energy", version = Version.VERSION, useMetadata = false, modid = "BuildCraft|Energy", dependencies = DefaultProps.DEPENDENCY_CORE)
|
||||
@NetworkMod(channels = {DefaultProps.NET_CHANNEL_NAME}, clientSideRequired = true, serverSideRequired = true)
|
||||
public class BuildCraftEnergy {
|
||||
public class BuildCraftEnergy extends BuildCraftMod {
|
||||
|
||||
public final static int ENERGY_REMOVE_BLOCK = 25;
|
||||
public final static int ENERGY_EXTRACT_ITEM = 2;
|
||||
|
@ -222,7 +221,7 @@ public class BuildCraftEnergy {
|
|||
|
||||
@EventHandler
|
||||
public void init(FMLInitializationEvent evt) {
|
||||
NetworkRegistry.instance().registerGuiHandler(instance, new GuiHandler());
|
||||
NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler());
|
||||
|
||||
new BptBlockEngine(engineBlock.blockID);
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ package buildcraft;
|
|||
import buildcraft.core.DefaultProps;
|
||||
import buildcraft.core.InterModComms;
|
||||
import buildcraft.core.Version;
|
||||
import buildcraft.core.network.PacketHandler;
|
||||
import buildcraft.core.proxy.CoreProxy;
|
||||
import buildcraft.core.utils.ConfigUtils;
|
||||
import buildcraft.factory.BlockAutoWorkbench;
|
||||
|
@ -39,7 +40,9 @@ import buildcraft.factory.TileQuarry;
|
|||
import buildcraft.factory.TileRefinery;
|
||||
import buildcraft.factory.TileTank;
|
||||
import buildcraft.factory.network.PacketHandlerFactory;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import cpw.mods.fml.common.Mod.EventHandler;
|
||||
import cpw.mods.fml.common.Mod.Instance;
|
||||
|
@ -51,7 +54,9 @@ import cpw.mods.fml.common.network.NetworkMod;
|
|||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.item.Item;
|
||||
|
@ -66,8 +71,7 @@ import net.minecraftforge.common.config.Property;
|
|||
import net.minecraftforge.event.ForgeSubscribe;
|
||||
|
||||
@Mod(name = "BuildCraft Factory", version = Version.VERSION, useMetadata = false, modid = "BuildCraft|Factory", dependencies = DefaultProps.DEPENDENCY_CORE)
|
||||
@NetworkMod(channels = {DefaultProps.NET_CHANNEL_NAME}, packetHandler = PacketHandlerFactory.class, clientSideRequired = true, serverSideRequired = true)
|
||||
public class BuildCraftFactory {
|
||||
public class BuildCraftFactory extends BuildCraftMod {
|
||||
|
||||
public static final int MINING_MJ_COST_PER_BLOCK = 64;
|
||||
public static BlockQuarry quarryBlock;
|
||||
|
@ -127,7 +131,7 @@ public class BuildCraftFactory {
|
|||
|
||||
@EventHandler
|
||||
public void load(FMLInitializationEvent evt) {
|
||||
NetworkRegistry.instance().registerGuiHandler(instance, new GuiHandler());
|
||||
NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler());
|
||||
|
||||
// EntityRegistry.registerModEntity(EntityMechanicalArm.class, "bcMechanicalArm", EntityIds.MECHANICAL_ARM, instance, 50, 1, true);
|
||||
|
||||
|
@ -154,6 +158,9 @@ public class BuildCraftFactory {
|
|||
|
||||
@EventHandler
|
||||
public void initialize(FMLPreInitializationEvent evt) {
|
||||
channels = NetworkRegistry.INSTANCE.newChannel
|
||||
(DefaultProps.NET_CHANNEL_NAME + "-FACTORY", new PacketHandlerFactory());
|
||||
|
||||
ConfigUtils genCat = new ConfigUtils(BuildCraftCore.mainConfiguration, Configuration.CATEGORY_GENERAL);
|
||||
|
||||
allowMining = genCat.get("mining.enabled", true, "disables the recipes for automated mining machines");
|
||||
|
|
34
common/buildcraft/BuildCraftMod.java
Executable file
34
common/buildcraft/BuildCraftMod.java
Executable file
|
@ -0,0 +1,34 @@
|
|||
package buildcraft;
|
||||
|
||||
import java.util.EnumMap;
|
||||
|
||||
import cpw.mods.fml.common.network.FMLEmbeddedChannel;
|
||||
import cpw.mods.fml.common.network.FMLOutboundHandler;
|
||||
import cpw.mods.fml.common.network.FMLOutboundHandler.OutboundTarget;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.world.World;
|
||||
import buildcraft.core.network.BuildCraftPacket;
|
||||
|
||||
public class BuildCraftMod {
|
||||
public EnumMap<Side, FMLEmbeddedChannel> channels;
|
||||
|
||||
public void sendToPlayers(BuildCraftPacket packet, World world, int x, int y, int z, int maxDistance) {
|
||||
channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.ALL);
|
||||
channels.get(Side.SERVER).writeOutbound(packet);
|
||||
}
|
||||
|
||||
public void sendToPlayer(EntityPlayer entityplayer, BuildCraftPacket packet) {
|
||||
channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.PLAYER);
|
||||
channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(entityplayer);
|
||||
channels.get(Side.SERVER).writeOutbound(packet);
|
||||
}
|
||||
|
||||
public void sendToServer(BuildCraftPacket packet) {
|
||||
channels.get(Side.CLIENT).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(OutboundTarget.TOSERVER);
|
||||
channels.get(Side.CLIENT).writeOutbound(packet);
|
||||
}
|
||||
|
||||
}
|
|
@ -16,6 +16,7 @@ import buildcraft.core.InterModComms;
|
|||
import buildcraft.silicon.ItemRedstoneChipset;
|
||||
import buildcraft.silicon.ItemRedstoneChipset.Chipset;
|
||||
import buildcraft.core.Version;
|
||||
import buildcraft.core.network.PacketHandler;
|
||||
import buildcraft.core.proxy.CoreProxy;
|
||||
import buildcraft.silicon.BlockLaser;
|
||||
import buildcraft.silicon.BlockLaserTable;
|
||||
|
@ -44,17 +45,18 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
|||
import cpw.mods.fml.common.network.NetworkMod;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import cpw.mods.fml.common.registry.LanguageRegistry;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.config.Property;
|
||||
|
||||
@Mod(name = "BuildCraft Silicon", version = Version.VERSION, useMetadata = false, modid = "BuildCraft|Silicon", dependencies = DefaultProps.DEPENDENCY_TRANSPORT)
|
||||
@NetworkMod(channels = {DefaultProps.NET_CHANNEL_NAME}, packetHandler = PacketHandlerSilicon.class, clientSideRequired = true, serverSideRequired = true)
|
||||
public class BuildCraftSilicon {
|
||||
public class BuildCraftSilicon extends BuildCraftMod {
|
||||
|
||||
public static ItemRedstoneChipset redstoneChipset;
|
||||
public static BlockLaser laserBlock;
|
||||
|
@ -91,7 +93,10 @@ public class BuildCraftSilicon {
|
|||
|
||||
@EventHandler
|
||||
public void init(FMLInitializationEvent evt) {
|
||||
NetworkRegistry.instance().registerGuiHandler(instance, new GuiHandler());
|
||||
channels = NetworkRegistry.INSTANCE.newChannel
|
||||
(DefaultProps.NET_CHANNEL_NAME + "-SILICON", new PacketHandlerSilicon());
|
||||
|
||||
NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler());
|
||||
CoreProxy.proxy.registerTileEntity(TileLaser.class, "net.minecraft.src.buildcraft.factory.TileLaser");
|
||||
CoreProxy.proxy.registerTileEntity(TileAssemblyTable.class, "net.minecraft.src.buildcraft.factory.TileAssemblyTable");
|
||||
CoreProxy.proxy.registerTileEntity(TileAdvancedCraftingTable.class, "net.minecraft.src.buildcraft.factory.TileAssemblyAdvancedWorkbench");
|
||||
|
|
|
@ -16,6 +16,7 @@ import buildcraft.core.DefaultProps;
|
|||
import buildcraft.core.InterModComms;
|
||||
import buildcraft.core.ItemBuildCraft;
|
||||
import buildcraft.core.Version;
|
||||
import buildcraft.core.network.PacketHandler;
|
||||
import buildcraft.core.proxy.CoreProxy;
|
||||
import buildcraft.core.triggers.BCAction;
|
||||
import buildcraft.core.triggers.BCTrigger;
|
||||
|
@ -101,7 +102,9 @@ import cpw.mods.fml.common.network.NetworkMod;
|
|||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.common.registry.LanguageRegistry;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
|
@ -113,7 +116,7 @@ import net.minecraftforge.common.config.Property;
|
|||
|
||||
@Mod(version = Version.VERSION, modid = "BuildCraft|Transport", name = "Buildcraft Transport", dependencies = DefaultProps.DEPENDENCY_CORE)
|
||||
@NetworkMod(channels = {DefaultProps.NET_CHANNEL_NAME}, packetHandler = PacketHandlerTransport.class, connectionHandler = TransportConnectionHandler.class)
|
||||
public class BuildCraftTransport {
|
||||
public class BuildCraftTransport extends BuildCraftMod {
|
||||
|
||||
public static BlockGenericPipe genericPipeBlock;
|
||||
public static float pipeDurability;
|
||||
|
@ -344,6 +347,9 @@ public class BuildCraftTransport {
|
|||
|
||||
@EventHandler
|
||||
public void init(FMLInitializationEvent evt) {
|
||||
channels = NetworkRegistry.INSTANCE.newChannel
|
||||
(DefaultProps.NET_CHANNEL_NAME + "-TRANSPORT", new PacketHandlerTransport());
|
||||
|
||||
// Register connection handler
|
||||
// MinecraftForge.registerConnectionHandler(new ConnectionHandler());
|
||||
|
||||
|
@ -377,7 +383,7 @@ public class BuildCraftTransport {
|
|||
}
|
||||
|
||||
TransportProxy.proxy.registerRenderers();
|
||||
NetworkRegistry.instance().registerGuiHandler(instance, new GuiHandler());
|
||||
NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
|
|
@ -2,41 +2,50 @@ package buildcraft.builders.network;
|
|||
|
||||
import buildcraft.builders.TileArchitect;
|
||||
import buildcraft.builders.TileBlueprintLibrary;
|
||||
import buildcraft.core.network.BuildCraftChannelHandler;
|
||||
import buildcraft.core.network.BuildCraftPacket;
|
||||
import buildcraft.core.network.PacketIds;
|
||||
import buildcraft.core.network.PacketPayloadArrays;
|
||||
import buildcraft.core.network.PacketUpdate;
|
||||
import buildcraft.core.proxy.CoreProxy;
|
||||
import cpw.mods.fml.common.network.IPacketHandler;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import cpw.mods.fml.common.network.Player;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.DataInputStream;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.network.INetHandler;
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import net.minecraft.network.packet.Packet250CustomPayload;
|
||||
import net.minecraft.network.Packet250CustomPayload;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class PacketHandlerBuilders implements IPacketHandler {
|
||||
public class PacketHandlerBuilders extends BuildCraftChannelHandler {
|
||||
|
||||
@Override
|
||||
public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player) {
|
||||
public void decodeInto(ChannelHandlerContext ctx, ByteBuf data, BuildCraftPacket packet) {
|
||||
super.decodeInto(ctx, data, packet);
|
||||
|
||||
DataInputStream data = new DataInputStream(new ByteArrayInputStream(packet.data));
|
||||
try {
|
||||
int packetID = data.read();
|
||||
INetHandler netHandler = ctx.channel().attr(NetworkRegistry.NET_HANDLER).get();
|
||||
|
||||
EntityPlayer player =
|
||||
CoreProxy.proxy.getPlayerFromNetHandler(netHandler);
|
||||
|
||||
int packetID = packet.getID();
|
||||
|
||||
switch (packetID) {
|
||||
case PacketIds.ARCHITECT_NAME:
|
||||
PacketUpdate packetA = new PacketUpdate();
|
||||
packetA.readData(data);
|
||||
onArchitectName((EntityPlayer) player, packetA);
|
||||
onArchitectName(player, (PacketUpdate) packet);
|
||||
break;
|
||||
case PacketIds.LIBRARY_ACTION:
|
||||
PacketLibraryAction packetB = new PacketLibraryAction();
|
||||
packetB.readData(data);
|
||||
onLibraryAction((EntityPlayer) player, packetB);
|
||||
onLibraryAction(player, (PacketLibraryAction) packet);
|
||||
break;
|
||||
case PacketIds.LIBRARY_SELECT:
|
||||
PacketLibraryAction packetC = new PacketLibraryAction();
|
||||
packetC.readData(data);
|
||||
onLibrarySelect((EntityPlayer) player, packetC);
|
||||
onLibrarySelect(player, (PacketLibraryAction) packet);
|
||||
break;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package buildcraft.builders.network;
|
||||
|
||||
import buildcraft.core.network.PacketCoordinates;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
@ -17,13 +19,13 @@ public class PacketLibraryAction extends PacketCoordinates {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void writeData(DataOutputStream data) throws IOException {
|
||||
public void writeData(ByteBuf data) {
|
||||
data.writeInt(actionId);
|
||||
super.writeData(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(DataInputStream data) throws IOException {
|
||||
public void readData(ByteBuf data) {
|
||||
actionId = data.readInt();
|
||||
super.readData(data);
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ import net.minecraft.entity.EntityLivingBase;
|
|||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
|
|
21
common/buildcraft/core/network/BuildCraftChannelHandler.java
Executable file
21
common/buildcraft/core/network/BuildCraftChannelHandler.java
Executable file
|
@ -0,0 +1,21 @@
|
|||
package buildcraft.core.network;
|
||||
|
||||
import cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
|
||||
public class BuildCraftChannelHandler extends FMLIndexedMessageToMessageCodec<BuildCraftPacket> {
|
||||
|
||||
public BuildCraftChannelHandler() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encodeInto(ChannelHandlerContext ctx, BuildCraftPacket packet, ByteBuf data) throws Exception {
|
||||
packet.writeData(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decodeInto(ChannelHandlerContext ctx, ByteBuf data, BuildCraftPacket packet) {
|
||||
packet.readData(data);
|
||||
}
|
||||
}
|
|
@ -1,39 +1,15 @@
|
|||
package buildcraft.core.network;
|
||||
|
||||
import buildcraft.core.DefaultProps;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.network.packet.Packet250CustomPayload;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
public abstract class BuildCraftPacket {
|
||||
|
||||
protected boolean isChunkDataPacket = false;
|
||||
protected String channel = DefaultProps.NET_CHANNEL_NAME;
|
||||
|
||||
public abstract int getID();
|
||||
|
||||
public Packet getPacket() {
|
||||
public abstract void readData(ByteBuf data);
|
||||
|
||||
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
|
||||
DataOutputStream data = new DataOutputStream(bytes);
|
||||
try {
|
||||
data.writeByte(getID());
|
||||
writeData(data);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Packet250CustomPayload packet = new Packet250CustomPayload();
|
||||
packet.channel = channel;
|
||||
packet.data = bytes.toByteArray();
|
||||
packet.length = packet.data.length;
|
||||
packet.isChunkDataPacket = this.isChunkDataPacket;
|
||||
return packet;
|
||||
}
|
||||
|
||||
public abstract void readData(DataInputStream data) throws IOException;
|
||||
|
||||
public abstract void writeData(DataOutputStream data) throws IOException;
|
||||
public abstract void writeData(ByteBuf data);
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
package buildcraft.core.network;
|
||||
|
||||
import java.io.IOException;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.network.Packet;
|
||||
|
||||
public interface ISynchronizedTile {
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package buildcraft.core.network;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
@ -25,7 +27,7 @@ public class PacketCoordinates extends BuildCraftPacket {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void writeData(DataOutputStream data) throws IOException {
|
||||
public void writeData(ByteBuf data) {
|
||||
|
||||
data.writeInt(posX);
|
||||
data.writeInt(posY);
|
||||
|
@ -33,7 +35,7 @@ public class PacketCoordinates extends BuildCraftPacket {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void readData(DataInputStream data) throws IOException {
|
||||
public void readData(ByteBuf data) {
|
||||
|
||||
posX = data.readInt();
|
||||
posY = data.readInt();
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package buildcraft.core.network;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
@ -35,7 +37,7 @@ public class PacketGuiReturn extends BuildCraftPacket {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void writeData(DataOutputStream data) throws IOException {
|
||||
public void writeData(ByteBuf data) {
|
||||
data.writeInt(obj.getWorld().provider.dimensionId);
|
||||
if (obj instanceof TileEntity) {
|
||||
TileEntity tile = (TileEntity) obj;
|
||||
|
@ -55,7 +57,7 @@ public class PacketGuiReturn extends BuildCraftPacket {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void readData(DataInputStream data) throws IOException {
|
||||
public void readData(ByteBuf data) {
|
||||
int dim = data.readInt();
|
||||
World world = DimensionManager.getWorld(dim);
|
||||
boolean tileReturn = data.readBoolean();
|
||||
|
|
|
@ -10,9 +10,12 @@ package buildcraft.core.network;
|
|||
|
||||
import buildcraft.core.gui.BuildCraftContainer;
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.client.entity.EntityClientPlayerMP;
|
||||
/**
|
||||
*
|
||||
|
@ -34,14 +37,14 @@ public class PacketGuiWidget extends BuildCraftPacket {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void writeData(DataOutputStream data) throws IOException {
|
||||
public void writeData(ByteBuf data) {
|
||||
data.writeByte(windowId);
|
||||
data.writeByte(widgetId);
|
||||
data.write(payload);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(DataInputStream data) throws IOException {
|
||||
public void readData(ByteBuf data) {
|
||||
windowId = data.readByte();
|
||||
widgetId = data.readByte();
|
||||
|
||||
|
|
|
@ -1,18 +1,20 @@
|
|||
package buildcraft.core.network;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import buildcraft.core.proxy.CoreProxy;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import net.minecraft.network.packet.Packet250CustomPayload;
|
||||
import net.minecraft.network.INetHandler;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.common.network.IPacketHandler;
|
||||
import cpw.mods.fml.common.network.Player;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
|
||||
public class PacketHandler implements IPacketHandler {
|
||||
public class PacketHandler extends BuildCraftChannelHandler {
|
||||
|
||||
private void onTileUpdate(EntityPlayer player, PacketTileUpdate packet) throws IOException {
|
||||
World world = player.worldObj;
|
||||
|
@ -30,23 +32,28 @@ public class PacketHandler implements IPacketHandler {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player) {
|
||||
DataInputStream data = new DataInputStream(new ByteArrayInputStream(packet.data));
|
||||
public void decodeInto(ChannelHandlerContext ctx, ByteBuf data, BuildCraftPacket packet) {
|
||||
super.decodeInto(ctx, data, packet);
|
||||
|
||||
try {
|
||||
|
||||
int packetID = data.read();
|
||||
INetHandler netHandler = ctx.channel().attr(NetworkRegistry.NET_HANDLER).get();
|
||||
|
||||
EntityPlayer player =
|
||||
CoreProxy.proxy.getPlayerFromNetHandler(netHandler);
|
||||
|
||||
int packetID = packet.getID();
|
||||
|
||||
switch (packetID) {
|
||||
case PacketIds.TILE_UPDATE: {
|
||||
PacketTileUpdate pkt = new PacketTileUpdate();
|
||||
pkt.readData(data);
|
||||
onTileUpdate((EntityPlayer) player, pkt);
|
||||
onTileUpdate(player, (PacketTileUpdate) packet);
|
||||
break;
|
||||
}
|
||||
|
||||
case PacketIds.STATE_UPDATE: {
|
||||
PacketTileState pkt = new PacketTileState();
|
||||
PacketTileState pkt = (PacketTileState) packet;
|
||||
pkt.readData(data);
|
||||
World world = ((EntityPlayer) player).worldObj;
|
||||
World world = player.worldObj;
|
||||
TileEntity tile = world.getBlockTileEntity(pkt.posX, pkt.posY, pkt.posZ);
|
||||
if (tile instanceof ISyncedTile) {
|
||||
pkt.applyStates(data, (ISyncedTile) tile);
|
||||
|
@ -55,14 +62,12 @@ public class PacketHandler implements IPacketHandler {
|
|||
}
|
||||
|
||||
case PacketIds.GUI_RETURN: {
|
||||
PacketGuiReturn pkt = new PacketGuiReturn((EntityPlayer) player);
|
||||
pkt.readData(data);
|
||||
// action will have happened already at read time
|
||||
break;
|
||||
}
|
||||
|
||||
case PacketIds.GUI_WIDGET: {
|
||||
PacketGuiWidget pkt = new PacketGuiWidget();
|
||||
pkt.readData(data);
|
||||
// action will have happened already at read time
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
package buildcraft.core.network;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.nbt.CompressedStreamTools;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
|
@ -19,7 +22,7 @@ public class PacketNBT extends PacketCoordinates {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void writeData(DataOutputStream data) throws IOException {
|
||||
public void writeData(ByteBuf data) {
|
||||
|
||||
super.writeData(data);
|
||||
|
||||
|
@ -29,7 +32,7 @@ public class PacketNBT extends PacketCoordinates {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void readData(DataInputStream data) throws IOException {
|
||||
public void readData(ByteBuf data) {
|
||||
|
||||
super.readData(data);
|
||||
|
||||
|
|
|
@ -2,6 +2,8 @@ package buildcraft.core.network;
|
|||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
@ -21,9 +23,9 @@ public abstract class PacketPayload {
|
|||
return null;
|
||||
}
|
||||
|
||||
public abstract void writeData(DataOutputStream data) throws IOException;
|
||||
public abstract void writeData(ByteBuf data);
|
||||
|
||||
public abstract void readData(DataInputStream data) throws IOException;
|
||||
public abstract void readData(ByteBuf data);
|
||||
|
||||
public abstract Type getType();
|
||||
}
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
package buildcraft.core.network;
|
||||
|
||||
import buildcraft.core.utils.Utils;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
@ -71,7 +73,7 @@ public class PacketPayloadArrays extends PacketPayload {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void writeData(DataOutputStream data) throws IOException {
|
||||
public void writeData(ByteBuf data) {
|
||||
data.writeInt(intPayload.length);
|
||||
data.writeInt(floatPayload.length);
|
||||
data.writeInt(stringPayload.length);
|
||||
|
@ -83,12 +85,12 @@ public class PacketPayloadArrays extends PacketPayload {
|
|||
data.writeFloat(floatData);
|
||||
}
|
||||
for (String stringData : stringPayload) {
|
||||
data.writeUTF(stringData);
|
||||
Utils.writeUTF(data, stringData);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(DataInputStream data) throws IOException {
|
||||
public void readData(ByteBuf data) {
|
||||
intPayload = new int[data.readInt()];
|
||||
floatPayload = new float[data.readInt()];
|
||||
stringPayload = new String[data.readInt()];
|
||||
|
@ -100,7 +102,7 @@ public class PacketPayloadArrays extends PacketPayload {
|
|||
floatPayload[i] = data.readFloat();
|
||||
}
|
||||
for (int i = 0; i < stringPayload.length; i++) {
|
||||
stringPayload[i] = data.readUTF();
|
||||
stringPayload[i] = Utils.readUTF(data);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
*/
|
||||
package buildcraft.core.network;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
@ -25,10 +27,10 @@ public class PacketPayloadStream extends PacketPayload {
|
|||
|
||||
public static interface StreamWriter {
|
||||
|
||||
public void writeData(DataOutputStream data) throws IOException;
|
||||
public void writeData(ByteBuf data);
|
||||
}
|
||||
private StreamWriter handler;
|
||||
public DataInputStream stream;
|
||||
public ByteBuf stream;
|
||||
|
||||
public PacketPayloadStream() {
|
||||
}
|
||||
|
@ -38,12 +40,12 @@ public class PacketPayloadStream extends PacketPayload {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void writeData(DataOutputStream data) throws IOException {
|
||||
public void writeData(ByteBuf data) {
|
||||
handler.writeData(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(DataInputStream data) throws IOException {
|
||||
public void readData(ByteBuf data) {
|
||||
stream = data;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
package buildcraft.core.network;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompressedStreamTools;
|
||||
|
||||
|
@ -21,7 +24,7 @@ public class PacketSlotChange extends PacketCoordinates {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void writeData(DataOutputStream data) throws IOException {
|
||||
public void writeData(ByteBuf data) {
|
||||
|
||||
super.writeData(data);
|
||||
|
||||
|
@ -45,7 +48,7 @@ public class PacketSlotChange extends PacketCoordinates {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void readData(DataInputStream data) throws IOException {
|
||||
public void readData(ByteBuf data) {
|
||||
|
||||
super.readData(data);
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package buildcraft.core.network;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
@ -43,7 +45,7 @@ public class PacketTileState extends PacketCoordinates {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void readData(DataInputStream data) throws IOException {
|
||||
public void readData(ByteBuf data) {
|
||||
super.readData(data);
|
||||
}
|
||||
|
||||
|
@ -61,7 +63,7 @@ public class PacketTileState extends PacketCoordinates {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void writeData(DataOutputStream data) throws IOException {
|
||||
public void writeData(ByteBuf data) {
|
||||
super.writeData(data);
|
||||
data.writeByte(stateList.size());
|
||||
for (StateWithId stateWithId : stateList) {
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package buildcraft.core.network;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
@ -36,7 +38,7 @@ public class PacketUpdate extends BuildCraftPacket {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void writeData(DataOutputStream data) throws IOException {
|
||||
public void writeData(ByteBuf data) {
|
||||
|
||||
data.writeInt(posX);
|
||||
data.writeInt(posY);
|
||||
|
@ -51,7 +53,7 @@ public class PacketUpdate extends BuildCraftPacket {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void readData(DataInputStream data) throws IOException {
|
||||
public void readData(ByteBuf data) {
|
||||
|
||||
posX = data.readInt();
|
||||
posY = data.readInt();
|
||||
|
|
|
@ -14,9 +14,11 @@ import buildcraft.core.network.BuildCraftPacket;
|
|||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.SidedProxy;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.Entity;
|
||||
|
@ -28,7 +30,9 @@ import net.minecraft.item.Item;
|
|||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.network.INetHandler;
|
||||
import net.minecraft.network.NetHandlerPlayServer;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChatMessageComponent;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
|
@ -131,26 +135,6 @@ public class CoreProxy {
|
|||
//GameRegistry.addShapelessRecipe(result, recipe);
|
||||
}
|
||||
|
||||
public void sendToPlayers(Packet packet, World world, int x, int y, int z, int maxDistance) {
|
||||
if (packet != null) {
|
||||
for (int j = 0; j < world.playerEntities.size(); j++) {
|
||||
EntityPlayerMP player = (EntityPlayerMP) world.playerEntities.get(j);
|
||||
|
||||
if (Math.abs(player.posX - x) <= maxDistance && Math.abs(player.posY - y) <= maxDistance && Math.abs(player.posZ - z) <= maxDistance) {
|
||||
player.playerNetServerHandler.sendPacketToPlayer(packet);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void sendToPlayer(EntityPlayer entityplayer, BuildCraftPacket packet) {
|
||||
EntityPlayerMP player = (EntityPlayerMP) entityplayer;
|
||||
player.playerNetServerHandler.sendPacketToPlayer(packet.getPacket());
|
||||
}
|
||||
|
||||
public void sendToServer(Packet packet) {
|
||||
}
|
||||
|
||||
public int addCustomTexture(String pathToTexture) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -237,4 +221,15 @@ public class CoreProxy {
|
|||
public EntityBlock newEntityBlock(World world, double i, double j, double k, double iSize, double jSize, double kSize, LaserKind laserKind) {
|
||||
return new EntityBlock(world, i, j, k, iSize, jSize, kSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function returns either the player from the handler if it's on the
|
||||
* server, or directly from the minecraft instance if it's the client.
|
||||
*
|
||||
* TODO: This is a bit kludgy, probably better to separate the client and
|
||||
* server channels instead.
|
||||
*/
|
||||
public EntityPlayer getPlayerFromNetHandler (INetHandler hander) {
|
||||
return ((NetHandlerPlayServer) hander).field_147369_b;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,18 +26,23 @@ import buildcraft.transport.render.TileEntityPickupFX;
|
|||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
import cpw.mods.fml.common.registry.LanguageRegistry;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.WorldClient;
|
||||
import net.minecraft.client.network.NetHandlerPlayClient;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.network.INetHandler;
|
||||
import net.minecraft.network.NetHandlerPlayServer;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChatMessageComponent;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
|
@ -185,4 +190,9 @@ public class CoreProxyClient extends CoreProxy {
|
|||
}
|
||||
return eb;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityPlayer getPlayerFromNetHandler (INetHandler hander) {
|
||||
return Minecraft.getMinecraft().thePlayer;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ import net.minecraft.entity.item.EntityItem;
|
|||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.packet.Packet60Explosion;
|
||||
import net.minecraft.network.Packet60Explosion;
|
||||
import net.minecraft.world.ChunkPosition;
|
||||
import net.minecraft.world.Explosion;
|
||||
import net.minecraft.world.World;
|
||||
|
|
|
@ -25,8 +25,11 @@ import buildcraft.core.network.ISynchronizedTile;
|
|||
import buildcraft.core.network.PacketUpdate;
|
||||
import buildcraft.core.proxy.CoreProxy;
|
||||
import buildcraft.energy.TileEngine;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
@ -397,4 +400,27 @@ public class Utils {
|
|||
}
|
||||
return slots;
|
||||
}
|
||||
|
||||
public static void writeUTF (ByteBuf data, String str) {
|
||||
try {
|
||||
byte [] b = str.getBytes("UTF-8");
|
||||
data.writeInt (b.length);
|
||||
data.writeBytes(b);
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
data.writeInt (0);
|
||||
}
|
||||
}
|
||||
|
||||
public static String readUTF (ByteBuf data) {
|
||||
try {
|
||||
int len = data.readInt();
|
||||
byte [] b = new byte [len];
|
||||
data.readBytes(b);
|
||||
return new String (b, "UTF-8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ import net.minecraft.entity.item.EntityItem;
|
|||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.packet.Packet3Chat;
|
||||
import net.minecraft.network.Packet3Chat;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.ChatMessageComponent;
|
||||
import net.minecraft.world.ChunkCoordIntPair;
|
||||
|
|
|
@ -1,37 +1,45 @@
|
|||
package buildcraft.factory.network;
|
||||
|
||||
import buildcraft.core.network.BuildCraftChannelHandler;
|
||||
import buildcraft.core.network.BuildCraftPacket;
|
||||
import buildcraft.core.network.PacketIds;
|
||||
import buildcraft.core.network.PacketPayload;
|
||||
import buildcraft.core.network.PacketPayloadStream;
|
||||
import buildcraft.core.network.PacketUpdate;
|
||||
import buildcraft.core.proxy.CoreProxy;
|
||||
import buildcraft.factory.TileRefinery;
|
||||
import cpw.mods.fml.common.network.IPacketHandler;
|
||||
import cpw.mods.fml.common.network.Player;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import net.minecraft.network.packet.Packet250CustomPayload;
|
||||
import net.minecraft.network.INetHandler;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
|
||||
public class PacketHandlerFactory implements IPacketHandler {
|
||||
public class PacketHandlerFactory extends BuildCraftChannelHandler {
|
||||
|
||||
@Override
|
||||
public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player) {
|
||||
|
||||
DataInputStream data = new DataInputStream(new ByteArrayInputStream(packet.data));
|
||||
public void decodeInto(ChannelHandlerContext ctx, ByteBuf data, BuildCraftPacket packet) {
|
||||
super.decodeInto(ctx, data, packet);
|
||||
|
||||
try {
|
||||
int packetID = data.read();
|
||||
PacketUpdate packetU = new PacketUpdate();
|
||||
INetHandler netHandler = ctx.channel().attr(NetworkRegistry.NET_HANDLER).get();
|
||||
|
||||
EntityPlayer player =
|
||||
CoreProxy.proxy.getPlayerFromNetHandler(netHandler);
|
||||
|
||||
int packetID = packet.getID();
|
||||
|
||||
switch (packetID) {
|
||||
|
||||
case PacketIds.REFINERY_FILTER_SET:
|
||||
packetU.readData(data);
|
||||
onRefinerySelect((EntityPlayer) player, packetU);
|
||||
onRefinerySelect(player, (PacketUpdate) packet);
|
||||
break;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,53 +1,55 @@
|
|||
package buildcraft.silicon.network;
|
||||
|
||||
import buildcraft.core.network.BuildCraftChannelHandler;
|
||||
import buildcraft.core.network.BuildCraftPacket;
|
||||
import buildcraft.core.network.PacketCoordinates;
|
||||
import buildcraft.core.network.PacketIds;
|
||||
import buildcraft.core.network.PacketNBT;
|
||||
import buildcraft.core.network.PacketSlotChange;
|
||||
import buildcraft.core.proxy.CoreProxy;
|
||||
import buildcraft.silicon.TileAdvancedCraftingTable;
|
||||
import buildcraft.silicon.TileAssemblyTable;
|
||||
import buildcraft.silicon.TileAssemblyTable.SelectionMessage;
|
||||
import buildcraft.silicon.gui.ContainerAssemblyTable;
|
||||
import cpw.mods.fml.common.network.IPacketHandler;
|
||||
import cpw.mods.fml.common.network.Player;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.DataInputStream;
|
||||
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import net.minecraft.network.packet.Packet250CustomPayload;
|
||||
import net.minecraft.network.INetHandler;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class PacketHandlerSilicon implements IPacketHandler {
|
||||
public class PacketHandlerSilicon extends BuildCraftChannelHandler {
|
||||
|
||||
@Override
|
||||
public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player) {
|
||||
|
||||
DataInputStream data = new DataInputStream(new ByteArrayInputStream(packet.data));
|
||||
public void decodeInto(ChannelHandlerContext ctx, ByteBuf data, BuildCraftPacket packet) {
|
||||
super.decodeInto(ctx, data, packet);
|
||||
|
||||
try {
|
||||
int packetID = data.read();
|
||||
INetHandler netHandler = ctx.channel().attr(NetworkRegistry.NET_HANDLER).get();
|
||||
|
||||
EntityPlayer player =
|
||||
CoreProxy.proxy.getPlayerFromNetHandler(netHandler);
|
||||
|
||||
int packetID = packet.getID();
|
||||
|
||||
switch (packetID) {
|
||||
case PacketIds.SELECTION_ASSEMBLY_SEND:
|
||||
PacketNBT packetT = new PacketNBT();
|
||||
packetT.readData(data);
|
||||
onSelectionUpdate((EntityPlayer) player, packetT);
|
||||
case PacketIds.SELECTION_ASSEMBLY_SEND:
|
||||
onSelectionUpdate(player, (PacketNBT) packet);
|
||||
break;
|
||||
|
||||
case PacketIds.SELECTION_ASSEMBLY:
|
||||
PacketNBT packetA = new PacketNBT();
|
||||
packetA.readData(data);
|
||||
onAssemblySelect((EntityPlayer) player, packetA);
|
||||
onAssemblySelect(player, (PacketNBT) packet);
|
||||
break;
|
||||
case PacketIds.SELECTION_ASSEMBLY_GET:
|
||||
PacketCoordinates packetC = new PacketCoordinates();
|
||||
packetC.readData(data);
|
||||
onAssemblyGetSelection((EntityPlayer) player, packetC);
|
||||
onAssemblyGetSelection(player, (PacketCoordinates) packet);
|
||||
break;
|
||||
case PacketIds.ADVANCED_WORKBENCH_SETSLOT:
|
||||
PacketSlotChange packet1 = new PacketSlotChange();
|
||||
packet1.readData(data);
|
||||
onAdvancedWorkbenchSet((EntityPlayer) player, packet1);
|
||||
onAdvancedWorkbenchSet(player, (PacketSlotChange) packet);
|
||||
break;
|
||||
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ import net.minecraft.block.Block;
|
|||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
|
|
@ -38,7 +38,7 @@ import net.minecraft.inventory.ICrafting;
|
|||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
|
|
@ -5,10 +5,13 @@ import buildcraft.core.network.PacketIds;
|
|||
import buildcraft.core.proxy.CoreProxy;
|
||||
import buildcraft.transport.PipeTransportFluids;
|
||||
import buildcraft.transport.TileGenericPipe;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.BitSet;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
@ -37,7 +40,7 @@ public class PacketFluidUpdate extends PacketCoordinates {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void readData(DataInputStream data) throws IOException {
|
||||
public void readData(ByteBuf data) {
|
||||
super.readData(data);
|
||||
|
||||
World world = CoreProxy.proxy.getClientWorld();
|
||||
|
@ -82,7 +85,7 @@ public class PacketFluidUpdate extends PacketCoordinates {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void writeData(DataOutputStream data) throws IOException {
|
||||
public void writeData(ByteBuf data) {
|
||||
super.writeData(data);
|
||||
|
||||
byte[] dBytes = toByteArray(delta);
|
||||
|
|
|
@ -3,8 +3,13 @@ package buildcraft.transport.network;
|
|||
import buildcraft.api.gates.GateExpansions;
|
||||
import buildcraft.core.network.BuildCraftPacket;
|
||||
import buildcraft.core.network.PacketIds;
|
||||
import buildcraft.core.utils.Utils;
|
||||
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
@ -16,22 +21,22 @@ public class PacketGateExpansionMap extends BuildCraftPacket {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void writeData(DataOutputStream data) throws IOException {
|
||||
public void writeData(ByteBuf data) {
|
||||
BiMap<Byte, String> map = GateExpansions.getServerMap();
|
||||
data.writeByte(map.size());
|
||||
for (Map.Entry<Byte, String> entry : map.entrySet()) {
|
||||
data.writeByte(entry.getKey());
|
||||
data.writeUTF(entry.getValue());
|
||||
Utils.writeUTF(data, entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(DataInputStream data) throws IOException {
|
||||
public void readData(ByteBuf data) {
|
||||
int numEntries = data.readByte();
|
||||
BiMap<Byte, String> map = HashBiMap.create(numEntries);
|
||||
for (int i = 0; i < numEntries; i++) {
|
||||
byte id = data.readByte();
|
||||
String identifier = data.readUTF();
|
||||
String identifier = Utils.readUTF(data);
|
||||
map.put(id, identifier);
|
||||
}
|
||||
GateExpansions.setClientMap(map);
|
||||
|
|
|
@ -1,115 +1,110 @@
|
|||
package buildcraft.transport.network;
|
||||
|
||||
import buildcraft.core.network.BuildCraftChannelHandler;
|
||||
import buildcraft.core.network.BuildCraftPacket;
|
||||
import buildcraft.core.network.PacketCoordinates;
|
||||
import buildcraft.core.network.PacketIds;
|
||||
import buildcraft.core.network.PacketSlotChange;
|
||||
import buildcraft.core.network.PacketUpdate;
|
||||
import buildcraft.core.proxy.CoreProxy;
|
||||
import buildcraft.transport.PipeTransportItems;
|
||||
import buildcraft.transport.PipeTransportPower;
|
||||
import buildcraft.transport.TileGenericPipe;
|
||||
import buildcraft.transport.gui.ContainerGateInterface;
|
||||
import buildcraft.transport.pipes.PipeItemsDiamond;
|
||||
import buildcraft.transport.pipes.PipeItemsEmerald;
|
||||
import cpw.mods.fml.common.network.IPacketHandler;
|
||||
import cpw.mods.fml.common.network.Player;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.DataInputStream;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import net.minecraft.network.packet.Packet250CustomPayload;
|
||||
import net.minecraft.network.INetHandler;
|
||||
import net.minecraft.network.NetHandlerPlayServer;
|
||||
import net.minecraft.network.play.INetHandlerPlayServer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class PacketHandlerTransport implements IPacketHandler {
|
||||
public class PacketHandlerTransport extends BuildCraftChannelHandler {
|
||||
|
||||
/**
|
||||
* TODO: A lot of this is based on the player to retrieve the world.
|
||||
* Passing a dimension id would be more appropriate. More generally, it
|
||||
* seems like a lot of these packets could be replaced with tile-based
|
||||
* RPCs.
|
||||
*/
|
||||
@Override
|
||||
public void onPacketData(INetworkManager manager, Packet250CustomPayload packet2, Player player) {
|
||||
DataInputStream data = new DataInputStream(new ByteArrayInputStream(packet2.data));
|
||||
public void decodeInto(ChannelHandlerContext ctx, ByteBuf data, BuildCraftPacket packet) {
|
||||
super.decodeInto(ctx, data, packet);
|
||||
try {
|
||||
// NetClientHandler net = (NetClientHandler) network.getNetHandler();
|
||||
INetHandler netHandler = ctx.channel().attr(NetworkRegistry.NET_HANDLER).get();
|
||||
|
||||
EntityPlayer player =
|
||||
CoreProxy.proxy.getPlayerFromNetHandler(netHandler);
|
||||
|
||||
int packetID = data.read();
|
||||
int packetID = packet.getID();
|
||||
|
||||
PacketUpdate packet = new PacketUpdate();
|
||||
switch (packetID) {
|
||||
case PacketIds.PIPE_POWER:
|
||||
PacketPowerUpdate packetPower = new PacketPowerUpdate();
|
||||
packetPower.readData(data);
|
||||
onPacketPower((EntityPlayer) player, packetPower);
|
||||
onPacketPower(player, (PacketPowerUpdate) packet);
|
||||
break;
|
||||
case PacketIds.PIPE_LIQUID:
|
||||
PacketFluidUpdate packetFluid = new PacketFluidUpdate();
|
||||
packetFluid.readData(data);
|
||||
// action will have happened already at read time
|
||||
break;
|
||||
case PacketIds.PIPE_TRAVELER: {
|
||||
PacketPipeTransportTraveler pkt = new PacketPipeTransportTraveler();
|
||||
pkt.readData(data);
|
||||
onPipeTravelerUpdate((EntityPlayer) player, pkt);
|
||||
onPipeTravelerUpdate(player, (PacketPipeTransportTraveler) packet);
|
||||
break;
|
||||
}
|
||||
case PacketIds.GATE_ACTIONS:
|
||||
packet.readData(data);
|
||||
onGateActions((EntityPlayer) player, packet);
|
||||
onGateActions(player, (PacketUpdate) packet);
|
||||
break;
|
||||
case PacketIds.GATE_TRIGGERS:
|
||||
packet.readData(data);
|
||||
onGateTriggers((EntityPlayer) player, packet);
|
||||
onGateTriggers(player, (PacketUpdate) packet);
|
||||
break;
|
||||
case PacketIds.GATE_SELECTION:
|
||||
packet.readData(data);
|
||||
onGateSelection((EntityPlayer) player, packet);
|
||||
onGateSelection(player, (PacketUpdate) packet);
|
||||
break;
|
||||
case PacketIds.PIPE_ITEMSTACK: {
|
||||
PacketPipeTransportItemStack pkt = new PacketPipeTransportItemStack();
|
||||
pkt.readData(data);
|
||||
// action will have happened already at read time
|
||||
break;
|
||||
}
|
||||
case PacketIds.PIPE_GATE_EXPANSION_MAP: {
|
||||
PacketGateExpansionMap pkt = new PacketGateExpansionMap();
|
||||
pkt.readData(data);
|
||||
// action will have happened already at read time
|
||||
break;
|
||||
}
|
||||
|
||||
/**
|
||||
* SERVER SIDE *
|
||||
*/
|
||||
case PacketIds.DIAMOND_PIPE_SELECT: {
|
||||
PacketSlotChange packet1 = new PacketSlotChange();
|
||||
packet1.readData(data);
|
||||
onDiamondPipeSelect((EntityPlayer) player, packet1);
|
||||
case PacketIds.DIAMOND_PIPE_SELECT: {
|
||||
onDiamondPipeSelect((EntityPlayer) player, (PacketSlotChange) packet);
|
||||
break;
|
||||
}
|
||||
|
||||
case PacketIds.EMERALD_PIPE_SELECT: {
|
||||
PacketSlotChange packet1 = new PacketSlotChange();
|
||||
packet1.readData(data);
|
||||
onEmeraldPipeSelect((EntityPlayer) player, packet1);
|
||||
case PacketIds.EMERALD_PIPE_SELECT: {
|
||||
onEmeraldPipeSelect((EntityPlayer) player, (PacketSlotChange) packet);
|
||||
break;
|
||||
}
|
||||
|
||||
case PacketIds.GATE_REQUEST_INIT:
|
||||
PacketCoordinates packetU = new PacketCoordinates();
|
||||
packetU.readData(data);
|
||||
onGateInitRequest((EntityPlayer) player, packetU);
|
||||
case PacketIds.GATE_REQUEST_INIT:
|
||||
onGateInitRequest((EntityPlayer) player, (PacketCoordinates) packet);
|
||||
break;
|
||||
|
||||
case PacketIds.GATE_REQUEST_SELECTION:
|
||||
PacketCoordinates packetS = new PacketCoordinates();
|
||||
packetS.readData(data);
|
||||
onGateSelectionRequest((EntityPlayerMP) player, packetS);
|
||||
onGateSelectionRequest((EntityPlayer) player, (PacketCoordinates) packet);
|
||||
break;
|
||||
|
||||
case PacketIds.GATE_SELECTION_CHANGE:
|
||||
PacketUpdate packet3 = new PacketUpdate();
|
||||
packet3.readData(data);
|
||||
onGateSelectionChange((EntityPlayerMP) player, packet3);
|
||||
onGateSelectionChange((EntityPlayer) player, (PacketUpdate) packet);
|
||||
break;
|
||||
|
||||
case PacketIds.PIPE_ITEMSTACK_REQUEST: {
|
||||
PacketPipeTransportItemStackRequest pkt = new PacketPipeTransportItemStackRequest(player);
|
||||
pkt.readData(data);
|
||||
// action will have happened already at read time
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,11 +3,14 @@ package buildcraft.transport.network;
|
|||
import buildcraft.core.network.BuildCraftPacket;
|
||||
import buildcraft.core.network.PacketIds;
|
||||
import buildcraft.transport.TravelingItem;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.network.Packet;
|
||||
|
||||
public class PacketPipeTransportItemStack extends BuildCraftPacket {
|
||||
|
||||
|
@ -23,13 +26,13 @@ public class PacketPipeTransportItemStack extends BuildCraftPacket {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void writeData(DataOutputStream data) throws IOException {
|
||||
public void writeData(ByteBuf data) {
|
||||
data.writeInt(entityId);
|
||||
Packet.writeItemStack(stack, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(DataInputStream data) throws IOException {
|
||||
public void readData(ByteBuf data) {
|
||||
this.entityId = data.readInt();
|
||||
stack = Packet.readItemStack(data);
|
||||
TravelingItem item = TravelingItem.clientCache.get(entityId);
|
||||
|
|
|
@ -5,6 +5,8 @@ import buildcraft.core.network.PacketIds;
|
|||
import buildcraft.transport.TravelingItem;
|
||||
import cpw.mods.fml.common.network.PacketDispatcher;
|
||||
import cpw.mods.fml.common.network.Player;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
@ -23,12 +25,12 @@ public class PacketPipeTransportItemStackRequest extends BuildCraftPacket {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void writeData(DataOutputStream data) throws IOException {
|
||||
public void writeData(ByteBuf data) {
|
||||
data.writeShort(travelerID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(DataInputStream data) throws IOException {
|
||||
public void readData(ByteBuf data) {
|
||||
travelerID = data.readShort();
|
||||
TravelingItem.TravelingItemCache cache = TravelingItem.serverCache;
|
||||
TravelingItem item = cache.get(travelerID);
|
||||
|
|
|
@ -4,9 +4,12 @@ import buildcraft.core.network.BuildCraftPacket;
|
|||
import buildcraft.core.network.PacketIds;
|
||||
import buildcraft.core.utils.EnumColor;
|
||||
import buildcraft.transport.TravelingItem;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
|
@ -35,7 +38,7 @@ public class PacketPipeTransportTraveler extends BuildCraftPacket {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void writeData(DataOutputStream data) throws IOException {
|
||||
public void writeData(ByteBuf data) {
|
||||
data.writeFloat((float) item.xCoord);
|
||||
data.writeFloat((float) item.yCoord);
|
||||
data.writeFloat((float) item.zCoord);
|
||||
|
@ -53,7 +56,7 @@ public class PacketPipeTransportTraveler extends BuildCraftPacket {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void readData(DataInputStream data) throws IOException {
|
||||
public void readData(ByteBuf data) {
|
||||
this.itemX = data.readFloat();
|
||||
this.itemY = data.readFloat();
|
||||
this.itemZ = data.readFloat();
|
||||
|
|
|
@ -2,6 +2,8 @@ package buildcraft.transport.network;
|
|||
|
||||
import buildcraft.core.network.PacketCoordinates;
|
||||
import buildcraft.core.network.PacketIds;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
@ -19,7 +21,7 @@ public class PacketPowerUpdate extends PacketCoordinates {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void readData(DataInputStream data) throws IOException {
|
||||
public void readData(ByteBuf data) {
|
||||
displayPower = new short[] { 0, 0, 0, 0, 0, 0 };
|
||||
super.readData(data);
|
||||
overload = data.readBoolean();
|
||||
|
@ -29,7 +31,7 @@ public class PacketPowerUpdate extends PacketCoordinates {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void writeData(DataOutputStream data) throws IOException {
|
||||
public void writeData(ByteBuf data) {
|
||||
super.writeData(data);
|
||||
data.writeBoolean(overload);
|
||||
for (int i = 0; i < displayPower.length; i++) {
|
||||
|
|
|
@ -14,7 +14,7 @@ import cpw.mods.fml.common.network.Player;
|
|||
import net.minecraft.network.INetworkManager;
|
||||
import net.minecraft.network.NetLoginHandler;
|
||||
import net.minecraft.network.packet.NetHandler;
|
||||
import net.minecraft.network.packet.Packet1Login;
|
||||
import net.minecraft.network.Packet1Login;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue