From d69794436492f1b9bcb5dfcf77aba159c95ff5cc Mon Sep 17 00:00:00 2001 From: SpaceToad Date: Mon, 6 Jan 2014 19:59:09 +0100 Subject: [PATCH] added missing files for initial RPC implementation --- common/buildcraft/BuildCraftCore.java | 19 +++++++++++++++++++ common/buildcraft/core/DefaultProps.java | 4 +++- .../core/network/PacketHandler.java | 17 +++++++++++++++++ common/buildcraft/core/network/PacketIds.java | 2 ++ 4 files changed, 41 insertions(+), 1 deletion(-) diff --git a/common/buildcraft/BuildCraftCore.java b/common/buildcraft/BuildCraftCore.java index 8c00e076..26580b01 100644 --- a/common/buildcraft/BuildCraftCore.java +++ b/common/buildcraft/BuildCraftCore.java @@ -30,6 +30,7 @@ import buildcraft.api.gates.ActionManager; import buildcraft.api.recipes.BuildcraftRecipes; import buildcraft.builders.blueprints.BlueprintDatabase; import buildcraft.core.BlockIndex; +import buildcraft.core.BlockPingPong; import buildcraft.core.BlockSpring; import buildcraft.core.BuildCraftConfiguration; import buildcraft.core.CommandBuildCraft; @@ -44,6 +45,7 @@ import buildcraft.core.ItemSpring; import buildcraft.core.ItemWrench; import buildcraft.core.SpringPopulate; import buildcraft.core.TickHandlerCoreClient; +import buildcraft.core.TilePingPong; import buildcraft.core.Version; import buildcraft.core.blueprints.BptItem; import buildcraft.core.network.EntityIds; @@ -68,6 +70,8 @@ import buildcraft.core.recipes.AssemblyRecipeManager; import buildcraft.core.recipes.IntegrationRecipeManager; import buildcraft.core.recipes.RefineryRecipeManager; import buildcraft.core.triggers.TriggerRedstoneInput; +import buildcraft.factory.BlockAutoWorkbench; +import buildcraft.factory.TileRefinery; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.Instance; @@ -105,6 +109,7 @@ public class BuildCraftCore { public static final int trackedPassiveEntityId = 156; public static boolean continuousCurrentModel; public static Block springBlock; + public static Block pingPongBlock; public static Item woodenGearItem; public static Item stoneGearItem; public static Item ironGearItem; @@ -257,11 +262,25 @@ public class BuildCraftCore { MinecraftForge.EVENT_BUS.register(this); + // FIXME: Ping Pong is just here as a temporary demonstration for + // RPCs, it's aimed at being removed before release + + int pingPongId = BuildCraftCore.mainConfiguration.getBlock("pingpong.id", DefaultProps.PING_PONG_ID).getInt(DefaultProps.PING_PONG_ID); + + if (pingPongId > 0) { + pingPongBlock = new BlockPingPong (pingPongId); + CoreProxy.proxy.registerBlock(pingPongBlock.setUnlocalizedName("pingPongBlock")); + CoreProxy.proxy.addName(pingPongBlock, "Ping Pong"); + + CoreProxy.proxy.registerTileEntity(TilePingPong.class, "net.minecraft.src.core.TilePingPong"); + } + } finally { if (mainConfiguration.hasChanged()) { mainConfiguration.save(); } } + } @EventHandler diff --git a/common/buildcraft/core/DefaultProps.java b/common/buildcraft/core/DefaultProps.java index 89f85f6d..b5bf1916 100644 --- a/common/buildcraft/core/DefaultProps.java +++ b/common/buildcraft/core/DefaultProps.java @@ -114,10 +114,12 @@ public class DefaultProps { public static int SPRING_ID = 1522; public static int FILTERED_BUFFER_ID = 1523; public static int FLOOD_GATE_ID = 1524; - + public static int OIL_ID = 1530; public static int FUEL_ID = 1531; + public static int PING_PONG_ID = 1532; + public static boolean CURRENT_CONTINUOUS = false; public static double PIPES_DURABILITY = 0.25D; public static boolean FILLER_DESTROY = false; diff --git a/common/buildcraft/core/network/PacketHandler.java b/common/buildcraft/core/network/PacketHandler.java index 8c0feb94..ebf5951a 100644 --- a/common/buildcraft/core/network/PacketHandler.java +++ b/common/buildcraft/core/network/PacketHandler.java @@ -11,6 +11,7 @@ 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.repackage.com.nothome.delta.DebugDiffWriter; public class PacketHandler implements IPacketHandler { @@ -65,6 +66,22 @@ public class PacketHandler implements IPacketHandler { pkt.readData(data); break; } + + case PacketIds.RPC: { + PacketRPC rpc = new PacketRPC(); + rpc.sender = (EntityPlayer) player; + + int x = data.readInt(); + int y = data.readInt(); + int z = data.readInt(); + + World world = ((EntityPlayer) player).worldObj; + TileEntity tile = world.getBlockTileEntity(x, y, z); + + rpc.setTile (tile); + rpc.readData(data); + break; + } } } catch (Exception ex) { ex.printStackTrace(); diff --git a/common/buildcraft/core/network/PacketIds.java b/common/buildcraft/core/network/PacketIds.java index cc7cea80..660eb36f 100644 --- a/common/buildcraft/core/network/PacketIds.java +++ b/common/buildcraft/core/network/PacketIds.java @@ -40,4 +40,6 @@ public class PacketIds { public static final int GUI_WIDGET = 81; public static final int STATE_UPDATE = 100; + + public static final int RPC = 110; }