Skip to content

Commit

Permalink
Partial RBMK Meltdowns
Browse files Browse the repository at this point in the history
Added Partial RBMK Meltdowns

Changed Solar Power
Changed order of RBMK Console stats

Fixed missing hover tooltips in RBMK Storage Gui
  • Loading branch information
Alcatergit committed Jun 22, 2023
1 parent 8030c6d commit eacccc0
Show file tree
Hide file tree
Showing 10 changed files with 83 additions and 57 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/hbm/blocks/machine/BlockHadronPower.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void printHook(Pre event, World world, int x, int y, int z) {

List<String> text = new ArrayList();
text.add(Library.getShortNumber(extractor.power) + "/" + Library.getShortNumber(extractor.getMaxPower()) + " HE");

text.add("&["+Library.getColorProgress((double)extractor.power/(double)extractor.getMaxPower())+"&] "+Library.getPercentage((double)extractor.power/(double)extractor.getMaxPower())+"%");
ILookOverlay.printGeneric(event, I18nUtil.resolveKey(getUnlocalizedName() + ".name"), 0xffff00, 0x404000, text);
}
}
6 changes: 6 additions & 0 deletions src/main/java/com/hbm/inventory/gui/GUIRBMKStorage.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ protected void drawGuiContainerForegroundLayer(int i, int j) {
this.fontRenderer.drawString(I18n.format("container.inventory"), 8, this.ySize - 96 + 2, 4210752);
}

@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks){
super.drawScreen(mouseX, mouseY, partialTicks);
super.renderHoveredToolTip(mouseX, mouseY);
}

