Small fixes

This commit is contained in:
BallOfEnergy 2024-10-13 15:50:00 -05:00
parent 94c97bc87a
commit b63ff682fd
4 changed files with 23 additions and 31 deletions

View File

@ -11,6 +11,7 @@ public abstract class NeutronNode {
protected NeutronType type; protected NeutronType type;
protected TileEntity tile; protected TileEntity tile;
// like NBT but less fucking CANCER // like NBT but less fucking CANCER
// Holds things like cached RBMK lid values.
protected Map<String, Object> data = new HashMap<>(); protected Map<String, Object> data = new HashMap<>();
public NeutronNode(TileEntity tile, NeutronType type) { public NeutronNode(TileEntity tile, NeutronType type) {

View File

@ -8,7 +8,7 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
public class NeutronNodeWorld { public class NeutronNodeWorld {
// HashMap of all RBMK nodes and their positions. // HashMap of all neutron nodes and their positions.
protected static HashMap<BlockPos, NeutronNode> nodeCache = new HashMap<>(); protected static HashMap<BlockPos, NeutronNode> nodeCache = new HashMap<>();
public static void addNode(NeutronNode node) { public static void addNode(NeutronNode node) {

View File

@ -143,14 +143,6 @@ public class PileNeutronHandler {
} }
} }
for (Map.Entry<World, NeutronNodeWorld.StreamWorld> world : NeutronNodeWorld.streamWorlds.entrySet()) {
for (NeutronStream stream : world.getValue().streams) {
stream.runStreamInteraction(world.getKey());
}
world.getValue().removeAllStreams();
}
for (Map.Entry<World, NeutronNodeWorld.StreamWorld> world : NeutronNodeWorld.streamWorlds.entrySet()) { for (Map.Entry<World, NeutronNodeWorld.StreamWorld> world : NeutronNodeWorld.streamWorlds.entrySet()) {
for (NeutronStream stream : world.getValue().streams) { for (NeutronStream stream : world.getValue().streams) {

View File

@ -22,17 +22,17 @@ public class TileEntityPileFuel extends TileEntityPileBase implements IPileNeutr
@Override @Override
public void updateEntity() { public void updateEntity() {
if(!worldObj.isRemote) { if(!worldObj.isRemote) {
dissipateHeat(); dissipateHeat();
checkRedstone(react()); checkRedstone(react());
transmute(); transmute();
if(this.heat >= this.maxHeat) { if(this.heat >= this.maxHeat) {
worldObj.newExplosion(null, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, 4, true, true); worldObj.newExplosion(null, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, 4, true, true);
worldObj.setBlock(xCoord, yCoord, zCoord, ModBlocks.gas_radon_dense); worldObj.setBlock(xCoord, yCoord, zCoord, ModBlocks.gas_radon_dense);
} }
if(worldObj.rand.nextFloat() * 2F <= this.heat / (float)this.maxHeat) { if(worldObj.rand.nextFloat() * 2F <= this.heat / (float)this.maxHeat) {
NBTTagCompound data = new NBTTagCompound(); NBTTagCompound data = new NBTTagCompound();
data.setString("type", "vanillaExt"); data.setString("type", "vanillaExt");
@ -40,55 +40,54 @@ public class TileEntityPileFuel extends TileEntityPileBase implements IPileNeutr
data.setDouble("mY", 0.05); data.setDouble("mY", 0.05);
PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(data, xCoord + 0.25 + worldObj.rand.nextDouble() * 0.5, yCoord + 1, zCoord + 0.25 + worldObj.rand.nextDouble() * 0.5), PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(data, xCoord + 0.25 + worldObj.rand.nextDouble() * 0.5, yCoord + 1, zCoord + 0.25 + worldObj.rand.nextDouble() * 0.5),
new TargetPoint(worldObj.provider.dimensionId, xCoord + 0.5, yCoord + 1, zCoord + 0.5, 20)); new TargetPoint(worldObj.provider.dimensionId, xCoord + 0.5, yCoord + 1, zCoord + 0.5, 20));
MainRegistry.proxy.effectNT(data);
} }
if(this.progress >= this.maxProgress) { if(this.progress >= this.maxProgress) {
worldObj.setBlock(xCoord, yCoord, zCoord, ModBlocks.block_graphite_plutonium, this.getBlockMetadata() & 7, 3); worldObj.setBlock(xCoord, yCoord, zCoord, ModBlocks.block_graphite_plutonium, this.getBlockMetadata() & 7, 3);
} }
} }
} }
private void dissipateHeat() { private void dissipateHeat() {
this.heat -= (this.getBlockMetadata() & 4) == 4 ? heat * 0.065 : heat * 0.05; //remove 5% of the stored heat per tick; 6.5% for windscale this.heat -= (this.getBlockMetadata() & 4) == 4 ? heat * 0.065 : heat * 0.05; //remove 5% of the stored heat per tick; 6.5% for windscale
} }
private int react() { private int react() {
int reaction = (int) (this.neutrons * (1D - ((double)this.heat / (double)this.maxHeat) * 0.5D)); //max heat reduces reaction by 50% due to thermal expansion int reaction = (int) (this.neutrons * (1D - ((double)this.heat / (double)this.maxHeat) * 0.5D)); //max heat reduces reaction by 50% due to thermal expansion
this.lastNeutrons = this.neutrons; this.lastNeutrons = this.neutrons;
this.neutrons = 0; this.neutrons = 0;
int lastProgress = this.progress; int lastProgress = this.progress;
this.progress += reaction; this.progress += reaction;
if(reaction <= 0) if(reaction <= 0)
return lastProgress; return lastProgress;
this.heat += reaction; this.heat += reaction;
for(int i = 0; i < 12; i++) for(int i = 0; i < 12; i++)
this.castRay((int) Math.max(reaction * 0.25, 1)); this.castRay((int) Math.max(reaction * 0.25, 1));
return lastProgress; return lastProgress;
} }
private void checkRedstone(int lastProgress) { private void checkRedstone(int lastProgress) {
int lastLevel = MathHelper.clamp_int((lastProgress * 16) / maxProgress, 0, 15); int lastLevel = MathHelper.clamp_int((lastProgress * 16) / maxProgress, 0, 15);
int newLevel = MathHelper.clamp_int((progress * 16) / maxProgress, 0, 15); int newLevel = MathHelper.clamp_int((progress * 16) / maxProgress, 0, 15);
if(lastLevel != newLevel) if(lastLevel != newLevel)
worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, this.getBlockType()); worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, this.getBlockType());
} }
private void transmute() { private void transmute() {
if((this.getBlockMetadata() & 8) == 8) { if((this.getBlockMetadata() & 8) == 8) {
if(this.progress < this.maxProgress - 1000) //Might be subject to change, but 1000 seems like a good number. if(this.progress < this.maxProgress - 1000) //Might be subject to change, but 1000 seems like a good number.
this.progress = maxProgress - 1000; this.progress = maxProgress - 1000;
return; return;
} else if(this.progress >= maxProgress - 1000) { } else if(this.progress >= maxProgress - 1000) {
worldObj.setBlockMetadataWithNotify(this.xCoord, this.yCoord, this.zCoord, this.getBlockMetadata() | 8, 3); worldObj.setBlockMetadataWithNotify(this.xCoord, this.yCoord, this.zCoord, this.getBlockMetadata() | 8, 3);
@ -100,7 +99,7 @@ public class TileEntityPileFuel extends TileEntityPileBase implements IPileNeutr
public void receiveNeutrons(int n) { public void receiveNeutrons(int n) {
this.neutrons += n; this.neutrons += n;
} }
@Override @Override
public void readFromNBT(NBTTagCompound nbt) { public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt); super.readFromNBT(nbt);
@ -108,7 +107,7 @@ public class TileEntityPileFuel extends TileEntityPileBase implements IPileNeutr
this.progress = nbt.getInteger("progress"); this.progress = nbt.getInteger("progress");
this.neutrons = nbt.getInteger("neutrons"); this.neutrons = nbt.getInteger("neutrons");
} }
@Override @Override
public void writeToNBT(NBTTagCompound nbt) { public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt); super.writeToNBT(nbt);