RBMK boilers and debugging overlays

This commit is contained in:
Bob 2021-04-10 18:42:02 +02:00
parent 07db4456af
commit f572329046
22 changed files with 340 additions and 53 deletions

View File

@ -4,22 +4,9 @@ import com.hbm.blocks.generic.*;
import com.hbm.blocks.generic.BlockHazard.ExtDisplayEffect;
import com.hbm.blocks.bomb.*;
import com.hbm.blocks.fluid.*;
import com.hbm.blocks.gas.BlockGasAsbestos;
import com.hbm.blocks.gas.BlockGasClorine;
import com.hbm.blocks.gas.BlockGasFlammable;
import com.hbm.blocks.gas.BlockGasMonoxide;
import com.hbm.blocks.gas.BlockGasRadon;
import com.hbm.blocks.gas.BlockGasRadonDense;
import com.hbm.blocks.gas.BlockGasRadonTomb;
import com.hbm.blocks.gas.*;
import com.hbm.blocks.machine.*;
import com.hbm.blocks.machine.rbmk.RBMKAbsorber;
import com.hbm.blocks.machine.rbmk.RBMKBlank;
import com.hbm.blocks.machine.rbmk.RBMKBoiler;
import com.hbm.blocks.machine.rbmk.RBMKControl;
import com.hbm.blocks.machine.rbmk.RBMKControlAuto;
import com.hbm.blocks.machine.rbmk.RBMKModerator;
import com.hbm.blocks.machine.rbmk.RBMKReflector;
import com.hbm.blocks.machine.rbmk.RBMKRod;
import com.hbm.blocks.machine.rbmk.*;
import com.hbm.blocks.network.*;
import com.hbm.blocks.test.*;
import com.hbm.blocks.turret.*;
@ -34,7 +21,6 @@ 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;
@ -864,6 +850,7 @@ public class ModBlocks {
public static Block rbmk_moderator;
public static Block rbmk_console;
public static final int guiID_rbmk_rod = 113;
public static final int guiID_rbmk_boiler = 114;
public static Block book_guide;

View File

@ -1,7 +1,11 @@
package com.hbm.blocks.machine.rbmk;
import com.hbm.blocks.ModBlocks;
import com.hbm.main.MainRegistry;
import com.hbm.tileentity.machine.rbmk.TileEntityRBMKBoiler;
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
@ -9,7 +13,30 @@ public class RBMKBoiler extends RBMKBase {
@Override
public TileEntity createNewTileEntity(World world, int meta) {
return new TileEntityRBMKBoiler();
if(meta >= this.offset)
return new TileEntityRBMKBoiler();
return null;
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
if(world.isRemote) {
return true;
} else if(!player.isSneaking()) {
int[] pos = this.findCore(world, x, y, z);
if(pos == null)
return false;
FMLNetworkHandler.openGui(player, MainRegistry.instance, ModBlocks.guiID_rbmk_boiler, world, pos[0], pos[1], pos[2]);
return true;
} else {
return true;
}
}
@Override

View File

@ -13,21 +13,25 @@ public class RBMKRod extends RBMKBase {
@Override
public TileEntity createNewTileEntity(World world, int meta) {
return new TileEntityRBMKRod();
if(meta >= this.offset)
return new TileEntityRBMKRod();
return null;
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
if(world.isRemote)
{
if(world.isRemote) {
return true;
} else if(!player.isSneaking())
{
int[] pos = this.findCore(world, x, y, z);
} else if(!player.isSneaking()) {
int[] pos = this.findCore(world, x, y, z);
if(pos == null)
return false;
FMLNetworkHandler.openGui(player, MainRegistry.instance, ModBlocks.guiID_rbmk_rod, world, pos[0], pos[1], pos[2]);
return true;
} else {

View File

@ -8,7 +8,7 @@ import com.hbm.inventory.inv.InventoryLeadBox;
import com.hbm.items.ModItems;
import com.hbm.tileentity.bomb.*;
import com.hbm.tileentity.machine.*;
import com.hbm.tileentity.machine.rbmk.TileEntityRBMKRod;
import com.hbm.tileentity.machine.rbmk.*;
import com.hbm.tileentity.turret.*;
import net.minecraft.entity.player.EntityPlayer;
@ -792,6 +792,13 @@ public class GUIHandler implements IGuiHandler {
}
return null;
}
case ModBlocks.guiID_rbmk_boiler: {
if(entity instanceof TileEntityRBMKBoiler) {
return new ContainerRBMKBoiler(player.inventory, (TileEntityRBMKBoiler) entity);
}
return null;
}
}
// NON-TE CONTAINERS
@ -1571,6 +1578,13 @@ public class GUIHandler implements IGuiHandler {
}
return null;
}
case ModBlocks.guiID_rbmk_boiler: {
if(entity instanceof TileEntityRBMKBoiler) {
return new GUIRBMKBoiler(player.inventory, (TileEntityRBMKBoiler) entity);
}
return null;
}
}
// ITEM GUIS

View File

@ -0,0 +1,45 @@
package com.hbm.inventory.container;
import com.hbm.tileentity.machine.rbmk.TileEntityRBMKBoiler;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class ContainerRBMKBoiler extends Container {
private TileEntityRBMKBoiler rbmk;
public ContainerRBMKBoiler(InventoryPlayer invPlayer, TileEntityRBMKBoiler tedf) {
rbmk = tedf;
for(int i = 0; i < 3; i++) {
for(int j = 0; j < 9; j++) {
this.addSlotToContainer(new Slot(invPlayer, j + i * 9 + 9, 8 + j * 18, 84 + i * 18 + 20));
}
}
for(int i = 0; i < 9; i++) {
this.addSlotToContainer(new Slot(invPlayer, i, 8 + i * 18, 142 + 20));
}
}
@Override
public ItemStack transferStackInSlot(EntityPlayer p_82846_1_, int par2) {
ItemStack var3 = null;
Slot var4 = (Slot) this.inventorySlots.get(par2);
if(var4 != null && var4.getHasStack()) {
return null;
}
return var3;
}
@Override
public boolean canInteractWith(EntityPlayer player) {
return rbmk.isUseableByPlayer(player);
}
}

View File

@ -0,0 +1,42 @@
package com.hbm.inventory.gui;
import org.lwjgl.opengl.GL11;
import com.hbm.inventory.container.ContainerRBMKBoiler;
import com.hbm.lib.RefStrings;
import com.hbm.tileentity.machine.rbmk.TileEntityRBMKBoiler;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
public class GUIRBMKBoiler extends GuiContainer {
private static ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/reactors/gui_rbmk_boiler.png");
private TileEntityRBMKBoiler rod;
public GUIRBMKBoiler(InventoryPlayer invPlayer, TileEntityRBMKBoiler tedf) {
super(new ContainerRBMKBoiler(invPlayer, tedf));
rod = tedf;
this.xSize = 176;
this.ySize = 186;
}
@Override
protected void drawGuiContainerForegroundLayer(int i, int j) {
String name = this.rod.hasCustomInventoryName() ? this.rod.getInventoryName() : I18n.format(this.rod.getInventoryName());
this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6, 4210752);
this.fontRendererObj.drawString(I18n.format("container.inventory"), 8, this.ySize - 96 + 2, 4210752);
}
@Override
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
}
}

View File

@ -14,17 +14,17 @@ 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
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
public String fullName = ""; //full name of the fuel rod
public double funcStart; //starting point of the linear reactivity function
public double funcEnd; //endpoint of the function
public double xGen = 0.5D;; //multiplier for xenon production
public double xBurn = 50D; //divider for xenon burnup
public double heat = 1D; //heat produced per outFlux
public double yield; //total potential inFlux the rod can take in its lifetime
public 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
public 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,

View File

@ -51,6 +51,8 @@ public class ItemUnstable extends Item {
world.spawnEntityInWorld(EntityNukeExplosionMK4.statFac(world, radius, entity.posX, entity.posY, entity.posZ));
world.playSoundAtEntity(entity, "hbm:entity.oldExplosion", 1.0F, 1.0F);
entity.attackEntityFrom(ModDamageSource.nuclearBlast, 10000);
stack.stackSize = 0;
}
}

View File

@ -44,6 +44,7 @@ import com.hbm.sound.MovingSoundXVL1456;
import com.hbm.tileentity.bomb.TileEntityNukeCustom;
import com.hbm.tileentity.bomb.TileEntityNukeCustom.CustomNukeEntry;
import com.hbm.tileentity.bomb.TileEntityNukeCustom.EnumEntryType;
import com.hbm.tileentity.machine.rbmk.TileEntityRBMKBase;
import com.hbm.util.I18nUtil;
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
import com.hbm.sound.MovingSoundPlayerLoop.EnumHbmSound;
@ -104,6 +105,11 @@ public class ModEventHandlerClient {
}
}
}
/// DODD DIAG HOOK FOR RBMK
if(event.type == ElementType.CROSSHAIRS) {
TileEntityRBMKBase.diagnosticPrintHook(event);
}
/// HANLDE ANIMATION BUSES ///

