implemented connection between UI and board parameters, #1732
This commit is contained in:
parent
1a74389a5c
commit
1518ccdcf6
16 changed files with 314 additions and 151 deletions
common/buildcraft
|
@ -14,7 +14,6 @@ import org.lwjgl.opengl.GL11;
|
|||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
@ -24,6 +23,7 @@ import buildcraft.core.DefaultProps;
|
|||
import buildcraft.core.fluids.Tank;
|
||||
import buildcraft.core.gui.AdvancedSlot;
|
||||
import buildcraft.core.gui.GuiAdvancedInterface;
|
||||
import buildcraft.core.gui.ItemSlot;
|
||||
import buildcraft.core.network.RPCHandler;
|
||||
import buildcraft.core.utils.StringUtils;
|
||||
|
||||
|
@ -45,7 +45,7 @@ public class GuiBuilder extends GuiAdvancedInterface {
|
|||
|
||||
for (int i = 0; i < 6; ++i) {
|
||||
for (int j = 0; j < 4; ++j) {
|
||||
slots[i * 4 + j] = new ItemSlot(179 + j * 18, 18 + i * 18);
|
||||
slots[i * 4 + j] = new ItemSlot(this, 179 + j * 18, 18 + i * 18);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ package buildcraft.core;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
@ -76,7 +77,10 @@ public class ItemRobot extends ItemBuildCraft {
|
|||
if (cpt.hasKey("id") && !"<unknown>".equals(cpt.getString("id"))) {
|
||||
RedstoneBoardRegistry.instance.getRedstoneBoard(cpt).addInformation(stack, player, list, advanced);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(IIconRegister par1IconRegister) {
|
||||
// cancels default BC icon registering
|
||||
}
|
||||
}
|
||||
|
|
49
common/buildcraft/core/gui/FluidSlot.java
Executable file
49
common/buildcraft/core/gui/FluidSlot.java
Executable file
|
@ -0,0 +1,49 @@
|
|||
/**
|
||||
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
|
||||
* http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
package buildcraft.core.gui;
|
||||
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
|
||||
import buildcraft.core.render.FluidRenderer;
|
||||
import buildcraft.core.render.RenderUtils;
|
||||
|
||||
/**
|
||||
* For the refinery, a kind of phantom slot for fluid.
|
||||
*/
|
||||
//TODO Get this class working well (Now it's just here to let the refinery compil)
|
||||
public class FluidSlot extends AdvancedSlot {
|
||||
|
||||
public Fluid fluid;
|
||||
public int colorRenderCache;
|
||||
|
||||
public FluidSlot(GuiAdvancedInterface gui, int x, int y) {
|
||||
super(gui, x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawSprite(int cornerX, int cornerY) {
|
||||
if (fluid != null) {
|
||||
RenderUtils.setGLColorFromInt(colorRenderCache);
|
||||
}
|
||||
super.drawSprite(cornerX, cornerY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon() {
|
||||
return FluidRenderer.getFluidTexture(fluid, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getTexture() {
|
||||
return FluidRenderer.getFluidSheet(fluid);
|
||||
}
|
||||
}
|
|
@ -14,50 +14,9 @@ import net.minecraft.client.renderer.OpenGlHelper;
|
|||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
|
||||
import buildcraft.core.render.FluidRenderer;
|
||||
import buildcraft.core.render.RenderUtils;
|
||||
|
||||
public abstract class GuiAdvancedInterface extends GuiBuildCraft {
|
||||
public class ItemSlot extends AdvancedSlot {
|
||||
|
||||
public ItemStack stack;
|
||||
|
||||
public ItemSlot(int x, int y) {
|
||||
super(GuiAdvancedInterface.this, x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStack() {
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* More dynamic slot displaying an inventory fluid at specified position in
|
||||
* the passed IInventory
|
||||
*/
|
||||
public class IInventorySlot extends AdvancedSlot {
|
||||
|
||||
private IInventory tile;
|
||||
private int slot;
|
||||
|
||||
public IInventorySlot(int x, int y, IInventory tile, int slot) {
|
||||
super(GuiAdvancedInterface.this, x, y);
|
||||
this.tile = tile;
|
||||
this.slot = slot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStack() {
|
||||
return tile.getStackInSlot(slot);
|
||||
}
|
||||
}
|
||||
public AdvancedSlot[] slots;
|
||||
|
||||
public GuiAdvancedInterface(BuildCraftContainer container, IInventory inventory, ResourceLocation texture) {
|
||||
|
@ -120,38 +79,6 @@ public abstract class GuiAdvancedInterface extends GuiBuildCraft {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* For the refinery, a kind of phantom slot for fluid.
|
||||
*/
|
||||
//TODO Get this class working well (Now it's just here to let the refinery compil)
|
||||
public class FluidSlot extends AdvancedSlot {
|
||||
|
||||
public Fluid fluid;
|
||||
public int colorRenderCache;
|
||||
|
||||
public FluidSlot(int x, int y) {
|
||||
super(GuiAdvancedInterface.this, x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawSprite(int cornerX, int cornerY) {
|
||||
if (fluid != null) {
|
||||
RenderUtils.setGLColorFromInt(colorRenderCache);
|
||||
}
|
||||
super.drawSprite(cornerX, cornerY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon() {
|
||||
return FluidRenderer.getFluidTexture(fluid, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getTexture() {
|
||||
return FluidRenderer.getFluidSheet(fluid);
|
||||
}
|
||||
}
|
||||
|
||||
public static RenderItem getItemRenderer () {
|
||||
return itemRender;
|
||||
}
|
||||
|
|
33
common/buildcraft/core/gui/IInventorySlot.java
Executable file
33
common/buildcraft/core/gui/IInventorySlot.java
Executable file
|
@ -0,0 +1,33 @@
|
|||
/**
|
||||
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
|
||||
* http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
package buildcraft.core.gui;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
/**
|
||||
* More dynamic slot displaying an inventory fluid at specified position in
|
||||
* the passed IInventory
|
||||
*/
|
||||
public class IInventorySlot extends AdvancedSlot {
|
||||
|
||||
private IInventory tile;
|
||||
private int slot;
|
||||
|
||||
public IInventorySlot(GuiAdvancedInterface gui, int x, int y, IInventory tile, int slot) {
|
||||
super(gui, x, y);
|
||||
this.tile = tile;
|
||||
this.slot = slot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStack() {
|
||||
return tile.getStackInSlot(slot);
|
||||
}
|
||||
}
|
25
common/buildcraft/core/gui/ItemSlot.java
Executable file
25
common/buildcraft/core/gui/ItemSlot.java
Executable file
|
@ -0,0 +1,25 @@
|
|||
/**
|
||||
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
|
||||
* http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
package buildcraft.core.gui;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ItemSlot extends AdvancedSlot {
|
||||
|
||||
public ItemStack stack;
|
||||
|
||||
public ItemSlot(GuiAdvancedInterface gui, int x, int y) {
|
||||
super(gui, x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStack() {
|
||||
return stack;
|
||||
}
|
||||
}
|
|
@ -39,6 +39,7 @@ public class BuildCraftChannelHandler extends FMLIndexedMessageToMessageCodec<Bu
|
|||
addDiscriminator(13, PacketUpdate.class);
|
||||
addDiscriminator(14, PacketRPCTile.class);
|
||||
addDiscriminator(15, PacketRPCPipe.class);
|
||||
addDiscriminator(16, PacketRPCGui.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -52,39 +52,45 @@ public class PacketHandler extends SimpleChannelInboundHandler<BuildCraftPacket>
|
|||
int packetID = packet.getID();
|
||||
|
||||
switch (packetID) {
|
||||
case PacketIds.TILE_UPDATE: {
|
||||
onTileUpdate(player, (PacketTileUpdate) packet);
|
||||
break;
|
||||
case PacketIds.TILE_UPDATE: {
|
||||
onTileUpdate(player, (PacketTileUpdate) packet);
|
||||
break;
|
||||
}
|
||||
|
||||
case PacketIds.STATE_UPDATE: {
|
||||
PacketTileState pkt = (PacketTileState) packet;
|
||||
World world = player.worldObj;
|
||||
|
||||
TileEntity tile = world.getTileEntity(pkt.posX, pkt.posY, pkt.posZ);
|
||||
|
||||
if (tile instanceof ISyncedTile) {
|
||||
pkt.applyStates((ISyncedTile) tile);
|
||||
}
|
||||
|
||||
case PacketIds.STATE_UPDATE: {
|
||||
PacketTileState pkt = (PacketTileState) packet;
|
||||
World world = player.worldObj;
|
||||
break;
|
||||
}
|
||||
|
||||
TileEntity tile = world.getTileEntity(pkt.posX, pkt.posY, pkt.posZ);
|
||||
case PacketIds.GUI_RETURN: {
|
||||
// action will have happened already at read time
|
||||
break;
|
||||
}
|
||||
|
||||
if (tile instanceof ISyncedTile) {
|
||||
pkt.applyStates((ISyncedTile) tile);
|
||||
}
|
||||
case PacketIds.GUI_WIDGET: {
|
||||
// action will have happened already at read time
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case PacketIds.RPC_TILE: {
|
||||
((PacketRPCTile) packet).call(player);
|
||||
|
||||
case PacketIds.GUI_RETURN: {
|
||||
// action will have happened already at read time
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case PacketIds.GUI_WIDGET: {
|
||||
// action will have happened already at read time
|
||||
break;
|
||||
}
|
||||
case PacketIds.RPC_GUI: {
|
||||
((PacketRPCGui) packet).call(player);
|
||||
|
||||
case PacketIds.RPC_TILE: {
|
||||
((PacketRPCTile) packet).call(player);
|
||||
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case PacketIds.RPC_PIPE: {
|
||||
// TODO: RPC pipes are not used right now. Ressurect this
|
||||
|
|
|
@ -41,6 +41,7 @@ public final class PacketIds {
|
|||
|
||||
public static final int RPC_TILE = 110;
|
||||
public static final int RPC_PIPE = 111;
|
||||
public static final int RPC_GUI = 112;
|
||||
|
||||
/**
|
||||
* Deactivate constructor
|
||||
|
|
51
common/buildcraft/core/network/PacketRPCGui.java
Executable file
51
common/buildcraft/core/network/PacketRPCGui.java
Executable file
|
@ -0,0 +1,51 @@
|
|||
/**
|
||||
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
|
||||
* http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
package buildcraft.core.network;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
public class PacketRPCGui extends BuildCraftPacket {
|
||||
byte [] contents;
|
||||
|
||||
public PacketRPCGui() {
|
||||
}
|
||||
|
||||
public PacketRPCGui(byte[] bytes) {
|
||||
contents = bytes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getID() {
|
||||
return PacketIds.RPC_GUI;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(ByteBuf data) {
|
||||
contents = new byte [data.readableBytes()];
|
||||
data.readBytes(contents);
|
||||
}
|
||||
|
||||
public void call (EntityPlayer sender) {
|
||||
RPCMessageInfo info = new RPCMessageInfo();
|
||||
info.sender = sender;
|
||||
|
||||
ByteBuf completeData = Unpooled.buffer();
|
||||
completeData.writeBytes(contents);
|
||||
|
||||
RPCHandler.receiveRPC(sender.openContainer, info, completeData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeData(ByteBuf data) {
|
||||
data.writeBytes(contents);
|
||||
}
|
||||
}
|
|
@ -22,6 +22,7 @@ import io.netty.buffer.Unpooled;
|
|||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import buildcraft.BuildCraftCore;
|
||||
|
@ -103,30 +104,51 @@ public final class RPCHandler {
|
|||
methods = mappings.toArray(new MethodMapping [mappings.size()]);
|
||||
}
|
||||
|
||||
public static void rpcServer (TileEntity tile, String method, Object ... actuals) {
|
||||
if (!handlers.containsKey(tile.getClass().getName())) {
|
||||
handlers.put (tile.getClass().getName(), new RPCHandler (tile.getClass()));
|
||||
public static void rpcServer(Object object, String method, Object... actuals) {
|
||||
if (!handlers.containsKey(object.getClass().getName())) {
|
||||
handlers.put(object.getClass().getName(), new RPCHandler(object.getClass()));
|
||||
}
|
||||
|
||||
PacketRPCTile packet = handlers.get (tile.getClass().getName()).createRCPPacket(tile, method, actuals);
|
||||
BuildCraftPacket packet = null;
|
||||
|
||||
if (object instanceof Container) {
|
||||
packet = handlers.get(object.getClass().getName()).createRCPPacketContainer(method, actuals);
|
||||
} else if (object instanceof TileEntity) {
|
||||
packet = handlers.get(object.getClass().getName()).createRCPPacketTile((TileEntity) object, method, actuals);
|
||||
}
|
||||
|
||||
if (packet != null) {
|
||||
for (PacketRPCTile p : packet.breakIntoSmallerPackets(MAX_PACKET_SIZE)) {
|
||||
BuildCraftCore.instance.sendToServer(p);
|
||||
if (packet instanceof PacketRPCTile) {
|
||||
for (PacketRPCTile p : ((PacketRPCTile) packet).breakIntoSmallerPackets(MAX_PACKET_SIZE)) {
|
||||
BuildCraftCore.instance.sendToServer(p);
|
||||
}
|
||||
} else {
|
||||
BuildCraftCore.instance.sendToServer(packet);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void rpcPlayer (TileEntity tile, String method, EntityPlayer player, Object ... actuals) {
|
||||
if (!handlers.containsKey(tile.getClass().getName())) {
|
||||
handlers.put (tile.getClass().getName(), new RPCHandler (tile.getClass()));
|
||||
public static void rpcPlayer(Object object, String method, EntityPlayer player, Object... actuals) {
|
||||
if (!handlers.containsKey(object.getClass().getName())) {
|
||||
handlers.put(object.getClass().getName(), new RPCHandler(object.getClass()));
|
||||
}
|
||||
|
||||
PacketRPCTile packet = handlers.get (tile.getClass().getName()).createRCPPacket(tile, method, actuals);
|
||||
BuildCraftPacket packet = null;
|
||||
|
||||
if (object instanceof Container) {
|
||||
packet = handlers.get(object.getClass().getName()).createRCPPacketContainer(method, actuals);
|
||||
} else if (object instanceof TileEntity) {
|
||||
packet = handlers.get(object.getClass().getName())
|
||||
.createRCPPacketTile((TileEntity) object, method, actuals);
|
||||
}
|
||||
|
||||
if (packet != null) {
|
||||
for (PacketRPCTile p : packet.breakIntoSmallerPackets(MAX_PACKET_SIZE)) {
|
||||
BuildCraftCore.instance.sendToPlayer(player, p);
|
||||
if (packet instanceof PacketRPCTile) {
|
||||
for (PacketRPCTile p : ((PacketRPCTile) packet).breakIntoSmallerPackets(MAX_PACKET_SIZE)) {
|
||||
BuildCraftCore.instance.sendToPlayer(player, p);
|
||||
}
|
||||
} else {
|
||||
BuildCraftCore.instance.sendToPlayer(player, packet);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -144,7 +166,7 @@ public final class RPCHandler {
|
|||
handlers.put (tile.getClass().getName(), new RPCHandler (tile.getClass()));
|
||||
}
|
||||
|
||||
PacketRPCTile packet = handlers.get (tile.getClass().getName()).createRCPPacket(tile, method, actuals);
|
||||
PacketRPCTile packet = handlers.get (tile.getClass().getName()).createRCPPacketTile(tile, method, actuals);
|
||||
|
||||
if (packet != null) {
|
||||
for (PacketRPCTile p : packet
|
||||
|
@ -167,7 +189,7 @@ public final class RPCHandler {
|
|||
handlers.put (pipe.getClass().getName(), new RPCHandler (pipe.getClass()));
|
||||
}
|
||||
|
||||
PacketRPCPipe packet = handlers.get (pipe.getClass().getName()).createRCPPacket(pipe, method, actuals);
|
||||
PacketRPCPipe packet = handlers.get (pipe.getClass().getName()).createRCPPacketPipe(pipe, method, actuals);
|
||||
|
||||
if (packet != null) {
|
||||
for (Object o : pipe.container.getWorld().playerEntities) {
|
||||
|
@ -182,31 +204,19 @@ public final class RPCHandler {
|
|||
}
|
||||
}
|
||||
|
||||
public static void receiveRPC (TileEntity tile, RPCMessageInfo info, ByteBuf data) {
|
||||
if (tile != null) {
|
||||
if (!handlers.containsKey(tile.getClass().getName())) {
|
||||
handlers.put(tile.getClass().getName(),
|
||||
new RPCHandler(tile.getClass()));
|
||||
public static void receiveRPC(Object obj, RPCMessageInfo info, ByteBuf data) {
|
||||
if (obj != null) {
|
||||
if (!handlers.containsKey(obj.getClass().getName())) {
|
||||
handlers.put(obj.getClass().getName(),
|
||||
new RPCHandler(obj.getClass()));
|
||||
}
|
||||
|
||||
handlers.get(tile.getClass().getName()).internalRpcReceive(tile,
|
||||
handlers.get(obj.getClass().getName()).internalRpcReceive(obj,
|
||||
info, data);
|
||||
}
|
||||
}
|
||||
|
||||
public static void receiveRPC (Pipe pipe, RPCMessageInfo info, ByteBuf data) {
|
||||
if (pipe != null) {
|
||||
if (!handlers.containsKey(pipe.getClass().getName())) {
|
||||
handlers.put(pipe.getClass().getName(),
|
||||
new RPCHandler(pipe.getClass()));
|
||||
}
|
||||
|
||||
handlers.get(pipe.getClass().getName()).internalRpcReceive(pipe,
|
||||
info, data);
|
||||
}
|
||||
}
|
||||
|
||||
private PacketRPCPipe createRCPPacket (Pipe pipe, String method, Object ... actuals) {
|
||||
private PacketRPCPipe createRCPPacketPipe (Pipe pipe, String method, Object ... actuals) {
|
||||
ByteBuf data = Unpooled.buffer();
|
||||
|
||||
try {
|
||||
|
@ -234,7 +244,7 @@ public final class RPCHandler {
|
|||
return new PacketRPCPipe(bytes);
|
||||
}
|
||||
|
||||
private PacketRPCTile createRCPPacket (TileEntity tile, String method, Object ... actuals) {
|
||||
private PacketRPCTile createRCPPacketTile (TileEntity tile, String method, Object ... actuals) {
|
||||
ByteBuf data = Unpooled.buffer();
|
||||
|
||||
try {
|
||||
|
@ -253,6 +263,25 @@ public final class RPCHandler {
|
|||
return new PacketRPCTile(tile, bytes);
|
||||
}
|
||||
|
||||
private PacketRPCGui createRCPPacketContainer(String method, Object... actuals) {
|
||||
ByteBuf data = Unpooled.buffer();
|
||||
|
||||
try {
|
||||
writeParameters(method, data, actuals);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalArgumentException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
byte[] bytes = new byte[data.readableBytes()];
|
||||
data.readBytes(bytes);
|
||||
|
||||
return new PacketRPCGui(bytes);
|
||||
}
|
||||
|
||||
private void writeParameters(String method, ByteBuf data, Object... actuals)
|
||||
throws IOException, IllegalArgumentException,
|
||||
IllegalAccessException {
|
||||
|
|
|
@ -20,6 +20,7 @@ import net.minecraftforge.fluids.FluidStack;
|
|||
import buildcraft.api.recipes.CraftingResult;
|
||||
import buildcraft.core.DefaultProps;
|
||||
import buildcraft.core.gui.AdvancedSlot;
|
||||
import buildcraft.core.gui.FluidSlot;
|
||||
import buildcraft.core.gui.GuiAdvancedInterface;
|
||||
import buildcraft.core.utils.StringUtils;
|
||||
import buildcraft.factory.TileRefinery;
|
||||
|
@ -39,9 +40,9 @@ public class GuiRefinery extends GuiAdvancedInterface {
|
|||
|
||||
this.slots = new AdvancedSlot[3];
|
||||
|
||||
this.slots[0] = new FluidSlot(38, 54);
|
||||
this.slots[1] = new FluidSlot(126, 54);
|
||||
this.slots[2] = new FluidSlot(82, 54);
|
||||
this.slots[0] = new FluidSlot(this, 38, 54);
|
||||
this.slots[1] = new FluidSlot(this, 126, 54);
|
||||
this.slots[2] = new FluidSlot(this, 82, 54);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -28,6 +28,9 @@ public class GuiHandler implements IGuiHandler {
|
|||
|
||||
@Override
|
||||
public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) {
|
||||
if (id == GuiIds.REDSTONE_BOARD) {
|
||||
return new GuiRedstoneBoard(player, x, y, z);
|
||||
}
|
||||
|
||||
if (!world.blockExists(x, y, z)) {
|
||||
return null;
|
||||
|
@ -58,9 +61,6 @@ public class GuiHandler implements IGuiHandler {
|
|||
return new GuiIntegrationTable(player.inventory, (TileIntegrationTable) tile);
|
||||
}
|
||||
|
||||
case GuiIds.REDSTONE_BOARD:
|
||||
return new GuiRedstoneBoard(player, x, y, z);
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
@ -69,6 +69,10 @@ public class GuiHandler implements IGuiHandler {
|
|||
@Override
|
||||
public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) {
|
||||
|
||||
if (id == GuiIds.REDSTONE_BOARD) {
|
||||
return new ContainerRedstoneBoard(player, x, y, z);
|
||||
}
|
||||
|
||||
if (!world.blockExists(x, y, z)) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -75,14 +75,12 @@ public class ItemRedstoneBoard extends ItemBuildCraft {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer entityplayer, World world, int x,
|
||||
int y, int z, int i, float par8, float par9, float par10) {
|
||||
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World world, EntityPlayer entityPlayer) {
|
||||
if (!world.isRemote) {
|
||||
entityplayer.openGui(BuildCraftSilicon.instance, GuiIds.REDSTONE_BOARD, world, x, y, z);
|
||||
entityPlayer.openGui(BuildCraftSilicon.instance, GuiIds.REDSTONE_BOARD, world, 0, 0, 0);
|
||||
}
|
||||
|
||||
return true;
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -10,13 +10,32 @@ package buildcraft.silicon.gui;
|
|||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import buildcraft.api.boards.IBoardParameter;
|
||||
import buildcraft.api.boards.IBoardParameterStack;
|
||||
import buildcraft.api.boards.RedstoneBoardNBT;
|
||||
import buildcraft.api.boards.RedstoneBoardRegistry;
|
||||
import buildcraft.core.gui.BuildCraftContainer;
|
||||
import buildcraft.core.network.RPC;
|
||||
import buildcraft.core.network.RPCSide;
|
||||
import buildcraft.core.utils.NBTUtils;
|
||||
|
||||
public class ContainerRedstoneBoard extends BuildCraftContainer {
|
||||
|
||||
public ContainerRedstoneBoard(EntityPlayer player, int x, int y, int z) {
|
||||
super(player.inventory.getSizeInventory());
|
||||
private EntityPlayer player;
|
||||
private RedstoneBoardNBT board;
|
||||
private IBoardParameter[] params;
|
||||
|
||||
public ContainerRedstoneBoard(EntityPlayer iPlayer, int x, int y, int z) {
|
||||
super(iPlayer.inventory.getSizeInventory());
|
||||
|
||||
player = iPlayer;
|
||||
|
||||
NBTTagCompound boardNBT = NBTUtils.getItemData(player.getHeldItem());
|
||||
board = RedstoneBoardRegistry.instance.getRedstoneBoard(boardNBT);
|
||||
params = board.getParameters(boardNBT);
|
||||
|
||||
for (int sy = 0; sy < 3; sy++) {
|
||||
for (int sx = 0; sx < 9; sx++) {
|
||||
|
@ -34,4 +53,11 @@ public class ContainerRedstoneBoard extends BuildCraftContainer {
|
|||
public boolean canInteractWith(EntityPlayer entityplayer) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@RPC(RPCSide.SERVER)
|
||||
public void setParameterStack(int position, ItemStack stack) {
|
||||
NBTTagCompound boardNBT = NBTUtils.getItemData(player.getHeldItem());
|
||||
((IBoardParameterStack) params[position]).setStack(stack);
|
||||
board.setParameters(NBTUtils.getItemData(player.getHeldItem()), params);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,11 +16,14 @@ import net.minecraft.util.ResourceLocation;
|
|||
import net.minecraft.world.World;
|
||||
|
||||
import buildcraft.api.boards.IBoardParameter;
|
||||
import buildcraft.api.boards.IBoardParameterStack;
|
||||
import buildcraft.api.boards.RedstoneBoardNBT;
|
||||
import buildcraft.api.boards.RedstoneBoardRegistry;
|
||||
import buildcraft.core.DefaultProps;
|
||||
import buildcraft.core.gui.AdvancedSlot;
|
||||
import buildcraft.core.gui.GuiAdvancedInterface;
|
||||
import buildcraft.core.gui.ItemSlot;
|
||||
import buildcraft.core.network.RPCHandler;
|
||||
import buildcraft.core.utils.NBTUtils;
|
||||
|
||||
public class GuiRedstoneBoard extends GuiAdvancedInterface {
|
||||
|
@ -47,9 +50,13 @@ public class GuiRedstoneBoard extends GuiAdvancedInterface {
|
|||
board = RedstoneBoardRegistry.instance.getRedstoneBoard(boardNBT);
|
||||
params = board.getParameters(boardNBT);
|
||||
|
||||
slots = new AdvancedSlot [1];
|
||||
slots[0] = new ItemSlot(10, 10);
|
||||
slots[0].drawBackround = true;
|
||||
slots = new AdvancedSlot[params.length];
|
||||
|
||||
for (int i = 0; i < params.length; ++i) {
|
||||
slots[i] = new ItemSlot(this, 10, 10 + i * 20);
|
||||
slots[i].drawBackround = true;
|
||||
((ItemSlot) slots[i]).stack = ((IBoardParameterStack) params[i]).getStack();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
@ -91,6 +98,7 @@ public class GuiRedstoneBoard extends GuiAdvancedInterface {
|
|||
|
||||
if (slot instanceof ItemSlot) {
|
||||
((ItemSlot) slot).stack = mc.thePlayer.inventory.getItemStack();
|
||||
RPCHandler.rpcServer(container, "setParameterStack", position, mc.thePlayer.inventory.getItemStack());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue