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
18bb7f63c4
commit
fce0b08056
@ -8,6 +8,7 @@ import java.util.Set;
|
||||
import com.hbm.util.fauxpointtwelve.BlockPos;
|
||||
import com.hbm.util.fauxpointtwelve.DirPos;
|
||||
|
||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
|
||||
@ -3,6 +3,7 @@ package com.hbm.blocks.machine.rbmk;
|
||||
import com.hbm.blocks.BlockDummyable;
|
||||
import com.hbm.blocks.ILookOverlay;
|
||||
import com.hbm.handler.MultiblockHandlerXR;
|
||||
import com.hbm.handler.rbmkmk2.RBMKHandler;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.items.machine.ItemRBMKLid;
|
||||
import com.hbm.lib.RefStrings;
|
||||
@ -11,6 +12,7 @@ import com.hbm.tileentity.machine.rbmk.RBMKDials;
|
||||
import com.hbm.tileentity.machine.rbmk.TileEntityRBMKBase;
|
||||
|
||||
import api.hbm.block.IToolable;
|
||||
import com.hbm.util.fauxpointtwelve.BlockPos;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
|
||||
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.common.util.ForgeDirection;
|
||||
|
||||
import static com.hbm.handler.rbmkmk2.RBMKHandler.getNode;
|
||||
|
||||
public abstract class RBMKBase extends BlockDummyable implements IToolable, ILookOverlay {
|
||||
|
||||
public static boolean dropLids = true;
|
||||
@ -170,6 +174,10 @@ public abstract class RBMKBase extends BlockDummyable implements IToolable, ILoo
|
||||
int i = rbmk.getBlockMetadata();
|
||||
|
||||
if(rbmk.hasLid() && rbmk.isLidRemovable()) {
|
||||
|
||||
RBMKHandler.RBMKNode node = getNode(new BlockPos(te));
|
||||
if (node != null)
|
||||
node.removeLid();
|
||||
|
||||
if(!world.isRemote) {
|
||||
if(i == DIR_NORMAL_LID.ordinal() + offset) {
|
||||
|
||||
@ -4,13 +4,16 @@ import com.hbm.blocks.machine.rbmk.RBMKBase;
|
||||
import com.hbm.handler.radiation.ChunkRadiationManager;
|
||||
import com.hbm.tileentity.machine.rbmk.*;
|
||||
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.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.*;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class RBMKHandler {
|
||||
|
||||
@ -30,6 +33,10 @@ public class RBMKHandler {
|
||||
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 {
|
||||
|
||||
protected RBMKType type;
|
||||
@ -40,16 +47,66 @@ public class RBMKHandler {
|
||||
this.type = type;
|
||||
this.tile = tile;
|
||||
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) {
|
||||
return worldObj.getTileEntity(pos.getX(), pos.getY(), pos.getZ());
|
||||
public static RBMKNode makeNode(TileEntityRBMKBase tile) {
|
||||
BlockPos pos = new BlockPos(tile);
|
||||
if (nodeCache.containsKey(pos))
|
||||
return getNode(pos);
|
||||
return new RBMKNode(tile, tile.getRBMKType());
|
||||
}
|
||||
|
||||
public static RBMKNode makeNode(TileEntityRBMKBase tile) {
|
||||
return new RBMKNode(tile, tile.getRBMKType());
|
||||
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 static class NeutronStream {
|
||||
@ -66,12 +123,25 @@ public class RBMKHandler {
|
||||
// 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;
|
||||
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() {
|
||||
@ -90,7 +160,7 @@ public class RBMKHandler {
|
||||
// This, however, is used for actual RBMK flux calculations.
|
||||
// Does NOT include the origin node
|
||||
// USES THE CACHE!!!
|
||||
public List<RBMKNode> getNodes() {
|
||||
public List<RBMKNode> getNodes(boolean cache) {
|
||||
List<RBMKNode> positions = new ArrayList<>();
|
||||
|
||||
for (int i = 1; i <= fluxRange; i++) {
|
||||
@ -99,24 +169,18 @@ public class RBMKHandler {
|
||||
|
||||
BlockPos pos = new BlockPos(origin.tile).add(x, 0, z);
|
||||
|
||||
if (nodeCache.containsKey(pos)) {
|
||||
positions.add(nodeCache.get(pos));
|
||||
continue;
|
||||
}
|
||||
if (nodeCache.containsKey(pos) && cache)
|
||||
positions.add(getNode(pos));
|
||||
|
||||
// If it isn't an RBMK block then don't do anything with it
|
||||
if(!(origin.tile.getBlockType() instanceof RBMKBase))
|
||||
continue;
|
||||
|
||||
TileEntity te = blockPosToTE(origin.tile.getWorldObj(), pos);
|
||||
|
||||
if (te instanceof TileEntityRBMKBase) {
|
||||
TileEntityRBMKBase rbmkBase = (TileEntityRBMKBase) te;
|
||||
RBMKType type = rbmkBase.getRBMKType();
|
||||
// they should ALL be RBMKBase TEs
|
||||
RBMKNode node = new RBMKNode(rbmkBase, type);
|
||||
positions.add(node);
|
||||
addNode(node);
|
||||
else if (this.origin.tile.getBlockType() instanceof RBMKBase) {
|
||||
TileEntity te = blockPosToTE(this.origin.tile.getWorldObj(), pos);
|
||||
if (te instanceof TileEntityRBMKBase) {
|
||||
TileEntityRBMKBase rbmkBase = (TileEntityRBMKBase)te;
|
||||
RBMKNode node = makeNode(rbmkBase);
|
||||
positions.add(node);
|
||||
if (cache)
|
||||
addNode(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
return positions;
|
||||
@ -143,6 +207,7 @@ public class RBMKHandler {
|
||||
}
|
||||
|
||||
int moderatedCount = 0;
|
||||
double totalFluxMod = 1;
|
||||
|
||||
for(BlockPos nodePos : getBlocks()) {
|
||||
|
||||
@ -152,33 +217,28 @@ public class RBMKHandler {
|
||||
RBMKNode node = nodeCache.get(nodePos);
|
||||
|
||||
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) {
|
||||
node = makeNode((TileEntityRBMKBase) te);
|
||||
addNode(node); // whoops!
|
||||
} else
|
||||
return; // TE no longer exists, die!!
|
||||
} else {
|
||||
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!
|
||||
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
|
||||
// no issue with casting here!
|
||||
TileEntityRBMKBase nodeTE = node.tile;
|
||||
@ -186,17 +246,17 @@ public class RBMKHandler {
|
||||
if(!node.hasLid)
|
||||
ChunkRadiationManager.proxy.incrementRad(worldObj, nodePos.getX(), nodePos.getY(), nodePos.getZ(), (float) (this.fluxQuantity * 0.05F));
|
||||
|
||||
if(node.type == RBMKType.MODERATOR) {
|
||||
moderatedCount += 1;
|
||||
if (node.type == RBMKHandler.RBMKType.MODERATOR) {
|
||||
moderatedCount++;
|
||||
moderateStream();
|
||||
}
|
||||
|
||||
if(node.tile instanceof IRBMKFluxReceiver) {
|
||||
IRBMKFluxReceiver column = ((IRBMKFluxReceiver) nodeTE);
|
||||
if(node.type == RBMKType.ROD) {
|
||||
TileEntityRBMKRod rod = ((TileEntityRBMKRod) column);
|
||||
if(rod.hasRod) {
|
||||
if(rod.isModerated())
|
||||
if (nodeTE instanceof IRBMKFluxReceiver) {
|
||||
IRBMKFluxReceiver column = (IRBMKFluxReceiver)nodeTE;
|
||||
if (node.type == RBMKHandler.RBMKType.ROD) {
|
||||
TileEntityRBMKRod rod = (TileEntityRBMKRod)column;
|
||||
if (rod.hasRod) {
|
||||
if (rod.isModerated())
|
||||
moderateStream();
|
||||
rod.receiveFlux(this);
|
||||
return;
|
||||
@ -208,67 +268,54 @@ public class RBMKHandler {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else if(node.type == RBMKType.CONTROL_ROD) {
|
||||
TileEntityRBMKControl rod = ((TileEntityRBMKControl) nodeTE);
|
||||
if (rod.level > 0D)
|
||||
fluxQuantity *= ((TileEntityRBMKControl) nodeTE).getMult();
|
||||
else
|
||||
return;
|
||||
}
|
||||
|
||||
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;
|
||||
} else if (node.type == RBMKHandler.RBMKType.CONTROL_ROD) {
|
||||
TileEntityRBMKControl rod = (TileEntityRBMKControl)nodeTE;
|
||||
if (rod.level > 0.0D) {
|
||||
this.fluxQuantity *= rod.getMult();
|
||||
totalFluxMod *= rod.getMult();
|
||||
continue;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
else if(node.type == RBMKType.ABSORBER) {
|
||||
if (absorberEfficiency == 1)
|
||||
return; // Instantly stop stream processing.
|
||||
else
|
||||
fluxQuantity *= absorberEfficiency;
|
||||
if (node.type == RBMKHandler.RBMKType.REFLECTOR) {
|
||||
if (this.origin.tile.isModerated())
|
||||
moderatedCount++;
|
||||
if (this.fluxRatio > 0 && moderatedCount > 0)
|
||||
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<RBMKNode> nodes = getNodes();
|
||||
|
||||
if(nodes.isEmpty()) // how tf did we get here if its empty
|
||||
List<RBMKHandler.RBMKNode> nodes = getNodes(true);
|
||||
if (nodes.isEmpty())
|
||||
return;
|
||||
|
||||
// Get the last node in the stream.
|
||||
RBMKNode lastNode = nodes.get(nodes.size() - 1);
|
||||
RBMKHandler.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 != RBMKType.REFLECTOR && lastNode.type != RBMKType.ABSORBER && lastNode.type != RBMKType.CONTROL_ROD) {
|
||||
// Neutrons must not have been caught then!
|
||||
irradiateFromFlux(new BlockPos(lastNode.tile).add(vector.xCoord, 0, vector.zCoord));
|
||||
}
|
||||
if (lastNode.type != RBMKHandler.RBMKType.REFLECTOR && lastNode.type != RBMKHandler.RBMKType.ABSORBER && lastNode.type != RBMKHandler.RBMKType.CONTROL_ROD)
|
||||
irradiateFromFlux((new BlockPos(lastNode.tile)).add(this.vector.xCoord, 0.0D, this.vector.zCoord));
|
||||
|
||||
// but oh wait, control rods exist
|
||||
if(lastNode.type == RBMKType.CONTROL_ROD) {
|
||||
TileEntityRBMKControl rod = ((TileEntityRBMKControl) lastNode.tile);
|
||||
// just get level and irradiate based on that
|
||||
if(rod.getMult() > 0D) {
|
||||
fluxQuantity = fluxQuantity * rod.getMult();
|
||||
irradiateFromFlux(new BlockPos(lastNode.tile).add(vector.xCoord, 0, vector.zCoord));
|
||||
if (lastNode.type == RBMKHandler.RBMKType.CONTROL_ROD) {
|
||||
TileEntityRBMKControl rod = (TileEntityRBMKControl)lastNode.tile;
|
||||
if (rod.getMult() > 0.0D) {
|
||||
this.fluxQuantity *= rod.getMult();
|
||||
irradiateFromFlux((new BlockPos(lastNode.tile)).add(this.vector.xCoord, 0.0D, this.vector.zCoord));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -279,8 +326,8 @@ public class RBMKHandler {
|
||||
// holy fucking shit
|
||||
// I have had this one line cause me like tens of problems
|
||||
// I FUCKING HATE THIS
|
||||
// total count of bugs fixed attributed to this function: 6
|
||||
if (!origin.tile.getWorldObj().getBlock(pos.getX(), pos.getY() + h, pos.getZ()).isOpaqueCube())
|
||||
// total count of bugs fixed attributed to this function: 10
|
||||
if (origin.tile.getWorldObj().getBlock(pos.getX(), pos.getY() + h, pos.getZ()).isOpaqueCube())
|
||||
hits += 1;
|
||||
}
|
||||
|
||||
@ -296,16 +343,20 @@ public class RBMKHandler {
|
||||
}
|
||||
|
||||
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.
|
||||
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) {
|
||||
nodeCache.put(new BlockPos(node.tile), node);
|
||||
}
|
||||
@ -314,26 +365,47 @@ public class RBMKHandler {
|
||||
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.
|
||||
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?
|
||||
// meh, good enough
|
||||
reflectorEfficiency = 1; //RBMKDials.getReflectorEfficiency();
|
||||
absorberEfficiency = 1; //RBMKDials.getAbsorberEfficiency();
|
||||
moderatorEfficiency = RBMKDials.getModeratorEfficiency(worldObj);
|
||||
reflectorEfficiency = 1; //RBMKDials.getReflectorEfficiency(world.worldObj);
|
||||
absorberEfficiency = 1; //RBMKDials.getAbsorberEfficiency(world.worldObj);
|
||||
moderatorEfficiency = RBMKDials.getModeratorEfficiency(world.getKey());
|
||||
|
||||
// I hate this.
|
||||
// this broke everything because it was ONE OFF
|
||||
// IT'S NOT THE TOTAL HEIGHT IT'S THE AMOUNT OF BLOCKS ABOVE AAAAAAAAAAAAA
|
||||
columnHeight = RBMKDials.getColumnHeight(worldObj) + 1;
|
||||
fluxRange = RBMKDials.getFluxRange(worldObj);
|
||||
streams.forEach((stream, world) -> {
|
||||
if (world == worldObj)
|
||||
// WOO!!
|
||||
stream.runStreamInteraction(world);
|
||||
});
|
||||
columnHeight = RBMKDials.getColumnHeight(world.getKey()) + 1;
|
||||
fluxRange = RBMKDials.getFluxRange(world.getKey());
|
||||
|
||||
for (NeutronStream stream : world.getValue().streams) {
|
||||
stream.runStreamInteraction(world.getKey());
|
||||
}
|
||||
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.machine.rbmk.RBMKBase;
|
||||
import com.hbm.handler.rbmkmk2.RBMKHandler;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.tileentity.machine.rbmk.TileEntityRBMKBase;
|
||||
|
||||
import com.hbm.util.fauxpointtwelve.BlockPos;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
@ -13,6 +15,8 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import static com.hbm.handler.rbmkmk2.RBMKHandler.getNode;
|
||||
|
||||
public class ItemRBMKLid extends Item {
|
||||
|
||||
@Override
|
||||
@ -37,7 +41,11 @@ public class ItemRBMKLid extends Item {
|
||||
|
||||
if(tile.hasLid())
|
||||
return false;
|
||||
|
||||
|
||||
RBMKHandler.RBMKNode node = getNode(new BlockPos(te));
|
||||
if (node != null)
|
||||
node.addLid();
|
||||
|
||||
int meta = RBMKBase.DIR_NORMAL_LID.ordinal();
|
||||
|
||||
if(this == ModItems.rbmk_lid_glass) {
|
||||
|
||||
@ -535,6 +535,12 @@ public class ModEventHandler {
|
||||
public void onLoad(WorldEvent.Load event) {
|
||||
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 Field reference = null;
|
||||
@ -1146,9 +1152,7 @@ public class ModEventHandler {
|
||||
TileEntityMachineRadarNT.updateSystem();
|
||||
Nodespace.updateNodespace();
|
||||
// RBMK!!!!
|
||||
MinecraftServer.getServer().theProfiler.startSection("rbmkHandler_flux_interaction");
|
||||
RBMKHandler.runAllInteractions();
|
||||
MinecraftServer.getServer().theProfiler.endSection();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -22,6 +22,7 @@ import com.hbm.tileentity.IOverpressurable;
|
||||
import com.hbm.tileentity.TileEntityLoadedBase;
|
||||
import com.hbm.tileentity.machine.rbmk.TileEntityRBMKConsole.ColumnType;
|
||||
import com.hbm.util.Compat;
|
||||
import com.hbm.util.GameRuleHelper;
|
||||
import com.hbm.util.I18nUtil;
|
||||
import com.hbm.util.fauxpointtwelve.BlockPos;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
|
||||
@ -51,7 +52,7 @@ import java.util.*;
|
||||
* @author hbm
|
||||
*
|
||||
*/
|
||||
public abstract class TileEntityRBMKBase extends TileEntityLoadedBase implements INBTPacketReceiver, IBufPacketReceiver {
|
||||
public abstract class TileEntityRBMKBase extends TileEntityLoadedBase implements IBufPacketReceiver {
|
||||
|
||||
public double heat;
|
||||
|
||||
@ -276,22 +277,6 @@ public abstract class TileEntityRBMKBase extends TileEntityLoadedBase implements
|
||||
nbt.setInteger("steam", this.steam);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void networkPack(NBTTagCompound nbt, int range) {
|
||||
diag = true;
|
||||
if(!worldObj.isRemote)
|
||||
PacketDispatcher.wrapper.sendToAllAround(new NBTPacket(nbt, xCoord, yCoord, zCoord), new TargetPoint(this.worldObj.provider.dimensionId, xCoord, yCoord, zCoord, range));
|
||||
diag = false;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void networkUnpack(NBTTagCompound nbt) {
|
||||
|
||||
diag = true;
|
||||
this.readFromNBT(nbt);
|
||||
diag = false;
|
||||
}
|
||||
|
||||
public void networkPackNT(int range) {
|
||||
if(!worldObj.isRemote) PacketDispatcher.wrapper.sendToAllAround(new BufPacket(xCoord, yCoord, zCoord, this), new TargetPoint(this.worldObj.provider.dimensionId, xCoord, yCoord, zCoord, range));
|
||||
}
|
||||
|
||||
@ -96,7 +96,7 @@ public class TileEntityRBMKOutgasser extends TileEntityRBMKSlottedBase implement
|
||||
|
||||
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);
|
||||
|
||||
|
||||
@ -17,6 +17,7 @@ import com.hbm.util.CompatEnergyControl;
|
||||
import com.hbm.util.ParticleUtil;
|
||||
|
||||
import api.hbm.tile.IInfoProviderEC;
|
||||
import com.hbm.util.fauxpointtwelve.BlockPos;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
@ -38,6 +39,9 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static com.hbm.handler.rbmkmk2.RBMKHandler.addNode;
|
||||
import static com.hbm.handler.rbmkmk2.RBMKHandler.getNode;
|
||||
|
||||
@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 {
|
||||
|
||||
@ -116,6 +120,8 @@ public class TileEntityRBMKRod extends TileEntityRBMKSlottedBase implements IRBM
|
||||
|
||||
if(this.heat > 10_000) this.heat = 10_000;
|
||||
|
||||
this.markDirty();
|
||||
|
||||
//for spreading, we want the buffered flux to be 0 because we want to know exactly how much gets reflected back
|
||||
this.fluxQuantity = 0;
|
||||
spreadFlux(fluxQuantityOut, fluxRatioOut);
|
||||
@ -139,7 +145,7 @@ public class TileEntityRBMKRod extends TileEntityRBMKSlottedBase implements IRBM
|
||||
|
||||
switch(type) {
|
||||
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;
|
||||
}
|
||||
|
||||
@ -153,16 +159,24 @@ public class TileEntityRBMKRod extends TileEntityRBMKSlottedBase implements IRBM
|
||||
ForgeDirection.WEST
|
||||
};
|
||||
|
||||
protected static NType stream;
|
||||
|
||||
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) {
|
||||
|
||||
Vec3 neutronVector = Vec3.createVectorHelper(dir.offsetX, dir.offsetY, dir.offsetZ);
|
||||
|
||||
new NeutronStream(RBMKHandler.makeNode(this), neutronVector, flux, ratio);
|
||||
// Create new neutron streams
|
||||
new NeutronStream(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));
|
||||
}
|
||||
|
||||
public void networkUnpack(NBTTagCompound nbt) {
|
||||
super.networkUnpack(nbt);
|
||||
}
|
||||
|
||||
public void handleButtonPacket(int value, int meta) {
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user