Skip to content

Commit

Permalink
fix: plutonium localization + structure checking + geometry hiccups
Browse files Browse the repository at this point in the history
  • Loading branch information
bruberu committed Jul 21, 2024
1 parent b2f41c2 commit 6270fad
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
21 changes: 13 additions & 8 deletions src/main/java/gregtech/api/nuclear/fission/FissionReactor.java
Original file line number Diff line number Diff line change
Expand Up @@ -243,26 +243,31 @@ public void computeGeometry() {
* Geometric factor calculation is done by (rough) numerical integration along a straight path between
* the two cells
*/
int prevX = fuelRods.get(i).getX();
int prevY = fuelRods.get(i).getY();
double resolution = ConfigHolder.machines.nuclear.fissionReactorResolution;
for (int t = 0; t < resolution; t++) {
double x;
double y;

x = (rodTwo.getX() - rodOne.getX()) *
((float) t / resolution) + fuelRods.get(i).getX();
y = (rodTwo.getY() - rodOne.getY()) *
((float) t / resolution) + fuelRods.get(i).getY();
int x = (int) Math.round((rodTwo.getX() - rodOne.getX()) *
((float) t / resolution) + fuelRods.get(i).getX());
int y = (int) Math.round((rodTwo.getY() - rodOne.getY()) *
((float) t / resolution) + fuelRods.get(i).getY());
if (x < 0 || x > reactorLayout.length - 1 || y < 0 || y > reactorLayout.length - 1) {
continue;
}
ReactorComponent component = reactorLayout[(int) Math.round(x)][(int) Math.round(y)];
ReactorComponent component = reactorLayout[x][y];

if (component == null) {
continue;
}

mij += component.getModerationFactor();

if (x == prevX && y == prevY) {
continue;
}
prevX = x;
prevY = y;

/*
* For simplicity, we pretend that fuel rods are completely opaque to neutrons, paths that hit fuel
* rods are ignored as obstructed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,11 +325,12 @@ protected EnumFacing getRight() {
/**
* Uses the upper layer to determine the diameter of the structure
*/
protected int findDiameter() {
protected int findDiameter(int heightTop) {
int i = 1;
BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos(this.getPos());
pos.move(getUp(), heightTop);
while (i <= 15) {
if (this.isBlockEdge(this.getWorld(), pos.move(getUp()),
if (this.isBlockEdge(this.getWorld(), pos,
this.getFrontFacing().getOpposite(),
i))
break;
Expand Down Expand Up @@ -482,7 +483,7 @@ protected BlockPattern createStructurePattern() {

this.height = heightTop + heightBottom + 1;

this.diameter = this.getWorld() != null ? Math.max(Math.min(this.findDiameter(), 15), 5) : 5;
this.diameter = this.getWorld() != null ? Math.max(Math.min(this.findDiameter(heightTop), 15), 5) : 5;

int radius = this.diameter % 2 == 0 ? (int) Math.floor(this.diameter / 2.f) :
Math.round((this.diameter - 1) / 2.f);
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/assets/gregtech/lang/en_us.lang
Original file line number Diff line number Diff line change
Expand Up @@ -1616,8 +1616,9 @@ gregtech.material.palladium=Palladium
gregtech.material.phosphorus=Phosphorus
gregtech.material.polonium=Polonium
gregtech.material.platinum=Platinum
gregtech.material.plutonium=Plutonium
gregtech.material.plutonium_238=Plutonium 238
gregtech.material.plutonium=Plutonium 239
gregtech.material.plutonium_239=Plutonium 239
gregtech.material.plutonium_240=Plutonium 240
gregtech.material.plutonium_241=Plutonium 241
gregtech.material.plutonium_242=Plutonium 242
Expand Down

0 comments on commit 6270fad

Please sign in to comment.