From 14d4eef90b2fc83c81857de5b91a79a0d5f95299 Mon Sep 17 00:00:00 2001 From: Bass Date: Sat, 16 Feb 2019 04:39:00 +0000 Subject: Theta Movement machines don't explode if broken Might roll this back, though honestly I just need to find how to set the explosion flag to off in the config xd --- .../thing/metaTileEntity/multi/GT_MetaTileEntity_TM_microwave.java | 3 +++ .../thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java | 3 +++ 2 files changed, 6 insertions(+) (limited to 'src') diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_microwave.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_microwave.java index 67c390ab7c..7e3a51da4f 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_microwave.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_microwave.java @@ -74,6 +74,9 @@ public class GT_MetaTileEntity_TM_microwave extends GT_MetaTileEntity_Multiblock return new GT_MetaTileEntity_TM_microwave(mName); } + @Override + public void onRemoval(){}//Literally stops this machine from exploding if you break it with some power left, it doesn't deal with any EM ffs + @Override public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { if (aSide == aFacing) { diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java index 605f958177..bb7c815416 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java @@ -142,6 +142,9 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock return new GT_MetaTileEntity_TM_teslaCoil(mName); } + @Override + public void onRemoval(){}//Literally stops this machine from exploding if you break it with some power left, it doesn't deal with any EM ffs + @Override @SideOnly(Side.CLIENT) public void registerIcons(IIconRegister aBlockIconRegister) { -- cgit From ee4bd9f91d4b8f85b550730aa1e3c63d91b3be2f Mon Sep 17 00:00:00 2001 From: Bass Date: Sat, 16 Feb 2019 08:14:14 +0000 Subject: Tesla WIP Both types of tesla now map other teslas After talking to 0laf, I think a super high tier Tesla Cover for straight tower to machine transfers. --- .../technus/tectech/loader/thing/CoverLoader.java | 6 +- .../technus/tectech/loader/thing/ThingsLoader.java | 1 + .../tectech/thing/cover/GT_Cover_TM_TeslaCoil.java | 2 +- .../cover/GT_Cover_TM_TeslaCoil_Ultimate.java | 8 + .../tectech/thing/item/TeslaCoilCoverUltimate.java | 36 +++++ .../multi/GT_MetaTileEntity_TM_teslaCoil.java | 178 ++++++++++++--------- .../single/GT_MetaTileEntity_TeslaCoil.java | 122 +++++++------- src/main/resources/assets/tectech/lang/en_US.lang | 1 + src/main/resources/assets/tectech/lang/zh_CN.lang | 1 + 9 files changed, 210 insertions(+), 145 deletions(-) create mode 100644 src/main/java/com/github/technus/tectech/thing/cover/GT_Cover_TM_TeslaCoil_Ultimate.java create mode 100644 src/main/java/com/github/technus/tectech/thing/item/TeslaCoilCoverUltimate.java (limited to 'src') diff --git a/src/main/java/com/github/technus/tectech/loader/thing/CoverLoader.java b/src/main/java/com/github/technus/tectech/loader/thing/CoverLoader.java index ca81427e03..e71489339e 100644 --- a/src/main/java/com/github/technus/tectech/loader/thing/CoverLoader.java +++ b/src/main/java/com/github/technus/tectech/loader/thing/CoverLoader.java @@ -3,15 +3,17 @@ package com.github.technus.tectech.loader.thing; import com.github.technus.tectech.TecTech; import com.github.technus.tectech.thing.cover.GT_Cover_TM_TeslaCoil; +import com.github.technus.tectech.thing.cover.GT_Cover_TM_TeslaCoil_Ultimate; import com.github.technus.tectech.thing.item.TeslaCoilCover; +import com.github.technus.tectech.thing.item.TeslaCoilCoverUltimate; import gregtech.api.GregTech_API; import gregtech.api.enums.Textures; import gregtech.api.objects.GT_RenderedTexture; import net.minecraft.item.ItemStack; - public class CoverLoader implements Runnable { public void run(){ - GregTech_API.registerCover(new ItemStack(TeslaCoilCover.INSTANCE, 1), new GT_RenderedTexture(Textures.BlockIcons.VENT_ADVANCED), new GT_Cover_TM_TeslaCoil()); + GregTech_API.registerCover(new ItemStack(TeslaCoilCover.INSTANCE, 1), new GT_RenderedTexture(Textures.BlockIcons.VENT_NORMAL), new GT_Cover_TM_TeslaCoil()); + GregTech_API.registerCover(new ItemStack(TeslaCoilCoverUltimate.INSTANCE, 1), new GT_RenderedTexture(Textures.BlockIcons.VENT_ADVANCED), new GT_Cover_TM_TeslaCoil_Ultimate()); TecTech.LOGGER.info("Cover functionality registered"); } } diff --git a/src/main/java/com/github/technus/tectech/loader/thing/ThingsLoader.java b/src/main/java/com/github/technus/tectech/loader/thing/ThingsLoader.java index e9967a3e62..6951ef6533 100644 --- a/src/main/java/com/github/technus/tectech/loader/thing/ThingsLoader.java +++ b/src/main/java/com/github/technus/tectech/loader/thing/ThingsLoader.java @@ -54,6 +54,7 @@ public class ThingsLoader implements Runnable { TecTech.LOGGER.info("Reactor Simulator registered"); TeslaCoilCover.run(); + TeslaCoilCoverUltimate.run(); TecTech.LOGGER.info("Covers Items registered"); ConstructableTriggerItem.run(); diff --git a/src/main/java/com/github/technus/tectech/thing/cover/GT_Cover_TM_TeslaCoil.java b/src/main/java/com/github/technus/tectech/thing/cover/GT_Cover_TM_TeslaCoil.java index e1e1b9d595..bfb4ae9208 100644 --- a/src/main/java/com/github/technus/tectech/thing/cover/GT_Cover_TM_TeslaCoil.java +++ b/src/main/java/com/github/technus/tectech/thing/cover/GT_Cover_TM_TeslaCoil.java @@ -1,6 +1,6 @@ package com.github.technus.tectech.thing.cover; -import gregtech.api.util.GT_CoverBehavior; + import gregtech.api.util.GT_CoverBehavior; public class GT_Cover_TM_TeslaCoil extends GT_CoverBehavior { public GT_Cover_TM_TeslaCoil() { diff --git a/src/main/java/com/github/technus/tectech/thing/cover/GT_Cover_TM_TeslaCoil_Ultimate.java b/src/main/java/com/github/technus/tectech/thing/cover/GT_Cover_TM_TeslaCoil_Ultimate.java new file mode 100644 index 0000000000..7ad6bc6f5f --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/cover/GT_Cover_TM_TeslaCoil_Ultimate.java @@ -0,0 +1,8 @@ +package com.github.technus.tectech.thing.cover; + + import gregtech.api.util.GT_CoverBehavior; + +public class GT_Cover_TM_TeslaCoil_Ultimate extends GT_CoverBehavior { + public GT_Cover_TM_TeslaCoil_Ultimate() { + } +} \ No newline at end of file diff --git a/src/main/java/com/github/technus/tectech/thing/item/TeslaCoilCoverUltimate.java b/src/main/java/com/github/technus/tectech/thing/item/TeslaCoilCoverUltimate.java new file mode 100644 index 0000000000..115f3a34c6 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/item/TeslaCoilCoverUltimate.java @@ -0,0 +1,36 @@ +package com.github.technus.tectech.thing.item; + +import com.github.technus.tectech.CommonValues; +import cpw.mods.fml.common.registry.GameRegistry; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; + +import java.util.List; + +import static com.github.technus.tectech.Reference.MODID; + + +public final class TeslaCoilCoverUltimate extends Item { + public static TeslaCoilCoverUltimate INSTANCE; + + public TeslaCoilCoverUltimate() { + setUnlocalizedName("tm.teslaCoilCoverUltimate"); + setTextureName(MODID + ":itemParametrizerMemoryCardUnlocked"); + } + + @Override + public void addInformation(ItemStack aStack, EntityPlayer ep, List aList, boolean boo) { + aList.add(CommonValues.BASS_MARK); + aList.add("Tesla-Enables Machines! (BUT LOUDER!!)"); + aList.add(EnumChatFormatting.BLUE + "Use on a machine to apply Tesla capabilities"); + aList.add(EnumChatFormatting.BLUE + "Who the hell need cables anyway?"); + } + + public static void run() { + INSTANCE = new TeslaCoilCoverUltimate(); + System.out.print(INSTANCE.getUnlocalizedName()); + GameRegistry.registerItem(INSTANCE, INSTANCE.getUnlocalizedName()); + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java index bb7c815416..926c5e5d30 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java @@ -1,6 +1,7 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; import com.github.technus.tectech.CommonValues; +import com.github.technus.tectech.thing.cover.GT_Cover_TM_TeslaCoil_Ultimate; import com.github.technus.tectech.thing.metaTileEntity.IConstructable; import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_Capacitor; import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_DynamoMulti; @@ -20,7 +21,7 @@ import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; -import java.util.ArrayList; +import java.util.*; import static com.github.technus.tectech.CommonValues.V; import static com.github.technus.tectech.Util.StructureBuilder; @@ -45,8 +46,7 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock private int scanTimeMin = 100; //Min scan time in ticks private int scanTimeTill = scanTimeMin; //Set default scan time - private ArrayList eTeslaList = new ArrayList<>(); //Makes a list of Smol Teslas - private ArrayList eTeslaTowerList = new ArrayList<>(); //Makes a list for BIGG Teslas + private Map eTeslaMap = new HashMap();//Tesla Map to map them tesla bois! private float histLow = 0.25F; //Power pass is disabled if power is under this fraction private float histHigh = 0.75F; //Power pass is enabled if power is over this fraction @@ -54,8 +54,11 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock private float histLowLimit = 0.05F; //How low can you configure it? private float histHighLimit = 0.95F; //How high can you configure it? - private int scanRadius = 64; //Radius for small to tower transfers - private int scanRadiusTower = scanRadius * 2; //Radius for tower to tower transfers + private int scanRadius = 64; //Tesla scan radius + + private int transferRadiusTower = 32; //Radius for tower to tower transfers + private int transferRadiusTransceiver = 16; //Radius for tower to transceiver transfers + private int transferRadiusCoverUltimate = 16; //Radius for tower to ultimate cover transfers private long outputVoltage = 512; //Tesla Voltage Output private long outputCurrent = 1; //Tesla Current Output @@ -68,12 +71,27 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock private long histLowParam = 0; private long histHighParam = 0; private long histScaleParam = 0; - private int scanRadiusParam = 0; - private int scanRadiusTowerParam = 0; + private int transferRadiusTowerParam = 0; + private int transferRadiusTransceiverParam = 0; + private int transferRadiusCoverUltimateParam = 0; private long outputVoltageParam = 0; private long outputCurrentParam = 0; private int scanTimeMinParam = 0; + static > SortedSet> entriesSortedByValues(Map map) { + SortedSet> sortedEntries = new TreeSet>( + new Comparator>() { + @Override + public int compare(Map.Entry e1, Map.Entry e2) { + int res = e1.getValue().compareTo(e2.getValue()); + return res != 0 ? res : 1; // Special fix to preserve items with equal values + } + } + ); + sortedEntries.addAll(map.entrySet()); + return sortedEntries; + } + //region structure private static final String[][] shape0 = new String[][]{//3 16 0 {"\u000F", "A . ",}, @@ -295,8 +313,9 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock histLowParam = 0; histHighParam = 0; histScaleParam = 0; - scanRadiusParam = 0; - scanRadiusTowerParam = 0; + transferRadiusTowerParam = 0; + transferRadiusTransceiverParam = 0; + transferRadiusCoverUltimateParam = 0; outputVoltageParam = 0; outputCurrentParam = 0; scanTimeMin = 0; @@ -344,55 +363,24 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock scanTime++; if (scanTime >= scanTimeTill) { scanTime = 0; - - scanRadius = 64; //TODO Generate depending on power stored - eTeslaList.clear(); - - if (parametrized && scanRadiusParam > 0 && scanRadiusParam < scanRadius) { - scanRadius = scanRadiusParam; - } + eTeslaMap.clear(); for (int xPosOffset = -scanRadius; xPosOffset <= scanRadius; xPosOffset++) { - for (int yPosOffset = -scanRadius; yPosOffset <= scanRadius; yPosOffset++) { - for (int zPosOffset = -scanRadius; zPosOffset <= scanRadius; zPosOffset++) { - if (xPosOffset == 0 && yPosOffset == 0 && zPosOffset == 0){ + for (int yPosOffset = -scanRadius; yPosOffset <= scanRadius; yPosOffset++) { + for (int zPosOffset = -scanRadius; zPosOffset <= scanRadius; zPosOffset++) { + if (xPosOffset == 0 && yPosOffset == 0 && zPosOffset == 0) { continue; } IGregTechTileEntity node = mte.getIGregTechTileEntityOffset(xPosOffset, yPosOffset, zPosOffset); - if (node == null) { - continue; - } - IMetaTileEntity nodeInside = node.getMetaTileEntity(); - if (nodeInside instanceof GT_MetaTileEntity_TeslaCoil){ - eTeslaList.add((GT_MetaTileEntity_TeslaCoil) nodeInside); - } - } - } - } - - scanRadiusTower = scanRadius * 2; - eTeslaTowerList.clear(); - - if (parametrized && scanRadiusTowerParam > 0 && scanRadiusTowerParam < scanRadiusTower) { - scanRadiusTower = scanRadiusTowerParam; - } - - for (int xPosOffset = -scanRadiusTower; xPosOffset <= scanRadiusTower; xPosOffset++) { - for (int yPosOffset = -scanRadiusTower; yPosOffset <= scanRadiusTower; yPosOffset++) { - for (int zPosOffset = -scanRadiusTower; zPosOffset <= scanRadiusTower; zPosOffset++) { - if (xPosOffset == 0 && yPosOffset == 0 && zPosOffset == 0){ + if (node == null) { continue; } - IGregTechTileEntity node = mte.getIGregTechTileEntityOffset(xPosOffset, yPosOffset, zPosOffset); - if (node == null) { - continue; - } - IMetaTileEntity nodeInside = node.getMetaTileEntity(); - if (nodeInside instanceof GT_MetaTileEntity_TM_teslaCoil && node.isActive()){ - eTeslaTowerList.add((GT_MetaTileEntity_TM_teslaCoil) nodeInside); - } - } - } + IMetaTileEntity nodeInside = node.getMetaTileEntity(); + if (nodeInside instanceof GT_MetaTileEntity_TeslaCoil || nodeInside instanceof GT_MetaTileEntity_TM_teslaCoil && node.isActive() || (node.getCoverBehaviorAtSide((byte) 1) instanceof GT_Cover_TM_TeslaCoil_Ultimate)) { + eTeslaMap.put(node, (int) Math.ceil(Math.sqrt(xPosOffset * xPosOffset + yPosOffset * yPosOffset + zPosOffset * zPosOffset))); + } + } + } } } @@ -402,50 +390,80 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock outputCurrent = 1;//TODO Generate depending on count of capacitors if (parametrized && outputVoltageParam > 0 && outputVoltage > outputVoltageParam){ - outputVoltage = outputVoltageParam;} + outputVoltage = outputVoltageParam; + } if (parametrized && outputCurrentParam > 0 && outputCurrent > outputCurrentParam){ - outputCurrent = outputCurrentParam;} + outputCurrent = outputCurrentParam; + } outputEuT = outputVoltage * outputCurrent; - long requestedSumEU = 0; + transferRadiusTower = 32; //TODO generate based on power stored + transferRadiusTransceiver = 16; //TODO generate based on power stored + transferRadiusCoverUltimate = 16; //TODO generate based on power stored - //Clean the Smol Tesla list - for (GT_MetaTileEntity_TeslaCoil Rx : eTeslaList.toArray(new GT_MetaTileEntity_TeslaCoil[eTeslaList.size()])) { - try { - requestedSumEU += Rx.maxEUStore() - Rx.getEUVar(); - } catch (Exception e) { - eTeslaList.remove(Rx); - } + if(parametrized && transferRadiusTowerParam > 0 && transferRadiusTowerParam < transferRadiusTower){ + transferRadiusTower = transferRadiusTowerParam; } - //Clean the large tesla list - for (GT_MetaTileEntity_TM_teslaCoil Rx : eTeslaTowerList.toArray(new GT_MetaTileEntity_TM_teslaCoil[eTeslaTowerList.size()])) { - try { - requestedSumEU += Rx.maxEUStore() - Rx.getEUVar(); - } catch (Exception e) { - eTeslaTowerList.remove(Rx); - } + if(parametrized && transferRadiusTransceiverParam > 0 && transferRadiusTransceiverParam < transferRadiusTransceiver){ + transferRadiusTransceiver = transferRadiusTransceiverParam; } - //Try to send EU to the smol teslas - for (GT_MetaTileEntity_TeslaCoil Rx : eTeslaList) { - if (!Rx.powerPassToggle) { - long euTran = outputVoltage; - if (Rx.getBaseMetaTileEntity().injectEnergyUnits((byte)6, euTran, 1L) > 0L) { - setEUVar(getEUVar() - euTran); + if(parametrized && transferRadiusCoverUltimateParam > 0 && transferRadiusCoverUltimateParam < transferRadiusCoverUltimate){ + transferRadiusCoverUltimate = transferRadiusCoverUltimateParam; + } + + //Clean the eTeslaMap + for (Map.Entry Rx : entriesSortedByValues(eTeslaMap)) { + IGregTechTileEntity node = Rx.getKey(); + if (node != null) { + IMetaTileEntity nodeInside = node.getMetaTileEntity(); + try { + if (nodeInside instanceof GT_MetaTileEntity_TM_teslaCoil && node.isActive()) { + GT_MetaTileEntity_TM_teslaCoil teslaTower = (GT_MetaTileEntity_TM_teslaCoil) nodeInside; + if (teslaTower.maxEUStore() > 0) { + continue; + } + } else if (nodeInside instanceof GT_MetaTileEntity_TeslaCoil) { + GT_MetaTileEntity_TeslaCoil teslaCoil = (GT_MetaTileEntity_TeslaCoil) nodeInside; + if (teslaCoil.getStoredEnergy()[1] > 0) { + continue; + } + } else if ((node.getCoverBehaviorAtSide((byte) 1) instanceof GT_Cover_TM_TeslaCoil_Ultimate) && node.getEUCapacity() > 0) { + continue; + } + } catch (Exception e) { } } + eTeslaMap.remove(Rx.getKey()); } - //Try to send EU to big teslas - for (GT_MetaTileEntity_TM_teslaCoil Rx : eTeslaTowerList) { - if (!Rx.powerPassToggle) { - long euTran = outputVoltage; - if (Rx.getEUVar() + euTran <= (Rx.maxEUStore()/2)) { + //Power transfer + for (Map.Entry Rx : entriesSortedByValues(eTeslaMap)) { + IGregTechTileEntity node = Rx.getKey(); + IMetaTileEntity nodeInside = node.getMetaTileEntity(); + long euTran = outputVoltage; + + if (nodeInside instanceof GT_MetaTileEntity_TM_teslaCoil && Rx.getValue() <= transferRadiusTower) { + GT_MetaTileEntity_TM_teslaCoil nodeTesla = (GT_MetaTileEntity_TM_teslaCoil) nodeInside; + if (!nodeTesla.powerPassToggle) { + if (nodeTesla.getEUVar() + euTran <= (nodeTesla.maxEUStore() / 2)) { + setEUVar(getEUVar() - euTran); + node.increaseStoredEnergyUnits(euTran, true); + } + } + } else if (nodeInside instanceof GT_MetaTileEntity_TeslaCoil && Rx.getValue() <= transferRadiusTransceiver) { + GT_MetaTileEntity_TeslaCoil nodeTesla = (GT_MetaTileEntity_TeslaCoil) nodeInside; + if (!nodeTesla.powerPassToggle) { + if (node.injectEnergyUnits((byte)6, euTran, 1L) > 0L) { + setEUVar(getEUVar() - euTran); + } + } + } else if ((node.getCoverBehaviorAtSide((byte) 1) instanceof GT_Cover_TM_TeslaCoil_Ultimate) && Rx.getValue() <= transferRadiusCoverUltimate){ + if (node.injectEnergyUnits((byte)6, euTran, 1L) > 0L) { setEUVar(getEUVar() - euTran); - Rx.getBaseMetaTileEntity().increaseStoredEnergyUnits(euTran, true); } } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_TeslaCoil.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_TeslaCoil.java index a8797682e6..906ce556f7 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_TeslaCoil.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_TeslaCoil.java @@ -25,27 +25,32 @@ public class GT_MetaTileEntity_TeslaCoil extends GT_MetaTileEntity_BasicBatteryB private int scanTimeMin = 100; //Min scan time in ticks private int scanTimeTill = scanTimeMin; //Set default scan time - private Map eTeslaTowerMap = new HashMap(); + private Map eTeslaMap = new HashMap();//Tesla Map to map them tesla bois! private int histSteps = 20; //Hysteresis Resolution private int histSettingLow = 3; private int histSettingHigh = 15; private int histLowLimit = 1; //How low can you configure it? - private int histHighLimit = histSteps-1; //How high can you configure it? + private int histHighLimit = histSteps - 1; //How high can you configure it? - private float histLow = (float)histSettingLow/histSteps; //Power pass is disabled if power is under this fraction - private float histHigh = (float)histSettingHigh/histSteps; //Power pass is enabled if power is over this fraction + private float histLow = (float) histSettingLow / histSteps; //Power pass is disabled if power is under this fraction + private float histHigh = (float) histSettingHigh / histSteps; //Power pass is enabled if power is over this fraction + + private int scanRadius = 32; //Tesla scan radius + + private int transferRadiusTower = 32; //Radius for transceiver to tower transfers + private int transferRadiusCover = 16; //Radius for transceiver to cover transfers - private int scanRadiusTower = 64; //Radius for tower to tower transfers private long outputVoltage = 512; //Tesla Voltage Output private long outputCurrent = 1; //Tesla Current Output private long outputEuT = outputVoltage * outputCurrent; //Tesla Power Output - static > SortedSet> entriesSortedByValues(Map map) { - SortedSet> sortedEntries = new TreeSet>( - new Comparator>() { - @Override public int compare(Map.Entry e1, Map.Entry e2) { + static > SortedSet> entriesSortedByValues(Map map) { + SortedSet> sortedEntries = new TreeSet>( + new Comparator>() { + @Override + public int compare(Map.Entry e1, Map.Entry e2) { int res = e1.getValue().compareTo(e2.getValue()); return res != 0 ? res : 1; // Special fix to preserve items with equal values } @@ -67,20 +72,20 @@ public class GT_MetaTileEntity_TeslaCoil extends GT_MetaTileEntity_BasicBatteryB public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { if (aPlayer.isSneaking()) { - if (histSettingHighhistLowLimit) { + if (histSettingLow > histLowLimit) { histSettingLow--; } else { - histSettingLow=histSettingHigh-1; + histSettingLow = histSettingHigh - 1; } - histLow = (float)histSettingLow/histSteps; + histLow = (float) histSettingLow / histSteps; PlayerChatHelper.SendInfo(aPlayer, "Hysteresis Low Changed to " + round(histLow * 100F) + "%"); } } @@ -101,10 +106,6 @@ public class GT_MetaTileEntity_TeslaCoil extends GT_MetaTileEntity_BasicBatteryB ItemStack[] var4 = this.mInventory; int var5 = var4.length; - if (aBaseMetaTileEntity.getCoverBehaviorAtSide((byte)1) instanceof GT_Cover_TM_TeslaCoil && scanTime == 0){ - System.out.println("I myself feel quite tesla enabled indeed!"); - } - for (int var6 = 0; var6 < var5; ++var6) { ItemStack tStack = var4[var6]; if (GT_ModHandler.isElectricItem(tStack, this.mTier)) { @@ -119,8 +120,7 @@ public class GT_MetaTileEntity_TeslaCoil extends GT_MetaTileEntity_BasicBatteryB long energyMax = getStoredEnergy()[1]; long energyStored = getStoredEnergy()[0]; - float energyFrac = (float)energyStored/energyMax; - //System.err.println(energyFrac); Debug energy fraction display + float energyFrac = (float) energyStored / energyMax; //ePowerPass hist toggle if (!powerPassToggle && energyFrac > histHigh) { @@ -133,14 +133,12 @@ public class GT_MetaTileEntity_TeslaCoil extends GT_MetaTileEntity_BasicBatteryB scanTime++; if (scanTime >= scanTimeTill) { scanTime = 0; + eTeslaMap.clear(); - scanRadiusTower = 64; //TODO Generate depending on power stored - eTeslaTowerMap.clear(); - - for (int xPosOffset = -scanRadiusTower; xPosOffset <= scanRadiusTower; xPosOffset++) { - for (int yPosOffset = -scanRadiusTower; yPosOffset <= scanRadiusTower; yPosOffset++) { - for (int zPosOffset = -scanRadiusTower; zPosOffset <= scanRadiusTower; zPosOffset++) { - if (xPosOffset == 0 && yPosOffset == 0 && zPosOffset == 0){ + for (int xPosOffset = -scanRadius; xPosOffset <= scanRadius; xPosOffset++) { + for (int yPosOffset = -scanRadius; yPosOffset <= scanRadius; yPosOffset++) { + for (int zPosOffset = -scanRadius; zPosOffset <= scanRadius; zPosOffset++) { + if (xPosOffset == 0 && yPosOffset == 0 && zPosOffset == 0) { continue; } IGregTechTileEntity node = mte.getIGregTechTileEntityOffset(xPosOffset, yPosOffset, zPosOffset); @@ -148,18 +146,14 @@ public class GT_MetaTileEntity_TeslaCoil extends GT_MetaTileEntity_BasicBatteryB continue; } IMetaTileEntity nodeInside = node.getMetaTileEntity(); - if (nodeInside instanceof GT_MetaTileEntity_TM_teslaCoil && node.isActive() || (node.getCoverBehaviorAtSide((byte)1) instanceof GT_Cover_TM_TeslaCoil)){ - eTeslaTowerMap.put(node,(int)Math.ceil(Math.sqrt(xPosOffset*xPosOffset + yPosOffset*yPosOffset + zPosOffset*zPosOffset))); + if (nodeInside instanceof GT_MetaTileEntity_TM_teslaCoil && node.isActive() || (node.getCoverBehaviorAtSide((byte) 1) instanceof GT_Cover_TM_TeslaCoil)) { + eTeslaMap.put(node, (int) Math.ceil(Math.sqrt(xPosOffset * xPosOffset + yPosOffset * yPosOffset + zPosOffset * zPosOffset))); } } } } } - for (Map.Entry Rx : entriesSortedByValues(eTeslaTowerMap)) { - System.out.println("yote @: " + Rx.getValue()); - } - //Stuff to do if ePowerPass if (powerPassToggle) { outputVoltage = 512;//TODO Set Depending On Tier @@ -167,41 +161,45 @@ public class GT_MetaTileEntity_TeslaCoil extends GT_MetaTileEntity_BasicBatteryB outputEuT = outputVoltage * outputCurrent; - long requestedSumEU = 0;//TODO Find a use for requestedSumEU + transferRadiusTower = 32; //TODO generate based on power stored + transferRadiusCover = 16; //TODO generate based on power stored - //Clean the node list SMALL INSTANCE REAPING DOESN'T WORK - for (Map.Entry Rx : entriesSortedByValues(eTeslaTowerMap)) { + //Clean the eTeslaMap + for (Map.Entry Rx : entriesSortedByValues(eTeslaMap)) { IGregTechTileEntity node = Rx.getKey(); - if (node == null) { - eTeslaTowerMap.remove(Rx.getKey()); - System.err.println("Dead Tesla Reaped!"); - continue; - } - IMetaTileEntity nodeInside = node.getMetaTileEntity(); - try { - if (nodeInside instanceof GT_MetaTileEntity_TM_teslaCoil && node.isActive()) { - GT_MetaTileEntity_TM_teslaCoil teslaTower = (GT_MetaTileEntity_TM_teslaCoil) nodeInside; - requestedSumEU += teslaTower.maxEUStore() - teslaTower.getEUVar(); - } else if ((node.getCoverBehaviorAtSide((byte) 1) instanceof GT_Cover_TM_TeslaCoil)) { - requestedSumEU += node.getEUCapacity() - node.getStoredEU(); - } else { - eTeslaTowerMap.remove(Rx.getKey()); - System.err.println("Dead Tesla Reaped!"); + if (node != null) { + IMetaTileEntity nodeInside = node.getMetaTileEntity(); + try { + if (nodeInside instanceof GT_MetaTileEntity_TM_teslaCoil && node.isActive()) { + GT_MetaTileEntity_TM_teslaCoil teslaTower = (GT_MetaTileEntity_TM_teslaCoil) nodeInside; + if (teslaTower.maxEUStore() > 0) { + continue; + } + } else if ((node.getCoverBehaviorAtSide((byte) 1) instanceof GT_Cover_TM_TeslaCoil) && node.getEUCapacity() > 0) { + continue; + } + } catch (Exception e) { } - } catch (Exception e) { - eTeslaTowerMap.remove(Rx.getKey()); - System.err.println("Dead Tesla Reaped!"); } + eTeslaMap.remove(Rx.getKey()); } - for (Map.Entry Rx : entriesSortedByValues(eTeslaTowerMap)) { - GT_MetaTileEntity_TM_teslaCoil nodeInside = (GT_MetaTileEntity_TM_teslaCoil) Rx.getKey().getMetaTileEntity(); - if (!nodeInside.powerPassToggle) { - long euTran = outputVoltage; - if (nodeInside.getEUVar() + euTran <= (nodeInside.maxEUStore() / 2)) { + //Power transfer + for (Map.Entry Rx : entriesSortedByValues(eTeslaMap)) { + IGregTechTileEntity node = Rx.getKey(); + IMetaTileEntity nodeInside = node.getMetaTileEntity(); + long euTran = outputVoltage; + if (nodeInside instanceof GT_MetaTileEntity_TM_teslaCoil && Rx.getValue() <= transferRadiusTower) { + GT_MetaTileEntity_TM_teslaCoil nodeTesla = (GT_MetaTileEntity_TM_teslaCoil) nodeInside; + if (!nodeTesla.powerPassToggle) { + if (nodeTesla.getEUVar() + euTran <= (nodeTesla.maxEUStore() / 2)) { + setEUVar(getEUVar() - euTran); + node.increaseStoredEnergyUnits(euTran, true); + } + } + } else if ((node.getCoverBehaviorAtSide((byte) 1) instanceof GT_Cover_TM_TeslaCoil) && Rx.getValue() <= transferRadiusCover){ + if (node.injectEnergyUnits((byte)6, euTran, 1L) > 0L) { setEUVar(getEUVar() - euTran); - nodeInside.getBaseMetaTileEntity().increaseStoredEnergyUnits(euTran, true); - System.err.println("Energy Sent!"); } } } diff --git a/src/main/resources/assets/tectech/lang/en_US.lang b/src/main/resources/assets/tectech/lang/en_US.lang index 2c748a18d7..f01a74a0a2 100644 --- a/src/main/resources/assets/tectech/lang/en_US.lang +++ b/src/main/resources/assets/tectech/lang/en_US.lang @@ -10,6 +10,7 @@ item.em.parametrizerMemoryCard.name=Parametrizer Memory Card item.em.EuMeterGT.name=GT EU meter item.tm.teslaCoilCover.name=Tesla Coil Cover +item.tm.teslaCoilCoverUltimate=Tesla Coil Cover Rich Edition death.attack.microwaving=%1$s was dehydrated by radiation. death.attack.microwaving.player=%1$s was dehydrated by radiation while fighting %2$s. diff --git a/src/main/resources/assets/tectech/lang/zh_CN.lang b/src/main/resources/assets/tectech/lang/zh_CN.lang index 47912d245d..52ae6c594d 100644 --- a/src/main/resources/assets/tectech/lang/zh_CN.lang +++ b/src/main/resources/assets/tectech/lang/zh_CN.lang @@ -7,6 +7,7 @@ item.em.debugBuilder.name=多方块机器蓝图 item.em.parametrizerMemoryCard.name=参量机记忆卡 item.tm.teslaCoilCover.name=Tesla Coil Cover +item.tm.teslaCoilCoverUltimate=Tesla Coil Cover Rich Edition death.attack.microwaving=%1$s 被辐射脱水 death.attack.microwaving.player=%1$s 在与 %2$s 战斗中被辐射脱水 -- cgit From 88124a202a65445e33697416fa6ee97ca8c024f5 Mon Sep 17 00:00:00 2001 From: Tec Date: Sat, 16 Feb 2019 10:00:48 +0100 Subject: Move to util --- src/main/java/com/github/technus/tectech/Util.java | 15 +++++++++++++-- .../multi/GT_MetaTileEntity_TM_teslaCoil.java | 15 +-------------- .../single/GT_MetaTileEntity_TeslaCoil.java | 16 +--------------- 3 files changed, 15 insertions(+), 31 deletions(-) (limited to 'src') diff --git a/src/main/java/com/github/technus/tectech/Util.java b/src/main/java/com/github/technus/tectech/Util.java index 1fd479939c..7a5366f337 100644 --- a/src/main/java/com/github/technus/tectech/Util.java +++ b/src/main/java/com/github/technus/tectech/Util.java @@ -24,8 +24,7 @@ import org.apache.commons.lang3.StringUtils; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.List; +import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -39,6 +38,18 @@ public final class Util { private Util() { } + @SuppressWarnings("ComparatorMethodParameterNotUsed") + public static > SortedSet> entriesSortedByValues(Map map) { + SortedSet> sortedEntries = new TreeSet>( + (e1, e2) -> { + int res = e1.getValue().compareTo(e2.getValue()); + return res != 0 ? res : 1; // Special fix to preserve items with equal values + } + ); + sortedEntries.addAll(map.entrySet()); + return sortedEntries; + } + public static String intBitsToString(int number) { StringBuilder result = new StringBuilder(16); diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java index 926c5e5d30..eca3dde6cb 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java @@ -25,6 +25,7 @@ import java.util.*; import static com.github.technus.tectech.CommonValues.V; import static com.github.technus.tectech.Util.StructureBuilder; +import static com.github.technus.tectech.Util.entriesSortedByValues; import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.texturePage; import static gregtech.api.GregTech_API.*; @@ -78,20 +79,6 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock private long outputCurrentParam = 0; private int scanTimeMinParam = 0; - static > SortedSet> entriesSortedByValues(Map map) { - SortedSet> sortedEntries = new TreeSet>( - new Comparator>() { - @Override - public int compare(Map.Entry e1, Map.Entry e2) { - int res = e1.getValue().compareTo(e2.getValue()); - return res != 0 ? res : 1; // Special fix to preserve items with equal values - } - } - ); - sortedEntries.addAll(map.entrySet()); - return sortedEntries; - } - //region structure private static final String[][] shape0 = new String[][]{//3 16 0 {"\u000F", "A . ",}, diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_TeslaCoil.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_TeslaCoil.java index 906ce556f7..c556ca2ef6 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_TeslaCoil.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_TeslaCoil.java @@ -15,6 +15,7 @@ import net.minecraft.item.ItemStack; import java.util.*; +import static com.github.technus.tectech.Util.entriesSortedByValues; import static java.lang.Math.round; @@ -41,25 +42,10 @@ public class GT_MetaTileEntity_TeslaCoil extends GT_MetaTileEntity_BasicBatteryB private int transferRadiusTower = 32; //Radius for transceiver to tower transfers private int transferRadiusCover = 16; //Radius for transceiver to cover transfers - private long outputVoltage = 512; //Tesla Voltage Output private long outputCurrent = 1; //Tesla Current Output private long outputEuT = outputVoltage * outputCurrent; //Tesla Power Output - static > SortedSet> entriesSortedByValues(Map map) { - SortedSet> sortedEntries = new TreeSet>( - new Comparator>() { - @Override - public int compare(Map.Entry e1, Map.Entry e2) { - int res = e1.getValue().compareTo(e2.getValue()); - return res != 0 ? res : 1; // Special fix to preserve items with equal values - } - } - ); - sortedEntries.addAll(map.entrySet()); - return sortedEntries; - } - public GT_MetaTileEntity_TeslaCoil(int aID, String aName, String aNameRegional, int aTier, int aSlotCount) { super(aID, aName, aNameRegional, aTier, "Tesla Coil Transceiver", aSlotCount); -- cgit From 5965915bd0549cd289846ea20c9de6037e7faed1 Mon Sep 17 00:00:00 2001 From: Tec Date: Sat, 16 Feb 2019 10:43:14 +0100 Subject: Refactor to LedStatus enum --- .../multi/GT_MetaTileEntity_EM_collider.java | 1 + .../multi/GT_MetaTileEntity_EM_computer.java | 41 +++++++++--------- .../multi/GT_MetaTileEntity_EM_dataBank.java | 1 + .../multi/GT_MetaTileEntity_EM_junction.java | 25 +++++------ .../multi/GT_MetaTileEntity_EM_switch.java | 21 +++++----- .../multi/GT_MetaTileEntity_TM_microwave.java | 21 +++++----- .../multi/base/GT_Container_MultiMachineEM.java | 12 +++--- .../multi/base/GT_GUIContainer_MultiMachineEM.java | 3 +- .../base/GT_MetaTileEntity_MultiblockBase_EM.java | 20 ++++----- .../thing/metaTileEntity/multi/base/LedStatus.java | 33 +++++++++++++++ .../multi/em_machine/Behaviour_Centrifuge.java | 29 ++++++------- .../Behaviour_ElectromagneticSeparator.java | 49 +++++++++++----------- .../em_machine/GT_MetaTileEntity_EM_machine.java | 43 +++++++++---------- 13 files changed, 169 insertions(+), 130 deletions(-) create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/LedStatus.java (limited to 'src') diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_collider.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_collider.java index 471870b13b..69bebb4a78 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_collider.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_collider.java @@ -37,6 +37,7 @@ import static com.github.technus.tectech.Util.StructureBuilderExtreme; import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.textureOffset; import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.texturePage; import static com.github.technus.tectech.thing.casing.TT_Container_Casings.sBlockCasingsTT; +import static com.github.technus.tectech.thing.metaTileEntity.multi.base.LedStatus.*; /** * Created by danie_000 on 17.12.2016. diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_computer.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_computer.java index c021f93260..77db52f4b1 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_computer.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_computer.java @@ -34,6 +34,7 @@ import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.textureOffset; import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.texturePage; import static com.github.technus.tectech.thing.casing.TT_Container_Casings.sBlockCasingsTT; +import static com.github.technus.tectech.thing.metaTileEntity.multi.base.LedStatus.*; /** * Created by danie_000 on 17.12.2016. @@ -208,55 +209,55 @@ public class GT_MetaTileEntity_EM_computer extends GT_MetaTileEntity_MultiblockB public void parametersOutAndStatusesWrite_EM(boolean machineBusy) { double ocRatio = getParameterIn(0, 0); if (ocRatio < 0) { - setStatusOfParameterIn(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_LOW); + setStatusOfParameterIn(0, 0, STATUS_TOO_LOW); } else if (ocRatio < 1) { - setStatusOfParameterIn(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_LOW); + setStatusOfParameterIn(0, 0, STATUS_LOW); } else if (ocRatio == 1) { - setStatusOfParameterIn(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_OK); + setStatusOfParameterIn(0, 0, STATUS_OK); } else if (ocRatio <= 3) { - setStatusOfParameterIn(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_HIGH); + setStatusOfParameterIn(0, 0, STATUS_HIGH); } else if (Double.isNaN(ocRatio)) { - setStatusOfParameterIn(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_WRONG); + setStatusOfParameterIn(0, 0, STATUS_WRONG); } else { - setStatusOfParameterIn(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_HIGH); + setStatusOfParameterIn(0, 0, STATUS_TOO_HIGH); } double ovRatio = getParameterIn(0, 1); if (ovRatio < 0.7f) { - setStatusOfParameterIn(0, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_LOW); + setStatusOfParameterIn(0, 1, STATUS_TOO_LOW); } else if (ovRatio < 0.8f) { - setStatusOfParameterIn(0, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_LOW); + setStatusOfParameterIn(0, 1, STATUS_LOW); } else if (ovRatio <= 1.2f) { - setStatusOfParameterIn(0, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_OK); + setStatusOfParameterIn(0, 1, STATUS_OK); } else if (ovRatio <= 2) { - setStatusOfParameterIn(0, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_HIGH); + setStatusOfParameterIn(0, 1, STATUS_HIGH); } else if (Double.isNaN(ovRatio)) { - setStatusOfParameterIn(0, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_WRONG); + setStatusOfParameterIn(0, 1, STATUS_WRONG); } else { - setStatusOfParameterIn(0, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_HIGH); + setStatusOfParameterIn(0, 1, STATUS_TOO_HIGH); } setParameterOut(0, 0, maxCurrentTemp); setParameterOut(0, 1, eAvailableData); if (maxCurrentTemp < -10000) { - setStatusOfParameterOut(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_LOW); + setStatusOfParameterOut(0, 0, STATUS_TOO_LOW); } else if (maxCurrentTemp < 0) { - setStatusOfParameterOut(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_LOW); + setStatusOfParameterOut(0, 0, STATUS_LOW); } else if (maxCurrentTemp == 0) { - setStatusOfParameterOut(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_OK); + setStatusOfParameterOut(0, 0, STATUS_OK); } else if (maxCurrentTemp <= 5000) { - setStatusOfParameterOut(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_HIGH); + setStatusOfParameterOut(0, 0, STATUS_HIGH); } else { - setStatusOfParameterOut(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_HIGH); + setStatusOfParameterOut(0, 0, STATUS_TOO_HIGH); } if (!machineBusy) { - setStatusOfParameterOut(0, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_NEUTRAL); + setStatusOfParameterOut(0, 1, STATUS_NEUTRAL); } else if (eAvailableData <= 0) { - setStatusOfParameterOut(0, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_LOW); + setStatusOfParameterOut(0, 1, STATUS_TOO_LOW); } else { - setStatusOfParameterOut(0, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_OK); + setStatusOfParameterOut(0, 1, STATUS_OK); } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_dataBank.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_dataBank.java index da2e06c873..e79675f016 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_dataBank.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_dataBank.java @@ -32,6 +32,7 @@ import static com.github.technus.tectech.Util.StructureBuilderExtreme; import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.textureOffset; import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.texturePage; import static com.github.technus.tectech.thing.casing.TT_Container_Casings.sBlockCasingsTT; +import static com.github.technus.tectech.thing.metaTileEntity.multi.base.LedStatus.STATUS_UNUSED; public class GT_MetaTileEntity_EM_dataBank extends GT_MetaTileEntity_MultiblockBase_EM implements IConstructable { private final ArrayList eStacksDataOutputs = new ArrayList<>(); diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_junction.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_junction.java index bd8ed9c6bb..a295a5c7f1 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_junction.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_junction.java @@ -15,6 +15,7 @@ import static com.github.technus.tectech.CommonValues.V; import static com.github.technus.tectech.Util.StructureBuilderExtreme; import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.textureOffset; import static com.github.technus.tectech.thing.casing.TT_Container_Casings.sBlockCasingsTT; +import static com.github.technus.tectech.thing.metaTileEntity.multi.base.LedStatus.*; /** * Created by danie_000 on 17.12.2016. @@ -84,27 +85,27 @@ public class GT_MetaTileEntity_EM_junction extends GT_MetaTileEntity_MultiblockB for (int i = 0; i < 10; i++) { src = getParameterIn(i, 0); if (src <= 0) { - setStatusOfParameterIn(i, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_LOW); - setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_NEUTRAL); + setStatusOfParameterIn(i, 0, STATUS_TOO_LOW); + setStatusOfParameterIn(i, 1, STATUS_NEUTRAL); } else if (src > eInputHatches.size()) { - setStatusOfParameterIn(i, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_HIGH); - setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_NEUTRAL); + setStatusOfParameterIn(i, 0, STATUS_TOO_HIGH); + setStatusOfParameterIn(i, 1, STATUS_NEUTRAL); } else if (Double.isNaN(src)) { - setStatusOfParameterIn(i, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_WRONG); - setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_NEUTRAL); + setStatusOfParameterIn(i, 0, STATUS_WRONG); + setStatusOfParameterIn(i, 1, STATUS_NEUTRAL); } else { - setStatusOfParameterIn(i, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_OK); + setStatusOfParameterIn(i, 0, STATUS_OK); dest = getParameterIn(i, 1); if (dest < 0) { - setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_LOW); + setStatusOfParameterIn(i, 1, STATUS_TOO_LOW); } else if (dest == 0) { - setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_LOW); + setStatusOfParameterIn(i, 1, STATUS_LOW); } else if (dest > eOutputHatches.size()) { - setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_HIGH); + setStatusOfParameterIn(i, 1, STATUS_TOO_HIGH); } else if (Double.isNaN(dest)) { - setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_WRONG); + setStatusOfParameterIn(i, 1, STATUS_WRONG); } else { - setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_OK); + setStatusOfParameterIn(i, 1, STATUS_OK); } } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_switch.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_switch.java index 1ddb655105..767bd676d6 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_switch.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_switch.java @@ -25,6 +25,7 @@ import static com.github.technus.tectech.Util.StructureBuilderExtreme; import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.textureOffset; import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.texturePage; import static com.github.technus.tectech.thing.casing.TT_Container_Casings.sBlockCasingsTT; +import static com.github.technus.tectech.thing.metaTileEntity.multi.base.LedStatus.*; /** * Created by danie_000 on 17.12.2016. @@ -182,24 +183,24 @@ public class GT_MetaTileEntity_EM_switch extends GT_MetaTileEntity_MultiblockBas for (int i = 0; i < 10; i++) { weight = getParameterIn(i, 0); if (weight < 0) { - setStatusOfParameterIn(i, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_LOW); - setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_NEUTRAL); + setStatusOfParameterIn(i, 0, STATUS_TOO_LOW); + setStatusOfParameterIn(i, 1, STATUS_NEUTRAL); } else if (Double.isNaN(weight)) { - setStatusOfParameterIn(i, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_WRONG); - setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_NEUTRAL); + setStatusOfParameterIn(i, 0, STATUS_WRONG); + setStatusOfParameterIn(i, 1, STATUS_NEUTRAL); } else { - setStatusOfParameterIn(i, 0, weight==0?STATUS_LOW:GT_MetaTileEntity_MultiblockBase_EM.STATUS_OK); + setStatusOfParameterIn(i, 0, weight==0?STATUS_LOW:STATUS_OK); dest = getParameterIn(i, 1); if (dest < 0) { - setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_LOW); + setStatusOfParameterIn(i, 1, STATUS_TOO_LOW); } else if (dest == 0) { - setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_LOW); + setStatusOfParameterIn(i, 1, STATUS_LOW); } else if (dest > eOutputData.size()) { - setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_HIGH); + setStatusOfParameterIn(i, 1, STATUS_TOO_HIGH); } else if (Double.isNaN(dest)) { - setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_WRONG); + setStatusOfParameterIn(i, 1, STATUS_WRONG); } else { - setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_OK); + setStatusOfParameterIn(i, 1, STATUS_OK); } } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_microwave.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_microwave.java index 67c390ab7c..1fdf8d6943 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_microwave.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_microwave.java @@ -28,6 +28,7 @@ import java.util.HashSet; import static com.github.technus.tectech.Util.StructureBuilderExtreme; import static com.github.technus.tectech.loader.MainLoader.microwaving; +import static com.github.technus.tectech.thing.metaTileEntity.multi.base.LedStatus.*; import static gregtech.api.GregTech_API.sBlockCasings4; /** @@ -218,28 +219,28 @@ public class GT_MetaTileEntity_TM_microwave extends GT_MetaTileEntity_Multiblock public void parametersOutAndStatusesWrite_EM(boolean machineBusy) { double powerParameter = getParameterIn(0, 0); if (powerParameter < 300) { - setStatusOfParameterIn(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_LOW); + setStatusOfParameterIn(0, 0, STATUS_TOO_LOW); } else if (powerParameter < 1000) { - setStatusOfParameterIn(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_LOW); + setStatusOfParameterIn(0, 0, STATUS_LOW); } else if (powerParameter == 1000) { - setStatusOfParameterIn(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_OK); + setStatusOfParameterIn(0, 0, STATUS_OK); } else if (powerParameter == Double.POSITIVE_INFINITY) { - setStatusOfParameterIn(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_HIGH); + setStatusOfParameterIn(0, 0, STATUS_TOO_HIGH); } else if (Double.isNaN(powerParameter)) { - setStatusOfParameterIn(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_WRONG); + setStatusOfParameterIn(0, 0, STATUS_WRONG); } else { - setStatusOfParameterOut(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_HIGH); + setStatusOfParameterOut(0, 0, STATUS_HIGH); } double timerParameter = getParameterIn(0, 1); if (timerParameter <= 1) { - setStatusOfParameterIn(0, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_LOW); + setStatusOfParameterIn(0, 1, STATUS_TOO_LOW); } else if (timerParameter <= 3000) { - setStatusOfParameterIn(0, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_OK); + setStatusOfParameterIn(0, 1, STATUS_OK); } else if (Double.isNaN(timerParameter)) { - setStatusOfParameterIn(0, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_WRONG); + setStatusOfParameterIn(0, 1, STATUS_WRONG); } else { - setStatusOfParameterIn(0, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_HIGH); + setStatusOfParameterIn(0, 1, STATUS_TOO_HIGH); } setParameterOut(0, 0, timerValue); diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_Container_MultiMachineEM.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_Container_MultiMachineEM.java index 91b2635001..4845117a99 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_Container_MultiMachineEM.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_Container_MultiMachineEM.java @@ -11,8 +11,8 @@ import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; public class GT_Container_MultiMachineEM extends GT_ContainerMetaTile_Machine { - public byte[] eParamsInStatus = new byte[20];//unused 0,G ok 1, B too low 2, R too high 3, Y blink dangerous 4,5 - public byte[] eParamsOutStatus = new byte[20]; + public LedStatus[] eParamsInStatus = new LedStatus[20];//unused 0,G ok 1, B too low 2, R too high 3, Y blink dangerous 4,5 + public LedStatus[] eParamsOutStatus = new LedStatus[20]; public byte eCertainMode = 5, eCertainStatus = 127; public boolean ePowerPass = false, eSafeVoid = false, allowedToWork = false; public final boolean ePowerPassButton, eSafeVoidButton, allowedToWorkButton; @@ -118,9 +118,9 @@ public class GT_Container_MultiMachineEM extends GT_ContainerMetaTile_Machine { ICrafting var1 = (ICrafting) crafter; int i = 100; for (int j = 0; j < eParamsInStatus.length; j++) { - var1.sendProgressBarUpdate(this, i++, eParamsInStatus[j] | eParamsOutStatus[j] << 8); + var1.sendProgressBarUpdate(this, i++, (eParamsInStatus[j].getOrdinalByte() | (eParamsOutStatus[j].getOrdinalByte() << 8))); } - var1.sendProgressBarUpdate(this, 120, eCertainMode | eCertainStatus << 8); + var1.sendProgressBarUpdate(this, 120, eCertainMode | (eCertainStatus << 8)); var1.sendProgressBarUpdate(this, 121, (ePowerPass ? 1 : 0) + (eSafeVoid ? 2 : 0) + (allowedToWork ? 4 : 0)); } } @@ -132,8 +132,8 @@ public class GT_Container_MultiMachineEM extends GT_ContainerMetaTile_Machine { return; } if (par1 >= 100 && par1 < 120) { - eParamsInStatus[par1 - 100] = (byte) (par2 & 0xff); - eParamsOutStatus[par1 - 100] = (byte) (par2 >>> 8); + eParamsInStatus[par1 - 100] = LedStatus.getStatus ((byte) (par2 & 0xff)); + eParamsOutStatus[par1 - 100] = LedStatus.getStatus ((byte) (par2 >>> 8)); } else if (par1 == 120) { eCertainMode = (byte) (par2 & 0xff); eCertainStatus = (byte) (par2 >>> 8); diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_GUIContainer_MultiMachineEM.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_GUIContainer_MultiMachineEM.java index 40285cc5e7..90ad4e7388 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_GUIContainer_MultiMachineEM.java +++ b/src/main/java/com/github/technus