From 85a15f1bbd29ba02109343bfa1acdb25e4f52384 Mon Sep 17 00:00:00 2001 From: Boblet Date: Thu, 25 Jun 2026 13:37:37 +0200 Subject: [PATCH] MS-ES v1.1 substring and count, pneumo storage exporter --- .../pneumatic/PneumoStorageExporter.java | 3 +- .../java/com/hbm/module/ParseMSES1Ext1.java | 31 ++++++++ .../TileEntityPneumaticMachineBase.java | 69 ++++++++++++++++++ .../TileEntityPneumoStorageExporter.java | 57 +++++++++++++++ .../TileEntityPneumoStorageImporter.java | 55 +------------- .../gui/storage/gui_pneumatic_exporter.png | Bin 0 -> 2154 bytes 6 files changed, 161 insertions(+), 54 deletions(-) create mode 100644 src/main/java/com/hbm/tileentity/network/pneumatic/TileEntityPneumaticMachineBase.java create mode 100644 src/main/java/com/hbm/tileentity/network/pneumatic/TileEntityPneumoStorageExporter.java create mode 100644 src/main/resources/assets/hbm/textures/gui/storage/gui_pneumatic_exporter.png 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 0000000000000000000000000000000000000000..cf6e1177c0b65a22254e7c588b21439848ce1e2a GIT binary patch literal 2154 zcmb_cc~sL$67GbML?lAg5k(@dxZoh_Du)mxL>3Gv1duC$4jAwN29PU3NhF9YFo-bE z5k$pg#m6n8ETCKg*D)f|h~WxXP*xy>a0mt>IrcYuyxsTa_-D7?>#llTT~%NASKZlO zWD-WlPzL~jadUM(4gd@?VE~PU)QR}=Gmt_gIJx35Q&p}PGVUMIWV|Ognd;Y~@5k@F^J;fB z=UK&#y&gez0XM&r*8AHxFTRO9b60@68XckJyY{UX(?>-YX!=z})lVF%BWqv15ZraB zQd!z<%L}tL>f5tne8E;Om;2+@L-J0YA@ZoYX=osg==_{Vr<*>aqObDCgH{g_2-n`9 zr`#v^GkoLh)7iPU8g&)g@^xVW?ATt5gbCzD$Y(?yhkcw3l?3 zzY`@}8IDjUo1*E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