mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-08-10 17:55:44 +00:00
RoR pager
This commit is contained in:
parent
6bc4c2a836
commit
9cb618f124
10
changelog
10
changelog
@ -1,3 +1,13 @@
|
||||
## Added
|
||||
* Redstone-over-radio pager
|
||||
* Item that receives RoR signals and displays them on the HUD info system
|
||||
* Info contains the channel name, a shortened timestamp to tell apart equal signals sent on different ticks, and the actual signal
|
||||
* Useful in various situations:
|
||||
* Usable for remote monitoring, allowing critical things like reactor temperature and coolant flow to be checked even if not on-site
|
||||
* Using RoR transmitters that are set to polling, it's now very easy to figure out if the chunk the transmitter is in is loaded
|
||||
* An automated message system for various general alerts, easily doable by using an RoR transmitter with custom mappings (do mind the character limit, longer alerts may have to be sent sequentially)
|
||||
* A simple way of getting live feedback from the RoR system, in order to detect when or if a system sends a signal, since other RoR receivers do not have a way of telling apart repeated identical signals
|
||||
|
||||
## Changed
|
||||
* RoR readers can now read neutron flux from fuel channels and the fill state of boilers and heat exchangers
|
||||
* Canned recursion can now be crafted from canned recursion
|
||||
|
||||
103
src/main/java/com/hbm/inventory/gui/GUIScreenPager.java
Normal file
103
src/main/java/com/hbm/inventory/gui/GUIScreenPager.java
Normal file
@ -0,0 +1,103 @@
|
||||
package com.hbm.inventory.gui;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.hbm.items.tool.ItemRTTYPager;
|
||||
import com.hbm.lib.RefStrings;
|
||||
import com.hbm.packet.PacketDispatcher;
|
||||
import com.hbm.packet.toserver.NBTItemControlPacket;
|
||||
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.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class GUIScreenPager extends GuiScreen {
|
||||
|
||||
private static ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/machine/gui_rtty_pager.png");
|
||||
public ItemStack pager;
|
||||
public String startingChannel;
|
||||
protected int xSize = 184;
|
||||
protected int ySize = 42;
|
||||
protected int guiLeft;
|
||||
protected int guiTop;
|
||||
|
||||
protected GuiTextField chan;
|
||||
|
||||
public GUIScreenPager(ItemStack pager) {
|
||||
this.pager = pager;
|
||||
if(pager != null && pager.hasTagCompound()) {
|
||||
startingChannel = pager.stackTagCompound.getString(ItemRTTYPager.KEY_CHANNEL);
|
||||
}
|
||||
if(startingChannel == null) this.startingChannel = "";
|
||||
}
|
||||
|
||||
@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;
|
||||
|
||||
chan = new GuiTextField(this.fontRendererObj, guiLeft + 27 + oX, guiTop + 19 + oY, 90 - oX * 2, 14);
|
||||
GUIScreenRBMKKeyPad.setupTextFieldStandard(chan, 10, startingChannel);
|
||||
}
|
||||
|
||||
@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.rttyPager");
|
||||
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);
|
||||
chan.drawTextBox();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(int x, int y, int b) {
|
||||
super.mouseClicked(x, y, b);
|
||||
|
||||
if(guiLeft + 137 <= x && guiLeft + 137 + 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(ItemRTTYPager.KEY_CHANNEL, this.chan.getText());
|
||||
PacketDispatcher.wrapper.sendToServer(new NBTItemControlPacket(data));
|
||||
return;
|
||||
}
|
||||
|
||||
this.chan.mouseClicked(x, y, b);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped(char c, int b) {
|
||||
if(this.chan.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; }
|
||||
}
|
||||
@ -1148,6 +1148,7 @@ public class ModItems {
|
||||
public static Item drone_linker;
|
||||
public static Item radar_linker;
|
||||
public static Item settings_tool;
|
||||
public static Item rtty_pager;
|
||||
|
||||
public static Item blueprints;
|
||||
public static Item blueprint_folder;
|
||||
@ -3918,6 +3919,7 @@ public class ModItems {
|
||||
drone_linker = new ItemDroneLinker().setUnlocalizedName("drone_linker").setMaxStackSize(1).setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":drone_linker");
|
||||
radar_linker = new ItemRadarLinker().setUnlocalizedName("radar_linker").setMaxStackSize(1).setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":radar_linker");
|
||||
settings_tool = new ItemSettingsTool().setUnlocalizedName("settings_tool").setMaxStackSize(1).setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":settings_tool");
|
||||
rtty_pager = new ItemRTTYPager().setUnlocalizedName("rtty_pager").setMaxStackSize(1).setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":rtty_pager");
|
||||
|
||||
key = new ItemKey().setUnlocalizedName("key").setMaxStackSize(1).setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":key");
|
||||
key_red = new ItemCustomLore().setUnlocalizedName("key_red").setMaxStackSize(1).setCreativeTab(null).setTextureName(RefStrings.MODID + ":key_red");
|
||||
@ -5636,6 +5638,7 @@ public class ModItems {
|
||||
GameRegistry.registerItem(analysis_tool, analysis_tool.getUnlocalizedName());
|
||||
GameRegistry.registerItem(coupling_tool, coupling_tool.getUnlocalizedName());
|
||||
GameRegistry.registerItem(settings_tool, settings_tool.getUnlocalizedName());
|
||||
GameRegistry.registerItem(rtty_pager, rtty_pager.getUnlocalizedName());
|
||||
GameRegistry.registerItem(dosimeter, dosimeter.getUnlocalizedName());
|
||||
GameRegistry.registerItem(geiger_counter, geiger_counter.getUnlocalizedName());
|
||||
GameRegistry.registerItem(digamma_diagnostic, digamma_diagnostic.getUnlocalizedName());
|
||||
|
||||
69
src/main/java/com/hbm/items/tool/ItemRTTYPager.java
Normal file
69
src/main/java/com/hbm/items/tool/ItemRTTYPager.java
Normal file
@ -0,0 +1,69 @@
|
||||
package com.hbm.items.tool;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.hbm.inventory.gui.GUIScreenPager;
|
||||
import com.hbm.items.IItemControlReceiver;
|
||||
import com.hbm.main.MainRegistry;
|
||||
import com.hbm.main.ServerProxy;
|
||||
import com.hbm.packet.PacketDispatcher;
|
||||
import com.hbm.packet.toclient.PlayerInformPacket;
|
||||
import com.hbm.tileentity.IGUIProvider;
|
||||
import com.hbm.tileentity.network.RTTYSystem;
|
||||
import com.hbm.tileentity.network.RTTYSystem.RTTYChannel;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemRTTYPager extends Item implements IItemControlReceiver, IGUIProvider {
|
||||
|
||||
public static final String KEY_CHANNEL = "chan";
|
||||
|
||||
@Override
|
||||
public void onUpdate(ItemStack stack, World world, Entity entity, int slot, boolean held) {
|
||||
if(!stack.hasTagCompound() || !stack.stackTagCompound.hasKey(KEY_CHANNEL)) return;
|
||||
if(!(entity instanceof EntityPlayerMP) || world.isRemote) return;
|
||||
|
||||
String channelFreq = stack.stackTagCompound.getString(KEY_CHANNEL);
|
||||
RTTYChannel chan = RTTYSystem.listen(world, channelFreq);
|
||||
|
||||
if(chan != null && chan.timeStamp >= world.getTotalWorldTime() - 1) {
|
||||
int alive = entity.ticksExisted % 1000;
|
||||
String message = EnumChatFormatting.GOLD + "[ " + channelFreq + " (" + alive + ") ] " + EnumChatFormatting.YELLOW + chan.signal;
|
||||
PacketDispatcher.wrapper.sendTo(new PlayerInformPacket(message, ServerProxy.ID_PAGER_DYN + slot, 5_000), (EntityPlayerMP) entity);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
|
||||
if(world.isRemote) player.openGui(MainRegistry.instance, 0, world, 0, 0, 0);
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool) {
|
||||
if(!stack.hasTagCompound() || !stack.stackTagCompound.hasKey(KEY_CHANNEL) || stack.stackTagCompound.getString(KEY_CHANNEL).isEmpty()) {
|
||||
list.add(EnumChatFormatting.RED + "No channel set!");
|
||||
} else {
|
||||
list.add(EnumChatFormatting.YELLOW + "Channel: " + stack.stackTagCompound.getString(KEY_CHANNEL));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receiveControl(ItemStack stack, NBTTagCompound data) {
|
||||
if(data.hasKey("chan")) {
|
||||
if(!stack.hasTagCompound()) stack.stackTagCompound = new NBTTagCompound();
|
||||
stack.stackTagCompound.setString(KEY_CHANNEL, data.getString(KEY_CHANNEL));
|
||||
}
|
||||
}
|
||||
|
||||
@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 GUIScreenPager(player.getHeldItem()); }
|
||||
}
|
||||
@ -799,6 +799,8 @@ public class CraftingManager {
|
||||
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(ModItems.rtty_pager, 1), new Object[] { "R", "C", "S", 'R', ModBlocks.radio_torch_receiver, 'C', DictFrame.fromOne(ModItems.circuit, EnumCircuitType.BASIC), 'S', STEEL.plate() });
|
||||
|
||||
addRecipeAuto(new ItemStack(ModBlocks.deco_rbmk, 8), new Object[] { "R", 'R', ModBlocks.rbmk_blank });
|
||||
addRecipeAuto(new ItemStack(ModBlocks.deco_rbmk_smooth, 1), new Object[] { "R", 'R', ModBlocks.deco_rbmk });
|
||||
addRecipeAuto(new ItemStack(ModBlocks.rbmk_blank, 1), new Object[] { "RRR", "R R", "RRR", 'R', ModBlocks.deco_rbmk });
|
||||
|
||||
@ -34,6 +34,7 @@ public class ServerProxy {
|
||||
public static final int ID_TOOLABILITY = 11;
|
||||
public static final int ID_GAS_HAZARD = 12;
|
||||
public static final int ID_WRENCH = 13;
|
||||
public static final int ID_PAGER_DYN = 1000;
|
||||
|
||||
public ITranslate getI18n() { return I18N; }
|
||||
|
||||
|
||||
@ -27,7 +27,7 @@ public class NBTItemControlPacket implements IMessage {
|
||||
try {
|
||||
buffer.writeNBTTagCompoundToBuffer(nbt);
|
||||
|
||||
} catch (IOException e) {
|
||||
} catch(IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@ -35,7 +35,7 @@ public class NBTItemControlPacket implements IMessage {
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
|
||||
if (buffer == null) {
|
||||
if(buffer == null) {
|
||||
buffer = new PacketBuffer(Unpooled.buffer());
|
||||
}
|
||||
buffer.writeBytes(buf);
|
||||
@ -44,7 +44,7 @@ public class NBTItemControlPacket implements IMessage {
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
|
||||
if (buffer == null) {
|
||||
if(buffer == null) {
|
||||
buffer = new PacketBuffer(Unpooled.buffer());
|
||||
}
|
||||
buf.writeBytes(buffer);
|
||||
|
||||
@ -485,6 +485,7 @@ container.rtgFurnace=RTG-Ofen
|
||||
container.rttyController=Redstone-over-Radio Controller
|
||||
container.rttyCounter=Redstone-over-Radio Itemzähler
|
||||
container.rttyLogic=Redstone-over-Radio Logikkempfänger
|
||||
container.rttyPager=Redstone-over-Radio Pager
|
||||
container.rttyReader=Redstone-over-Radio Leser
|
||||
container.rttyReceiver=Redstone-over-Radio Empfänger
|
||||
container.rttySender=Redstone-over-Radio Sender
|
||||
@ -3357,6 +3358,7 @@ item.rpa_helmet.name=Powerrüstung der Versprengten - Helm
|
||||
item.rpa_legs.name=Powerrüstung der Versprengten - Beinschutz
|
||||
item.rpa_plate.name=Powerrüstung der Versprengten - Brustpanzer
|
||||
item.rtg_unit.name=RTG Einheit
|
||||
item.rtty_pager.name=Redstone-over-Radio Pager
|
||||
item.rune_blank.name=Blank Catalyst Matrix
|
||||
item.rune_dagaz.name=Balanced Catalyst Matrix
|
||||
item.rune_hagalaz.name=Rough Catalyst Matrix
|
||||
|
||||
@ -893,6 +893,7 @@ container.rtgFurnace=RTG Furnace
|
||||
container.rttyController=Redstone-over-Radio Controller
|
||||
container.rttyCounter=Redstone-over-Radio Item Counter
|
||||
container.rttyLogic=Redstone-over-Radio Logic Receiver
|
||||
container.rttyPager=Redstone-over-Radio Pager
|
||||
container.rttyReader=Redstone-over-Radio Reader
|
||||
container.rttyReceiver=Redstone-over-Radio Receiver
|
||||
container.rttySender=Redstone-over-Radio Transmitter
|
||||
@ -4456,6 +4457,7 @@ item.rpa_helmet.name=Remnants Power Armor Helmet
|
||||
item.rpa_legs.name=Remnants Power Armor Leggings
|
||||
item.rpa_plate.name=Remnants Power Armor Chestplate
|
||||
item.rtg_unit.name=RTG Unit
|
||||
item.rtty_pager.name=Redstone-over-Radio Pager
|
||||
item.rubber_gloves.name=Thick Rubber Gloves
|
||||
item.rune_blank.name=Blank Catalyst Matrix
|
||||
item.rune_dagaz.name=Balanced Catalyst Matrix
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 879 B |
BIN
src/main/resources/assets/hbm/textures/items/rtty_pager.png
Normal file
BIN
src/main/resources/assets/hbm/textures/items/rtty_pager.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 268 B |
Loading…
x
Reference in New Issue
Block a user