Skip to content

Commit

Permalink
breeder rods & integration
Browse files Browse the repository at this point in the history
  • Loading branch information
RecursivePineapple committed Sep 29, 2024
1 parent d984cda commit a995dd6
Show file tree
Hide file tree
Showing 38 changed files with 2,637 additions and 539 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ If you would like to help, send a me message on discord (my username is recursiv
If you find an issue and would like to report it, you can either open an issue here or send me a message on discord.

# TODO
- Breeder rods
- UI Polishing
- New textures
- Make vents state their total cooling capacity in sim results
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.recursive_pineapple.nuclear_horizons.networking.PacketDispatcher;
import com.recursive_pineapple.nuclear_horizons.reactors.blocks.BlockList;
import com.recursive_pineapple.nuclear_horizons.reactors.fluids.FluidList;
import com.recursive_pineapple.nuclear_horizons.reactors.items.ForeignItems;
import com.recursive_pineapple.nuclear_horizons.reactors.items.ItemList;
import com.recursive_pineapple.nuclear_horizons.reactors.tile.simulator.SimulationItems;

Expand Down Expand Up @@ -31,16 +32,16 @@ public void preInit(FMLPreInitializationEvent event) {
// load "Do your mod setup. Build whatever data structures you care about. Register recipes." (Remove if not needed)
public void init(FMLInitializationEvent event) {
PacketDispatcher.registerPackets();
// PacketDispatcher.TileEntityUpdatedMessage.init();

SimulationItems.init();

FluidList.registerCoolants();
}

// postInit "Handle interaction with other mods, complete your setup based on this." (Remove if not needed)
public void postInit(FMLPostInitializationEvent event) {}
public void postInit(FMLPostInitializationEvent event) {
FluidList.registerCoolants();
}

// register server commands in this event handler (Remove if not needed)
public void serverStarting(FMLServerStartingEvent event) {}
public void serverStarting(FMLServerStartingEvent event) {
SimulationItems.registerSimulationItems();
ForeignItems.registerForeignReactorItems();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ public class Config {
public static double ROD_EU_MULTIPLIER = 1;
public static double ROD_HU_MULTIPLIER = 1;
public static double MOX_EU_COEFFICIENT = 4;
public static int REACTOR_EU_MULTIPLIER = 100;
public static int FLUID_NUKE_HU_MULTIPLIER = 2;

public static void synchronizeConfiguration(File configFile) {
Configuration configuration = new Configuration(configFile);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,15 @@ public default double getExplosionRadiusMultiplier() {
return 1.0;
}

public default void modifySimulationResults(SimulationResult result, int componentIndex) {
public default void onSimulationStarted(SimulationResult result, int componentIndex) {

}

public default void setSimulationComponent(SimulationResult result, int componentIndex) {

}

public default void onSimulationFinished(SimulationResult result, int componentIndex) {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ public interface IReactorGrid {

public int getMaxHullHeat();

public default float getHeatRatio() {
return getHullHeat() / (float) getMaxHullHeat();
}

public void setHullHeat(int newHeat);

public void addHullHeat(int delta);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package com.recursive_pineapple.nuclear_horizons.reactors.components.adapters;

import com.recursive_pineapple.nuclear_horizons.reactors.components.IComponentAdapter;
import com.recursive_pineapple.nuclear_horizons.reactors.components.IReactorGrid;
import com.recursive_pineapple.nuclear_horizons.reactors.components.InventoryDirection;
import com.recursive_pineapple.nuclear_horizons.reactors.items.interfaces.IBreederRod;

import net.minecraft.item.ItemStack;

public class BreederRodAdapter implements IComponentAdapter {

private final IReactorGrid reactor;
private final int x, y;
private final ItemStack itemStack;
private final IBreederRod breederRod;

public BreederRodAdapter(IReactorGrid reactor, int x, int y, ItemStack itemStack, IBreederRod breederRod) {
this.reactor = reactor;
this.x = x;
this.y = y;
this.itemStack = itemStack;
this.breederRod = breederRod;
}

@Override
public int getX() {
return x;
}

@Override
public int getY() {
return y;
}

@Override
public ItemStack getItemStack() {
return itemStack;
}

@Override
public void onHeatTick() {
if(!reactor.isActive()) {
return;
}

int neighbouringRods = 0;

for (var dir : InventoryDirection.values()) {
int x2 = dir.offsetX(x);
int y2 = dir.offsetY(y);

if (x2 < 0 || y2 < 0 || x2 >= reactor.getWidth() || y2 >= reactor.getHeight()) {
continue;
}

var neighbour = reactor.getComponent(x2, y2);

if (neighbour != null) {
neighbouringRods += neighbour.getFuelRodCount();
}
}

int heatMultiplier = 1 + reactor.getHullHeat() / breederRod.getReactorHeatDivisor(itemStack) * breederRod.getHeatMultiplier(itemStack);

int storedNeutrons = breederRod.getStoredNeutrons(itemStack);

storedNeutrons += neighbouringRods * heatMultiplier;

int max = breederRod.getMaxNeutrons(itemStack);

storedNeutrons = Math.min(storedNeutrons, max);

breederRod.setNeutrons(itemStack, storedNeutrons);

if (storedNeutrons >= max) {
reactor.setItem(x, y, ItemStack.copyItemStack(breederRod.getProduct(itemStack)));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,44 +40,59 @@ public ItemStack getItemStack() {
return itemStack;
}

protected double getEUMultiplier() {
double mult = Config.ROD_EU_MULTIPLIER;

if (fuelRod.isMox(itemStack)) {
mult *= 1 + fuelRod.getMoxEUCoefficient(itemStack) * reactor.getHeatRatio();
}

return mult;
}

protected double getHeatMultiplier() {
double mult = Config.ROD_HU_MULTIPLIER;

if (fuelRod.isMox(itemStack) && reactor.isFluid() && reactor.getHeatRatio() >= 0.5) {
mult *= fuelRod.getMoxHeatCoefficient(itemStack);
}

return mult;
}

@Override
public void onHeatTick() {
if (!reactor.isActive()) {
return;
}

if (fuelRod.getRemainingHealth(itemStack) <= 0) {
var product = fuelRod.getProduct(itemStack);
reactor.setItem(x, y, product != null ? product.copy() : null);
reactor.setItem(x, y, ItemStack.copyItemStack(fuelRod.getProduct(itemStack)));
return;
}

int pulses = this.getPulseCount();
int heat = (int) (fuelRod.getHeatMult(itemStack) * pulses * (pulses + 1) * Config.ROD_HU_MULTIPLIER);

if (fuelRod.isMox(itemStack) && reactor.isFluid()
&& (reactor.getHullHeat() / reactor.getMaxHullHeat()) >= 0.5) {
heat *= 2;
}
int heat = (int) (fuelRod.getHeatMult(itemStack) * fuelRod.getRodCount(itemStack) * getHeatMultiplier() * pulses * (pulses + 1) / 2);

var heatableNeighbours = this.getHeatableNeighbours();

if (heatableNeighbours.isEmpty()) {
reactor.addHullHeat(heat);
} else {
int rodCount = fuelRod.getRodCount(itemStack);

int heatPerRod = heat / rodCount;

for (int i = 0; i < heatableNeighbours.size(); i++) {
int remainingNeighbours = heatableNeighbours.size() - i;
int heatToTransfer = heatPerRod / remainingNeighbours;
heatPerRod -= heatToTransfer;
heatPerRod += heatableNeighbours.get(i)
.addHeat(heatToTransfer * rodCount) / rodCount;

int heatToTransfer = heat / remainingNeighbours;
heat -= heatToTransfer;

int rejected = heatableNeighbours.get(i).addHeat(heatToTransfer);

heat += rejected;
}

reactor.addHullHeat(heatPerRod * rodCount);
if (heat > 0) {
reactor.addHullHeat(heat);
}
}
}

Expand All @@ -92,11 +107,7 @@ public void onEnergyTick() {
}

int pulses = this.getPulseCount();
double energy = fuelRod.getEnergyMult(itemStack) * pulses * Config.ROD_EU_MULTIPLIER;

if (fuelRod.isMox(itemStack)) {
energy *= 1 + Config.MOX_EU_COEFFICIENT * reactor.getHullHeat() / reactor.getMaxHullHeat();
}
double energy = fuelRod.getEnergyMult(itemStack) * fuelRod.getRodCount(itemStack) * getEUMultiplier() * pulses;

reactor.addEU(energy);
fuelRod.applyDamage(itemStack, 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public int addHeat(int delta) {
int rejected = this.heatContainer.addHeat(itemStack, delta);

if (this.heatContainer.getRemainingHealth(itemStack) <= 0 && this.heatContainer.isConsumable(itemStack)) {
this.reactor.setItem(x, y, null);
this.reactor.setItem(x, y, ItemStack.copyItemStack(this.heatContainer.getProduct(itemStack)));
}

return rejected;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.recursive_pineapple.nuclear_horizons.reactors.components.IReactorGrid;
import com.recursive_pineapple.nuclear_horizons.reactors.components.InventoryDirection;
import com.recursive_pineapple.nuclear_horizons.reactors.items.interfaces.IHeatMover;
import com.recursive_pineapple.nuclear_horizons.reactors.tile.simulator.SimulationComponentResult;
import com.recursive_pineapple.nuclear_horizons.reactors.tile.simulator.SimulationResult;

public class HeatMoverAdapter implements IComponentAdapter {
Expand All @@ -15,6 +16,8 @@ public class HeatMoverAdapter implements IComponentAdapter {
private final ItemStack itemStack;
private final IHeatMover heatMover;

private SimulationComponentResult simResult;

public HeatMoverAdapter(IReactorGrid reactor, int x, int y, ItemStack itemStack, IHeatMover heatMover) {
this.reactor = reactor;
this.x = x;
Expand Down Expand Up @@ -60,13 +63,8 @@ public int addHeat(int delta) {
}

@Override
public void modifySimulationResults(SimulationResult result, int componentIndex) {
// if(result.maxHullCooling == null) result.maxHullCooling = 0l;

// result.maxHullCooling += this.heatMover.getTransferFromReactor(itemStack, reactor);

// if(result.componentResults[componentIndex].maxAirHeating
// TODO: this
public void onSimulationFinished(SimulationResult result, int componentIndex) {

}

@Override
Expand Down
Loading

0 comments on commit a995dd6

Please sign in to comment.