Diamond pipes now handle metadata when updating. Removed IInventory from TileGenericPipe.
This commit is contained in:
parent
51303806e3
commit
7fbe8623ac
34 changed files with 173 additions and 375 deletions
buildcraft_client/net/minecraft/src/buildcraft
builders
core
energy
factory
silicon
transport
buildcraft_server/net/minecraft/src/buildcraft/transport
common/net/minecraft/src/buildcraft
builders
core
energy
factory
silicon
transport
|
@ -35,7 +35,7 @@ public class GuiBlueprintLibrary extends GuiBuildCraft {
|
|||
BptPlayerIndex index;
|
||||
|
||||
public GuiBlueprintLibrary(EntityPlayer player, TileBlueprintLibrary library) {
|
||||
super(new ContainerBlueprintLibrary(player, library));
|
||||
super(new ContainerBlueprintLibrary(player, library), library);
|
||||
this.player = player;
|
||||
xSize = 176;
|
||||
ySize = 225;
|
||||
|
|
|
@ -25,7 +25,7 @@ public class GuiBuilder extends GuiAdvancedInterface {
|
|||
TileBuilder builder;
|
||||
|
||||
public GuiBuilder(IInventory playerInventory, TileBuilder builder) {
|
||||
super(new CraftingBuilder(playerInventory, builder));
|
||||
super(new CraftingBuilder(playerInventory, builder), builder);
|
||||
this.playerInventory = playerInventory;
|
||||
this.builder = builder;
|
||||
xSize = 176;
|
||||
|
|
|
@ -22,7 +22,7 @@ public class GuiFiller extends GuiBuildCraft {
|
|||
TileFiller filler;
|
||||
|
||||
public GuiFiller(IInventory playerInventory, TileFiller filler) {
|
||||
super(new CraftingFiller(playerInventory, filler));
|
||||
super(new CraftingFiller(playerInventory, filler), filler);
|
||||
this.playerInventory = playerInventory;
|
||||
this.filler = filler;
|
||||
xSize = 175;
|
||||
|
|
|
@ -27,7 +27,7 @@ public class GuiTemplate extends GuiBuildCraft {
|
|||
boolean editMode = false;
|
||||
|
||||
public GuiTemplate(IInventory playerInventory, TileArchitect template) {
|
||||
super(new CraftingTemplate(playerInventory, template));
|
||||
super(new CraftingTemplate(playerInventory, template), template);
|
||||
this.playerInventory = playerInventory;
|
||||
this.template = template;
|
||||
xSize = 175;
|
||||
|
|
|
@ -113,8 +113,8 @@ public abstract class GuiAdvancedInterface extends GuiBuildCraft {
|
|||
|
||||
public AdvancedSlot[] slots;
|
||||
|
||||
public GuiAdvancedInterface(BuildCraftContainer container) {
|
||||
super(container);
|
||||
public GuiAdvancedInterface(BuildCraftContainer container, IInventory inventory) {
|
||||
super(container, inventory);
|
||||
}
|
||||
|
||||
public int getSlotAtLocation(int i, int j) {
|
||||
|
|
|
@ -223,13 +223,13 @@ public abstract class GuiBuildCraft extends GuiContainer {
|
|||
|
||||
protected TileEntity tile;
|
||||
|
||||
public GuiBuildCraft(BuildCraftContainer container) {
|
||||
public GuiBuildCraft(BuildCraftContainer container, IInventory inventory) {
|
||||
super(container);
|
||||
|
||||
if (container.inventory instanceof TileEntity)
|
||||
tile = (TileEntity) container.inventory;
|
||||
if (inventory instanceof TileEntity)
|
||||
tile = (TileEntity) inventory;
|
||||
|
||||
initLedgers(container.inventory);
|
||||
initLedgers(inventory);
|
||||
}
|
||||
|
||||
protected void initLedgers(IInventory inventory) {}
|
||||
|
|
|
@ -22,7 +22,7 @@ import org.lwjgl.opengl.GL11;
|
|||
public class GuiCombustionEngine extends GuiEngine {
|
||||
|
||||
public GuiCombustionEngine(InventoryPlayer inventoryplayer, TileEngine tileEngine) {
|
||||
super(new ContainerEngine(inventoryplayer, tileEngine));
|
||||
super(new ContainerEngine(inventoryplayer, tileEngine), tileEngine);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -50,8 +50,8 @@ public abstract class GuiEngine extends GuiBuildCraft {
|
|||
|
||||
}
|
||||
|
||||
public GuiEngine(BuildCraftContainer container) {
|
||||
super(container);
|
||||
public GuiEngine(BuildCraftContainer container, IInventory inventory) {
|
||||
super(container, inventory);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -18,7 +18,7 @@ import org.lwjgl.opengl.GL11;
|
|||
public class GuiSteamEngine extends GuiEngine {
|
||||
|
||||
public GuiSteamEngine(InventoryPlayer inventoryplayer, TileEngine tileEngine) {
|
||||
super(new ContainerEngine(inventoryplayer, tileEngine));
|
||||
super(new ContainerEngine(inventoryplayer, tileEngine), tileEngine);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -19,7 +19,7 @@ import org.lwjgl.opengl.GL11;
|
|||
public class GuiAutoCrafting extends GuiBuildCraft {
|
||||
|
||||
public GuiAutoCrafting(InventoryPlayer inventoryplayer, World world, TileAutoWorkbench tile) {
|
||||
super(new ContainerAutoWorkbench(inventoryplayer, tile));
|
||||
super(new ContainerAutoWorkbench(inventoryplayer, tile), tile);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -24,7 +24,7 @@ public class GuiRefinery extends GuiAdvancedInterface {
|
|||
ContainerRefinery container;
|
||||
|
||||
public GuiRefinery(InventoryPlayer inventory, TileRefinery refinery) {
|
||||
super(new ContainerRefinery(inventory, refinery));
|
||||
super(new ContainerRefinery(inventory, refinery), refinery);
|
||||
|
||||
xSize = 175;
|
||||
ySize = 207;
|
||||
|
|
|
@ -32,7 +32,6 @@ import org.lwjgl.opengl.GL11;
|
|||
public class GuiAssemblyTable extends GuiAdvancedInterface {
|
||||
|
||||
TileAssemblyTable assemblyTable;
|
||||
private IInventory playerInventory;
|
||||
|
||||
class RecipeSlot extends AdvancedSlot {
|
||||
|
||||
|
@ -52,9 +51,8 @@ public class GuiAssemblyTable extends GuiAdvancedInterface {
|
|||
}
|
||||
|
||||
public GuiAssemblyTable(IInventory playerInventory, TileAssemblyTable assemblyTable) {
|
||||
super(new ContainerAssemblyTable(playerInventory, assemblyTable));
|
||||
super(new ContainerAssemblyTable(playerInventory, assemblyTable), assemblyTable);
|
||||
|
||||
this.playerInventory = playerInventory;
|
||||
this.assemblyTable = assemblyTable;
|
||||
xSize = 175;
|
||||
ySize = 207;
|
||||
|
|
|
@ -24,12 +24,12 @@ import org.lwjgl.opengl.GL11;
|
|||
public class GuiDiamondPipe extends GuiAdvancedInterface {
|
||||
|
||||
IInventory playerInventory;
|
||||
TileGenericPipe filterInventory;
|
||||
PipeLogicDiamond filterInventory;
|
||||
|
||||
public GuiDiamondPipe(IInventory playerInventory, TileGenericPipe filterInventory) {
|
||||
super(new CraftingDiamondPipe(playerInventory, filterInventory));
|
||||
public GuiDiamondPipe(IInventory playerInventory, TileGenericPipe tile) {
|
||||
super(new CraftingDiamondPipe(playerInventory, (IInventory)tile.pipe.logic), (IInventory)tile.pipe.logic);
|
||||
this.playerInventory = playerInventory;
|
||||
this.filterInventory = filterInventory;
|
||||
this.filterInventory = (PipeLogicDiamond)tile.pipe.logic;
|
||||
xSize = 175;
|
||||
ySize = 225;
|
||||
|
||||
|
@ -39,7 +39,7 @@ public class GuiDiamondPipe extends GuiAdvancedInterface {
|
|||
for (int j1 = 0; j1 < 9; j1++) {
|
||||
int id = k * 9 + j1;
|
||||
slots[id] = new IInventorySlot(8 + j1 * 18, 18 + k * 18, filterInventory, j1 + k * 9);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -160,7 +160,7 @@ public class GuiGateInterface extends GuiAdvancedInterface {
|
|||
}
|
||||
|
||||
public GuiGateInterface(IInventory playerInventory, Pipe pipe) {
|
||||
super(new CraftingGateInterface(playerInventory, pipe));
|
||||
super(new CraftingGateInterface(playerInventory, pipe), null);
|
||||
|
||||
_container = (CraftingGateInterface) this.inventorySlots;
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ import net.minecraft.src.World;
|
|||
import net.minecraft.src.buildcraft.core.BlockIndex;
|
||||
import net.minecraft.src.buildcraft.core.network.ISynchronizedTile;
|
||||
import net.minecraft.src.buildcraft.core.network.PacketIds;
|
||||
import net.minecraft.src.buildcraft.core.network.PacketNBT;
|
||||
import net.minecraft.src.buildcraft.core.network.PacketPipeDescription;
|
||||
import net.minecraft.src.buildcraft.core.network.PacketPipeTransportContent;
|
||||
import net.minecraft.src.buildcraft.core.network.PacketUpdate;
|
||||
|
@ -36,9 +37,9 @@ public class PacketHandler implements IPacketHandler {
|
|||
PacketUpdate packet = new PacketUpdate();
|
||||
switch (packetID) {
|
||||
case PacketIds.DIAMOND_PIPE_CONTENTS:
|
||||
packet = new PacketUpdate(packetID);
|
||||
packet.readData(data);
|
||||
onDiamondContents(packet);
|
||||
PacketNBT packetN = new PacketNBT();
|
||||
packetN.readData(data);
|
||||
onDiamondContents(packetN);
|
||||
break;
|
||||
case PacketIds.PIPE_DESCRIPTION:
|
||||
PacketPipeDescription packetU = new PacketPipeDescription();
|
||||
|
@ -161,7 +162,7 @@ public class PacketHandler implements IPacketHandler {
|
|||
*
|
||||
* @param packet
|
||||
*/
|
||||
private void onDiamondContents(PacketUpdate packet) {
|
||||
private void onDiamondContents(PacketNBT packet) {
|
||||
|
||||
World world = ModLoader.getMinecraftInstance().theWorld;
|
||||
|
||||
|
@ -179,16 +180,17 @@ public class PacketHandler implements IPacketHandler {
|
|||
if (!(pipe.pipe.logic instanceof PipeLogicDiamond))
|
||||
return;
|
||||
|
||||
((PipeLogicDiamond) pipe.pipe.logic).handleContentsPacket(packet);
|
||||
((PipeLogicDiamond) pipe.pipe.logic).handleFilterSet(packet);
|
||||
|
||||
// / FIXME: Unsure how to handle this
|
||||
/*
|
||||
BlockIndex index = new BlockIndex(packet.posX, packet.posY, packet.posZ);
|
||||
|
||||
if (BuildCraftCore.bufferedDescriptions.containsKey(index))
|
||||
BuildCraftCore.bufferedDescriptions.remove(index);
|
||||
|
||||
BuildCraftCore.bufferedDescriptions.put(index, packet);
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ public class GuiHandler implements IGuiHandler {
|
|||
switch (ID) {
|
||||
|
||||
case GuiIds.PIPE_DIAMOND:
|
||||
return new CraftingDiamondPipe(player.inventory, pipe);
|
||||
return new CraftingDiamondPipe(player.inventory, (PipeLogicDiamond)pipe.pipe.logic);
|
||||
|
||||
case GuiIds.GATES:
|
||||
return new CraftingGateInterface(player.inventory, pipe.pipe);
|
||||
|
|
|
@ -129,7 +129,7 @@ public class PacketHandler implements IPacketHandler {
|
|||
if (!(pipe.pipe.logic instanceof PipeLogicDiamond))
|
||||
return;
|
||||
|
||||
pipe.pipe.logic.setInventorySlotContents(packet.slot, packet.stack);
|
||||
((PipeLogicDiamond)pipe.pipe.logic).setInventorySlotContents(packet.slot, packet.stack);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ class ContainerBlueprintLibrary extends BuildCraftContainer {
|
|||
TileBlueprintLibrary library;
|
||||
|
||||
public ContainerBlueprintLibrary(EntityPlayer player, TileBlueprintLibrary library) {
|
||||
super(library);
|
||||
super(library.getSizeInventory());
|
||||
this.playerInventory = player.inventory;
|
||||
this.library = library;
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ class CraftingBuilder extends BuildCraftContainer {
|
|||
TileBuilder builder;
|
||||
|
||||
public CraftingBuilder(IInventory playerInventory, TileBuilder builder) {
|
||||
super(builder);
|
||||
super(builder.getSizeInventory());
|
||||
this.playerIInventory = playerInventory;
|
||||
this.builder = builder;
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ class CraftingFiller extends BuildCraftContainer {
|
|||
IInventory fillerInventory;
|
||||
|
||||
public CraftingFiller(IInventory playerInventory, IInventory fillerInventory) {
|
||||
super(fillerInventory);
|
||||
super(fillerInventory.getSizeInventory());
|
||||
this.playerIInventory = playerInventory;
|
||||
this.fillerInventory = fillerInventory;
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ class CraftingTemplateRoot extends BuildCraftContainer {
|
|||
int computingTime = 0;
|
||||
|
||||
public CraftingTemplateRoot(IInventory playerInventory, TileArchitect template) {
|
||||
super(template);
|
||||
super(template.getSizeInventory());
|
||||
this.playerIInventory = playerInventory;
|
||||
this.template = template;
|
||||
|
||||
|
|
|
@ -16,10 +16,10 @@ import net.minecraft.src.Slot;
|
|||
|
||||
public abstract class BuildCraftContainer extends Container {
|
||||
|
||||
public IInventory inventory;
|
||||
private int inventorySize;
|
||||
|
||||
public BuildCraftContainer(IInventory inventory) {
|
||||
this.inventory = inventory;
|
||||
public BuildCraftContainer(int inventorySize) {
|
||||
this.inventorySize = inventorySize;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -29,10 +29,10 @@ public abstract class BuildCraftContainer extends Container {
|
|||
if (slot != null && slot.getHasStack()) {
|
||||
ItemStack itemstack1 = slot.getStack();
|
||||
itemstack = itemstack1.copy();
|
||||
if (i < inventory.getSizeInventory()) {
|
||||
if (!mergeItemStack(itemstack1, inventory.getSizeInventory(), inventorySlots.size(), true))
|
||||
if (i < inventorySize) {
|
||||
if (!mergeItemStack(itemstack1, inventorySize, inventorySlots.size(), true))
|
||||
return null;
|
||||
} else if (!mergeItemStack(itemstack1, 0, inventory.getSizeInventory(), false))
|
||||
} else if (!mergeItemStack(itemstack1, 0, inventorySize, false))
|
||||
return null;
|
||||
if (itemstack1.stackSize == 0)
|
||||
slot.putStack(null);
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
package net.minecraft.src.buildcraft.core.network;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.src.CompressedStreamTools;
|
||||
import net.minecraft.src.NBTTagCompound;
|
||||
|
||||
public class PacketNBT extends PacketCoordinates {
|
||||
|
||||
private NBTTagCompound nbttagcompound;
|
||||
|
||||
public PacketNBT() {
|
||||
}
|
||||
|
||||
public PacketNBT(int id, NBTTagCompound nbttagcompound, int xCoord, int yCoord, int zCoord) {
|
||||
super(id, xCoord, yCoord, zCoord);
|
||||
this.nbttagcompound = nbttagcompound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeData(DataOutputStream data) throws IOException {
|
||||
|
||||
super.writeData(data);
|
||||
|
||||
byte[] compressed = CompressedStreamTools.compress(nbttagcompound);
|
||||
data.writeShort(compressed.length);
|
||||
data.write(compressed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(DataInputStream data) throws IOException {
|
||||
|
||||
super.readData(data);
|
||||
|
||||
short length = data.readShort();
|
||||
byte[] compressed = new byte[length];
|
||||
data.readFully(compressed);
|
||||
this.nbttagcompound = CompressedStreamTools.decompress(compressed);
|
||||
}
|
||||
|
||||
public NBTTagCompound getTagCompound() {
|
||||
return this.nbttagcompound;
|
||||
}
|
||||
|
||||
}
|
|
@ -17,7 +17,7 @@ import net.minecraft.src.buildcraft.core.BuildCraftContainer;
|
|||
public class ContainerEngineRoot extends BuildCraftContainer {
|
||||
|
||||
public ContainerEngineRoot(InventoryPlayer inventoryplayer, TileEngine tileEngine) {
|
||||
super(tileEngine);
|
||||
super(tileEngine.getSizeInventory());
|
||||
|
||||
engine = tileEngine;
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ public class ContainerAutoWorkbench extends BuildCraftContainer {
|
|||
}
|
||||
|
||||
public ContainerAutoWorkbench(InventoryPlayer inventoryplayer, TileAutoWorkbench tile) {
|
||||
super(tile);
|
||||
super(tile.getSizeInventory());
|
||||
|
||||
craftResult = new InventoryCraftResult();
|
||||
this.tile = tile;
|
||||
|
|
|
@ -12,7 +12,7 @@ public class ContainerHopper extends BuildCraftContainer {
|
|||
TileHopper hopper;
|
||||
|
||||
public ContainerHopper(InventoryPlayer inventory, TileHopper tile) {
|
||||
super(tile);
|
||||
super(tile.getSizeInventory());
|
||||
playerIInventory = inventory;
|
||||
hopper = tile;
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ public class ContainerRefinery extends BuildCraftContainer {
|
|||
TileRefinery refinery;
|
||||
|
||||
public ContainerRefinery(InventoryPlayer inventory, TileRefinery refinery) {
|
||||
super(refinery);
|
||||
super(refinery.getSizeInventory());
|
||||
|
||||
for (int l = 0; l < 3; l++) {
|
||||
for (int k1 = 0; k1 < 9; k1++) {
|
||||
|
|
|
@ -25,7 +25,7 @@ class ContainerAssemblyTable extends BuildCraftContainer {
|
|||
boolean networkSynchronized = false;
|
||||
|
||||
public ContainerAssemblyTable(IInventory playerInventory, TileAssemblyTable table) {
|
||||
super(table);
|
||||
super(table.getSizeInventory());
|
||||
this.playerIInventory = playerInventory;
|
||||
|
||||
for (int l = 0; l < 4; l++) {
|
||||
|
|
|
@ -20,7 +20,7 @@ class CraftingDiamondPipe extends BuildCraftContainer {
|
|||
IInventory filterIInventory;
|
||||
|
||||
public CraftingDiamondPipe(IInventory playerInventory, IInventory filterInventory) {
|
||||
super(filterInventory);
|
||||
super(filterInventory.getSizeInventory());
|
||||
this.playerIInventory = playerInventory;
|
||||
this.filterIInventory = filterInventory;
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ public class CraftingGateInterface extends BuildCraftContainer {
|
|||
private boolean isNetInitialized = false;
|
||||
|
||||
public CraftingGateInterface(IInventory playerInventory, Pipe pipe) {
|
||||
super(pipe.container);
|
||||
super(0);
|
||||
this.playerIInventory = playerInventory;
|
||||
|
||||
for (int l = 0; l < 3; l++)
|
||||
|
@ -86,7 +86,7 @@ public class CraftingGateInterface extends BuildCraftContainer {
|
|||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer entityplayer) {
|
||||
return pipe.container.isUseableByPlayer(entityplayer);
|
||||
return true;
|
||||
}
|
||||
|
||||
/** CLIENT SIDE **/
|
||||
|
|
|
@ -30,94 +30,26 @@ public class PipeLogic implements IDropControlInventory {
|
|||
this.yCoord = yCoord;
|
||||
this.zCoord = zCoord;
|
||||
}
|
||||
public void setWorld(World worldObj) { this.worldObj = worldObj; }
|
||||
public void setTile(TileGenericPipe tile) { this.container = tile; }
|
||||
|
||||
public void setWorld(World worldObj) {
|
||||
this.worldObj = worldObj;
|
||||
}
|
||||
/* SAVING & LOADING */
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound) {}
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {}
|
||||
|
||||
public boolean blockActivated(EntityPlayer entityplayer) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
|
||||
}
|
||||
|
||||
public void setTile(TileGenericPipe tile) {
|
||||
this.container = tile;
|
||||
}
|
||||
|
||||
public boolean isPipeConnected(TileEntity tile) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void onNeighborBlockChange(int blockId) {
|
||||
|
||||
}
|
||||
|
||||
public void onBlockPlaced() {
|
||||
|
||||
}
|
||||
|
||||
public void initialize() {
|
||||
|
||||
}
|
||||
|
||||
public boolean inputOpen(Orientations from) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean outputOpen(Orientations to) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean addItem(ItemStack stack, boolean doAdd, Orientations from) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public ItemStack extractItem(boolean doRemove, Orientations from) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getSizeInventory() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public ItemStack getStackInSlot(int i) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public ItemStack decrStackSize(int i, int j) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setInventorySlotContents(int i, ItemStack itemstack) {
|
||||
|
||||
}
|
||||
|
||||
public String getInvName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getInventoryStackLimit() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public boolean canInteractWith(EntityPlayer entityplayer) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void updateEntity() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doDrop() {
|
||||
return true;
|
||||
}
|
||||
/* PIPE LOGIC */
|
||||
public void initialize() {}
|
||||
public void updateEntity() {}
|
||||
|
||||
public boolean blockActivated(EntityPlayer entityplayer) { return false; }
|
||||
|
||||
public boolean isPipeConnected(TileEntity tile) { return true; }
|
||||
public void onNeighborBlockChange(int blockId) {}
|
||||
public void onBlockPlaced() {}
|
||||
|
||||
public boolean inputOpen(Orientations from) { return true; }
|
||||
public boolean outputOpen(Orientations to) { return true; }
|
||||
|
||||
/* IDROPCONTROLINVENTORY */
|
||||
@Override public boolean doDrop() { return true; }
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ import net.minecraft.src.NBTTagList;
|
|||
import net.minecraft.src.Packet;
|
||||
import net.minecraft.src.mod_BuildCraftTransport;
|
||||
import net.minecraft.src.buildcraft.api.APIProxy;
|
||||
import net.minecraft.src.buildcraft.api.ISpecialInventory;
|
||||
import net.minecraft.src.buildcraft.api.Orientations;
|
||||
import net.minecraft.src.buildcraft.api.SafeTimeTracker;
|
||||
import net.minecraft.src.buildcraft.api.TileNetworkData;
|
||||
|
@ -25,34 +26,22 @@ import net.minecraft.src.buildcraft.core.CoreProxy;
|
|||
import net.minecraft.src.buildcraft.core.DefaultProps;
|
||||
import net.minecraft.src.buildcraft.core.GuiIds;
|
||||
import net.minecraft.src.buildcraft.core.network.PacketIds;
|
||||
import net.minecraft.src.buildcraft.core.network.PacketNBT;
|
||||
import net.minecraft.src.buildcraft.core.network.PacketUpdate;
|
||||
import net.minecraft.src.buildcraft.core.network.TilePacketWrapper;
|
||||
import net.minecraft.src.buildcraft.core.utils.SimpleInventory;
|
||||
|
||||
public class PipeLogicDiamond extends PipeLogic {
|
||||
|
||||
ItemStack[] items = new ItemStack[54];
|
||||
|
||||
public class PacketStack {
|
||||
|
||||
@TileNetworkData(intKind = TileNetworkData.UNSIGNED_BYTE)
|
||||
public int num;
|
||||
|
||||
@TileNetworkData(staticSize = 9)
|
||||
public short[] ids = new short[9];
|
||||
|
||||
@TileNetworkData(staticSize = 9, intKind = TileNetworkData.UNSIGNED_BYTE)
|
||||
public int[] dmg = new int[9];
|
||||
}
|
||||
|
||||
private static TilePacketWrapper networkPacket;
|
||||
public class PipeLogicDiamond extends PipeLogic implements ISpecialInventory {
|
||||
|
||||
private SimpleInventory filters = new SimpleInventory(54, "items", 1);
|
||||
private final SafeTimeTracker tracker = new SafeTimeTracker();
|
||||
|
||||
public PipeLogicDiamond() {
|
||||
if (networkPacket == null)
|
||||
networkPacket = new TilePacketWrapper(new Class[] { PacketStack.class });
|
||||
/* PIPE LOGIC */
|
||||
@Override
|
||||
public boolean doDrop() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean blockActivated(EntityPlayer entityplayer) {
|
||||
if (entityplayer.getCurrentEquippedItem() != null
|
||||
|
@ -67,107 +56,28 @@ public class PipeLogicDiamond extends PipeLogic {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return items.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int i) {
|
||||
return items[i];
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int i, int j) {
|
||||
ItemStack stack = items[i].copy();
|
||||
stack.stackSize = j;
|
||||
|
||||
items[i].stackSize -= j;
|
||||
|
||||
if (items[i].stackSize == 0)
|
||||
items[i] = null;
|
||||
|
||||
if (APIProxy.isServerSide())
|
||||
for (int p = 0; p < 6; ++p)
|
||||
CoreProxy.sendToPlayers(getContentsPacket(p), worldObj, xCoord, yCoord, zCoord,
|
||||
DefaultProps.NETWORK_UPDATE_RANGE, mod_BuildCraftTransport.instance);
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int i, ItemStack itemstack) {
|
||||
if (items[i] == null && itemstack == null)
|
||||
return;
|
||||
else if (items[i] != null && itemstack != null && items[i].isStackEqual(itemstack))
|
||||
return;
|
||||
|
||||
if (itemstack != null)
|
||||
items[i] = itemstack.copy();
|
||||
else
|
||||
items[i] = null;
|
||||
|
||||
if (APIProxy.isServerSide())
|
||||
for (int p = 0; p < 6; ++p)
|
||||
CoreProxy.sendToPlayers(getContentsPacket(p), worldObj, xCoord, yCoord, zCoord,
|
||||
DefaultProps.NETWORK_UPDATE_RANGE, mod_BuildCraftTransport.instance);
|
||||
}
|
||||
|
||||
/* UPDATING */
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
if (tracker.markTimeIfDelay(worldObj, 20 * BuildCraftCore.updateFactor))
|
||||
if (APIProxy.isServerSide())
|
||||
for (int p = 0; p < 6; ++p)
|
||||
CoreProxy.sendToPlayers(getContentsPacket(p), worldObj, xCoord, yCoord, zCoord,
|
||||
DefaultProps.NETWORK_UPDATE_RANGE, mod_BuildCraftTransport.instance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInvName() {
|
||||
return "Filters";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer entityplayer) {
|
||||
// TODO Auto-generated method stub
|
||||
return true;
|
||||
sendFilterSet();
|
||||
}
|
||||
|
||||
/* SAVING & LOADING */
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
super.readFromNBT(nbttagcompound);
|
||||
|
||||
NBTTagList nbttaglist = nbttagcompound.getTagList("items");
|
||||
|
||||
for (int j = 0; j < nbttaglist.tagCount(); ++j) {
|
||||
NBTTagCompound nbttagcompound2 = (NBTTagCompound) nbttaglist.tagAt(j);
|
||||
int index = nbttagcompound2.getInteger("index");
|
||||
items[index] = ItemStack.loadItemStackFromNBT(nbttagcompound2);
|
||||
}
|
||||
filters.readFromNBT(nbttagcompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
super.writeToNBT(nbttagcompound);
|
||||
|
||||
NBTTagList nbttaglist = new NBTTagList();
|
||||
|
||||
for (int j = 0; j < items.length; ++j)
|
||||
if (items[j] != null && items[j].stackSize > 0) {
|
||||
NBTTagCompound nbttagcompound2 = new NBTTagCompound();
|
||||
nbttaglist.appendTag(nbttagcompound2);
|
||||
nbttagcompound2.setInteger("index", j);
|
||||
items[j].writeToNBT(nbttagcompound2);
|
||||
}
|
||||
|
||||
nbttagcompound.setTag("items", nbttaglist);
|
||||
filters.writeToNBT(nbttagcompound);
|
||||
}
|
||||
|
||||
/* ISPECIALINVENTORY */
|
||||
@Override
|
||||
public boolean addItem(ItemStack stack, boolean doAdd, Orientations from) {
|
||||
return false;
|
||||
|
@ -178,43 +88,47 @@ public class PipeLogicDiamond extends PipeLogic {
|
|||
return null;
|
||||
}
|
||||
|
||||
/** SERVER SIDE **/
|
||||
public Packet getContentsPacket(int num) {
|
||||
PacketStack stacks = new PacketStack();
|
||||
stacks.num = num;
|
||||
/* IINVENTORY IMPLEMENTATION */
|
||||
@Override public int getSizeInventory() { return filters.getSizeInventory(); }
|
||||
@Override public ItemStack getStackInSlot(int i) { return filters.getStackInSlot(i); }
|
||||
@Override public String getInvName() { return "Filters"; }
|
||||
@Override public int getInventoryStackLimit() { return filters.getInventoryStackLimit(); }
|
||||
@Override public ItemStack getStackInSlotOnClosing(int i) { return filters.getStackInSlotOnClosing(i); }
|
||||
@Override public void onInventoryChanged() { filters.onInventoryChanged(); }
|
||||
@Override public boolean isUseableByPlayer(EntityPlayer var1) { return true; }
|
||||
@Override public void openChest() {}
|
||||
@Override public void closeChest() {}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int i, int j) {
|
||||
ItemStack stack = filters.decrStackSize(i, j);
|
||||
|
||||
for (int j = 0; j < 9; ++j)
|
||||
if (items[j + num * 9] == null) {
|
||||
stacks.ids[j] = -1;
|
||||
stacks.dmg[j] = -1;
|
||||
} else {
|
||||
stacks.ids[j] = (short) items[j + num * 9].itemID;
|
||||
stacks.dmg[j] = items[j + num * 9].getItemDamage();
|
||||
}
|
||||
if (APIProxy.isServerSide())
|
||||
sendFilterSet();
|
||||
|
||||
return new PacketUpdate(PacketIds.DIAMOND_PIPE_CONTENTS, xCoord, yCoord, zCoord, networkPacket.toPayload(stacks))
|
||||
.getPacket();
|
||||
|
||||
}
|
||||
|
||||
/** CLIENT SIDE **/
|
||||
public void handleContentsPacket(PacketUpdate packet) {
|
||||
PacketStack stacks = new PacketStack();
|
||||
|
||||
networkPacket.fromPayload(stacks, packet.payload);
|
||||
|
||||
int num = stacks.num;
|
||||
|
||||
for (int j = 0; j < 9; ++j)
|
||||
if (stacks.ids[j] == -1)
|
||||
items[num * 9 + j] = null;
|
||||
else
|
||||
items[num * 9 + j] = new ItemStack(stacks.ids[j], 1, stacks.dmg[j]);
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doDrop() {
|
||||
return false;
|
||||
public void setInventorySlotContents(int i, ItemStack itemstack) {
|
||||
|
||||
filters.setInventorySlotContents(i, itemstack);
|
||||
if (APIProxy.isServerSide())
|
||||
sendFilterSet();
|
||||
|
||||
}
|
||||
|
||||
/* SERVER SIDE */
|
||||
public void sendFilterSet() {
|
||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
this.writeToNBT(nbttagcompound);
|
||||
PacketNBT packet = new PacketNBT(PacketIds.DIAMOND_PIPE_CONTENTS, nbttagcompound, xCoord, yCoord, zCoord);
|
||||
CoreProxy.sendToPlayers(packet.getPacket(), worldObj, xCoord, yCoord, zCoord, DefaultProps.NETWORK_UPDATE_RANGE, mod_BuildCraftTransport.instance);
|
||||
}
|
||||
|
||||
/* CLIENT SIDE */
|
||||
public void handleFilterSet(PacketNBT packet) {
|
||||
this.readFromNBT(packet.getTagCompound());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ import net.minecraft.src.buildcraft.core.network.PacketPipeDescription;
|
|||
import net.minecraft.src.buildcraft.core.network.PacketTileUpdate;
|
||||
import net.minecraft.src.buildcraft.core.network.PacketUpdate;
|
||||
|
||||
public class TileGenericPipe extends TileEntity implements IPowerReceptor, ILiquidContainer, ISpecialInventory, IPipeEntry,
|
||||
public class TileGenericPipe extends TileEntity implements IPowerReceptor, ILiquidContainer, IPipeEntry,
|
||||
IPipeTile, ISynchronizedTile, IOverrideDefaultTriggers, ITileBufferHolder, IPipeConnection, IDropControlInventory {
|
||||
|
||||
public TileBuffer[] tileBuffer;
|
||||
|
@ -254,92 +254,6 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ILiqu
|
|||
blockNeighborChange = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
if (BlockGenericPipe.isFullyDefined(pipe))
|
||||
return pipe.logic.getSizeInventory();
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int i) {
|
||||
if (BlockGenericPipe.isFullyDefined(pipe))
|
||||
return pipe.logic.getStackInSlot(i);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int i, int j) {
|
||||
if (BlockGenericPipe.isFullyDefined(pipe))
|
||||
return pipe.logic.decrStackSize(i, j);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int i, ItemStack itemstack) {
|
||||
if (BlockGenericPipe.isFullyDefined(pipe))
|
||||
pipe.logic.setInventorySlotContents(i, itemstack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int slot) {
|
||||
if (!BlockGenericPipe.isFullyDefined(pipe))
|
||||
return null;
|
||||
|
||||
if (pipe.logic.getStackInSlot(slot) == null)
|
||||
return null;
|
||||
|
||||
ItemStack toReturn = pipe.logic.getStackInSlot(slot);
|
||||
pipe.logic.setInventorySlotContents(slot, null);
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInvName() {
|
||||
if (BlockGenericPipe.isFullyDefined(pipe))
|
||||
return pipe.logic.getInvName();
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
if (BlockGenericPipe.isFullyDefined(pipe))
|
||||
return pipe.logic.getInventoryStackLimit();
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer entityplayer) {
|
||||
if (worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) != this)
|
||||
return false;
|
||||
|
||||
if (BlockGenericPipe.isFullyDefined(pipe))
|
||||
return pipe.logic.canInteractWith(entityplayer);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addItem(ItemStack stack, boolean doAdd, Orientations from) {
|
||||
if (BlockGenericPipe.isValid(pipe))
|
||||
return pipe.logic.addItem(stack, doAdd, from);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack extractItem(boolean doRemove, Orientations from) {
|
||||
if (BlockGenericPipe.isValid(pipe))
|
||||
return pipe.logic.extractItem(doRemove, from);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void entityEntering(EntityPassiveItem item, Orientations orientation) {
|
||||
if (BlockGenericPipe.isValid(pipe))
|
||||
|
@ -405,16 +319,6 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ILiqu
|
|||
return pipe.getNetworkPacket();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openChest() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeChest() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int powerRequest() {
|
||||
return getPowerProvider().maxEnergyReceived;
|
||||
|
|
|
@ -55,8 +55,9 @@ public class PipeItemsDiamond extends Pipe implements IPipeTransportItemsHook {
|
|||
// NB: if there's several of the same match, the probability
|
||||
// to use that filter is higher, this is why there are
|
||||
// no breaks here.
|
||||
PipeLogicDiamond diamondLogic = (PipeLogicDiamond)logic;
|
||||
for (int slot = 0; slot < 9; ++slot) {
|
||||
ItemStack stack = logic.getStackInSlot(dir.ordinal() * 9 + slot);
|
||||
ItemStack stack = diamondLogic.getStackInSlot(dir.ordinal() * 9 + slot);
|
||||
|
||||
if (stack != null)
|
||||
foundFilter = true;
|
||||
|
|
Loading…
Add table
Reference in a new issue