mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-08-10 17:55:44 +00:00
MS-ES v1.1 substring and count, pneumo storage exporter
This commit is contained in:
parent
5cee3ed8fa
commit
85a15f1bbd
@ -1,6 +1,7 @@
|
|||||||
package com.hbm.blocks.network.pneumatic;
|
package com.hbm.blocks.network.pneumatic;
|
||||||
|
|
||||||
import com.hbm.blocks.machine.BlockMachineBase;
|
import com.hbm.blocks.machine.BlockMachineBase;
|
||||||
|
import com.hbm.tileentity.network.pneumatic.TileEntityPneumoStorageExporter;
|
||||||
|
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
@ -14,6 +15,6 @@ public class PneumoStorageExporter extends BlockMachineBase {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TileEntity createNewTileEntity(World world, int meta) {
|
public TileEntity createNewTileEntity(World world, int meta) {
|
||||||
return null;
|
return new TileEntityPneumoStorageExporter();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,6 +9,7 @@ import java.util.regex.Pattern;
|
|||||||
* Additions compared to v1 Standard:
|
* Additions compared to v1 Standard:
|
||||||
* * Support for splitter chars, splitting and split count
|
* * Support for splitter chars, splitting and split count
|
||||||
* * Support for the stack, a secondary buffer that can push, pop and peek
|
* * 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
|
* @author hbm
|
||||||
*/
|
*/
|
||||||
@ -77,6 +78,36 @@ public class ParseMSES1Ext1 extends ParseMSES1 {
|
|||||||
return EnumStatementReturn.OK;
|
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);
|
return super.eval(ctx, line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -2,24 +2,13 @@ package com.hbm.tileentity.network.pneumatic;
|
|||||||
|
|
||||||
import com.hbm.inventory.container.ContainerPneumoStorageImporter;
|
import com.hbm.inventory.container.ContainerPneumoStorageImporter;
|
||||||
import com.hbm.inventory.gui.GUIPneumoStorageImporter;
|
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.entity.player.EntityPlayer;
|
||||||
import net.minecraft.inventory.Container;
|
import net.minecraft.inventory.Container;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
public class TileEntityPneumoStorageImporter extends TileEntityMachineBase implements IPneumaticConnector, IGUIProvider {
|
public class TileEntityPneumoStorageImporter extends TileEntityPneumaticMachineBase {
|
||||||
|
|
||||||
protected PneumaticNode node;
|
|
||||||
public StackCache cache;
|
|
||||||
|
|
||||||
public int[] delay = new int[9];
|
public int[] delay = new int[9];
|
||||||
public int[] SLOT_ACCESS = new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8};
|
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
|
@Override
|
||||||
public void updateEntity() {
|
public void updateEntity() {
|
||||||
|
super.updateEntity();
|
||||||
|
|
||||||
if(!worldObj.isRemote) {
|
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.cache != null && !this.cache.hasExpired) for(int i = 0; i < 9; i++) {
|
||||||
if(this.delay[i] > 0) {
|
if(this.delay[i] > 0) {
|
||||||
this.delay[i]--;
|
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 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); }
|
@Override public Object provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) { return new GUIPneumoStorageImporter(player.inventory, this); }
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 2.1 KiB |
Loading…
x
Reference in New Issue
Block a user