i want to kill myself ❤️

This commit is contained in:
BallOfEnergy 2024-09-02 15:17:07 -05:00
parent e7419ef76b
commit 5902ff5189
26 changed files with 428 additions and 325 deletions

View File

@ -3,7 +3,8 @@ package com.hbm.blocks.machine.rbmk;
import com.hbm.blocks.BlockDummyable; import com.hbm.blocks.BlockDummyable;
import com.hbm.blocks.ILookOverlay; import com.hbm.blocks.ILookOverlay;
import com.hbm.handler.MultiblockHandlerXR; import com.hbm.handler.MultiblockHandlerXR;
import com.hbm.handler.rbmkmk2.RBMKHandler; import com.hbm.handler.neutron.NeutronNodeWorld;
import com.hbm.handler.neutron.RBMKNeutronHandler.RBMKNeutronNode;
import com.hbm.items.ModItems; import com.hbm.items.ModItems;
import com.hbm.items.machine.ItemRBMKLid; import com.hbm.items.machine.ItemRBMKLid;
import com.hbm.lib.RefStrings; import com.hbm.lib.RefStrings;
@ -29,8 +30,6 @@ import net.minecraft.world.World;
import net.minecraftforge.client.event.RenderGameOverlayEvent.Pre; import net.minecraftforge.client.event.RenderGameOverlayEvent.Pre;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import static com.hbm.handler.rbmkmk2.RBMKHandler.getNode;
public abstract class RBMKBase extends BlockDummyable implements IToolable, ILookOverlay { public abstract class RBMKBase extends BlockDummyable implements IToolable, ILookOverlay {
public static boolean dropLids = true; public static boolean dropLids = true;
@ -175,7 +174,7 @@ public abstract class RBMKBase extends BlockDummyable implements IToolable, ILoo
if(rbmk.hasLid() && rbmk.isLidRemovable()) { if(rbmk.hasLid() && rbmk.isLidRemovable()) {
RBMKHandler.RBMKNode node = getNode(new BlockPos(te)); RBMKNeutronNode node = (RBMKNeutronNode) NeutronNodeWorld.getNode(new BlockPos(te));
if (node != null) if (node != null)
node.removeLid(); node.removeLid();

View File

@ -0,0 +1,20 @@
package com.hbm.handler.neutron;
import com.hbm.handler.neutron.NeutronStream.NeutronType;
import net.minecraft.tileentity.TileEntity;
import java.util.HashMap;
import java.util.Map;
public abstract class NeutronNode {
protected NeutronType type;
protected TileEntity tile;
// like NBT but less fucking CANCER
protected Map<String, Object> data = new HashMap<>();
public NeutronNode(TileEntity tile, NeutronType type) {
this.type = type;
this.tile = tile;
}
}

View File

@ -0,0 +1,62 @@
package com.hbm.handler.neutron;
import com.hbm.util.fauxpointtwelve.BlockPos;
import net.minecraft.world.World;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class NeutronNodeWorld {
// HashMap of all RBMK nodes and their positions.
protected static HashMap<BlockPos, NeutronNode> nodeCache = new HashMap<>();
public static void addNode(NeutronNode node) {
nodeCache.put(new BlockPos(node.tile), node);
}
public static void removeNode(BlockPos position) {
nodeCache.remove(position);
}
public static NeutronNode getNode(BlockPos position) {
return nodeCache.get(position);
}
public static void removeAllNodes() {
nodeCache.clear();
}
// List of all stream worlds.
public static HashMap<World, StreamWorld> streamWorlds = new HashMap<>();
public static class StreamWorld {
List<NeutronStream> streams;
public StreamWorld() {
streams = new ArrayList<>();
}
public void addStream(NeutronStream stream) {
this.streams.add(stream);
}
public void removeAllStreams() {
this.streams.clear();
}
public void removeAllStreamsOfType(NeutronStream.NeutronType type) {
List<NeutronStream> toRemove = new ArrayList<>();
for (NeutronStream stream : streams) {
if (stream.type == type)
toRemove.add(stream);
}
toRemove.forEach((stream) -> streams.remove(stream));
}
public static void removeAllWorlds() {
streamWorlds.clear();
}
}
}

View File

@ -0,0 +1,69 @@
package com.hbm.handler.neutron;
import com.hbm.util.fauxpointtwelve.BlockPos;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import com.hbm.handler.neutron.NeutronNodeWorld.StreamWorld;
import java.util.ArrayList;
import java.util.List;
public abstract class NeutronStream {
public enum NeutronType {
DUMMY, // Dummy streams for testing
RBMK, // RBMK neutron streams
PILE // Chicago pile streams
}
public NeutronNode origin;
// doubles!!
public double fluxQuantity;
// Hey, new implementation! Basically a ratio for slow flux to fast flux
// 0 = all slow flux
// 1 = all fast flux
public double fluxRatio;
public NeutronType type = NeutronType.DUMMY;
// Vector for direction of neutron flow.
public Vec3 vector;
// Primarily used as a "dummy stream", not to be added to the streams list.
public NeutronStream(NeutronNode origin, Vec3 vector) {
this.origin = origin;
this.vector = vector;
}
public NeutronStream(NeutronNode origin, Vec3 vector, double flux, double ratio, NeutronType type) {
this.origin = origin;
this.vector = vector;
this.fluxQuantity = flux;
this.fluxRatio = ratio;
this.type = type;
World worldObj = origin.tile.getWorldObj();
if (NeutronNodeWorld.streamWorlds.get(worldObj) == null) {
StreamWorld world = new StreamWorld();
world.addStream(this);
NeutronNodeWorld.streamWorlds.put(worldObj, world);
} else
NeutronNodeWorld.streamWorlds.get(worldObj).addStream(this);
}
// USES THE CACHE!!!
public List<BlockPos> getBlocks(int range) {
List<BlockPos> positions = new ArrayList<>();
for (int i = 1; i <= range; i++) {
int x = (int) Math.floor(0.5 + vector.xCoord * i);
int z = (int) Math.floor(0.5 + vector.zCoord * i);
BlockPos pos = new BlockPos(origin.tile).add(x, 0, z);
positions.add(pos);
}
return positions;
}
public abstract void runStreamInteraction(World worldObj);
}

View File

@ -0,0 +1,44 @@
package com.hbm.handler.neutron;
import com.hbm.tileentity.machine.pile.TileEntityPileBase;
import net.minecraft.world.World;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class PileNeutronHandler {
public static class PileNeutronNode extends NeutronNode {
public PileNeutronNode(TileEntityPileBase tile) {
super(tile, NeutronStream.NeutronType.RBMK);
}
}
// The big one!! Runs all interactions for neutrons.
public static void runAllInteractions() {
// Remove `StreamWorld` objects if they have no streams.
{ // aflghdkljghlkbhfjkghgilurbhlkfjghkffdjgn
List<World> toRemove = new ArrayList<>();
NeutronNodeWorld.streamWorlds.forEach((world, streamWorld) -> {
if (streamWorld.streams.isEmpty())
toRemove.add(world);
});
for (World world : toRemove) {
NeutronNodeWorld.streamWorlds.remove(world);
}
}
for (Map.Entry<World, NeutronNodeWorld.StreamWorld> world : NeutronNodeWorld.streamWorlds.entrySet()) {
for (NeutronStream stream : world.getValue().streams) {
stream.runStreamInteraction(world.getKey());
}
world.getValue().removeAllStreams();
}
}
}

View File

@ -1,4 +1,4 @@
package com.hbm.handler.rbmkmk2; package com.hbm.handler.neutron;
import com.hbm.blocks.machine.rbmk.RBMKBase; import com.hbm.blocks.machine.rbmk.RBMKBase;
import com.hbm.handler.radiation.ChunkRadiationManager; import com.hbm.handler.radiation.ChunkRadiationManager;
@ -7,7 +7,6 @@ import com.hbm.util.fauxpointtwelve.BlockPos;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.HashMap;
import java.util.Map.Entry; import java.util.Map.Entry;
import net.minecraft.block.Block; import net.minecraft.block.Block;
@ -16,7 +15,7 @@ import net.minecraft.util.Vec3;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
public class RBMKHandler { public class RBMKNeutronHandler {
static double moderatorEfficiency; static double moderatorEfficiency;
static double reflectorEfficiency; static double reflectorEfficiency;
@ -38,30 +37,27 @@ public class RBMKHandler {
return worldObj.getTileEntity(pos.getX(), pos.getY(), pos.getZ()); return worldObj.getTileEntity(pos.getX(), pos.getY(), pos.getZ());
} }
public static class RBMKNode { public static RBMKNeutronNode makeNode(TileEntityRBMKBase tile) {
BlockPos pos = new BlockPos(tile);
if (NeutronNodeWorld.nodeCache.containsKey(pos))
return (RBMKNeutronNode) NeutronNodeWorld.getNode(pos);
return new RBMKNeutronNode(tile, tile.getRBMKType(), tile.hasLid());
}
protected RBMKType type; public static class RBMKNeutronNode extends NeutronNode {
protected TileEntityRBMKBase tile;
protected boolean hasLid;
public RBMKNode(TileEntityRBMKBase tile, RBMKType type) { public RBMKNeutronNode(TileEntityRBMKBase tile, RBMKType type, boolean hasLid) {
this.type = type; super(tile, NeutronStream.NeutronType.RBMK);
this.tile = tile; this.data.put("hasLid", hasLid);
this.hasLid = tile.hasLid(); this.data.put("type", type);
}
public RBMKNode(TileEntityRBMKBase tile, RBMKType type, boolean hasLid) {
this.type = type;
this.tile = tile;
this.hasLid = hasLid;
} }
public void addLid() { public void addLid() {
this.hasLid = true; this.data.replace("hasLid", true);
} }
public void removeLid() { public void removeLid() {
this.hasLid = false; this.data.replace("hasLid", false);
} }
public List<BlockPos> getReaSimNodes() { public List<BlockPos> getReaSimNodes() {
@ -74,16 +70,15 @@ public class RBMKHandler {
} }
public List<BlockPos> checkNode() { public List<BlockPos> checkNode() {
List<BlockPos> list = new ArrayList<>(); List<BlockPos> list = new ArrayList<>();
BlockPos pos = new BlockPos(this.tile); BlockPos pos = new BlockPos(this.tile);
List<NeutronStream> streams = new ArrayList<>(); List<RBMKNeutronStream> streams = new ArrayList<>();
// Simulate streams coming out of the RBMK rod. // Simulate streams coming out of the RBMK rod.
for (ForgeDirection dir : TileEntityRBMKRod.fluxDirs) { for (ForgeDirection dir : TileEntityRBMKRod.fluxDirs) {
streams.add(new NeutronStream(this, Vec3.createVectorHelper(dir.offsetX, 0, dir.offsetZ))); streams.add(new RBMKNeutronStream(this, Vec3.createVectorHelper(dir.offsetX, 0, dir.offsetZ)));
} }
// Check if the rod should uncache nodes. // Check if the rod should uncache nodes.
@ -91,7 +86,7 @@ public class RBMKHandler {
TileEntityRBMKRod rod = (TileEntityRBMKRod) tile; TileEntityRBMKRod rod = (TileEntityRBMKRod) tile;
if (!rod.hasRod || rod.lastFluxQuantity == 0) { if (!rod.hasRod || rod.lastFluxQuantity == 0) {
for (NeutronStream stream : streams) { for (RBMKNeutronStream stream : streams) {
stream.getNodes(false).forEach(node -> list.add(new BlockPos(node.tile))); stream.getNodes(false).forEach(node -> list.add(new BlockPos(node.tile)));
} }
@ -112,16 +107,16 @@ public class RBMKHandler {
// Check if non-rod nodes should be uncached... but now with ReaSim! // Check if non-rod nodes should be uncached... but now with ReaSim!
{ // Yeah, I don't want to contaminate the surrounding scope. { // Yeah, I don't want to contaminate the surrounding scope.
List<RBMKNode> nodes = new ArrayList<>(); List<RBMKNeutronNode> nodes = new ArrayList<>();
points.forEach(nodePos -> { points.forEach(nodePos -> {
RBMKNode node = getNode(nodePos); RBMKNeutronNode node = (RBMKNeutronNode) NeutronNodeWorld.getNode(nodePos);
if (node != null) if (node != null)
nodes.add(node); nodes.add(node);
}); });
boolean hasRod = false; boolean hasRod = false;
for (RBMKNode node : nodes) { for (RBMKNeutronNode node : nodes) {
if (node.tile instanceof TileEntityRBMKRod) { if (node.tile instanceof TileEntityRBMKRod) {
@ -141,11 +136,11 @@ public class RBMKHandler {
} }
// Check if non-rod nodes should be uncached due to no rod in range. // Check if non-rod nodes should be uncached due to no rod in range.
for (NeutronStream stream : streams) { for (RBMKNeutronStream stream : streams) {
List<RBMKNode> nodes = stream.getNodes(false); List<RBMKNeutronNode> nodes = stream.getNodes(false);
for (RBMKNode node : nodes) { for (RBMKNeutronNode node : nodes) {
if (node.tile instanceof TileEntityRBMKRod) if (node.tile instanceof TileEntityRBMKRod)
return list; return list;
} }
@ -162,84 +157,21 @@ public class RBMKHandler {
} }
} }
public static RBMKNode makeNode(TileEntityRBMKBase tile) {
BlockPos pos = new BlockPos(tile);
if (nodeCache.containsKey(pos))
return getNode(pos);
if (!tile.hasWorldObj())
return new RBMKNode(tile, tile.getRBMKType(), true);
return new RBMKNode(tile, tile.getRBMKType());
}
public static class StreamWorld { public static class RBMKNeutronStream extends NeutronStream {
List<NeutronStream> streams; public RBMKNeutronStream(NeutronNode origin, Vec3 vector) {
super(origin, vector);
public StreamWorld() {
streams = new ArrayList<>();
} }
public void addStream(NeutronStream stream) { public RBMKNeutronStream(NeutronNode origin, Vec3 vector, double flux, double ratio) {
this.streams.add(stream); super(origin, vector, flux, ratio, NeutronType.RBMK);
}
public void removeAllStreams() {
this.streams.clear();
}
}
public static class NeutronStream {
public RBMKNode origin;
// doubles!!
public double fluxQuantity;
// Hey, new implementation! Basically a ratio for slow flux to fast flux
// 0 = all slow flux
// 1 = all fast flux
public double fluxRatio;
// Vector for direction of neutron flow.
public Vec3 vector;
// Primarily used as a "dummy stream", not to be added to the streams list.
public NeutronStream(RBMKNode origin, Vec3 vector) {
this.origin = origin;
this.vector = vector;
}
public NeutronStream(RBMKNode origin, Vec3 vector, double flux, double ratio) {
this.origin = origin;
this.vector = vector;
this.fluxQuantity = flux;
this.fluxRatio = ratio;
World worldObj = origin.tile.getWorldObj();
if (streamWorlds.get(worldObj) == null) {
StreamWorld world = new StreamWorld();
world.addStream(this);
streamWorlds.put(worldObj, world);
} else
streamWorlds.get(worldObj).addStream(this);
}
// USES THE CACHE!!!
public List<BlockPos> getBlocks() {
List<BlockPos> positions = new ArrayList<>();
for (int i = 1; i <= fluxRange; i++) {
int x = (int) Math.floor(0.5 + vector.xCoord * i);
int z = (int) Math.floor(0.5 + vector.zCoord * i);
BlockPos pos = new BlockPos(origin.tile).add(x, 0, z);
positions.add(pos);
}
return positions;
} }
// Does NOT include the origin node // Does NOT include the origin node
// USES THE CACHE!!! // USES THE CACHE!!!
public List<RBMKNode> getNodes(boolean addNode) { public List<RBMKNeutronNode> getNodes(boolean addNode) {
List<RBMKNode> positions = new ArrayList<>(); List<RBMKNeutronNode> positions = new ArrayList<>();
for (int i = 1; i <= fluxRange; i++) { for (int i = 1; i <= fluxRange; i++) {
int x = (int) Math.floor(0.5 + vector.xCoord * i); int x = (int) Math.floor(0.5 + vector.xCoord * i);
@ -247,17 +179,17 @@ public class RBMKHandler {
BlockPos pos = new BlockPos(origin.tile).add(x, 0, z); BlockPos pos = new BlockPos(origin.tile).add(x, 0, z);
if (nodeCache.containsKey(pos)) if (NeutronNodeWorld.nodeCache.containsKey(pos))
positions.add(getNode(pos)); positions.add((RBMKNeutronNode) NeutronNodeWorld.getNode(pos));
else if (this.origin.tile.getBlockType() instanceof RBMKBase) { else if (this.origin.tile.getBlockType() instanceof RBMKBase) {
TileEntity te = blockPosToTE(this.origin.tile.getWorldObj(), pos); TileEntity te = blockPosToTE(this.origin.tile.getWorldObj(), pos);
if (te instanceof TileEntityRBMKBase) { if (te instanceof TileEntityRBMKBase) {
TileEntityRBMKBase rbmkBase = (TileEntityRBMKBase)te; TileEntityRBMKBase rbmkBase = (TileEntityRBMKBase) te;
RBMKNode node = makeNode(rbmkBase); RBMKNeutronNode node = makeNode(rbmkBase);
positions.add(node); positions.add(node);
if (addNode) if (addNode)
addNode(node); NeutronNodeWorld.addNode(node);
} }
} }
} }
@ -268,36 +200,36 @@ public class RBMKHandler {
public void runStreamInteraction(World worldObj) { public void runStreamInteraction(World worldObj) {
// do nothing if there's nothing to do lmao // do nothing if there's nothing to do lmao
if(fluxQuantity == 0D) if (fluxQuantity == 0D)
return; return;
BlockPos pos = new BlockPos(origin.tile); BlockPos pos = new BlockPos(origin.tile);
TileEntityRBMKBase originTE; TileEntityRBMKBase originTE;
if (nodeCache.containsKey(pos)) if (NeutronNodeWorld.nodeCache.containsKey(pos))
originTE = nodeCache.get(pos).tile; originTE = (TileEntityRBMKBase) NeutronNodeWorld.nodeCache.get(pos).tile;
else { else {
originTE = (TileEntityRBMKBase) blockPosToTE(worldObj, pos); originTE = (TileEntityRBMKBase) blockPosToTE(worldObj, pos);
if(originTE == null) if (originTE == null)
return; // Doesn't exist anymore! return; // Doesn't exist anymore!
addNode(new RBMKNode(originTE, originTE.getRBMKType())); NeutronNodeWorld.addNode(new RBMKNeutronNode(originTE, originTE.getRBMKType(), originTE.hasLid()));
} }
int moderatedCount = 0; int moderatedCount = 0;
for(BlockPos nodePos : getBlocks()) { for (BlockPos nodePos : getBlocks(fluxRange)) {
if(fluxQuantity == 0D) // Whoops, used it all up! if (fluxQuantity == 0D) // Whoops, used it all up!
return; return;
RBMKNode node = nodeCache.get(nodePos); RBMKNeutronNode node = (RBMKNeutronNode) NeutronNodeWorld.nodeCache.get(nodePos);
if(node == null) { if (node == null) {
TileEntity te = blockPosToTE(worldObj, nodePos); // ok, maybe it didn't get added to the list somehow?? TileEntity te = blockPosToTE(worldObj, nodePos); // ok, maybe it didn't get added to the list somehow??
if (te instanceof TileEntityRBMKBase) { if (te instanceof TileEntityRBMKBase) {
node = makeNode((TileEntityRBMKBase) te); node = makeNode((TileEntityRBMKBase) te);
addNode(node); // whoops! NeutronNodeWorld.addNode(node); // whoops!
} else { } else {
int hits = getHits(nodePos); // Get the amount of hits on blocks. int hits = getHits(nodePos); // Get the amount of hits on blocks.
if (hits == columnHeight) // If stream is fully blocked. if (hits == columnHeight) // If stream is fully blocked.
@ -313,42 +245,44 @@ public class RBMKHandler {
} }
} }
if(node.type == RBMKType.OTHER) // pass right on by! RBMKType type = (RBMKType) node.data.get("type");
if (type == RBMKType.OTHER) // pass right on by!
continue; continue;
// we established earlier during `getNodes()` that they should all be RBMKBase TEs // we established earlier during `getNodes()` that they should all be RBMKBase TEs
// no issue with casting here! // no issue with casting here!
TileEntityRBMKBase nodeTE = node.tile; TileEntityRBMKBase nodeTE = (TileEntityRBMKBase) node.tile;
if(!node.hasLid) if (!(boolean) node.data.get("hasLid"))
ChunkRadiationManager.proxy.incrementRad(worldObj, nodePos.getX(), nodePos.getY(), nodePos.getZ(), (float) (this.fluxQuantity * 0.05F)); ChunkRadiationManager.proxy.incrementRad(worldObj, nodePos.getX(), nodePos.getY(), nodePos.getZ(), (float) (this.fluxQuantity * 0.05F));
if (node.type == RBMKType.MODERATOR || nodeTE.isModerated()) { if (type == RBMKType.MODERATOR || nodeTE.isModerated()) {
moderatedCount++; moderatedCount++;
moderateStream(); moderateStream();
} }
if (nodeTE instanceof IRBMKFluxReceiver) { if (nodeTE instanceof IRBMKFluxReceiver) {
IRBMKFluxReceiver column = (IRBMKFluxReceiver)nodeTE; IRBMKFluxReceiver column = (IRBMKFluxReceiver) nodeTE;
if (node.type == RBMKType.ROD) { if (type == RBMKType.ROD) {
TileEntityRBMKRod rod = (TileEntityRBMKRod)column; TileEntityRBMKRod rod = (TileEntityRBMKRod) column;
if (rod.hasRod) { if (rod.hasRod) {
rod.receiveFlux(this); rod.receiveFlux(this);
return; return;
} }
} else if(node.type == RBMKType.OUTGASSER) { } else if (type == RBMKType.OUTGASSER) {
TileEntityRBMKOutgasser outgasser = ((TileEntityRBMKOutgasser) column); TileEntityRBMKOutgasser outgasser = ((TileEntityRBMKOutgasser) column);
if(outgasser.canProcess()) { if (outgasser.canProcess()) {
column.receiveFlux(this); column.receiveFlux(this);
return; return;
} }
} }
} else if (node.type == RBMKType.CONTROL_ROD) { } else if (type == RBMKType.CONTROL_ROD) {
TileEntityRBMKControl rod = (TileEntityRBMKControl) nodeTE; TileEntityRBMKControl rod = (TileEntityRBMKControl) nodeTE;
if (rod.level > 0.0D) { if (rod.level > 0.0D) {
@ -357,41 +291,43 @@ public class RBMKHandler {
continue; continue;
} }
return; return;
} else if (node.type == RBMKType.REFLECTOR) { } else if (type == RBMKType.REFLECTOR) {
if (this.origin.tile.isModerated()) if (((TileEntityRBMKBase) this.origin.tile).isModerated())
moderatedCount++; moderatedCount++;
if (this.fluxRatio > 0 && moderatedCount > 0) if (this.fluxRatio > 0 && moderatedCount > 0)
for (int i = 0; i < moderatedCount; i++) for (int i = 0; i < moderatedCount; i++)
moderateStream(); moderateStream();
if (RBMKHandler.reflectorEfficiency != 1.0D) { if (reflectorEfficiency != 1.0D) {
this.fluxQuantity *= RBMKHandler.reflectorEfficiency; this.fluxQuantity *= reflectorEfficiency;
continue; continue;
} }
((TileEntityRBMKRod)originTE).receiveFlux(this); ((TileEntityRBMKRod) originTE).receiveFlux(this);
return; return;
} else if (node.type == RBMKType.ABSORBER) { } else if (type == RBMKType.ABSORBER) {
if (RBMKHandler.absorberEfficiency == 1) if (absorberEfficiency == 1)
return; return;
this.fluxQuantity *= RBMKHandler.absorberEfficiency; this.fluxQuantity *= absorberEfficiency;
} }
} }
List<RBMKNode> nodes = getNodes(true); List<RBMKNeutronNode> nodes = getNodes(true);
if (nodes.isEmpty()) if (nodes.isEmpty())
return; return;
RBMKNode lastNode = nodes.get(nodes.size() - 1); RBMKNeutronNode lastNode = nodes.get(nodes.size() - 1);
if (lastNode.type != RBMKType.REFLECTOR && lastNode.type != RBMKType.ABSORBER && lastNode.type != RBMKType.CONTROL_ROD) RBMKType lastNodeType = (RBMKType) lastNode.data.get("type");
if (lastNodeType != RBMKType.REFLECTOR && lastNodeType != RBMKType.ABSORBER && lastNodeType != RBMKType.CONTROL_ROD)
irradiateFromFlux((new BlockPos(lastNode.tile)).add(this.vector.xCoord, 0.0D, this.vector.zCoord)); irradiateFromFlux((new BlockPos(lastNode.tile)).add(this.vector.xCoord, 0.0D, this.vector.zCoord));
if (lastNode.type == RBMKType.CONTROL_ROD) { if (lastNodeType == RBMKType.CONTROL_ROD) {
TileEntityRBMKControl rod = (TileEntityRBMKControl)lastNode.tile; TileEntityRBMKControl rod = (TileEntityRBMKControl) lastNode.tile;
if (rod.getMult() > 0.0D) { if (rod.getMult() > 0.0D) {
this.fluxQuantity *= rod.getMult(); this.fluxQuantity *= rod.getMult();
irradiateFromFlux((new BlockPos(lastNode.tile)).add(this.vector.xCoord, 0.0D, this.vector.zCoord)); irradiateFromFlux((new BlockPos(lastNode.tile)).add(this.vector.xCoord, 0.0D, this.vector.zCoord));
@ -426,32 +362,7 @@ public class RBMKHandler {
public void moderateStream() { public void moderateStream() {
fluxRatio *= (1 - moderatorEfficiency); fluxRatio *= (1 - moderatorEfficiency);
} }
}
// List of all stream worlds.
public static HashMap<World, StreamWorld> streamWorlds = new HashMap<>();
public static void removeAllWorlds() {
streamWorlds.clear();
}
// HashMap of all RBMK nodes and their positions.
protected static HashMap<BlockPos, RBMKNode> nodeCache = new HashMap<>();
public static void addNode(RBMKNode node) {
nodeCache.put(new BlockPos(node.tile), node);
}
public static void removeNode(BlockPos position) {
nodeCache.remove(position);
}
public static RBMKNode getNode(BlockPos position) {
return nodeCache.get(position);
}
public static void removeAllNodes() {
nodeCache.clear();
} }
private static int ticks = 0; private static int ticks = 0;
@ -462,17 +373,17 @@ public class RBMKHandler {
// Remove `StreamWorld` objects if they have no streams. // Remove `StreamWorld` objects if they have no streams.
{ // aflghdkljghlkbhfjkghgilurbhlkfjghkffdjgn { // aflghdkljghlkbhfjkghgilurbhlkfjghkffdjgn
List<World> toRemove = new ArrayList<>(); List<World> toRemove = new ArrayList<>();
streamWorlds.forEach((world, streamWorld) -> { NeutronNodeWorld.streamWorlds.forEach((world, streamWorld) -> {
if (streamWorld.streams.isEmpty()) if (streamWorld.streams.isEmpty())
toRemove.add(world); toRemove.add(world);
}); });
for (World world : toRemove) { for (World world : toRemove) {
streamWorlds.remove(world); NeutronNodeWorld.streamWorlds.remove(world);
} }
} }
for (Entry<World, StreamWorld> world : streamWorlds.entrySet()) { for (Entry<World, NeutronNodeWorld.StreamWorld> world : NeutronNodeWorld.streamWorlds.entrySet()) {
// Gamerule caching because this apparently is kinda slow? // Gamerule caching because this apparently is kinda slow?
// meh, good enough // meh, good enough
@ -487,9 +398,10 @@ public class RBMKHandler {
fluxRange = RBMKDials.getFluxRange(world.getKey()); fluxRange = RBMKDials.getFluxRange(world.getKey());
for (NeutronStream stream : world.getValue().streams) { for (NeutronStream stream : world.getValue().streams) {
stream.runStreamInteraction(world.getKey()); if (stream.type == NeutronStream.NeutronType.RBMK)
stream.runStreamInteraction(world.getKey());
} }
world.getValue().removeAllStreams(); world.getValue().removeAllStreamsOfType(NeutronStream.NeutronType.RBMK);
} }
// Freshen the node cache every `cacheTime` ticks to prevent huge RAM usage. // Freshen the node cache every `cacheTime` ticks to prevent huge RAM usage.
@ -497,11 +409,13 @@ public class RBMKHandler {
if (ticks >= cacheTime) { if (ticks >= cacheTime) {
ticks = 0; ticks = 0;
List<BlockPos> toRemove = new ArrayList<>(); List<BlockPos> toRemove = new ArrayList<>();
for(RBMKNode cachedNode : nodeCache.values()) for(NeutronNode cachedNode : NeutronNodeWorld.nodeCache.values()) {
toRemove.addAll(cachedNode.checkNode()); RBMKNeutronNode node = (RBMKNeutronNode) cachedNode;
toRemove.addAll(node.checkNode());
}
for(BlockPos pos : toRemove) for(BlockPos pos : toRemove)
removeNode(pos); NeutronNodeWorld.removeNode(pos);
} }
ticks++; ticks++;
} }

View File

@ -1,55 +0,0 @@
package com.hbm.handler.rbmkmk2;
import com.hbm.items.machine.ItemRBMKPellet;
import com.hbm.items.machine.ItemRBMKRod;
import net.minecraft.util.MathHelper;
import java.util.function.BiFunction;
import java.util.function.Function;
public class ItemRBMKRodFluxCurve extends ItemRBMKRod {
/** Double 1: Flux ratio in.
* Double 2: Depletion value.
* Return double: Output flux ratio.
**/
BiFunction<Double, Double, Double> ratioCurve;
/** Double 1: Flux quantity in. <br>
* Double 2: Flux ratio in. <br>
* Return double: Output flux quantity.
**/
BiFunction<Double, Double, Double> fluxCurve;
public ItemRBMKRodFluxCurve(ItemRBMKPellet pellet) {
super(pellet);
}
public ItemRBMKRodFluxCurve(String fullName) {
super(fullName);
}
public ItemRBMKRodFluxCurve setOutputRatioCurve(Function<Double, Double> func) {
this.ratioCurve = (fluxRatioIn, depletion) -> func.apply(fluxRatioIn) * 1.0D;
return this;
}
public ItemRBMKRodFluxCurve setDepletionOutputRatioCurve(BiFunction<Double, Double, Double> func) {
this.ratioCurve = func;
return this;
}
public ItemRBMKRodFluxCurve setOutputFluxCurve(BiFunction<Double, Double, Double> func) {
this.fluxCurve = func;
return this;
}
public double fluxRatioOut(double fluxRatioIn, double depletion) {
return MathHelper.clamp_double(ratioCurve.apply(fluxRatioIn, depletion), 0, 1);
}
public double fluxFromRatio(double quantity, double ratio) {
return fluxCurve.apply(quantity, ratio);
}
}

View File

@ -394,7 +394,7 @@ public class HazardRegistry {
registerRBMKRod(rbmk_fuel_zfb_pu241, pu239 * rod_rbmk * 0.1F, wst * rod_rbmk * 7.5F); registerRBMKRod(rbmk_fuel_zfb_pu241, pu239 * rod_rbmk * 0.1F, wst * rod_rbmk * 7.5F);
registerRBMKRod(rbmk_fuel_zfb_am_mix, pu241 * rod_rbmk * 0.1F, wst * rod_rbmk * 10F); registerRBMKRod(rbmk_fuel_zfb_am_mix, pu241 * rod_rbmk * 0.1F, wst * rod_rbmk * 10F);
registerRBMK(rbmk_fuel_drx, bf * rod_rbmk, bf * rod_rbmk * 100F, true, true, 0, 1F/3F); registerRBMK(rbmk_fuel_drx, bf * rod_rbmk, bf * rod_rbmk * 100F, true, true, 0, 1F/3F);
registerRBMKRod(rbmk_fuel_curve, saf * rod_rbmk * np237 * rod_rbmk, wst * rod_rbmk * 35F); //registerRBMKRod(rbmk_fuel_curve, saf * rod_rbmk * np237 * rod_rbmk, wst * rod_rbmk * 35F);
registerRBMKPellet(rbmk_pellet_ueu, u * billet, wst * billet * 20F); registerRBMKPellet(rbmk_pellet_ueu, u * billet, wst * billet * 20F);
registerRBMKPellet(rbmk_pellet_meu, uf * billet, wst * billet * 21.5F); registerRBMKPellet(rbmk_pellet_meu, uf * billet, wst * billet * 21.5F);

View File

@ -7,7 +7,6 @@ import com.hbm.handler.ToolAbility;
import com.hbm.handler.ToolAbility.LuckAbility; import com.hbm.handler.ToolAbility.LuckAbility;
import com.hbm.handler.WeaponAbility; import com.hbm.handler.WeaponAbility;
import com.hbm.handler.guncfg.*; import com.hbm.handler.guncfg.*;
import com.hbm.handler.rbmkmk2.ItemRBMKRodFluxCurve;
import com.hbm.interfaces.ICustomWarhead.SaltedFuel.HalfLifeType; import com.hbm.interfaces.ICustomWarhead.SaltedFuel.HalfLifeType;
import com.hbm.inventory.fluid.Fluids; import com.hbm.inventory.fluid.Fluids;
import com.hbm.inventory.fluid.tank.FluidTank; import com.hbm.inventory.fluid.tank.FluidTank;
@ -1132,7 +1131,7 @@ public class ModItems {
public static ItemRBMKRod rbmk_fuel_zfb_am_mix; public static ItemRBMKRod rbmk_fuel_zfb_am_mix;
public static ItemRBMKRod rbmk_fuel_drx; public static ItemRBMKRod rbmk_fuel_drx;
public static ItemRBMKRod rbmk_fuel_test; public static ItemRBMKRod rbmk_fuel_test;
public static ItemRBMKRodFluxCurve rbmk_fuel_curve; //public static ItemRBMKRod rbmk_fuel_curve;
public static ItemRBMKPellet rbmk_pellet_ueu; public static ItemRBMKPellet rbmk_pellet_ueu;
public static ItemRBMKPellet rbmk_pellet_meu; public static ItemRBMKPellet rbmk_pellet_meu;
public static ItemRBMKPellet rbmk_pellet_heu233; public static ItemRBMKPellet rbmk_pellet_heu233;
@ -3763,15 +3762,18 @@ public class ModItems {
.setHeat(1.0D) .setHeat(1.0D)
.setMeltingPoint(100000) .setMeltingPoint(100000)
.setUnlocalizedName("rbmk_fuel_test").setTextureName(RefStrings.MODID + ":rbmk_fuel_test"); .setUnlocalizedName("rbmk_fuel_test").setTextureName(RefStrings.MODID + ":rbmk_fuel_test");
rbmk_fuel_curve = (ItemRBMKRodFluxCurve) new ItemRBMKRodFluxCurve("3D curve test") /* Experimental flux curve shit
rbmk_fuel_curve = (ItemRBMKRod) new ItemRBMKRod("3D Flux Curve Test")
.setFluxCurve(true)
.setOutputFluxCurve((fluxQuantity, fluxRatio) -> fluxQuantity * (1 - Math.pow(fluxRatio, 2))) .setOutputFluxCurve((fluxQuantity, fluxRatio) -> fluxQuantity * (1 - Math.pow(fluxRatio, 2)))
.setDepletionOutputRatioCurve((ratioIn, depletion) -> Math.pow(ratioIn, 2) * depletion) .setDepletionOutputRatioCurve((ratioIn, depletion) -> Math.pow(ratioIn, 2) * depletion)
.setYield(1000000D) .setYield(1000000D)
.setStats(100) .setStats(75)
.setFunction(EnumBurnFunc.EXPERIMENTAL) .setFunction(EnumBurnFunc.SQUARE_ROOT)
.setHeat(1.0D) .setHeat(1.5D)
.setMeltingPoint(100000) .setMeltingPoint(100000)
.setUnlocalizedName("rbmk_fuel_curve").setTextureName(RefStrings.MODID + ":rbmk_fuel_curve"); .setUnlocalizedName("rbmk_fuel_curve").setTextureName(RefStrings.MODID + ":rbmk_fuel_curve");
*/
watz_pellet = new ItemWatzPellet().setUnlocalizedName("watz_pellet").setTextureName(RefStrings.MODID + ":watz_pellet"); watz_pellet = new ItemWatzPellet().setUnlocalizedName("watz_pellet").setTextureName(RefStrings.MODID + ":watz_pellet");
watz_pellet_depleted = new ItemWatzPellet().setUnlocalizedName("watz_pellet_depleted").setTextureName(RefStrings.MODID + ":watz_pellet"); watz_pellet_depleted = new ItemWatzPellet().setUnlocalizedName("watz_pellet_depleted").setTextureName(RefStrings.MODID + ":watz_pellet");
@ -6613,7 +6615,7 @@ public class ModItems {
GameRegistry.registerItem(rbmk_fuel_zfb_am_mix, rbmk_fuel_zfb_am_mix.getUnlocalizedName()); GameRegistry.registerItem(rbmk_fuel_zfb_am_mix, rbmk_fuel_zfb_am_mix.getUnlocalizedName());
GameRegistry.registerItem(rbmk_fuel_drx, rbmk_fuel_drx.getUnlocalizedName()); GameRegistry.registerItem(rbmk_fuel_drx, rbmk_fuel_drx.getUnlocalizedName());
GameRegistry.registerItem(rbmk_fuel_test, rbmk_fuel_test.getUnlocalizedName()); GameRegistry.registerItem(rbmk_fuel_test, rbmk_fuel_test.getUnlocalizedName());
GameRegistry.registerItem(rbmk_fuel_curve, rbmk_fuel_curve.getUnlocalizedName()); //GameRegistry.registerItem(rbmk_fuel_curve, rbmk_fuel_curve.getUnlocalizedName());
GameRegistry.registerItem(rbmk_pellet_ueu, rbmk_pellet_ueu.getUnlocalizedName()); GameRegistry.registerItem(rbmk_pellet_ueu, rbmk_pellet_ueu.getUnlocalizedName());
GameRegistry.registerItem(rbmk_pellet_meu, rbmk_pellet_meu.getUnlocalizedName()); GameRegistry.registerItem(rbmk_pellet_meu, rbmk_pellet_meu.getUnlocalizedName());

View File

@ -2,7 +2,8 @@ package com.hbm.items.machine;
import com.hbm.blocks.ModBlocks; import com.hbm.blocks.ModBlocks;
import com.hbm.blocks.machine.rbmk.RBMKBase; import com.hbm.blocks.machine.rbmk.RBMKBase;
import com.hbm.handler.rbmkmk2.RBMKHandler; import com.hbm.handler.neutron.NeutronNodeWorld;
import com.hbm.handler.neutron.RBMKNeutronHandler.RBMKNeutronNode;
import com.hbm.items.ModItems; import com.hbm.items.ModItems;
import com.hbm.tileentity.machine.rbmk.TileEntityRBMKBase; import com.hbm.tileentity.machine.rbmk.TileEntityRBMKBase;
@ -15,8 +16,6 @@ import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World; import net.minecraft.world.World;
import static com.hbm.handler.rbmkmk2.RBMKHandler.getNode;
public class ItemRBMKLid extends Item { public class ItemRBMKLid extends Item {
@Override @Override
@ -42,7 +41,7 @@ public class ItemRBMKLid extends Item {
if(tile.hasLid()) if(tile.hasLid())
return false; return false;
RBMKHandler.RBMKNode node = getNode(new BlockPos(te)); RBMKNeutronNode node = (RBMKNeutronNode) NeutronNodeWorld.getNode(new BlockPos(te));
if (node != null) if (node != null)
node.addLid(); node.addLid();

View File

@ -2,6 +2,8 @@ package com.hbm.items.machine;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.function.BiFunction;
import java.util.function.Function;
import com.hbm.items.ModItems; import com.hbm.items.ModItems;
import com.hbm.main.MainRegistry; import com.hbm.main.MainRegistry;
@ -14,6 +16,7 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World; import net.minecraft.world.World;
public class ItemRBMKRod extends Item { public class ItemRBMKRod extends Item {
@ -241,7 +244,7 @@ public class ItemRBMKRod extends Item {
} }
/** /**
* @param reactivity [0;100] ...or at least those are sane levels * @param enrichment [0;100] ...or at least those are sane levels
* @return the amount of reactivity yielded, unmodified by xenon * @return the amount of reactivity yielded, unmodified by xenon
*/ */
public double reactivityFunc(double in, double enrichment) { public double reactivityFunc(double in, double enrichment) {
@ -355,7 +358,55 @@ public class ItemRBMKRod extends Item {
public static double getPoisonLevel(ItemStack stack) { public static double getPoisonLevel(ItemStack stack) {
return getPoison(stack) / 100D; return getPoison(stack) / 100D;
} }
// START Special flux curve handling!
// Nothing really uses this yet, though it's a really fun feature to play around with.
// For the RBMK handler to see if the rod is special.
public boolean specialFluxCurve = false;
public ItemRBMKRod setFluxCurve(boolean bool) {
specialFluxCurve = bool;
return this;
}
/** Double 1: Flux ratio in.
* Double 2: Depletion value.
* Return double: Output flux ratio.
**/
BiFunction<Double, Double, Double> ratioCurve;
/** Double 1: Flux quantity in. <br>
* Double 2: Flux ratio in. <br>
* Return double: Output flux quantity.
**/
BiFunction<Double, Double, Double> fluxCurve;
public ItemRBMKRod setOutputRatioCurve(Function<Double, Double> func) {
this.ratioCurve = (fluxRatioIn, depletion) -> func.apply(fluxRatioIn) * 1.0D;
return this;
}
public ItemRBMKRod setDepletionOutputRatioCurve(BiFunction<Double, Double, Double> func) {
this.ratioCurve = func;
return this;
}
public ItemRBMKRod setOutputFluxCurve(BiFunction<Double, Double, Double> func) {
this.fluxCurve = func;
return this;
}
public double fluxRatioOut(double fluxRatioIn, double depletion) {
return MathHelper.clamp_double(ratioCurve.apply(fluxRatioIn, depletion), 0, 1);
}
public double fluxFromRatio(double quantity, double ratio) {
return fluxCurve.apply(quantity, ratio);
}
// END Special flux curve handling.
@Override @Override
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool) { public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool) {

View File

@ -9,7 +9,9 @@ import java.util.Map;
import java.util.Random; import java.util.Random;
import java.util.UUID; import java.util.UUID;
import com.hbm.handler.rbmkmk2.RBMKHandler; import com.hbm.handler.neutron.NeutronNodeWorld;
import com.hbm.handler.neutron.PileNeutronHandler;
import com.hbm.handler.neutron.RBMKNeutronHandler;
import org.apache.commons.lang3.math.NumberUtils; import org.apache.commons.lang3.math.NumberUtils;
import org.apache.logging.log4j.Level; import org.apache.logging.log4j.Level;
@ -537,8 +539,8 @@ public class ModEventHandler {
@SubscribeEvent @SubscribeEvent
public void onUnload(WorldEvent.Unload event) { public void onUnload(WorldEvent.Unload event) {
RBMKHandler.removeAllWorlds(); // Remove world from worlds when unloaded to avoid world issues. NeutronNodeWorld.StreamWorld.removeAllWorlds(); // Remove world from worlds when unloaded to avoid world issues.
RBMKHandler.removeAllNodes(); // Remove all nodes. NeutronNodeWorld.removeAllNodes(); // Remove all nodes.
} }
public static boolean didSit = false; public static boolean didSit = false;
@ -1151,7 +1153,9 @@ public class ModEventHandler {
TileEntityMachineRadarNT.updateSystem(); TileEntityMachineRadarNT.updateSystem();
Nodespace.updateNodespace(); Nodespace.updateNodespace();
// RBMK!!!! // RBMK!!!!
RBMKHandler.runAllInteractions(); RBMKNeutronHandler.runAllInteractions();
// Chicago Pile!!!!
PileNeutronHandler.runAllInteractions();
} }
} }

View File

@ -1,6 +1,6 @@
package com.hbm.tileentity.machine.rbmk; package com.hbm.tileentity.machine.rbmk;
import com.hbm.handler.rbmkmk2.RBMKHandler; import com.hbm.handler.neutron.NeutronStream;
public interface IRBMKFluxReceiver { public interface IRBMKFluxReceiver {
@ -16,5 +16,5 @@ public interface IRBMKFluxReceiver {
} }
} }
public void receiveFlux(RBMKHandler.NeutronStream stream); public void receiveFlux(NeutronStream stream);
} }

View File

@ -1,7 +1,7 @@
package com.hbm.tileentity.machine.rbmk; package com.hbm.tileentity.machine.rbmk;
import com.hbm.entity.projectile.EntityRBMKDebris.DebrisType; import com.hbm.entity.projectile.EntityRBMKDebris.DebrisType;
import com.hbm.handler.rbmkmk2.RBMKHandler; import com.hbm.handler.neutron.RBMKNeutronHandler.RBMKType;
import com.hbm.tileentity.machine.rbmk.TileEntityRBMKConsole.ColumnType; import com.hbm.tileentity.machine.rbmk.TileEntityRBMKConsole.ColumnType;
public class TileEntityRBMKAbsorber extends TileEntityRBMKBase { public class TileEntityRBMKAbsorber extends TileEntityRBMKBase {
@ -19,8 +19,8 @@ public class TileEntityRBMKAbsorber extends TileEntityRBMKBase {
} }
@Override @Override
public RBMKHandler.RBMKType getRBMKType() { public RBMKType getRBMKType() {
return RBMKHandler.RBMKType.ABSORBER; return RBMKType.ABSORBER;
} }
@Override @Override

View File

@ -8,8 +8,9 @@ import com.hbm.blocks.machine.rbmk.RBMKBase;
import com.hbm.entity.effect.EntitySpear; import com.hbm.entity.effect.EntitySpear;
import com.hbm.entity.projectile.EntityRBMKDebris; import com.hbm.entity.projectile.EntityRBMKDebris;
import com.hbm.entity.projectile.EntityRBMKDebris.DebrisType; import com.hbm.entity.projectile.EntityRBMKDebris.DebrisType;
import com.hbm.handler.rbmkmk2.RBMKHandler; import com.hbm.handler.neutron.NeutronNodeWorld;
import com.hbm.handler.rbmkmk2.RBMKHandler.RBMKType; import com.hbm.handler.neutron.RBMKNeutronHandler;
import com.hbm.handler.neutron.RBMKNeutronHandler.RBMKType;
import com.hbm.main.MainRegistry; import com.hbm.main.MainRegistry;
import com.hbm.packet.AuxParticlePacketNT; import com.hbm.packet.AuxParticlePacketNT;
import com.hbm.packet.BufPacket; import com.hbm.packet.BufPacket;
@ -42,7 +43,12 @@ import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import java.util.*; import java.util.List;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Set;
import java.util.HashSet;
import java.util.Iterator;
/** /**
* Base class for all RBMK components, active or passive. Handles heat and the explosion sequence * Base class for all RBMK components, active or passive. Handles heat and the explosion sequence
@ -220,7 +226,7 @@ public abstract class TileEntityRBMKBase extends TileEntityLoadedBase implements
public void invalidate() { public void invalidate() {
super.invalidate(); super.invalidate();
RBMKHandler.removeNode(new BlockPos(this)); // woo-fucking-hoo!!! NeutronNodeWorld.removeNode(new BlockPos(this)); // woo-fucking-hoo!!!
} }
@Override @Override
@ -246,13 +252,15 @@ public abstract class TileEntityRBMKBase extends TileEntityLoadedBase implements
heat = 20D; heat = 20D;
} }
public abstract RBMKType getRBMKType(); public RBMKType getRBMKType() {
return RBMKType.OTHER;
}
protected static boolean diag = false; protected static boolean diag = false;
@Override @Override
public void readFromNBT(NBTTagCompound nbt) { public void readFromNBT(NBTTagCompound nbt) {
if(!diag) { if(!diag) {
super.readFromNBT(nbt); super.readFromNBT(nbt);
} }

View File

@ -1,7 +1,6 @@
package com.hbm.tileentity.machine.rbmk; package com.hbm.tileentity.machine.rbmk;
import com.hbm.entity.projectile.EntityRBMKDebris.DebrisType; import com.hbm.entity.projectile.EntityRBMKDebris.DebrisType;
import com.hbm.handler.rbmkmk2.RBMKHandler;
import com.hbm.tileentity.machine.rbmk.TileEntityRBMKConsole.ColumnType; import com.hbm.tileentity.machine.rbmk.TileEntityRBMKConsole.ColumnType;
public class TileEntityRBMKBlank extends TileEntityRBMKBase { public class TileEntityRBMKBlank extends TileEntityRBMKBase {
@ -18,11 +17,6 @@ public class TileEntityRBMKBlank extends TileEntityRBMKBase {
super.onMelt(reduce); super.onMelt(reduce);
} }
@Override
public RBMKHandler.RBMKType getRBMKType() {
return RBMKHandler.RBMKType.OTHER;
}
@Override @Override
public ColumnType getConsoleType() { public ColumnType getConsoleType() {
return ColumnType.BLANK; return ColumnType.BLANK;

View File

@ -8,7 +8,6 @@ import api.hbm.tile.IInfoProviderEC;
import com.hbm.blocks.ModBlocks; import com.hbm.blocks.ModBlocks;
import com.hbm.entity.projectile.EntityRBMKDebris.DebrisType; import com.hbm.entity.projectile.EntityRBMKDebris.DebrisType;
import com.hbm.handler.CompatHandler; import com.hbm.handler.CompatHandler;
import com.hbm.handler.rbmkmk2.RBMKHandler;
import com.hbm.interfaces.IControlReceiver; import com.hbm.interfaces.IControlReceiver;
import com.hbm.inventory.container.ContainerRBMKGeneric; import com.hbm.inventory.container.ContainerRBMKGeneric;
import com.hbm.inventory.fluid.FluidType; import com.hbm.inventory.fluid.FluidType;
@ -224,11 +223,6 @@ public class TileEntityRBMKBoiler extends TileEntityRBMKSlottedBase implements I
super.onMelt(reduce); super.onMelt(reduce);
} }
@Override
public RBMKHandler.RBMKType getRBMKType() {
return RBMKHandler.RBMKType.OTHER;
}
@Override @Override
public ColumnType getConsoleType() { public ColumnType getConsoleType() {
return ColumnType.BOILER; return ColumnType.BOILER;

View File

@ -2,7 +2,7 @@ package com.hbm.tileentity.machine.rbmk;
import com.hbm.entity.projectile.EntityRBMKDebris.DebrisType; import com.hbm.entity.projectile.EntityRBMKDebris.DebrisType;
import com.hbm.handler.CompatHandler; import com.hbm.handler.CompatHandler;
import com.hbm.handler.rbmkmk2.RBMKHandler; import com.hbm.handler.neutron.RBMKNeutronHandler.RBMKType;
import cpw.mods.fml.common.Optional; 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;
@ -132,8 +132,8 @@ public abstract class TileEntityRBMKControl extends TileEntityRBMKSlottedBase im
} }
@Override @Override
public RBMKHandler.RBMKType getRBMKType() { public RBMKType getRBMKType() {
return RBMKHandler.RBMKType.CONTROL_ROD; return RBMKType.CONTROL_ROD;
} }
@Override @Override

View File

@ -2,7 +2,6 @@ package com.hbm.tileentity.machine.rbmk;
import api.hbm.fluid.IFluidStandardReceiver; import api.hbm.fluid.IFluidStandardReceiver;
import com.hbm.handler.CompatHandler; import com.hbm.handler.CompatHandler;
import com.hbm.handler.rbmkmk2.RBMKHandler;
import com.hbm.inventory.fluid.Fluids; import com.hbm.inventory.fluid.Fluids;
import com.hbm.inventory.fluid.tank.FluidTank; import com.hbm.inventory.fluid.tank.FluidTank;
import com.hbm.lib.Library; import com.hbm.lib.Library;
@ -17,7 +16,6 @@ import net.minecraft.entity.Entity;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource; import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper;
import java.util.List; import java.util.List;
@ -118,11 +116,6 @@ public class TileEntityRBMKCooler extends TileEntityRBMKBase implements IFluidSt
this.lastCooled = buf.readInt(); this.lastCooled = buf.readInt();
} }
@Override
public RBMKHandler.RBMKType getRBMKType() {
return RBMKHandler.RBMKType.OTHER;
}
@Override @Override
public ColumnType getConsoleType() { public ColumnType getConsoleType() {
return ColumnType.COOLER; return ColumnType.COOLER;

View File

@ -4,7 +4,6 @@ import api.hbm.fluid.IFluidStandardTransceiver;
import com.hbm.blocks.ModBlocks; import com.hbm.blocks.ModBlocks;
import com.hbm.entity.projectile.EntityRBMKDebris.DebrisType; import com.hbm.entity.projectile.EntityRBMKDebris.DebrisType;
import com.hbm.handler.CompatHandler; import com.hbm.handler.CompatHandler;
import com.hbm.handler.rbmkmk2.RBMKHandler;
import com.hbm.inventory.container.ContainerRBMKHeater; import com.hbm.inventory.container.ContainerRBMKHeater;
import com.hbm.inventory.fluid.Fluids; import com.hbm.inventory.fluid.Fluids;
import com.hbm.inventory.fluid.tank.FluidTank; import com.hbm.inventory.fluid.tank.FluidTank;
@ -154,11 +153,6 @@ public class TileEntityRBMKHeater extends TileEntityRBMKSlottedBase implements I
super.onMelt(reduce); super.onMelt(reduce);
} }
@Override
public RBMKHandler.RBMKType getRBMKType() {
return RBMKHandler.RBMKType.OTHER;
}
@Override @Override
public ColumnType getConsoleType() { public ColumnType getConsoleType() {
return ColumnType.HEATEX; return ColumnType.HEATEX;

View File

@ -1,7 +1,7 @@
package com.hbm.tileentity.machine.rbmk; package com.hbm.tileentity.machine.rbmk;
import com.hbm.entity.projectile.EntityRBMKDebris.DebrisType; import com.hbm.entity.projectile.EntityRBMKDebris.DebrisType;
import com.hbm.handler.rbmkmk2.RBMKHandler; import com.hbm.handler.neutron.RBMKNeutronHandler.RBMKType;
import com.hbm.tileentity.machine.rbmk.TileEntityRBMKConsole.ColumnType; import com.hbm.tileentity.machine.rbmk.TileEntityRBMKConsole.ColumnType;
public class TileEntityRBMKModerator extends TileEntityRBMKBase { public class TileEntityRBMKModerator extends TileEntityRBMKBase {
@ -19,8 +19,8 @@ public class TileEntityRBMKModerator extends TileEntityRBMKBase {
} }
@Override @Override
public RBMKHandler.RBMKType getRBMKType() { public RBMKType getRBMKType() {
return RBMKHandler.RBMKType.MODERATOR; return RBMKType.MODERATOR;
} }
@Override @Override

View File

@ -4,7 +4,8 @@ import api.hbm.fluid.IFluidStandardSender;
import com.hbm.blocks.ModBlocks; import com.hbm.blocks.ModBlocks;
import com.hbm.entity.projectile.EntityRBMKDebris.DebrisType; import com.hbm.entity.projectile.EntityRBMKDebris.DebrisType;
import com.hbm.handler.CompatHandler; import com.hbm.handler.CompatHandler;
import com.hbm.handler.rbmkmk2.RBMKHandler; import com.hbm.handler.neutron.NeutronStream;
import com.hbm.handler.neutron.RBMKNeutronHandler;
import com.hbm.inventory.FluidStack; import com.hbm.inventory.FluidStack;
import com.hbm.inventory.container.ContainerRBMKOutgasser; import com.hbm.inventory.container.ContainerRBMKOutgasser;
import com.hbm.inventory.fluid.Fluids; import com.hbm.inventory.fluid.Fluids;
@ -92,7 +93,7 @@ public class TileEntityRBMKOutgasser extends TileEntityRBMKSlottedBase implement
} }
@Override @Override
public void receiveFlux(RBMKHandler.NeutronStream stream) { public void receiveFlux(NeutronStream stream) {
if(canProcess()) { if(canProcess()) {
@ -167,8 +168,8 @@ public class TileEntityRBMKOutgasser extends TileEntityRBMKSlottedBase implement
} }
@Override @Override
public RBMKHandler.RBMKType getRBMKType() { public RBMKNeutronHandler.RBMKType getRBMKType() {
return RBMKHandler.RBMKType.OUTGASSER; return RBMKNeutronHandler.RBMKType.OUTGASSER;
} }
@Override @Override

View File

@ -1,7 +1,7 @@
package com.hbm.tileentity.machine.rbmk; package com.hbm.tileentity.machine.rbmk;
import com.hbm.entity.projectile.EntityRBMKDebris.DebrisType; import com.hbm.entity.projectile.EntityRBMKDebris.DebrisType;
import com.hbm.handler.rbmkmk2.RBMKHandler; import com.hbm.handler.neutron.RBMKNeutronHandler;
import com.hbm.tileentity.machine.rbmk.TileEntityRBMKConsole.ColumnType; import com.hbm.tileentity.machine.rbmk.TileEntityRBMKConsole.ColumnType;
public class TileEntityRBMKReflector extends TileEntityRBMKBase { public class TileEntityRBMKReflector extends TileEntityRBMKBase {
@ -19,8 +19,8 @@ public class TileEntityRBMKReflector extends TileEntityRBMKBase {
} }
@Override @Override
public RBMKHandler.RBMKType getRBMKType() { public RBMKNeutronHandler.RBMKType getRBMKType() {
return RBMKHandler.RBMKType.REFLECTOR; return RBMKNeutronHandler.RBMKType.REFLECTOR;
} }
@Override @Override

View File

@ -5,10 +5,11 @@ import com.hbm.blocks.machine.rbmk.RBMKBase;
import com.hbm.blocks.machine.rbmk.RBMKRod; import com.hbm.blocks.machine.rbmk.RBMKRod;
import com.hbm.entity.projectile.EntityRBMKDebris.DebrisType; import com.hbm.entity.projectile.EntityRBMKDebris.DebrisType;
import com.hbm.handler.CompatHandler; import com.hbm.handler.CompatHandler;
import com.hbm.handler.neutron.NeutronNodeWorld;
import com.hbm.handler.neutron.NeutronStream;
import com.hbm.handler.neutron.RBMKNeutronHandler;
import com.hbm.handler.radiation.ChunkRadiationManager; import com.hbm.handler.radiation.ChunkRadiationManager;
import com.hbm.handler.rbmkmk2.RBMKHandler; import com.hbm.handler.neutron.RBMKNeutronHandler.RBMKNeutronNode;
import com.hbm.handler.rbmkmk2.RBMKHandler.NeutronStream;
import com.hbm.handler.rbmkmk2.ItemRBMKRodFluxCurve;
import com.hbm.inventory.container.ContainerRBMKRod; import com.hbm.inventory.container.ContainerRBMKRod;
import com.hbm.inventory.gui.GUIRBMKRod; import com.hbm.inventory.gui.GUIRBMKRod;
import com.hbm.items.ModItems; import com.hbm.items.ModItems;
@ -40,8 +41,6 @@ import net.minecraftforge.common.util.ForgeDirection;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import static com.hbm.handler.rbmkmk2.RBMKHandler.*;
@Optional.InterfaceList({@Optional.Interface(iface = "li.cil.oc.api.network.SimpleComponent", modid = "OpenComputers")}) @Optional.InterfaceList({@Optional.Interface(iface = "li.cil.oc.api.network.SimpleComponent", modid = "OpenComputers")})
public class TileEntityRBMKRod extends TileEntityRBMKSlottedBase implements IRBMKFluxReceiver, IRBMKLoadable, SimpleComponent, IInfoProviderEC, CompatHandler.OCComponent { public class TileEntityRBMKRod extends TileEntityRBMKSlottedBase implements IRBMKFluxReceiver, IRBMKLoadable, SimpleComponent, IInfoProviderEC, CompatHandler.OCComponent {
@ -93,14 +92,15 @@ public class TileEntityRBMKRod extends TileEntityRBMKSlottedBase implements IRBM
double fluxRatioOut; double fluxRatioOut;
double fluxQuantityOut; double fluxQuantityOut;
if (rod instanceof ItemRBMKRodFluxCurve) { // Experimental flux ratio curve rods! // Experimental flux ratio curve rods!
ItemRBMKRodFluxCurve rodCurve = (ItemRBMKRodFluxCurve) rod; // Again, nothing really uses this so its just idle code at the moment.
if (rod.specialFluxCurve) {
fluxRatioOut = rodCurve.fluxRatioOut(this.fluxRatio, ItemRBMKRod.getEnrichment(slots[0])); fluxRatioOut = rod.fluxRatioOut(this.fluxRatio, ItemRBMKRod.getEnrichment(slots[0]));
double fluxIn; double fluxIn;
fluxIn = rodCurve.fluxFromRatio(this.fluxQuantity, this.fluxRatio); fluxIn = rod.fluxFromRatio(this.fluxQuantity, this.fluxRatio);
fluxQuantityOut = rod.burn(worldObj, slots[0], fluxIn); fluxQuantityOut = rod.burn(worldObj, slots[0], fluxIn);
} else { } else {
@ -182,15 +182,15 @@ public class TileEntityRBMKRod extends TileEntityRBMKSlottedBase implements IRBM
if (flux == 0) { if (flux == 0) {
// simple way to remove the node from the cache when no flux is going into it! // simple way to remove the node from the cache when no flux is going into it!
removeNode(pos); NeutronNodeWorld.removeNode(pos);
return; return;
} }
RBMKHandler.RBMKNode node = getNode(pos); RBMKNeutronNode node = (RBMKNeutronNode) NeutronNodeWorld.getNode(pos);
if(node == null) { if(node == null) {
node = RBMKHandler.makeNode(this); node = RBMKNeutronHandler.makeNode(this);
addNode(node); NeutronNodeWorld.addNode(node);
} }
for(ForgeDirection dir : fluxDirs) { for(ForgeDirection dir : fluxDirs) {
@ -198,7 +198,7 @@ public class TileEntityRBMKRod extends TileEntityRBMKSlottedBase implements IRBM
Vec3 neutronVector = Vec3.createVectorHelper(dir.offsetX, dir.offsetY, dir.offsetZ); Vec3 neutronVector = Vec3.createVectorHelper(dir.offsetX, dir.offsetY, dir.offsetZ);
// Create new neutron streams // Create new neutron streams
new NeutronStream(node, neutronVector, flux, ratio); new RBMKNeutronHandler.RBMKNeutronStream(node, neutronVector, flux, ratio);
} }
} }
@ -215,7 +215,7 @@ public class TileEntityRBMKRod extends TileEntityRBMKSlottedBase implements IRBM
this.fluxRatio = 0; this.fluxRatio = 0;
} else { } else {
this.fluxQuantity = nbt.getDouble("fluxQuantity"); this.fluxQuantity = nbt.getDouble("fluxQuantity");
this.fluxRatio = nbt.getDouble("fluxRatio"); this.fluxRatio = nbt.getDouble("fluxMod");
} }
this.hasRod = nbt.getBoolean("hasRod"); this.hasRod = nbt.getBoolean("hasRod");
} }
@ -223,8 +223,17 @@ public class TileEntityRBMKRod extends TileEntityRBMKSlottedBase implements IRBM
public void writeToNBT(NBTTagCompound nbt) { public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt); super.writeToNBT(nbt);
nbt.setDouble("fluxSlow", this.lastFluxQuantity * (1 - fluxRatio)); nbt.setDouble("fluxQuantity", this.fluxQuantity);
nbt.setDouble("fluxFast", this.lastFluxQuantity * fluxRatio); nbt.setDouble("fluxMod", this.fluxRatio);
nbt.setBoolean("hasRod", this.hasRod);
}
// aaaaaaaa
public void writeToNBTDiag(NBTTagCompound nbt) {
super.writeToNBT(nbt);
nbt.setDouble("fluxSlow", this.fluxQuantity * (1 - fluxRatio));
nbt.setDouble("fluxFast", this.fluxQuantity * fluxRatio);
nbt.setBoolean("hasRod", this.hasRod); nbt.setBoolean("hasRod", this.hasRod);
} }
@ -246,7 +255,7 @@ public class TileEntityRBMKRod extends TileEntityRBMKSlottedBase implements IRBM
public void getDiagData(NBTTagCompound nbt) { public void getDiagData(NBTTagCompound nbt) {
diag = true; diag = true;
this.writeToNBT(nbt); this.writeToNBTDiag(nbt);
diag = false; diag = false;
if(slots[0] != null && slots[0].getItem() instanceof ItemRBMKRod) { if(slots[0] != null && slots[0].getItem() instanceof ItemRBMKRod) {
@ -308,8 +317,8 @@ public class TileEntityRBMKRod extends TileEntityRBMKSlottedBase implements IRBM
} }
@Override @Override
public RBMKHandler.RBMKType getRBMKType() { public RBMKNeutronHandler.RBMKType getRBMKType() {
return RBMKHandler.RBMKType.ROD; return RBMKNeutronHandler.RBMKType.ROD;
} }
@Override @Override

View File

@ -1,12 +1,13 @@
package com.hbm.tileentity.machine.rbmk; package com.hbm.tileentity.machine.rbmk;
import com.hbm.handler.rbmkmk2.RBMKHandler.RBMKNode; import com.hbm.handler.neutron.NeutronNodeWorld;
import com.hbm.handler.neutron.RBMKNeutronHandler;
import com.hbm.tileentity.machine.rbmk.TileEntityRBMKConsole.ColumnType; import com.hbm.tileentity.machine.rbmk.TileEntityRBMKConsole.ColumnType;
import com.hbm.util.fauxpointtwelve.BlockPos; import com.hbm.util.fauxpointtwelve.BlockPos;
import net.minecraft.util.Vec3; import net.minecraft.util.Vec3;
import static com.hbm.handler.rbmkmk2.RBMKHandler.*; import static com.hbm.handler.neutron.RBMKNeutronHandler.*;
public class TileEntityRBMKRodReaSim extends TileEntityRBMKRod { public class TileEntityRBMKRodReaSim extends TileEntityRBMKRod {
@ -26,15 +27,15 @@ public class TileEntityRBMKRodReaSim extends TileEntityRBMKRod {
if (flux == 0) { if (flux == 0) {
// simple way to remove the node from the cache when no flux is going into it! // simple way to remove the node from the cache when no flux is going into it!
removeNode(pos); NeutronNodeWorld.removeNode(pos);
return; return;
} }
RBMKNode node = getNode(pos); RBMKNeutronNode node = (RBMKNeutronNode) NeutronNodeWorld.getNode(pos);
if(node == null) { if(node == null) {
node = makeNode(this); node = makeNode(this);
addNode(node); NeutronNodeWorld.addNode(node);
} }
int count = RBMKDials.getReaSimCount(worldObj); int count = RBMKDials.getReaSimCount(worldObj);
@ -44,7 +45,7 @@ public class TileEntityRBMKRodReaSim extends TileEntityRBMKRod {
neutronVector.rotateAroundY((float)(Math.PI * 2D * worldObj.rand.nextDouble())); neutronVector.rotateAroundY((float)(Math.PI * 2D * worldObj.rand.nextDouble()));
new NeutronStream(makeNode(this), neutronVector, flux, ratio); new RBMKNeutronHandler.RBMKNeutronStream(makeNode(this), neutronVector, flux, ratio);
// Create new neutron streams // Create new neutron streams
} }
} }

View File

@ -1,6 +1,6 @@
package com.hbm.tileentity.machine.rbmk; package com.hbm.tileentity.machine.rbmk;
import com.hbm.handler.rbmkmk2.RBMKHandler; import com.hbm.handler.neutron.RBMKNeutronHandler;
import com.hbm.inventory.container.ContainerRBMKStorage; import com.hbm.inventory.container.ContainerRBMKStorage;
import com.hbm.inventory.gui.GUIRBMKStorage; import com.hbm.inventory.gui.GUIRBMKStorage;
import com.hbm.items.machine.ItemRBMKRod; import com.hbm.items.machine.ItemRBMKRod;
@ -42,8 +42,8 @@ public class TileEntityRBMKStorage extends TileEntityRBMKSlottedBase implements
} }
@Override @Override
public RBMKHandler.RBMKType getRBMKType() { public RBMKNeutronHandler.RBMKType getRBMKType() {
return RBMKHandler.RBMKType.OTHER; return RBMKNeutronHandler.RBMKType.OTHER;
} }
@Override @Override