mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
this is fucking insane dude
RBMK optimization update soon!!!!!!!
This commit is contained in:
parent
3e487dd528
commit
e32f67c2b2
@ -8,6 +8,7 @@ import java.util.Set;
|
|||||||
import com.hbm.util.fauxpointtwelve.BlockPos;
|
import com.hbm.util.fauxpointtwelve.BlockPos;
|
||||||
import com.hbm.util.fauxpointtwelve.DirPos;
|
import com.hbm.util.fauxpointtwelve.DirPos;
|
||||||
|
|
||||||
|
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
|||||||
@ -3,6 +3,7 @@ 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.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;
|
||||||
@ -11,6 +12,7 @@ import com.hbm.tileentity.machine.rbmk.RBMKDials;
|
|||||||
import com.hbm.tileentity.machine.rbmk.TileEntityRBMKBase;
|
import com.hbm.tileentity.machine.rbmk.TileEntityRBMKBase;
|
||||||
|
|
||||||
import api.hbm.block.IToolable;
|
import api.hbm.block.IToolable;
|
||||||
|
import com.hbm.util.fauxpointtwelve.BlockPos;
|
||||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||||
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
|
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
@ -27,6 +29,8 @@ 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;
|
||||||
@ -171,6 +175,10 @@ 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));
|
||||||
|
if (node != null)
|
||||||
|
node.removeLid();
|
||||||
|
|
||||||
if(!world.isRemote) {
|
if(!world.isRemote) {
|
||||||
if(i == DIR_NORMAL_LID.ordinal() + offset) {
|
if(i == DIR_NORMAL_LID.ordinal() + offset) {
|
||||||
world.spawnEntityInWorld(new EntityItem(world, pos[0] + 0.5, pos[1] + 0.5 + RBMKDials.getColumnHeight(world), pos[2] + 0.5, new ItemStack(ModItems.rbmk_lid)));
|
world.spawnEntityInWorld(new EntityItem(world, pos[0] + 0.5, pos[1] + 0.5 + RBMKDials.getColumnHeight(world), pos[2] + 0.5, new ItemStack(ModItems.rbmk_lid)));
|
||||||
|
|||||||
@ -4,13 +4,16 @@ import com.hbm.blocks.machine.rbmk.RBMKBase;
|
|||||||
import com.hbm.handler.radiation.ChunkRadiationManager;
|
import com.hbm.handler.radiation.ChunkRadiationManager;
|
||||||
import com.hbm.tileentity.machine.rbmk.*;
|
import com.hbm.tileentity.machine.rbmk.*;
|
||||||
import com.hbm.util.fauxpointtwelve.BlockPos;
|
import com.hbm.util.fauxpointtwelve.BlockPos;
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
import java.util.HashMap;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.Vec3;
|
import net.minecraft.util.Vec3;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
public class RBMKHandler {
|
public class RBMKHandler {
|
||||||
|
|
||||||
@ -30,6 +33,10 @@ public class RBMKHandler {
|
|||||||
OTHER // why do neutron calculations on them if they won't change anything?
|
OTHER // why do neutron calculations on them if they won't change anything?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static TileEntity blockPosToTE(World worldObj, BlockPos pos) {
|
||||||
|
return worldObj.getTileEntity(pos.getX(), pos.getY(), pos.getZ());
|
||||||
|
}
|
||||||
|
|
||||||
public static class RBMKNode {
|
public static class RBMKNode {
|
||||||
|
|
||||||
protected RBMKType type;
|
protected RBMKType type;
|
||||||
@ -40,16 +47,66 @@ public class RBMKHandler {
|
|||||||
this.type = type;
|
this.type = type;
|
||||||
this.tile = tile;
|
this.tile = tile;
|
||||||
this.hasLid = tile.hasLid();
|
this.hasLid = tile.hasLid();
|
||||||
addNode(this);
|
}
|
||||||
|
|
||||||
|
public void addLid() {
|
||||||
|
this.hasLid = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeLid() {
|
||||||
|
this.hasLid = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void checkNode(BlockPos pos) {
|
||||||
|
|
||||||
|
if (tile == null)
|
||||||
|
removeNode(pos); // what the fuck???
|
||||||
|
|
||||||
|
if (tile.isInvalid())
|
||||||
|
removeNode(pos);
|
||||||
|
|
||||||
|
if (tile instanceof TileEntityRBMKRod && !(tile instanceof TileEntityRBMKRodReaSim)) {
|
||||||
|
TileEntityRBMKRod rod = (TileEntityRBMKRod) tile;
|
||||||
|
if (!rod.hasRod) {
|
||||||
|
|
||||||
|
// Simulate streams coming out of the RBMK rod find nodes to uncache.
|
||||||
|
|
||||||
|
for (ForgeDirection dir : TileEntityRBMKRod.fluxDirs) {
|
||||||
|
NeutronStream stream = new NeutronStream(this, Vec3.createVectorHelper(dir.offsetX, 0, dir.offsetZ));
|
||||||
|
|
||||||
|
List<RBMKNode> nodes = stream.getNodes(false);
|
||||||
|
for (RBMKNode nodeToRemove : nodes)
|
||||||
|
removeNode(new BlockPos(nodeToRemove.tile));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Implement `hasRodInRange` for non-rod tile uncaching.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static TileEntity blockPosToTE(World worldObj, BlockPos pos) {
|
public static RBMKNode makeNode(TileEntityRBMKBase tile) {
|
||||||
return worldObj.getTileEntity(pos.getX(), pos.getY(), pos.getZ());
|
BlockPos pos = new BlockPos(tile);
|
||||||
|
if (nodeCache.containsKey(pos))
|
||||||
|
return getNode(pos);
|
||||||
|
return new RBMKNode(tile, tile.getRBMKType());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static RBMKNode makeNode(TileEntityRBMKBase tile) {
|
public static class StreamWorld {
|
||||||
return new RBMKNode(tile, tile.getRBMKType());
|
|
||||||
|
List<NeutronStream> streams;
|
||||||
|
|
||||||
|
public StreamWorld() {
|
||||||
|
streams = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addStream(NeutronStream stream) {
|
||||||
|
this.streams.add(stream);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeAllStreams() {
|
||||||
|
this.streams.clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class NeutronStream {
|
public static class NeutronStream {
|
||||||
@ -66,12 +123,25 @@ public class RBMKHandler {
|
|||||||
// Vector for direction of neutron flow.
|
// Vector for direction of neutron flow.
|
||||||
public Vec3 vector;
|
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) {
|
public NeutronStream(RBMKNode origin, Vec3 vector, double flux, double ratio) {
|
||||||
this.origin = origin;
|
this.origin = origin;
|
||||||
this.vector = vector;
|
this.vector = vector;
|
||||||
this.fluxQuantity = flux;
|
this.fluxQuantity = flux;
|
||||||
this.fluxRatio = ratio;
|
this.fluxRatio = ratio;
|
||||||
streams.put(this, origin.tile.getWorldObj());
|
World worldObj = origin.tile.getWorldObj();
|
||||||
|
if (streamWorlds.get(worldObj) != null)
|
||||||
|
streamWorlds.get(worldObj).addStream(this);
|
||||||
|
else {
|
||||||
|
StreamWorld world = new StreamWorld();
|
||||||
|
world.addStream(this);
|
||||||
|
streamWorlds.put(worldObj, world);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<BlockPos> getBlocks() {
|
public List<BlockPos> getBlocks() {
|
||||||
@ -90,7 +160,7 @@ public class RBMKHandler {
|
|||||||
// This, however, is used for actual RBMK flux calculations.
|
// This, however, is used for actual RBMK flux calculations.
|
||||||
// Does NOT include the origin node
|
// Does NOT include the origin node
|
||||||
// USES THE CACHE!!!
|
// USES THE CACHE!!!
|
||||||
public List<RBMKNode> getNodes() {
|
public List<RBMKNode> getNodes(boolean cache) {
|
||||||
List<RBMKNode> positions = new ArrayList<>();
|
List<RBMKNode> positions = new ArrayList<>();
|
||||||
|
|
||||||
for (int i = 1; i <= fluxRange; i++) {
|
for (int i = 1; i <= fluxRange; i++) {
|
||||||
@ -99,24 +169,18 @@ 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 (nodeCache.containsKey(pos) && cache)
|
||||||
positions.add(nodeCache.get(pos));
|
positions.add(getNode(pos));
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If it isn't an RBMK block then don't do anything with it
|
else if (this.origin.tile.getBlockType() instanceof RBMKBase) {
|
||||||
if(!(origin.tile.getBlockType() instanceof RBMKBase))
|
TileEntity te = blockPosToTE(this.origin.tile.getWorldObj(), pos);
|
||||||
continue;
|
if (te instanceof TileEntityRBMKBase) {
|
||||||
|
TileEntityRBMKBase rbmkBase = (TileEntityRBMKBase)te;
|
||||||
TileEntity te = blockPosToTE(origin.tile.getWorldObj(), pos);
|
RBMKNode node = makeNode(rbmkBase);
|
||||||
|
positions.add(node);
|
||||||
if (te instanceof TileEntityRBMKBase) {
|
if (cache)
|
||||||
TileEntityRBMKBase rbmkBase = (TileEntityRBMKBase) te;
|
addNode(node);
|
||||||
RBMKType type = rbmkBase.getRBMKType();
|
}
|
||||||
// they should ALL be RBMKBase TEs
|
|
||||||
RBMKNode node = new RBMKNode(rbmkBase, type);
|
|
||||||
positions.add(node);
|
|
||||||
addNode(node);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return positions;
|
return positions;
|
||||||
@ -143,6 +207,7 @@ public class RBMKHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int moderatedCount = 0;
|
int moderatedCount = 0;
|
||||||
|
double totalFluxMod = 1;
|
||||||
|
|
||||||
for(BlockPos nodePos : getBlocks()) {
|
for(BlockPos nodePos : getBlocks()) {
|
||||||
|
|
||||||
@ -152,33 +217,28 @@ public class RBMKHandler {
|
|||||||
RBMKNode node = nodeCache.get(nodePos);
|
RBMKNode node = 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!
|
addNode(node); // whoops!
|
||||||
} else
|
} else {
|
||||||
return; // TE no longer exists, die!!
|
int hits = getHits(nodePos); // Get the amount of hits on blocks.
|
||||||
|
if (hits == columnHeight) // If stream is fully blocked.
|
||||||
|
return;
|
||||||
|
else if (hits > 0) { // If stream is partially blocked.
|
||||||
|
irradiateFromFlux(pos, hits);
|
||||||
|
fluxQuantity *= 1 - ((double) hits / columnHeight); // Inverse to get partial blocking by blocks.
|
||||||
|
continue;
|
||||||
|
} else { // Nothing hit!
|
||||||
|
irradiateFromFlux(pos, 0);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(node.type == RBMKType.OTHER) // pass right on by!
|
if(node.type == RBMKType.OTHER) // pass right on by!
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Block block = node.tile.getBlockType();
|
|
||||||
|
|
||||||
if (!(block instanceof RBMKBase)) {
|
|
||||||
int hits = getHits(nodePos); // Get the amount of hits on blocks.
|
|
||||||
if (hits == columnHeight) // If stream is fully blocked.
|
|
||||||
return;
|
|
||||||
else if (hits > 0) { // If stream is partially blocked.
|
|
||||||
irradiateFromFlux(pos, hits);
|
|
||||||
fluxQuantity *= 1 - ((double) hits / columnHeight); // Inverse to get partial blocking by blocks.
|
|
||||||
continue;
|
|
||||||
} else { // Nothing hit!
|
|
||||||
irradiateFromFlux(pos, 0);
|
|
||||||
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 = node.tile;
|
||||||
@ -186,17 +246,17 @@ public class RBMKHandler {
|
|||||||
if(!node.hasLid)
|
if(!node.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) {
|
if (node.type == RBMKHandler.RBMKType.MODERATOR) {
|
||||||
moderatedCount += 1;
|
moderatedCount++;
|
||||||
moderateStream();
|
moderateStream();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(node.tile instanceof IRBMKFluxReceiver) {
|
if (nodeTE instanceof IRBMKFluxReceiver) {
|
||||||
IRBMKFluxReceiver column = ((IRBMKFluxReceiver) nodeTE);
|
IRBMKFluxReceiver column = (IRBMKFluxReceiver)nodeTE;
|
||||||
if(node.type == RBMKType.ROD) {
|
if (node.type == RBMKHandler.RBMKType.ROD) {
|
||||||
TileEntityRBMKRod rod = ((TileEntityRBMKRod) column);
|
TileEntityRBMKRod rod = (TileEntityRBMKRod)column;
|
||||||
if(rod.hasRod) {
|
if (rod.hasRod) {
|
||||||
if(rod.isModerated())
|
if (rod.isModerated())
|
||||||
moderateStream();
|
moderateStream();
|
||||||
rod.receiveFlux(this);
|
rod.receiveFlux(this);
|
||||||
return;
|
return;
|
||||||
@ -208,67 +268,54 @@ public class RBMKHandler {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
else if(node.type == RBMKType.CONTROL_ROD) {
|
} else if (node.type == RBMKHandler.RBMKType.CONTROL_ROD) {
|
||||||
TileEntityRBMKControl rod = ((TileEntityRBMKControl) nodeTE);
|
TileEntityRBMKControl rod = (TileEntityRBMKControl)nodeTE;
|
||||||
if (rod.level > 0D)
|
if (rod.level > 0.0D) {
|
||||||
fluxQuantity *= ((TileEntityRBMKControl) nodeTE).getMult();
|
this.fluxQuantity *= rod.getMult();
|
||||||
else
|
totalFluxMod *= rod.getMult();
|
||||||
return;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
else if(node.type == RBMKType.REFLECTOR) {
|
|
||||||
if((origin.tile).isModerated())
|
|
||||||
moderatedCount += 1;
|
|
||||||
if (fluxRatio > 0D && moderatedCount > 0) {
|
|
||||||
for (int i = 0; i < moderatedCount; i++) {
|
|
||||||
moderateStream(); // Moderate streams on the way back!
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(reflectorEfficiency != 1) {
|
|
||||||
fluxQuantity *= reflectorEfficiency;
|
|
||||||
} else {
|
|
||||||
((TileEntityRBMKRod) originTE).receiveFlux(this);
|
|
||||||
// this one missing return line was baffling me for half an hour
|
|
||||||
// "why is this rod jumping to double the flux randomly????"
|
|
||||||
// because you aren't fucking returning from the function, and it's hitting the reflector after it, you idiot
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if(node.type == RBMKType.ABSORBER) {
|
if (node.type == RBMKHandler.RBMKType.REFLECTOR) {
|
||||||
if (absorberEfficiency == 1)
|
if (this.origin.tile.isModerated())
|
||||||
return; // Instantly stop stream processing.
|
moderatedCount++;
|
||||||
else
|
if (this.fluxRatio > 0 && moderatedCount > 0)
|
||||||
fluxQuantity *= absorberEfficiency;
|
for (int i = 0; i < moderatedCount; i++)
|
||||||
|
moderateStream();
|
||||||
|
if (totalFluxMod < 1)
|
||||||
|
this.fluxQuantity *= totalFluxMod;
|
||||||
|
if (RBMKHandler.reflectorEfficiency != 1.0D) {
|
||||||
|
this.fluxQuantity *= RBMKHandler.reflectorEfficiency;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
((TileEntityRBMKRod)originTE).receiveFlux(this);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (node.type == RBMKHandler.RBMKType.ABSORBER) {
|
||||||
|
if (RBMKHandler.absorberEfficiency == 1)
|
||||||
|
return;
|
||||||
|
this.fluxQuantity *= RBMKHandler.absorberEfficiency;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called *after* most streams have returned.
|
List<RBMKHandler.RBMKNode> nodes = getNodes(true);
|
||||||
List<RBMKNode> nodes = getNodes();
|
if (nodes.isEmpty())
|
||||||
|
|
||||||
if(nodes.isEmpty()) // how tf did we get here if its empty
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Get the last node in the stream.
|
RBMKHandler.RBMKNode lastNode = nodes.get(nodes.size() - 1);
|
||||||
RBMKNode lastNode = nodes.get(nodes.size() - 1);
|
|
||||||
|
|
||||||
// Block hits don't have to be considered here, since if it's fully blocked it'll return the function before getting here.
|
if (lastNode.type != RBMKHandler.RBMKType.REFLECTOR && lastNode.type != RBMKHandler.RBMKType.ABSORBER && lastNode.type != RBMKHandler.RBMKType.CONTROL_ROD)
|
||||||
if(lastNode.type != RBMKType.REFLECTOR && lastNode.type != RBMKType.ABSORBER && lastNode.type != RBMKType.CONTROL_ROD) {
|
irradiateFromFlux((new BlockPos(lastNode.tile)).add(this.vector.xCoord, 0.0D, this.vector.zCoord));
|
||||||
// Neutrons must not have been caught then!
|
|
||||||
irradiateFromFlux(new BlockPos(lastNode.tile).add(vector.xCoord, 0, vector.zCoord));
|
|
||||||
}
|
|
||||||
|
|
||||||
// but oh wait, control rods exist
|
if (lastNode.type == RBMKHandler.RBMKType.CONTROL_ROD) {
|
||||||
if(lastNode.type == RBMKType.CONTROL_ROD) {
|
TileEntityRBMKControl rod = (TileEntityRBMKControl)lastNode.tile;
|
||||||
TileEntityRBMKControl rod = ((TileEntityRBMKControl) lastNode.tile);
|
if (rod.getMult() > 0.0D) {
|
||||||
// just get level and irradiate based on that
|
this.fluxQuantity *= rod.getMult();
|
||||||
if(rod.getMult() > 0D) {
|
irradiateFromFlux((new BlockPos(lastNode.tile)).add(this.vector.xCoord, 0.0D, this.vector.zCoord));
|
||||||
fluxQuantity = fluxQuantity * rod.getMult();
|
|
||||||
irradiateFromFlux(new BlockPos(lastNode.tile).add(vector.xCoord, 0, vector.zCoord));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -279,8 +326,8 @@ public class RBMKHandler {
|
|||||||
// holy fucking shit
|
// holy fucking shit
|
||||||
// I have had this one line cause me like tens of problems
|
// I have had this one line cause me like tens of problems
|
||||||
// I FUCKING HATE THIS
|
// I FUCKING HATE THIS
|
||||||
// total count of bugs fixed attributed to this function: 6
|
// total count of bugs fixed attributed to this function: 10
|
||||||
if (!origin.tile.getWorldObj().getBlock(pos.getX(), pos.getY() + h, pos.getZ()).isOpaqueCube())
|
if (origin.tile.getWorldObj().getBlock(pos.getX(), pos.getY() + h, pos.getZ()).isOpaqueCube())
|
||||||
hits += 1;
|
hits += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -296,16 +343,20 @@ public class RBMKHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void moderateStream() {
|
public void moderateStream() {
|
||||||
fluxRatio = 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.
|
// HashMap of all RBMK nodes and their positions.
|
||||||
protected static HashMap<BlockPos, RBMKNode> nodeCache = new HashMap<>();
|
protected static HashMap<BlockPos, RBMKNode> nodeCache = new HashMap<>();
|
||||||
|
|
||||||
// List of all active neutron streams.
|
|
||||||
public static HashMap<NeutronStream, World> streams = new HashMap<>();
|
|
||||||
|
|
||||||
public static void addNode(RBMKNode node) {
|
public static void addNode(RBMKNode node) {
|
||||||
nodeCache.put(new BlockPos(node.tile), node);
|
nodeCache.put(new BlockPos(node.tile), node);
|
||||||
}
|
}
|
||||||
@ -314,26 +365,47 @@ public class RBMKHandler {
|
|||||||
nodeCache.remove(position);
|
nodeCache.remove(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static RBMKNode getNode(BlockPos position) {
|
||||||
|
return nodeCache.get(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void removeAllNodes() {
|
||||||
|
nodeCache.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int cacheTime = 40;
|
||||||
|
static int ticks = 0;
|
||||||
|
|
||||||
// The big one!! Runs all interactions for neutrons.
|
// The big one!! Runs all interactions for neutrons.
|
||||||
public static void runAllInteractions() {
|
public static void runAllInteractions() {
|
||||||
|
|
||||||
for (World worldObj : MinecraftServer.getServer().worldServers) {
|
for (Entry<World, StreamWorld> world : streamWorlds.entrySet()) {
|
||||||
|
|
||||||
// Gamerule caching because this apparently is kinda slow?
|
// Gamerule caching because this apparently is kinda slow?
|
||||||
// meh, good enough
|
// meh, good enough
|
||||||
reflectorEfficiency = 1; //RBMKDials.getReflectorEfficiency();
|
reflectorEfficiency = 1; //RBMKDials.getReflectorEfficiency(world.worldObj);
|
||||||
absorberEfficiency = 1; //RBMKDials.getAbsorberEfficiency();
|
absorberEfficiency = 1; //RBMKDials.getAbsorberEfficiency(world.worldObj);
|
||||||
moderatorEfficiency = RBMKDials.getModeratorEfficiency(worldObj);
|
moderatorEfficiency = RBMKDials.getModeratorEfficiency(world.getKey());
|
||||||
|
|
||||||
// I hate this.
|
// I hate this.
|
||||||
// this broke everything because it was ONE OFF
|
// this broke everything because it was ONE OFF
|
||||||
// IT'S NOT THE TOTAL HEIGHT IT'S THE AMOUNT OF BLOCKS ABOVE AAAAAAAAAAAAA
|
// IT'S NOT THE TOTAL HEIGHT IT'S THE AMOUNT OF BLOCKS ABOVE AAAAAAAAAAAAA
|
||||||
columnHeight = RBMKDials.getColumnHeight(worldObj) + 1;
|
columnHeight = RBMKDials.getColumnHeight(world.getKey()) + 1;
|
||||||
fluxRange = RBMKDials.getFluxRange(worldObj);
|
fluxRange = RBMKDials.getFluxRange(world.getKey());
|
||||||
streams.forEach((stream, world) -> {
|
|
||||||
if (world == worldObj)
|
for (NeutronStream stream : world.getValue().streams) {
|
||||||
// WOO!!
|
stream.runStreamInteraction(world.getKey());
|
||||||
stream.runStreamInteraction(world);
|
}
|
||||||
});
|
world.getValue().removeAllStreams();
|
||||||
}
|
}
|
||||||
streams.clear();
|
|
||||||
|
// Freshen the node cache every `cacheTime` ticks to prevent huge RAM usage.
|
||||||
|
if (ticks >= cacheTime) {
|
||||||
|
ticks = 0;
|
||||||
|
for(Entry<BlockPos, RBMKNode> cachedNode : nodeCache.entrySet()) {
|
||||||
|
cachedNode.getValue().checkNode(cachedNode.getKey());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ticks++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,9 +2,11 @@ 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.items.ModItems;
|
import com.hbm.items.ModItems;
|
||||||
import com.hbm.tileentity.machine.rbmk.TileEntityRBMKBase;
|
import com.hbm.tileentity.machine.rbmk.TileEntityRBMKBase;
|
||||||
|
|
||||||
|
import com.hbm.util.fauxpointtwelve.BlockPos;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
@ -13,6 +15,8 @@ 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
|
||||||
@ -38,6 +42,10 @@ public class ItemRBMKLid extends Item {
|
|||||||
if(tile.hasLid())
|
if(tile.hasLid())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
RBMKHandler.RBMKNode node = getNode(new BlockPos(te));
|
||||||
|
if (node != null)
|
||||||
|
node.addLid();
|
||||||
|
|
||||||
int meta = RBMKBase.DIR_NORMAL_LID.ordinal();
|
int meta = RBMKBase.DIR_NORMAL_LID.ordinal();
|
||||||
|
|
||||||
if(this == ModItems.rbmk_lid_glass) {
|
if(this == ModItems.rbmk_lid_glass) {
|
||||||
|
|||||||
@ -536,6 +536,12 @@ public class ModEventHandler {
|
|||||||
BobmazonOfferFactory.init();
|
BobmazonOfferFactory.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void onUnload(WorldEvent.Unload event) {
|
||||||
|
RBMKHandler.removeAllWorlds(); // Remove world from worlds when unloaded to avoid world issues.
|
||||||
|
RBMKHandler.removeAllNodes(); // Remove all nodes.
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean didSit = false;
|
public static boolean didSit = false;
|
||||||
public static Field reference = null;
|
public static Field reference = null;
|
||||||
|
|
||||||
@ -1146,9 +1152,7 @@ public class ModEventHandler {
|
|||||||
TileEntityMachineRadarNT.updateSystem();
|
TileEntityMachineRadarNT.updateSystem();
|
||||||
Nodespace.updateNodespace();
|
Nodespace.updateNodespace();
|
||||||
// RBMK!!!!
|
// RBMK!!!!
|
||||||
MinecraftServer.getServer().theProfiler.startSection("rbmkHandler_flux_interaction");
|
|
||||||
RBMKHandler.runAllInteractions();
|
RBMKHandler.runAllInteractions();
|
||||||
MinecraftServer.getServer().theProfiler.endSection();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -19,6 +19,7 @@ import com.hbm.tileentity.IOverpressurable;
|
|||||||
import com.hbm.tileentity.TileEntityLoadedBase;
|
import com.hbm.tileentity.TileEntityLoadedBase;
|
||||||
import com.hbm.tileentity.machine.rbmk.TileEntityRBMKConsole.ColumnType;
|
import com.hbm.tileentity.machine.rbmk.TileEntityRBMKConsole.ColumnType;
|
||||||
import com.hbm.util.Compat;
|
import com.hbm.util.Compat;
|
||||||
|
import com.hbm.util.GameRuleHelper;
|
||||||
import com.hbm.util.I18nUtil;
|
import com.hbm.util.I18nUtil;
|
||||||
import com.hbm.util.fauxpointtwelve.BlockPos;
|
import com.hbm.util.fauxpointtwelve.BlockPos;
|
||||||
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
|
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
|
||||||
|
|||||||
@ -96,7 +96,7 @@ public class TileEntityRBMKOutgasser extends TileEntityRBMKSlottedBase implement
|
|||||||
|
|
||||||
if(canProcess()) {
|
if(canProcess()) {
|
||||||
|
|
||||||
double efficiency = Math.min((1 - stream.fluxRatio) * 0.8, 1);
|
double efficiency = Math.min(1 - stream.fluxRatio * 0.8, 1);
|
||||||
|
|
||||||
progress += stream.fluxQuantity * efficiency * RBMKDials.getOutgasserMod(worldObj);
|
progress += stream.fluxQuantity * efficiency * RBMKDials.getOutgasserMod(worldObj);
|
||||||
|
|
||||||
|
|||||||
@ -17,6 +17,7 @@ import com.hbm.util.CompatEnergyControl;
|
|||||||
import com.hbm.util.ParticleUtil;
|
import com.hbm.util.ParticleUtil;
|
||||||
|
|
||||||
import api.hbm.tile.IInfoProviderEC;
|
import api.hbm.tile.IInfoProviderEC;
|
||||||
|
import com.hbm.util.fauxpointtwelve.BlockPos;
|
||||||
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;
|
||||||
@ -139,7 +140,7 @@ public class TileEntityRBMKRod extends TileEntityRBMKSlottedBase implements IRBM
|
|||||||
|
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case SLOW: return (this.fluxQuantity * (1 - this.fluxRatio) + Math.min(this.fluxRatio * 0.5, 1));
|
case SLOW: return (this.fluxQuantity * (1 - this.fluxRatio) + Math.min(this.fluxRatio * 0.5, 1));
|
||||||
case FAST: return (this.fluxQuantity * this.fluxRatio + Math.min((1 - this.fluxRatio) * 0.3, 1));
|
case FAST: return (this.fluxQuantity * this.fluxRatio + Math.min(1 - this.fluxRatio * 0.3, 1));
|
||||||
case ANY: return this.fluxQuantity;
|
case ANY: return this.fluxQuantity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,16 +154,24 @@ public class TileEntityRBMKRod extends TileEntityRBMKSlottedBase implements IRBM
|
|||||||
ForgeDirection.WEST
|
ForgeDirection.WEST
|
||||||
};
|
};
|
||||||
|
|
||||||
protected static NType stream;
|
|
||||||
|
|
||||||
public void spreadFlux(double flux, double ratio) {
|
public void spreadFlux(double flux, double ratio) {
|
||||||
|
|
||||||
|
BlockPos pos = new BlockPos(this);
|
||||||
|
|
||||||
|
RBMKHandler.RBMKNode node;
|
||||||
|
|
||||||
|
if(getNode(pos) == null) {
|
||||||
|
node = RBMKHandler.makeNode(this);
|
||||||
|
addNode(node);
|
||||||
|
} else
|
||||||
|
node = getNode(pos);
|
||||||
|
|
||||||
for(ForgeDirection dir : fluxDirs) {
|
for(ForgeDirection dir : fluxDirs) {
|
||||||
|
|
||||||
Vec3 neutronVector = Vec3.createVectorHelper(dir.offsetX, dir.offsetY, dir.offsetZ);
|
Vec3 neutronVector = Vec3.createVectorHelper(dir.offsetX, dir.offsetY, dir.offsetZ);
|
||||||
|
|
||||||
new NeutronStream(RBMKNeutronHandler.makeNode(this), neutronVector, flux, ratio);
|
|
||||||
// Create new neutron streams
|
// Create new neutron streams
|
||||||
|
new RBMKNeutronStream(node, neutronVector, flux, ratio);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -134,10 +134,6 @@ public abstract class TileEntityRBMKSlottedBase extends TileEntityRBMKActiveBase
|
|||||||
PacketDispatcher.wrapper.sendToAllAround(new NBTPacket(nbt, xCoord, yCoord, zCoord), new TargetPoint(this.worldObj.provider.dimensionId, xCoord, yCoord, zCoord, range));
|
PacketDispatcher.wrapper.sendToAllAround(new NBTPacket(nbt, xCoord, yCoord, zCoord), new TargetPoint(this.worldObj.provider.dimensionId, xCoord, yCoord, zCoord, range));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void networkUnpack(NBTTagCompound nbt) {
|
|
||||||
super.networkUnpack(nbt);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void handleButtonPacket(int value, int meta) {
|
public void handleButtonPacket(int value, int meta) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user