diff --git a/mods/eln/Eln.java b/mods/eln/Eln.java index 79d73bcbd..249423edf 100644 --- a/mods/eln/Eln.java +++ b/mods/eln/Eln.java @@ -94,6 +94,7 @@ import mods.eln.sixnode.electricaldatalogger.ElectricalDataLoggerDescriptor; import mods.eln.sixnode.electricalentitysensor.ElectricalEntitySensorDescriptor; import mods.eln.sixnode.electricalgatesource.ElectricalGateSourceDescriptor; +import mods.eln.sixnode.electricalgatesource.ElectricalGateSourceRenderObj; import mods.eln.sixnode.electricallightsensor.ElectricalLightSensorDescriptor; import mods.eln.sixnode.electricalmath.ElectricalMathDescriptor; import mods.eln.sixnode.electricalredstoneinput.ElectricalRedstoneInputDescriptor; @@ -127,6 +128,7 @@ import mods.eln.sixnode.wirelesssignal.WirelessSignalAnalyserItemDescriptor; import mods.eln.sixnode.wirelesssignal.repeater.WirelessSignalRepeaterDescriptor; import mods.eln.sixnode.wirelesssignal.rx.WirelessSignalRxDescriptor; +import mods.eln.sixnode.wirelesssignal.source.WirelessSignalSourceDescriptor; import mods.eln.sixnode.wirelesssignal.tx.WirelessSignalTxDescriptor; import mods.eln.sixnode.wirelesssignal.tx.WirelessSignalTxElement; import mods.eln.solver.ConstSymbole; @@ -219,6 +221,7 @@ public class Eln { public static final String[] objNames = new String[] { "/model/condo200/condo200.obj", "/model/WallClock/WallClock.obj", + "/model/TutoPlate/TutoPlate.obj", "/model/relay800/relay800.obj", "/model/hub/hub.obj", "/model/electricalweathersensor/electricalweathersensor.obj", @@ -1593,7 +1596,7 @@ private void registerSixNodeMisc(int id) { name = "Tutorial sign"; TutorialSignDescriptor desc = new TutorialSignDescriptor( - name, obj.getObj("voltagesource")); + name, obj.getObj("TutoPlate")); sixNodeItem.addDescriptor(subId + (id << 6), desc); } } @@ -1916,14 +1919,16 @@ void registerElectricalRelay(int id) { void registerElectricalGateSource(int id) { int subId, completId; String name; - ElectricalGateSourceDescriptor desc; - + + ElectricalGateSourceRenderObj signalsourcepot = new ElectricalGateSourceRenderObj(obj.getObj("signalsourcepot")); + ElectricalGateSourceRenderObj ledswitch = new ElectricalGateSourceRenderObj(obj.getObj("ledswitch")); + { subId = 0; name = "Signal Trimmer"; - desc = new ElectricalGateSourceDescriptor(name, obj.getObj("signalsourcepot"), false); + ElectricalGateSourceDescriptor desc = new ElectricalGateSourceDescriptor(name, signalsourcepot, false); sixNodeItem.addDescriptor(subId + (id << 6), desc); } @@ -1932,7 +1937,7 @@ void registerElectricalGateSource(int id) { name = "Signal Switch"; - desc = new ElectricalGateSourceDescriptor(name, obj.getObj("ledswitch"), true); + ElectricalGateSourceDescriptor desc = new ElectricalGateSourceDescriptor(name, ledswitch, true); sixNodeItem.addDescriptor(subId + (id << 6), desc); } @@ -1941,10 +1946,26 @@ void registerElectricalGateSource(int id) { name = "Signal Button"; - desc = new ElectricalGateSourceDescriptor(name, obj.getObj("ledswitch"), true); + ElectricalGateSourceDescriptor desc = new ElectricalGateSourceDescriptor(name, ledswitch, true); desc.setWithAutoReset(); sixNodeItem.addDescriptor(subId + (id << 6), desc); } + { + subId = 12; + + name = "Wireless Button"; + + WirelessSignalSourceDescriptor desc = new WirelessSignalSourceDescriptor(name, ledswitch,wirelessTxRange, true); + sixNodeItem.addDescriptor(subId + (id << 6), desc); + } + { + subId = 16; + + name = "Wireless Switch"; + + WirelessSignalSourceDescriptor desc = new WirelessSignalSourceDescriptor(name, ledswitch,wirelessTxRange, false); + sixNodeItem.addDescriptor(subId + (id << 6), desc); + } } diff --git a/mods/eln/misc/Version.java b/mods/eln/misc/Version.java index cb2a447f9..7060f6bb0 100644 --- a/mods/eln/misc/Version.java +++ b/mods/eln/misc/Version.java @@ -14,13 +14,13 @@ public final class Version { public final static int MAJOR = 1; /** Minor version code. */ - public final static int MINOR = 5; + public final static int MINOR = 6; /** * Unique version code. Must be a String for annotations. Used to check if a * new version if available. Each update must increment this number. */ - public final static String REVISION = "10"; + public final static String REVISION = "11"; public final static String getVersionName() { return String.format("BETA-%d.%d r%s", MAJOR, MINOR, REVISION); diff --git a/mods/eln/sixnode/electricalgatesource/ElectricalGateSourceDescriptor.java b/mods/eln/sixnode/electricalgatesource/ElectricalGateSourceDescriptor.java index 32e59de39..1a03e85d6 100644 --- a/mods/eln/sixnode/electricalgatesource/ElectricalGateSourceDescriptor.java +++ b/mods/eln/sixnode/electricalgatesource/ElectricalGateSourceDescriptor.java @@ -29,48 +29,17 @@ public class ElectricalGateSourceDescriptor extends SixNodeDescriptor { - private Obj3DPart rot; - private Obj3DPart main; - private Obj3D obj; - private float rotAlphaOn, rotAlphaOff; + public boolean onOffOnly; - private Obj3DPart lever; - private Obj3DPart led; - private Obj3DPart halo; - public float speed; + public boolean autoReset = false; - - public ElectricalGateSourceDescriptor(String name, Obj3D obj, boolean onOffOnly) { - super(name, ElectricalGateSourceElement.class, ElectricalGateSourceRender.class); - this.obj = obj; - if(obj != null){ - main = obj.getPart("main"); - - if(obj.getString("type").equals("pot")) { - objType = ObjType.Pot; - rot = obj.getPart("rot"); - if(rot != null) { - rotAlphaOff = rot.getFloat("alphaOff"); - rotAlphaOn = rot.getFloat("alphaOn"); - speed = rot.getFloat("speed"); - } - } - - if(obj.getString("type").equals("button")) { - lever = obj.getPart("button"); - led = obj.getPart("led"); - halo = obj.getPart("halo"); - - objType = ObjType.Button; - if(lever != null) { - speed = lever.getFloat("speed"); - leverTx = lever.getFloat("tx"); - } - } - } - this.onOffOnly = onOffOnly; - } - + + public ElectricalGateSourceDescriptor(String name, ElectricalGateSourceRenderObj render, boolean onOffOnly) { + super(name, ElectricalGateSourceElement.class, ElectricalGateSourceRender.class); + this.render = render; + this.onOffOnly = onOffOnly; + } + @Override public void addInformation(ItemStack itemStack, EntityPlayer entityPlayer, List list, boolean par4) { @@ -78,79 +47,48 @@ public void addInformation(ItemStack itemStack, EntityPlayer entityPlayer, list.add("Provides signal voltage"); list.add("from user control"); } - - - public void setWithAutoReset(){ + + public void setWithAutoReset() { autoReset = true; } - - enum ObjType {Pot, Button}; + + enum ObjType { + Pot, Button + }; + ObjType objType; float leverTx; + ElectricalGateSourceRenderObj render; void draw(float factor, float distance, TileEntity e) { - switch (objType) { - case Button: - if(main != null)main.draw(); - - GL11.glTranslatef(leverTx * factor, 0f, 0f); - if(lever != null) lever.draw(); - - // if(factor < 0.5f) { - // GL11.glColor3f(234f / 255f, 80 / 255f, 0f); - UtilsClient.ledOnOffColor(factor > 0.5f); - UtilsClient.disableLight(); - if(led != null) led.draw(); - UtilsClient.enableBlend(); - - if(halo != null) { - if(e == null) - UtilsClient.drawLight(halo); - else { - Color c = UtilsClient.ledOnOffColorC(factor > 0.5f); - UtilsClient.drawHaloNoLightSetup(halo, c.getRed() / 255f, c.getGreen() / 255f, c.getBlue() / 255f, e, false); - } - } - - UtilsClient.disableBlend(); - UtilsClient.enableLight(); - // } - /* else { - if(led != null) led.draw(); - }*/ - - break; - case Pot: - if(main != null) main.draw(); - if(rot != null) rot.draw(factor * (rotAlphaOn - rotAlphaOff) + rotAlphaOff, 1f, 0f, 0f); - break; - } + render.draw(factor, distance, e); } - + @Override public void setParent(Item item, int damage) { super.setParent(item, damage); Data.addSignal(newItemStack()); } - + @Override public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) { return true; } - + @Override public boolean handleRenderType(ItemStack item, ItemRenderType type) { return true; } + @Override public boolean shouldUseRenderHelperEln(ItemRenderType type, ItemStack item, ItemRendererHelper helper) { - + return true; } @Override public void renderItem(ItemRenderType type, ItemStack item, Object... data) { GL11.glScalef(1.5f, 1.5f, 1.5f); - if(type == ItemRenderType.INVENTORY) GL11.glScalef(1.5f, 1.5f, 1.5f); + if (type == ItemRenderType.INVENTORY) GL11.glScalef(1.5f, 1.5f, 1.5f); draw(0f, 1f, null); } } diff --git a/mods/eln/sixnode/electricalgatesource/ElectricalGateSourceElement.java b/mods/eln/sixnode/electricalgatesource/ElectricalGateSourceElement.java index c5b0b15b2..5da98fabc 100644 --- a/mods/eln/sixnode/electricalgatesource/ElectricalGateSourceElement.java +++ b/mods/eln/sixnode/electricalgatesource/ElectricalGateSourceElement.java @@ -48,7 +48,8 @@ public ElectricalGateSourceElement(SixNode sixNode, Direction side, SixNodeDescr electricalComponentList.add(outputGateProcess); if (this.descriptor.autoReset) { - electricalProcessList.add(autoResetProcess = new AutoResetProcess()); + slowProcessList.add(autoResetProcess = new AutoResetProcess()); + autoResetProcess.reset(); } } diff --git a/mods/eln/sixnode/electricalgatesource/ElectricalGateSourceRender.java b/mods/eln/sixnode/electricalgatesource/ElectricalGateSourceRender.java index 27719362b..16bd7d816 100644 --- a/mods/eln/sixnode/electricalgatesource/ElectricalGateSourceRender.java +++ b/mods/eln/sixnode/electricalgatesource/ElectricalGateSourceRender.java @@ -35,7 +35,7 @@ public class ElectricalGateSourceRender extends SixNodeElementRender { public ElectricalGateSourceRender(SixNodeEntity tileEntity, Direction side, SixNodeDescriptor descriptor) { super(tileEntity, side, descriptor); this.descriptor = (ElectricalGateSourceDescriptor) descriptor; - interpolator = new RcInterpolator(this.descriptor.speed); + interpolator = new RcInterpolator(this.descriptor.render.speed); } LRDU front; diff --git a/mods/eln/sixnode/electricalgatesource/ElectricalGateSourceRenderObj.java b/mods/eln/sixnode/electricalgatesource/ElectricalGateSourceRenderObj.java new file mode 100644 index 000000000..45cd22293 --- /dev/null +++ b/mods/eln/sixnode/electricalgatesource/ElectricalGateSourceRenderObj.java @@ -0,0 +1,91 @@ +package mods.eln.sixnode.electricalgatesource; + +import java.awt.Color; + +import net.minecraft.tileentity.TileEntity; + +import org.lwjgl.opengl.GL11; + +import mods.eln.misc.Obj3D; +import mods.eln.misc.UtilsClient; +import mods.eln.misc.Obj3D.Obj3DPart; +import mods.eln.sixnode.electricalgatesource.ElectricalGateSourceDescriptor.ObjType; + +public class ElectricalGateSourceRenderObj { + + private Obj3DPart rot; + private Obj3DPart main; + private Obj3D obj; + private Obj3DPart lever; + private Obj3DPart led; + private Obj3DPart halo; + ObjType objType; + float leverTx; + + + private float rotAlphaOn, rotAlphaOff; + public float speed; + + public ElectricalGateSourceRenderObj(Obj3D obj) { + this.obj = obj; + if (obj != null) { + main = obj.getPart("main"); + + if (obj.getString("type").equals("pot")) { + objType = ObjType.Pot; + rot = obj.getPart("rot"); + if (rot != null) { + rotAlphaOff = rot.getFloat("alphaOff"); + rotAlphaOn = rot.getFloat("alphaOn"); + speed = rot.getFloat("speed"); + } + } + + if (obj.getString("type").equals("button")) { + lever = obj.getPart("button"); + led = obj.getPart("led"); + halo = obj.getPart("halo"); + + objType = ObjType.Button; + if (lever != null) { + speed = lever.getFloat("speed"); + leverTx = lever.getFloat("tx"); + } + } + } + } + + + public void draw(float factor, float distance, TileEntity e) { + switch (objType) { + case Button: + if (main != null) main.draw(); + + GL11.glTranslatef(leverTx * factor, 0f, 0f); + if (lever != null) lever.draw(); + + UtilsClient.ledOnOffColor(factor > 0.5f); + UtilsClient.disableLight(); + if (led != null) led.draw(); + UtilsClient.enableBlend(); + + if (halo != null) { + if (e == null) + UtilsClient.drawLight(halo); + else { + Color c = UtilsClient.ledOnOffColorC(factor > 0.5f); + UtilsClient.drawHaloNoLightSetup(halo, c.getRed() / 255f, c.getGreen() / 255f, c.getBlue() / 255f, e, false); + } + } + + UtilsClient.disableBlend(); + UtilsClient.enableLight(); + + break; + case Pot: + if (main != null) main.draw(); + if (rot != null) rot.draw(factor * (rotAlphaOn - rotAlphaOff) + rotAlphaOff, 1f, 0f, 0f); + break; + } + } +} diff --git a/mods/eln/sixnode/electricaltimeout/ElectricalTimeoutDescriptor.java b/mods/eln/sixnode/electricaltimeout/ElectricalTimeoutDescriptor.java index e0f8f6743..db24761b8 100644 --- a/mods/eln/sixnode/electricaltimeout/ElectricalTimeoutDescriptor.java +++ b/mods/eln/sixnode/electricaltimeout/ElectricalTimeoutDescriptor.java @@ -87,7 +87,6 @@ public boolean shouldUseRenderHelperEln(ItemRenderType type, ItemStack item, Ite public void renderItem(ItemRenderType type, ItemStack item, Object... data) { if(type == ItemRenderType.INVENTORY) { GL11.glScalef(2.2f, 2.2f, 2.2f); - //GL11.glTranslatef(-0.1f, 0.0f, 0f); } draw(1f); } diff --git a/mods/eln/sixnode/modbusrtu/ModbusRtuElement.java b/mods/eln/sixnode/modbusrtu/ModbusRtuElement.java index d39f596d9..4f590813b 100644 --- a/mods/eln/sixnode/modbusrtu/ModbusRtuElement.java +++ b/mods/eln/sixnode/modbusrtu/ModbusRtuElement.java @@ -22,8 +22,8 @@ import mods.eln.sim.nbt.NbtElectricalGateInputOutput; import mods.eln.sim.nbt.NbtElectricalGateOutputProcess; import mods.eln.sixnode.wirelesssignal.IWirelessSignalSpot; +import mods.eln.sixnode.wirelesssignal.IWirelessSignalTx; import mods.eln.sixnode.wirelesssignal.WirelessUtils; -import mods.eln.sixnode.wirelesssignal.tx.IWirelessSignalTx; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.nbt.NBTTagCompound; diff --git a/mods/eln/sixnode/modbusrtu/ServerWirelessRxStatus.java b/mods/eln/sixnode/modbusrtu/ServerWirelessRxStatus.java index 2c149f3da..c1c5bae00 100644 --- a/mods/eln/sixnode/modbusrtu/ServerWirelessRxStatus.java +++ b/mods/eln/sixnode/modbusrtu/ServerWirelessRxStatus.java @@ -5,8 +5,8 @@ import com.google.common.base.CaseFormat; import mods.eln.misc.Utils; +import mods.eln.sixnode.wirelesssignal.IWirelessSignalTx; import mods.eln.sixnode.wirelesssignal.aggregator.BiggerAggregator; -import mods.eln.sixnode.wirelesssignal.tx.IWirelessSignalTx; import mods.eln.sixnode.wirelesssignal.tx.WirelessSignalTxElement; public class ServerWirelessRxStatus extends WirelessRxStatus implements IModbusSlot{ diff --git a/mods/eln/sixnode/modbusrtu/ServerWirelessTxStatus.java b/mods/eln/sixnode/modbusrtu/ServerWirelessTxStatus.java index 72c6df9ad..d7683295e 100644 --- a/mods/eln/sixnode/modbusrtu/ServerWirelessTxStatus.java +++ b/mods/eln/sixnode/modbusrtu/ServerWirelessTxStatus.java @@ -4,7 +4,7 @@ import mods.eln.Eln; import mods.eln.misc.Coordonate; import mods.eln.misc.Utils; -import mods.eln.sixnode.wirelesssignal.tx.IWirelessSignalTx; +import mods.eln.sixnode.wirelesssignal.IWirelessSignalTx; import mods.eln.sixnode.wirelesssignal.tx.WirelessSignalTxElement; public class ServerWirelessTxStatus extends WirelessTxStatus implements IWirelessSignalTx,IModbusSlot{ diff --git a/mods/eln/sixnode/modbusrtu/WirelessTxStatus.java b/mods/eln/sixnode/modbusrtu/WirelessTxStatus.java index 362be9f13..f323e4eed 100644 --- a/mods/eln/sixnode/modbusrtu/WirelessTxStatus.java +++ b/mods/eln/sixnode/modbusrtu/WirelessTxStatus.java @@ -8,7 +8,7 @@ import mods.eln.Eln; import mods.eln.misc.Coordonate; import mods.eln.misc.INBTTReady; -import mods.eln.sixnode.wirelesssignal.tx.IWirelessSignalTx; +import mods.eln.sixnode.wirelesssignal.IWirelessSignalTx; public class WirelessTxStatus implements INBTTReady{ WirelessTxStatus(){ diff --git a/mods/eln/sixnode/tutorialsign/TutorialSignDescriptor.java b/mods/eln/sixnode/tutorialsign/TutorialSignDescriptor.java index 453825782..686391a87 100644 --- a/mods/eln/sixnode/tutorialsign/TutorialSignDescriptor.java +++ b/mods/eln/sixnode/tutorialsign/TutorialSignDescriptor.java @@ -2,27 +2,87 @@ import java.util.List; +import org.lwjgl.opengl.GL11; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; +import net.minecraftforge.client.IItemRenderer.ItemRenderType; +import net.minecraftforge.client.IItemRenderer.ItemRendererHelper; import mods.eln.misc.Obj3D; +import mods.eln.misc.UtilsClient; import mods.eln.misc.Obj3D.Obj3DPart; import mods.eln.node.six.SixNodeDescriptor; public class TutorialSignDescriptor extends SixNodeDescriptor { private Obj3D obj; - private Obj3DPart main; + private Obj3DPart main,light,halo; public TutorialSignDescriptor(String name, Obj3D obj) { super(name, TutorialSignElement.class, TutorialSignRender.class); this.obj = obj; if(obj != null) { main = obj.getPart("main"); + light = obj.getPart("light"); + halo = obj.getPart("halo"); + + } + } + + void setupColor(float factor,float alpha){ + if(factor < 0.5){ + factor *= 2; + float factorN = 1f-factor; + GL11.glColor4f(0, 0, 0.4f * factorN ,alpha); + }else{ + factor = (factor - 0.5f)*2; + float factorN = 1f-factor; + GL11.glColor4f(0, 1 * factor, 0 ,alpha); } } - void draw() { + void draw(float factor) { + //GL11.glColor3f(0.8f, 0.8f, 0.8f); if(main != null) main.draw(); + UtilsClient.disableLight(); + + setupColor(factor,1); + if(light != null){ + light.draw(); + } + + UtilsClient.enableBlend(); + setupColor(factor,0.4f); + if(halo != null) halo.draw(); + + UtilsClient.disableBlend(); + UtilsClient.enableLight(); + GL11.glColor3f(1f, 1f, 1f); + } + + + + @Override + public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) { + return true; + } + + @Override + public boolean handleRenderType(ItemStack item, ItemRenderType type) { + return true; + } + @Override + public boolean shouldUseRenderHelperEln(ItemRenderType type, ItemStack item, ItemRendererHelper helper) { + + return true; + } + + @Override + public void renderItem(ItemRenderType type, ItemStack item, Object... data) { + /*if(type == ItemRenderType.INVENTORY) { + GL11.glScalef(2.2f, 2.2f, 2.2f); + }*/ + draw(1f); } @Override @@ -30,4 +90,7 @@ public void addInformation(ItemStack itemStack, EntityPlayer entityPlayer, List super.addInformation(itemStack, entityPlayer, list, par4); //list.add(""); } + + + } diff --git a/mods/eln/sixnode/tutorialsign/TutorialSignElement.java b/mods/eln/sixnode/tutorialsign/TutorialSignElement.java index 09ccbb736..b6fafff59 100644 --- a/mods/eln/sixnode/tutorialsign/TutorialSignElement.java +++ b/mods/eln/sixnode/tutorialsign/TutorialSignElement.java @@ -90,7 +90,7 @@ public static String getText(String balise){ } } String text = baliseMap.get(balise); - if(text == null) return "No balise found"; + if(text == null) return "No assosiated text to this beacon"; return text; } diff --git a/mods/eln/sixnode/tutorialsign/TutorialSignOverlay.java b/mods/eln/sixnode/tutorialsign/TutorialSignOverlay.java index 492fd31e9..86876bc3d 100644 --- a/mods/eln/sixnode/tutorialsign/TutorialSignOverlay.java +++ b/mods/eln/sixnode/tutorialsign/TutorialSignOverlay.java @@ -20,10 +20,18 @@ public TutorialSignOverlay() { int i = 0; i++; } + + TutorialSignRender oldRender = null; @SubscribeEvent public void render(RenderGameOverlayEvent.Text event) { Minecraft mc = Minecraft.getMinecraft(); EntityClientPlayerMP player = mc.thePlayer; + + if(oldRender != null){ + oldRender.lightInterpol.setTarget(0); + oldRender = null; + } + int px = MathHelper.floor_double(player.posX),py = MathHelper.floor_double(player.posY),pz = MathHelper.floor_double(player.posZ); int r = 1; World w = player.worldObj; @@ -56,6 +64,8 @@ public void render(RenderGameOverlayEvent.Text event) { if(best != null){ + oldRender = best; + oldRender.lightInterpol.setTarget(1f); GL11.glPushMatrix(); GL11.glScalef(0.5f, 0.5f, 0.5f); int y = 0; diff --git a/mods/eln/sixnode/tutorialsign/TutorialSignRender.java b/mods/eln/sixnode/tutorialsign/TutorialSignRender.java index e70470dd0..ffe8da620 100644 --- a/mods/eln/sixnode/tutorialsign/TutorialSignRender.java +++ b/mods/eln/sixnode/tutorialsign/TutorialSignRender.java @@ -4,6 +4,7 @@ import java.io.IOException; import mods.eln.misc.Direction; +import mods.eln.misc.RcInterpolator; import mods.eln.node.six.SixNodeDescriptor; import mods.eln.node.six.SixNodeElementRender; import mods.eln.node.six.SixNodeEntity; @@ -24,19 +25,19 @@ public TutorialSignRender(SixNodeEntity tileEntity, Direction side, SixNodeDescr String baliseName; String texts[]; + RcInterpolator lightInterpol = new RcInterpolator(0.6f); + @Override public void draw() { super.draw(); - descriptor.draw(); - /* - GL11.glPushMatrix(); - - GL11.glTranslatef(0.5f, 0f, 0f); - GL11.glRotatef(90, 0, 0, 1); - float scale = 1/64f; - GL11.glScalef(scale, scale, scale); - Minecraft.getMinecraft().fontRenderer.drawString(text,0,0,0); - GL11.glPopMatrix();*/ + descriptor.draw(lightInterpol.get()); + + } + + @Override + public void refresh(float deltaT) { + lightInterpol.step(deltaT); + super.refresh(deltaT); } @Override diff --git a/mods/eln/sixnode/wirelesssignal/IWirelessSignalSpot.java b/mods/eln/sixnode/wirelesssignal/IWirelessSignalSpot.java index c5a5ec723..0c534043a 100644 --- a/mods/eln/sixnode/wirelesssignal/IWirelessSignalSpot.java +++ b/mods/eln/sixnode/wirelesssignal/IWirelessSignalSpot.java @@ -4,7 +4,6 @@ import java.util.HashMap; import mods.eln.misc.Coordonate; -import mods.eln.sixnode.wirelesssignal.tx.IWirelessSignalTx; public interface IWirelessSignalSpot { public static ArrayList spots = new ArrayList(); diff --git a/mods/eln/sixnode/wirelesssignal/tx/IWirelessSignalTx.java b/mods/eln/sixnode/wirelesssignal/IWirelessSignalTx.java similarity index 81% rename from mods/eln/sixnode/wirelesssignal/tx/IWirelessSignalTx.java rename to mods/eln/sixnode/wirelesssignal/IWirelessSignalTx.java index b62cf4890..94e45e763 100644 --- a/mods/eln/sixnode/wirelesssignal/tx/IWirelessSignalTx.java +++ b/mods/eln/sixnode/wirelesssignal/IWirelessSignalTx.java @@ -1,4 +1,4 @@ -package mods.eln.sixnode.wirelesssignal.tx; +package mods.eln.sixnode.wirelesssignal; import mods.eln.misc.Coordonate; diff --git a/mods/eln/sixnode/wirelesssignal/WirelessSignalAnalyserItemDescriptor.java b/mods/eln/sixnode/wirelesssignal/WirelessSignalAnalyserItemDescriptor.java index e571a6e73..b0b12c257 100644 --- a/mods/eln/sixnode/wirelesssignal/WirelessSignalAnalyserItemDescriptor.java +++ b/mods/eln/sixnode/wirelesssignal/WirelessSignalAnalyserItemDescriptor.java @@ -12,7 +12,6 @@ import mods.eln.misc.Utils; import mods.eln.sixnode.wirelesssignal.WirelessUtils.WirelessSignalSpot; import mods.eln.sixnode.wirelesssignal.aggregator.BiggerAggregator; -import mods.eln.sixnode.wirelesssignal.tx.IWirelessSignalTx; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.world.World; diff --git a/mods/eln/sixnode/wirelesssignal/WirelessUtils.java b/mods/eln/sixnode/wirelesssignal/WirelessUtils.java index 0fceecef6..be9f57291 100644 --- a/mods/eln/sixnode/wirelesssignal/WirelessUtils.java +++ b/mods/eln/sixnode/wirelesssignal/WirelessUtils.java @@ -8,7 +8,6 @@ import java.util.Map.Entry; import mods.eln.misc.Coordonate; -import mods.eln.sixnode.wirelesssignal.tx.IWirelessSignalTx; import mods.eln.sixnode.wirelesssignal.tx.WirelessSignalTxElement; import net.minecraft.block.Block; import net.minecraft.init.Blocks; diff --git a/mods/eln/sixnode/wirelesssignal/aggregator/BiggerAggregator.java b/mods/eln/sixnode/wirelesssignal/aggregator/BiggerAggregator.java index cba20a7fb..4c2a11358 100644 --- a/mods/eln/sixnode/wirelesssignal/aggregator/BiggerAggregator.java +++ b/mods/eln/sixnode/wirelesssignal/aggregator/BiggerAggregator.java @@ -2,7 +2,7 @@ import java.util.Collection; -import mods.eln.sixnode.wirelesssignal.tx.IWirelessSignalTx; +import mods.eln.sixnode.wirelesssignal.IWirelessSignalTx; public class BiggerAggregator implements IWirelessSignalAggregator{ diff --git a/mods/eln/sixnode/wirelesssignal/aggregator/IWirelessSignalAggregator.java b/mods/eln/sixnode/wirelesssignal/aggregator/IWirelessSignalAggregator.java index f2876300c..295877d97 100644 --- a/mods/eln/sixnode/wirelesssignal/aggregator/IWirelessSignalAggregator.java +++ b/mods/eln/sixnode/wirelesssignal/aggregator/IWirelessSignalAggregator.java @@ -2,7 +2,7 @@ import java.util.Collection; -import mods.eln.sixnode.wirelesssignal.tx.IWirelessSignalTx; +import mods.eln.sixnode.wirelesssignal.IWirelessSignalTx; public interface IWirelessSignalAggregator { double aggregate(Collection txs); diff --git a/mods/eln/sixnode/wirelesssignal/aggregator/SmallerAggregator.java b/mods/eln/sixnode/wirelesssignal/aggregator/SmallerAggregator.java index a2b71e3cc..f8276e7cd 100644 --- a/mods/eln/sixnode/wirelesssignal/aggregator/SmallerAggregator.java +++ b/mods/eln/sixnode/wirelesssignal/aggregator/SmallerAggregator.java @@ -2,7 +2,7 @@ import java.util.Collection; -import mods.eln.sixnode.wirelesssignal.tx.IWirelessSignalTx; +import mods.eln.sixnode.wirelesssignal.IWirelessSignalTx; public class SmallerAggregator implements IWirelessSignalAggregator{ diff --git a/mods/eln/sixnode/wirelesssignal/aggregator/ToogleAggregator.java b/mods/eln/sixnode/wirelesssignal/aggregator/ToogleAggregator.java index 46e117bc1..5237fee8e 100644 --- a/mods/eln/sixnode/wirelesssignal/aggregator/ToogleAggregator.java +++ b/mods/eln/sixnode/wirelesssignal/aggregator/ToogleAggregator.java @@ -5,7 +5,7 @@ import net.minecraft.nbt.NBTTagCompound; import mods.eln.misc.INBTTReady; -import mods.eln.sixnode.wirelesssignal.tx.IWirelessSignalTx; +import mods.eln.sixnode.wirelesssignal.IWirelessSignalTx; public class ToogleAggregator extends BiggerAggregator implements INBTTReady{ diff --git a/mods/eln/sixnode/wirelesssignal/repeater/WirelessSignalRepeaterProcess.java b/mods/eln/sixnode/wirelesssignal/repeater/WirelessSignalRepeaterProcess.java index c1e3ec21e..bea8d9565 100644 --- a/mods/eln/sixnode/wirelesssignal/repeater/WirelessSignalRepeaterProcess.java +++ b/mods/eln/sixnode/wirelesssignal/repeater/WirelessSignalRepeaterProcess.java @@ -14,9 +14,9 @@ import mods.eln.misc.Utils; import mods.eln.sim.IProcess; import mods.eln.sixnode.wirelesssignal.IWirelessSignalSpot; +import mods.eln.sixnode.wirelesssignal.IWirelessSignalTx; import mods.eln.sixnode.wirelesssignal.WirelessUtils; import mods.eln.sixnode.wirelesssignal.aggregator.IWirelessSignalAggregator; -import mods.eln.sixnode.wirelesssignal.tx.IWirelessSignalTx; public class WirelessSignalRepeaterProcess implements IProcess,IWirelessSignalSpot{ diff --git a/mods/eln/sixnode/wirelesssignal/rx/WirelessSignalRxGui.java b/mods/eln/sixnode/wirelesssignal/rx/WirelessSignalRxGui.java index c0aea7cc5..093d12d7b 100644 --- a/mods/eln/sixnode/wirelesssignal/rx/WirelessSignalRxGui.java +++ b/mods/eln/sixnode/wirelesssignal/rx/WirelessSignalRxGui.java @@ -53,7 +53,7 @@ public void initGui() { int y = 6+12+4; add(buttonBigger = new AggregatorBt(x,y,w,20,"Biggest",(byte) 0)); x += 2+w; add(buttonSmaller = new AggregatorBt(x,y,w,20,"Smallest",(byte) 1)); x += 2+w; - add(buttonToogle = new AggregatorBt(x,y,w,20,"Event",(byte) 2)); x += 2+w; + add(buttonToogle = new AggregatorBt(x,y,w,20,"Toggle",(byte) 2)); x += 2+w; buttonBigger.setHelper(helper); diff --git a/mods/eln/sixnode/wirelesssignal/rx/WirelessSignalRxProcess.java b/mods/eln/sixnode/wirelesssignal/rx/WirelessSignalRxProcess.java index 28b485535..7c828342f 100644 --- a/mods/eln/sixnode/wirelesssignal/rx/WirelessSignalRxProcess.java +++ b/mods/eln/sixnode/wirelesssignal/rx/WirelessSignalRxProcess.java @@ -7,9 +7,9 @@ import mods.eln.misc.Utils; import mods.eln.sim.IProcess; import mods.eln.sixnode.wirelesssignal.IWirelessSignalSpot; +import mods.eln.sixnode.wirelesssignal.IWirelessSignalTx; import mods.eln.sixnode.wirelesssignal.WirelessUtils; import mods.eln.sixnode.wirelesssignal.aggregator.IWirelessSignalAggregator; -import mods.eln.sixnode.wirelesssignal.tx.IWirelessSignalTx; import net.minecraft.nbt.NBTTagCompound; public class WirelessSignalRxProcess implements IProcess,INBTTReady{ diff --git a/mods/eln/sixnode/wirelesssignal/source/WirelessSignalSourceDescriptor.java b/mods/eln/sixnode/wirelesssignal/source/WirelessSignalSourceDescriptor.java new file mode 100644 index 000000000..c3c4a08aa --- /dev/null +++ b/mods/eln/sixnode/wirelesssignal/source/WirelessSignalSourceDescriptor.java @@ -0,0 +1,66 @@ +package mods.eln.sixnode.wirelesssignal.source; + +import mods.eln.node.six.SixNodeDescriptor; +import mods.eln.sixnode.electricalgatesource.ElectricalGateSourceRenderObj; +import mods.eln.wiki.Data; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.client.IItemRenderer.ItemRenderType; + +import org.lwjgl.opengl.GL11; + +public class WirelessSignalSourceDescriptor extends SixNodeDescriptor{ + + + public WirelessSignalSourceDescriptor( + String name, + ElectricalGateSourceRenderObj render, + int range,boolean autoReset + ) { + super(name, WirelessSignalSourceElement.class, WirelessSignalSourceRender.class); + this.range = range; + this.autoReset = autoReset; + this.render = render; + + } + int range; + public boolean autoReset; + ElectricalGateSourceRenderObj render; + + void draw(float factor, float distance, TileEntity e) { + render.draw(factor, distance, e); + } + + + @Override + public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, + ItemRendererHelper helper) { + + return true; + } + @Override + public void setParent(Item item, int damage) { + + super.setParent(item, damage); + Data.addSignal(newItemStack()); + } + @Override + public boolean handleRenderType(ItemStack item, ItemRenderType type) { + + return true; + } + @Override + public boolean shouldUseRenderHelperEln(ItemRenderType type, ItemStack item, ItemRendererHelper helper) { + + return true; + } + + @Override + public void renderItem(ItemRenderType type, ItemStack item, Object... data) { + GL11.glScalef(1.5f, 1.5f, 1.5f); + if (type == ItemRenderType.INVENTORY) GL11.glScalef(1.5f, 1.5f, 1.5f); + draw(0f, 1f, null); + } + +} diff --git a/mods/eln/sixnode/wirelesssignal/source/WirelessSignalSourceElement.java b/mods/eln/sixnode/wirelesssignal/source/WirelessSignalSourceElement.java new file mode 100644 index 000000000..2eac09b8b --- /dev/null +++ b/mods/eln/sixnode/wirelesssignal/source/WirelessSignalSourceElement.java @@ -0,0 +1,222 @@ +package mods.eln.sixnode.wirelesssignal.source; + +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; + +import mods.eln.misc.Coordonate; +import mods.eln.misc.Direction; +import mods.eln.misc.LRDU; +import mods.eln.misc.Utils; +import mods.eln.node.six.SixNode; +import mods.eln.node.six.SixNodeDescriptor; +import mods.eln.node.six.SixNodeElement; +import mods.eln.sim.ElectricalLoad; +import mods.eln.sim.IProcess; +import mods.eln.sim.ThermalLoad; +import mods.eln.sixnode.wirelesssignal.IWirelessSignalTx; +import mods.eln.sixnode.wirelesssignal.tx.WirelessSignalTxElement; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.nbt.NBTTagCompound; + +public class WirelessSignalSourceElement extends SixNodeElement implements IWirelessSignalTx{ + + + + + public static HashMap> channelMap = new HashMap>(); + + + WirelessSignalSourceDescriptor descriptor; + + public AutoResetProcess autoResetProcess; + boolean state = false; + + public String channel = "Default channel"; + + public WirelessSignalSourceElement(SixNode sixNode, Direction side, + SixNodeDescriptor descriptor) { + super(sixNode, side, descriptor); + + front = LRDU.Down; + this.descriptor = (WirelessSignalSourceDescriptor) descriptor; + WirelessSignalTxElement.channelRegister(this); + + if (this.descriptor.autoReset) { + slowProcessList.add(autoResetProcess = new AutoResetProcess()); + autoResetProcess.reset(); + } + } + class AutoResetProcess implements IProcess { + double timeout = 0; + double timeoutDelay = 0.21; + + @Override + public void process(double time) { + if (timeout > 0) { + if (timeout - time < 0) { + if(state){ + state = false; + needPublish(); + } + } + timeout -= time; + } + } + + void reset(){ + timeout = timeoutDelay; + } + } + + + + + @Override + public ElectricalLoad getElectricalLoad(LRDU lrdu) { + + return null; + } + + @Override + public ThermalLoad getThermalLoad(LRDU lrdu) { + + return null; + } + + @Override + public int getConnectionMask(LRDU lrdu) { + return 0; + } + + @Override + public String multiMeterString() { + return null; + } + + @Override + public String thermoMeterString() { + + return null; + } + + @Override + public void initialize() { + + + } + + @Override + public boolean onBlockActivated(EntityPlayer entityPlayer, Direction side, + float vx, float vy, float vz) { + if(Utils.isPlayerUsingWrench(entityPlayer)) + return false; + + state = ! state; + if(state && autoResetProcess != null) autoResetProcess.reset(); + needPublish(); + return true; + } + + + + @Override + public void destroy(EntityPlayerMP entityPlayer) { + WirelessSignalTxElement.channelRemove(this); + super.destroy(entityPlayer); + } + + + @Override + public void writeToNBT(NBTTagCompound nbt) { + + super.writeToNBT(nbt); + nbt.setString("channel", channel); + nbt.setBoolean("state", state); + } + @Override + public void readFromNBT(NBTTagCompound nbt) { + + WirelessSignalTxElement.channelRemove(this); + + super.readFromNBT(nbt); + channel = nbt.getString("channel"); + state = nbt.getBoolean("state"); + + + WirelessSignalTxElement.channelRegister(this); + + } + + @Override + public Coordonate getCoordonate() { + + return sixNode.coordonate; + } + + @Override + public int getRange() { + + return descriptor.range; + } + + @Override + public String getChannel() { + + return channel; + } + + + @Override + public double getValue() { + + return state ? 1.0 : 0.0; + } + + + + public static final byte setChannelId = 1; + @Override + public void networkUnserialize(DataInputStream stream) { + + super.networkUnserialize(stream); + + try { + switch(stream.readByte()){ + case setChannelId: + WirelessSignalTxElement.channelRemove(this); + channel = stream.readUTF(); + needPublish(); + WirelessSignalTxElement.channelRegister(this); + break; + } + } catch (IOException e) { + + e.printStackTrace(); + } + } + + @Override + public boolean hasGui() { + + return true; + } + + + + @Override + public void networkSerialize(DataOutputStream stream) { + + super.networkSerialize(stream); + try { + stream.writeUTF(channel); + stream.writeBoolean(state); + } catch (IOException e) { + + e.printStackTrace(); + } + } +} diff --git a/mods/eln/sixnode/wirelesssignal/source/WirelessSignalSourceGui.java b/mods/eln/sixnode/wirelesssignal/source/WirelessSignalSourceGui.java new file mode 100644 index 000000000..d270d2861 --- /dev/null +++ b/mods/eln/sixnode/wirelesssignal/source/WirelessSignalSourceGui.java @@ -0,0 +1,42 @@ +package mods.eln.sixnode.wirelesssignal.source; + +import mods.eln.gui.GuiHelper; +import mods.eln.gui.GuiScreenEln; +import mods.eln.gui.GuiTextFieldEln; +import mods.eln.gui.IGuiObject; + +public class WirelessSignalSourceGui extends GuiScreenEln{ + + GuiTextFieldEln channel; + private WirelessSignalSourceRender render; + + + public WirelessSignalSourceGui(WirelessSignalSourceRender render) { + this.render = render; + } + + @Override + public void initGui() { + + super.initGui(); + channel = newGuiTextField(6, 6, 220); + channel.setText(render.channel); + channel.setComment(0, "Specify the channel"); + } + + @Override + protected GuiHelper newHelper() { + + return new GuiHelper(this, 220+12, 12+12); + } + + + @Override + public void guiObjectEvent(IGuiObject object) { + if(object == channel){ + render.clientSetString(WirelessSignalSourceElement.setChannelId,channel.getText()); + } + super.guiObjectEvent(object); + } + +} diff --git a/mods/eln/sixnode/wirelesssignal/source/WirelessSignalSourceRender.java b/mods/eln/sixnode/wirelesssignal/source/WirelessSignalSourceRender.java new file mode 100644 index 000000000..0e034b7df --- /dev/null +++ b/mods/eln/sixnode/wirelesssignal/source/WirelessSignalSourceRender.java @@ -0,0 +1,84 @@ +package mods.eln.sixnode.wirelesssignal.source; + +import ibxm.Channel; + +import java.io.DataInputStream; +import java.io.IOException; + +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.entity.player.EntityPlayer; +import mods.eln.Eln; +import mods.eln.cable.CableRenderDescriptor; +import mods.eln.misc.Direction; +import mods.eln.misc.LRDU; +import mods.eln.misc.RcInterpolator; +import mods.eln.misc.UtilsClient; +import mods.eln.node.six.SixNodeDescriptor; +import mods.eln.node.six.SixNodeElementRender; +import mods.eln.node.six.SixNodeEntity; + +public class WirelessSignalSourceRender extends SixNodeElementRender{ + + + WirelessSignalSourceDescriptor descriptor; + public WirelessSignalSourceRender(SixNodeEntity tileEntity, Direction side, + SixNodeDescriptor descriptor) { + super(tileEntity, side, descriptor); + this.descriptor = (WirelessSignalSourceDescriptor) descriptor; + + interpolator = new RcInterpolator(this.descriptor.render.speed); + } + + + + RcInterpolator interpolator; + + @Override + public void draw() { + + super.draw(); + LRDU.Down.glRotateOnX(); + descriptor.draw(interpolator.get(), UtilsClient.distanceFromClientPlayer(this.tileEntity), tileEntity); + } + + @Override + public void refresh(float deltaT) { + interpolator.setTarget((float) ((state ? 1 : 0))); + interpolator.step(deltaT); + } + + @Override + public CableRenderDescriptor getCableRender(LRDU lrdu) { + + return Eln.instance.signalCableDescriptor.render; + } + + + + @Override + public GuiScreen newGuiDraw(Direction side, EntityPlayer player) { + + return new WirelessSignalSourceGui(this); + } + + String channel; + boolean state = false; + @Override + public void publishUnserialize(DataInputStream stream) { + + super.publishUnserialize(stream); + try { + channel = stream.readUTF(); + state = stream.readBoolean(); + } catch (IOException e) { + + e.printStackTrace(); + } + } + + + + + + +} diff --git a/mods/eln/sixnode/wirelesssignal/tx/WirelessSignalTxElement.java b/mods/eln/sixnode/wirelesssignal/tx/WirelessSignalTxElement.java index e2c5e1970..f69734cd0 100644 --- a/mods/eln/sixnode/wirelesssignal/tx/WirelessSignalTxElement.java +++ b/mods/eln/sixnode/wirelesssignal/tx/WirelessSignalTxElement.java @@ -22,6 +22,7 @@ import mods.eln.sim.ElectricalLoad; import mods.eln.sim.ThermalLoad; import mods.eln.sim.nbt.NbtElectricalGateInput; +import mods.eln.sixnode.wirelesssignal.IWirelessSignalTx; public class WirelessSignalTxElement extends SixNodeElement implements IWirelessSignalTx{ @@ -34,77 +35,7 @@ public class WirelessSignalTxElement extends SixNodeElement implements IWireless WirelessSignalTxDescriptor descriptor; -/* - public static IWirelessSignalTx getBestTx(String channel,Coordonate rxCoordonate){ - IWirelessSignalTx bestTx = null; - float bestPower = -1f; - int bestGeneration = 1000; - Coordonate rxC = rxCoordonate; - - ArrayList txList = WirelessSignalTxElement.channelMap.get(channel); - if(txList != null) { - int x = rxC.x; - int y = rxC.y; - int z = rxC.z; - for(IWirelessSignalTx tx : txList){ - Coordonate txC = tx.getCoordonate(); - double distance = txC.trueDistanceTo(rxC); - - if(txC.dimention == rxC.dimention && distance <= tx.getRange() && tx.getGeneration() < 100){ - float power = 0f; - if(Double.isNaN(distance = getVirtualDistance(distance, txC, rxC))) continue; - power = (float) (tx.getRange() - distance); - - if(power < -0.1) continue; - - - if(tx.getGeneration() < bestGeneration || (tx.getGeneration() == bestGeneration && power > bestPower)){ - bestPower = power; - bestTx = tx; - bestGeneration = tx.getGeneration(); - } - } - } - } - - return bestTx; - }*/ - - - static public double getVirtualDistance(double distance,Coordonate txC,Coordonate rxC) - { - double virtualDistance = distance; - if(distance > 2){ - double vx,vy,vz; - double dx,dy,dz; - vx = rxC.x + 0.5; - vy = rxC.y + 0.5; - vz = rxC.z + 0.5; - - dx = (txC.x - rxC.x)/distance; - dy = (txC.y - rxC.y)/distance; - dz = (txC.z - rxC.z)/distance; - Coordonate c = new Coordonate(); - c.setDimention(rxC.dimention); - - for(int idx = 0;idx < distance - 1;idx++){ - vx += dx; - vy += dy; - vz += dz; - c.x = (int) vx; - c.y = (int) vy; - c.z = (int) vz; - //if(c.getBlockExist() == false) return Double.NaN; - Block b = c.getBlock(); - if(b != null && b.isOpaqueCube()){ - virtualDistance += 2.0; - } - - } - } - return virtualDistance; - } public String channel = "Default channel";