View File

@ -2,6 +2,7 @@ package com.hbm.packet;
import java.io.IOException;
import com.hbm.tileentity.INBTPacketReceiver;
import com.hbm.tileentity.TileEntityMachineBase;
import com.hbm.tileentity.TileEntityTickingBase;
@ -80,10 +81,9 @@ public class NBTPacket implements IMessage {
NBTTagCompound nbt = m.buffer.readNBTTagCompoundFromBuffer();
if(nbt != null) {
if(te instanceof TileEntityMachineBase)
((TileEntityMachineBase) te).networkUnpack(nbt);
if(te instanceof TileEntityTickingBase)
((TileEntityTickingBase) te).networkUnpack(nbt);
if(te instanceof INBTPacketReceiver)
((INBTPacketReceiver) te).networkUnpack(nbt);
}
} catch (IOException e) {

View File

@ -0,0 +1,8 @@
package com.hbm.tileentity;
import net.minecraft.nbt.NBTTagCompound;
public interface INBTPacketReceiver {
public void networkUnpack(NBTTagCompound nbt);
}

View File

@ -16,7 +16,7 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidTank;
public abstract class TileEntityMachineBase extends TileEntity implements ISidedInventory {
public abstract class TileEntityMachineBase extends TileEntity implements ISidedInventory, INBTPacketReceiver {
public ItemStack slots[];

View File

@ -8,7 +8,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.fluids.FluidTank;
public abstract class TileEntityTickingBase extends TileEntity {
public abstract class TileEntityTickingBase extends TileEntity implements INBTPacketReceiver {
public TileEntityTickingBase() { }

View File

@ -1,10 +1,30 @@
package com.hbm.tileentity.machine.rbmk;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import org.lwjgl.opengl.GL11;
import com.google.common.collect.Sets;
import com.hbm.blocks.machine.rbmk.RBMKBase;
import com.hbm.packet.NBTPacket;
import com.hbm.packet.PacketDispatcher;
import com.hbm.tileentity.INBTPacketReceiver;
import com.hbm.util.I18nUtil;
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.common.util.ForgeDirection;
/**
@ -12,7 +32,7 @@ import net.minecraftforge.common.util.ForgeDirection;
* @author hbm
*
*/
public abstract class TileEntityRBMKBase extends TileEntity {
public abstract class TileEntityRBMKBase extends TileEntity implements INBTPacketReceiver {
public double heat;
@ -44,8 +64,15 @@ public abstract class TileEntityRBMKBase extends TileEntity {
@Override
public void updateEntity() {
moveHeat();
coolPassively();
if(!worldObj.isRemote) {
moveHeat();
coolPassively();
NBTTagCompound data = new NBTTagCompound();
this.writeToNBT(data);
this.networkPack(data, 10);
}
}
public static final ForgeDirection[] heatDirs = new ForgeDirection[] {
@ -99,7 +126,11 @@ public abstract class TileEntityRBMKBase extends TileEntity {
* TODO: add faster passive cooling based on temperature (blackbody radiation has an exponent of 4!)
*/
private void coolPassively() {
this.heat -= this.passiveCooling();
if(heat < 0)
heat = 0D;
}
@Override
@ -115,4 +146,78 @@ public abstract class TileEntityRBMKBase extends TileEntity {
nbt.setDouble("heat", this.heat);
}
public void networkPack(NBTTagCompound nbt, int range) {
if(!worldObj.isRemote)
PacketDispatcher.wrapper.sendToAllAround(new NBTPacket(nbt, xCoord, yCoord, zCoord), new TargetPoint(this.worldObj.provider.dimensionId, xCoord, yCoord, zCoord, range));
}
public void networkUnpack(NBTTagCompound nbt) {
this.readFromNBT(nbt);
}
public void getDiagData(NBTTagCompound nbt) {
this.writeToNBT(nbt);
}
@SideOnly(Side.CLIENT)
public static void diagnosticPrintHook(RenderGameOverlayEvent.Pre event) {
Minecraft mc = Minecraft.getMinecraft();
World world = mc.theWorld;
MovingObjectPosition mop = mc.objectMouseOver;
ScaledResolution resolution = event.resolution;
if(mop != null && mop.typeOfHit == mop.typeOfHit.BLOCK && world.getBlock(mop.blockX, mop.blockY, mop.blockZ) instanceof RBMKBase) {
RBMKBase rbmk = (RBMKBase)world.getBlock(mop.blockX, mop.blockY, mop.blockZ);
int[] pos = rbmk.findCore(world, mop.blockX, mop.blockY, mop.blockZ);
if(pos == null)
return;
TileEntityRBMKBase te = (TileEntityRBMKBase)world.getTileEntity(pos[0], pos[1], pos[2]);
NBTTagCompound flush = new NBTTagCompound();
te.getDiagData(flush);
Set<String> keys = flush.func_150296_c();
GL11.glPushMatrix();
int pX = resolution.getScaledWidth() / 2 + 8;
int pZ = resolution.getScaledHeight() / 2;
List<String> exceptions = new ArrayList();
exceptions.add("x");
exceptions.add("y");
exceptions.add("z");
exceptions.add("items");
exceptions.add("id");
String title = "Dump of Ordered Data Diagnostic (DODD)";
mc.fontRenderer.drawString(title, pX + 1, pZ - 19, 0x006000);
mc.fontRenderer.drawString(title, pX, pZ - 20, 0x00FF00);
mc.fontRenderer.drawString(I18nUtil.resolveKey(rbmk.getUnlocalizedName() + ".name"), pX, pZ - 10, 0xFFFFFF);
String[] ents = new String[keys.size()];
keys.toArray(ents);
Arrays.sort(ents);
for(String key : ents) {
if(exceptions.contains(key))
continue;
mc.fontRenderer.drawString(key + ": " + flush.getTag(key), pX, pZ, 0xFFFFFF);
pZ += 10;
}
GL11.glDisable(GL11.GL_BLEND);
GL11.glPopMatrix();
Minecraft.getMinecraft().renderEngine.bindTexture(Gui.icons);
}
}
}

View File

@ -11,20 +11,17 @@ import com.hbm.inventory.FluidTank;
import com.hbm.lib.Library;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Vec3;
public class TileEntityRBMKBoiler extends TileEntityRBMKActiveBase implements IFluidAcceptor, IFluidSource, IControlReceiver {
public class TileEntityRBMKBoiler extends TileEntityRBMKSlottedBase implements IFluidAcceptor, IFluidSource, IControlReceiver {
public FluidTank feed;
public FluidTank steam;
public List<IFluidAcceptor> list = new ArrayList();
public TileEntityRBMKBoiler() {
super();
super(0);
feed = new FluidTank(FluidType.WATER, 10000, 0);
steam = new FluidTank(FluidType.STEAM, 1000000, 1);

View File

@ -1,7 +1,10 @@
package com.hbm.tileentity.machine.rbmk;
import net.minecraft.tileentity.TileEntity;
public class TileEntityRBMKControl extends TileEntityRBMKActiveBase {
public class TileEntityRBMKControl extends TileEntity {
@Override
public String getName() {
return "container.rbmkControl";
}
}

View File

@ -2,6 +2,7 @@ package com.hbm.tileentity.machine.rbmk;
import com.hbm.items.machine.ItemRBMKRod;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
@ -32,7 +33,7 @@ public class TileEntityRBMKRod extends TileEntityRBMKSlottedBase implements IRBM
@Override
public void updateEntity() {
if(slots[0] != null && slots[0].getItem() instanceof ItemRBMKRod) {
if(!worldObj.isRemote && slots[0] != null && slots[0].getItem() instanceof ItemRBMKRod) {
ItemRBMKRod rod = ((ItemRBMKRod)slots[0].getItem());
@ -111,4 +112,34 @@ public class TileEntityRBMKRod extends TileEntityRBMKSlottedBase implements IRBM
}
}
}
@Override
public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt);
this.fluxFast = nbt.getDouble("fluxFast");
this.fluxSlow = nbt.getDouble("fluxSlow");
}
@Override
public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
nbt.setDouble("fluxFast", this.fluxFast);
nbt.setDouble("fluxSlow", this.fluxSlow);
}
public void getDiagData(NBTTagCompound nbt) {
this.writeToNBT(nbt);
if(slots[0] != null && slots[0].getItem() instanceof ItemRBMKRod) {
ItemRBMKRod rod = ((ItemRBMKRod)slots[0].getItem());
nbt.setString("f_yield", rod.getYield(slots[0]) + " / " + rod.yield + " (" + (rod.getEnrichment(slots[0]) * 100) + "%)");
nbt.setString("f_xenon", rod.getPoison(slots[0]) + "%");
nbt.setString("f_heat", rod.getCoreHeat(slots[0]) + " / " + rod.getHullHeat(slots[0]) + " / " + rod.meltingPoint);
}
}
}

View File

@ -2761,6 +2761,14 @@ tile.radiobox.name=Rosenberg Ungeziefervernichter
tile.radiorec.name=Kaputtes UKW Radio
tile.rail_booster.name=Hochgeschwindigkeits-Boosterschienen
tile.rail_highspeed.name=Hochgeschwindigkeitsschienen
tile.rbmk_absorber.name=RBMK Bor-Neutronenabsorber
tile.rbmk_blank.name=RBMK Strukturteil
tile.rbmk_boiler.name=RBMK Dampfkanal
tile.rbmk_control.name=RBMK Steuerstäbe
tile.rbmk_control_auto.name=RBMK Automatische Steuerstäbe
tile.rbmk_moderator.name=RBMK Graphitmoderator
tile.rbmk_reflector.name=RBMK Wolframcarbid-Moderator
tile.rbmk_rod.name=RBMK Brennstäbe
tile.reactor_computer.name=Reaktorsteuerung
tile.reactor_conductor.name=Reaktorboiler
tile.reactor_control.name=Steuerstäbe

View File

@ -2772,6 +2772,14 @@ tile.radiobox.name=Rosenberg Pest Control Box
tile.radiorec.name=Broken FM Radio
tile.rail_booster.name=High Speed Booster Rail
tile.rail_highspeed.name=High Speed Rail
tile.rbmk_absorber.name=RBMK Boron Neutron Absorber
tile.rbmk_blank.name=RBMK Structural Column
tile.rbmk_boiler.name=RBMK Steam Channel
tile.rbmk_control.name=RBMK Control Rods
tile.rbmk_control_auto.name=RBMK Automatic Control Rods
tile.rbmk_moderator.name=RBMK Graphite Moderator
tile.rbmk_reflector.name=RBMK Tungsten Carbide Neutron Reflector
tile.rbmk_rod.name=RBMK Fuel Rod
tile.reactor_computer.name=Reactor Control
tile.reactor_conductor.name=Reactor Boiler
tile.reactor_control.name=Control Rods

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB