mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-02-24 06:50:46 +00:00
Force PWR to use doubles as control rod values, round to 100s place when displaying to prevent floating-point errors looking terrible.
also add cable gauge and radar compat telex is next
This commit is contained in:
parent
f1ed151f6b
commit
bc45b66052
@ -14,8 +14,13 @@ import com.hbm.util.BobMathUtil;
|
|||||||
import com.hbm.util.I18nUtil;
|
import com.hbm.util.I18nUtil;
|
||||||
|
|
||||||
import api.hbm.energymk2.PowerNetMK2;
|
import api.hbm.energymk2.PowerNetMK2;
|
||||||
|
import cpw.mods.fml.common.Optional;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
import li.cil.oc.api.machine.Arguments;
|
||||||
|
import li.cil.oc.api.machine.Callback;
|
||||||
|
import li.cil.oc.api.machine.Context;
|
||||||
|
import li.cil.oc.api.network.SimpleComponent;
|
||||||
import net.minecraft.block.BlockContainer;
|
import net.minecraft.block.BlockContainer;
|
||||||
import net.minecraft.block.BlockPistonBase;
|
import net.minecraft.block.BlockPistonBase;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
@ -98,7 +103,8 @@ public class BlockCableGauge extends BlockContainer implements IBlockMultiPass,
|
|||||||
return IBlockMultiPass.getRenderType();
|
return IBlockMultiPass.getRenderType();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class TileEntityCableGauge extends TileEntityCableBaseNT implements INBTPacketReceiver {
|
@Optional.InterfaceList({@Optional.Interface(iface = "li.cil.oc.api.network.SimpleComponent", modid = "OpenComputers")})
|
||||||
|
public static class TileEntityCableGauge extends TileEntityCableBaseNT implements INBTPacketReceiver, SimpleComponent {
|
||||||
|
|
||||||
private long deltaTick = 0;
|
private long deltaTick = 0;
|
||||||
private long deltaSecond = 0;
|
private long deltaSecond = 0;
|
||||||
@ -134,5 +140,22 @@ public class BlockCableGauge extends BlockContainer implements IBlockMultiPass,
|
|||||||
this.deltaTick = Math.max(nbt.getLong("deltaT"), 0);
|
this.deltaTick = Math.max(nbt.getLong("deltaT"), 0);
|
||||||
this.deltaLastSecond = Math.max(nbt.getLong("deltaS"), 0);
|
this.deltaLastSecond = Math.max(nbt.getLong("deltaS"), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getComponentName() {
|
||||||
|
return "ntm_power_gauge";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Callback(direct = true)
|
||||||
|
@Optional.Method(modid = "OpenComputers")
|
||||||
|
public Object[] getTransfer(Context context, Arguments args) {
|
||||||
|
return new Object[] {deltaTick, deltaSecond};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Callback(direct = true)
|
||||||
|
@Optional.Method(modid = "OpenComputers")
|
||||||
|
public Object[] getInfo(Context context, Arguments args) {
|
||||||
|
return new Object[] {deltaTick, deltaSecond, xCoord, yCoord, zCoord};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -65,7 +65,7 @@ public class GUIPWR extends GuiInfoContainer {
|
|||||||
this.drawCustomInfoStat(x, y, guiLeft + 151, guiTop + 31, 18, 18, x, y, new String[] { "Hull: " + String.format(Locale.US, "%,d", controller.hullHeat) + " / " + String.format(Locale.US, "%,d", controller.hullHeatCapacityBase) + " TU" });
|
this.drawCustomInfoStat(x, y, guiLeft + 151, guiTop + 31, 18, 18, x, y, new String[] { "Hull: " + String.format(Locale.US, "%,d", controller.hullHeat) + " / " + String.format(Locale.US, "%,d", controller.hullHeatCapacityBase) + " TU" });
|
||||||
|
|
||||||
this.drawCustomInfoStat(x, y, guiLeft + 52, guiTop + 31, 36, 18, x, y, new String[] { ((int) (controller.progress * 100 / controller.processTime)) + "%" });
|
this.drawCustomInfoStat(x, y, guiLeft + 52, guiTop + 31, 36, 18, x, y, new String[] { ((int) (controller.progress * 100 / controller.processTime)) + "%" });
|
||||||
this.drawCustomInfoStat(x, y, guiLeft + 52, guiTop + 53, 54, 4, x, y, "Control rod level: " + (100 - controller.rodLevel) + "%");
|
this.drawCustomInfoStat(x, y, guiLeft + 52, guiTop + 53, 54, 4, x, y, "Control rod level: " + (100 - (Math.round(controller.rodLevel * 100)/100)) + "%");
|
||||||
|
|
||||||
if(controller.typeLoaded != -1 && controller.amountLoaded > 0) {
|
if(controller.typeLoaded != -1 && controller.amountLoaded > 0) {
|
||||||
ItemStack display = new ItemStack(ModItems.pwr_fuel, 1, controller.typeLoaded);
|
ItemStack display = new ItemStack(ModItems.pwr_fuel, 1, controller.typeLoaded);
|
||||||
|
|||||||
@ -43,6 +43,9 @@ import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
|
|||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import li.cil.oc.api.machine.Arguments;
|
||||||
|
import li.cil.oc.api.machine.Callback;
|
||||||
|
import li.cil.oc.api.machine.Context;
|
||||||
import li.cil.oc.api.network.SimpleComponent;
|
import li.cil.oc.api.network.SimpleComponent;
|
||||||
import net.minecraft.client.gui.GuiScreen;
|
import net.minecraft.client.gui.GuiScreen;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
@ -603,5 +606,72 @@ public class TileEntityMachineRadarNT extends TileEntityMachineBase implements I
|
|||||||
return "ntm_radar";
|
return "ntm_radar";
|
||||||
}
|
}
|
||||||
|
|
||||||
//soon :tm:
|
@Callback(direct = true)
|
||||||
|
@Optional.Method(modid = "OpenComputers")
|
||||||
|
public Object[] getSettings(Context context, Arguments args) {
|
||||||
|
return new Object[] {scanMissiles, scanShells, scanPlayers, smartMode};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Callback(direct = true)
|
||||||
|
@Optional.Method(modid = "OpenComputers")
|
||||||
|
public Object[] getRange(Context context, Arguments args) {
|
||||||
|
return new Object[] {this.getRange()};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Callback(direct = true, limit = 4)
|
||||||
|
@Optional.Method(modid = "OpenComputers")
|
||||||
|
public Object[] setSettings(Context context, Arguments args) {
|
||||||
|
this.scanMissiles = args.checkBoolean(0);
|
||||||
|
this.scanShells = args.checkBoolean(1);
|
||||||
|
this.scanPlayers = args.checkBoolean(2);
|
||||||
|
this.smartMode = args.checkBoolean(3);
|
||||||
|
return new Object[] {};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Callback(direct = true)
|
||||||
|
@Optional.Method(modid = "OpenComputers")
|
||||||
|
public Object[] getEnergyInfo(Context context, Arguments args) {
|
||||||
|
return new Object[] {getPower(), getMaxPower()};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Callback(direct = true)
|
||||||
|
@Optional.Method(modid = "OpenComputers")
|
||||||
|
public Object[] isJammed(Context context, Arguments args) {
|
||||||
|
return new Object[] {this.jammed};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Callback(direct = true)
|
||||||
|
@Optional.Method(modid = "OpenComputers")
|
||||||
|
public Object[] getAmount(Context context, Arguments args) {
|
||||||
|
return new Object[] {entries.size()};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Callback(direct = true)
|
||||||
|
@Optional.Method(modid = "OpenComputers")
|
||||||
|
public Object[] isIndexPlayer(Context context, Arguments args) {
|
||||||
|
int index = args.checkInteger(0);
|
||||||
|
RadarEntry e = entries.get(0);
|
||||||
|
return new Object[] {e.blipLevel == IRadarDetectableNT.PLAYER};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Callback(direct = true)
|
||||||
|
@Optional.Method(modid = "OpenComputers")
|
||||||
|
public Object[] getIndexType(Context context, Arguments args) {
|
||||||
|
int index = args.checkInteger(0);
|
||||||
|
RadarEntry e = entries.get(0);
|
||||||
|
return new Object[] {e.blipLevel};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Callback(direct = true)
|
||||||
|
@Optional.Method(modid = "OpenComputers")
|
||||||
|
public Object[] getEntityAtIndex(Context context, Arguments args) {
|
||||||
|
int index = args.checkInteger(0);
|
||||||
|
RadarEntry e = entries.get(0);
|
||||||
|
boolean isPlayer = (boolean)this.isIndexPlayer(context, args)[0];
|
||||||
|
int type = (int)this.getIndexType(context, args)[0];
|
||||||
|
if(isPlayer) {
|
||||||
|
return new Object[]{true, e.posX, e.posY, e.posZ, type, e.unlocalizedName};
|
||||||
|
}
|
||||||
|
return new Object[]{false, e.posX, e.posY, e.posZ, type};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -53,8 +53,8 @@ public class TileEntityPWRController extends TileEntityMachineBase implements IG
|
|||||||
public static final int hullHeatCapacityBase = 10_000_000;
|
public static final int hullHeatCapacityBase = 10_000_000;
|
||||||
public double flux;
|
public double flux;
|
||||||
|
|
||||||
public int rodLevel = 100;
|
public double rodLevel = 100;
|
||||||
public int rodTarget = 100;
|
public double rodTarget = 100;
|
||||||
|
|
||||||
public int typeLoaded;
|
public int typeLoaded;
|
||||||
public int amountLoaded;
|
public int amountLoaded;
|
||||||
@ -202,7 +202,8 @@ public class TileEntityPWRController extends TileEntityMachineBase implements IG
|
|||||||
this.decrStackSize(0, 1);
|
this.decrStackSize(0, 1);
|
||||||
this.markChanged();
|
this.markChanged();
|
||||||
}
|
}
|
||||||
|
double diff = this.rodLevel - this.rodTarget;
|
||||||
|
if(diff < 1 && diff > -1) this.rodLevel = this.rodTarget;
|
||||||
if(this.rodTarget > this.rodLevel) this.rodLevel++;
|
if(this.rodTarget > this.rodLevel) this.rodLevel++;
|
||||||
if(this.rodTarget < this.rodLevel) this.rodLevel--;
|
if(this.rodTarget < this.rodLevel) this.rodLevel--;
|
||||||
|
|
||||||
@ -280,8 +281,8 @@ public class TileEntityPWRController extends TileEntityMachineBase implements IG
|
|||||||
data.setDouble("progress", progress);
|
data.setDouble("progress", progress);
|
||||||
data.setInteger("typeLoaded", typeLoaded);
|
data.setInteger("typeLoaded", typeLoaded);
|
||||||
data.setInteger("amountLoaded", amountLoaded);
|
data.setInteger("amountLoaded", amountLoaded);
|
||||||
data.setInteger("rodLevel", rodLevel);
|
data.setDouble("rodLevel", rodLevel);
|
||||||
data.setInteger("rodTarget", rodTarget);
|
data.setDouble("rodTarget", rodTarget);
|
||||||
data.setInteger("coreHeatCapacity", coreHeatCapacity);
|
data.setInteger("coreHeatCapacity", coreHeatCapacity);
|
||||||
this.networkPack(data, 150);
|
this.networkPack(data, 150);
|
||||||
} else {
|
} else {
|
||||||
@ -395,7 +396,7 @@ public class TileEntityPWRController extends TileEntityMachineBase implements IG
|
|||||||
progress = nbt.getDouble("progress");
|
progress = nbt.getDouble("progress");
|
||||||
typeLoaded = nbt.getInteger("typeLoaded");
|
typeLoaded = nbt.getInteger("typeLoaded");
|
||||||
amountLoaded = nbt.getInteger("amountLoaded");
|
amountLoaded = nbt.getInteger("amountLoaded");
|
||||||
rodLevel = nbt.getInteger("rodLevel");
|
rodLevel = nbt.getDouble("rodLevel");
|
||||||
rodTarget = nbt.getInteger("rodTarget");
|
rodTarget = nbt.getInteger("rodTarget");
|
||||||
coreHeatCapacity = nbt.getInteger("coreHeatCapacity");
|
coreHeatCapacity = nbt.getInteger("coreHeatCapacity");
|
||||||
}
|
}
|
||||||
@ -454,8 +455,8 @@ public class TileEntityPWRController extends TileEntityMachineBase implements IG
|
|||||||
this.coreHeat = nbt.getInteger("coreHeat");
|
this.coreHeat = nbt.getInteger("coreHeat");
|
||||||
this.hullHeat = nbt.getInteger("hullHeat");
|
this.hullHeat = nbt.getInteger("hullHeat");
|
||||||
this.flux = nbt.getDouble("flux");
|
this.flux = nbt.getDouble("flux");
|
||||||
this.rodLevel = nbt.getInteger("rodLevel");
|
this.rodLevel = nbt.getDouble("rodLevel");
|
||||||
this.rodTarget = nbt.getInteger("rodTarget");
|
this.rodTarget = nbt.getDouble("rodTarget");
|
||||||
this.typeLoaded = nbt.getInteger("typeLoaded");
|
this.typeLoaded = nbt.getInteger("typeLoaded");
|
||||||
this.amountLoaded = nbt.getInteger("amountLoaded");
|
this.amountLoaded = nbt.getInteger("amountLoaded");
|
||||||
this.progress = nbt.getDouble("progress");
|
this.progress = nbt.getDouble("progress");
|
||||||
@ -499,8 +500,8 @@ public class TileEntityPWRController extends TileEntityMachineBase implements IG
|
|||||||
nbt.setInteger("coreHeat", coreHeat);
|
nbt.setInteger("coreHeat", coreHeat);
|
||||||
nbt.setInteger("hullHeat", hullHeat);
|
nbt.setInteger("hullHeat", hullHeat);
|
||||||
nbt.setDouble("flux", flux);
|
nbt.setDouble("flux", flux);
|
||||||
nbt.setInteger("rodLevel", rodLevel);
|
nbt.setDouble("rodLevel", rodLevel);
|
||||||
nbt.setInteger("rodTarget", rodTarget);
|
nbt.setDouble("rodTarget", rodTarget);
|
||||||
nbt.setInteger("typeLoaded", typeLoaded);
|
nbt.setInteger("typeLoaded", typeLoaded);
|
||||||
nbt.setInteger("amountLoaded", amountLoaded);
|
nbt.setInteger("amountLoaded", amountLoaded);
|
||||||
nbt.setDouble("progress", progress);
|
nbt.setDouble("progress", progress);
|
||||||
@ -588,7 +589,7 @@ public class TileEntityPWRController extends TileEntityMachineBase implements IG
|
|||||||
@Callback(direct = true, limit = 4)
|
@Callback(direct = true, limit = 4)
|
||||||
@Optional.Method(modid = "OpenComputers")
|
@Optional.Method(modid = "OpenComputers")
|
||||||
public Object[] setLevel(Context context, Arguments args) {
|
public Object[] setLevel(Context context, Arguments args) {
|
||||||
rodTarget = MathHelper.clamp_int(args.checkInteger(0), 0, 100);
|
rodTarget = MathHelper.clamp_double(args.checkDouble(0), 0, 100);
|
||||||
this.markChanged();
|
this.markChanged();
|
||||||
return new Object[] {true};
|
return new Object[] {true};
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user