mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
oh my fucking god
This commit is contained in:
parent
bc0d1059d8
commit
931bbb3d8c
@ -1,6 +1,16 @@
|
|||||||
package com.hbm.handler.neutron;
|
package com.hbm.handler.neutron;
|
||||||
|
|
||||||
|
import api.hbm.block.IPileNeutronReceiver;
|
||||||
|
import com.hbm.blocks.ModBlocks;
|
||||||
import com.hbm.tileentity.machine.pile.TileEntityPileBase;
|
import com.hbm.tileentity.machine.pile.TileEntityPileBase;
|
||||||
|
import com.hbm.tileentity.machine.rbmk.TileEntityRBMKBase;
|
||||||
|
import com.hbm.util.ContaminationUtil;
|
||||||
|
import com.hbm.util.fauxpointtwelve.BlockPos;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.AxisAlignedBB;
|
||||||
|
import net.minecraft.util.Vec3;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -9,14 +19,110 @@ import java.util.Map;
|
|||||||
|
|
||||||
public class PileNeutronHandler {
|
public class PileNeutronHandler {
|
||||||
|
|
||||||
|
public static int range = 5;
|
||||||
|
|
||||||
public static class PileNeutronNode extends NeutronNode {
|
public static class PileNeutronNode extends NeutronNode {
|
||||||
|
|
||||||
public PileNeutronNode(TileEntityPileBase tile) {
|
public PileNeutronNode(TileEntityPileBase tile) {
|
||||||
super(tile, NeutronStream.NeutronType.RBMK);
|
super(tile, NeutronStream.NeutronType.PILE);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static PileNeutronNode makeNode(TileEntityPileBase tile) {
|
||||||
|
BlockPos pos = new BlockPos(tile);
|
||||||
|
if (NeutronNodeWorld.nodeCache.containsKey(pos))
|
||||||
|
return (PileNeutronNode) NeutronNodeWorld.getNode(pos);
|
||||||
|
return new PileNeutronNode(tile);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static TileEntity blockPosToTE(World worldObj, BlockPos pos) {
|
||||||
|
return worldObj.getTileEntity(pos.getX(), pos.getY(), pos.getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class PileNeutronStream extends NeutronStream {
|
||||||
|
|
||||||
|
public PileNeutronStream(NeutronNode origin, Vec3 vector) {
|
||||||
|
super(origin, vector);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PileNeutronStream(NeutronNode origin, Vec3 vector, double flux) {
|
||||||
|
super(origin, vector, flux, 0D, NeutronType.PILE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void runStreamInteraction(World worldObj) {
|
||||||
|
|
||||||
|
//Random rand = origin.tile.getWorldObj().rand;
|
||||||
|
//Vec3 vec = Vec3.createVectorHelper(1, 0, 0);
|
||||||
|
//vec.rotateAroundZ((float)(rand.nextDouble() * Math.PI * 2D));
|
||||||
|
//vec.rotateAroundY((float)(rand.nextDouble() * Math.PI * 2D));
|
||||||
|
//vec.rotateAroundX((float)(rand.nextDouble() * Math.PI * 2D));
|
||||||
|
|
||||||
|
TileEntityPileBase originTE = (TileEntityPileBase) origin.tile;
|
||||||
|
BlockPos pos = new BlockPos(originTE);
|
||||||
|
|
||||||
|
for(float i = 1; i <= range; i += 0.5F) {
|
||||||
|
|
||||||
|
BlockPos node = new BlockPos(
|
||||||
|
(int)Math.floor(pos.getX() + 0.5 + vector.xCoord * i),
|
||||||
|
(int)Math.floor(pos.getY() + 0.5 + vector.yCoord * i),
|
||||||
|
(int)Math.floor(pos.getZ() + 0.5 + vector.zCoord * i)
|
||||||
|
);
|
||||||
|
|
||||||
|
TileEntity tile;
|
||||||
|
|
||||||
|
if (NeutronNodeWorld.nodeCache.containsKey(node))
|
||||||
|
tile = NeutronNodeWorld.nodeCache.get(node).tile;
|
||||||
|
else {
|
||||||
|
tile = blockPosToTE(worldObj, node);
|
||||||
|
if (tile == null)
|
||||||
|
return; // Doesn't exist anymore!
|
||||||
|
if (tile instanceof TileEntityPileBase)
|
||||||
|
NeutronNodeWorld.addNode(new PileNeutronNode((TileEntityPileBase) tile));
|
||||||
|
}
|
||||||
|
|
||||||
|
TileEntityPileBase te = (TileEntityPileBase) tile;
|
||||||
|
Block block = te.getBlockType();
|
||||||
|
|
||||||
|
|
||||||
|
// Return when a boron block is hit
|
||||||
|
if(block == ModBlocks.block_boron)
|
||||||
|
return;
|
||||||
|
|
||||||
|
else if(block == ModBlocks.concrete ||
|
||||||
|
block == ModBlocks.concrete_smooth ||
|
||||||
|
block == ModBlocks.concrete_asbestos ||
|
||||||
|
block == ModBlocks.concrete_colored ||
|
||||||
|
block == ModBlocks.brick_concrete)
|
||||||
|
fluxQuantity *= 0.25;
|
||||||
|
|
||||||
|
int meta = te.getBlockMetadata();
|
||||||
|
|
||||||
|
if(block == ModBlocks.block_graphite_rod && (meta & 8) == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(te instanceof IPileNeutronReceiver) {
|
||||||
|
|
||||||
|
IPileNeutronReceiver rec = (IPileNeutronReceiver) te;
|
||||||
|
rec.receiveNeutrons((int) fluxQuantity);
|
||||||
|
|
||||||
|
if(block != ModBlocks.block_graphite_detector || (meta & 8) == 0)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int x = (int) (node.getX() + 0.5);
|
||||||
|
int y = (int) (node.getY() + 0.5);
|
||||||
|
int z = (int) (node.getZ() + 0.5);
|
||||||
|
List<EntityLivingBase> entities = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(x, y, z, x, y, z));
|
||||||
|
|
||||||
|
if(entities != null)
|
||||||
|
for(EntityLivingBase e : entities)
|
||||||
|
ContaminationUtil.contaminate(e, ContaminationUtil.HazardType.RADIATION, ContaminationUtil.ContaminationType.CREATIVE, (float) (fluxQuantity / 4D));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// The big one!! Runs all interactions for neutrons.
|
// The big one!! Runs all interactions for neutrons.
|
||||||
public static void runAllInteractions() {
|
public static void runAllInteractions() {
|
||||||
|
|
||||||
@ -40,5 +146,15 @@ public class PileNeutronHandler {
|
|||||||
}
|
}
|
||||||
world.getValue().removeAllStreams();
|
world.getValue().removeAllStreams();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (Map.Entry<World, NeutronNodeWorld.StreamWorld> world : NeutronNodeWorld.streamWorlds.entrySet()) {
|
||||||
|
|
||||||
|
for (NeutronStream stream : world.getValue().streams) {
|
||||||
|
if (stream.type == NeutronStream.NeutronType.PILE)
|
||||||
|
stream.runStreamInteraction(world.getKey());
|
||||||
|
}
|
||||||
|
world.getValue().removeAllStreamsOfType(NeutronStream.NeutronType.PILE);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -410,8 +410,10 @@ public class RBMKNeutronHandler {
|
|||||||
ticks = 0;
|
ticks = 0;
|
||||||
List<BlockPos> toRemove = new ArrayList<>();
|
List<BlockPos> toRemove = new ArrayList<>();
|
||||||
for(NeutronNode cachedNode : NeutronNodeWorld.nodeCache.values()) {
|
for(NeutronNode cachedNode : NeutronNodeWorld.nodeCache.values()) {
|
||||||
RBMKNeutronNode node = (RBMKNeutronNode) cachedNode;
|
if (cachedNode.type == NeutronStream.NeutronType.RBMK) {
|
||||||
toRemove.addAll(node.checkNode());
|
RBMKNeutronNode node = (RBMKNeutronNode) cachedNode;
|
||||||
|
toRemove.addAll(node.checkNode());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(BlockPos pos : toRemove)
|
for(BlockPos pos : toRemove)
|
||||||
|
|||||||
@ -1,96 +1,49 @@
|
|||||||
package com.hbm.tileentity.machine.pile;
|
package com.hbm.tileentity.machine.pile;
|
||||||
|
|
||||||
import java.util.List;
|
import com.hbm.handler.neutron.NeutronNodeWorld;
|
||||||
import java.util.Random;
|
import com.hbm.handler.neutron.PileNeutronHandler;
|
||||||
|
import com.hbm.handler.neutron.PileNeutronHandler.PileNeutronStream;
|
||||||
|
import com.hbm.handler.neutron.PileNeutronHandler.PileNeutronNode;
|
||||||
|
|
||||||
import com.hbm.blocks.ModBlocks;
|
import com.hbm.util.fauxpointtwelve.BlockPos;
|
||||||
import com.hbm.util.ContaminationUtil;
|
|
||||||
import com.hbm.util.ContaminationUtil.ContaminationType;
|
|
||||||
import com.hbm.util.ContaminationUtil.HazardType;
|
|
||||||
|
|
||||||
import api.hbm.block.IPileNeutronReceiver;
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.AxisAlignedBB;
|
|
||||||
import net.minecraft.util.Vec3;
|
import net.minecraft.util.Vec3;
|
||||||
|
|
||||||
public abstract class TileEntityPileBase extends TileEntity {
|
public abstract class TileEntityPileBase extends TileEntity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public abstract void updateEntity();
|
public abstract void updateEntity();
|
||||||
|
|
||||||
protected void castRay(int flux, int range) {
|
|
||||||
Random rand = worldObj.rand;
|
|
||||||
Vec3 vec = Vec3.createVectorHelper(1, 0, 0);
|
|
||||||
vec.rotateAroundZ((float)(rand.nextDouble() * Math.PI * 2D));
|
|
||||||
vec.rotateAroundY((float)(rand.nextDouble() * Math.PI * 2D));
|
|
||||||
vec.rotateAroundX((float)(rand.nextDouble() * Math.PI * 2D));
|
|
||||||
|
|
||||||
int prevX = xCoord;
|
|
||||||
int prevY = yCoord;
|
|
||||||
int prevZ = zCoord;
|
|
||||||
|
|
||||||
for(float i = 1; i <= range; i += 0.5F) {
|
|
||||||
|
|
||||||
int x = (int)Math.floor(xCoord + 0.5 + vec.xCoord * i);
|
@Override
|
||||||
int y = (int)Math.floor(yCoord + 0.5 + vec.yCoord * i);
|
public void invalidate() {
|
||||||
int z = (int)Math.floor(zCoord + 0.5 + vec.zCoord * i);
|
super.invalidate();
|
||||||
|
|
||||||
if(x == prevX && y == prevY && z == prevZ)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
prevX = x;
|
NeutronNodeWorld.removeNode(new BlockPos(this));
|
||||||
prevY = y;
|
}
|
||||||
prevZ = z;
|
|
||||||
|
protected void castRay(int flux) {
|
||||||
/*if(i == range || i == 1) {
|
|
||||||
NBTTagCompound data2 = new NBTTagCompound();
|
BlockPos pos = new BlockPos(this);
|
||||||
data2.setString("type", "vanillaExt");
|
|
||||||
data2.setString("mode", i == range ? "greendust" :
|
if (flux == 0) {
|
||||||
i == 1 ? "reddust" : "bluedust");
|
// simple way to remove the node from the cache when no flux is going into it!
|
||||||
data2.setDouble("posX", xCoord + 0.5 + vec.xCoord * i);
|
NeutronNodeWorld.removeNode(pos);
|
||||||
data2.setDouble("posY", yCoord + 0.5 + vec.yCoord * i);
|
return;
|
||||||
data2.setDouble("posZ", zCoord + 0.5 + vec.zCoord * i);
|
|
||||||
MainRegistry.proxy.effectNT(data2);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
Block b = worldObj.getBlock(x, y, z);
|
|
||||||
|
|
||||||
if(b == ModBlocks.concrete || b == ModBlocks.concrete_smooth || b == ModBlocks.concrete_asbestos || b == ModBlocks.concrete_colored || b == ModBlocks.brick_concrete)
|
|
||||||
flux *= 0.25;
|
|
||||||
|
|
||||||
if(b == ModBlocks.block_boron)
|
|
||||||
return;
|
|
||||||
|
|
||||||
int meta = worldObj.getBlockMetadata(x, y, z);
|
|
||||||
|
|
||||||
if(b == ModBlocks.block_graphite_rod && (meta & 8) == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
TileEntity te = worldObj.getTileEntity(x, y, z);
|
|
||||||
|
|
||||||
if(te instanceof IPileNeutronReceiver) {
|
|
||||||
|
|
||||||
//this part throttles neutron efficiency for reactions that are way too close, efficiency reaches 100% after 1.5 meters
|
|
||||||
//This entire time, this multiplier has been using the max distance, not the actual one, meaning efficency has always been 100%
|
|
||||||
//float mult = Math.min((float)i / 1.5F, 1F);
|
|
||||||
//int n = (int)(flux * mult);
|
|
||||||
|
|
||||||
IPileNeutronReceiver rec = (IPileNeutronReceiver) te;
|
|
||||||
rec.receiveNeutrons(flux);
|
|
||||||
|
|
||||||
if(b != ModBlocks.block_graphite_detector || (meta & 8) == 0)
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<EntityLivingBase> entities = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(x + 0.5, y + 0.5, z + 0.5, x + 0.5, y + 0.5, z + 0.5));
|
|
||||||
|
|
||||||
if(entities != null)
|
|
||||||
for(EntityLivingBase e : entities) {
|
|
||||||
|
|
||||||
ContaminationUtil.contaminate(e, HazardType.RADIATION, ContaminationType.CREATIVE, flux / 4F);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PileNeutronNode node = (PileNeutronNode) NeutronNodeWorld.getNode(pos);
|
||||||
|
|
||||||
|
if(node == null) {
|
||||||
|
node = PileNeutronHandler.makeNode(this);
|
||||||
|
NeutronNodeWorld.addNode(node);
|
||||||
|
}
|
||||||
|
|
||||||
|
Vec3 neutronVector = Vec3.createVectorHelper(1, 0, 0);
|
||||||
|
|
||||||
|
neutronVector.rotateAroundX((float)(Math.PI * 2D * worldObj.rand.nextDouble()));
|
||||||
|
neutronVector.rotateAroundY((float)(Math.PI * 2D * worldObj.rand.nextDouble()));
|
||||||
|
neutronVector.rotateAroundZ((float)(Math.PI * 2D * worldObj.rand.nextDouble()));
|
||||||
|
|
||||||
|
new PileNeutronStream(node, neutronVector, flux);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -35,7 +35,7 @@ public class TileEntityPileBreedingFuel extends TileEntityPileBase implements IP
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
for(int i = 0; i < 2; i++)
|
for(int i = 0; i < 2; i++)
|
||||||
this.castRay(1, 5);
|
this.castRay(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -71,7 +71,7 @@ public class TileEntityPileFuel extends TileEntityPileBase implements IPileNeutr
|
|||||||
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), 5);
|
this.castRay((int) Math.max(reaction * 0.25, 1));
|
||||||
|
|
||||||
return lastProgress;
|
return lastProgress;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,7 +12,7 @@ public class TileEntityPileSource extends TileEntityPileBase {
|
|||||||
int n = this.getBlockType() == ModBlocks.block_graphite_source ? 1 : 2;
|
int n = this.getBlockType() == ModBlocks.block_graphite_source ? 1 : 2;
|
||||||
|
|
||||||
for(int i = 0; i < 12; i++) {
|
for(int i = 0; i < 12; i++) {
|
||||||
this.castRay(n, 5);
|
this.castRay(n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user