mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-08-10 17:55:44 +00:00
Merge branch 'HbmMods:master' into rulang121
This commit is contained in:
commit
9fcf5ff3c0
@ -38,4 +38,5 @@
|
||||
* Fixed AUTOCAL's file opening buttons not working on some systems, it will fall back to opening the folder instead
|
||||
* Fixed some recipes not using ore dict when they should
|
||||
* Fixed `anyBismoid` group not being a proper group, causing other mods' bismuth and arsenic to not be included
|
||||
* Fixed RoR gauge not using SI suffixes on values below 0
|
||||
* Fixed RoR gauge not using SI suffixes on values below 0
|
||||
* Fixed AUTOCAL units not closing their GUI when the unit is destroyed
|
||||
@ -12,12 +12,7 @@ import com.hbm.blocks.machine.fusion.*;
|
||||
import com.hbm.blocks.machine.pile.*;
|
||||
import com.hbm.blocks.machine.rbmk.*;
|
||||
import com.hbm.blocks.network.*;
|
||||
import com.hbm.blocks.network.pneumatic.PneumoStorageAccess;
|
||||
import com.hbm.blocks.network.pneumatic.PneumoStorageClutter;
|
||||
import com.hbm.blocks.network.pneumatic.PneumoStorageImporter;
|
||||
import com.hbm.blocks.network.pneumatic.PneumoStorageMono;
|
||||
import com.hbm.blocks.network.pneumatic.PneumoTube;
|
||||
import com.hbm.blocks.network.pneumatic.PneumoTubePaintableBlock;
|
||||
import com.hbm.blocks.network.pneumatic.*;
|
||||
import com.hbm.blocks.rail.*;
|
||||
import com.hbm.blocks.test.*;
|
||||
import com.hbm.blocks.turret.*;
|
||||
@ -810,6 +805,7 @@ public class ModBlocks {
|
||||
public static Block pneumatic_storage_clutter;
|
||||
public static Block pneumatic_storage_mono;
|
||||
public static Block pneumatic_storage_importer;
|
||||
public static Block pneumatic_storage_exporter;
|
||||
|
||||
public static Block fan;
|
||||
public static Block piston_inserter;
|
||||
@ -1915,6 +1911,7 @@ public class ModBlocks {
|
||||
pneumatic_storage_clutter = new PneumoStorageClutter().setBlockName("pneumatic_storage_clutter").setStepSound(ModSoundTypes.pipe).setHardness(5.0F).setResistance(10.0F).setCreativeTab(null).setBlockTextureName(RefStrings.MODID + ":pneumatic_storage_clutter");
|
||||
pneumatic_storage_mono = new PneumoStorageMono().setBlockName("pneumatic_storage_mono").setStepSound(ModSoundTypes.pipe).setHardness(5.0F).setResistance(10.0F).setCreativeTab(null).setBlockTextureName(RefStrings.MODID + ":pneumatic_storage_mono");
|
||||
pneumatic_storage_importer = new PneumoStorageImporter().setBlockName("pneumatic_storage_importer").setStepSound(ModSoundTypes.pipe).setHardness(5.0F).setResistance(10.0F).setCreativeTab(null).setBlockTextureName(RefStrings.MODID + ":pneumatic_storage_importer");
|
||||
pneumatic_storage_exporter = new PneumoStorageExporter().setBlockName("pneumatic_storage_exporter").setStepSound(ModSoundTypes.pipe).setHardness(5.0F).setResistance(10.0F).setCreativeTab(null).setBlockTextureName(RefStrings.MODID + ":pneumatic_storage_exporter");
|
||||
|
||||
chain = new BlockChain(Material.iron).setBlockName("dungeon_chain").setHardness(0.25F).setResistance(2.0F).setCreativeTab(MainRegistry.blockTab).setBlockTextureName(RefStrings.MODID + ":chain");
|
||||
|
||||
@ -3183,6 +3180,7 @@ public class ModBlocks {
|
||||
register(pneumatic_storage_clutter);
|
||||
register(pneumatic_storage_mono);
|
||||
register(pneumatic_storage_importer);
|
||||
register(pneumatic_storage_exporter);
|
||||
register(fan);
|
||||
register(piston_inserter);
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@ public class RadioAUTOCAL extends BlockDummyable {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override public int[] getDimensions() { return new int[] {1, 0, 0, 0, 0 ,0}; }
|
||||
@Override public int[] getDimensions() { return new int[] {1, 0, 0, 0, 0, 0}; }
|
||||
@Override public int getOffset() { return 0; }
|
||||
|
||||
@Override
|
||||
|
||||
@ -0,0 +1,20 @@
|
||||
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;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class PneumoStorageExporter extends BlockMachineBase {
|
||||
|
||||
public PneumoStorageExporter() {
|
||||
super(Material.iron, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int meta) {
|
||||
return new TileEntityPneumoStorageExporter();
|
||||
}
|
||||
}
|
||||
@ -1,33 +1,20 @@
|
||||
package com.hbm.blocks.network.pneumatic;
|
||||
|
||||
import com.hbm.main.MainRegistry;
|
||||
import com.hbm.blocks.machine.BlockMachineBase;
|
||||
import com.hbm.tileentity.network.pneumatic.TileEntityPneumoStorageImporter;
|
||||
|
||||
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class PneumoStorageImporter extends BlockContainer {
|
||||
public class PneumoStorageImporter extends BlockMachineBase {
|
||||
|
||||
public PneumoStorageImporter() {
|
||||
super(Material.iron);
|
||||
super(Material.iron, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int meta) {
|
||||
return new TileEntityPneumoStorageImporter();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
|
||||
if(world.isRemote) return true;
|
||||
if(!player.isSneaking()) {
|
||||
FMLNetworkHandler.openGui(player, MainRegistry.instance, 0, world, x, y, z);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,7 +6,11 @@ import com.hbm.tileentity.network.pneumatic.TileEntityPneumoStorageMono;
|
||||
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@ -30,4 +34,46 @@ public class PneumoStorageMono extends BlockContainer {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean willHarvest) {
|
||||
|
||||
if(!player.capabilities.isCreativeMode && !world.isRemote && willHarvest) {
|
||||
|
||||
TileEntityPneumoStorageMono inv = (TileEntityPneumoStorageMono) world.getTileEntity(x, y, z);
|
||||
ItemStack drop = new ItemStack(this);
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
|
||||
if(inv != null) {
|
||||
for(int i = 0; i < 3; i++) {
|
||||
ItemStack stack = inv.getStackInSlot(i);
|
||||
if(stack == null) continue;
|
||||
NBTTagCompound slot = new NBTTagCompound();
|
||||
stack.writeToNBT(slot);
|
||||
nbt.setTag("slot" + i, slot);
|
||||
nbt.setInteger("amount" + i, inv.amounts[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if(!nbt.hasNoTags()) drop.stackTagCompound = nbt;
|
||||
world.spawnEntityInWorld(new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, drop));
|
||||
}
|
||||
|
||||
return world.setBlockToAir(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) {
|
||||
|
||||
TileEntityPneumoStorageMono inv = (TileEntityPneumoStorageMono) world.getTileEntity(x, y, z);
|
||||
|
||||
if(inv != null && stack.hasTagCompound()) {
|
||||
for(int i = 0; i < 3; i++) {
|
||||
inv.setInventorySlotContents(i, ItemStack.loadItemStackFromNBT(stack.stackTagCompound.getCompoundTag("slot" + i)));
|
||||
inv.amounts[i] = stack.stackTagCompound.getInteger("amount" + i);
|
||||
}
|
||||
}
|
||||
|
||||
super.onBlockPlacedBy(world, x, y, z, player, stack);
|
||||
}
|
||||
}
|
||||
@ -64,6 +64,12 @@ public class GUIScreenRadioAUTOCAL extends GuiScreen {
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float f) {
|
||||
|
||||
if(this.autocal == null || this.autocal.isInvalid()) {
|
||||
Minecraft.getMinecraft().thePlayer.closeScreen();
|
||||
return;
|
||||
}
|
||||
|
||||
this.drawDefaultBackground();
|
||||
this.drawGuiContainerBackgroundLayer(f, mouseX, mouseY);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
|
||||
@ -15,12 +15,59 @@ public interface IParse {
|
||||
public NBTTagCompound variables = new NBTTagCompound();
|
||||
public HashMap<String, Integer> jmp = new HashMap();
|
||||
|
||||
public String buffer = "";
|
||||
public static final int MAX_BUFFER_LENGTH = 256;
|
||||
public static final int MAX_STACK_SIZE = 256;
|
||||
|
||||
private String buffer = "";
|
||||
private String[] stack = new String[MAX_STACK_SIZE];
|
||||
private int stackSize = 0;
|
||||
public String splitString = ";";
|
||||
public int clockSpeed = 1;
|
||||
public int current = 0;
|
||||
|
||||
public ParseContext(World world) {
|
||||
this.world = world;
|
||||
|
||||
for(int i = 0; i < MAX_STACK_SIZE; i++) stack[i] = "";
|
||||
}
|
||||
|
||||
public String readBuffer() {
|
||||
return this.buffer;
|
||||
}
|
||||
|
||||
/** Sets the buffer and imposes length restrictions. Returns true if successful, and false if truncation has taken place. */
|
||||
public boolean writeBuffer(String buffer) {
|
||||
|
||||
if(buffer.length() > MAX_BUFFER_LENGTH) {
|
||||
this.buffer = buffer.substring(0, MAX_BUFFER_LENGTH);
|
||||
return false;
|
||||
}
|
||||
|
||||
this.buffer = buffer;
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean push(String line) {
|
||||
if(stackSize >= MAX_STACK_SIZE) return false;
|
||||
if(line.length() > MAX_BUFFER_LENGTH) line = line.substring(0, MAX_BUFFER_LENGTH);
|
||||
stack[stackSize] = line;
|
||||
stackSize++;
|
||||
return true;
|
||||
}
|
||||
|
||||
public String pop() {
|
||||
if(stackSize <= 0) return null;
|
||||
if(stackSize > MAX_STACK_SIZE) stackSize = MAX_STACK_SIZE;
|
||||
String ret = stack[stackSize - 1];
|
||||
stack[stackSize - 1] = "";
|
||||
stackSize--;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public String peek() {
|
||||
if(stackSize <= 0) return null;
|
||||
if(stackSize > MAX_STACK_SIZE) stackSize = MAX_STACK_SIZE;
|
||||
return stack[stackSize - 1];
|
||||
}
|
||||
|
||||
public void turnOff() {
|
||||
@ -29,6 +76,30 @@ public interface IParse {
|
||||
this.buffer = "";
|
||||
if(!this.variables.hasNoTags()) this.variables = new NBTTagCompound();
|
||||
}
|
||||
|
||||
// NBT R/W is now in control of the CTX, meaning additions to the AUTOCAL runtime should be a lot easier
|
||||
public void readFromNBT(NBTTagCompound nbt, String[] script, IParse parser) {
|
||||
current = nbt.getInteger("current");
|
||||
clockSpeed = nbt.getInteger("clockSpeed");
|
||||
buffer = nbt.getString("buffer");
|
||||
splitString = nbt.getString("splitString");
|
||||
variables = nbt.getCompoundTag("variables");
|
||||
|
||||
stackSize = nbt.getInteger("stackSize");
|
||||
for(int i = 0; i < MAX_STACK_SIZE; i++) stack[i] = nbt.getString("st" + i);
|
||||
for(int i = 0; i < script.length; i++) parser.generateJumpPoints(this, script[i], i);
|
||||
}
|
||||
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
nbt.setInteger("current", current);
|
||||
nbt.setInteger("clockSpeed", clockSpeed);
|
||||
nbt.setString("buffer", buffer);
|
||||
nbt.setString("splitString", splitString);
|
||||
nbt.setTag("variables", variables);
|
||||
|
||||
nbt.setInteger("stackSize", stackSize);
|
||||
for(int i = 0; i < MAX_STACK_SIZE; i++) nbt.setString("st" + i, stack[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public static enum EnumStatementReturn {
|
||||
@ -45,6 +116,8 @@ public interface IParse {
|
||||
/** Skips the instruction, doesn't use up a clock cycle */
|
||||
SKIP,
|
||||
/** General undefined behavior */
|
||||
UNDEFINED
|
||||
UNDEFINED,
|
||||
/** Stack ran full */
|
||||
STACK_EXCEEDED
|
||||
}
|
||||
}
|
||||
|
||||
@ -48,7 +48,7 @@ public class ParseMSES1 implements IParse {
|
||||
// sets the script index to the jump point, if the buffer is the string 'true'
|
||||
if(lower.startsWith("jmpif ")) {
|
||||
if(line.length() <= 6) return EnumStatementReturn.PARAMETER_ERROR;
|
||||
if(!ctx.buffer.equals("true")) return EnumStatementReturn.OK;
|
||||
if(!ctx.readBuffer().equals("true")) return EnumStatementReturn.OK;
|
||||
String jmpKey = substitute(ctx, line.substring(6), false);
|
||||
if(ctx.jmp.containsKey(jmpKey)) {
|
||||
ctx.current = ctx.jmp.get(jmpKey);
|
||||
@ -60,7 +60,7 @@ public class ParseMSES1 implements IParse {
|
||||
// sets the script index to the jump point, if the buffer is the NOT 'true'
|
||||
if(lower.startsWith("jmpnot ")) {
|
||||
if(line.length() <= 7) return EnumStatementReturn.PARAMETER_ERROR;
|
||||
if(ctx.buffer.equals("true")) return EnumStatementReturn.OK;
|
||||
if(ctx.readBuffer().equals("true")) return EnumStatementReturn.OK;
|
||||
String jmpKey = substitute(ctx, line.substring(7), false);
|
||||
if(ctx.jmp.containsKey(jmpKey)) {
|
||||
ctx.current = ctx.jmp.get(jmpKey);
|
||||
@ -82,21 +82,21 @@ public class ParseMSES1 implements IParse {
|
||||
// loads the requested variable into the buffer
|
||||
if(lower.startsWith("load ")) {
|
||||
if(line.length() <= 5) return EnumStatementReturn.PARAMETER_ERROR;
|
||||
ctx.buffer = ctx.variables.getString(line.substring(5));
|
||||
ctx.writeBuffer(ctx.variables.getString(line.substring(5)));
|
||||
return EnumStatementReturn.OK;
|
||||
}
|
||||
|
||||
// saves the buffer with the specified name
|
||||
if(lower.startsWith("save ")) {
|
||||
if(line.length() <= 5 || ctx.buffer.isEmpty()) return EnumStatementReturn.PARAMETER_ERROR;
|
||||
ctx.variables.setString(line.substring(5), ctx.buffer);
|
||||
if(line.length() <= 5 || ctx.readBuffer().isEmpty()) return EnumStatementReturn.PARAMETER_ERROR;
|
||||
ctx.variables.setString(line.substring(5), ctx.readBuffer());
|
||||
return EnumStatementReturn.OK;
|
||||
}
|
||||
|
||||
// stores the specified value in the buffer
|
||||
if(lower.startsWith("buffer ")) {
|
||||
if(line.length() <= 7) return EnumStatementReturn.PARAMETER_ERROR;
|
||||
ctx.buffer = line.substring(7);
|
||||
ctx.writeBuffer(line.substring(7));
|
||||
return EnumStatementReturn.OK;
|
||||
}
|
||||
|
||||
@ -106,7 +106,18 @@ public class ParseMSES1 implements IParse {
|
||||
String statement = substitute(ctx, line.substring(5), true);
|
||||
try {
|
||||
double result = Calculator.evaluateExpression(statement);
|
||||
ctx.buffer = "" + result;
|
||||
ctx.writeBuffer("" + result);
|
||||
} catch(Throwable ex) { return EnumStatementReturn.PARAMETER_ERROR; }
|
||||
return EnumStatementReturn.OK;
|
||||
}
|
||||
|
||||
// runs the calculation from the buffer, allows string substitution, saves result to buffer
|
||||
if(lower.equals("eval")) {
|
||||
if(ctx.readBuffer().isEmpty()) return EnumStatementReturn.PARAMETER_ERROR;
|
||||
String statement = substitute(ctx, ctx.readBuffer(), true);
|
||||
try {
|
||||
double result = Calculator.evaluateExpression(statement);
|
||||
ctx.writeBuffer("" + result);
|
||||
} catch(Throwable ex) { return EnumStatementReturn.PARAMETER_ERROR; }
|
||||
return EnumStatementReturn.OK;
|
||||
}
|
||||
@ -117,115 +128,115 @@ public class ParseMSES1 implements IParse {
|
||||
String statement = substitute(ctx, line.substring(6), true);
|
||||
try {
|
||||
double result = Calculator.evaluateExpression(statement);
|
||||
ctx.buffer = "" + (int) Math.round(result);
|
||||
ctx.writeBuffer("" + (int) Math.round(result));
|
||||
} catch(Throwable ex) { return EnumStatementReturn.PARAMETER_ERROR; }
|
||||
return EnumStatementReturn.OK;
|
||||
}
|
||||
|
||||
// runs the calculation from the buffer, allows string substitution, saves result to buffer
|
||||
// runs the calculation from the buffer, allows string substitution, saves rounded result to buffer
|
||||
if(lower.equals("evalr")) {
|
||||
if(ctx.buffer.isEmpty()) return EnumStatementReturn.PARAMETER_ERROR;
|
||||
String statement = substitute(ctx, ctx.buffer, true);
|
||||
if(ctx.readBuffer().isEmpty()) return EnumStatementReturn.PARAMETER_ERROR;
|
||||
String statement = substitute(ctx, ctx.readBuffer(), true);
|
||||
try {
|
||||
double result = Calculator.evaluateExpression(statement);
|
||||
ctx.buffer = "" + (int) Math.round(result);
|
||||
ctx.writeBuffer("" + (int) Math.round(result));
|
||||
} catch(Throwable ex) { return EnumStatementReturn.PARAMETER_ERROR; }
|
||||
return EnumStatementReturn.OK;
|
||||
}
|
||||
|
||||
// rounds the buffer down to the nearest integer
|
||||
if(lower.equals("rounddown") || lower.equals("floor")) {
|
||||
if(ctx.buffer.isEmpty()) return EnumStatementReturn.PARAMETER_ERROR;
|
||||
if(ctx.readBuffer().isEmpty()) return EnumStatementReturn.PARAMETER_ERROR;
|
||||
try {
|
||||
double d = Double.parseDouble(ctx.buffer);
|
||||
ctx.buffer = "" + (int) Math.floor(d);
|
||||
double d = Double.parseDouble(ctx.readBuffer());
|
||||
ctx.writeBuffer("" + (int) Math.floor(d));
|
||||
} catch(Exception ex) { return EnumStatementReturn.PARAMETER_ERROR; }
|
||||
return EnumStatementReturn.OK;
|
||||
}
|
||||
|
||||
// rounds the buffer up to the nearest integer
|
||||
if(lower.equals("roundup") || lower.equals("ceil")) {
|
||||
if(ctx.buffer.isEmpty()) return EnumStatementReturn.PARAMETER_ERROR;
|
||||
if(ctx.readBuffer().isEmpty()) return EnumStatementReturn.PARAMETER_ERROR;
|
||||
try {
|
||||
double d = Double.parseDouble(ctx.buffer);
|
||||
ctx.buffer = "" + (int) Math.ceil(d);
|
||||
double d = Double.parseDouble(ctx.readBuffer());
|
||||
ctx.writeBuffer("" + (int) Math.ceil(d));
|
||||
} catch(Exception ex) { return EnumStatementReturn.PARAMETER_ERROR; }
|
||||
return EnumStatementReturn.OK;
|
||||
}
|
||||
|
||||
// rounds the buffer to the nearest integer (.5 cutoff rule)
|
||||
if(lower.equals("round") || lower.equals("nearest")) {
|
||||
if(ctx.buffer.isEmpty()) return EnumStatementReturn.PARAMETER_ERROR;
|
||||
if(ctx.readBuffer().isEmpty()) return EnumStatementReturn.PARAMETER_ERROR;
|
||||
try {
|
||||
double d = Double.parseDouble(ctx.buffer);
|
||||
ctx.buffer = "" + (int) Math.round(d);
|
||||
double d = Double.parseDouble(ctx.readBuffer());
|
||||
ctx.writeBuffer("" + (int) Math.round(d));
|
||||
} catch(Exception ex) { return EnumStatementReturn.PARAMETER_ERROR; }
|
||||
return EnumStatementReturn.OK;
|
||||
}
|
||||
|
||||
// concatenate, same as buffer but evaluates $var$ substitutions
|
||||
if(lower.startsWith("concat ")) {
|
||||
if(line.length() <= 7 || ctx.buffer.isEmpty()) return EnumStatementReturn.PARAMETER_ERROR;
|
||||
if(line.length() <= 7 || ctx.readBuffer().isEmpty()) return EnumStatementReturn.PARAMETER_ERROR;
|
||||
String concat = substitute(ctx, line.substring(7), false);
|
||||
ctx.buffer = concat;
|
||||
ctx.writeBuffer(concat);
|
||||
return EnumStatementReturn.OK;
|
||||
}
|
||||
|
||||
// compares the buffer with a value, allows substitutions
|
||||
if(lower.startsWith("eq ")) {
|
||||
if(line.length() <= 3 || ctx.buffer.isEmpty()) return EnumStatementReturn.PARAMETER_ERROR;
|
||||
ctx.buffer = ctx.buffer.equals(substitute(ctx, line.substring(3), false)) ? "true" : "false";
|
||||
if(line.length() <= 3 || ctx.readBuffer().isEmpty()) return EnumStatementReturn.PARAMETER_ERROR;
|
||||
ctx.writeBuffer(ctx.readBuffer().equals(substitute(ctx, line.substring(3), false)) ? "true" : "false");
|
||||
return EnumStatementReturn.OK;
|
||||
}
|
||||
|
||||
// greater than buffer
|
||||
if(lower.startsWith("gtb ")) {
|
||||
if(line.length() <= 4 || ctx.buffer.isEmpty()) return EnumStatementReturn.PARAMETER_ERROR;
|
||||
if(line.length() <= 4 || ctx.readBuffer().isEmpty()) return EnumStatementReturn.PARAMETER_ERROR;
|
||||
try {
|
||||
double buffer = Double.parseDouble(ctx.buffer);
|
||||
double buffer = Double.parseDouble(ctx.readBuffer());
|
||||
double val = Double.parseDouble(substitute(ctx, line.substring(4), false));
|
||||
ctx.buffer = val > buffer ? "true" : "false";
|
||||
ctx.writeBuffer(val > buffer ? "true" : "false");
|
||||
} catch(Exception ex) { return EnumStatementReturn.PARAMETER_ERROR; }
|
||||
return EnumStatementReturn.OK;
|
||||
}
|
||||
|
||||
// lower than buffer
|
||||
if(lower.startsWith("ltb ")) {
|
||||
if(line.length() <= 4 || ctx.buffer.isEmpty()) return EnumStatementReturn.PARAMETER_ERROR;
|
||||
if(line.length() <= 4 || ctx.readBuffer().isEmpty()) return EnumStatementReturn.PARAMETER_ERROR;
|
||||
try {
|
||||
double buffer = Double.parseDouble(ctx.buffer);
|
||||
double buffer = Double.parseDouble(ctx.readBuffer());
|
||||
double val = Double.parseDouble(substitute(ctx, line.substring(4), false));
|
||||
ctx.buffer = val < buffer ? "true" : "false";
|
||||
ctx.writeBuffer(val < buffer ? "true" : "false");
|
||||
} catch(Exception ex) { return EnumStatementReturn.PARAMETER_ERROR; }
|
||||
return EnumStatementReturn.OK;
|
||||
}
|
||||
|
||||
// greater than or equal buffer
|
||||
if(lower.startsWith("geb ")) {
|
||||
if(line.length() <= 4 || ctx.buffer.isEmpty()) return EnumStatementReturn.PARAMETER_ERROR;
|
||||
if(line.length() <= 4 || ctx.readBuffer().isEmpty()) return EnumStatementReturn.PARAMETER_ERROR;
|
||||
try {
|
||||
double buffer = Double.parseDouble(ctx.buffer);
|
||||
double buffer = Double.parseDouble(ctx.readBuffer());
|
||||
double val = Double.parseDouble(substitute(ctx, line.substring(4), false));
|
||||
ctx.buffer = val >= buffer ? "true" : "false";
|
||||
ctx.writeBuffer(val >= buffer ? "true" : "false");
|
||||
} catch(Exception ex) { return EnumStatementReturn.PARAMETER_ERROR; }
|
||||
return EnumStatementReturn.OK;
|
||||
}
|
||||
|
||||
// lower than or equal buffer
|
||||
if(lower.startsWith("leb ")) {
|
||||
if(line.length() <= 4 || ctx.buffer.isEmpty()) return EnumStatementReturn.PARAMETER_ERROR;
|
||||
if(line.length() <= 4 || ctx.readBuffer().isEmpty()) return EnumStatementReturn.PARAMETER_ERROR;
|
||||
try {
|
||||
double buffer = Double.parseDouble(ctx.buffer);
|
||||
double buffer = Double.parseDouble(ctx.readBuffer());
|
||||
double val = Double.parseDouble(substitute(ctx, line.substring(4), false));
|
||||
ctx.buffer = val <= buffer ? "true" : "false";
|
||||
ctx.writeBuffer(val <= buffer ? "true" : "false");
|
||||
} catch(Exception ex) { return EnumStatementReturn.PARAMETER_ERROR; }
|
||||
return EnumStatementReturn.OK;
|
||||
}
|
||||
|
||||
// sends an RoR signal using the buffer's contents as the message over the supplied channel
|
||||
if(lower.startsWith("send ")) {
|
||||
if(line.length() <= 5 || ctx.buffer.isEmpty()) return EnumStatementReturn.PARAMETER_ERROR;
|
||||
RTTYSystem.broadcast(ctx.world, substitute(ctx, line.substring(5), false), ctx.buffer);
|
||||
if(line.length() <= 5 || ctx.readBuffer().isEmpty()) return EnumStatementReturn.PARAMETER_ERROR;
|
||||
RTTYSystem.broadcast(ctx.world, substitute(ctx, line.substring(5), false), ctx.readBuffer());
|
||||
return EnumStatementReturn.OK;
|
||||
}
|
||||
|
||||
@ -233,7 +244,7 @@ public class ParseMSES1 implements IParse {
|
||||
if(lower.startsWith("listen ")) {
|
||||
if(line.length() <= 7) return EnumStatementReturn.PARAMETER_ERROR;
|
||||
RTTYChannel chan = RTTYSystem.listen(ctx.world, substitute(ctx, line.substring(7), false));
|
||||
if(chan != null) ctx.buffer = chan.signal + "";
|
||||
if(chan != null) ctx.writeBuffer(chan.signal + "");
|
||||
return EnumStatementReturn.OK;
|
||||
}
|
||||
|
||||
@ -254,7 +265,7 @@ public class ParseMSES1 implements IParse {
|
||||
readingVar = true;
|
||||
} else {
|
||||
if("buffer".equals(var)) {
|
||||
joined.append(ctx.buffer);
|
||||
joined.append(ctx.readBuffer());
|
||||
} else {
|
||||
String variable = ctx.variables.getString(var.toString());
|
||||
if(forceNumber && variable.isEmpty()) variable = "0";
|
||||
|
||||
125
src/main/java/com/hbm/module/ParseMSES1Ext1.java
Normal file
125
src/main/java/com/hbm/module/ParseMSES1Ext1.java
Normal file
@ -0,0 +1,125 @@
|
||||
package com.hbm.module;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.hbm.tileentity.network.RTTYSystem;
|
||||
import com.hbm.tileentity.network.RTTYSystem.RTTYChannel;
|
||||
|
||||
/**
|
||||
* MSES1-FEIS: Machine Script, Equestrian Standard - First Extended Instruction Set (v1.1)
|
||||
*
|
||||
* 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
|
||||
* * Support for listening only to recent RoR signals using poll
|
||||
*
|
||||
* @author hbm
|
||||
*/
|
||||
public class ParseMSES1Ext1 extends ParseMSES1 {
|
||||
|
||||
@Override
|
||||
public EnumStatementReturn eval(ParseContext ctx, String line) {
|
||||
String lower = line.toLowerCase(Locale.US);
|
||||
|
||||
// sets the splitter char
|
||||
if(lower.startsWith("splitter ")) {
|
||||
if(line.length() <= 9) return EnumStatementReturn.PARAMETER_ERROR;
|
||||
String splitter = substitute(ctx, line.substring(9), false);
|
||||
ctx.splitString = splitter;
|
||||
return EnumStatementReturn.OK;
|
||||
}
|
||||
|
||||
// grabs a fragment based on index
|
||||
if(lower.startsWith("split ")) {
|
||||
if(line.length() <= 6) return EnumStatementReturn.PARAMETER_ERROR;
|
||||
try {
|
||||
int index = Integer.parseInt(line.substring(6));
|
||||
if(index < 1) return EnumStatementReturn.PARAMETER_ERROR;
|
||||
String[] frags = ctx.readBuffer().split(Pattern.quote(ctx.splitString));
|
||||
if(index > frags.length) return EnumStatementReturn.PARAMETER_ERROR;
|
||||
ctx.writeBuffer(frags[index - 1]);
|
||||
return EnumStatementReturn.OK;
|
||||
} catch(Throwable ex) { return EnumStatementReturn.PARAMETER_ERROR; }
|
||||
}
|
||||
|
||||
// counts the amount of fragments in this string
|
||||
if(lower.equals("splitcount")) {
|
||||
if(ctx.readBuffer().isEmpty()) return EnumStatementReturn.PARAMETER_ERROR;
|
||||
String[] frags = ctx.readBuffer().split(Pattern.quote(ctx.splitString));
|
||||
ctx.writeBuffer(frags.length + "");
|
||||
return EnumStatementReturn.OK;
|
||||
}
|
||||
|
||||
// pushes the buffer to stack
|
||||
if(lower.equals("push")) {
|
||||
if(ctx.readBuffer().isEmpty()) return EnumStatementReturn.PARAMETER_ERROR;
|
||||
boolean succ = ctx.push(ctx.readBuffer());
|
||||
return succ ? EnumStatementReturn.OK : EnumStatementReturn.STACK_EXCEEDED;
|
||||
}
|
||||
|
||||
// pushes the supplied value (or variable) to stack
|
||||
if(lower.startsWith("push ")) {
|
||||
if(line.length() <= 5) return EnumStatementReturn.PARAMETER_ERROR;
|
||||
boolean succ = ctx.push(substitute(ctx, line.substring(5), false));
|
||||
return succ ? EnumStatementReturn.OK : EnumStatementReturn.STACK_EXCEEDED;
|
||||
}
|
||||
|
||||
// removes the most recent element from stack and writes it to the buffer
|
||||
if(lower.equals("pop")) {
|
||||
String val = ctx.pop();
|
||||
if(val == null) return EnumStatementReturn.UNDEFINED;
|
||||
ctx.writeBuffer(val);
|
||||
return EnumStatementReturn.OK;
|
||||
}
|
||||
|
||||
// writes the most recent element to the buffer
|
||||
if(lower.equals("peek")) {
|
||||
String val = ctx.peek();
|
||||
if(val == null) return EnumStatementReturn.UNDEFINED;
|
||||
ctx.writeBuffer(val);
|
||||
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; }
|
||||
}
|
||||
|
||||
// listens to an RoR signal using the supplied channel name and saves it to the buffer
|
||||
if(lower.startsWith("poll ")) {
|
||||
if(line.length() <= 5) return EnumStatementReturn.PARAMETER_ERROR;
|
||||
RTTYChannel chan = RTTYSystem.listen(ctx.world, substitute(ctx, line.substring(5), false));
|
||||
if(chan != null && chan.timeStamp >= ctx.world.getTotalWorldTime() - 1) ctx.writeBuffer(chan.signal + "");
|
||||
return EnumStatementReturn.OK;
|
||||
}
|
||||
|
||||
return super.eval(ctx, line);
|
||||
}
|
||||
}
|
||||
@ -5,7 +5,7 @@ import com.hbm.inventory.gui.GUIScreenRadioAUTOCAL;
|
||||
import com.hbm.module.IParse;
|
||||
import com.hbm.module.IParse.EnumStatementReturn;
|
||||
import com.hbm.module.IParse.ParseContext;
|
||||
import com.hbm.module.ParseMSES1;
|
||||
import com.hbm.module.ParseMSES1Ext1;
|
||||
import com.hbm.tileentity.IGUIProvider;
|
||||
import com.hbm.tileentity.TileEntityTickingBase;
|
||||
import com.hbm.util.BufferUtil;
|
||||
@ -27,10 +27,8 @@ public class TileEntityRadioAUTOCAL extends TileEntityTickingBase implements ICo
|
||||
public boolean ignoreError = false;
|
||||
public boolean autoReboot = false;
|
||||
|
||||
public static final int MAX_BUFFER_LENGTH = 256;
|
||||
|
||||
public String[] script = new String[0];
|
||||
public IParse msesv1 = new ParseMSES1();
|
||||
public IParse msesv1ext = new ParseMSES1Ext1();
|
||||
public ParseContext ctx;
|
||||
|
||||
public String[] history = new String[] {"", "", "", "", "", ""};
|
||||
@ -69,16 +67,16 @@ public class TileEntityRadioAUTOCAL extends TileEntityTickingBase implements ICo
|
||||
int index = this.ctx.current;
|
||||
this.ctx.current ++;
|
||||
String line = this.script[index];
|
||||
EnumStatementReturn ret = msesv1.eval(ctx, line);
|
||||
if(ctx.buffer.length() > MAX_BUFFER_LENGTH) ctx.buffer = ctx.buffer.substring(0, MAX_BUFFER_LENGTH);
|
||||
EnumStatementReturn ret = msesv1ext.eval(ctx, line);
|
||||
if(ret != EnumStatementReturn.SKIP) pushMsg(index + ": " + line);
|
||||
this.history[0] = "Buffer: " + ctx.buffer;
|
||||
this.history[0] = "Buffer: " + ctx.readBuffer();
|
||||
if(ret == EnumStatementReturn.END_TICK) break;
|
||||
if(ret == EnumStatementReturn.SHUTDOWN) this.stop("Program requested shutdown");
|
||||
if(!this.ignoreError) {
|
||||
if(ret == EnumStatementReturn.UNRECOGNIZED_COMMAND) this.stop("Unrecognized command");
|
||||
if(ret == EnumStatementReturn.PARAMETER_ERROR) this.stop("Parameter error");
|
||||
if(ret == EnumStatementReturn.UNDEFINED) this.stop("Undefined behavior");
|
||||
if(ret == EnumStatementReturn.STACK_EXCEEDED) this.stop("Stack exceeded capacity");
|
||||
}
|
||||
if(ret == EnumStatementReturn.SKIP) i--;
|
||||
} catch(Exception ex) {
|
||||
@ -132,19 +130,14 @@ public class TileEntityRadioAUTOCAL extends TileEntityTickingBase implements ICo
|
||||
this.ignoreError = nbt.getBoolean("ignoreError");
|
||||
this.autoReboot = nbt.getBoolean("autoReboot");
|
||||
|
||||
this.ctx = new ParseContext(null);
|
||||
this.ctx.current = nbt.getInteger("current");
|
||||
this.ctx.clockSpeed = nbt.getInteger("clockSpeed");
|
||||
this.ctx.buffer = nbt.getString("buffer");
|
||||
|
||||
NBTTagList lineList = nbt.getTagList("script", 8);
|
||||
this.script = new String[lineList.tagList.size()];
|
||||
for(int i = 0; i < script.length; i++) {
|
||||
this.script[i] = lineList.getStringTagAt(i);
|
||||
this.msesv1.generateJumpPoints(ctx, script[i], i);
|
||||
}
|
||||
|
||||
this.ctx.variables = nbt.getCompoundTag("variables");
|
||||
|
||||
this.ctx = new ParseContext(null);
|
||||
this.ctx.readFromNBT(nbt, script, msesv1ext);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -154,17 +147,14 @@ public class TileEntityRadioAUTOCAL extends TileEntityTickingBase implements ICo
|
||||
nbt.setBoolean("isOn", isOn);
|
||||
nbt.setBoolean("ignoreError", ignoreError);
|
||||
nbt.setBoolean("autoReboot", autoReboot);
|
||||
|
||||
nbt.setInteger("current", ctx.current);
|
||||
nbt.setInteger("clockSpeed", ctx.clockSpeed);
|
||||
nbt.setString("buffer", ctx.buffer);
|
||||
|
||||
NBTTagList lineList = new NBTTagList();
|
||||
for(String line : this.script) {
|
||||
lineList.appendTag(new NBTTagString(line));
|
||||
}
|
||||
nbt.setTag("script", lineList);
|
||||
nbt.setTag("variables", this.ctx.variables);
|
||||
|
||||
this.ctx.writeToNBT(nbt);
|
||||
}
|
||||
|
||||
@Override public Container provideContainer(int ID, EntityPlayer player, World world, int x, int y, int z) { return null; }
|
||||
@ -189,7 +179,7 @@ public class TileEntityRadioAUTOCAL extends TileEntityTickingBase implements ICo
|
||||
this.script = data.getString("payload").split("\n");
|
||||
for(int i = 0; i < script.length; i++) {
|
||||
script[i] = script[i].trim();
|
||||
this.msesv1.generateJumpPoints(ctx, script[i], i);
|
||||
this.msesv1ext.generateJumpPoints(ctx, script[i], i);
|
||||
}
|
||||
if(this.isOn) stop("Script has changed");
|
||||
}
|
||||
|
||||
@ -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.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); }
|
||||
}
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 2.1 KiB |
Loading…
x
Reference in New Issue
Block a user