diff --git a/changelog b/changelog index 53b14aebf..3629667a0 100644 --- a/changelog +++ b/changelog @@ -1,22 +1,10 @@ ## Added -* Freight elevator - * A 3x3 hydraulic platform - * Can be stacked - * Only supports two floors, the top and the bottom - * Hopefully not terribly janky +* Redstone-over-Radio Terminal + * Allows commands to be sent manually, command line style ## Changed -* Reduced steam demand of the rotary furnace's hotter fuels by a bit -* The acidizer now has a sound loop (chemplant sound at 75% pitch) -* Updated some bomb part recipes, mainly to make use of the new neutron reflectors and some more modern materials (why did ivy mike coolers still use iron?) -* Updated the fat man igniter and gadget wiring icons -* The cape items, which haven't actually been used by anyone ever, are now deprecated. Existing capes will still work, but the items are now unobtainable -* Some long deprecated melee weapons have now been properly removed +* RoR graphs can now have their min and max bounds set to a fixed number + * This should make it easier to accurately tell the difference/scale of values when they exist in an expected range (for example, RBMK temperatures) ## Fixed -* Fixed an issue where 40mm grenades that impact entities within three ticks of spawning would never detonate -* Fixed broken foundry scrap name and tooltip -* Finally fixed the rotary furnace's steam going into the negatives because 70k was too bald to do it -* Fixed magnet and HUD toggle popups being incorrect half the time -* Fixed crash caused by connecting NONE type pipe anchors -* Fixed color inconsistency with the bedrock ore density scanner \ No newline at end of file +* Fixed RoR graph showing the wrong name in the GUI \ No newline at end of file diff --git a/src/main/java/com/hbm/blocks/ModBlocks.java b/src/main/java/com/hbm/blocks/ModBlocks.java index 60c18d7a2..5eca2e438 100644 --- a/src/main/java/com/hbm/blocks/ModBlocks.java +++ b/src/main/java/com/hbm/blocks/ModBlocks.java @@ -1104,6 +1104,7 @@ public class ModBlocks { public static Block rbmk_graph; public static Block rbmk_lever; public static Block rbmk_indicator; + public static Block rbmk_terminal; public static Block rbmk_autoloader; public static Block rbmk_loader; public static Block rbmk_steam_inlet; @@ -2128,6 +2129,7 @@ public class ModBlocks { rbmk_graph = new RBMKGraph().setBlockName("rbmk_graph").setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":rbmk/rbmk_display"); rbmk_lever = new RBMKLever().setBlockName("rbmk_lever").setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":rbmk/rbmk_display"); rbmk_indicator = new RBMKIndicator().setBlockName("rbmk_indicator").setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":rbmk/rbmk_display"); + rbmk_terminal = new RBMKTerminal().setBlockName("rbmk_terminal").setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":rbmk/rbmk_display"); rbmk_autoloader = new RBMKAutoloader().setBlockName("rbmk_autoloader").setCreativeTab(MainRegistry.machineTab).setHardness(50.0F).setResistance(60.0F).setBlockTextureName(RefStrings.MODID + ":rbmk_autoloader"); rbmk_loader = new RBMKLoader(Material.iron).setBlockName("rbmk_loader").setCreativeTab(MainRegistry.machineTab).setHardness(50.0F).setResistance(60.0F).setBlockTextureName(RefStrings.MODID + ":rbmk_loader"); rbmk_steam_inlet = new RBMKInlet(Material.iron).setBlockName("rbmk_steam_inlet").setCreativeTab(MainRegistry.machineTab).setHardness(50.0F).setResistance(60.0F).setBlockTextureName(RefStrings.MODID + ":rbmk_steam_inlet"); @@ -3123,6 +3125,7 @@ public class ModBlocks { register(rbmk_indicator); register(rbmk_numitron); register(rbmk_graph); + register(rbmk_terminal); register(rbmk_autoloader); register(rbmk_loader); register(rbmk_steam_inlet); diff --git a/src/main/java/com/hbm/blocks/machine/rbmk/RBMKTerminal.java b/src/main/java/com/hbm/blocks/machine/rbmk/RBMKTerminal.java new file mode 100644 index 000000000..02bb63896 --- /dev/null +++ b/src/main/java/com/hbm/blocks/machine/rbmk/RBMKTerminal.java @@ -0,0 +1,44 @@ +package com.hbm.blocks.machine.rbmk; + +import org.lwjgl.opengl.GL11; + +import com.hbm.main.MainRegistry; +import com.hbm.main.ResourceManager; +import com.hbm.tileentity.machine.rbmk.TileEntityRBMKTerminal; + +import cpw.mods.fml.common.network.internal.FMLNetworkHandler; +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +public class RBMKTerminal extends RBMKMiniPanelBase { + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileEntityRBMKTerminal(); + } + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { + if(player.isSneaking()) return false; + if(world.isRemote) FMLNetworkHandler.openGui(player, MainRegistry.instance, 0, world, x, y, z); + return true; + } + + @Override + public void renderInventoryBlock(Block block, int meta, int modelId, Object renderBlocks) { + super.renderInventoryBlock(block, meta, modelId, renderBlocks); + + GL11.glPushMatrix(); + GL11.glTranslated(0, -0.5, 0); + GL11.glRotated(-90, 0, 1, 0); + + GL11.glTranslated(0.25, 0, 0); + Minecraft.getMinecraft().getTextureManager().bindTexture(ResourceManager.rbmk_terminal_tex); + ResourceManager.rbmk_terminal.renderAll(); + + GL11.glPopMatrix(); + } +} diff --git a/src/main/java/com/hbm/inventory/gui/GUIScreenRBMKGraph.java b/src/main/java/com/hbm/inventory/gui/GUIScreenRBMKGraph.java index b4bcfa087..309937bfe 100644 --- a/src/main/java/com/hbm/inventory/gui/GUIScreenRBMKGraph.java +++ b/src/main/java/com/hbm/inventory/gui/GUIScreenRBMKGraph.java @@ -16,18 +16,19 @@ import net.minecraft.client.gui.GuiTextField; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.ResourceLocation; -// Literally just GUIScreenRBMKDisplay but with three lines switched out - this sucks ass public class GUIScreenRBMKGraph extends GuiScreen { private static ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/machine/gui_rbmk_graph.png"); public TileEntityRBMKGraph graph; protected int xSize = 256; - protected int ySize = 114; + protected int ySize = 150; protected int guiLeft; protected int guiTop; protected GuiTextField[] label = new GuiTextField[2]; protected GuiTextField[] rtty = new GuiTextField[2]; + protected GuiTextField[] min = new GuiTextField[2]; + protected GuiTextField[] max = new GuiTextField[2]; protected boolean[] active = new boolean[2]; protected boolean[] polling = new boolean[2]; @@ -47,10 +48,14 @@ public class GUIScreenRBMKGraph extends GuiScreen { int oY = 4; for(int i = 0; i < 2; i++) { - label[i] = new GuiTextField(this.fontRendererObj, guiLeft + 175 + oX, guiTop + 55 + oY + i * 36, 72 - oX * 2, 14); + label[i] = new GuiTextField(this.fontRendererObj, guiLeft + 27 + oX, guiTop + 73 + oY + i * 54, 72 - oX * 2, 14); GUIScreenRBMKKeyPad.setupTextFieldStandard(label[i], 30, graph.graphs[i].label); - rtty[i] = new GuiTextField(this.fontRendererObj, guiLeft + 27 + oX, guiTop + 55 + oY + i * 36, 72 - oX * 2, 14); + rtty[i] = new GuiTextField(this.fontRendererObj, guiLeft + 27 + oX, guiTop + 55 + oY + i * 54, 72 - oX * 2, 14); GUIScreenRBMKKeyPad.setupTextFieldStandard(rtty[i], 10, graph.graphs[i].rtty); + min[i] = new GuiTextField(this.fontRendererObj, guiLeft + 175 + oX, guiTop + 55 + oY + i * 54, 72 - oX * 2, 14); + GUIScreenRBMKKeyPad.setupTextFieldStandard(rtty[i], 15, graph.graphs[i].minBound ? graph.graphs[i].min + "" : ""); + max[i] = new GuiTextField(this.fontRendererObj, guiLeft + 175 + oX, guiTop + 73 + oY + i * 54, 72 - oX * 2, 14); + GUIScreenRBMKKeyPad.setupTextFieldStandard(rtty[i], 15, graph.graphs[i].maxBound ? graph.graphs[i].max + "" : ""); active[i] = graph.graphs[i].active; polling[i] = graph.graphs[i].polling; @@ -67,7 +72,7 @@ public class GUIScreenRBMKGraph extends GuiScreen { } private void drawGuiContainerForegroundLayer(int x, int y) { - String name = I18nUtil.resolveKey("container.rbmkNumitron"); + String name = I18nUtil.resolveKey("container.rbmkGraph"); this.fontRendererObj.drawString(name, this.guiLeft + this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, this.guiTop + 6, 4210752); } @@ -77,13 +82,15 @@ public class GUIScreenRBMKGraph extends GuiScreen { drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); for(int i = 0; i < 2; i++) { - if(this.active[i]) drawTexturedModalRect(guiLeft + 111, guiTop + i * 36 + 54, 18, 114, 16, 16); - if(this.polling[i]) drawTexturedModalRect(guiLeft + 128, guiTop + i * 36 + 53, 0, 114, 18, 18); + if(this.active[i]) drawTexturedModalRect(guiLeft + 111, guiTop + i * 54 + 54, 18, 114, 16, 16); + if(this.polling[i]) drawTexturedModalRect(guiLeft + 128, guiTop + i * 54 + 53, 0, 114, 18, 18); } for(int i = 0; i < 2; i++) { this.label[i].drawTextBox(); this.rtty[i].drawTextBox(); + this.min[i].drawTextBox(); + this.max[i].drawTextBox(); } } @@ -92,13 +99,13 @@ public class GUIScreenRBMKGraph extends GuiScreen { super.mouseClicked(x, y, b); for(int i = 0; i < 2; i++) { - if(guiLeft + 111 <= x && guiLeft + 111 + 16 > x && guiTop + i * 36 + 54 < y && guiTop + i * 36 + 54 + 16 >= y) { + if(guiLeft + 111 <= x && guiLeft + 111 + 16 > x && guiTop + i * 54 + 54 < y && guiTop + i * 36 + 54 + 16 >= y) { this.active[i] = !this.active[i]; mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 0.5F + (this.active[i] ? 0.25F : 0F))); return; } - if(guiLeft + 128 <= x && guiLeft + 128 + 18 > x && guiTop + i * 36 + 53 < y && guiTop + i * 36 + 53 + 18 >= y) { + if(guiLeft + 128 <= x && guiLeft + 128 + 18 > x && guiTop + i * 54 + 53 < y && guiTop + i * 36 + 53 + 18 >= y) { this.polling[i] = !this.polling[i]; mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 0.5F + (this.polling[i] ? 0.25F : 0F))); return; @@ -120,6 +127,8 @@ public class GUIScreenRBMKGraph extends GuiScreen { for(int i = 0; i < 2; i++) { data.setString("label" + i, this.label[i].getText()); data.setString("rtty" + i, this.rtty[i].getText()); + try { if(!min[i].getText().isEmpty()) data.setLong("min" + i, Long.parseLong(this.min[i].getText())); } catch(Exception ex) { } + try { if(!max[i].getText().isEmpty()) data.setLong("max" + i, Long.parseLong(this.max[i].getText())); } catch(Exception ex) { } } PacketDispatcher.wrapper.sendToServer(new NBTControlPacket(data, graph.xCoord, graph.yCoord, graph.zCoord)); return; @@ -128,6 +137,8 @@ public class GUIScreenRBMKGraph extends GuiScreen { for(int i = 0; i < 2; i++) { this.label[i].mouseClicked(x, y, b); this.rtty[i].mouseClicked(x, y, b); + this.min[i].mouseClicked(x, y, b); + this.max[i].mouseClicked(x, y, b); } } @@ -137,6 +148,8 @@ public class GUIScreenRBMKGraph extends GuiScreen { for(int i = 0; i < 2; i++) { if(this.label[i].textboxKeyTyped(c, b)) return; if(this.rtty[i].textboxKeyTyped(c, b)) return; + if(this.min[i].textboxKeyTyped(c, b)) return; + if(this.max[i].textboxKeyTyped(c, b)) return; } if(b == 1 || b == this.mc.gameSettings.keyBindInventory.getKeyCode()) { diff --git a/src/main/java/com/hbm/inventory/gui/GUIScreenRBMKTerminal.java b/src/main/java/com/hbm/inventory/gui/GUIScreenRBMKTerminal.java new file mode 100644 index 000000000..18965c358 --- /dev/null +++ b/src/main/java/com/hbm/inventory/gui/GUIScreenRBMKTerminal.java @@ -0,0 +1,88 @@ +package com.hbm.inventory.gui; + +import org.lwjgl.input.Keyboard; +import org.lwjgl.opengl.GL11; + +import com.hbm.packet.PacketDispatcher; +import com.hbm.packet.toserver.NBTControlPacket; +import com.hbm.tileentity.machine.rbmk.TileEntityRBMKTerminal; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.gui.GuiTextField; +import net.minecraft.nbt.NBTTagCompound; + +public class GUIScreenRBMKTerminal extends GuiScreen { + + protected GuiTextField line; + protected TileEntityRBMKTerminal terminal; + + public GUIScreenRBMKTerminal(TileEntityRBMKTerminal terminal) { + this.terminal = terminal; + } + + @Override + public void initGui() { + super.initGui(); + + Keyboard.enableRepeatEvents(true); + + line = new GuiTextField(this.fontRendererObj, 0, 0, 0, 0); + line.setMaxStringLength(50); + + line.setFocused(true); + } + + public void drawScreen(int x, int y, float f) { + + if(terminal.isInvalid()) { // for if the terminal blows up + this.mc.displayGuiScreen((GuiScreen) null); + this.mc.setIngameFocus(); + return; + } + + GL11.glScaled(0.5, 0.5, 1); + this.fontRendererObj.drawString("[Esc] - Quit", 2, 2, 0xffffff); + this.fontRendererObj.drawString("chan - Set selected channel", 2, 12, 0xffffff); + this.fontRendererObj.drawString("send - Send single signal over selected channel", 2, 22, 0xffffff); + this.fontRendererObj.drawString("start - Continuously send signal over selected channel", 2, 32, 0xffffff); + this.fontRendererObj.drawString("stop - Stop continuous sending", 2, 42, 0xffffff); + } + + protected void keyTyped(char c, int b) { + if(b == 1) { + this.mc.displayGuiScreen((GuiScreen) null); + this.mc.setIngameFocus(); + return; + } + + if(b == Keyboard.KEY_RETURN) { + NBTTagCompound data = new NBTTagCompound(); + data.setString("cmd", this.line.getText()); + PacketDispatcher.wrapper.sendToServer(new NBTControlPacket(data, terminal.xCoord, terminal.yCoord, terminal.zCoord)); + this.line.setText(""); + return; + } + + if(b == 199) return; + if(b == 203) return; + if(b == 205) return; + if(b == 207) return; + + this.line.setCursorPositionEnd(); + if(this.line.textboxKeyTyped(c, b)) return; + } + + public static String getWorkingLine() { + + if(Minecraft.getMinecraft().currentScreen instanceof GUIScreenRBMKTerminal) { + GUIScreenRBMKTerminal gui = (GUIScreenRBMKTerminal) Minecraft.getMinecraft().currentScreen; + return gui.line.getText(); + } + + return ""; + } + + @Override public void onGuiClosed() { Keyboard.enableRepeatEvents(false); } + @Override public boolean doesGuiPauseGame() { return false; } +} diff --git a/src/main/java/com/hbm/main/ClientProxy.java b/src/main/java/com/hbm/main/ClientProxy.java index d8784cb89..94e2016a1 100644 --- a/src/main/java/com/hbm/main/ClientProxy.java +++ b/src/main/java/com/hbm/main/ClientProxy.java @@ -416,6 +416,7 @@ public class ClientProxy extends ServerProxy { ClientRegistry.bindTileEntitySpecialRenderer(TileEntityRBMKGraph.class, new RenderRBMKGraph()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityRBMKLever.class, new RenderRBMKLever()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityRBMKIndicator.class, new RenderRBMKIndicator()); + ClientRegistry.bindTileEntitySpecialRenderer(TileEntityRBMKTerminal.class, new RenderRBMKTerminal()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityRBMKRod.class, new RenderRBMKFuelChannel()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityRBMKRodReaSim.class, new RenderRBMKFuelChannel()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityRBMKAutoloader.class, new RenderRBMKAutoloader()); diff --git a/src/main/java/com/hbm/main/CraftingManager.java b/src/main/java/com/hbm/main/CraftingManager.java index e10f81ae9..d89bf0063 100644 --- a/src/main/java/com/hbm/main/CraftingManager.java +++ b/src/main/java/com/hbm/main/CraftingManager.java @@ -791,12 +791,13 @@ public class CraftingManager { addRecipeAuto(new ItemStack(ModBlocks.rbmk_display_blank, 8), new Object[] { "B", "D", 'B', B.ingot(), 'D', ModBlocks.concrete_asbestos }); addRecipeAuto(new ItemStack(ModBlocks.rbmk_display, 1), new Object[] { "C", "B", 'C', ModItems.crt_display, 'B', ModBlocks.rbmk_display_blank }); - addRecipeAuto(new ItemStack(ModBlocks.rbmk_key_pad, 1), new Object[] { "R", "C", "B", 'R', ModBlocks.radio_torch_sender, 'B', ModBlocks.rbmk_display_blank, 'C', DictFrame.fromOne(ModItems.circuit, EnumCircuitType.ANALOG) }); + addRecipeAuto(new ItemStack(ModBlocks.rbmk_key_pad, 1), new Object[] { "R", "C", "B", 'R', ModBlocks.radio_torch_sender, 'B', ModBlocks.rbmk_display_blank, 'C', DictFrame.fromOne(ModItems.circuit, EnumCircuitType.VACUUM_TUBE) }); addRecipeAuto(new ItemStack(ModBlocks.rbmk_gauge, 1), new Object[] { "R", "C", "B", 'R', ModBlocks.radio_torch_receiver, 'B', ModBlocks.rbmk_display_blank, 'C', DictFrame.fromOne(ModItems.circuit, EnumCircuitType.VACUUM_TUBE) }); addRecipeAuto(new ItemStack(ModBlocks.rbmk_numitron, 1), new Object[] { " R ", "CCC", " B ", 'R', ModBlocks.radio_torch_receiver, 'B', ModBlocks.rbmk_display_blank, 'C', DictFrame.fromOne(ModItems.circuit, EnumCircuitType.NUMITRON) }); addRecipeAuto(new ItemStack(ModBlocks.rbmk_graph, 1), new Object[] { "R", "C", "B", 'R', ModBlocks.radio_torch_receiver, 'B', ModBlocks.rbmk_display_blank, 'C', ModItems.crt_display }); addRecipeAuto(new ItemStack(ModBlocks.rbmk_lever, 1), new Object[] { "R", "C", "B", 'R', ModBlocks.radio_torch_sender, 'B', ModBlocks.rbmk_display_blank, 'C', CU.ingot() }); addRecipeAuto(new ItemStack(ModBlocks.rbmk_indicator, 1), new Object[] { "R", "C", "B", 'R', ModBlocks.radio_torch_receiver, 'B', ModBlocks.rbmk_display_blank, 'C', ModItems.coil_tungsten }); + addRecipeAuto(new ItemStack(ModBlocks.rbmk_terminal, 1), new Object[] { "R ", "CD", "B ", 'R', ModBlocks.radio_torch_sender, 'B', ModBlocks.rbmk_display_blank, 'C', DictFrame.fromOne(ModItems.circuit, EnumCircuitType.ANALOG), 'D', ModItems.crt_display }); addRecipeAuto(new ItemStack(ModItems.rtty_pager, 1), new Object[] { "R", "C", "S", 'R', ModBlocks.radio_torch_receiver, 'C', DictFrame.fromOne(ModItems.circuit, EnumCircuitType.BASIC), 'S', STEEL.plate() }); diff --git a/src/main/java/com/hbm/main/ResourceManager.java b/src/main/java/com/hbm/main/ResourceManager.java index fff7c9ac9..90e495965 100644 --- a/src/main/java/com/hbm/main/ResourceManager.java +++ b/src/main/java/com/hbm/main/ResourceManager.java @@ -1624,6 +1624,7 @@ public class ResourceManager { public static final HFRWavefrontObjectVBO rbmk_numitron = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/rbmk/numitron.obj")).asVBO(); public static final HFRWavefrontObjectVBO rbmk_lever = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/rbmk/lever.obj")).asVBO(); public static final HFRWavefrontObjectVBO rbmk_indicator = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/rbmk/indicator.obj")).asVBO(); + public static final HFRWavefrontObjectVBO rbmk_terminal = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/rbmk/terminal.obj")).asVBO(); public static final HFRWavefrontObject rbmk_debris = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/rbmk/debris.obj")).noSmooth(); public static final ResourceLocation rbmk_crane_console_tex = new ResourceLocation(RefStrings.MODID, "textures/models/machines/crane_console.png"); public static final ResourceLocation rbmk_crane_tex = new ResourceLocation(RefStrings.MODID, "textures/models/machines/rbmk_crane.png"); @@ -1635,6 +1636,7 @@ public class ResourceManager { public static final ResourceLocation rbmk_numitron_lights_tex = new ResourceLocation(RefStrings.MODID, "textures/models/network/numitron_lights.png"); public static final ResourceLocation rbmk_lever_tex = new ResourceLocation(RefStrings.MODID, "textures/models/network/lever.png"); public static final ResourceLocation rbmk_indicator_tex = new ResourceLocation(RefStrings.MODID, "textures/models/network/indicator.png"); + public static final ResourceLocation rbmk_terminal_tex = new ResourceLocation(RefStrings.MODID, "textures/models/network/terminal.png"); public static final HFRWavefrontObject hev_battery = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/blocks/battery.obj")).noSmooth(); public static final HFRWavefrontObject anvil = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/blocks/anvil.obj")).noSmooth(); public static final HFRWavefrontObject crystal_power = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/blocks/crystals_power.obj")).noSmooth(); diff --git a/src/main/java/com/hbm/render/tileentity/RenderRBMKGraph.java b/src/main/java/com/hbm/render/tileentity/RenderRBMKGraph.java index 08d3741f6..82ea6c80a 100644 --- a/src/main/java/com/hbm/render/tileentity/RenderRBMKGraph.java +++ b/src/main/java/com/hbm/render/tileentity/RenderRBMKGraph.java @@ -52,8 +52,8 @@ public class RenderRBMKGraph extends TileEntitySpecialRenderer { FontRenderer font = Minecraft.getMinecraft().fontRenderer; int height = font.FONT_HEIGHT; - long lowest = BobMathUtil.min(unit.values); - long highest = BobMathUtil.max(unit.values); + long lowest = unit.minBound ? unit.min : BobMathUtil.min(unit.values); + long highest = unit.maxBound ? unit.max : BobMathUtil.max(unit.values); Tessellator tess = Tessellator.instance; tess.startDrawing(GL11.GL_LINES); @@ -63,6 +63,8 @@ public class RenderRBMKGraph extends TileEntitySpecialRenderer { for(int j = 0; j < 2; j++) { int k = v + j; long flux = unit.values[k]; + if(flux < lowest) flux = lowest; + if(flux > highest) flux = highest; double dx = 0.03225; double dy = 0.5 - 0.03125 + (flux - lowest) * 0.1875D / Math.max(range, 1); double dz = 0.375 - k * 0.75 / (unit.values.length - 1); diff --git a/src/main/java/com/hbm/render/tileentity/RenderRBMKTerminal.java b/src/main/java/com/hbm/render/tileentity/RenderRBMKTerminal.java new file mode 100644 index 000000000..fe6bf0f47 --- /dev/null +++ b/src/main/java/com/hbm/render/tileentity/RenderRBMKTerminal.java @@ -0,0 +1,95 @@ +package com.hbm.render.tileentity; + +import org.lwjgl.opengl.GL11; + +import com.hbm.inventory.gui.GUIScreenRBMKTerminal; +import com.hbm.main.ResourceManager; +import com.hbm.tileentity.machine.rbmk.TileEntityRBMKTerminal; +import com.hbm.util.BobMathUtil; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.tileentity.TileEntity; + +public class RenderRBMKTerminal extends TileEntitySpecialRenderer { + + @Override + public void renderTileEntityAt(TileEntity te, double x, double y, double z, float interp) { + + GL11.glPushMatrix(); + GL11.glTranslated(x + 0.5, y, z + 0.5); + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glEnable(GL11.GL_LIGHTING); + + switch(te.getBlockMetadata()) { + 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; + case 5: GL11.glRotatef(0, 0F, 1F, 0F); break; + } + + TileEntityRBMKTerminal terminal = (TileEntityRBMKTerminal) te; + + GL11.glTranslated(0.25, 0, 0); + Minecraft.getMinecraft().getTextureManager().bindTexture(ResourceManager.rbmk_terminal_tex); + ResourceManager.rbmk_terminal.renderAll(); + + GL11.glTranslated(0.0635, 0.125, 0.0625 * 5.5); + + RenderArcFurnace.fullbright(true); + FontRenderer font = Minecraft.getMinecraft().fontRenderer; + int height = font.FONT_HEIGHT; + float scale = 1F / 250F; + String prefix = "> "; + int prefixWidth = font.getStringWidth(prefix); + int maxWidth = 172; + int fontColor = terminal.doesRepeat ? 0xff8000 : 0x00ff00; + + String suffix = ""; + + if(Minecraft.getMinecraft().currentScreen instanceof GUIScreenRBMKTerminal && BobMathUtil.getBlink()) { + suffix = "_"; + } + int suffixWidth = font.getStringWidth(suffix); + + for(int i = 0; i < 18; i++) { + + String label = i == 0 ? GUIScreenRBMKTerminal.getWorkingLine() : terminal.history[i - 1]; + if(label == null) label = ""; + + StringBuilder builder = new StringBuilder(40); + + if(i == 0 || !label.isEmpty()) builder.append(prefix); + + int width = prefixWidth; + for(int j = 0; j < label.length(); j++) { + char c = label.charAt(j); + width += font.getCharWidth(c); + if(width <= maxWidth) { + builder.append(c); + } else { + break; + } + } + + if(i == 0 && font.getStringWidth(builder.toString()) + suffixWidth <= maxWidth) { + builder.append(suffix); + } + + GL11.glTranslated(0, 10 * scale, 0); + + GL11.glPushMatrix(); + GL11.glScalef(scale, -scale, scale); + GL11.glNormal3f(0.0F, 0.0F, -1.0F); + GL11.glRotatef(90, 0, 1, 0); + + font.drawString(builder.toString(), 0, - height / 2, fontColor); + GL11.glPopMatrix(); + } + + RenderArcFurnace.fullbright(false); + + GL11.glPopMatrix(); + } +} diff --git a/src/main/java/com/hbm/tileentity/TileMappings.java b/src/main/java/com/hbm/tileentity/TileMappings.java index 58c39b82a..bfedd2533 100644 --- a/src/main/java/com/hbm/tileentity/TileMappings.java +++ b/src/main/java/com/hbm/tileentity/TileMappings.java @@ -412,6 +412,7 @@ public class TileMappings { put(TileEntityRBMKGraph.class, "tileentity_rbmk_graph"); put(TileEntityRBMKLever.class, "tileentity_rbmk_lever"); put(TileEntityRBMKIndicator.class, "tileentity_rbmk_indicator"); + put(TileEntityRBMKTerminal.class, "tileentity_rbmk_terminal"); put(TileEntityRBMKInlet.class, "tileentity_rbmk_inlet"); put(TileEntityRBMKOutlet.class, "tileentity_rbmk_outlet"); put(TileEntityRBMKAutoloader.class, "tileentity_rbmk_autoloader"); diff --git a/src/main/java/com/hbm/tileentity/machine/rbmk/TileEntityRBMKGraph.java b/src/main/java/com/hbm/tileentity/machine/rbmk/TileEntityRBMKGraph.java index 60dfd326b..caa406e79 100644 --- a/src/main/java/com/hbm/tileentity/machine/rbmk/TileEntityRBMKGraph.java +++ b/src/main/java/com/hbm/tileentity/machine/rbmk/TileEntityRBMKGraph.java @@ -88,6 +88,12 @@ public class TileEntityRBMKGraph extends TileEntityLoadedBase implements IGUIPro public long[] values = new long[30]; // 2 values/s for 15 seconds /** Whether this graph is visible on the panel */ public boolean active; + /** Fixed min value */ + public long min; + public boolean minBound = false; + /** Fixed max value */ + public long max; + public boolean maxBound = false; public GraphUnit(int initialIndex) { label = "Graph " + (initialIndex + 1); @@ -125,6 +131,10 @@ public class TileEntityRBMKGraph extends TileEntityLoadedBase implements IGUIPro buf.writeBoolean(polling); BufferUtil.writeString(buf, label); BufferUtil.writeString(buf, rtty); + buf.writeBoolean(minBound); + if(minBound) buf.writeLong(min); + buf.writeBoolean(maxBound); + if(maxBound) buf.writeLong(max); // original idea had the system send the min value, max value, and all values // crunched down to single bytes because the graph simply doesn't need this much resolution if(active) for(int i = 0; i < values.length; i++) buf.writeLong(values[i]); @@ -136,6 +146,10 @@ public class TileEntityRBMKGraph extends TileEntityLoadedBase implements IGUIPro polling = buf.readBoolean(); label = BufferUtil.readString(buf); rtty = BufferUtil.readString(buf); + minBound = buf.readBoolean(); + if(minBound) min = buf.readLong(); + maxBound = buf.readBoolean(); + if(maxBound) max = buf.readLong(); if(active) for(int i = 0; i < values.length; i++) values[i] = buf.readLong(); } @@ -144,6 +158,10 @@ public class TileEntityRBMKGraph extends TileEntityLoadedBase implements IGUIPro this.polling = nbt.getBoolean("polling" + index); this.label = nbt.getString("label" + index); this.rtty = nbt.getString("rtty" + index); + this.minBound = nbt.getBoolean("minBound" + index); + this.min = nbt.getLong("min" + index); + this.maxBound = nbt.getBoolean("maxBound" + index); + this.max = nbt.getLong("max" + index); for(int i = 0; i < values.length; i++) this.values[i] = nbt.getLong("value" + index + "_" + i); } @@ -152,6 +170,10 @@ public class TileEntityRBMKGraph extends TileEntityLoadedBase implements IGUIPro nbt.setBoolean("polling" + index, polling); nbt.setString("label" + index, label); nbt.setString("rtty" + index, rtty); + nbt.setBoolean("minBound" + index, minBound); + nbt.setLong("min" + index, min); + nbt.setBoolean("maxBound" + index, maxBound); + nbt.setLong("max" + index, max); for(int i = 0; i < values.length; i++) nbt.setLong("value" + index + "_" + i, values[i]); } } @@ -178,7 +200,27 @@ public class TileEntityRBMKGraph extends TileEntityLoadedBase implements IGUIPro GraphUnit graph = this.graphs[i]; graph.label = data.getString("label" + i); graph.rtty = data.getString("rtty" + i); + if(data.hasKey("min" + i)) { + graph.min = data.getLong("min" + i); + graph.minBound = true; + } else { + graph.minBound = false; + } + if(data.hasKey("max" + i)) { + graph.max = data.getLong("max" + i); + graph.maxBound = true; + } else { + graph.maxBound = false; + } + + if(graph.max < graph.min) { + long temp = graph.max; + graph.max = graph.min; + graph.min = temp; + } } + + this.markChanged(); } // OpenComputers methods diff --git a/src/main/java/com/hbm/tileentity/machine/rbmk/TileEntityRBMKTerminal.java b/src/main/java/com/hbm/tileentity/machine/rbmk/TileEntityRBMKTerminal.java new file mode 100644 index 000000000..0c2a0a0a1 --- /dev/null +++ b/src/main/java/com/hbm/tileentity/machine/rbmk/TileEntityRBMKTerminal.java @@ -0,0 +1,152 @@ +package com.hbm.tileentity.machine.rbmk; + +import com.hbm.explosion.vanillant.ExplosionVNT; +import com.hbm.explosion.vanillant.standard.EntityProcessorCrossSmooth; +import com.hbm.explosion.vanillant.standard.ExplosionEffectWeapon; +import com.hbm.explosion.vanillant.standard.PlayerProcessorStandard; +import com.hbm.interfaces.IControlReceiver; +import com.hbm.inventory.gui.GUIScreenRBMKTerminal; +import com.hbm.tileentity.IGUIProvider; +import com.hbm.tileentity.TileEntityLoadedBase; +import com.hbm.tileentity.network.RTTYSystem; +import com.hbm.util.BufferUtil; + +import io.netty.buffer.ByteBuf; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; + +public class TileEntityRBMKTerminal extends TileEntityLoadedBase implements IGUIProvider, IControlReceiver { + + public String[] history = new String[17]; + public String channel = ""; + public String repeatCmd = ""; + public boolean doesRepeat = false; + + @Override + public void updateEntity() { + if(!worldObj.isRemote) { + + if(!this.channel.isEmpty() && !this.repeatCmd.isEmpty()) + RTTYSystem.broadcast(worldObj, this.channel, this.repeatCmd + ""); + + this.networkPackNT(50); + } + } + + public void eval(String cmd) { + if(cmd == null) return; + + push(cmd); + if(cmd.isEmpty()) return; + + if(cmd.startsWith("chan ")) { + this.channel = cmd.substring(5); + push("Set channel to " + (this.channel.isEmpty() ? "" : this.channel)); + this.markChanged(); + return; + } + + if(cmd.equals("chan")) { + this.channel = ""; + push("Set channel to "); + this.markChanged(); + return; + } + + if(cmd.startsWith("start ")) { + this.repeatCmd = cmd.substring(6); + push("Repeating signal on channel " + this.channel); + this.markChanged(); + return; + } + + if(cmd.startsWith("stop ")) { + this.repeatCmd = ""; + push("Stopping repeat signal"); + this.markChanged(); + return; + } + + if(cmd.startsWith("send ")) { + if(this.channel.isEmpty()) { + push("Cannot send - no channel set"); + return; + } + RTTYSystem.broadcast(worldObj, this.channel, cmd.substring(5)); + push("Sent signal on channel " + this.channel); + return; + } + + if(cmd.equals("horse")) { + push("Horse."); + return; + } + + if(cmd.equals("selfdestruct")) { + worldObj.func_147480_a(xCoord, yCoord, zCoord, false); + ExplosionVNT vnt = new ExplosionVNT(worldObj, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, 5, null); + vnt.setEntityProcessor(new EntityProcessorCrossSmooth(1, 50).setupPiercing(5F, 0.5F)); + vnt.setPlayerProcessor(new PlayerProcessorStandard()); + vnt.setSFX(new ExplosionEffectWeapon(10, 2.5F, 1F)); + vnt.explode(); + return; + } + + push("Unrecognized command!"); + } + + public void push(String msg) { + for(int i = history.length - 2; i > 0; i--) { + history[i] = history[i - 1]; + } + history[0] = msg; + } + + @Override + public void serialize(ByteBuf buf) { + super.serialize(buf); + buf.writeBoolean(!this.repeatCmd.isEmpty()); + for(int i = 0; i < history.length; i++) BufferUtil.writeString(buf, history[i]); + } + + @Override + public void deserialize(ByteBuf buf) { + super.deserialize(buf); + this.doesRepeat = buf.readBoolean(); + for(int i = 0; i < history.length; i++) this.history[i] = BufferUtil.readString(buf); + } + + @Override + public void readFromNBT(NBTTagCompound nbt) { + super.readFromNBT(nbt); + this.channel = nbt.getString("channel"); + this.repeatCmd = nbt.getString("repeatCmd"); + for(int i = 0; i < history.length; i++) this.history[i] = nbt.getString("history" + i); + } + + @Override + public void writeToNBT(NBTTagCompound nbt) { + super.writeToNBT(nbt); + nbt.setString("channel", channel); + nbt.setString("repeatCmd", repeatCmd); + for(int i = 0; i < history.length; i++) nbt.setString("history" + i, history[i]); + } + + @Override + public boolean hasPermission(EntityPlayer player) { + return player.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5) < 15 * 15; + } + + @Override + public void receiveControl(NBTTagCompound data) { + if(data.hasKey("cmd")) { + eval(data.getString("cmd")); + this.markChanged(); + } + } + + @Override public Container provideContainer(int ID, EntityPlayer player, World world, int x, int y, int z) { return null; } + @Override public Object provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) { return new GUIScreenRBMKTerminal(this); } +} diff --git a/src/main/resources/assets/hbm/lang/de_DE.lang b/src/main/resources/assets/hbm/lang/de_DE.lang index 68591356e..d5eed0701 100644 --- a/src/main/resources/assets/hbm/lang/de_DE.lang +++ b/src/main/resources/assets/hbm/lang/de_DE.lang @@ -4813,6 +4813,7 @@ tile.rbmk_rod_reasim_mod.name=RBMK Moderierte Brennstäbe (ReaSim) tile.rbmk_steam_inlet.name=RBMK ReaSim Wassereinlass tile.rbmk_steam_outlet.name=RBMK ReaSim Dampfabnehmer tile.rbmk_storage.name=RBMK Lagerteil +tile.rbmk_terminal.name=Redstone-over-Radio Terminal tile.reactor_computer.name=Reaktorsteuerung tile.reactor_conductor.name=Reaktorboiler tile.reactor_control.name=Steuerstäbe diff --git a/src/main/resources/assets/hbm/lang/en_US.lang b/src/main/resources/assets/hbm/lang/en_US.lang index e531cc305..198399b76 100644 --- a/src/main/resources/assets/hbm/lang/en_US.lang +++ b/src/main/resources/assets/hbm/lang/en_US.lang @@ -6090,6 +6090,8 @@ tile.rbmk_steam_inlet.desc=Inserts water into RBMK columns if ReaSim boilers are tile.rbmk_steam_outlet.name=RBMK ReaSim Steam Outlet tile.rbmk_steam_outlet.desc=Extracts super dense steam from RBMK columns if ReaSim boilers are enabled$Connects to RBMK columns sideways tile.rbmk_storage.name=RBMK Storage Column +tile.rbmk_terminal.name=Redstone-over-Radio Terminal +tile.rbmk_terminal.desc=Allos RoR commands to be sent manually. tile.rbmk.dodd.heat=Column Heat tile.rbmk.dodd.reasimWater=ReaSim Water tile.rbmk.dodd.reasimSteam=ReaSim Steam diff --git a/src/main/resources/assets/hbm/models/rbmk/terminal.obj b/src/main/resources/assets/hbm/models/rbmk/terminal.obj new file mode 100644 index 000000000..1b81deea3 --- /dev/null +++ b/src/main/resources/assets/hbm/models/rbmk/terminal.obj @@ -0,0 +1,79 @@ +# Blender v2.79 (sub 0) OBJ File: '' +# www.blender.org +o Base +v 0.062500 0.875000 0.375000 +v 0.062500 0.125000 0.375000 +v 0.062500 0.875000 -0.375000 +v 0.062500 0.125000 -0.375000 +v 0.000000 0.937500 0.437500 +v 0.000000 0.062500 0.437500 +v 0.000000 0.937500 -0.437500 +v 0.000000 0.062500 -0.437500 +v 0.125000 0.875000 -0.375000 +v 0.125000 0.875000 0.375000 +v 0.125000 0.125000 0.375000 +v 0.125000 0.125000 -0.375000 +v 0.125000 0.937500 -0.437500 +v 0.125000 0.937500 0.437500 +v 0.125000 0.062500 0.437500 +v 0.125000 0.062500 -0.437500 +vt 0.200060 0.200060 +vt 0.799941 0.799940 +vt 0.200060 0.799940 +vt 0.150070 0.200060 +vt 0.200060 0.849930 +vt 0.999900 0.849930 +vt 0.899920 0.150070 +vt 0.999900 0.150070 +vt 0.000100 0.150070 +vt 0.100080 0.849930 +vt 0.000100 0.849930 +vt 0.849930 0.000100 +vt 0.150070 0.100080 +vt 0.150070 0.000100 +vt 0.150070 0.999900 +vt 0.849930 0.899920 +vt 0.849930 0.999900 +vt 0.799940 0.849930 +vt 0.150070 0.899920 +vt 0.150070 0.799940 +vt 0.100080 0.150070 +vt 0.200060 0.150070 +vt 0.849930 0.100080 +vt 0.799940 0.150070 +vt 0.849930 0.200060 +vt 0.899920 0.849930 +vt 0.849930 0.799940 +vt 0.799940 0.200059 +vn 1.0000 0.0000 0.0000 +vn 0.0000 0.0000 -1.0000 +vn 0.0000 -1.0000 0.0000 +vn 0.0000 -0.0000 1.0000 +vn 0.0000 1.0000 0.0000 +s off +f 2/1/1 3/2/1 1/3/1 +f 1/3/2 11/4/2 2/1/2 +f 3/2/3 10/5/3 1/3/3 +f 7/6/2 16/7/2 8/8/2 +f 6/9/4 14/10/4 5/11/4 +f 8/12/3 15/13/3 6/14/3 +f 5/15/5 13/16/5 7/17/5 +f 9/18/1 14/19/1 10/5/1 +f 10/20/1 15/21/1 11/4/1 +f 11/22/1 16/23/1 12/24/1 +f 12/25/1 13/26/1 9/27/1 +f 4/28/4 9/27/4 3/2/4 +f 2/1/5 12/24/5 4/28/5 +f 2/1/1 4/28/1 3/2/1 +f 1/3/2 10/20/2 11/4/2 +f 3/2/3 9/18/3 10/5/3 +f 7/6/2 13/26/2 16/7/2 +f 6/9/4 15/21/4 14/10/4 +f 8/12/3 16/23/3 15/13/3 +f 5/15/5 14/19/5 13/16/5 +f 9/18/1 13/16/1 14/19/1 +f 10/20/1 14/10/1 15/21/1 +f 11/22/1 15/13/1 16/23/1 +f 12/25/1 16/7/1 13/26/1 +f 4/28/4 12/25/4 9/27/4 +f 2/1/5 11/22/5 12/24/5 diff --git a/src/main/resources/assets/hbm/textures/gui/machine/gui_rbmk_graph.png b/src/main/resources/assets/hbm/textures/gui/machine/gui_rbmk_graph.png index 17036c200..6771c25aa 100644 Binary files a/src/main/resources/assets/hbm/textures/gui/machine/gui_rbmk_graph.png and b/src/main/resources/assets/hbm/textures/gui/machine/gui_rbmk_graph.png differ diff --git a/src/main/resources/assets/hbm/textures/models/network/terminal.png b/src/main/resources/assets/hbm/textures/models/network/terminal.png new file mode 100644 index 000000000..5cc569b81 Binary files /dev/null and b/src/main/resources/assets/hbm/textures/models/network/terminal.png differ