Re-introduction of the builder block

Added back the builder block to the world, with fixes of initial obvious errors.
TileArchitect is now passing its name through RPCs.
This commit is contained in:
SpaceToad 2014-01-11 13:59:30 +01:00
parent 9dab76fc71
commit 08d01c0394
6 changed files with 30 additions and 13 deletions

View file

@ -10,12 +10,15 @@ package buildcraft.builders;
import buildcraft.BuildCraftBuilders;
import buildcraft.api.core.Position;
import buildcraft.api.tools.IToolWrench;
import buildcraft.core.CreativeTabBuildCraft;
import buildcraft.core.GuiIds;
import buildcraft.core.proxy.CoreProxy;
import buildcraft.core.utils.Utils;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.ArrayList;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
@ -37,7 +40,7 @@ public class BlockBuilder extends BlockContainer {
public BlockBuilder(int i) {
super(i, Material.iron);
setHardness(5F);
setCreativeTab(null);
setCreativeTab(CreativeTabBuildCraft.MACHINES.get());
}
@Override

View file

@ -41,6 +41,10 @@ public abstract class ItemBlueprint extends ItemBuildCraft {
}
public static Blueprint getBlueprint(ItemStack stack) {
if (stack == null) {
return null;
}
NBTTagCompound nbt = NBTUtils.getItemData(stack);
byte[] idRaw = nbt.getByteArray("blueprint");
BlueprintId id = BlueprintId.fromRawId(idRaw);

View file

@ -16,9 +16,13 @@ import buildcraft.core.Box;
import buildcraft.core.TileBuildCraft;
import buildcraft.core.network.PacketUpdate;
import buildcraft.core.network.NetworkData;
import buildcraft.core.network.RPC;
import buildcraft.core.network.RPCSide;
import buildcraft.core.proxy.CoreProxy;
import buildcraft.core.utils.Utils;
import java.io.IOException;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
@ -34,8 +38,9 @@ public class TileArchitect extends TileBuildCraft implements IInventory {
private ItemStack items[] = new ItemStack[2];
private boolean isComputing = false;
public int computingTime = 0;
public @NetworkData
String name = "";
@NetworkData
public String name = "";
@Override
public void updateEntity() {
@ -139,6 +144,7 @@ public class TileArchitect extends TileBuildCraft implements IInventory {
return blueprint;
}
@RPC
public void handleClientInput(char c) {
if (c == 8) {
if (name.length() > 0) {
@ -333,4 +339,5 @@ public class TileArchitect extends TileBuildCraft implements IInventory {
@Override
public void closeChest() {
}
}

View file

@ -11,10 +11,10 @@ public class BlueprintMeta {
public BlueprintId id;
@NetworkData
public String name;
public String name = "";
@NetworkData
public String creator;
public String creator = "";
public BlueprintMeta() {

View file

@ -14,6 +14,7 @@ import buildcraft.core.network.PacketIds;
import buildcraft.core.network.PacketPayload;
import buildcraft.core.network.PacketPayloadStream;
import buildcraft.core.network.PacketUpdate;
import buildcraft.core.network.RPCHandler;
import buildcraft.core.proxy.CoreProxy;
import buildcraft.core.utils.StringUtils;
@ -82,19 +83,15 @@ public class GuiTemplate extends GuiBuildCraft {
@Override
protected void keyTyped(char c, int i) {
// FIXME: Not much point to port this to stream payload at this stage,
// should use a RPC instead.
/*if (i != 1 && editMode) {
if (i != 1 && editMode) {
if (c == 13) {
editMode = false;
return;
}
PacketPayloadStream payload = new PacketPayloadStream();
payload.intPayload = new int[]{c};
PacketUpdate packet = new PacketUpdate(PacketIds.ARCHITECT_NAME, template.xCoord, template.yCoord, template.zCoord, payload);
CoreProxy.proxy.sendToServer(packet.getPacket());
RPCHandler.rpcServer(template, "handleClientInput", c);
} else {
super.keyTyped(c, i);
}*/
}
}
}

View file

@ -73,6 +73,8 @@ public class RPCHandler {
for (int j = 0; j < mapping.parameters.length; ++j) {
if (mapping.parameters [j].equals(int.class)) {
// accepted
} else if (mapping.parameters [j].equals(char.class)) {
// accepted
} else if (mapping.parameters [j].equals(String.class)) {
// accepted
} else if (mapping.parameters [j].equals(RPCMessageInfo.class)) {
@ -156,6 +158,8 @@ public class RPCHandler {
for (int i = 0; i < actuals.length; ++i) {
if (formals [i].equals(int.class)) {
data.writeInt((Integer) actuals [i]);
} else if (formals [i].equals(char.class)) {
data.writeChar((Character) actuals [i]);
} else if (formals [i].equals(String.class)) {
data.writeUTF((String) actuals [i]);
} else {
@ -191,6 +195,8 @@ public class RPCHandler {
for (int i = 0; i < expectedParameters; ++i) {
if (formals [i].equals(int.class)) {
actuals [i] = data.readInt();
} else if (formals [i].equals(char.class)) {
actuals [i] = data.readChar();
} else if (formals [i].equals(String.class)) {
actuals [i] = data.readUTF();
} else {