@Override
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) {
super.drawDefaultBackground();
Expand Down
37 changes: 30 additions & 7 deletions src/main/java/com/hbm/items/machine/ItemRBMKRod.java
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,11 @@ public double burn(World world, ItemStack stack, double inFlux) {

return outFlux;
}

public static double getMeltdownFactor(double meltdownPercent){
if(meltdownPercent == 0) return 1;
return 1D - 0.3D * (meltdownPercent/100D);
}

/**
* Heat up the core based on the outFlux, then move some heat to the hull
Expand All @@ -209,13 +214,19 @@ public void updateHeat(World world, ItemStack stack, double mod) {

double coreHeat = getCoreHeat(stack);
double hullHeat = getHullHeat(stack);
double meltdownPercent = getMeltdownPercent(stack);

if(hullHeat > this.meltingPoint) {
meltdownPercent += 0.05D * hullHeat/this.meltingPoint;
setMeltdownPercent(stack, meltdownPercent);
}

if(coreHeat > hullHeat) {

double mid = (coreHeat - hullHeat) / 2D;

coreHeat -= mid * this.diffusion * RBMKDials.getFuelDiffusionMod(world) * mod;
hullHeat += mid * this.diffusion * RBMKDials.getFuelDiffusionMod(world) * mod;
double heatTransfer = mid * this.diffusion * RBMKDials.getFuelDiffusionMod(world) * mod;
coreHeat -= heatTransfer * getMeltdownFactor(meltdownPercent);
hullHeat += heatTransfer;

setCoreHeat(stack, coreHeat);
setHullHeat(stack, hullHeat);
Expand All @@ -230,11 +241,12 @@ public void updateHeat(World world, ItemStack stack, double mod) {
public double provideHeat(World world, ItemStack stack, double heat, double mod) {

double hullHeat = getHullHeat(stack);

//metldown! the hull melts so the entire structure stops making sense
//hull and core heats are instantly equalized into 33% of their sum each,
//the rest is sent to the component which is always fatal
if(hullHeat > this.meltingPoint) {
//hull and fuel core heat, fuel skin heat are instantly averaged,
//that average is sent to the component which is always fatal
if(getMeltdownPercent(stack) >= 100) {
setMeltdownPercent(stack, 100);
double coreHeat = getCoreHeat(stack);
double avg = (heat + hullHeat + coreHeat) / 3D;
setCoreHeat(stack, avg);
Expand Down Expand Up @@ -413,6 +425,7 @@ public void addInformation(ItemStack stack, World worldIn, List<String> list, IT
list.add(TextFormatting.RED + I18nUtil.resolveKey("trait.rbmx.skinTemp", ((int)(getHullHeat(stack) * 10D) / 10D) + "m"));
list.add(TextFormatting.RED + I18nUtil.resolveKey("trait.rbmx.coreTemp", ((int)(getCoreHeat(stack) * 10D) / 10D) + "m"));
list.add(TextFormatting.DARK_RED + I18nUtil.resolveKey("trait.rbmx.melt", meltingPoint + "m"));
list.add(TextFormatting.DARK_RED + I18nUtil.resolveKey("trait.rbmx.meltdown", ((int)(getMeltdownPercent(stack) * 1000D) / 1000D) + "%"));

} else {

Expand All @@ -433,6 +446,7 @@ public void addInformation(ItemStack stack, World worldIn, List<String> list, IT
list.add(TextFormatting.RED + I18nUtil.resolveKey("trait.rbmk.skinTemp", ((int)(getHullHeat(stack) * 10D) / 10D) + "°C"));
list.add(TextFormatting.RED + I18nUtil.resolveKey("trait.rbmk.coreTemp", ((int)(getCoreHeat(stack) * 10D) / 10D) + "°C"));
list.add(TextFormatting.DARK_RED + I18nUtil.resolveKey("trait.rbmk.melt", meltingPoint + "°C"));
list.add(TextFormatting.DARK_RED + I18nUtil.resolveKey("trait.rbmk.meltdown", ((int)(getMeltdownPercent(stack) * 1000D) / 1000D) + "%"));
}

super.addInformation(stack, worldIn, list, flag);
Expand Down Expand Up @@ -490,6 +504,14 @@ public static double getYield(ItemStack stack) {

return 0;
}

public static void setMeltdownPercent(ItemStack stack, double meltdownPercent){
setDouble(stack, "meltdown", meltdownPercent);
}

public static double getMeltdownPercent(ItemStack stack){
return getDouble(stack, "meltdown");
}

public static void setPoison(ItemStack stack, double xenon) {
setDouble(stack, "xenon", xenon);
Expand Down Expand Up @@ -550,5 +572,6 @@ private static void setNBTDefaults(ItemStack stack) {
setYield(stack, ((ItemRBMKRod)stack.getItem()).yield);
setCoreHeat(stack, 20.0D);
setHullHeat(stack, 20.0D);
setMeltdownPercent(stack, 0D);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class TileEntitySolarMirror extends TileEntityTickingBase {
public int tZ;
public boolean isOn;

public static int maxTU = 1000;
public static int maxTU = 500;

@Override
public String getInventoryName() {
Expand Down Expand Up @@ -133,5 +133,4 @@ public AxisAlignedBB getRenderBoundingBox() {
public double getMaxRenderDistanceSquared() {
return 65536.0D;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -495,8 +495,9 @@ public List<String> getFancyStats() {
stats.add(TextFormatting.GREEN + I18nUtil.resolveKey("rbmk.rod.flux", (int)this.data.getDouble("flux")));
stats.add(TextFormatting.DARK_GREEN + I18nUtil.resolveKey("rbmk.rod.depletion", ((int)(((1D - this.data.getDouble("enrichment")) * 100000)) / 1000D) + "%"));
stats.add(TextFormatting.DARK_PURPLE + I18nUtil.resolveKey("rbmk.rod.xenon", ((int)(((this.data.getDouble("xenon")) * 1000D)) / 1000D) + "%"));
stats.add(TextFormatting.DARK_RED + I18nUtil.resolveKey("rbmk.rod.coreTemp", ((int)((this.data.getDouble("c_coreHeat") * 10D)) / 10D) + "°C"));
stats.add(TextFormatting.RED + I18nUtil.resolveKey("rbmk.rod.skinTemp", ((int)((this.data.getDouble("c_heat") * 10D)) / 10D) + "°C", ((int)((this.data.getDouble("c_maxHeat") * 10D)) / 10D) + "°C"));
stats.add(TextFormatting.DARK_RED + I18nUtil.resolveKey("rbmk.rod.coreTemp", ((int)((this.data.getDouble("c_coreHeat") * 10D)) / 10D) + "°C"));
stats.add(TextFormatting.DARK_RED + I18nUtil.resolveKey("trait.rbmk.meltdown", ((int)(((this.data.getDouble("meltdown")) * 1000D)) / 1000D) + "%"));
break;
case BOILER:
stats.add(TextFormatting.BLUE + I18nUtil.resolveKey("rbmk.boiler.water", this.data.getInteger("water"), this.data.getInteger("maxWater")));
Expand Down Expand Up @@ -585,11 +586,11 @@ public RBMKGraph(ScreenType type, Integer[] columns, int[] dataBuffer) {
public static enum ScreenType {
NONE(0 * 18),
COL_TEMP(1 * 18),
FUEL_TEMP(5 * 18),
ROD_EXTRACTION(2 * 18),
FLUX(6 * 18),
FUEL_DEPLETION(3 * 18),
FUEL_POISON(4 * 18),
FUEL_TEMP(5 * 18),
FLUX(6 * 18);
FUEL_POISON(4 * 18);

public int offset;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,11 +228,6 @@ public boolean canExtractItem(int i, ItemStack itemStack, int j) {
return i == 1;
}

@Override
public int[] getAccessibleSlotsFromSide(EnumFacing p_94128_1_) {
return new int[] {0, 1};
}

@Override
public void recievePacket(NBTTagCompound[] tags){
if(tags.length == 1){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ public void update() {

if(!this.hasLid()) {
RadiationSavedData.incrementRad(world, pos, (float) ((this.fluxFast + this.fluxSlow) * 0.05F), Float.MAX_VALUE);
} else{
double meltdownPercent = rod.getMeltdownPercent(inventory.getStackInSlot(0));
if(meltdownPercent > 0){
RadiationSavedData.incrementRad(world, pos, (float) ((this.fluxFast + this.fluxSlow) * 0.05F * (meltdownPercent/100)), Float.MAX_VALUE);
}
}

super.update();
Expand All @@ -117,6 +122,13 @@ public void update() {
}
}
}

@Override
public boolean canExtractItem(int slot, ItemStack itemStack, int amount) {
if(itemStack.getItem() instanceof ItemRBMKRod)
return !(ItemRBMKRod.getMeltdownPercent(itemStack) > 0);
return true;
}

/**
* SLOW: full efficiency for slow neutrons, fast neutrons have half efficiency
Expand Down Expand Up @@ -364,6 +376,7 @@ public NBTTagCompound getNBTForConsole() {
data.setDouble("c_heat", ItemRBMKRod.getHullHeat(inventory.getStackInSlot(0)));
data.setDouble("c_coreHeat", ItemRBMKRod.getCoreHeat(inventory.getStackInSlot(0)));
data.setDouble("c_maxHeat", rod.meltingPoint);
data.setDouble("meltdown", ItemRBMKRod.getMeltdownPercent(inventory.getStackInSlot(0)));
}
data.setDouble("flux", this.fluxOut);
return data;
Expand Down Expand Up @@ -395,9 +408,4 @@ public void unload() {
inventory.setStackInSlot(0, ItemStack.EMPTY);
this.markDirty();
}

@Override
public int[] getAccessibleSlotsFromSide(EnumFacing e) {
return new int[] {0};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,29 @@ public abstract class TileEntityRBMKSlottedBase extends TileEntityRBMKActiveBase
public TileEntityRBMKSlottedBase(int scount) {
inventory = new ItemStackHandler(scount){
@Override
protected void onContentsChanged(int slot){
protected void onContentsChanged(int slot) {
markDirty();
super.onContentsChanged(slot);
}

@Override
public boolean isItemValid(int slot, ItemStack itemStack) {
return isItemValidForSlot(slot, itemStack);
}

@Override
public ItemStack insertItem(int slot, ItemStack stack, boolean simulate) {
if(canInsertItem(slot, stack, stack.getCount()))
return super.insertItem(slot, stack, simulate);
return ItemStack.EMPTY;
}

@Override
public ItemStack extractItem(int slot, int amount, boolean simulate) {
if(canExtractItem(slot, inventory.getStackInSlot(slot), amount))
return super.extractItem(slot, amount, simulate);
return ItemStack.EMPTY;
}
};
}

Expand Down Expand Up @@ -73,36 +92,14 @@ public boolean canExtractItem(int slot, ItemStack itemStack, int amount) {
return true;
}

public int[] getAccessibleSlotsFromSide(EnumFacing e) {
return new int[] {};
}

@Override
public boolean hasCapability(Capability<?> capability, EnumFacing facing){
return (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY && inventory != null) || super.hasCapability(capability, facing);
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || super.hasCapability(capability, facing);
}

@Override
public <T> T getCapability(Capability<T> capability, EnumFacing facing){
if(capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY && inventory != null){
if(facing == null)
return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(inventory);
return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(new ItemStackHandlerWrapper(inventory, getAccessibleSlotsFromSide(facing)){
@Override
public ItemStack extractItem(int slot, int amount, boolean simulate) {
if(canExtractItem(slot, inventory.getStackInSlot(slot), amount))
return super.extractItem(slot, amount, simulate);
return ItemStack.EMPTY;
}

@Override
public ItemStack insertItem(int slot, ItemStack stack, boolean simulate) {
if(canInsertItem(slot, stack, stack.getCount()))
return super.insertItem(slot, stack, simulate);
return stack;
}
});
}
return super.getCapability(capability, facing);
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY ? CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(inventory) :
super.getCapability(capability, facing);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,6 @@ public boolean canExtractItem(int i, ItemStack itemStack, int j) {
return true;
}

@Override
public int[] getAccessibleSlotsFromSide(EnumFacing e) {
return new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
}

@Override
public boolean canLoad(ItemStack toLoad) {
return toLoad != null && inventory.getStackInSlot(11).isEmpty();
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/assets/hbm/lang/en_us.lang
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,7 @@ trait.rbmk.fluxFunc=Flux function: %s
trait.rbmk.funcType=Function type: %s
trait.rbmk.heat=Heat per output flux: %s
trait.rbmk.melt=Melting point: %s
trait.rbmk.meltdown=Internal Meltdown: %s
trait.rbmk.neutron.any=All Neutrons
trait.rbmk.neutron.fast=Fast Neutrons
trait.rbmk.neutron.slow=Slow Neutrons
Expand All @@ -518,6 +519,7 @@ trait.rbmx.fluxFunc=Doom function: %s
trait.rbmx.funcType=Function specification: %s
trait.rbmx.heat=Crust per emitted entropy: %s
trait.rbmx.melt=Crush depth: %s
trait.rbmx.meltdown=Reality Breakdown: %s
trait.rbmk.neutron.any.x=All non-euclidean shapes
trait.rbmk.neutron.fast.x=Elliptic non-euclidean shapes
trait.rbmk.neutron.slow.x=Hyperbolic non-euclidean shapes
Expand Down

0 comments on commit eacccc0

Please sign in to comment.