mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
RTTY control
This commit is contained in:
parent
0ab4f215b1
commit
dbbe55a990
@ -24,6 +24,7 @@
|
||||
* Sub-beams do not cause splash damage
|
||||
* Sub-beams will strike the initially hit entity again, meaning that the more sub-beams there are, the more powerful the initial strike ends up being
|
||||
* Renamed the default capacitor ammo to "capacitor (standard)" to avoid confusion
|
||||
* Low wavelength capacitors now need niobium instead of silicon to make
|
||||
|
||||
## Fixed
|
||||
* Fixed a potential crash caused by cargo dropships landing on cargo docks with no satellite chip installed
|
||||
|
||||
@ -7,6 +7,7 @@ public interface IRORInteractive extends IRORInfo {
|
||||
|
||||
public static String EX_NULL = "Exception: Null Command";
|
||||
public static String EX_NAME = "Exception: Multiple Name Separators";
|
||||
public static String EX_FORMAT = "Exception: Parameter in Invalid Format";
|
||||
|
||||
/** Runs a function on the ROR component, usually causing the component to change or do something. Returns are optional. */
|
||||
public String runRORFunction(String name, String[] params);
|
||||
@ -30,4 +31,11 @@ public interface IRORInteractive extends IRORInfo {
|
||||
String[] params = paramList.split(PARAM_SEPARATOR);
|
||||
return params;
|
||||
}
|
||||
|
||||
public static int parseInt(String val, int min, int max) {
|
||||
int result = 0;
|
||||
try { result = Integer.parseInt(val); } catch(Exception x) { throw new RORFunctionException(EX_FORMAT); };
|
||||
if(result < min || result > max) throw new RORFunctionException(EX_FORMAT);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,12 +1,24 @@
|
||||
package com.hbm.blocks.network;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.hbm.blocks.ILookOverlay;
|
||||
import com.hbm.inventory.gui.GUIScreenRadioTorchController;
|
||||
import com.hbm.tileentity.network.TileEntityRadioTorchController;
|
||||
import com.hbm.util.Compat;
|
||||
import com.hbm.util.I18nUtil;
|
||||
|
||||
import api.hbm.redstoneoverradio.IRORInteractive;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent.Pre;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class RadioTorchController extends RadioTorchBase {
|
||||
|
||||
@ -16,22 +28,32 @@ public class RadioTorchController extends RadioTorchBase {
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int meta) {
|
||||
return null;
|
||||
return new TileEntityRadioTorchController();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Container provideContainer(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
return null;
|
||||
public boolean canBlockStay(World world, int x, int y, int z, ForgeDirection dir, Block b) {
|
||||
TileEntity tile = Compat.getTileStandard(world, x - dir.offsetX, y - dir.offsetY, z - dir.offsetZ);
|
||||
return tile instanceof IRORInteractive;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printHook(Pre event, World world, int x, int y, int z) {
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
|
||||
if(te instanceof TileEntityRadioTorchController) {
|
||||
TileEntityRadioTorchController radio = (TileEntityRadioTorchController) te;
|
||||
List<String> text = new ArrayList();
|
||||
text.add(EnumChatFormatting.AQUA + "Freq: " + radio.channel);
|
||||
ILookOverlay.printGeneric(event, I18nUtil.resolveKey(getUnlocalizedName() + ".name"), 0xffff00, 0x404000, text);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Object provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
if(te instanceof TileEntityRadioTorchController) return new GUIScreenRadioTorchController((TileEntityRadioTorchController) te);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printHook(Pre event, World world, int x, int y, int z) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,150 @@
|
||||
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);
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -28,9 +28,7 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||
public class GUIScreenRadioTorchReader extends GuiScreen {
|
||||
|
||||
protected static final ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/machine/gui_rtty_reader.png");
|
||||
|
||||
public TileEntityRadioTorchReader rtty;
|
||||
|
||||
protected int xSize = 256;
|
||||
protected int ySize = 204;
|
||||
protected int guiLeft;
|
||||
|
||||
@ -40,6 +40,7 @@ public class AmmoPressRecipes extends SerializableRecipe {
|
||||
OreDictStack plastic = new OreDictStack(ANY_PLASTIC.ingot());
|
||||
OreDictStack uranium = new OreDictStack(U238.ingot());
|
||||
OreDictStack ferro = new OreDictStack(FERRO.ingot());
|
||||
OreDictStack nb = new OreDictStack(NB.ingot());
|
||||
ComparableStack smokeful = new ComparableStack(Items.gunpowder);
|
||||
OreDictStack smokeless = new OreDictStack(ANY_SMOKELESS.dust());
|
||||
ComparableStack rocket = new ComparableStack(ModItems.rocket_fuel);
|
||||
@ -386,9 +387,9 @@ public class AmmoPressRecipes extends SerializableRecipe {
|
||||
null, silicon.copy(6), null,
|
||||
null, plastic, null));
|
||||
recipes.add(new AmmoPressRecipe(DictFrame.fromOne(ModItems.ammo_standard, EnumAmmo.CAPACITOR_IR, 4),
|
||||
null, plastic, null,
|
||||
null, silicon.copy(4), null,
|
||||
null, plastic, null));
|
||||
null, plastic, null,
|
||||
null, nb, null,
|
||||
null, plastic, null));
|
||||
|
||||
OreDictStack lPlate = new OreDictStack(PB.plate());
|
||||
recipes.add(new AmmoPressRecipe(DictFrame.fromOne(ModItems.ammo_standard, EnumAmmo.TAU_URANIUM, 16),
|
||||
|
||||
@ -9,6 +9,8 @@ import com.hbm.inventory.fluid.tank.FluidTank;
|
||||
import api.hbm.energymk2.IEnergyReceiverMK2;
|
||||
import api.hbm.fluidmk2.IFluidConnectorMK2;
|
||||
import api.hbm.fluidmk2.IFluidReceiverMK2;
|
||||
import api.hbm.redstoneoverradio.IRORInfo;
|
||||
import api.hbm.redstoneoverradio.IRORValueProvider;
|
||||
import api.hbm.tile.IHeatSource;
|
||||
import com.hbm.inventory.material.Mats;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
@ -28,7 +30,7 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||
@Optional.Interface(iface = "com.hbm.handler.CompatHandler.OCComponent", modid = "opencomputers"),
|
||||
@Optional.Interface(iface = "li.cil.oc.api.network.SimpleComponent", modid = "opencomputers")
|
||||
})
|
||||
public class TileEntityProxyCombo extends TileEntityProxyBase implements IEnergyReceiverMK2, ISidedInventory, IFluidReceiverMK2, IHeatSource, ICrucibleAcceptor, SimpleComponent, OCComponent {
|
||||
public class TileEntityProxyCombo extends TileEntityProxyBase implements IEnergyReceiverMK2, ISidedInventory, IFluidReceiverMK2, IHeatSource, ICrucibleAcceptor, SimpleComponent, OCComponent, IRORValueProvider {
|
||||
|
||||
TileEntity tile;
|
||||
boolean inventory;
|
||||
@ -512,4 +514,16 @@ public class TileEntityProxyCombo extends TileEntityProxyBase implements IEnergy
|
||||
return ((OCComponent) this.getTile()).invoke(method, context, args);
|
||||
return OCComponent.super.invoke(null, null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getFunctionInfo() {
|
||||
if(getTile() instanceof IRORInfo) return ((IRORInfo) getTile()).getFunctionInfo();
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String provideRORValue(String name) {
|
||||
if(getTile() instanceof IRORValueProvider) return ((IRORValueProvider) getTile()).provideRORValue(name);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@ -429,6 +429,7 @@ public class TileMappings {
|
||||
put(TileEntityRadioTorchCounter.class, "tileentity_rtty_counter");
|
||||
put(TileEntityRadioTorchLogic.class, "tileentity_rtty_logic");
|
||||
put(TileEntityRadioTorchReader.class, "tileentity_rtty_reader");
|
||||
put(TileEntityRadioTorchController.class, "tileentity_rtty_controller");
|
||||
put(TileEntityRadioTelex.class, "tileentity_rtty_telex");
|
||||
|
||||
put(TileEntityDroneWaypoint.class, "tileentity_drone_waypoint");
|
||||
|
||||
@ -3,6 +3,7 @@ package com.hbm.tileentity.machine.storage;
|
||||
import api.hbm.energymk2.IEnergyReceiverMK2.ConnectionPriority;
|
||||
import api.hbm.fluidmk2.FluidNode;
|
||||
import api.hbm.fluidmk2.IFluidStandardTransceiverMK2;
|
||||
import api.hbm.redstoneoverradio.IRORInteractive;
|
||||
import api.hbm.redstoneoverradio.IRORValueProvider;
|
||||
|
||||
import java.util.HashSet;
|
||||
@ -46,7 +47,7 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
@Optional.InterfaceList({@Optional.Interface(iface = "li.cil.oc.api.network.SimpleComponent", modid = "opencomputers")})
|
||||
public class TileEntityBarrel extends TileEntityMachineBase implements SimpleComponent, IFluidStandardTransceiverMK2, IPersistentNBT, IGUIProvider, CompatHandler.OCComponent, IFluidCopiable, IRORValueProvider {
|
||||
public class TileEntityBarrel extends TileEntityMachineBase implements SimpleComponent, IFluidStandardTransceiverMK2, IPersistentNBT, IGUIProvider, CompatHandler.OCComponent, IFluidCopiable, IRORValueProvider, IRORInteractive {
|
||||
|
||||
protected FluidNode node;
|
||||
protected FluidType lastType;
|
||||
@ -408,6 +409,8 @@ public class TileEntityBarrel extends TileEntityMachineBase implements SimpleCom
|
||||
PREFIX_VALUE + "type",
|
||||
PREFIX_VALUE + "fill",
|
||||
PREFIX_VALUE + "fillpercent",
|
||||
PREFIX_FUNCTION + "setmode" + NAME_SEPARATOR + "mode",
|
||||
PREFIX_FUNCTION + "setmode" + NAME_SEPARATOR + "mode" + PARAM_SEPARATOR + "fallback",
|
||||
};
|
||||
}
|
||||
|
||||
@ -418,4 +421,25 @@ public class TileEntityBarrel extends TileEntityMachineBase implements SimpleCom
|
||||
if((PREFIX_VALUE + "fillpercent").equals(name)) return "" + (tank.getFill() * 100 / tank.getMaxFill());
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String runRORFunction(String name, String[] params) {
|
||||
|
||||
if((PREFIX_FUNCTION + "setmode").equals(name) && params.length > 0) {
|
||||
int mode = IRORInteractive.parseInt(params[0], 0, 3);
|
||||
|
||||
if(mode != this.mode) {
|
||||
this.mode = (short) mode;
|
||||
this.markChanged();
|
||||
return null;
|
||||
} else if(params.length > 1) {
|
||||
int altmode = IRORInteractive.parseInt(params[1], 0, 3);
|
||||
this.mode = (short) altmode;
|
||||
this.markChanged();
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@ package com.hbm.tileentity.machine.storage;
|
||||
import api.hbm.energymk2.IEnergyReceiverMK2.ConnectionPriority;
|
||||
import api.hbm.fluidmk2.FluidNode;
|
||||
import api.hbm.fluidmk2.IFluidStandardTransceiverMK2;
|
||||
import api.hbm.redstoneoverradio.IRORInteractive;
|
||||
import api.hbm.redstoneoverradio.IRORValueProvider;
|
||||
|
||||
import com.hbm.blocks.BlockDummyable;
|
||||
@ -55,7 +56,7 @@ import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
@Optional.InterfaceList({@Optional.Interface(iface = "li.cil.oc.api.network.SimpleComponent", modid = "opencomputers")})
|
||||
public class TileEntityMachineFluidTank extends TileEntityMachineBase implements SimpleComponent, OCComponent, IFluidStandardTransceiverMK2, IPersistentNBT, IOverpressurable, IGUIProvider, IRepairable, IFluidCopiable, IRORValueProvider {
|
||||
public class TileEntityMachineFluidTank extends TileEntityMachineBase implements SimpleComponent, OCComponent, IFluidStandardTransceiverMK2, IPersistentNBT, IOverpressurable, IGUIProvider, IRepairable, IFluidCopiable, IRORValueProvider, IRORInteractive {
|
||||
|
||||
protected FluidNode node;
|
||||
protected FluidType lastType;
|
||||
@ -537,14 +538,10 @@ public class TileEntityMachineFluidTank extends TileEntityMachineBase implements
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
public Object[] invoke(String method, Context context, Arguments args) throws Exception {
|
||||
switch (method) {
|
||||
case "getFluidStored":
|
||||
return getFluidStored(context, args);
|
||||
case "getMaxStored":
|
||||
return getMaxStored(context, args);
|
||||
case "getTypeStored":
|
||||
return getTypeStored(context, args);
|
||||
case "getInfo":
|
||||
return getInfo(context, args);
|
||||
case "getFluidStored": return getFluidStored(context, args);
|
||||
case "getMaxStored": return getMaxStored(context, args);
|
||||
case "getTypeStored": return getTypeStored(context, args);
|
||||
case "getInfo": return getInfo(context, args);
|
||||
}
|
||||
throw new NoSuchMethodException();
|
||||
}
|
||||
@ -555,14 +552,37 @@ public class TileEntityMachineFluidTank extends TileEntityMachineBase implements
|
||||
PREFIX_VALUE + "type",
|
||||
PREFIX_VALUE + "fill",
|
||||
PREFIX_VALUE + "fillpercent",
|
||||
PREFIX_FUNCTION + "setmode" + NAME_SEPARATOR + "mode",
|
||||
PREFIX_FUNCTION + "setmode" + NAME_SEPARATOR + "mode" + PARAM_SEPARATOR + "fallback",
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String provideRORValue(String name) {
|
||||
if("type".equals(name)) return tank.getTankType().getName();
|
||||
if("fill".equals(name)) return "" + tank.getFill();
|
||||
if("fillpercent".equals(name)) return "" + (tank.getFill() * 100 / tank.getMaxFill());
|
||||
if((PREFIX_VALUE + "type").equals(name)) return tank.getTankType().getName();
|
||||
if((PREFIX_VALUE + "fill").equals(name)) return "" + tank.getFill();
|
||||
if((PREFIX_VALUE + "fillpercent").equals(name)) return "" + (tank.getFill() * 100 / tank.getMaxFill());
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String runRORFunction(String name, String[] params) {
|
||||
|
||||
if((PREFIX_FUNCTION + "setmode").equals(name) && params.length > 0) {
|
||||
int mode = IRORInteractive.parseInt(params[0], 0, 3);
|
||||
|
||||
if(mode != this.mode) {
|
||||
this.mode = (short) mode;
|
||||
this.markChanged();
|
||||
return null;
|
||||
} else if(params.length > 1) {
|
||||
int altmode = IRORInteractive.parseInt(params[1], 0, 3);
|
||||
this.mode = (short) altmode;
|
||||
this.markChanged();
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,93 @@
|
||||
package com.hbm.tileentity.network;
|
||||
|
||||
import com.hbm.interfaces.IControlReceiver;
|
||||
import com.hbm.tileentity.TileEntityLoadedBase;
|
||||
import com.hbm.tileentity.network.RTTYSystem.RTTYChannel;
|
||||
import com.hbm.util.BufferUtil;
|
||||
import com.hbm.util.Compat;
|
||||
|
||||
import api.hbm.redstoneoverradio.IRORInteractive;
|
||||
import api.hbm.redstoneoverradio.RORFunctionException;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class TileEntityRadioTorchController extends TileEntityLoadedBase implements IControlReceiver {
|
||||
|
||||
public String channel;
|
||||
public String prev;
|
||||
public boolean polling = false;
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
|
||||
if(!worldObj.isRemote) {
|
||||
|
||||
if(channel != null && !channel.isEmpty()) {
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata()).getOpposite();
|
||||
|
||||
TileEntity tile = Compat.getTileStandard(worldObj, xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ);
|
||||
|
||||
if(tile instanceof IRORInteractive) {
|
||||
IRORInteractive ror = (IRORInteractive) tile;
|
||||
|
||||
RTTYChannel chan = RTTYSystem.listen(worldObj, channel);
|
||||
if(chan != null) {
|
||||
String rec = "" + chan.signal;
|
||||
if(this.polling || !rec.equals(prev)) {
|
||||
try {
|
||||
if(rec != null && !rec.isEmpty()) ror.runRORFunction(IRORInteractive.PREFIX_FUNCTION + IRORInteractive.getCommand(rec), IRORInteractive.getParams(rec));
|
||||
} catch(RORFunctionException ex) { }
|
||||
prev = rec;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
networkPackNT(50);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(ByteBuf buf) {
|
||||
buf.writeBoolean(this.polling);
|
||||
BufferUtil.writeString(buf, channel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuf buf) {
|
||||
this.polling = buf.readBoolean();
|
||||
channel = BufferUtil.readString(buf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
this.polling = nbt.getBoolean("p");
|
||||
channel = nbt.getString("c");
|
||||
this.prev = nbt.getString("prev");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
super.writeToNBT(nbt);
|
||||
nbt.setBoolean("p", polling);
|
||||
nbt.setString("c", channel);
|
||||
if(prev != null) nbt.setString("prev", prev);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receiveControl(NBTTagCompound data) {
|
||||
if(data.hasKey("p")) this.polling = data.getBoolean("p");
|
||||
if(data.hasKey("c")) channel = data.getString("c");
|
||||
|
||||
this.markDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(EntityPlayer player) {
|
||||
return player.getDistance(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5) < 16D;
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.1 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 12 KiB |
Loading…
x
Reference in New Issue
Block a user