mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-03-14 05:35:35 +00:00
configurable RoR button panel
This commit is contained in:
parent
a95b3761c6
commit
816ead946d
13
changelog
13
changelog
@ -1,3 +1,13 @@
|
|||||||
|
## Added
|
||||||
|
* Key pad
|
||||||
|
* Fits visually with the RBMK display block
|
||||||
|
* Allows up to four buttons to be configured with a screwdriver (shhift click!)
|
||||||
|
* Buttons will send RoR signals when pressed, with a configured value on the configured frequencies
|
||||||
|
* Can be set to polling, which will resend the command until the button is pressed again
|
||||||
|
* Single push buttons and buttons set to polling which are enabled will glow in the dark
|
||||||
|
* Each button can be assigned a label with glow in the dark paint
|
||||||
|
* Allows RBMK control rods to be fully remote controllable with no console
|
||||||
|
|
||||||
## Changed
|
## Changed
|
||||||
* Updated textures for some nuclear bomb GUIs
|
* Updated textures for some nuclear bomb GUIs
|
||||||
* RBMK fuel rods too hot to be taken out manually can now be removed by players in creative mode
|
* RBMK fuel rods too hot to be taken out manually can now be removed by players in creative mode
|
||||||
@ -7,4 +17,5 @@
|
|||||||
|
|
||||||
## Fixed
|
## Fixed
|
||||||
* Fixed some damage categories not applying correctly, causing things like general energy resistance to not work against lasers
|
* Fixed some damage categories not applying correctly, causing things like general energy resistance to not work against lasers
|
||||||
* Fixed RoR components not being able to be attached to the top of reasim fuel rods
|
* Fixed RoR components not being able to be attached to the top of reasim fuel rods
|
||||||
|
* Fixed a crash in multiplayer regarding RBMK control rods
|
||||||
@ -1,14 +1,51 @@
|
|||||||
package com.hbm.blocks.machine.rbmk;
|
package com.hbm.blocks.machine.rbmk;
|
||||||
|
|
||||||
|
import com.hbm.main.MainRegistry;
|
||||||
import com.hbm.tileentity.machine.rbmk.TileEntityRBMKKeyPad;
|
import com.hbm.tileentity.machine.rbmk.TileEntityRBMKKeyPad;
|
||||||
|
|
||||||
|
import api.hbm.block.IToolable;
|
||||||
|
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
public class RBMKKeyPad extends RBMKMiniPanelBase {
|
public class RBMKKeyPad extends RBMKMiniPanelBase implements IToolable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TileEntity createNewTileEntity(World world, int meta) {
|
public TileEntity createNewTileEntity(World world, int meta) {
|
||||||
return new TileEntityRBMKKeyPad();
|
return new TileEntityRBMKKeyPad();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onScrew(World world, EntityPlayer player, int x, int y, int z, int side, float fX, float fY, float fZ, ToolType tool) {
|
||||||
|
if(tool != ToolType.SCREWDRIVER) return false;
|
||||||
|
if(world.isRemote) FMLNetworkHandler.openGui(player, MainRegistry.instance, 0, world, x, y, z);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@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;
|
||||||
|
if(player.isSneaking()) return false;
|
||||||
|
|
||||||
|
if(hitX != 0 && hitX != 1 && hitZ != 0 && hitZ != 1 && side != 0 && side != 1) {
|
||||||
|
|
||||||
|
TileEntityRBMKKeyPad tile = (TileEntityRBMKKeyPad) world.getTileEntity(x, y, z);
|
||||||
|
int meta = world.getBlockMetadata(x, y, z);
|
||||||
|
|
||||||
|
int indexHit = 0;
|
||||||
|
|
||||||
|
if(meta == 2 && hitX < 0.5) indexHit = 1;
|
||||||
|
if(meta == 3 && hitX > 0.5) indexHit = 1;
|
||||||
|
if(meta == 4 && hitZ > 0.5) indexHit = 1;
|
||||||
|
if(meta == 5 && hitZ < 0.5) indexHit = 1;
|
||||||
|
|
||||||
|
if(hitY < 0.5) indexHit += 2;
|
||||||
|
|
||||||
|
if(!tile.keys[indexHit].active) return false;
|
||||||
|
tile.keys[indexHit].click();
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,6 +2,7 @@ package com.hbm.blocks.machine.rbmk;
|
|||||||
|
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
|
import com.hbm.lib.Library;
|
||||||
import com.hbm.render.block.ISBRHUniversal;
|
import com.hbm.render.block.ISBRHUniversal;
|
||||||
import com.hbm.render.util.RenderBlocksNT;
|
import com.hbm.render.util.RenderBlocksNT;
|
||||||
|
|
||||||
@ -34,6 +35,18 @@ public abstract class RBMKMiniPanelBase extends BlockContainer implements ISBRHU
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) {
|
||||||
|
|
||||||
|
int meta = world.getBlockMetadata(x, y, z);
|
||||||
|
setBlockBounds(0, 0, 0, 1, 1, 1);
|
||||||
|
|
||||||
|
if(meta == Library.POS_X.ordinal()) setBlockBounds(0, 0, 0, 0.75F, 1, 1);
|
||||||
|
if(meta == Library.POS_Z.ordinal()) setBlockBounds(0, 0, 0, 1, 1, 0.75F);
|
||||||
|
if(meta == Library.NEG_X.ordinal()) setBlockBounds(0.25F, 0, 0, 1, 1, 1);
|
||||||
|
if(meta == Library.NEG_Z.ordinal()) setBlockBounds(0, 0, 0.25F, 1, 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemStack) {
|
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemStack) {
|
||||||
int i = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
|
int i = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
|
||||||
|
|||||||
174
src/main/java/com/hbm/inventory/gui/GUIScreenRBMKKeyPad.java
Normal file
174
src/main/java/com/hbm/inventory/gui/GUIScreenRBMKKeyPad.java
Normal file
@ -0,0 +1,174 @@
|
|||||||
|
package com.hbm.inventory.gui;
|
||||||
|
|
||||||
|
import org.lwjgl.input.Keyboard;
|
||||||
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
|
import com.hbm.lib.RefStrings;
|
||||||
|
import com.hbm.packet.PacketDispatcher;
|
||||||
|
import com.hbm.packet.toserver.NBTControlPacket;
|
||||||
|
import com.hbm.tileentity.machine.rbmk.TileEntityRBMKKeyPad;
|
||||||
|
import com.hbm.util.i18n.I18nUtil;
|
||||||
|
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.audio.PositionedSoundRecord;
|
||||||
|
import net.minecraft.client.gui.GuiScreen;
|
||||||
|
import net.minecraft.client.gui.GuiTextField;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
|
public class GUIScreenRBMKKeyPad extends GuiScreen {
|
||||||
|
|
||||||
|
private static ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/machine/gui_rbmk_keypad.png");
|
||||||
|
public TileEntityRBMKKeyPad keypad;
|
||||||
|
protected int xSize = 256;
|
||||||
|
protected int ySize = 204;
|
||||||
|
protected int guiLeft;
|
||||||
|
protected int guiTop;
|
||||||
|
|
||||||
|
protected GuiTextField[] color = new GuiTextField[4];
|
||||||
|
protected GuiTextField[] label = new GuiTextField[4];
|
||||||
|
protected GuiTextField[] rtty = new GuiTextField[4];
|
||||||
|
protected GuiTextField[] cmd = new GuiTextField[4];
|
||||||
|
protected boolean[] active = new boolean[4];
|
||||||
|
protected boolean[] polling = new boolean[4];
|
||||||
|
|
||||||
|
public GUIScreenRBMKKeyPad(TileEntityRBMKKeyPad keypad) {
|
||||||
|
this.keypad = keypad;
|
||||||
|
|
||||||
|
this.xSize = 256;
|
||||||
|
this.ySize = 204;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setupTextFieldStandard(GuiTextField field, int length, String def) {
|
||||||
|
field.setTextColor(0x00ff00);
|
||||||
|
field.setDisabledTextColour(0x00ff00);
|
||||||
|
field.setEnableBackgroundDrawing(false);
|
||||||
|
field.setMaxStringLength(length);
|
||||||
|
field.setText(def != null ? def : "");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initGui() {
|
||||||
|
super.initGui();
|
||||||
|
this.guiLeft = (this.width - this.xSize) / 2;
|
||||||
|
this.guiTop = (this.height - this.ySize) / 2;
|
||||||
|
|
||||||
|
Keyboard.enableRepeatEvents(true);
|
||||||
|
|
||||||
|
int oX = 4;
|
||||||
|
int oY = 4;
|
||||||
|
|
||||||
|
for(int i = 0; i < 4; i++) {
|
||||||
|
String col = Integer.toHexString(keypad.keys[i].color);
|
||||||
|
while(col.length() < 6) col = "0" + col;
|
||||||
|
color[i] = new GuiTextField(this.fontRendererObj, guiLeft + 27 + oX, guiTop + 55 + oY + i * 36, 72 - oX * 2, 14);
|
||||||
|
setupTextFieldStandard(color[i], 6, col);
|
||||||
|
label[i] = new GuiTextField(this.fontRendererObj, guiLeft + 175 + oX, guiTop + 55 + oY + i * 36, 72 - oX * 2, 14);
|
||||||
|
setupTextFieldStandard(label[i], 15, keypad.keys[i].label);
|
||||||
|
rtty[i] = new GuiTextField(this.fontRendererObj, guiLeft + 27 + oX, guiTop + 73 + oY + i * 36, 72 - oX * 2, 14);
|
||||||
|
setupTextFieldStandard(rtty[i], 10, keypad.keys[i].rtty);
|
||||||
|
cmd[i] = new GuiTextField(this.fontRendererObj, guiLeft + 121 + oX, guiTop + 73 + oY + i * 36, 126 - oX * 2, 14);
|
||||||
|
setupTextFieldStandard(cmd[i], 32, keypad.keys[i].command);
|
||||||
|
|
||||||
|
active[i] = keypad.keys[i].active;
|
||||||
|
polling[i] = keypad.keys[i].polling;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drawScreen(int mouseX, int mouseY, float f) {
|
||||||
|
this.drawDefaultBackground();
|
||||||
|
this.drawGuiContainerBackgroundLayer(f, mouseX, mouseY);
|
||||||
|
GL11.glDisable(GL11.GL_LIGHTING);
|
||||||
|
this.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||||
|
GL11.glEnable(GL11.GL_LIGHTING);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void drawGuiContainerForegroundLayer(int x, int y) {
|
||||||
|
String name = I18nUtil.resolveKey("container.rbmkKeyPad");
|
||||||
|
this.fontRendererObj.drawString(name, this.guiLeft + this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, this.guiTop + 6, 4210752);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void drawGuiContainerBackgroundLayer(float f, int mouseX, int mouseY) {
|
||||||
|
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||||
|
Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
|
||||||
|
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
|
||||||
|
|
||||||
|
for(int i = 0; i < 4; i++) {
|
||||||
|
if(this.active[i]) drawTexturedModalRect(guiLeft + 111, guiTop + i * 36 + 54, 18, 204, 16, 16);
|
||||||
|
if(this.polling[i]) drawTexturedModalRect(guiLeft + 128, guiTop + i * 36 + 53, 0, 204, 18, 18);
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int i = 0; i < 4; i++) {
|
||||||
|
this.color[i].drawTextBox();
|
||||||
|
this.label[i].drawTextBox();
|
||||||
|
this.rtty[i].drawTextBox();
|
||||||
|
this.cmd[i].drawTextBox();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void mouseClicked(int x, int y, int b) {
|
||||||
|
super.mouseClicked(x, y, b);
|
||||||
|
|
||||||
|
for(int i = 0; i < 4; i++) {
|
||||||
|
if(guiLeft + 111 <= x && guiLeft + 111 + 16 > x && guiTop + i * 36 + 54 < y && guiTop + i * 36 + 54 + 16 >= y) {
|
||||||
|
this.active[i] = !this.active[i];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(guiLeft + 128 <= x && guiLeft + 128 + 18 > x && guiTop + i * 36 + 53 < y && guiTop + i * 36 + 53 + 18 >= y) {
|
||||||
|
this.polling[i] = !this.polling[i];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(guiLeft + 209 <= x && guiLeft + 209 + 18 > x && guiTop + 17 < y && guiTop + 17 + 18 >= y) {
|
||||||
|
mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
|
||||||
|
NBTTagCompound data = new NBTTagCompound();
|
||||||
|
byte active = 0;
|
||||||
|
byte polling = 0;
|
||||||
|
for(int i = 0; i < 4; i++) {
|
||||||
|
if(this.active[i]) active |= 1 << i;
|
||||||
|
if(this.polling[i]) polling |= 1 << i;
|
||||||
|
}
|
||||||
|
data.setByte("active", active);
|
||||||
|
data.setByte("polling", polling);
|
||||||
|
|
||||||
|
for(int i = 0; i < 4; i++) {
|
||||||
|
try { data.setInteger("color" + i, Integer.parseInt(this.color[i].getText(), 16)); } catch(Exception ex) { }
|
||||||
|
data.setString("label" + i, this.label[i].getText());
|
||||||
|
data.setString("rtty" + i, this.rtty[i].getText());
|
||||||
|
data.setString("cmd" + i, this.cmd[i].getText());
|
||||||
|
}
|
||||||
|
PacketDispatcher.wrapper.sendToServer(new NBTControlPacket(data, keypad.xCoord, keypad.yCoord, keypad.zCoord));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int i = 0; i < 4; i++) {
|
||||||
|
this.color[i].mouseClicked(x, y, b);
|
||||||
|
this.label[i].mouseClicked(x, y, b);
|
||||||
|
this.rtty[i].mouseClicked(x, y, b);
|
||||||
|
this.cmd[i].mouseClicked(x, y, b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void keyTyped(char c, int b) {
|
||||||
|
|
||||||
|
for(int i = 0; i < 4; i++) {
|
||||||
|
if(this.color[i].textboxKeyTyped(c, b)) return;
|
||||||
|
if(this.label[i].textboxKeyTyped(c, b)) return;
|
||||||
|
if(this.rtty[i].textboxKeyTyped(c, b)) return;
|
||||||
|
if(this.cmd[i].textboxKeyTyped(c, b)) return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(b == 1 || b == this.mc.gameSettings.keyBindInventory.getKeyCode()) {
|
||||||
|
this.mc.thePlayer.closeScreen();
|
||||||
|
this.mc.setIngameFocus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public void onGuiClosed() { Keyboard.enableRepeatEvents(false); }
|
||||||
|
@Override public boolean doesGuiPauseGame() { return false; }
|
||||||
|
}
|
||||||
@ -71,7 +71,6 @@ public class GUIScreenRadioTorchController extends GuiScreen {
|
|||||||
GL11.glEnable(GL11.GL_LIGHTING);
|
GL11.glEnable(GL11.GL_LIGHTING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void drawGuiContainerForegroundLayer(int x, int y) {
|
private void drawGuiContainerForegroundLayer(int x, int y) {
|
||||||
String name = I18nUtil.resolveKey("container.rttyController");
|
String name = I18nUtil.resolveKey("container.rttyController");
|
||||||
this.fontRendererObj.drawString(name, this.guiLeft + this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, this.guiTop + 6, 4210752);
|
this.fontRendererObj.drawString(name, this.guiLeft + this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, this.guiTop + 6, 4210752);
|
||||||
|
|||||||
@ -1613,6 +1613,7 @@ public class ResourceManager {
|
|||||||
public static final HFRWavefrontObjectVBO rbmk_crane = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/rbmk/crane.obj")).asVBO();
|
public static final HFRWavefrontObjectVBO rbmk_crane = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/rbmk/crane.obj")).asVBO();
|
||||||
public static final HFRWavefrontObjectVBO rbmk_autoloader = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/rbmk/autoloader.obj")).asVBO();
|
public static final HFRWavefrontObjectVBO rbmk_autoloader = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/rbmk/autoloader.obj")).asVBO();
|
||||||
public static final HFRWavefrontObjectVBO rbmk_console = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/rbmk/rbmk_console.obj")).asVBO();
|
public static final HFRWavefrontObjectVBO rbmk_console = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/rbmk/rbmk_console.obj")).asVBO();
|
||||||
|
public static final HFRWavefrontObjectVBO rbmk_button = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/rbmk/button.obj")).asVBO();
|
||||||
public static final HFRWavefrontObject rbmk_debris = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/rbmk/debris.obj")).noSmooth();
|
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_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");
|
public static final ResourceLocation rbmk_crane_tex = new ResourceLocation(RefStrings.MODID, "textures/models/machines/rbmk_crane.png");
|
||||||
|
|||||||
@ -2,8 +2,13 @@ package com.hbm.render.tileentity;
|
|||||||
|
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
|
import com.hbm.main.ResourceManager;
|
||||||
import com.hbm.tileentity.machine.rbmk.TileEntityRBMKKeyPad;
|
import com.hbm.tileentity.machine.rbmk.TileEntityRBMKKeyPad;
|
||||||
|
import com.hbm.tileentity.machine.rbmk.TileEntityRBMKKeyPad.KeyUnit;
|
||||||
|
import com.hbm.util.ColorUtil;
|
||||||
|
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.gui.FontRenderer;
|
||||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
|
||||||
@ -26,6 +31,49 @@ public class RenderRBMKKeyPad extends TileEntitySpecialRenderer {
|
|||||||
|
|
||||||
TileEntityRBMKKeyPad keypad = (TileEntityRBMKKeyPad) te;
|
TileEntityRBMKKeyPad keypad = (TileEntityRBMKKeyPad) te;
|
||||||
|
|
||||||
|
for(int i = 0; i < 4; i++) {
|
||||||
|
KeyUnit key = keypad.keys[i];
|
||||||
|
if(!key.active) continue;
|
||||||
|
|
||||||
|
boolean glow = !(key.polling && !key.isPressed);
|
||||||
|
float mult = glow ? 1F : 0.5F;
|
||||||
|
|
||||||
|
GL11.glPushMatrix();
|
||||||
|
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||||
|
GL11.glTranslated(0.25, (i / 2) * -0.5 + 0.25, (i % 2) * -0.5 + 0.25);
|
||||||
|
|
||||||
|
GL11.glColor3f(0.5F, 0.5F, 0.5F);
|
||||||
|
ResourceManager.rbmk_button.renderPart("Socket");
|
||||||
|
|
||||||
|
GL11.glPushMatrix();
|
||||||
|
GL11.glTranslated((key.polling && key.isPressed) ? -0.03125 : 0, 0, 0);
|
||||||
|
GL11.glColor3f(ColorUtil.fr(key.color) * mult, ColorUtil.fg(key.color) * mult, ColorUtil.fb(key.color) * mult);
|
||||||
|
|
||||||
|
if(glow) RenderArcFurnace.fullbright(true);
|
||||||
|
ResourceManager.rbmk_button.renderPart("Button");
|
||||||
|
if(glow) RenderArcFurnace.fullbright(false);
|
||||||
|
|
||||||
|
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||||
|
GL11.glPopMatrix();
|
||||||
|
|
||||||
|
FontRenderer font = Minecraft.getMinecraft().fontRenderer;
|
||||||
|
int height = font.FONT_HEIGHT;
|
||||||
|
if(key.label != null && !key.label.isEmpty()) {
|
||||||
|
|
||||||
|
GL11.glTranslated(0.01, 0.3125, 0);
|
||||||
|
int width = font.getStringWidth(key.label);
|
||||||
|
float f3 = Math.min(0.0125F, 0.4F / Math.max(width, 1));
|
||||||
|
GL11.glScalef(f3, -f3, f3);
|
||||||
|
GL11.glNormal3f(0.0F, 0.0F, -1.0F);
|
||||||
|
GL11.glRotatef(90, 0, 1, 0);
|
||||||
|
|
||||||
|
RenderArcFurnace.fullbright(true);
|
||||||
|
font.drawString(key.label, - width / 2, - height / 2, 0x00ff00);
|
||||||
|
RenderArcFurnace.fullbright(false);
|
||||||
|
}
|
||||||
|
GL11.glPopMatrix();
|
||||||
|
}
|
||||||
|
|
||||||
GL11.glPopMatrix();
|
GL11.glPopMatrix();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,7 +23,6 @@ import net.minecraftforge.common.util.ForgeDirection;
|
|||||||
@Optional.InterfaceList({@Optional.Interface(iface = "li.cil.oc.api.network.SimpleComponent", modid = "OpenComputers")})
|
@Optional.InterfaceList({@Optional.Interface(iface = "li.cil.oc.api.network.SimpleComponent", modid = "OpenComputers")})
|
||||||
public abstract class TileEntityRBMKControl extends TileEntityRBMKSlottedBase implements SimpleComponent, CompatHandler.OCComponent, IEnergyReceiverMK2 {
|
public abstract class TileEntityRBMKControl extends TileEntityRBMKSlottedBase implements SimpleComponent, CompatHandler.OCComponent, IEnergyReceiverMK2 {
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public double lastLevel;
|
public double lastLevel;
|
||||||
public double level;
|
public double level;
|
||||||
public static final double speed = 0.00277D; // it takes around 18 seconds for the thing to fully extend
|
public static final double speed = 0.00277D; // it takes around 18 seconds for the thing to fully extend
|
||||||
|
|||||||
@ -1,12 +1,20 @@
|
|||||||
package com.hbm.tileentity.machine.rbmk;
|
package com.hbm.tileentity.machine.rbmk;
|
||||||
|
|
||||||
|
import com.hbm.interfaces.IControlReceiver;
|
||||||
|
import com.hbm.inventory.gui.GUIScreenRBMKKeyPad;
|
||||||
|
import com.hbm.tileentity.IGUIProvider;
|
||||||
import com.hbm.tileentity.TileEntityLoadedBase;
|
import com.hbm.tileentity.TileEntityLoadedBase;
|
||||||
import com.hbm.tileentity.network.RTTYSystem;
|
import com.hbm.tileentity.network.RTTYSystem;
|
||||||
import com.hbm.util.BufferUtil;
|
import com.hbm.util.BufferUtil;
|
||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.inventory.Container;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.util.MathHelper;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
public class TileEntityRBMKKeyPad extends TileEntityLoadedBase {
|
public class TileEntityRBMKKeyPad extends TileEntityLoadedBase implements IGUIProvider, IControlReceiver {
|
||||||
|
|
||||||
/* __________
|
/* __________
|
||||||
* / /|
|
* / /|
|
||||||
@ -21,7 +29,7 @@ public class TileEntityRBMKKeyPad extends TileEntityLoadedBase {
|
|||||||
public KeyUnit[] keys = new KeyUnit[4];
|
public KeyUnit[] keys = new KeyUnit[4];
|
||||||
|
|
||||||
public TileEntityRBMKKeyPad() {
|
public TileEntityRBMKKeyPad() {
|
||||||
for(int i = 0; i < 4; i++) this.keys[i] = new KeyUnit();
|
for(int i = 0; i < 4; i++) this.keys[i] = new KeyUnit(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -61,8 +69,20 @@ public class TileEntityRBMKKeyPad extends TileEntityLoadedBase {
|
|||||||
public String rtty;
|
public String rtty;
|
||||||
/** What to send when pressed */
|
/** What to send when pressed */
|
||||||
public String command;
|
public String command;
|
||||||
|
/** Whether this button is enabled and can be pressed */
|
||||||
|
public boolean active;
|
||||||
|
|
||||||
|
public KeyUnit(int initialIndex) {
|
||||||
|
if(initialIndex == 0) color = 0xff0000;
|
||||||
|
if(initialIndex == 1) color = 0xffff00;
|
||||||
|
if(initialIndex == 2) color = 0x0080ff;
|
||||||
|
if(initialIndex == 3) color = 0x00ff00;
|
||||||
|
label = "Button " + (initialIndex + 1);
|
||||||
|
}
|
||||||
|
|
||||||
public void click() {
|
public void click() {
|
||||||
|
if(!active) return;
|
||||||
|
|
||||||
if(!polling) {
|
if(!polling) {
|
||||||
if(canSend()) RTTYSystem.broadcast(worldObj, rtty, command);
|
if(canSend()) RTTYSystem.broadcast(worldObj, rtty, command);
|
||||||
} else {
|
} else {
|
||||||
@ -72,6 +92,8 @@ public class TileEntityRBMKKeyPad extends TileEntityLoadedBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void update() {
|
public void update() {
|
||||||
|
if(!active) return;
|
||||||
|
|
||||||
if(polling && isPressed) {
|
if(polling && isPressed) {
|
||||||
if(canSend()) RTTYSystem.broadcast(worldObj, rtty, command);
|
if(canSend()) RTTYSystem.broadcast(worldObj, rtty, command);
|
||||||
}
|
}
|
||||||
@ -82,6 +104,7 @@ public class TileEntityRBMKKeyPad extends TileEntityLoadedBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void serialize(ByteBuf buf) {
|
public void serialize(ByteBuf buf) {
|
||||||
|
buf.writeBoolean(active);
|
||||||
buf.writeBoolean(polling);
|
buf.writeBoolean(polling);
|
||||||
if(polling) buf.writeBoolean(isPressed);
|
if(polling) buf.writeBoolean(isPressed);
|
||||||
buf.writeInt(color);
|
buf.writeInt(color);
|
||||||
@ -91,6 +114,7 @@ public class TileEntityRBMKKeyPad extends TileEntityLoadedBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void deserialize(ByteBuf buf) {
|
public void deserialize(ByteBuf buf) {
|
||||||
|
active = buf.readBoolean();
|
||||||
polling = buf.readBoolean();
|
polling = buf.readBoolean();
|
||||||
if(polling) isPressed = buf.readBoolean();
|
if(polling) isPressed = buf.readBoolean();
|
||||||
color = buf.readInt();
|
color = buf.readInt();
|
||||||
@ -99,4 +123,31 @@ public class TileEntityRBMKKeyPad extends TileEntityLoadedBase {
|
|||||||
command = BufferUtil.readString(buf);
|
command = BufferUtil.readString(buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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 GUIScreenRBMKKeyPad(this); }
|
||||||
|
|
||||||
|
@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) {
|
||||||
|
|
||||||
|
int active = data.getByte("active");
|
||||||
|
int polling = data.getByte("polling");
|
||||||
|
for(int i = 0; i < 4; i++) {
|
||||||
|
this.keys[i].active = (active & (1 << i)) != 0;
|
||||||
|
this.keys[i].polling = (polling & (1 << i)) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int i = 0; i < 4; i++) {
|
||||||
|
KeyUnit key = this.keys[i];
|
||||||
|
key.color = MathHelper.clamp_int(data.getInteger("color" + i), 0, 0xffffff);
|
||||||
|
key.label = data.getString("label" + i);
|
||||||
|
key.rtty = data.getString("rtty" + i);
|
||||||
|
key.command = data.getString("cmd" + i);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
52
src/main/resources/assets/hbm/models/rbmk/button.obj
Normal file
52
src/main/resources/assets/hbm/models/rbmk/button.obj
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
# Blender v2.79 (sub 0) OBJ File: ''
|
||||||
|
# www.blender.org
|
||||||
|
o Socket
|
||||||
|
v 0.062500 0.718750 0.156250
|
||||||
|
v 0.062500 0.406250 0.156250
|
||||||
|
v 0.062500 0.406250 -0.156250
|
||||||
|
v 0.062500 0.718750 -0.156250
|
||||||
|
v 0.000000 0.718750 -0.156250
|
||||||
|
v 0.000000 0.406250 -0.156250
|
||||||
|
v 0.000000 0.718750 0.156250
|
||||||
|
v 0.000000 0.406250 0.156250
|
||||||
|
vn 0.0000 -1.0000 0.0000
|
||||||
|
vn 0.0000 0.0000 1.0000
|
||||||
|
vn 0.0000 0.0000 -1.0000
|
||||||
|
vn 0.0000 1.0000 0.0000
|
||||||
|
vn 1.0000 0.0000 0.0000
|
||||||
|
s off
|
||||||
|
f 6//1 2//1 8//1
|
||||||
|
f 8//2 1//2 7//2
|
||||||
|
f 5//3 3//3 6//3
|
||||||
|
f 7//4 4//4 5//4
|
||||||
|
f 4//5 2//5 3//5
|
||||||
|
f 6//1 3//1 2//1
|
||||||
|
f 8//2 2//2 1//2
|
||||||
|
f 5//3 4//3 3//3
|
||||||
|
f 7//4 1//4 4//4
|
||||||
|
f 4//5 1//5 2//5
|
||||||
|
o Button
|
||||||
|
v 0.062500 0.437500 0.125000
|
||||||
|
v 0.062500 0.687500 0.125000
|
||||||
|
v 0.062500 0.437500 -0.125000
|
||||||
|
v 0.062500 0.687500 -0.125000
|
||||||
|
v 0.125000 0.687500 -0.125000
|
||||||
|
v 0.125000 0.437500 -0.125000
|
||||||
|
v 0.125000 0.437500 0.125000
|
||||||
|
v 0.125000 0.687500 0.125000
|
||||||
|
vn 1.0000 0.0000 0.0000
|
||||||
|
vn 0.0000 1.0000 0.0000
|
||||||
|
vn 0.0000 0.0000 -1.0000
|
||||||
|
vn 0.0000 0.0000 1.0000
|
||||||
|
vn 0.0000 -1.0000 0.0000
|
||||||
|
s off
|
||||||
|
f 13//6 15//6 14//6
|
||||||
|
f 10//7 13//7 12//7
|
||||||
|
f 12//8 14//8 11//8
|
||||||
|
f 9//9 16//9 10//9
|
||||||
|
f 11//10 15//10 9//10
|
||||||
|
f 13//6 16//6 15//6
|
||||||
|
f 10//7 16//7 13//7
|
||||||
|
f 12//8 13//8 14//8
|
||||||
|
f 9//9 15//9 16//9
|
||||||
|
f 11//10 14//10 15//10
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 4.4 KiB |
Loading…
x
Reference in New Issue
Block a user