-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d984cda
commit a995dd6
Showing
38 changed files
with
2,637 additions
and
539 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
.../recursive_pineapple/nuclear_horizons/reactors/components/adapters/BreederRodAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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))); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.