Merge pull request #3026 from legendarydoge30/gdfgdf

Added a lot of RoR support to the battery socket and PA, added extra ports to PA, updated calculator
This commit is contained in:
HbmMods 2026-07-23 13:12:47 +02:00 committed by GitHub
commit 7741714ce0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 142 additions and 31 deletions

View File

@ -9,6 +9,7 @@ import com.hbm.main.MainRegistry;
import com.hbm.tileentity.TileEntityProxyCombo;
import com.hbm.tileentity.machine.albion.TileEntityPASource;
import com.hbm.util.fauxpointtwelve.DirPos;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
@ -45,7 +46,6 @@ public class BlockPASource extends BlockDummyable implements ITooltipProvider {
super.fillSpace(world, x, y, z, dir, o);
ForgeDirection rot = dir.getRotation(ForgeDirection.UP);
this.makeExtra(world, x + rot.offsetX * 4, y, z + rot.offsetZ * 4);
this.makeExtra(world, x + dir.offsetX, y, z + dir.offsetZ);
this.makeExtra(world, x + dir.offsetX + rot.offsetX * 2, y, z + dir.offsetZ + rot.offsetZ * 2);
@ -53,6 +53,9 @@ public class BlockPASource extends BlockDummyable implements ITooltipProvider {
this.makeExtra(world, x - dir.offsetX, y, z - dir.offsetZ);
this.makeExtra(world, x - dir.offsetX + rot.offsetX * 2, y, z - dir.offsetZ + rot.offsetZ * 2);
this.makeExtra(world, x - dir.offsetX - rot.offsetX * 2, y, z - dir.offsetZ - rot.offsetZ * 2);
this.makeExtra(world, x,y - 1, z);
this.makeExtra(world, x + rot.offsetX * 2, y - 1, z + rot.offsetZ * 2);
this.makeExtra(world, x - rot.offsetX * 2, y - 1, z - rot.offsetZ * 2);
}
@Override

View File

@ -48,7 +48,7 @@ public class GUICalculator extends GuiScreen {
if (!inputField.textboxKeyTyped(p_73869_1_, p_73869_2_))
super.keyTyped(p_73869_1_, p_73869_2_);
String input = inputField.getText().replaceAll("[^\\d+\\-*/^!.()\\sA-Za-z]+", "");
String input = inputField.getText().replaceAll("[^\\d+\\-*/%^!.()\\sA-Za-z]+", "");
if (p_73869_1_ == 13 || p_73869_1_ == 10) { // when pressing enter (CR or LF)
if (selectedHist != -1) {

View File

@ -16,6 +16,7 @@ import com.hbm.tileentity.machine.albion.TileEntityPASource.Particle;
import com.hbm.util.fauxpointtwelve.BlockPos;
import com.hbm.util.fauxpointtwelve.DirPos;
import api.hbm.redstoneoverradio.IRORValueProvider;
import cpw.mods.fml.common.Optional;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@ -31,7 +32,7 @@ import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
@Optional.InterfaceList({@Optional.Interface(iface = "li.cil.oc.api.network.SimpleComponent", modid = "OpenComputers")})
public class TileEntityPADetector extends TileEntityCooledBase implements IGUIProvider, IParticleUser, SimpleComponent, CompatHandler.OCComponent {
public class TileEntityPADetector extends TileEntityCooledBase implements IGUIProvider, IParticleUser, SimpleComponent, CompatHandler.OCComponent, IRORValueProvider {
public static final long usage = 100_000;
@ -186,6 +187,22 @@ public class TileEntityPADetector extends TileEntityCooledBase implements IGUIPr
return true;
}
@Override
public String[] getFunctionInfo() {
return new String[] {
PREFIX_VALUE + "temperature",
PREFIX_VALUE + "pfmcold",
PREFIX_VALUE + "pfm"
};
}
@Override
public String provideRORValue(String name) {
if((PREFIX_VALUE + "temperature").equals(name)) return "" + (int) this.temperature;
if((PREFIX_VALUE + "pfmcold").equals(name)) return "" + coolantTanks[0].getFill();
if((PREFIX_VALUE + "pfm").equals(name)) return "" + coolantTanks[1].getFill();
return null;
}
@Override
public BlockPos getExitPos(Particle particle) {
return null;

View File

@ -16,6 +16,7 @@ import com.hbm.util.EnumUtil;
import com.hbm.util.fauxpointtwelve.BlockPos;
import com.hbm.util.fauxpointtwelve.DirPos;
import api.hbm.redstoneoverradio.IRORValueProvider;
import api.hbm.redstoneoverradio.IRORInteractive;
import cpw.mods.fml.common.Optional;
import cpw.mods.fml.relauncher.Side;
@ -35,7 +36,7 @@ import net.minecraftforge.common.util.ForgeDirection;
@SuppressWarnings("unused")
@Optional.InterfaceList({@Optional.Interface(iface = "li.cil.oc.api.network.SimpleComponent", modid = "OpenComputers")})
public class TileEntityPADipole extends TileEntityCooledBase implements IGUIProvider, IControlReceiver, IParticleUser, OCComponent, SimpleComponent, IRORInteractive {
public class TileEntityPADipole extends TileEntityCooledBase implements IGUIProvider, IControlReceiver, IParticleUser, OCComponent, SimpleComponent, IRORInteractive, IRORValueProvider {
public int dirLower;
public int dirUpper;
@ -391,10 +392,21 @@ public class TileEntityPADipole extends TileEntityCooledBase implements IGUIProv
@Override
public String[] getFunctionInfo() {
return new String[] {
PREFIX_FUNCTION + "setthreshold" + NAME_SEPARATOR + "threshold",
PREFIX_VALUE + "temperature",
PREFIX_VALUE + "pfmcold",
PREFIX_VALUE + "pfm",
PREFIX_FUNCTION + "setthreshold" + NAME_SEPARATOR + "threshold"
};
}
@Override
public String provideRORValue(String name) {
if((PREFIX_VALUE + "temperature").equals(name)) return "" + (int) this.temperature;
if((PREFIX_VALUE + "pfmcold").equals(name)) return "" + coolantTanks[0].getFill();
if((PREFIX_VALUE + "pfm").equals(name)) return "" + coolantTanks[1].getFill();
return null;
}
@Override
public String runRORFunction(String name, String[] params) {

View File

@ -13,6 +13,7 @@ import com.hbm.util.EnumUtil;
import com.hbm.util.fauxpointtwelve.BlockPos;
import com.hbm.util.fauxpointtwelve.DirPos;
import api.hbm.redstoneoverradio.IRORValueProvider;
import cpw.mods.fml.common.Optional;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@ -27,7 +28,7 @@ import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
@Optional.InterfaceList({@Optional.Interface(iface = "li.cil.oc.api.network.SimpleComponent", modid = "OpenComputers")})
public class TileEntityPAQuadrupole extends TileEntityCooledBase implements IGUIProvider, IParticleUser, SimpleComponent, CompatHandler.OCComponent {
public class TileEntityPAQuadrupole extends TileEntityCooledBase implements IGUIProvider, IParticleUser, SimpleComponent, CompatHandler.OCComponent, IRORValueProvider {
public static final long usage = 100_000;
public static final int focusGain = 100;
@ -137,6 +138,22 @@ public class TileEntityPAQuadrupole extends TileEntityCooledBase implements IGUI
return new GUIPAQuadrupole(player.inventory, this);
}
@Override
public String[] getFunctionInfo() {
return new String[] {
PREFIX_VALUE + "temperature",
PREFIX_VALUE + "pfmcold",
PREFIX_VALUE + "pfm"
};
}
@Override
public String provideRORValue(String name) {
if((PREFIX_VALUE + "temperature").equals(name)) return "" + (int) this.temperature;
if((PREFIX_VALUE + "pfmcold").equals(name)) return "" + coolantTanks[0].getFill();
if((PREFIX_VALUE + "pfm").equals(name)) return "" + coolantTanks[1].getFill();
return null;
}
@Override
@Optional.Method(modid = "OpenComputers")
public String getComponentName() {

View File

@ -10,6 +10,7 @@ import com.hbm.tileentity.machine.albion.TileEntityPASource.Particle;
import com.hbm.util.fauxpointtwelve.BlockPos;
import com.hbm.util.fauxpointtwelve.DirPos;
import api.hbm.redstoneoverradio.IRORValueProvider;
import cpw.mods.fml.common.Optional;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@ -24,7 +25,7 @@ import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
@Optional.InterfaceList({@Optional.Interface(iface = "li.cil.oc.api.network.SimpleComponent", modid = "OpenComputers")})
public class TileEntityPARFC extends TileEntityCooledBase implements IGUIProvider, IParticleUser, SimpleComponent, CompatHandler.OCComponent {
public class TileEntityPARFC extends TileEntityCooledBase implements IGUIProvider, IParticleUser, SimpleComponent, CompatHandler.OCComponent, IRORValueProvider {
public static final long usage = 250_000;
public static final int momentumGain = 100;
@ -129,6 +130,22 @@ public class TileEntityPARFC extends TileEntityCooledBase implements IGUIProvide
return new GUIPARFC(player.inventory, this);
}
@Override
public String[] getFunctionInfo() {
return new String[] {
PREFIX_VALUE + "temperature",
PREFIX_VALUE + "pfmcold",
PREFIX_VALUE + "pfm"
};
}
@Override
public String provideRORValue(String name) {
if((PREFIX_VALUE + "temperature").equals(name)) return "" + (int) this.temperature;
if((PREFIX_VALUE + "pfmcold").equals(name)) return "" + coolantTanks[0].getFill();
if((PREFIX_VALUE + "pfm").equals(name)) return "" + coolantTanks[1].getFill();
return null;
}
@Override
@Optional.Method(modid = "OpenComputers")
public String getComponentName() {

View File

@ -1,5 +1,6 @@
package com.hbm.tileentity.machine.albion;
import api.hbm.redstoneoverradio.IRORInteractive;
import com.hbm.blocks.BlockDummyable;
import com.hbm.handler.CompatHandler;
import com.hbm.interfaces.IControlReceiver;
@ -12,6 +13,8 @@ import com.hbm.util.EnumUtil;
import com.hbm.util.fauxpointtwelve.BlockPos;
import com.hbm.util.fauxpointtwelve.DirPos;
import api.hbm.redstoneoverradio.IRORValueProvider;
import api.hbm.redstoneoverradio.IRORInteractive;
import cpw.mods.fml.common.Optional;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@ -32,7 +35,7 @@ import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
@Optional.InterfaceList({@Optional.Interface(iface = "li.cil.oc.api.network.SimpleComponent", modid = "OpenComputers")})
public class TileEntityPASource extends TileEntityCooledBase implements IGUIProvider, IConditionalInvAccess, IControlReceiver, SimpleComponent, CompatHandler.OCComponent {
public class TileEntityPASource extends TileEntityCooledBase implements IGUIProvider, IConditionalInvAccess, IControlReceiver, SimpleComponent, CompatHandler.OCComponent, IRORValueProvider, IRORInteractive {
public static final long usage = 100_000;
public Particle particle;
@ -164,6 +167,9 @@ public class TileEntityPASource extends TileEntityCooledBase implements IGUIProv
new DirPos(xCoord - dir.offsetX * 2 + rot.offsetX * 2, yCoord, zCoord - dir.offsetZ * 2 + rot.offsetZ * 2, dir.getOpposite()),
new DirPos(xCoord - dir.offsetX * 2 - rot.offsetX * 2, yCoord, zCoord - dir.offsetZ * 2 - rot.offsetZ * 2, dir.getOpposite()),
new DirPos(xCoord + rot.offsetX * 5, yCoord, zCoord + rot.offsetZ * 5, rot),
new DirPos(xCoord, yCoord-2, zCoord, dir),
new DirPos(xCoord + rot.offsetX * 2, yCoord-2, zCoord + rot.offsetZ * 2, dir),
new DirPos(xCoord - rot.offsetX * 2, yCoord-2, zCoord - rot.offsetZ * 2, dir),
};
}
@ -448,4 +454,40 @@ public class TileEntityPASource extends TileEntityCooledBase implements IGUIProv
if(this.defocus < 0) this.defocus = 0;
}
}
@Override
public String[] getFunctionInfo() {
return new String[] {
PREFIX_VALUE + "status",
PREFIX_VALUE + "momentum",
PREFIX_VALUE + "defocus",
PREFIX_VALUE + "temperature",
PREFIX_VALUE + "pfmcold",
PREFIX_VALUE + "pfm",
PREFIX_FUNCTION + "cancel"
};
}
@Override
public String provideRORValue(String name) {
if((PREFIX_VALUE + "status").equals(name)) return "" + this.state;
if((PREFIX_VALUE + "momentum").equals(name)) return "" + this.lastSpeed;
if((PREFIX_VALUE + "defocus").equals(name)) {
return this.particle != null ? "" + this.particle.defocus : "0";
}
if((PREFIX_VALUE + "temperature").equals(name)) return "" + (int) this.temperature;
if((PREFIX_VALUE + "pfmcold").equals(name)) return "" + coolantTanks[0].getFill();
if((PREFIX_VALUE + "pfm").equals(name)) return "" + coolantTanks[1].getFill();
return null;
}
@Override
public String runRORFunction(String name, String[] params) {
if ((PREFIX_FUNCTION + "cancel").equals(name)) {
particle = null;
state = PAState.IDLE;
return null;
}
return null;
}
}

View File

@ -319,6 +319,7 @@ public class TileEntityBatterySocket extends TileEntityBatteryBase implements IR
public String[] getFunctionInfo() {
return new String[] {
PREFIX_VALUE + "fill",
PREFIX_VALUE + "maxfill",
PREFIX_VALUE + "fillpercent",
PREFIX_VALUE + "delta",
PREFIX_FUNCTION + "setmode" + NAME_SEPARATOR + "mode (0-3)",
@ -332,6 +333,7 @@ public class TileEntityBatterySocket extends TileEntityBatteryBase implements IR
@Override
public String provideRORValue(String name) {
if((PREFIX_VALUE + "fill").equals(name)) return "" + this.getPower();
if((PREFIX_VALUE + "maxfill").equals(name)) return "" + this.getMaxPower();
if((PREFIX_VALUE + "fillpercent").equals(name)) return "" + this.getPower() * 100 / (Math.max(this.getMaxPower(), 1));
if((PREFIX_VALUE + "delta").equals(name)) return "" + delta;
return null;

View File

@ -21,7 +21,7 @@ public class Calculator {
for (int i = 0; i < tokens.length; i++) {
if (tokens[i] == ' ') continue;
if (tokens[i] >= '0' && tokens[i] <= '9' || tokens[i] == '.' || (tokens[i] == '-' && (i == 0 || "+-*/^(".contains(String.valueOf(tokens[i - 1]))))) {
if (tokens[i] >= '0' && tokens[i] <= '9' || tokens[i] == '.' || (tokens[i] == '-' && (i == 0 || "+-*/%^(".contains(String.valueOf(tokens[i - 1]))))) {
StringBuilder buffer = new StringBuilder();
if (tokens[i] == '-') {
buffer.append('-'); // for negative numbers
@ -37,7 +37,7 @@ public class Calculator {
operators.pop();
if (!operators.isEmpty() && operators.peek().length() > 1)
values.push(evaluateFunction(operators.pop(), values.pop()));
} else if (tokens[i] == '+' || tokens[i] == '-' || tokens[i] == '*' || tokens[i] == '/' || tokens[i] == '^') {
} else if (tokens[i] == '+' || tokens[i] == '-' || tokens[i] == '*' || tokens[i] == '/' || tokens[i] == '%' || tokens[i] == '^') {
while (!operators.isEmpty() && hasPrecedence(String.valueOf(tokens[i]), operators.peek()))
values.push(evaluateOperator(operators.pop().charAt(0), values.pop(), values.pop()));
operators.push(Character.toString(tokens[i]));
@ -67,6 +67,7 @@ public class Calculator {
case '-': return y - x;
case '*': return y * x;
case '/': return y / x;
case '%': return y % x;
case '^': return Math.pow(y, x); // should not happen here, but oh well
}
@ -102,7 +103,7 @@ public class Calculator {
char secondChar = second.charAt(0);
if (secondChar == '(' || secondChar == ')') return false;
else return (firstChar != '*' && firstChar != '/' && firstChar != '^') || (secondChar != '+' && secondChar != '-');
else return (firstChar != '*' && firstChar != '/' && firstChar != '%' && firstChar != '^') || (secondChar != '+' && secondChar != '-');
}
/** Returns the input with all powers evaluated */

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.0 KiB

After

Width:  |  Height:  |  Size: 10 KiB