mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
meltdownier meltdowns
This commit is contained in:
parent
fd1cce407c
commit
7a92f88338
@ -62,6 +62,21 @@ public interface IFluidUser extends IFluidConnector {
|
||||
}
|
||||
}
|
||||
|
||||
public static IPipeNet getPipeNet(World world, int x, int y, int z, FluidType type) {
|
||||
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
|
||||
if(te instanceof IFluidConductor) {
|
||||
IFluidConductor con = (IFluidConductor) te;
|
||||
|
||||
if(con.getPipeNet(type) != null) {
|
||||
return con.getPipeNet(type);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public default void sendFluidToAll(FluidType type, TileEntity te) {
|
||||
|
||||
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
|
||||
@ -3,7 +3,7 @@ package com.hbm.lib;
|
||||
public class RefStrings {
|
||||
public static final String MODID = "hbm";
|
||||
public static final String NAME = "Hbm's Nuclear Tech Mod";
|
||||
public static final String VERSION = "1.0.27 BETA (4438)";
|
||||
public static final String VERSION = "1.0.27 BETA (4441)";
|
||||
//HBM's Beta Naming Convention:
|
||||
//V T (X)
|
||||
//V -> next release version
|
||||
|
||||
@ -29,6 +29,7 @@ public class RBMKDials {
|
||||
public static final String KEY_REASIM_BOILERS = "dialReasimBoilers";
|
||||
public static final String KEY_REASIM_BOILER_SPEED = "dialReasimBoilerSpeed";
|
||||
public static final String KEY_DISABLE_MELTDOWNS = "dialDisableMeltdowns";
|
||||
public static final String KEY_ENABLE_MELTDOWN_OVERPRESSURE = "dialEnableMeltdownOverpressure";
|
||||
|
||||
public static void createDials(World world) {
|
||||
GameRules rules = world.getGameRules();
|
||||
@ -53,6 +54,7 @@ public class RBMKDials {
|
||||
rules.setOrCreateGameRule(KEY_REASIM_BOILERS, "false");
|
||||
rules.setOrCreateGameRule(KEY_REASIM_BOILER_SPEED, "0.05");
|
||||
rules.setOrCreateGameRule(KEY_DISABLE_MELTDOWNS, "false");
|
||||
rules.setOrCreateGameRule(KEY_ENABLE_MELTDOWN_OVERPRESSURE, "false");
|
||||
}
|
||||
}
|
||||
|
||||
@ -218,4 +220,13 @@ public class RBMKDials {
|
||||
public static boolean getMeltdownsDisabled(World world) {
|
||||
return world.getGameRules().getGameRuleBooleanValue(KEY_DISABLE_MELTDOWNS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether or not connected pipes and turbines should explode when the reactor undergoes a meltdown.
|
||||
* @param world
|
||||
* @return
|
||||
*/
|
||||
public static boolean getOverpressure(World world) {
|
||||
return world.getGameRules().getGameRuleBooleanValue(KEY_ENABLE_MELTDOWN_OVERPRESSURE);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@ package com.hbm.tileentity.machine.rbmk;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@ -22,6 +23,9 @@ import com.hbm.tileentity.TileEntityLoadedBase;
|
||||
import com.hbm.tileentity.machine.rbmk.TileEntityRBMKConsole.ColumnType;
|
||||
import com.hbm.util.I18nUtil;
|
||||
|
||||
import api.hbm.fluid.IFluidConductor;
|
||||
import api.hbm.fluid.IFluidConnector;
|
||||
import api.hbm.fluid.IPipeNet;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
@ -394,6 +398,7 @@ public abstract class TileEntityRBMKBase extends TileEntityLoadedBase implements
|
||||
}
|
||||
|
||||
public static HashSet<TileEntityRBMKBase> columns = new HashSet();
|
||||
public static HashSet<IPipeNet> pipes = new HashSet();
|
||||
|
||||
//assumes that !worldObj.isRemote
|
||||
public void meltdown() {
|
||||
@ -401,6 +406,7 @@ public abstract class TileEntityRBMKBase extends TileEntityLoadedBase implements
|
||||
RBMKBase.dropLids = false;
|
||||
|
||||
columns.clear();
|
||||
pipes.clear();
|
||||
getFF(xCoord, yCoord, zCoord);
|
||||
|
||||
int minX = xCoord;
|
||||
@ -456,6 +462,42 @@ public abstract class TileEntityRBMKBase extends TileEntityLoadedBase implements
|
||||
}
|
||||
}
|
||||
|
||||
/* Hanlde overpressure event */
|
||||
if(RBMKDials.getOverpressure(worldObj) && !pipes.isEmpty()) {
|
||||
HashSet<IFluidConductor> pipeBlocks = new HashSet();
|
||||
HashSet<IFluidConnector> pipeReceivers = new HashSet();
|
||||
|
||||
//unify all parts into single sets to prevent redundancy
|
||||
pipes.forEach(x -> {
|
||||
pipeBlocks.addAll(x.getLinks());
|
||||
pipeReceivers.addAll(x.getSubscribers());
|
||||
});
|
||||
|
||||
int count = 0;
|
||||
int max = Math.min(pipeBlocks.size() / 5, 100);
|
||||
Iterator<IFluidConductor> itPipes = pipeBlocks.iterator();
|
||||
Iterator<IFluidConnector> itReceivers = pipeReceivers.iterator();
|
||||
|
||||
while(itPipes.hasNext() && count < max) {
|
||||
IFluidConductor pipe = itPipes.next();
|
||||
if(pipe instanceof TileEntity) {
|
||||
TileEntity tile = (TileEntity) pipe;
|
||||
worldObj.setBlock(tile.xCoord, tile.yCoord, tile.zCoord, Blocks.air);
|
||||
}
|
||||
count++;
|
||||
}
|
||||
|
||||
while(itReceivers.hasNext()) {
|
||||
IFluidConnector con = itReceivers.next();
|
||||
if(con instanceof TileEntity) {
|
||||
TileEntity tile = (TileEntity) con;
|
||||
worldObj.setBlock(tile.xCoord, tile.yCoord, tile.zCoord, Blocks.air);
|
||||
//TODO: create an interface so overpressure can be handled by machines themselves
|
||||
worldObj.newExplosion(null, tile.xCoord + 0.5, tile.yCoord + 0.5, tile.zCoord + 0.5, 5F, false, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int smallDim = Math.min(maxX - minX, maxZ - minZ);
|
||||
int avgX = minX + (maxX - minX) / 2;
|
||||
int avgZ = minZ + (maxZ - minZ) / 2;
|
||||
|
||||
@ -4,6 +4,9 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import api.hbm.fluid.IFluidStandardTransceiver;
|
||||
import api.hbm.fluid.IFluidUser;
|
||||
import api.hbm.fluid.IPipeNet;
|
||||
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.entity.projectile.EntityRBMKDebris.DebrisType;
|
||||
import com.hbm.interfaces.IControlReceiver;
|
||||
@ -269,6 +272,15 @@ public class TileEntityRBMKBoiler extends TileEntityRBMKSlottedBase implements I
|
||||
spawnDebris(DebrisType.BLANK);
|
||||
}
|
||||
|
||||
if(RBMKDials.getOverpressure(worldObj)) {
|
||||
for(DirPos pos : getOutputPos()) {
|
||||
IPipeNet net = IFluidUser.getPipeNet(worldObj, pos.getX(), pos.getY(), pos.getZ(), steam.getTankType());
|
||||
if(net != null) {
|
||||
this.pipes.add(net);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
super.onMelt(reduce);
|
||||
}
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
"modid": "hbm",
|
||||
"name": "Hbm's Nuclear Tech",
|
||||
"description": "A mod that adds weapons, nuclear themed stuff and machines",
|
||||
"version":"1.0.27_X4438",
|
||||
"version":"1.0.27_X4441",
|
||||
"mcversion": "1.7.10",
|
||||
"url": "",
|
||||
"updateUrl": "",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user