functional RBMK rods, boiler GUI work

This commit is contained in:
Bob 2021-04-17 16:58:31 +02:00
parent 4c9893715c
commit 82ca248049
15 changed files with 278 additions and 15 deletions

View File

@ -171,6 +171,7 @@ public class ModBlocks {
public static Block block_fallout;
public static Block block_lanthanium;
public static Block block_actinium;
public static Block block_tritium;
public static Block block_australium;
public static Block block_weidanium;
@ -852,6 +853,7 @@ public class ModBlocks {
public static final int guiID_rbmk_rod = 113;
public static final int guiID_rbmk_boiler = 114;
public static final int guiID_rbmk_control = 115;
public static final int guiID_rbmk_console = 116;
public static Block book_guide;
@ -1102,6 +1104,7 @@ public class ModBlocks {
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_tritium = new BlockRotatablePillar(Material.glass, RefStrings.MODID + ":block_tritium_top").setBlockName("block_tritium").setCreativeTab(MainRegistry.blockTab).setStepSound(Block.soundTypeGlass).setHardness(3.0F).setResistance(2.0F).setBlockTextureName(RefStrings.MODID + ":block_tritium_side");
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");
@ -1461,8 +1464,8 @@ public class ModBlocks {
fusion_hatch = new FusionHatch(Material.iron).setBlockName("fusion_hatch").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":fusion_hatch");
fusion_core = new FusionCore(Material.iron).setBlockName("fusion_core").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":fusion_core_side");
plasma = new BlockPlasma(Material.iron).setBlockName("plasma").setHardness(5.0F).setResistance(6000.0F).setLightLevel(1.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":plasma");
iter = new MachineITER().setBlockName("iter").setHardness(5.0F).setResistance(6000.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":iter");
plasma_heater = new MachinePlasmaHeater().setBlockName("plasma_heater").setHardness(5.0F).setResistance(6000.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":plasma_heater");
iter = new MachineITER().setBlockName("iter").setHardness(5.0F).setResistance(60.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":iter");
plasma_heater = new MachinePlasmaHeater().setBlockName("plasma_heater").setHardness(5.0F).setResistance(60.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":plasma_heater");
watz_element = new BlockPillar(Material.iron, RefStrings.MODID + ":watz_element_top").setBlockName("watz_element").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":watz_element_side");
watz_control = new BlockPillar(Material.iron, RefStrings.MODID + ":watz_control_top").setBlockName("watz_control").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":watz_control_side");
@ -1890,6 +1893,7 @@ public class ModBlocks {
GameRegistry.registerBlock(block_verticium, ItemOreBlock.class, block_verticium.getUnlocalizedName());
GameRegistry.registerBlock(block_lanthanium, block_lanthanium.getUnlocalizedName());
GameRegistry.registerBlock(block_actinium, block_actinium.getUnlocalizedName());
GameRegistry.registerBlock(block_tritium, block_tritium.getUnlocalizedName());
//Bottlecap Blocks
GameRegistry.registerBlock(block_cap_nuka, block_cap_nuka.getUnlocalizedName());

View File

@ -1,22 +1,33 @@
package com.hbm.blocks.machine.rbmk;
import com.hbm.blocks.BlockDummyable;
import com.hbm.blocks.ModBlocks;
import com.hbm.blocks.machine.BlockMachineBase;
import com.hbm.handler.MultiblockHandlerXR;
import com.hbm.main.MainRegistry;
import com.hbm.tileentity.machine.TileEntityMachinePlasmaHeater;
import com.hbm.tileentity.machine.rbmk.TileEntityRBMKConsole;
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public class RBMKConsole extends BlockMachineBase {
public class RBMKConsole extends BlockDummyable {
public RBMKConsole() {
super(Material.iron, 0);
this.rotatable = true;
super(Material.iron);
}
@Override
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) {
return new TileEntityRBMKConsole();
public TileEntity createNewTileEntity(World world, int meta) {
if(meta >= 12)
return new TileEntityRBMKConsole();
return null;
}
@Override
@ -33,4 +44,53 @@ public class RBMKConsole extends BlockMachineBase {
public boolean renderAsNormalBlock() {
return false;
}
@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;
TileEntityRBMKConsole entity = (TileEntityRBMKConsole) world.getTileEntity(pos[0], pos[1], pos[2]);
if(entity != null) {
FMLNetworkHandler.openGui(player, MainRegistry.instance, ModBlocks.guiID_rbmk_console, world, pos[0], pos[1], pos[2]);
}
return true;
} else {
return false;
}
}
@Override
public int[] getDimensions() {
return new int[] {3, 0, 0, 0, 2, 2};
}
@Override
public int getOffset() {
return 1;
}
@Override
public void fillSpace(World world, int x, int y, int z, ForgeDirection dir, int o) {
super.fillSpace(world, x, y, z, dir, o);
MultiblockHandlerXR.fillSpace(world, x + dir.offsetX * o , y, z + dir.offsetZ * o, new int[] {0, 0, 0, 1, 2, 2}, this, dir);
}
protected boolean checkRequirement(World world, int x, int y, int z, ForgeDirection dir, int o) {
if(!MultiblockHandlerXR.checkSpace(world, x + dir.offsetX * o , y + dir.offsetY * o, z + dir.offsetZ * o, new int[] {0, 0, 0, 1, 2, 2}, x, y, z, dir))
return false;
return super.checkRequirement(world, x, y, z, dir, o);
}
}

View File

@ -4,30 +4,47 @@ import org.lwjgl.opengl.GL11;
import com.hbm.inventory.container.ContainerRBMKBoiler;
import com.hbm.lib.RefStrings;
import com.hbm.packet.NBTControlPacket;
import com.hbm.packet.PacketDispatcher;
import com.hbm.tileentity.machine.rbmk.TileEntityRBMKBoiler;
import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.nbt.NBTTagCompound;
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;
private TileEntityRBMKBoiler boiler;
public GUIRBMKBoiler(InventoryPlayer invPlayer, TileEntityRBMKBoiler tedf) {
super(new ContainerRBMKBoiler(invPlayer, tedf));
rod = tedf;
boiler = tedf;
this.xSize = 176;
this.ySize = 186;
}
@Override
protected void mouseClicked(int x, int y, int i) {
super.mouseClicked(x, y, i);
if(guiLeft + 33 <= x && guiLeft + 33 + 20 > x && guiTop + 21 < y && guiTop + 21 + 64 >= y) {
mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
NBTTagCompound data = new NBTTagCompound();
data.setBoolean("compression", true); //we only need to send on bit, so boolean it is
PacketDispatcher.wrapper.sendToServer(new NBTControlPacket(data, boiler.xCoord, boiler.yCoord, boiler.zCoord));
}
}
@Override
protected void drawGuiContainerForegroundLayer(int i, int j) {
String name = this.rod.hasCustomInventoryName() ? this.rod.getInventoryName() : I18n.format(this.rod.getInventoryName());
String name = this.boiler.hasCustomInventoryName() ? this.boiler.getInventoryName() : I18n.format(this.boiler.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);
@ -38,5 +55,12 @@ public class GUIRBMKBoiler extends GuiContainer {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
switch(boiler.steam.getTankType()) {
case STEAM: drawTexturedModalRect(guiLeft + 36, guiTop + 24, 194, 0, 14, 58); break;
case HOTSTEAM: drawTexturedModalRect(guiLeft + 36, guiTop + 24, 208, 0, 14, 58); break;
case SUPERHOTSTEAM: drawTexturedModalRect(guiLeft + 36, guiTop + 24, 222, 0, 14, 58); break;
case ULTRAHOTSTEAM: drawTexturedModalRect(guiLeft + 36, guiTop + 24, 236, 0, 14, 58); break;
}
}
}

View File

@ -2,18 +2,21 @@ package com.hbm.inventory.gui;
import org.lwjgl.opengl.GL11;
import com.hbm.inventory.container.ContainerRBMKBoiler;
import com.hbm.inventory.container.ContainerRBMKControl;
import com.hbm.lib.RefStrings;
import com.hbm.packet.NBTControlPacket;
import com.hbm.packet.PacketDispatcher;
import com.hbm.tileentity.machine.rbmk.TileEntityRBMKControl;
import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
public class GUIRBMKControl extends GuiContainer {
public class GUIRBMKControl extends GuiInfoContainer {
private static ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/reactors/gui_rbmk_control.png");
private TileEntityRBMKControl rod;
@ -26,6 +29,39 @@ public class GUIRBMKControl extends GuiContainer {
this.ySize = 186;
}
@Override
public void drawScreen(int mouseX, int mouseY, float f) {
super.drawScreen(mouseX, mouseY, f);
this.drawCustomInfoStat(mouseX, mouseY, guiLeft + 71, guiTop + 29, 16, 56, mouseX, mouseY, new String[]{ (int)(rod.level * 100) + "%" } );
}
@Override
protected void mouseClicked(int x, int y, int i) {
super.mouseClicked(x, y, i);
for(int k = 0; k < 5; k++) {
//manual rod control
if(guiLeft + 118 <= x && guiLeft + 118 + 30 > x && guiTop + 26 + k * 11 < y && guiTop + 26 + 10 + k * 11 >= y) {
mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
NBTTagCompound data = new NBTTagCompound();
data.setDouble("level", 1.0D - (k * 0.25D));
PacketDispatcher.wrapper.sendToServer(new NBTControlPacket(data, rod.xCoord, rod.yCoord, rod.zCoord));
}
//color groups
if(guiLeft + 28 <= x && guiLeft + 28 + 12 > x && guiTop + 26 + k * 11 < y && guiTop + 26 + 10 + k * 11 >= y) {
mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
NBTTagCompound data = new NBTTagCompound();
data.setInteger("color", k);
PacketDispatcher.wrapper.sendToServer(new NBTControlPacket(data, rod.xCoord, rod.yCoord, rod.zCoord));
}
}
}
@Override
protected void drawGuiContainerForegroundLayer(int i, int j) {
String name = this.rod.hasCustomInventoryName() ? this.rod.getInventoryName() : I18n.format(this.rod.getInventoryName());
@ -39,5 +75,16 @@ public class GUIRBMKControl extends GuiContainer {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
int height = (int)(56 * (1D - rod.level));
if(height > 0)
drawTexturedModalRect(guiLeft + 75, guiTop + 29, 176, 56 - height, 8, height);
if(rod.color != null) {
int color = rod.color.ordinal();
drawTexturedModalRect(guiLeft + 28, guiTop + 26 + color * 11, 184, color * 10, 12, 10);
}
}
}

View File

@ -926,6 +926,18 @@ public class ItemRenderLibrary {
bindTexture(ResourceManager.fel_tex); ResourceManager.fel.renderAll();
GL11.glShadeModel(GL11.GL_FLAT);
}});
renderers.put(Item.getItemFromBlock(ModBlocks.rbmk_console), new ItemRenderBase() {
public void renderInventory() {
GL11.glTranslated(0, -3, 0);
GL11.glScaled(2.5, 2.5, 2.5);
}
public void renderCommon() {
GL11.glShadeModel(GL11.GL_SMOOTH);
bindTexture(ResourceManager.rbmk_console_tex);
ResourceManager.rbmk_console.renderAll();
GL11.glShadeModel(GL11.GL_FLAT);
}});
}
private static void bindTexture(ResourceLocation res) {

View File

@ -22,7 +22,7 @@ public class RenderRBMKConsole extends TileEntitySpecialRenderer {
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glEnable(GL11.GL_LIGHTING);
switch(te.getBlockMetadata()) {
switch(te.getBlockMetadata() - BlockDummyable.offset) {
case 2: GL11.glRotatef(90, 0F, 1F, 0F); break;
case 4: GL11.glRotatef(180, 0F, 1F, 0F); break;
case 3: GL11.glRotatef(270, 0F, 1F, 0F); break;

View File

@ -31,6 +31,17 @@ public class TileEntityRBMKBoiler extends TileEntityRBMKSlottedBase implements I
public String getName() {
return "container.rbmkBoiler";
}
@Override
public void updateEntity() {
if(!worldObj.isRemote) {
feed.updateTank(xCoord, yCoord, zCoord, worldObj.provider.dimensionId);
steam.updateTank(xCoord, yCoord, zCoord, worldObj.provider.dimensionId);
}
super.updateEntity();
}
@Override
public void fillFluidInit(FluidType type) {
@ -138,6 +149,17 @@ public class TileEntityRBMKBoiler extends TileEntityRBMKSlottedBase implements I
@Override
public void receiveControl(NBTTagCompound data) {
//TODO: compression toggles
if(data.hasKey("compression")) {
switch(steam.getTankType()) {
case STEAM: steam.setTankType(FluidType.HOTSTEAM); steam.setFill(steam.getFill() / 10); break;
case HOTSTEAM: steam.setTankType(FluidType.SUPERHOTSTEAM); steam.setFill(steam.getFill() / 10); break;
case SUPERHOTSTEAM: steam.setTankType(FluidType.ULTRAHOTSTEAM); steam.setFill(steam.getFill() / 10); break;
case ULTRAHOTSTEAM: steam.setTankType(FluidType.STEAM); steam.setFill(Math.min(steam.getFill() * 1000, steam.getMaxFill())); break;
}
this.markDirty();
}
}
}

View File

@ -1,6 +1,17 @@
package com.hbm.tileentity.machine.rbmk;
public class TileEntityRBMKControl extends TileEntityRBMKSlottedBase {
import com.hbm.interfaces.IControlReceiver;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.Vec3;
public class TileEntityRBMKControl extends TileEntityRBMKSlottedBase implements IControlReceiver {
public double level;
public static final double speed = 0.00277D; // it takes around 18 seconds for the thing to fully extend
public double targetLevel;
public RBMKColor color;
public TileEntityRBMKControl() {
super(0);
@ -11,4 +22,87 @@ public class TileEntityRBMKControl extends TileEntityRBMKSlottedBase {
return "container.rbmkControl";
}
@Override
public boolean hasPermission(EntityPlayer player) {
return Vec3.createVectorHelper(xCoord - player.posX, yCoord - player.posY, zCoord - player.posZ).lengthVector() < 20;
}
@Override
public void updateEntity() {
if(!worldObj.isRemote) {
if(level < targetLevel) {
level += speed;
if(level > targetLevel)
level = targetLevel;
}
if(level > targetLevel) {
level -= speed;
if(level < targetLevel)
level = targetLevel;
}
}
super.updateEntity();
}
@Override
public void receiveControl(NBTTagCompound data) {
if(data.hasKey("level")) {
this.targetLevel = data.getDouble("level");
}
if(data.hasKey("color")) {
int c = Math.abs(data.getInteger("color")) % RBMKColor.values().length; //to stop naughty kids from sending packets that crash the server
RBMKColor newCol = RBMKColor.values()[c];
if(newCol == this.color) {
this.color = null;
} else {
this.color = newCol;
}
}
this.markDirty();
}
@Override
public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt);
this.level = nbt.getDouble("level");
this.targetLevel = nbt.getDouble("targetLevel");
if(nbt.hasKey("color"))
this.color = RBMKColor.values()[nbt.getInteger("color")];
else
this.color = null;
}
@Override
public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
nbt.setDouble("level", this.level);
nbt.setDouble("targetLevel", this.targetLevel);
if(color != null)
nbt.setInteger("color", color.ordinal());
}
public static enum RBMKColor {
RED,
YELLOW,
GREEN,
BLUE,
PURPLE
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 217 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 156 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 157 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.9 KiB

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB