RBMK flux and ladders, many ladders

This commit is contained in:
Bob 2021-04-09 00:28:56 +02:00
parent 84f16755e6
commit e0a5d3f1d0
25 changed files with 284 additions and 53 deletions

View File

@ -34,6 +34,7 @@ import com.hbm.main.MainRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.block.Block;
import net.minecraft.block.BlockFalling;
import net.minecraft.block.BlockLadder;
import net.minecraft.block.material.*;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraftforge.fluids.Fluid;
@ -182,6 +183,8 @@ public class ModBlocks {
public static Block block_white_phosphorus;
public static Block block_red_phosphorus;
public static Block block_fallout;
public static Block block_lanthanium;
public static Block block_actinium;
public static Block block_australium;
public static Block block_weidanium;
@ -560,9 +563,20 @@ public class ModBlocks {
public static Block fluid_duct;
public static Block conveyor;
public static Block chain;
public static Block ladder_sturdy;
public static Block ladder_iron;
public static Block ladder_gold;
public static Block ladder_aluminium;
public static Block ladder_copper;
public static Block ladder_titanium;
public static Block ladder_lead;
public static Block ladder_cobalt;
public static Block ladder_steel;
public static Block ladder_tungsten;
public static Block barrel_plastic;
public static Block barrel_corroded;
public static Block barrel_iron;
@ -1098,6 +1112,8 @@ public class ModBlocks {
block_white_phosphorus = new BlockHazard(Material.rock).addFire(15).toBlock().setBlockName("block_white_phosphorus").setCreativeTab(MainRegistry.blockTab).setHardness(5.0F).setResistance(10.0F).setBlockTextureName(RefStrings.MODID + ":block_white_phosphorus");
block_red_phosphorus = new BlockHazardFalling().addFire(15).toBlock().setStepSound(Block.soundTypeSand).setBlockName("block_red_phosphorus").setCreativeTab(MainRegistry.blockTab).setHardness(5.0F).setResistance(10.0F).setBlockTextureName(RefStrings.MODID + ":block_red_phosphorus");
block_fallout = new BlockHazardFalling().addRadiation(ItemHazard.fo * ItemHazard.block).toBlock().setStepSound(Block.soundTypeGravel).setBlockName("block_fallout").setCreativeTab(MainRegistry.blockTab).setHardness(0.2F).setBlockTextureName(RefStrings.MODID + ":ash");
block_lanthanium = new BlockGeneric(Material.iron).setBlockName("block_lanthanium").setCreativeTab(MainRegistry.blockTab).setStepSound(Block.soundTypeMetal).setHardness(5.0F).setResistance(10.0F).setBlockTextureName(RefStrings.MODID + ":block_lanthanium");
block_actinium = new BlockGeneric(Material.iron).setBlockName("block_actinium").setCreativeTab(MainRegistry.blockTab).setStepSound(Block.soundTypeMetal).setHardness(5.0F).setResistance(10.0F).setBlockTextureName(RefStrings.MODID + ":block_actinium");
block_australium = new BlockGeneric(Material.iron).setBlockName("block_australium").setCreativeTab(MainRegistry.blockTab).setHardness(5.0F).setResistance(10.0F).setBlockTextureName(RefStrings.MODID + ":block_australium");
block_weidanium = new BlockGeneric(Material.iron).setBlockName("block_weidanium").setCreativeTab(MainRegistry.blockTab).setHardness(5.0F).setResistance(10.0F).setBlockTextureName(RefStrings.MODID + ":block_weidanium");
@ -1395,6 +1411,17 @@ public class ModBlocks {
chain = new BlockChain(Material.iron).setBlockName("dungeon_chain").setHardness(0.25F).setResistance(2.0F).setCreativeTab(MainRegistry.blockTab).setBlockTextureName(RefStrings.MODID + ":chain");
ladder_sturdy = new BlockNTMLadder().setBlockName("ladder_sturdy").setHardness(0.25F).setResistance(2.0F).setCreativeTab(MainRegistry.blockTab).setBlockTextureName(RefStrings.MODID + ":ladder_sturdy");
ladder_iron = new BlockNTMLadder().setBlockName("ladder_iron").setHardness(0.25F).setResistance(2.0F).setCreativeTab(MainRegistry.blockTab).setBlockTextureName(RefStrings.MODID + ":ladder_iron");
ladder_gold = new BlockNTMLadder().setBlockName("ladder_gold").setHardness(0.25F).setResistance(2.0F).setCreativeTab(MainRegistry.blockTab).setBlockTextureName(RefStrings.MODID + ":ladder_gold");
ladder_aluminium = new BlockNTMLadder().setBlockName("ladder_aluminium").setHardness(0.25F).setResistance(2.0F).setCreativeTab(MainRegistry.blockTab).setBlockTextureName(RefStrings.MODID + ":ladder_aluminium");
ladder_copper = new BlockNTMLadder().setBlockName("ladder_copper").setHardness(0.25F).setResistance(2.0F).setCreativeTab(MainRegistry.blockTab).setBlockTextureName(RefStrings.MODID + ":ladder_copper");
ladder_titanium = new BlockNTMLadder().setBlockName("ladder_titanium").setHardness(0.25F).setResistance(2.0F).setCreativeTab(MainRegistry.blockTab).setBlockTextureName(RefStrings.MODID + ":ladder_titanium");
ladder_lead = new BlockNTMLadder().setBlockName("ladder_lead").setHardness(0.25F).setResistance(2.0F).setCreativeTab(MainRegistry.blockTab).setBlockTextureName(RefStrings.MODID + ":ladder_lead");
ladder_cobalt = new BlockNTMLadder().setBlockName("ladder_cobalt").setHardness(0.25F).setResistance(2.0F).setCreativeTab(MainRegistry.blockTab).setBlockTextureName(RefStrings.MODID + ":ladder_cobalt");
ladder_steel = new BlockNTMLadder().setBlockName("ladder_steel").setHardness(0.25F).setResistance(2.0F).setCreativeTab(MainRegistry.blockTab).setBlockTextureName(RefStrings.MODID + ":ladder_steel");
ladder_tungsten = new BlockNTMLadder().setBlockName("ladder_tungsten").setHardness(0.25F).setResistance(2.0F).setCreativeTab(MainRegistry.blockTab).setBlockTextureName(RefStrings.MODID + ":ladder_tungsten");
barrel_plastic = new BlockFluidBarrel(Material.iron, 12000).setBlockName("barrel_plastic").setStepSound(Block.soundTypeStone).setHardness(2.0F).setResistance(5.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":barrel_plastic");
barrel_corroded = new BlockFluidBarrel(Material.iron, 6000).setBlockName("barrel_corroded").setStepSound(Block.soundTypeMetal).setHardness(2.0F).setResistance(5.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":barrel_corroded");
barrel_iron = new BlockFluidBarrel(Material.iron, 8000).setBlockName("barrel_iron").setStepSound(Block.soundTypeMetal).setHardness(2.0F).setResistance(5.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":barrel_iron");
@ -1872,6 +1899,8 @@ public class ModBlocks {
GameRegistry.registerBlock(block_unobtainium, ItemOreBlock.class, block_unobtainium.getUnlocalizedName());
GameRegistry.registerBlock(block_daffergon, ItemOreBlock.class, block_daffergon.getUnlocalizedName());
GameRegistry.registerBlock(block_verticium, ItemOreBlock.class, block_verticium.getUnlocalizedName());
GameRegistry.registerBlock(block_lanthanium, block_lanthanium.getUnlocalizedName());
GameRegistry.registerBlock(block_actinium, block_actinium.getUnlocalizedName());
//Bottlecap Blocks
GameRegistry.registerBlock(block_cap_nuka, block_cap_nuka.getUnlocalizedName());
@ -2212,6 +2241,17 @@ public class ModBlocks {
GameRegistry.registerBlock(fluid_duct, fluid_duct.getUnlocalizedName());
GameRegistry.registerBlock(conveyor, conveyor.getUnlocalizedName());
GameRegistry.registerBlock(chain, chain.getUnlocalizedName());
GameRegistry.registerBlock(ladder_sturdy, ladder_sturdy.getUnlocalizedName());
GameRegistry.registerBlock(ladder_iron, ladder_iron.getUnlocalizedName());
GameRegistry.registerBlock(ladder_gold, ladder_gold.getUnlocalizedName());
GameRegistry.registerBlock(ladder_titanium, ladder_titanium.getUnlocalizedName());
GameRegistry.registerBlock(ladder_copper, ladder_copper.getUnlocalizedName());
GameRegistry.registerBlock(ladder_tungsten, ladder_tungsten.getUnlocalizedName());
GameRegistry.registerBlock(ladder_aluminium, ladder_aluminium.getUnlocalizedName());
GameRegistry.registerBlock(ladder_steel, ladder_steel.getUnlocalizedName());
GameRegistry.registerBlock(ladder_lead, ladder_lead.getUnlocalizedName());
GameRegistry.registerBlock(ladder_cobalt, ladder_cobalt.getUnlocalizedName());
GameRegistry.registerBlock(barrel_plastic, ItemBlockLore.class, barrel_plastic.getUnlocalizedName());
GameRegistry.registerBlock(barrel_corroded, ItemBlockLore.class, barrel_corroded.getUnlocalizedName());

View File

@ -0,0 +1,10 @@
package com.hbm.blocks.generic;
import net.minecraft.block.BlockLadder;
public class BlockNTMLadder extends BlockLadder {
public BlockNTMLadder() {
super();
}
}

View File

@ -43,7 +43,7 @@ public class GUIRBMKRod extends GuiContainer {
if(rod.slots[0] != null) {
drawTexturedModalRect(guiLeft + 34, guiTop + 21, 176, 0, 18, 67);
double depletion = ItemRBMKRod.getEnrichment(rod.slots[0]);
double depletion = 1D - ItemRBMKRod.getEnrichment(rod.slots[0]);
int d = (int)(depletion * 67);
drawTexturedModalRect(guiLeft + 34, guiTop + 21, 194, 0, 18, d);

View File

@ -5,6 +5,7 @@ import java.util.List;
import com.hbm.items.ModItems;
import com.hbm.items.special.ItemHazard;
import com.hbm.main.MainRegistry;
import com.hbm.tileentity.machine.rbmk.IRBMKFluxReceiver.NType;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
@ -13,13 +14,37 @@ import net.minecraft.util.EnumChatFormatting;
public class ItemRBMKRod extends ItemHazard {
String fullName = ""; //full name of the fuel rod
double funcStart; //starting point of the linear reactivity function
double funcEnd; //endpoint of the function
double xGen = 0.5D;; //multiplier for xenon production
double xBurn = 50D; //divider for xenon burnup
double heat = 1D; //heat produced per outFlux
double yield; //total potential inFlux the rod can take in its lifetime
String fullName = ""; //full name of the fuel rod
double funcStart; //starting point of the linear reactivity function
double funcEnd; //endpoint of the function
double xGen = 0.5D;; //multiplier for xenon production
double xBurn = 50D; //divider for xenon burnup
double heat = 1D; //heat produced per outFlux
double yield; //total potential inFlux the rod can take in its lifetime
double meltingPoint = 1000D; //the maximum heat of the rod's hull before shit hits the fan. the core can be as hot as it wants to be
double diffusion = 1D; //the speed at which the core heats the hull
public NType nType = NType.SLOW; //neutronType, the most efficient neutron type for fission
public NType rType = NType.FAST; //releaseType, the type of neutrons released by this fuel
/* _____
* ,I I I I,
* |'-----'|
* | |
* '-----'
* I I I I
* I I I I
* I I I I
* I I I I
* I I I I
* I I I I
* I I I I
* |'-----'|
* | |
* '-----'
* I I I I
*
* i drew a fuel rod yay
*/
public ItemRBMKRod(String fullName) {
@ -40,6 +65,12 @@ public class ItemRBMKRod extends ItemHazard {
this.funcEnd = funcEnd;
return this;
}
public ItemRBMKRod setNeutronTypes(NType nType, NType rType) {
this.nType = nType;
this.rType = rType;
return this;
}
/**
* Adjusts the input flux using the poison level
@ -72,16 +103,26 @@ public class ItemRBMKRod extends ItemHazard {
setYield(stack, y);
//TODO: core heatup
return outFlux;
}
/**
* Call this after 'burn' and supply its returned outFlux to get the appropriate heat
* @param flux
* @return heat generated from outFlux
* Heat up the core based on the outFlux, then move some heat to the hull
* @param stack
*/
public double heatFromFlux(double flux) {
return flux * this.heat;
public void updateHeat(ItemStack stack) {
//TODO
}
/**
* return one tick's worth of heat and cool the hull of the fuel rod, this heat goes into the fuel rod assembly block
* @param stack
* @return
*/
public double provideHeat(ItemStack stack) {
return 0; //TODO
}
/**
@ -136,65 +177,101 @@ public class ItemRBMKRod extends ItemHazard {
}
list.add(EnumChatFormatting.GREEN + "Depletion: " + (100D - ((getYield(stack) * 1000D / yield) / 10D)) + "%");
list.add(EnumChatFormatting.LIGHT_PURPLE + "Xenon poison: " + ((getPoison(stack) * 10D) / 10D) + "%");
list.add(EnumChatFormatting.GOLD + "Heat per tick at full power: " + heat);
list.add(EnumChatFormatting.YELLOW + "Flux function:");
list.add(EnumChatFormatting.WHITE + " f(0) = " + funcStart);
list.add(EnumChatFormatting.WHITE + " f(1) = " + funcEnd);
list.add(EnumChatFormatting.WHITE + " f(x) = " + funcStart + " + " + (funcEnd - funcStart) + " * x");
list.add(EnumChatFormatting.YELLOW + "Xenon gen function:");
list.add(EnumChatFormatting.WHITE + " g(x) = x * " + xGen);
list.add(EnumChatFormatting.YELLOW + "Xenon burn function:");
list.add(EnumChatFormatting.WHITE + " b(x) = x² * " + xBurn);
list.add(EnumChatFormatting.DARK_PURPLE + "Xenon poison: " + ((getPoison(stack) * 10D) / 10D) + "%");
list.add(EnumChatFormatting.BLUE + "Splits with: " + nType.localized);
list.add(EnumChatFormatting.BLUE + "Splits into: " + rType.localized);
list.add(EnumChatFormatting.YELLOW + "Flux function: " + EnumChatFormatting.WHITE + "" + funcStart + " + " + (funcEnd - funcStart) + " * x");
list.add(EnumChatFormatting.YELLOW + "Xenon gen function: " + EnumChatFormatting.WHITE + "x * " + xGen);
list.add(EnumChatFormatting.YELLOW + "Xenon burn function: " + EnumChatFormatting.WHITE + "x² * " + xBurn);
list.add(EnumChatFormatting.GOLD + "Heat per tick at full power: " + heat + "°C");
list.add(EnumChatFormatting.GOLD + "Diffusion: " + diffusion + "°C/t");
list.add(EnumChatFormatting.RED + "Skin temp: " + ((int)(getHullHeat(stack) * 10D) / 10D) + "°C");
list.add(EnumChatFormatting.RED + "Core temp: " + ((int)(getCoreHeat(stack) * 10D) / 10D) + "°C");
list.add(EnumChatFormatting.DARK_RED + "Melting point: " + meltingPoint + "°C");
super.addInformation(stack, player, list, bool);
}
/* __ __ ____ ________
* | \ | | | __ \ |__ __|
* | \ | | | |__| | | |
* | |\\| | | __ < | |
* | | \ | | |__| | | |
* |__| \__| |_____/ |__|
*/
public static void setYield(ItemStack stack, double yield) {
if(!stack.hasTagCompound())
stack.stackTagCompound = new NBTTagCompound();
stack.stackTagCompound.setDouble("yield", yield);
setDouble(stack, "yield", yield);
}
public static double getYield(ItemStack stack) {
if(stack.hasTagCompound()) {
return stack.stackTagCompound.getDouble("yield");
}
if(stack.getItem() instanceof ItemRBMKRod) {
return ((ItemRBMKRod)stack.getItem()).yield;
return getDouble(stack, "yield");
}
return 0;
}
public static void setPoison(ItemStack stack, double yield) {
if(!stack.hasTagCompound())
stack.stackTagCompound = new NBTTagCompound();
stack.stackTagCompound.setDouble("xenon", yield);
public static void setPoison(ItemStack stack, double xenon) {
setDouble(stack, "xenon", xenon);
}
public static double getPoison(ItemStack stack) {
if(stack.hasTagCompound()) {
return stack.stackTagCompound.getDouble("xenon");
}
return 0;
return getDouble(stack, "xenon");
}
public static void setCoreHeat(ItemStack stack, double heat) {
setDouble(stack, "core", heat);
}
public static double getCoreHeat(ItemStack stack) {
return getDouble(stack, "core");
}
public static void setHullHeat(ItemStack stack, double heat) {
setDouble(stack, "hull", heat);
}
public static double getHullHeat(ItemStack stack) {
return getDouble(stack, "hull");
}
@Override
public boolean showDurabilityBar(ItemStack stack) {
return getDurabilityForDisplay(stack) < 1D;
return getDurabilityForDisplay(stack) > 0D;
}
@Override
public double getDurabilityForDisplay(ItemStack stack) {
return getEnrichment(stack);
return 1D - getEnrichment(stack);
}
public static void setDouble(ItemStack stack, String key, double yield) {
if(!stack.hasTagCompound())
setNBTDefaults(stack);
stack.stackTagCompound.setDouble(key, yield);
}
public static double getDouble(ItemStack stack, String key) {
if(!stack.hasTagCompound())
setNBTDefaults(stack);
return stack.stackTagCompound.getDouble(key);
}
/**
* Sets up the default values for all NBT data because doing it one-by-one will only correctly set the first called value and the rest stays 0 which is very not good
* @param stack
*/
private static void setNBTDefaults(ItemStack stack) {
stack.stackTagCompound = new NBTTagCompound();
setYield(stack, ((ItemRBMKRod)stack.getItem()).yield);
setCoreHeat(stack, 20.0D);
setHullHeat(stack, 20.0D);
}
}

View File

@ -2,5 +2,17 @@ package com.hbm.tileentity.machine.rbmk;
public interface IRBMKFluxReceiver {
public void receiveFlux(float flux);
public enum NType {
FAST("Fast Neutrons"),
SLOW("Slow Neutrons"),
ANY("All Neutrons"); //not to be used for reactor flux calculation, only for the fuel designation
public String localized;
private NType(String loc) {
this.localized = loc;
}
}
public void receiveFlux(NType type, double flux);
}

View File

@ -47,7 +47,6 @@ public abstract class TileEntityRBMKBase extends TileEntity {
coolPassively();
}
public static final ForgeDirection[] heatDirs = new ForgeDirection[] {
ForgeDirection.NORTH,
ForgeDirection.EAST,

View File

@ -1,9 +1,15 @@
package com.hbm.tileentity.machine.rbmk;
import com.hbm.items.machine.ItemRBMKRod;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityRBMKRod extends TileEntityRBMKSlottedBase implements IRBMKFluxReceiver {
//amount of "neutron energy" buffered for the next tick to use for the reaction
private float flux;
private double fluxFast;
private double fluxSlow;
public TileEntityRBMKRod() {
super(1);
@ -15,7 +21,94 @@ public class TileEntityRBMKRod extends TileEntityRBMKSlottedBase implements IRBM
}
@Override
public void receiveFlux(float flux) {
this.flux += flux;
public void receiveFlux(NType type, double flux) {
switch(type) {
case FAST: this.fluxFast += flux; break;
case SLOW: this.fluxSlow += flux; break;
}
}
@Override
public void updateEntity() {
if(slots[0] != null && slots[0].getItem() instanceof ItemRBMKRod) {
ItemRBMKRod rod = ((ItemRBMKRod)slots[0].getItem());
double fluxIn = fluxFromType(rod.nType);
double fluxOut = rod.burn(slots[0], fluxIn);
NType rType = rod.rType;
spreadFlux(rType, fluxOut);
}
super.updateEntity();
}
/**
* SLOW: full efficiency for slow neutrons, fast neutrons have half efficiency
* FAST: fast neutrons have 100% efficiency, slow only 30%
* ANY: just add together whatever we have because who cares
* @param type
* @return
*/
private double fluxFromType(NType type) {
switch(type) {
case SLOW: return this.fluxFast * 0.5D + this.fluxSlow;
case FAST: return this.fluxFast + this.fluxSlow * 0.3D;
case ANY: return this.fluxFast + this.fluxSlow;
}
return 0.0D;
}
public static final ForgeDirection[] fluxDirs = new ForgeDirection[] {
ForgeDirection.NORTH,
ForgeDirection.EAST,
ForgeDirection.SOUTH,
ForgeDirection.WEST
};
private void spreadFlux(NType type, double fluxOut) {
int range = 5;
for(ForgeDirection dir : fluxDirs) {
NType stream = type;
for(int i = 1; i <= range; i++) {
TileEntity te = worldObj.getTileEntity(xCoord + dir.offsetX * i, yCoord, zCoord + dir.offsetZ * i);
//burn baby burn
if(te instanceof TileEntityRBMKRod) {
TileEntityRBMKRod rod = (TileEntityRBMKRod)te;
rod.receiveFlux(stream, fluxOut);
break;
}
//set neutrons to slow
if(te instanceof TileEntityRBMKModerator) {
stream = NType.SLOW;
continue;
}
//return the neutrons back to this with no further action required
if(te instanceof TileEntityRBMKReflector) {
this.receiveFlux(stream, fluxOut);
break;
}
//break the neutron flow and nothign else
if(te instanceof TileEntityRBMKAbsorber) {
break;
}
}
}
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 554 B

After

Width:  |  Height:  |  Size: 678 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 570 B

After

Width:  |  Height:  |  Size: 615 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 477 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 490 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 501 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 459 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 459 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 480 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 469 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 540 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 482 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 368 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 271 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 297 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 299 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 635 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 519 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 518 B