/
Belyash5
/
Flu
Обзор
Документация
Войти
/
Belyash5
/
Flu
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/main/java/com/hbm/inventory/gui/GUIScreenRadioTorchController.java
154 строки
5 KB
Bob
i have achieved stability (ability to stab)
04 май 2025, 23:55
04 май 2025, 23:55
82d3523
Код
Авторство
О чём код?
package com.hbm.inventory.gui; import java.util.ArrayList; import java.util.Arrays; import java.util.List; 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.network.TileEntityRadioTorchController; import com.hbm.util.Compat; import com.hbm.util.I18nUtil; import api.hbm.redstoneoverradio.IRORInfo; import api.hbm.redstoneoverradio.IRORValueProvider; 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.tileentity.TileEntity; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.util.ForgeDirection; public class GUIScreenRadioTorchController extends GuiScreen { private static ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/machine/gui_rtty_controller.png"); protected TileEntityRadioTorchController rtty; protected int xSize = 256; protected int ySize = 204; protected int guiLeft; protected int guiTop; protected GuiTextField frequency; public GUIScreenRadioTorchController(TileEntityRadioTorchController radio) { this.rtty = radio; this.xSize = 256; this.ySize = 42; } @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; this.frequency = new GuiTextField(this.fontRendererObj, guiLeft + 25 + oX, guiTop + 17 + oY, 90 - oX * 2, 14); this.frequency.setTextColor(0x00ff00); this.frequency.setDisabledTextColour(0x00ff00); this.frequency.setEnableBackgroundDrawing(false); this.frequency.setMaxStringLength(10); this.frequency.setText(rtty.channel == null ? "" : rtty.channel); } @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.rttyController"); this.fontRendererObj.drawString(name, this.guiLeft + this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, this.guiTop + 6, 4210752); if(guiLeft + 173 <= x && guiLeft + 173 + 18 > x && guiTop + 17 < y && guiTop + 17 + 18 >= y) { func_146283_a(Arrays.asList(new String[] { rtty.polling ? "Polling" : "State Change" }), x, y); } if(guiLeft + 209 <= x && guiLeft + 209 + 18 > x && guiTop + 17 < y && guiTop + 17 + 18 >= y) { func_146283_a(Arrays.asList(new String[] { "Save Settings" }), x, y); } if(guiLeft + 137 <= x && guiLeft + 137 + 18 > x && guiTop + 17 < y && guiTop + 17 + 18 >= y) { ForgeDirection dir = ForgeDirection.getOrientation(rtty.getBlockMetadata()).getOpposite(); TileEntity tile = Compat.getTileStandard(rtty.getWorldObj(), rtty.xCoord + dir.offsetX, rtty.yCoord + dir.offsetY, rtty.zCoord + dir.offsetZ); if(tile instanceof IRORInfo) { IRORInfo prov = (IRORInfo) tile; String[] info = prov.getFunctionInfo(); List<String> lines = new ArrayList(); lines.add("Usable functions:"); for(String s : info) { if(s.startsWith(IRORValueProvider.PREFIX_FUNCTION)) lines.add(EnumChatFormatting.AQUA + s.substring(4)); } func_146283_a(lines, x, y); } } } 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); if(rtty.polling) { drawTexturedModalRect(guiLeft + 173, guiTop + 17, 0, 42, 18, 18); } this.frequency.drawTextBox(); } @Override protected void mouseClicked(int x, int y, int i) { super.mouseClicked(x, y, i); this.frequency.mouseClicked(x, y, i); if(guiLeft + 173 <= x && guiLeft + 173 + 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(); data.setBoolean("p", !rtty.polling); PacketDispatcher.wrapper.sendToServer(new NBTControlPacket(data, rtty.xCoord, rtty.yCoord, rtty.zCoord)); } 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(); data.setString("c", this.frequency.getText()); PacketDispatcher.wrapper.sendToServer(new NBTControlPacket(data, rtty.xCoord, rtty.yCoord, rtty.zCoord)); } } @Override protected void keyTyped(char c, int i) { if(this.frequency.textboxKeyTyped(c, i)) return; if(i == 1 || i == 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; } }