diff --git a/src/main/java/com/hbm/blocks/network/pneumatic/PneumoStorageExporter.java b/src/main/java/com/hbm/blocks/network/pneumatic/PneumoStorageExporter.java index 49d0724e4..033447355 100644 --- a/src/main/java/com/hbm/blocks/network/pneumatic/PneumoStorageExporter.java +++ b/src/main/java/com/hbm/blocks/network/pneumatic/PneumoStorageExporter.java @@ -1,6 +1,7 @@ package com.hbm.blocks.network.pneumatic; import com.hbm.blocks.machine.BlockMachineBase; +import com.hbm.tileentity.network.pneumatic.TileEntityPneumoStorageExporter; import net.minecraft.block.material.Material; import net.minecraft.tileentity.TileEntity; @@ -14,6 +15,6 @@ public class PneumoStorageExporter extends BlockMachineBase { @Override public TileEntity createNewTileEntity(World world, int meta) { - return null; + return new TileEntityPneumoStorageExporter(); } } diff --git a/src/main/java/com/hbm/module/ParseMSES1Ext1.java b/src/main/java/com/hbm/module/ParseMSES1Ext1.java index 072e6ed58..d59ce6ee3 100644 --- a/src/main/java/com/hbm/module/ParseMSES1Ext1.java +++ b/src/main/java/com/hbm/module/ParseMSES1Ext1.java @@ -9,6 +9,7 @@ import java.util.regex.Pattern; * Additions compared to v1 Standard: * * Support for splitter chars, splitting and split count * * Support for the stack, a secondary buffer that can push, pop and peek + * * Support for getting string length and substring using first and last * * @author hbm */ @@ -77,6 +78,36 @@ public class ParseMSES1Ext1 extends ParseMSES1 { return EnumStatementReturn.OK; } + // figures out buffer string's length + if(lower.equals("length")) { + ctx.writeBuffer("" + ctx.readBuffer().length()); + return EnumStatementReturn.OK; + } + + // grabs the first x characters from the buffer and writes them back to the buffer + if(lower.startsWith("first ")) { + if(line.length() <= 6) return EnumStatementReturn.PARAMETER_ERROR; + try { + int length = Integer.parseInt(line.substring(6)); + int max = ctx.readBuffer().length(); + if(length > max) length = max; + ctx.writeBuffer(ctx.readBuffer().substring(0, length)); + return EnumStatementReturn.OK; + } catch(Exception x) { return EnumStatementReturn.PARAMETER_ERROR; } + } + + // grabs the last x characters from the buffer and writes them back to the buffer + if(lower.startsWith("last ")) { + if(line.length() <= 5) return EnumStatementReturn.PARAMETER_ERROR; + try { + int length = Integer.parseInt(line.substring(5)); + int max = ctx.readBuffer().length(); + if(length > max) length = max; + ctx.writeBuffer(ctx.readBuffer().substring(max - length, max)); + return EnumStatementReturn.OK; + } catch(Exception x) { return EnumStatementReturn.PARAMETER_ERROR; } + } + return super.eval(ctx, line); } } diff --git a/src/main/java/com/hbm/tileentity/network/pneumatic/TileEntityPneumaticMachineBase.java b/src/main/java/com/hbm/tileentity/network/pneumatic/TileEntityPneumaticMachineBase.java new file mode 100644 index 000000000..681739cf4 --- /dev/null +++ b/src/main/java/com/hbm/tileentity/network/pneumatic/TileEntityPneumaticMachineBase.java @@ -0,0 +1,69 @@ +package com.hbm.tileentity.network.pneumatic; + +import com.hbm.tileentity.IGUIProvider; +import com.hbm.tileentity.TileEntityMachineBase; +import com.hbm.tileentity.network.pneumatic.TileEntityPneumoTube.PneumaticNode; +import com.hbm.uninos.UniNodespace; +import com.hbm.uninos.networkproviders.PneumaticNetworkProvider; +import com.hbm.util.fauxpointtwelve.BlockPos; + +import api.hbm.ntl.IPneumaticConnector; +import api.hbm.ntl.StackCache; + +public abstract class TileEntityPneumaticMachineBase extends TileEntityMachineBase implements IPneumaticConnector, IGUIProvider { + + protected PneumaticNode node; + public StackCache cache; + + public TileEntityPneumaticMachineBase(int slotCount) { + super(slotCount); + } + + @Override + public void updateEntity() { + + if(!worldObj.isRemote) { + + if(this.node == null || this.node.expired) { + if(this.cache != null) this.cache.dissolveCache(); + + this.node = (PneumaticNode) UniNodespace.getNode(worldObj, xCoord, yCoord, zCoord, PneumaticNetworkProvider.THE_PROVIDER); + + if(this.node == null || this.node.expired) { + this.node = (PneumaticNode) new PneumaticNode(new BlockPos(xCoord, yCoord, zCoord)).setStandardConnections(xCoord, yCoord, zCoord); + UniNodespace.createNode(worldObj, this.node); + } + } + + if(this.cache == null || this.cache.hasExpired) { + this.cache = new StackCache(xCoord, yCoord, zCoord); + } + + if(this.node != null && this.node.hasValidNet()) { + this.node.net.addStackCache(cache); + } + } + } + + @Override + public void invalidate() { + super.invalidate(); + + if(!worldObj.isRemote && this.node != null) { + UniNodespace.destroyNode(worldObj, xCoord, yCoord, zCoord, PneumaticNetworkProvider.THE_PROVIDER); + } + + if(this.cache != null) this.cache.dissolveCache(); + } + + @Override + public void onChunkUnload() { + super.onChunkUnload(); + + if(!worldObj.isRemote && this.node != null) { + UniNodespace.destroyNode(worldObj, xCoord, yCoord, zCoord, PneumaticNetworkProvider.THE_PROVIDER); + } + + if(this.cache != null) this.cache.dissolveCache(); + } +} diff --git a/src/main/java/com/hbm/tileentity/network/pneumatic/TileEntityPneumoStorageExporter.java b/src/main/java/com/hbm/tileentity/network/pneumatic/TileEntityPneumoStorageExporter.java new file mode 100644 index 000000000..0bd594d5f --- /dev/null +++ b/src/main/java/com/hbm/tileentity/network/pneumatic/TileEntityPneumoStorageExporter.java @@ -0,0 +1,57 @@ +package com.hbm.tileentity.network.pneumatic; + + +import api.hbm.redstoneoverradio.IRORInteractive; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.world.World; + +public class TileEntityPneumoStorageExporter extends TileEntityPneumaticMachineBase implements IRORInteractive { + + /** If requests should be pulled repeatedly every tick */ + public boolean continuousRequest = false; + /** If ROR configuration has taken place, ignore manually defined filters entirely */ + public boolean rorConfiguredMode = false; + /** What strategy to use for handling request filters */ + public int requestMode = 0; + + /** Each slot individually tries to pull as much as it can of the configured item */ + public static final int MODE_AS_MUCH_AS_POSSIBLE = 0; + /** Each slot individually tries to pull the exact quantity configured */ + public static final int MODE_FULL_STACK = 1; + /** All request slots try to pull the desired quantities simultaneously */ + public static final int MODE_FULL_REQUEST = 2; + + public TileEntityPneumoStorageExporter() { + super(18); + } + + @Override + public String getName() { + return "container.pneumoStorageExporter"; + } + + @Override + public void updateEntity() { + super.updateEntity(); + } + + @Override public Container provideContainer(int ID, EntityPlayer player, World world, int x, int y, int z) { return null; } + @Override public Object provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) { return null; } + + @Override + public String[] getFunctionInfo() { + return new String[] { + PREFIX_FUNCTION + "setfilter" + NAME_SEPARATOR + "slot" + PARAM_SEPARATOR + "itemid" + PARAM_SEPARATOR + "itemmeta" + PARAM_SEPARATOR + "amount", + PREFIX_FUNCTION + "setcontinuous" + NAME_SEPARATOR + "slot" + PARAM_SEPARATOR + "itemid" + PARAM_SEPARATOR + "itemmeta" + PARAM_SEPARATOR + "amount", + PREFIX_FUNCTION + "request", + PREFIX_FUNCTION + "requestslot" + NAME_SEPARATOR + "slot", + PREFIX_FUNCTION + "checkavailability" + NAME_SEPARATOR + "itemid" + PARAM_SEPARATOR + "itemmeta" + PARAM_SEPARATOR + "returnchannel", + }; + } + + @Override + public String runRORFunction(String name, String[] params) { + return null; + } +} diff --git a/src/main/java/com/hbm/tileentity/network/pneumatic/TileEntityPneumoStorageImporter.java b/src/main/java/com/hbm/tileentity/network/pneumatic/TileEntityPneumoStorageImporter.java index 131486f71..60e5544d8 100644 --- a/src/main/java/com/hbm/tileentity/network/pneumatic/TileEntityPneumoStorageImporter.java +++ b/src/main/java/com/hbm/tileentity/network/pneumatic/TileEntityPneumoStorageImporter.java @@ -2,24 +2,13 @@ package com.hbm.tileentity.network.pneumatic; import com.hbm.inventory.container.ContainerPneumoStorageImporter; import com.hbm.inventory.gui.GUIPneumoStorageImporter; -import com.hbm.tileentity.IGUIProvider; -import com.hbm.tileentity.TileEntityMachineBase; -import com.hbm.tileentity.network.pneumatic.TileEntityPneumoTube.PneumaticNode; -import com.hbm.uninos.UniNodespace; -import com.hbm.uninos.networkproviders.PneumaticNetworkProvider; -import com.hbm.util.fauxpointtwelve.BlockPos; -import api.hbm.ntl.IPneumaticConnector; -import api.hbm.ntl.StackCache; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; import net.minecraft.item.ItemStack; import net.minecraft.world.World; -public class TileEntityPneumoStorageImporter extends TileEntityMachineBase implements IPneumaticConnector, IGUIProvider { - - protected PneumaticNode node; - public StackCache cache; +public class TileEntityPneumoStorageImporter extends TileEntityPneumaticMachineBase { public int[] delay = new int[9]; public int[] SLOT_ACCESS = new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8}; @@ -45,28 +34,10 @@ public class TileEntityPneumoStorageImporter extends TileEntityMachineBase imple @Override public void updateEntity() { + super.updateEntity(); if(!worldObj.isRemote) { - if(this.node == null || this.node.expired) { - if(this.cache != null) this.cache.dissolveCache(); - - this.node = (PneumaticNode) UniNodespace.getNode(worldObj, xCoord, yCoord, zCoord, PneumaticNetworkProvider.THE_PROVIDER); - - if(this.node == null || this.node.expired) { - this.node = (PneumaticNode) new PneumaticNode(new BlockPos(xCoord, yCoord, zCoord)).setStandardConnections(xCoord, yCoord, zCoord); - UniNodespace.createNode(worldObj, this.node); - } - } - - if(this.cache == null || this.cache.hasExpired) { - this.cache = new StackCache(xCoord, yCoord, zCoord); - } - - if(this.node != null && this.node.hasValidNet()) { - this.node.net.addStackCache(cache); - } - if(this.cache != null && !this.cache.hasExpired) for(int i = 0; i < 9; i++) { if(this.delay[i] > 0) { this.delay[i]--; @@ -85,28 +56,6 @@ public class TileEntityPneumoStorageImporter extends TileEntityMachineBase imple } } - @Override - public void invalidate() { - super.invalidate(); - - if(!worldObj.isRemote && this.node != null) { - UniNodespace.destroyNode(worldObj, xCoord, yCoord, zCoord, PneumaticNetworkProvider.THE_PROVIDER); - } - - if(this.cache != null) this.cache.dissolveCache(); - } - - @Override - public void onChunkUnload() { - super.onChunkUnload(); - - if(!worldObj.isRemote && this.node != null) { - UniNodespace.destroyNode(worldObj, xCoord, yCoord, zCoord, PneumaticNetworkProvider.THE_PROVIDER); - } - - if(this.cache != null) this.cache.dissolveCache(); - } - @Override public Container provideContainer(int ID, EntityPlayer player, World world, int x, int y, int z) { return new ContainerPneumoStorageImporter(player.inventory, this); } @Override public Object provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) { return new GUIPneumoStorageImporter(player.inventory, this); } } diff --git a/src/main/resources/assets/hbm/textures/gui/storage/gui_pneumatic_exporter.png b/src/main/resources/assets/hbm/textures/gui/storage/gui_pneumatic_exporter.png new file mode 100644 index 000000000..cf6e1177c Binary files /dev/null and b/src/main/resources/assets/hbm/textures/gui/storage/gui_pneumatic_exporter.png differ