diff options
author | Tec <daniel112092@gmail.com> | 2019-07-17 09:25:46 +0200 |
---|---|---|
committer | Tec <daniel112092@gmail.com> | 2019-07-17 09:25:46 +0200 |
commit | 11c0e1d102b7692502f93e416ecbba456515993c (patch) | |
tree | 635f91a3fa74d89a46b7c3844e44b4b87cd4d944 | |
parent | db90af28310cf6a00beea911b9debfce4bea8b1b (diff) | |
parent | 1d554019f1596476b7198c30debc9a41db27195f (diff) | |
download | GT5-Unofficial-11c0e1d102b7692502f93e416ecbba456515993c.tar.gz GT5-Unofficial-11c0e1d102b7692502f93e416ecbba456515993c.tar.bz2 GT5-Unofficial-11c0e1d102b7692502f93e416ecbba456515993c.zip |
Merge branch 'betterParametrizers'
124 files changed, 5128 insertions, 1893 deletions
diff --git a/build.gradle b/build.gradle index 6fccbe64e8..0d563706a2 100644 --- a/build.gradle +++ b/build.gradle @@ -33,7 +33,7 @@ file "build.properties" withReader { } version = "${config.minecraft.version}-${config.tectech.version}" -group= "com.github.technus" +group = "com.github.technus" archivesBaseName = "TecTech" minecraft { @@ -59,12 +59,12 @@ repositories { name = "ic2" url = "http://maven.ic2.player.to/" } - - ivy { + + ivy { name 'gtnh_download_source' artifactPattern "http://downloads.gtnewhorizons.com/Mods_for_Jenkins/[module]-[revision].[ext]" } - + maven { name = "chickenbones" url = "http://chickenbones.net/maven/" @@ -97,37 +97,37 @@ tasks.setupDecompWorkspace.dependsOn getGregTech tasks.compileJava.dependsOn getGregTech processResources -{ - def cleanVersion = project.version.split('-')[1] - // this will ensure that this task is redone when the versions change. - inputs.property "version", cleanVersion - inputs.property "mcversion", project.minecraft.version - - // replace stuff in mcmod.info, nothing else - from(sourceSets.main.resources.srcDirs) { - include 'mcmod.info' - - // replace version and mcversion - expand 'version':cleanVersion, 'mcversion':project.minecraft.version - } - - // copy everything else, thats not the mcmod.info - from(sourceSets.main.resources.srcDirs) { - exclude 'mcmod.info' - } -} + { + def cleanVersion = project.version.split('-')[1] + // this will ensure that this task is redone when the versions change. + inputs.property "version", cleanVersion + inputs.property "mcversion", project.minecraft.version -task signJar(dependsOn: 'reobf'){ + // replace stuff in mcmod.info, nothing else + from(sourceSets.main.resources.srcDirs) { + include 'mcmod.info' + + // replace version and mcversion + expand 'version': cleanVersion, 'mcversion': project.minecraft.version + } + + // copy everything else, thats not the mcmod.info + from(sourceSets.main.resources.srcDirs) { + exclude 'mcmod.info' + } + } + +task signJar(dependsOn: 'reobf') { doLast { ant.signjar( - destDir: jar.destinationDir, - jar: jar.getArchivePath(), - alias: findProperty('keyStoreAlias') ?: '', - keystore: findProperty('keyStore') ?: '', - storepass: findProperty('keyStorePass') ?: '', - digestalg: findProperty('signDigestAlg') ?: '', - tsaurl: findProperty('signTSAurl') ?: '', - verbose: true - ) + destDir: jar.destinationDir, + jar: jar.getArchivePath(), + alias: findProperty('keyStoreAlias') ?: '', + keystore: findProperty('keyStore') ?: '', + storepass: findProperty('keyStorePass') ?: '', + digestalg: findProperty('signDigestAlg') ?: '', + tsaurl: findProperty('signTSAurl') ?: '', + verbose: true + ) } -} +}
\ No newline at end of file diff --git a/build.properties b/build.properties index 1c9906c5b5..69cdaa724f 100644 --- a/build.properties +++ b/build.properties @@ -1,14 +1,14 @@ minecraft.version=1.7.10 forge.version=1.7.10-10.13.4.1614-1.7.10 -tectech.version=3.6.11 +tectech.version=3.6.10 ic2.version=2.2.790-experimental codechickenlib.version=1.1.3.140 codechickencore.version=1.0.7.47 nei.version=1.0.5.120 -gregtech.jenkinsbuild=293 -gregtech.version=5.09.33.14 +gregtech.jenkinsbuild=299 +gregtech.version=5.09.33.16 cofhcore.version=[1.7.10]3.1.4-329-dev cofhlib.version=[1.7.10]1.0.3-175-dev -yamcore.version=0.5.78 +yamcore.version=0.5.78
\ No newline at end of file diff --git a/src/main/java/com/github/technus/tectech/TecTech.java b/src/main/java/com/github/technus/tectech/TecTech.java index 6f1c4fc7a0..f998a9017b 100644 --- a/src/main/java/com/github/technus/tectech/TecTech.java +++ b/src/main/java/com/github/technus/tectech/TecTech.java @@ -2,20 +2,31 @@ package com.github.technus.tectech; import com.github.technus.tectech.loader.MainLoader; import com.github.technus.tectech.loader.TecTechConfig; -import com.github.technus.tectech.mechanics.ConvertFloat; -import com.github.technus.tectech.mechanics.ConvertInteger; +import com.github.technus.tectech.mechanics.anomaly.AnomalyHandler; +import com.github.technus.tectech.mechanics.anomaly.CancerCommand; +import com.github.technus.tectech.mechanics.anomaly.ChargeCommand; +import com.github.technus.tectech.mechanics.commands.ConvertFloat; +import com.github.technus.tectech.mechanics.commands.ConvertInteger; +import com.github.technus.tectech.mechanics.data.ChunkDataHandler; +import com.github.technus.tectech.mechanics.data.PlayerPersistence; import com.github.technus.tectech.mechanics.elementalMatter.core.commands.GiveEM; import com.github.technus.tectech.mechanics.elementalMatter.core.commands.ListEM; import com.github.technus.tectech.proxy.CommonProxy; +import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.SidedProxy; -import cpw.mods.fml.common.event.FMLInitializationEvent; -import cpw.mods.fml.common.event.FMLPostInitializationEvent; -import cpw.mods.fml.common.event.FMLPreInitializationEvent; -import cpw.mods.fml.common.event.FMLServerStartingEvent; +import cpw.mods.fml.common.event.*; import eu.usrv.yamcore.auxiliary.IngameErrorLog; import eu.usrv.yamcore.auxiliary.LogHelper; +import gregtech.GT_Mod; +import gregtech.common.GT_Proxy; +import net.minecraftforge.common.MinecraftForge; + +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; +import java.util.Collection; +import java.util.Iterator; import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; @@ -34,6 +45,10 @@ public class TecTech { private static IngameErrorLog moduleAdminErrorLogs; public static TecTechConfig configTecTech; + public static ChunkDataHandler chunkDataHandler; + public static AnomalyHandler anomalyHandler; + public static PlayerPersistence playerPersistence; + /** * For Loader.isModLoaded checks during the runtime */ @@ -68,6 +83,14 @@ public class TecTech { moduleAdminErrorLogs = new IngameErrorLog(); } + playerPersistence=new PlayerPersistence("tec"); + FMLCommonHandler.instance().bus().register(playerPersistence); + MinecraftForge.EVENT_BUS.register(playerPersistence); + + chunkDataHandler=new ChunkDataHandler(); + FMLCommonHandler.instance().bus().register(chunkDataHandler); + MinecraftForge.EVENT_BUS.register(chunkDataHandler); + MainLoader.preLoad(); } @@ -75,6 +98,96 @@ public class TecTech { public void Load(FMLInitializationEvent event) { hasCOFH = Loader.isModLoaded(Reference.COFHCORE); + + if(configTecTech.DISABLE_MATERIAL_LOADING_FFS){ + try { + Field modifiersField = Field.class.getDeclaredField( "modifiers" ); + modifiersField.setAccessible( true ); + Field field= GT_Proxy.class.getDeclaredField("mEvents"); + field.setAccessible(true); + modifiersField.setInt( field, field.getModifiers() & ~Modifier.FINAL ); + field.set(GT_Mod.gregtechproxy, new Collection() { + @Override + public int size() { + return 0; + } + + @Override + public boolean isEmpty() { + return true; + } + + @Override + public boolean contains(Object o) { + return false; + } + + @Override + public Iterator iterator() { + return new Iterator() { + @Override + public boolean hasNext() { + return false; + } + + @Override + public Object next() { + return null; + } + }; + } + + @Override + public Object[] toArray() { + return new Object[0]; + } + + @Override + public boolean add(Object o) { + return false; + } + + @Override + public boolean remove(Object o) { + return false; + } + + @Override + public boolean addAll(Collection c) { + return false; + } + + @Override + public void clear() { + + } + + @Override + public boolean retainAll(Collection c) { + return false; + } + + @Override + public boolean removeAll(Collection c) { + return false; + } + + @Override + public boolean containsAll(Collection c) { + return false; + } + + @Override + public Object[] toArray(Object[] a) { + return new Object[0]; + } + }); + } catch (NoSuchFieldException | IllegalAccessException e) { + LOGGER.error(Reference.MODID + " could not disable material loading!"); + } + + } + MainLoader.load(); MainLoader.addAfterGregTechPostLoadRunner(); } @@ -82,6 +195,9 @@ public class TecTech { @Mod.EventHandler public void PostLoad(FMLPostInitializationEvent PostEvent) { MainLoader.postLoad(); + + chunkDataHandler.registerChunkMetaDataHandler(anomalyHandler=new AnomalyHandler()); + } @Mod.EventHandler @@ -91,6 +207,14 @@ public class TecTech { pEvent.registerServerCommand(new ListEM()); if(DEBUG_MODE) { pEvent.registerServerCommand(new GiveEM()); + pEvent.registerServerCommand(new CancerCommand()); + pEvent.registerServerCommand(new ChargeCommand()); } } + + @Mod.EventHandler + public void onServerAboutToStart(FMLServerAboutToStartEvent aEvent) { + chunkDataHandler.clearData(); + playerPersistence.clearData(); + } } diff --git a/src/main/java/com/github/technus/tectech/Util.java b/src/main/java/com/github/technus/tectech/Util.java index 1fd479939c..c98fefcd86 100644 --- a/src/main/java/com/github/technus/tectech/Util.java +++ b/src/main/java/com/github/technus/tectech/Util.java @@ -2,6 +2,9 @@ package com.github.technus.tectech; import com.github.technus.tectech.thing.casing.TT_Container_Casings; import com.github.technus.tectech.thing.metaTileEntity.IFrontRotation; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.IHatchAdder; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.ObfuscationReflectionHelper; import cpw.mods.fml.common.registry.GameRegistry; import gregtech.api.GregTech_API; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; @@ -11,26 +14,37 @@ import gregtech.api.util.GT_OreDictUnificator; import gregtech.api.util.GT_Utility; import net.minecraft.block.Block; import net.minecraft.block.material.Material; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.init.Items; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.ICrafting; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.CompressedStreamTools; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.server.MinecraftServer; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.world.ChunkCoordIntPair; import net.minecraft.world.World; +import net.minecraft.world.chunk.Chunk; +import net.minecraft.world.storage.IPlayerFileData; +import net.minecraft.world.storage.SaveHandler; import net.minecraftforge.fluids.FluidStack; import org.apache.commons.lang3.StringUtils; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; 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; import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; import static gregtech.api.enums.GT_Values.E; +import static java.nio.charset.Charset.forName; /** * Created by Tec on 21.03.2017. @@ -39,6 +53,18 @@ public final class Util { private Util() { } + @SuppressWarnings("ComparatorMethodParameterNotUsed") + public static <K, V extends Comparable<? super V>> SortedSet<Map.Entry<K, V>> entriesSortedByValues(Map<K, V> map) { + SortedSet<Map.Entry<K, V>> 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); @@ -56,7 +82,7 @@ public final class Util { } public static String intBitsToShortString(int number) { - StringBuilder result = new StringBuilder(16); + StringBuilder result = new StringBuilder(35); for (int i = 31; i >= 0; i--) { int mask = 1 << i; @@ -71,6 +97,22 @@ public final class Util { return result.toString(); } + public static String longBitsToShortString(long number) { + StringBuilder result = new StringBuilder(71); + + for (int i = 63; i >= 0; i--) { + long mask = 1L << i; + result.append((number & mask) != 0 ? ":" : "."); + + if (i % 8 == 0) { + result.append('|'); + } + } + result.replace(result.length() - 1, result.length(), ""); + + return result.toString(); + } + //region junk /* //Check Machine Structure based on string[][] (effectively char[][][]), ond offset of the controller @@ -360,14 +402,14 @@ public final class Util { */ //endregion + //Check Machine Structure based on string[][] (effectively char[][][]), ond offset of the controller //This only checks for REGULAR BLOCKS! public static boolean StructureCheckerExtreme( String[][] structure,//0-9 casing, +- air no air, A... ignore 'A'-CHAR-1 blocks Block[] blockType,//use numbers 0-9 for casing types byte[] blockMeta,//use numbers 0-9 for casing types - Method adder, - String[] addingMethods, + IHatchAdder[] addingMethods, short[] casingTextures, Block[] blockTypeFallback,//use numbers 0-9 for casing types byte[] blockMetaFallback,//use numbers 0-9 for casing types @@ -578,28 +620,22 @@ public final class Util { } return false; } - } else if ((pointer = block - ' ') >= 0) { + } else //noinspection ConstantConditions + if ((pointer = block - ' ') >= 0) { igt = aBaseMetaTileEntity.getIGregTechTileEntity(x, y, z); - try { - if (igt == null || !(boolean) adder.invoke(imt, addingMethods[pointer], igt, casingTextures[pointer])) { - if (world.getBlock(x, y, z) != blockTypeFallback[pointer]) { - if (DEBUG_MODE) { - TecTech.LOGGER.info("Fallback-struct-block-error " + x + ' ' + y + ' ' + z + " / " + a + ' ' + b + ' ' + c + " / " + world.getBlock(x, y, z).getUnlocalizedName() + ' ' + (blockTypeFallback[pointer] == null ? "null" : blockTypeFallback[pointer].getUnlocalizedName())); - } - return false; - } - if (world.getBlockMetadata(x, y, z) != blockMetaFallback[pointer]) { - if (DEBUG_MODE) { - TecTech.LOGGER.info("Fallback-Struct-meta-id-error " + x + ' ' + y + ' ' + z + " / " + a + ' ' + b + ' ' + c + " / " + world.getBlockMetadata(x, y, z) + ' ' + blockMetaFallback[pointer]); - } - return false; + if (igt == null || !addingMethods[pointer].apply(igt, casingTextures[pointer])) { + if (world.getBlock(x, y, z) != blockTypeFallback[pointer]) { + if (DEBUG_MODE) { + TecTech.LOGGER.info("Fallback-struct-block-error " + x + ' ' + y + ' ' + z + " / " + a + ' ' + b + ' ' + c + " / " + world.getBlock(x, y, z).getUnlocalizedName() + ' ' + (blockTypeFallback[pointer] == null ? "null" : blockTypeFallback[pointer].getUnlocalizedName())); } + return false; } - } catch (InvocationTargetException | IllegalAccessException e) { - if (DEBUG_MODE) { - e.printStackTrace(); + if (world.getBlockMetadata(x, y, z) != blockMetaFallback[pointer]) { + if (DEBUG_MODE) { + TecTech.LOGGER.info("Fallback-Struct-meta-id-error " + x + ' ' + y + ' ' + z + " / " + a + ' ' + b + ' ' + c + " / " + world.getBlockMetadata(x, y, z) + ' ' + blockMetaFallback[pointer]); + } + return false; } - return false; } } } @@ -1137,7 +1173,7 @@ public final class Util { c++;//depth } output.add("}"); - return output.toArray(new String[output.size()]); + return output.toArray(new String[0]); } private static final Pattern matchE_ = Pattern.compile("(E,(E,)+)"); @@ -1291,18 +1327,18 @@ public final class Util { return (testedValue & setBits) == setBits; } - public static class TT_ItemStack implements Comparable<TT_ItemStack> { + public static class ItemStack_NoNBT implements Comparable<ItemStack_NoNBT> { public final Item mItem; public final int mStackSize; public final int mMetaData; - public TT_ItemStack(Item aItem, long aStackSize, long aMetaData) { + public ItemStack_NoNBT(Item aItem, long aStackSize, long aMetaData) { this.mItem = aItem; this.mStackSize = (byte) ((int) aStackSize); this.mMetaData = (short) ((int) aMetaData); } - public TT_ItemStack(ItemStack aStack) { + public ItemStack_NoNBT(ItemStack aStack) { if (aStack == null) { mItem = null; mStackSize = mMetaData = 0; @@ -1314,7 +1350,7 @@ public final class Util { } @Override - public int compareTo(TT_ItemStack o) { + public int compareTo(ItemStack_NoNBT o) { if (mMetaData > o.mMetaData) return 1; if (mMetaData < o.mMetaData) return -1; if (mStackSize > o.mStackSize) return 1; @@ -1329,10 +1365,10 @@ public final class Util { @Override public boolean equals(Object aStack) { return aStack == this || - (aStack instanceof TT_ItemStack && - ((mItem == ((TT_ItemStack) aStack).mItem) || ((TT_ItemStack) aStack).mItem.getUnlocalizedName().equals(this.mItem.getUnlocalizedName())) && - ((TT_ItemStack) aStack).mStackSize == this.mStackSize && - ((TT_ItemStack) aStack).mMetaData == this.mMetaData); + (aStack instanceof ItemStack_NoNBT && + ((mItem == ((ItemStack_NoNBT) aStack).mItem) || ((ItemStack_NoNBT) aStack).mItem.getUnlocalizedName().equals(this.mItem.getUnlocalizedName())) && + ((ItemStack_NoNBT) aStack).mStackSize == this.mStackSize && + ((ItemStack_NoNBT) aStack).mMetaData == this.mMetaData); } @Override @@ -1352,7 +1388,184 @@ public final class Util { field.setAccessible(true); field.set(me,(byte)tier); }catch (Exception e){ - e.printStackTrace(); + //e.printStackTrace(); + } + } + + public static double receiveDouble(double previousValue, int startIndex, int index, int value){ + return Double.longBitsToDouble(receiveLong(Double.doubleToLongBits(previousValue),startIndex,index,value)); + } + + public static long receiveLong(long previousValue, int startIndex, int index, int value){ + value &=0xFFFF; + switch (index-startIndex){ + case 0: + previousValue&= 0xFFFF_FFFF_FFFF_0000L; + previousValue|=value; + break; + case 1: + previousValue&=0xFFFF_FFFF_0000_FFFFL; + previousValue|=value<<16; + break; + case 2: + previousValue&=0xFFFF_0000_FFFF_FFFFL; + previousValue|=(long)value<<32; + break; + case 3: + previousValue&=0x0000_FFFF_FFFF_FFFFL; + previousValue|=(long)value<<48; + break; + } + return previousValue; + } + + public static void sendDouble(double value,Container container, ICrafting crafter,int startIndex){ + sendLong(Double.doubleToLongBits(value),container,crafter,startIndex); + } + + public static void sendLong(long value,Container container, ICrafting crafter,int startIndex){ + crafter.sendProgressBarUpdate(container, startIndex++, (int)(value & 0xFFFFL)); + crafter.sendProgressBarUpdate(container, startIndex++, (int)((value & 0xFFFF0000L)>>>16)); + crafter.sendProgressBarUpdate(container, startIndex++, (int)((value & 0xFFFF00000000L)>>>32)); + crafter.sendProgressBarUpdate(container, startIndex, (int)((value & 0xFFFF000000000000L)>>>48)); + } + + public static float receiveFloat(float previousValue, int startIndex, int index, int value){ + return Float.intBitsToFloat(receiveInteger(Float.floatToIntBits(previousValue),startIndex,index,value)); + } + + public static int receiveInteger(int previousValue, int startIndex, int index, int value){ + value &=0xFFFF; + switch (index-startIndex){ + case 0: + previousValue&= 0xFFFF_0000; + previousValue|=value; + break; + case 1: + previousValue&=0x0000_FFFF; + previousValue|=value<<16; + break; } + return previousValue; + } + + public static void sendFloat(float value,Container container, ICrafting crafter,int startIndex){ + sendInteger(Float.floatToIntBits(value),container,crafter,startIndex); + } + + public static void sendInteger(int value,Container container, ICrafting crafter,int startIndex){ + crafter.sendProgressBarUpdate(container, startIndex++, (int)(value & 0xFFFFL)); + crafter.sendProgressBarUpdate(container, startIndex, (value & 0xFFFF0000)>>>16); + } + + public static String doubleToString(double value){ + if(value==(long)value){ + return Long.toString((long)value); + } + return Double.toString(value); + } + + public static boolean checkChunkExist(World world, ChunkCoordIntPair chunk){ + int x=chunk.getCenterXPos(); + int z=chunk.getCenterZPosition(); + return world.checkChunksExist(x, 0, z, x, 0, z); + } + + public static NBTTagCompound getPlayerData(UUID uuid1,UUID uuid2,String extension) { + try { + if (FMLCommonHandler.instance().getEffectiveSide().isServer()) { + if (uuid1 != null && uuid2!=null) { + IPlayerFileData playerNBTManagerObj = MinecraftServer.getServer().worldServerForDimension(0).getSaveHandler().getSaveHandler(); + SaveHandler sh = (SaveHandler)playerNBTManagerObj; + File dir = ObfuscationReflectionHelper.getPrivateValue(SaveHandler.class, sh, new String[]{"playersDirectory", "field_75771_c"}); + String id1=uuid1.toString(); + NBTTagCompound tagCompound=read(new File(dir, id1 + "."+extension)); + if(tagCompound!=null){ + return tagCompound; + } + tagCompound=readBackup(new File(dir, id1 + "."+extension+"_bak")); + if(tagCompound!=null){ + return tagCompound; + } + String id2=uuid2.toString(); + tagCompound=read(new File(dir, id2 + "."+extension)); + if(tagCompound!=null){ + return tagCompound; + } + tagCompound=readBackup(new File(dir, id2 + "."+extension+"_bak")); + if(tagCompound!=null){ + return tagCompound; + } + } + } + } catch (Exception ignored) {} + return new NBTTagCompound(); + } + + public static void savePlayerFile(EntityPlayer player,String extension, NBTTagCompound data) { + try { + if (FMLCommonHandler.instance().getEffectiveSide().isServer()) { + if (player != null) { + IPlayerFileData playerNBTManagerObj = MinecraftServer.getServer().worldServerForDimension(0).getSaveHandler().getSaveHandler(); + SaveHandler sh = (SaveHandler)playerNBTManagerObj; + File dir = ObfuscationReflectionHelper.getPrivateValue(SaveHandler.class, sh, new String[]{"playersDirectory", "field_75771_c"}); + String id1=player.getUniqueID().toString(); + write(new File(dir, id1 + "."+extension),data); + write(new File(dir, id1 + "."+extension+"_bak"),data); + String id2=UUID.nameUUIDFromBytes(player.getCommandSenderName().getBytes(forName("UTF-8"))).toString(); + write(new File(dir, id2 + "."+extension),data); + write(new File(dir, id2 + "."+extension+"_bak"),data); + } + } + } catch (Exception ignored) {} + } + + private static NBTTagCompound read(File file){ + if (file != null && file.exists()) { + try(FileInputStream fileInputStream= new FileInputStream(file)) { + return CompressedStreamTools.readCompressed(fileInputStream); + } catch (Exception var9) { + TecTech.LOGGER.error("Cannot read NBT File: "+file.getAbsolutePath()); + } + } + return null; + } + + private static NBTTagCompound readBackup(File file){ + if (file != null && file.exists()) { + try(FileInputStream fileInputStream= new FileInputStream(file)) { + return CompressedStreamTools.readCompressed(fileInputStream); + } catch (Exception var9) { + TecTech.LOGGER.error("Cannot read NBT File: "+file.getAbsolutePath()); + return new NBTTagCompound(); + } + } + return null; + } + + private static void write(File file,NBTTagCompound tagCompound){ + if (file != null) { + if(tagCompound==null){ + if(file.exists()) file.delete(); + }else { + try(FileOutputStream fileOutputStream= new FileOutputStream(file)) { + CompressedStreamTools.writeCompressed(tagCompound,fileOutputStream); + } catch (Exception var9) { + TecTech.LOGGER.error("Cannot write NBT File: "+file.getAbsolutePath()); + } + } + } + } + + public static AxisAlignedBB fromChunkCoordIntPair(ChunkCoordIntPair chunkCoordIntPair){ + int x=chunkCoordIntPair.chunkXPos<<4; + int z=chunkCoordIntPair.chunkZPos<<4; + return AxisAlignedBB.getBoundingBox(x,-128,z,x+16,512,z+16); + } + + public static AxisAlignedBB fromChunk(Chunk chunk){ + int x=chunk.xPosition<<4; + int z=chunk.zPosition<<4; + return AxisAlignedBB.getBoundingBox(x,-128,z,x+16,512,z+16); } } diff --git a/src/main/java/com/github/technus/tectech/compatibility/dreamcraft/DreamCraftRecipeLoader.java b/src/main/java/com/github/technus/tectech/compatibility/dreamcraft/DreamCraftRecipeLoader.java index 4875847fd4..16636d67cf 100644 --- a/src/main/java/com/github/technus/tectech/compatibility/dreamcraft/DreamCraftRecipeLoader.java +++ b/src/main/java/com/github/technus/tectech/compatibility/dreamcraft/DreamCraftRecipeLoader.java @@ -5,6 +5,7 @@ import com.github.technus.tectech.thing.CustomItemList; import com.github.technus.tectech.thing.block.QuantumGlassBlock; import com.github.technus.tectech.thing.metaTileEntity.multi.em_machine.Behaviour_Centrifuge; import com.github.technus.tectech.thing.metaTileEntity.multi.em_machine.Behaviour_ElectromagneticSeparator; +import com.github.technus.tectech.thing.metaTileEntity.multi.em_machine.Behaviour_Recycler; import com.github.technus.tectech.thing.metaTileEntity.multi.em_machine.GT_MetaTileEntity_EM_machine; import cpw.mods.fml.common.Loader; import gregtech.api.enums.GT_Values; @@ -14,6 +15,7 @@ import gregtech.api.enums.OrePrefixes; import gregtech.api.interfaces.IItemContainer; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Utility; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidRegistry; @@ -81,6 +83,13 @@ public class DreamCraftRecipeLoader implements Runnable { ItemList.Circuit_Quantummainframe.get(1) }, Materials.Osmium.getMolten(288), CustomItemList.EMpipe.get(1), 400, 500000); + //Laser + addAssemblerRecipeWithCleanroom(new ItemStack[]{ + CustomItemList.DATApipe.get(1), + GT_ModHandler.getIC2Item("reinforcedGlass", 1L), + GT_OreDictUnificator.get(OrePrefixes.foil, Materials.Osmiridium, 2) + }, null, CustomItemList.LASERpipe.get(1), 100, 500000); + //endregoin //region casing @@ -212,6 +221,118 @@ public class DreamCraftRecipeLoader implements Runnable { //GT_Values.RA.ADD_ASSEMBLER_RECIPE(new ItemStack[]{com.dreammaster.gthandler.CustomItemList.Transformer_UMV_UIV.get(1), CustomItemList.eM_energymulti4_UIV.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.NetherStar, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.BlackPlutonium, 4)}, Materials.Electrum.getMolten(8000), CustomItemList.eM_energymulti16_UIV.get(1), 200, 8000000); //GT_Values.RA.ADD_ASSEMBLER_RECIPE(new ItemStack[]{com.dreammaster.gthandler.CustomItemList.WetTransformer_UMV_UIV.get(1), CustomItemList.eM_energymulti16_UIV.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt12, Materials.NetherStar, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.BlackPlutonium, 6)}, Materials.Tungsten.getMolten(8000), CustomItemList.eM_energymulti64_UIV.get(1), 400, 8000000); + //Laser Dynamo IV-UEV 256/t + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_IV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 1), ItemList.Emitter_IV.get(1), ItemList.Electric_Pump_IV.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.TungstenSteel, 2), GT_Utility.getIntegratedCircuit(1)}, null, CustomItemList.eM_dynamotunnel1_IV.get(1), 1000, 7680); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_LuV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 1), ItemList.Emitter_LuV.get(1), ItemList.Electric_Pump_LuV.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.VanadiumGallium, 2), GT_Utility.getIntegratedCircuit(1)}, null, CustomItemList.eM_dynamotunnel1_LuV.get(1), 1000, 30720); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_ZPM.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 1), ItemList.Emitter_ZPM.get(1), ItemList.Electric_Pump_ZPM.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.Naquadah, 2), GT_Utility.getIntegratedCircuit(1)}, null, CustomItemList.eM_dynamotunnel1_ZPM.get(1), 1000, 122880); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_UV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 1), ItemList.Emitter_UV.get(1), ItemList.Electric_Pump_UV.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.NaquadahAlloy, 2), GT_Utility.getIntegratedCircuit(1)}, null, CustomItemList.eM_dynamotunnel1_UV.get(1), 1000, 500000); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_MAX.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 1), ItemList.Emitter_UHV.get(1), ItemList.Electric_Pump_UHV.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.Bedrockium, 2), GT_Utility.getIntegratedCircuit(1)}, null, CustomItemList.eM_dynamotunnel1_UHV.get(1), 1000, 2000000); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{getItemContainer("Hull_UEV").get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 1), ItemList.Emitter_UEV.get(1), ItemList.Electric_Pump_UEV.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.Draconium, 2), GT_Utility.getIntegratedCircuit(1)}, null, CustomItemList.eM_dynamotunnel1_UEV.get(1), 1000, 8000000); + + //Laser Dynamo IV-UEV 1024/t + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_IV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 2), ItemList.Emitter_IV.get(2), ItemList.Electric_Pump_IV.get(2), GT_OreDictUnificator.get(OrePrefixes.wireGt02, Materials.TungstenSteel, 4), GT_Utility.getIntegratedCircuit(2)}, null, CustomItemList.eM_dynamotunnel2_IV.get(1), 2000, 7680); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_LuV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 2), ItemList.Emitter_LuV.get(2), ItemList.Electric_Pump_LuV.get(2), GT_OreDictUnificator.get(OrePrefixes.wireGt02, Materials.VanadiumGallium, 4), GT_Utility.getIntegratedCircuit(2)}, null, CustomItemList.eM_dynamotunnel2_LuV.get(1), 2000, 30720); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_ZPM.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 2), ItemList.Emitter_ZPM.get(2), ItemList.Electric_Pump_ZPM.get(2), GT_OreDictUnificator.get(OrePrefixes.wireGt02, Materials.Naquadah, 4), GT_Utility.getIntegratedCircuit(2)}, null, CustomItemList.eM_dynamotunnel2_ZPM.get(1), 2000, 122880); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_UV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 2), ItemList.Emitter_UV.get(2), ItemList.Electric_Pump_UV.get(2), GT_OreDictUnificator.get(OrePrefixes.wireGt02, Materials.NaquadahAlloy, 4), GT_Utility.getIntegratedCircuit(2)}, null, CustomItemList.eM_dynamotunnel2_UV.get(1), 2000, 500000); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_MAX.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 2), ItemList.Emitter_UHV.get(2), ItemList.Electric_Pump_UHV.get(2), GT_OreDictUnificator.get(OrePrefixes.wireGt02, Materials.Bedrockium, 4), GT_Utility.getIntegratedCircuit(2)}, null, CustomItemList.eM_dynamotunnel2_UHV.get(1), 2000, 2000000); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{getItemContainer("Hull_UEV").get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 2), ItemList.Emitter_UEV.get(2), ItemList.Electric_Pump_UEV.get(2), GT_OreDictUnificator.get(OrePrefixes.wireGt02, Materials.Draconium, 4), GT_Utility.getIntegratedCircuit(2)}, null, CustomItemList.eM_dynamotunnel2_UEV.get(1), 2000, 8000000); + + //Laser Dynamo IV-UEV 4096/t + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_IV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 4), ItemList.Emitter_IV.get(4), ItemList.Electric_Pump_IV.get(4), GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.TungstenSteel, 4), GT_Utility.getIntegratedCircuit(3)}, null, CustomItemList.eM_dynamotunnel3_IV.get(1), 4000, 7680); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_LuV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 4), ItemList.Emitter_LuV.get(4), ItemList.Electric_Pump_LuV.get(4), GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.VanadiumGallium, 4), GT_Utility.getIntegratedCircuit(3)}, null, CustomItemList.eM_dynamotunnel3_LuV.get(1), 4000, 30720); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_ZPM.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 4), ItemList.Emitter_ZPM.get(4), ItemList.Electric_Pump_ZPM.get(4), GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Naquadah, 4), GT_Utility.getIntegratedCircuit(3)}, null, CustomItemList.eM_dynamotunnel3_ZPM.get(1), 4000, 122880); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_UV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 4), ItemList.Emitter_UV.get(4), ItemList.Electric_Pump_UV.get(4), GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.NaquadahAlloy, 4), GT_Utility.getIntegratedCircuit(3)}, null, CustomItemList.eM_dynamotunnel3_UV.get(1), 4000, 500000); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_MAX.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 4), ItemList.Emitter_UHV.get(4), ItemList.Electric_Pump_UHV.get(4), GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Bedrockium, 4), GT_Utility.getIntegratedCircuit(3)}, null, CustomItemList.eM_dynamotunnel3_UHV.get(1), 4000, 2000000); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{getItemContainer("Hull_UEV").get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 4), ItemList.Emitter_UEV.get(4), ItemList.Electric_Pump_UEV.get(4), GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Draconium, 4), GT_Utility.getIntegratedCircuit(3)}, null, CustomItemList.eM_dynamotunnel3_UEV.get(1), 4000, 8000000); + + //Laser Dynamo IV-UEV 16384/t + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_IV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 8), ItemList.Emitter_IV.get(8), ItemList.Electric_Pump_IV.get(8), GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.TungstenSteel, 8), GT_Utility.getIntegratedCircuit(4)}, null, CustomItemList.eM_dynamotunnel4_IV.get(1), 8000, 7680); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_LuV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 8), ItemList.Emitter_LuV.get(8), ItemList.Electric_Pump_LuV.get(8), GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.VanadiumGallium, 8), GT_Utility.getIntegratedCircuit(4)}, null, CustomItemList.eM_dynamotunnel4_LuV.get(1), 8000, 30720); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_ZPM.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 8), ItemList.Emitter_ZPM.get(8), ItemList.Electric_Pump_ZPM.get(8), GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Naquadah, 8), GT_Utility.getIntegratedCircuit(4)}, null, CustomItemList.eM_dynamotunnel4_ZPM.get(1), 8000, 122880); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_UV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 8), ItemList.Emitter_UV.get(8), ItemList.Electric_Pump_UV.get(8), GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.NaquadahAlloy, 8), GT_Utility.getIntegratedCircuit(4)}, null, CustomItemList.eM_dynamotunnel4_UV.get(1), 8000, 500000); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_MAX.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 8), ItemList.Emitter_UHV.get(8), ItemList.Electric_Pump_UHV.get(8), GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Bedrockium, 8), GT_Utility.getIntegratedCircuit(4)}, null, CustomItemList.eM_dynamotunnel4_UHV.get(1), 8000, 2000000); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{getItemContainer("Hull_UEV").get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 8), ItemList.Emitter_UEV.get(8), ItemList.Electric_Pump_UEV.get(8), GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Draconium, 8), GT_Utility.getIntegratedCircuit(4)}, null, CustomItemList.eM_dynamotunnel4_UEV.get(1), 8000, 8000000); + + //Laser Dynamo IV-UEV 65536/t + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_IV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 16), ItemList.Emitter_IV.get(16), ItemList.Electric_Pump_IV.get(16), GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.TungstenSteel, 8), GT_Utility.getIntegratedCircuit(5)}, null, CustomItemList.eM_dynamotunnel5_IV.get(1), 16000, 7680); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_LuV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 16), ItemList.Emitter_LuV.get(16), ItemList.Electric_Pump_LuV.get(16), GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.VanadiumGallium, 8), GT_Utility.getIntegratedCircuit(5)}, null, CustomItemList.eM_dynamotunnel5_LuV.get(1), 16000, 30720); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_ZPM.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 16), ItemList.Emitter_ZPM.get(16), ItemList.Electric_Pump_ZPM.get(16), GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.Naquadah, 8), GT_Utility.getIntegratedCircuit(5)}, null, CustomItemList.eM_dynamotunnel5_ZPM.get(1), 16000, 122880); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_UV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 16), ItemList.Emitter_UV.get(16), ItemList.Electric_Pump_UV.get(16), GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.NaquadahAlloy, 8), GT_Utility.getIntegratedCircuit(5)}, null, CustomItemList.eM_dynamotunnel5_UV.get(1), 16000, 500000); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_MAX.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 16), ItemList.Emitter_UHV.get(16), ItemList.Electric_Pump_UHV.get(16), GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.Bedrockium, 8), GT_Utility.getIntegratedCircuit(5)}, null, CustomItemList.eM_dynamotunnel5_UHV.get(1), 16000, 2000000); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{getItemContainer("Hull_UEV").get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 16), ItemList.Emitter_UEV.get(16), ItemList.Electric_Pump_UEV.get(16), GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.Draconium, 8), GT_Utility.getIntegratedCircuit(5)}, null, CustomItemList.eM_dynamotunnel5_UEV.get(1), 16000, 8000000); + + //Laser Dynamo IV-UEV 262144/t + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_IV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 32), ItemList.Emitter_IV.get(32), ItemList.Electric_Pump_IV.get(32), GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.TungstenSteel, 16), GT_Utility.getIntegratedCircuit(6)}, null, CustomItemList.eM_dynamotunnel6_IV.get(1), 32000, 7680); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_LuV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 32), ItemList.Emitter_LuV.get(32), ItemList.Electric_Pump_LuV.get(32), GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.VanadiumGallium, 16), GT_Utility.getIntegratedCircuit(6)}, null, CustomItemList.eM_dynamotunnel6_LuV.get(1), 32000, 30720); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_ZPM.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 32), ItemList.Emitter_ZPM.get(32), ItemList.Electric_Pump_ZPM.get(32), GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.Naquadah, 16), GT_Utility.getIntegratedCircuit(6)}, null, CustomItemList.eM_dynamotunnel6_ZPM.get(1), 32000, 122880); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_UV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 32), ItemList.Emitter_UV.get(32), ItemList.Electric_Pump_UV.get(32), GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.NaquadahAlloy, 16), GT_Utility.getIntegratedCircuit(6)}, null, CustomItemList.eM_dynamotunnel6_UV.get(1), 32000, 500000); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_MAX.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 32), ItemList.Emitter_UHV.get(32), ItemList.Electric_Pump_UHV.get(32), GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.Bedrockium, 16), GT_Utility.getIntegratedCircuit(6)}, null, CustomItemList.eM_dynamotunnel6_UHV.get(1), 32000, 2000000); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{getItemContainer("Hull_UEV").get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 32), ItemList.Emitter_UEV.get(32), ItemList.Electric_Pump_UEV.get(32), GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.Draconium, 16), GT_Utility.getIntegratedCircuit(6)}, null, CustomItemList.eM_dynamotunnel6_UEV.get(1), 32000, 8000000); + + //Laser Dynamo IV-UEV 1048576/t + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_IV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 64), ItemList.Emitter_IV.get(64), ItemList.Electric_Pump_IV.get(64), GT_OreDictUnificator.get(OrePrefixes.wireGt16, Materials.TungstenSteel, 16), GT_Utility.getIntegratedCircuit(7)}, null, CustomItemList.eM_dynamotunnel7_IV.get(1), 64000, 7680); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_LuV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 64), ItemList.Emitter_LuV.get(64), ItemList.Electric_Pump_LuV.get(64), GT_OreDictUnificator.get(OrePrefixes.wireGt16, Materials.VanadiumGallium, 16), GT_Utility.getIntegratedCircuit(7)}, null, CustomItemList.eM_dynamotunnel7_LuV.get(1), 64000, 30720); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_ZPM.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 64), ItemList.Emitter_ZPM.get(64), ItemList.Electric_Pump_ZPM.get(64), GT_OreDictUnificator.get(OrePrefixes.wireGt16, Materials.Naquadah, 16), GT_Utility.getIntegratedCircuit(7)}, null, CustomItemList.eM_dynamotunnel7_ZPM.get(1), 64000, 122880); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_UV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 64), ItemList.Emitter_UV.get(64), ItemList.Electric_Pump_UV.get(64), GT_OreDictUnificator.get(OrePrefixes.wireGt16, Materials.NaquadahAlloy, 16), GT_Utility.getIntegratedCircuit(7)}, null, CustomItemList.eM_dynamotunnel7_UV.get(1), 64000, 500000); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_MAX.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 64), ItemList.Emitter_UHV.get(64), ItemList.Electric_Pump_UHV.get(64), GT_OreDictUnificator.get(OrePrefixes.wireGt16, Materials.Bedrockium, 16), GT_Utility.getIntegratedCircuit(7)}, null, CustomItemList.eM_dynamotunnel7_UHV.get(1), 64000, 2000000); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{getItemContainer("Hull_UEV").get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 64), ItemList.Emitter_UEV.get(64), ItemList.Electric_Pump_UEV.get(64), GT_OreDictUnificator.get(OrePrefixes.wireGt16, Materials.Draconium, 16), GT_Utility.getIntegratedCircuit(7)}, null, CustomItemList.eM_dynamotunnel7_UEV.get(1), 64000, 8000000); + + //Laser Target IV-UEV 256/t + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_IV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 1), ItemList.Sensor_IV.get(1), ItemList.Electric_Pump_IV.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.TungstenSteel, 2), GT_Utility.getIntegratedCircuit(1)}, null, CustomItemList.eM_energytunnel1_IV.get(1), 1000, 7680); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_LuV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 1), ItemList.Sensor_LuV.get(1), ItemList.Electric_Pump_LuV.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.VanadiumGallium, 2), GT_Utility.getIntegratedCircuit(1)}, null, CustomItemList.eM_energytunnel1_LuV.get(1), 1000, 30720); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_ZPM.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 1), ItemList.Sensor_ZPM.get(1), ItemList.Electric_Pump_ZPM.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.Naquadah, 2), GT_Utility.getIntegratedCircuit(1)}, null, CustomItemList.eM_energytunnel1_ZPM.get(1), 1000, 122880); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_UV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 1), ItemList.Sensor_UV.get(1), ItemList.Electric_Pump_UV.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.NaquadahAlloy, 2), GT_Utility.getIntegratedCircuit(1)}, null, CustomItemList.eM_energytunnel1_UV.get(1), 1000, 500000); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_MAX.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 1), ItemList.Sensor_UHV.get(1), ItemList.Electric_Pump_UHV.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.Bedrockium, 2), GT_Utility.getIntegratedCircuit(1)}, null, CustomItemList.eM_energytunnel1_UHV.get(1), 1000, 2000000); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{getItemContainer("Hull_UEV").get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 1), ItemList.Sensor_UEV.get(1), ItemList.Electric_Pump_UEV.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.Draconium, 2), GT_Utility.getIntegratedCircuit(1)}, null, CustomItemList.eM_energytunnel1_UEV.get(1), 1000, 8000000); + + //Laser Target IV-UEV 1024/t + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_IV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 2), ItemList.Sensor_IV.get(2), ItemList.Electric_Pump_IV.get(2), GT_OreDictUnificator.get(OrePrefixes.wireGt02, Materials.TungstenSteel, 4), GT_Utility.getIntegratedCircuit(2)}, null, CustomItemList.eM_energytunnel2_IV.get(1), 2000, 7680); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_LuV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 2), ItemList.Sensor_LuV.get(2), ItemList.Electric_Pump_LuV.get(2), GT_OreDictUnificator.get(OrePrefixes.wireGt02, Materials.VanadiumGallium, 4), GT_Utility.getIntegratedCircuit(2)}, null, CustomItemList.eM_energytunnel2_LuV.get(1), 2000, 30720); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_ZPM.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 2), ItemList.Sensor_ZPM.get(2), ItemList.Electric_Pump_ZPM.get(2), GT_OreDictUnificator.get(OrePrefixes.wireGt02, Materials.Naquadah, 4), GT_Utility.getIntegratedCircuit(2)}, null, CustomItemList.eM_energytunnel2_ZPM.get(1), 2000, 122880); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_UV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 2), ItemList.Sensor_UV.get(2), ItemList.Electric_Pump_UV.get(2), GT_OreDictUnificator.get(OrePrefixes.wireGt02, Materials.NaquadahAlloy, 4), GT_Utility.getIntegratedCircuit(2)}, null, CustomItemList.eM_energytunnel2_UV.get(1), 2000, 500000); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_MAX.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 2), ItemList.Sensor_UHV.get(2), ItemList.Electric_Pump_UHV.get(2), GT_OreDictUnificator.get(OrePrefixes.wireGt02, Materials.Bedrockium, 4), GT_Utility.getIntegratedCircuit(2)}, null, CustomItemList.eM_energytunnel2_UHV.get(1), 2000, 2000000); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{getItemContainer("Hull_UEV").get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 2), ItemList.Sensor_UEV.get(2), ItemList.Electric_Pump_UEV.get(2), GT_OreDictUnificator.get(OrePrefixes.wireGt02, Materials.Draconium, 4), GT_Utility.getIntegratedCircuit(2)}, null, CustomItemList.eM_energytunnel2_UEV.get(1), 2000, 8000000); + + //Laser Target IV-UEV 4096/t + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_IV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 4), ItemList.Sensor_IV.get(4), ItemList.Electric_Pump_IV.get(4), GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.TungstenSteel, 4), GT_Utility.getIntegratedCircuit(3)}, null, CustomItemList.eM_energytunnel3_IV.get(1), 4000, 7680); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_LuV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 4), ItemList.Sensor_LuV.get(4), ItemList.Electric_Pump_LuV.get(4), GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.VanadiumGallium, 4), GT_Utility.getIntegratedCircuit(3)}, null, CustomItemList.eM_energytunnel3_LuV.get(1), 4000, 30720); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_ZPM.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 4), ItemList.Sensor_ZPM.get(4), ItemList.Electric_Pump_ZPM.get(4), GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Naquadah, 4), GT_Utility.getIntegratedCircuit(3)}, null, CustomItemList.eM_energytunnel3_ZPM.get(1), 4000, 122880); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_UV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 4), ItemList.Sensor_UV.get(4), ItemList.Electric_Pump_UV.get(4), GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.NaquadahAlloy, 4), GT_Utility.getIntegratedCircuit(3)}, null, CustomItemList.eM_energytunnel3_UV.get(1), 4000, 500000); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_MAX.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 4), ItemList.Sensor_UHV.get(4), ItemList.Electric_Pump_UHV.get(4), GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Bedrockium, 4), GT_Utility.getIntegratedCircuit(3)}, null, CustomItemList.eM_energytunnel3_UHV.get(1), 4000, 2000000); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{getItemContainer("Hull_UEV").get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 4), ItemList.Sensor_UEV.get(4), ItemList.Electric_Pump_UEV.get(4), GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Draconium, 4), GT_Utility.getIntegratedCircuit(3)}, null, CustomItemList.eM_energytunnel3_UEV.get(1), 4000, 8000000); + + //Laser Target IV-UEV 16384/t + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_IV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 8), ItemList.Sensor_IV.get(8), ItemList.Electric_Pump_IV.get(8), GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.TungstenSteel, 8), GT_Utility.getIntegratedCircuit(4)}, null, CustomItemList.eM_energytunnel4_IV.get(1), 8000, 7680); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_LuV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 8), ItemList.Sensor_LuV.get(8), ItemList.Electric_Pump_LuV.get(8), GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.VanadiumGallium, 8), GT_Utility.getIntegratedCircuit(4)}, null, CustomItemList.eM_energytunnel4_LuV.get(1), 8000, 30720); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_ZPM.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 8), ItemList.Sensor_ZPM.get(8), ItemList.Electric_Pump_ZPM.get(8), GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Naquadah, 8), GT_Utility.getIntegratedCircuit(4)}, null, CustomItemList.eM_energytunnel4_ZPM.get(1), 8000, 122880); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_UV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 8), ItemList.Sensor_UV.get(8), ItemList.Electric_Pump_UV.get(8), GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.NaquadahAlloy, 8), GT_Utility.getIntegratedCircuit(4)}, null, CustomItemList.eM_energytunnel4_UV.get(1), 8000, 500000); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_MAX.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 8), ItemList.Sensor_UHV.get(8), ItemList.Electric_Pump_UHV.get(8), GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Bedrockium, 8), GT_Utility.getIntegratedCircuit(4)}, null, CustomItemList.eM_energytunnel4_UHV.get(1), 8000, 2000000); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{getItemContainer("Hull_UEV").get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 8), ItemList.Sensor_UEV.get(8), ItemList.Electric_Pump_UEV.get(8), GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Draconium, 8), GT_Utility.getIntegratedCircuit(4)}, null, CustomItemList.eM_energytunnel4_UEV.get(1), 8000, 8000000); + + //Laser Target IV-UEV 65536/t + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_IV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 16), ItemList.Sensor_IV.get(16), ItemList.Electric_Pump_IV.get(16), GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.TungstenSteel, 8), GT_Utility.getIntegratedCircuit(5)}, null, CustomItemList.eM_energytunnel5_IV.get(1), 16000, 7680); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_LuV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 16), ItemList.Sensor_LuV.get(16), ItemList.Electric_Pump_LuV.get(16), GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.VanadiumGallium, 8), GT_Utility.getIntegratedCircuit(5)}, null, CustomItemList.eM_energytunnel5_LuV.get(1), 16000, 30720); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_ZPM.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 16), ItemList.Sensor_ZPM.get(16), ItemList.Electric_Pump_ZPM.get(16), GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.Naquadah, 8), GT_Utility.getIntegratedCircuit(5)}, null, CustomItemList.eM_energytunnel5_ZPM.get(1), 16000, 122880); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_UV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 16), ItemList.Sensor_UV.get(16), ItemList.Electric_Pump_UV.get(16), GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.NaquadahAlloy, 8), GT_Utility.getIntegratedCircuit(5)}, null, CustomItemList.eM_energytunnel5_UV.get(1), 16000, 500000); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_MAX.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 16), ItemList.Sensor_UHV.get(16), ItemList.Electric_Pump_UHV.get(16), GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.Bedrockium, 8), GT_Utility.getIntegratedCircuit(5)}, null, CustomItemList.eM_energytunnel5_UHV.get(1), 16000, 2000000); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{getItemContainer("Hull_UEV").get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 16), ItemList.Sensor_UEV.get(16), ItemList.Electric_Pump_UEV.get(16), GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.Draconium, 8), GT_Utility.getIntegratedCircuit(5)}, null, CustomItemList.eM_energytunnel5_UEV.get(1), 16000, 8000000); + + //Laser Target IV-UEV 262144/t + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_IV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 32), ItemList.Sensor_IV.get(32), ItemList.Electric_Pump_IV.get(32), GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.TungstenSteel, 16), GT_Utility.getIntegratedCircuit(6)}, null, CustomItemList.eM_energytunnel6_IV.get(1), 32000, 7680); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_LuV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 32), ItemList.Sensor_LuV.get(32), ItemList.Electric_Pump_LuV.get(32), GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.VanadiumGallium, 16), GT_Utility.getIntegratedCircuit(6)}, null, CustomItemList.eM_energytunnel6_LuV.get(1), 32000, 30720); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_ZPM.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 32), ItemList.Sensor_ZPM.get(32), ItemList.Electric_Pump_ZPM.get(32), GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.Naquadah, 16), GT_Utility.getIntegratedCircuit(6)}, null, CustomItemList.eM_energytunnel6_ZPM.get(1), 32000, 122880); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_UV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 32), ItemList.Sensor_UV.get(32), ItemList.Electric_Pump_UV.get(32), GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.NaquadahAlloy, 16), GT_Utility.getIntegratedCircuit(6)}, null, CustomItemList.eM_energytunnel6_UV.get(1), 32000, 500000); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_MAX.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 32), ItemList.Sensor_UHV.get(32), ItemList.Electric_Pump_UHV.get(32), GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.Bedrockium, 16), GT_Utility.getIntegratedCircuit(6)}, null, CustomItemList.eM_energytunnel6_UHV.get(1), 32000, 2000000); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{getItemContainer("Hull_UEV").get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 32), ItemList.Sensor_UEV.get(32), ItemList.Electric_Pump_UEV.get(32), GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.Draconium, 16), GT_Utility.getIntegratedCircuit(6)}, null, CustomItemList.eM_energytunnel6_UEV.get(1), 32000, 8000000); + + //Laser Target IV-UEV 1048576/t + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_IV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 64), ItemList.Sensor_IV.get(64), ItemList.Electric_Pump_IV.get(64), GT_OreDictUnificator.get(OrePrefixes.wireGt16, Materials.TungstenSteel, 16), GT_Utility.getIntegratedCircuit(7)}, null, CustomItemList.eM_energytunnel7_IV.get(1), 64000, 7680); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_LuV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 64), ItemList.Sensor_LuV.get(64), ItemList.Electric_Pump_LuV.get(64), GT_OreDictUnificator.get(OrePrefixes.wireGt16, Materials.VanadiumGallium, 16), GT_Utility.getIntegratedCircuit(7)}, null, CustomItemList.eM_energytunnel7_LuV.get(1), 64000, 30720); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_ZPM.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 64), ItemList.Sensor_ZPM.get(64), ItemList.Electric_Pump_ZPM.get(64), GT_OreDictUnificator.get(OrePrefixes.wireGt16, Materials.Naquadah, 16), GT_Utility.getIntegratedCircuit(7)}, null, CustomItemList.eM_energytunnel7_ZPM.get(1), 64000, 122880); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_UV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 64), ItemList.Sensor_UV.get(64), ItemList.Electric_Pump_UV.get(64), GT_OreDictUnificator.get(OrePrefixes.wireGt16, Materials.NaquadahAlloy, 16), GT_Utility.getIntegratedCircuit(7)}, null, CustomItemList.eM_energytunnel7_UV.get(1), 64000, 500000); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_MAX.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 64), ItemList.Sensor_UHV.get(64), ItemList.Electric_Pump_UHV.get(64), GT_OreDictUnificator.get(OrePrefixes.wireGt16, Materials.Bedrockium, 16), GT_Utility.getIntegratedCircuit(7)}, null, CustomItemList.eM_energytunnel7_UHV.get(1), 64000, 2000000); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{getItemContainer("Hull_UEV").get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 64), ItemList.Sensor_UEV.get(64), ItemList.Electric_Pump_UEV.get(64), GT_OreDictUnificator.get(OrePrefixes.wireGt16, Materials.Draconium, 16), GT_Utility.getIntegratedCircuit(7)}, null, CustomItemList.eM_energytunnel7_UEV.get(1), 64000, 8000000); + //Data Input addAssemblerRecipeWithCleanroom(new ItemStack[]{ CustomItemList.eM_Computer_Casing.get(1), @@ -974,22 +1095,31 @@ public class DreamCraftRecipeLoader implements Runnable { } private void register_machine_EM_behaviours(){ - GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_Centrifuge(5),ItemList.Machine_IV_Centrifuge.get(1)); - GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_Centrifuge(6),getItemContainer("CentrifugeLuV").get(1)); - GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_Centrifuge(7),getItemContainer("CentrifugeZPM").get(1)); - GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_Centrifuge(8),getItemContainer("CentrifugeUV").get(1)); - GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_Centrifuge(9),getItemContainer("CentrifugeUHV").get(1)); - GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_Centrifuge(10),getItemContainer("CentrifugeUEV").get(1)); - GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_Centrifuge(11),getItemContainer("CentrifugeUIV").get(1)); - GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_Centrifuge(12),getItemContainer("CentrifugeUMV").get(1)); - - GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_ElectromagneticSeparator(5),ItemList.Machine_IV_ElectromagneticSeparator.get(1)); - GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_ElectromagneticSeparator(6),getItemContainer("ElectromagneticSeparatorLuV").get(1)); - GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_ElectromagneticSeparator(7),getItemContainer("ElectromagneticSeparatorZPM").get(1)); - GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_ElectromagneticSeparator(8),getItemContainer("ElectromagneticSeparatorUV").get(1)); - GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_ElectromagneticSeparator(9),getItemContainer("ElectromagneticSeparatorUHV").get(1)); - GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_ElectromagneticSeparator(10),getItemContainer("ElectromagneticSeparatorUEV").get(1)); - GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_ElectromagneticSeparator(11),getItemContainer("ElectromagneticSeparatorUIV").get(1)); - GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_ElectromagneticSeparator(12),getItemContainer("ElectromagneticSeparatorUMV").get(1)); + GT_MetaTileEntity_EM_machine.registerBehaviour(()->new Behaviour_Centrifuge(5),ItemList.Machine_IV_Centrifuge.get(1)); + GT_MetaTileEntity_EM_machine.registerBehaviour(()->new Behaviour_Centrifuge(6),getItemContainer("CentrifugeLuV").get(1)); + GT_MetaTileEntity_EM_machine.registerBehaviour(()->new Behaviour_Centrifuge(7),getItemContainer("CentrifugeZPM").get(1)); + GT_MetaTileEntity_EM_machine.registerBehaviour(()->new Behaviour_Centrifuge(8),getItemContainer("CentrifugeUV").get(1)); + GT_MetaTileEntity_EM_machine.registerBehaviour(()->new Behaviour_Centrifuge(9),getItemContainer("CentrifugeUHV").get(1)); + GT_MetaTileEntity_EM_machine.registerBehaviour(()->new Behaviour_Centrifuge(10),getItemContainer("CentrifugeUEV").get(1)); + GT_MetaTileEntity_EM_machine.registerBehaviour(()->new Behaviour_Centrifuge(11),getItemContainer("CentrifugeUIV").get(1)); + GT_MetaTileEntity_EM_machine.registerBehaviour(()->new Behaviour_Centrifuge(12),getItemContainer("CentrifugeUMV").get(1)); + + GT_MetaTileEntity_EM_machine.registerBehaviour(()->new Behaviour_ElectromagneticSeparator(5),ItemList.Machine_IV_ElectromagneticSeparator.get(1)); + GT_MetaTileEntity_EM_machine.registerBehaviour(()->new Behaviour_ElectromagneticSeparator(6),getItemContainer("ElectromagneticSeparatorLuV").get(1)); + GT_MetaTileEntity_EM_machine.registerBehaviour(()->new Behaviour_ElectromagneticSeparator(7),getItemContainer("ElectromagneticSeparatorZPM").get(1)); + GT_MetaTileEntity_EM_machine.registerBehaviour(()->new Behaviour_ElectromagneticSeparator(8),getItemContainer("ElectromagneticSeparatorUV").get(1)); + GT_MetaTileEntity_EM_machine.registerBehaviour(()->new Behaviour_ElectromagneticSeparator(9),getItemContainer("ElectromagneticSeparatorUHV").get(1)); + GT_MetaTileEntity_EM_machine.registerBehaviour(()->new Behaviour_ElectromagneticSeparator(10),getItemContainer("ElectromagneticSeparatorUEV").get(1)); + GT_MetaTileEntity_EM_machine.registerBehaviour(()->new Behaviour_ElectromagneticSeparator(11),getItemContainer("ElectromagneticSeparatorUIV").get(1)); + GT_MetaTileEntity_EM_machine.registerBehaviour(()->new Behaviour_ElectromagneticSeparator(12),getItemContainer("ElectromagneticSeparatorUMV").get(1)); + + GT_MetaTileEntity_EM_machine.registerBehaviour(()->new Behaviour_Recycler(5),ItemList.Machine_IV_Recycler.get(1)); + GT_MetaTileEntity_EM_machine.registerBehaviour(()->new Behaviour_Recycler(6),getItemContainer("RecyclerLuV").get(1)); + GT_MetaTileEntity_EM_machine.registerBehaviour(()->new Behaviour_Recycler(7),getItemContainer("RecyclerZPM").get(1)); + GT_MetaTileEntity_EM_machine.registerBehaviour(()->new Behaviour_Recycler(8),getItemContainer("RecyclerUV").get(1)); + GT_MetaTileEntity_EM_machine.registerBehaviour(()->new Behaviour_Recycler(9),getItemContainer("RecyclerUHV").get(1)); + GT_MetaTileEntity_EM_machine.registerBehaviour(()->new Behaviour_Recycler(10),getItemContainer("RecyclerUEV").get(1)); + GT_MetaTileEntity_EM_machine.registerBehaviour(()->new Behaviour_Recycler(11),getItemContainer("RecyclerUIV").get(1)); + GT_MetaTileEntity_EM_machine.registerBehaviour(()->new Behaviour_Recycler(12),getItemContainer("RecyclerUMV").get(1)); } } diff --git a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/elementalMatter/definitions/AspectDefinitionCompatEnabled.java b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/elementalMatter/definitions/AspectDefinitionCompatEnabled.java index 91523326db..da930a1d79 100644 --- a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/elementalMatter/definitions/AspectDefinitionCompatEnabled.java +++ b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/elementalMatter/definitions/AspectDefinitionCompatEnabled.java @@ -30,7 +30,7 @@ public final class AspectDefinitionCompatEnabled extends AspectDefinitionCompat aspectToDef.put("perditio",magic_entropy); ArrayList<Aspect> list=Aspect.getCompoundAspects(); - Aspect[] array= list.toArray(new Aspect[list.size()]); + Aspect[] array= list.toArray(new Aspect[0]); while (!list.isEmpty()) { for (Aspect aspect : array) { if (list.contains(aspect)) { diff --git a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_essentiaDequantizer.java b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_essentiaDequantizer.java index 84cd28b7c9..3d64ceee62 100644 --- a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_essentiaDequantizer.java +++ b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_essentiaDequantizer.java @@ -10,6 +10,7 @@ import com.github.technus.tectech.thing.casing.TT_Container_Casings; import com.github.technus.tectech.thing.metaTileEntity.IConstructable; import com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_quantizer; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.IHatchAdder; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; @@ -45,7 +46,10 @@ public class GT_MetaTileEntity_EM_essentiaDequantizer extends GT_MetaTileEntity_ }; private static final Block[] blockType = new Block[]{QuantumGlassBlock.INSTANCE, sBlockCasingsTT, sBlockCasingsTT, sBlockCasingsTT}; private static final byte[] blockMeta = new byte[]{0,0,4,8}; - private static final String[] addingMethods = new String[]{"addClassicToMachineList", "addElementalInputToMachineList", "addElementalMufflerToMachineList"}; + private final IHatchAdder[] addingMethods = new IHatchAdder[]{ + this::addClassicToMachineList, + this::addElementalInputToMachineList, + this::addElementalMufflerToMachineList}; private static final short[] casingTextures = new short[]{textureOffset, textureOffset + 4, textureOffset + 4}; private static final Block[] blockTypeFallback = new Block[]{sBlockCasingsTT, sBlockCasingsTT, sBlockCasingsTT}; private static final byte[] blockMetaFallback = new byte[]{0, 4, 4}; diff --git a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_essentiaQuantizer.java b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_essentiaQuantizer.java index d45060c758..9bd16c959b 100644 --- a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_essentiaQuantizer.java +++ b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_essentiaQuantizer.java @@ -10,6 +10,7 @@ import com.github.technus.tectech.thing.casing.TT_Container_Casings; import com.github.technus.tectech.thing.metaTileEntity.IConstructable; import com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_quantizer; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.IHatchAdder; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; @@ -45,7 +46,10 @@ public class GT_MetaTileEntity_EM_essentiaQuantizer extends GT_MetaTileEntity_Mu }; private static final Block[] blockType = new Block[]{QuantumGlassBlock.INSTANCE, sBlockCasingsTT, sBlockCasingsTT, sBlockCasingsTT}; private static final byte[] blockMeta = new byte[]{0,4,0,8}; - private static final String[] addingMethods = new String[]{"addClassicToMachineList", "addElementalOutputToMachineList", "addElementalMufflerToMachineList"}; + private final IHatchAdder[] addingMethods = new IHatchAdder[]{ + this::addClassicToMachineList, + this::addElementalOutputToMachineList, + this::addElementalMufflerToMachineList}; private static final short[] casingTextures = new short[]{textureOffset, textureOffset+4, textureOffset + 4}; private static final Block[] blockTypeFallback = new Block[]{sBlockCasingsTT, sBlockCasingsTT, sBlockCasingsTT}; private static final byte[] blockMetaFallback = new byte[]{0, 4, 4}; diff --git a/src/main/java/com/github/technus/tectech/entity/fx/WeightlessParticleFX.java b/src/main/java/com/github/technus/tectech/entity/fx/WeightlessParticleFX.java new file mode 100644 index 0000000000..22b72463f8 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/entity/fx/WeightlessParticleFX.java @@ -0,0 +1,51 @@ +package com.github.technus.tectech.entity.fx; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.particle.EntityFX; +import net.minecraft.world.World; + +@SideOnly(Side.CLIENT) +public class WeightlessParticleFX extends EntityFX +{ + private static final String __OBFID = "CL_00000903"; + + public WeightlessParticleFX(World p_i1205_1_, double p_i1205_2_, double p_i1205_4_, double p_i1205_6_, double p_i1205_8_, double p_i1205_10_, double p_i1205_12_) + { + super(p_i1205_1_, p_i1205_2_, p_i1205_4_, p_i1205_6_, p_i1205_8_, p_i1205_10_, p_i1205_12_); + this.motionX = p_i1205_8_ + (double)((float)(Math.random() * 2.0D - 1.0D) * 0.05F); + this.motionY = p_i1205_10_ + (double)((float)(Math.random() * 2.0D - 1.0D) * 0.05F); + this.motionZ = p_i1205_12_ + (double)((float)(Math.random() * 2.0D - 1.0D) * 0.05F); + this.particleRed = this.particleGreen = this.particleBlue = this.rand.nextFloat() * 0.3F + 0.7F; + this.particleScale = this.rand.nextFloat() * this.rand.nextFloat() * 6.0F + 1.0F; + this.particleMaxAge = (int)(16.0D / ((double)this.rand.nextFloat() * 0.8D + 0.2D)) + 2; + } + + /** + * Called to update the entity's position/logic. + */ + public void onUpdate() + { + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + + if (this.particleAge++ >= this.particleMaxAge) + { + this.setDead(); + } + + this.setParticleTextureIndex(7 - this.particleAge * 8 / this.particleMaxAge); + //this.motionY += 0.004D; + this.moveEntity(this.motionX, this.motionY, this.motionZ); + this.motionX *= 0.8999999761581421D; + this.motionY *= 0.8999999761581421D; + this.motionZ *= 0.8999999761581421D; + + if (this.onGround) + { + this.motionX *= 0.699999988079071D; + this.motionZ *= 0.699999988079071D; + } + } +} diff --git a/src/main/java/com/github/technus/tectech/loader/mechanics/ElementalLoader.java b/src/main/java/com/github/technus/tectech/loader/ElementalLoader.java index a2ea8c60de..130106a76b 100644 --- a/src/main/java/com/github/technus/tectech/loader/mechanics/ElementalLoader.java +++ b/src/main/java/com/github/technus/tectech/loader/ElementalLoader.java @@ -1,4 +1,4 @@ -package com.github.technus.tectech.loader.mechanics; +package com.github.technus.tectech.loader; import com.github.technus.tectech.compatibility.thaumcraft.elementalMatter.definitions.dComplexAspectDefinition; import com.github.technus.tectech.compatibility.thaumcraft.elementalMatter.definitions.ePrimalAspectDefinition; diff --git a/src/main/java/com/github/technus/tectech/loader/entity/EntityLoader.java b/src/main/java/com/github/technus/tectech/loader/EntityLoader.java index 209d7ccd39..b188989ba3 100644 --- a/src/main/java/com/github/technus/tectech/loader/entity/EntityLoader.java +++ b/src/main/java/com/github/technus/tectech/loader/EntityLoader.java @@ -1,4 +1,4 @@ -package com.github.technus.tectech.loader.entity; +package com.github.technus.tectech.loader; import com.github.technus.tectech.TecTech; import com.github.technus.tectech.compatibility.openmodularturrets.entity.projectiles.projectileEM; diff --git a/src/main/java/com/github/technus/tectech/loader/MainLoader.java b/src/main/java/com/github/technus/tectech/loader/MainLoader.java index de53fb225f..b45e8bd532 100644 --- a/src/main/java/com/github/technus/tectech/loader/MainLoader.java +++ b/src/main/java/com/github/technus/tectech/loader/MainLoader.java @@ -6,10 +6,8 @@ import com.github.technus.tectech.compatibility.thaumcraft.elementalMatter.defin import com.github.technus.tectech.compatibility.thaumcraft.elementalMatter.definitions.AspectDefinitionCompatEnabled; import com.github.technus.tectech.compatibility.thaumcraft.thing.metaTileEntity.multi.EssentiaCompat; import com.github.technus.tectech.compatibility.thaumcraft.thing.metaTileEntity.multi.EssentiaCompatEnabled; -import com.github.technus.tectech.loader.entity.EntityLoader; import com.github.technus.tectech.loader.gui.CreativeTabTecTech; import com.github.technus.tectech.loader.gui.ModGuiHandler; -import com.github.technus.tectech.loader.mechanics.ElementalLoader; import com.github.technus.tectech.loader.recipe.RecipeLoader; import com.github.technus.tectech.loader.thing.ComponentLoader; import com.github.technus.tectech.loader.thing.MachineLoader; @@ -17,7 +15,6 @@ import com.github.technus.tectech.loader.thing.ThingsLoader; import com.github.technus.tectech.thing.casing.TT_Container_Casings; import com.github.technus.tectech.thing.metaTileEntity.Textures; import com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_collider; -import com.github.technus.tectech.thing.metaTileEntity.multi.base.network.RotationPacketDispatcher; import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.ProgressManager; import cpw.mods.fml.common.network.NetworkRegistry; @@ -46,11 +43,10 @@ import static com.github.technus.tectech.compatibility.thaumcraft.elementalMatte import static com.github.technus.tectech.compatibility.thaumcraft.thing.metaTileEntity.multi.EssentiaCompat.essentiaContainerCompat; import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; import static com.github.technus.tectech.loader.gui.CreativeTabTecTech.creativeTabTecTech; -import static gregtech.api.enums.Dyes.*; import static gregtech.api.enums.GT_Values.W; public final class MainLoader { - public static DamageSource microwaving, elementalPollution; + public static DamageSource microwaving, elementalPollution,subspace; private MainLoader(){} @@ -103,10 +99,11 @@ public final class MainLoader { progressBarLoad.step("Add damage types"); microwaving =new DamageSource("microwaving").setDamageBypassesArmor(); elementalPollution =new DamageSource("elementalPollution").setDamageBypassesArmor(); + subspace =new DamageSource("subspace").setDamageBypassesArmor().setDamageIsAbsolute(); LOGGER.info("Damage types addition Done"); progressBarLoad.step("Register Packet Dispatcher"); - new RotationPacketDispatcher(); + new NetworkDispatcher(); LOGGER.info("Packet Dispatcher registered"); progressBarLoad.step("Register GUI Handler"); @@ -235,14 +232,11 @@ public final class MainLoader { } public static void addAfterGregTechPostLoadRunner() { - GregTech_API.sAfterGTPostload.add(new Runnable() { - @Override - public void run() { - if(TecTech.configTecTech.NERF_FUSION) { - FixBrokenFusionRecipes(); - } - GT_MetaTileEntity_EM_collider.setValues(getFuelValue(Materials.Helium.getPlasma(125))); + GregTech_API.sAfterGTPostload.add(() -> { + if(TecTech.configTecTech.NERF_FUSION) { + FixBrokenFusionRecipes(); } + GT_MetaTileEntity_EM_collider.setValues(getFuelValue(Materials.Helium.getPlasma(125))); }); } diff --git a/src/main/java/com/github/technus/tectech/loader/NetworkDispatcher.java b/src/main/java/com/github/technus/tectech/loader/NetworkDispatcher.java new file mode 100644 index 0000000000..0f20d31f4d --- /dev/null +++ b/src/main/java/com/github/technus/tectech/loader/NetworkDispatcher.java @@ -0,0 +1,30 @@ +package com.github.technus.tectech.loader; + +import com.github.technus.tectech.thing.metaTileEntity.pipe.PipeActivityMessage; +import com.github.technus.tectech.thing.metaTileEntity.RotationMessage; +import com.github.technus.tectech.mechanics.data.ChunkDataMessage; +import com.github.technus.tectech.mechanics.data.PlayerDataMessage; + +import static com.github.technus.tectech.Reference.MODID; + +public class NetworkDispatcher extends eu.usrv.yamcore.network.PacketDispatcher { + public static NetworkDispatcher INSTANCE; + + public NetworkDispatcher() { + super(MODID); + INSTANCE = this; + registerPackets(); + } + + @Override + public void registerPackets() { + registerMessage(PipeActivityMessage.ServerHandler.class, PipeActivityMessage.PipeActivityQuery.class); + registerMessage(PipeActivityMessage.ClientHandler.class, PipeActivityMessage.PipeActivityData.class); + registerMessage(RotationMessage.ServerHandler.class, RotationMessage.RotationQuery.class); + registerMessage(RotationMessage.ClientHandler.class, RotationMessage.RotationData.class); + registerMessage(ChunkDataMessage.ServerHandler.class, ChunkDataMessage.ChunkDataQuery.class); + registerMessage(ChunkDataMessage.ClientHandler.class, ChunkDataMessage.ChunkDataData.class); + registerMessage(PlayerDataMessage.ServerHandler.class, PlayerDataMessage.PlayerDataQuery.class); + registerMessage(PlayerDataMessage.ClientHandler.class, PlayerDataMessage.PlayerDataData.class); + } +} diff --git a/src/main/java/com/github/technus/tectech/loader/TecTechConfig.java b/src/main/java/com/github/technus/tectech/loader/TecTechConfig.java index 468a0c909a..e7eb0c0945 100644 --- a/src/main/java/com/github/technus/tectech/loader/TecTechConfig.java +++ b/src/main/java/com/github/technus/tectech/loader/TecTechConfig.java @@ -17,6 +17,7 @@ public class TecTechConfig extends ConfigManager { public boolean EASY_SCAN; public boolean NERF_FUSION; public boolean ENABLE_TURRET_EXPLOSIONS; + public boolean DISABLE_MATERIAL_LOADING_FFS; public float TURRET_DAMAGE_FACTOR; public float TURRET_EXPLOSION_FACTOR; @@ -30,6 +31,7 @@ public class TecTechConfig extends ConfigManager { BOOM_ENABLE = true; NERF_FUSION = false; ENABLE_TURRET_EXPLOSIONS = true; + DISABLE_MATERIAL_LOADING_FFS=false; TURRET_DAMAGE_FACTOR = 10; TURRET_EXPLOSION_FACTOR = 1; } @@ -56,6 +58,8 @@ public class TecTechConfig extends ConfigManager { "Damage is multiplied by this number"); TURRET_EXPLOSION_FACTOR = _mainConfig.getFloat("TurretExplosionFactor", "Features", TURRET_EXPLOSION_FACTOR, 0, Short.MAX_VALUE, "Explosion strength is multiplied by this number"); + DISABLE_MATERIAL_LOADING_FFS = _mainConfig.getBoolean("DisableMaterialLoading", "Debug", DISABLE_MATERIAL_LOADING_FFS, + "Set to true to disable gregtech material processing"); } /** diff --git a/src/main/java/com/github/technus/tectech/loader/recipe/BloodyRecipeLoader.java b/src/main/java/com/github/technus/tectech/loader/recipe/BloodyRecipeLoader.java index d37a4c886c..bfe015749c 100644 --- a/src/main/java/com/github/technus/tectech/loader/recipe/BloodyRecipeLoader.java +++ b/src/main/java/com/github/technus/tectech/loader/recipe/BloodyRecipeLoader.java @@ -5,6 +5,7 @@ import com.github.technus.tectech.thing.CustomItemList; import com.github.technus.tectech.thing.block.QuantumGlassBlock; import com.github.technus.tectech.thing.metaTileEntity.multi.em_machine.Behaviour_Centrifuge; import com.github.technus.tectech.thing.metaTileEntity.multi.em_machine.Behaviour_ElectromagneticSeparator; +import com.github.technus.tectech.thing.metaTileEntity.multi.em_machine.Behaviour_Recycler; import com.github.technus.tectech.thing.metaTileEntity.multi.em_machine.GT_MetaTileEntity_EM_machine; import gregtech.api.enums.GT_Values; import gregtech.api.enums.ItemList; @@ -12,6 +13,7 @@ import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Utility; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidRegistry; @@ -49,6 +51,13 @@ public class BloodyRecipeLoader implements Runnable { ItemList.Circuit_Quantummainframe.get(1) }, Materials.Osmium.getMolten(288), CustomItemList.EMpipe.get(1), 400, 491520); + //Laser + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ + CustomItemList.DATApipe.get(1), + GT_ModHandler.getIC2Item("reinforcedGlass", 1L), + GT_OreDictUnificator.get(OrePrefixes.foil, Materials.Osmium, 2) + }, null, CustomItemList.LASERpipe.get(1), 100, 500000); + //endregoin @@ -365,6 +374,90 @@ public class BloodyRecipeLoader implements Runnable { Materials.Tungsten.getMolten(4608), CustomItemList.eM_energymulti64_UEV.get(1), 400, 2000000); + //Laser Dynamo IV-UV 256/t + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_IV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 1), ItemList.Emitter_IV.get(1), ItemList.Electric_Pump_IV.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.TungstenSteel, 2), GT_Utility.getIntegratedCircuit(1)}, null, CustomItemList.eM_dynamotunnel1_IV.get(1), 1000, 7680); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_LuV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 1), ItemList.Emitter_LuV.get(1), ItemList.Electric_Pump_LuV.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.VanadiumGallium, 2), GT_Utility.getIntegratedCircuit(1)}, null, CustomItemList.eM_dynamotunnel1_LuV.get(1), 1000, 30720); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_ZPM.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 1), ItemList.Emitter_ZPM.get(1), ItemList.Electric_Pump_ZPM.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.Naquadah, 2), GT_Utility.getIntegratedCircuit(1)}, null, CustomItemList.eM_dynamotunnel1_ZPM.get(1), 1000, 122880); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_UV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 1), ItemList.Emitter_UV.get(1), ItemList.Electric_Pump_UV.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.NaquadahAlloy, 2), GT_Utility.getIntegratedCircuit(1)}, null, CustomItemList.eM_dynamotunnel1_UV.get(1), 1000, 500000); + + //Laser Dynamo IV-UV 1024/t + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_IV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 2), ItemList.Emitter_IV.get(2), ItemList.Electric_Pump_IV.get(2), GT_OreDictUnificator.get(OrePrefixes.wireGt02, Materials.TungstenSteel, 4), GT_Utility.getIntegratedCircuit(2)}, null, CustomItemList.eM_dynamotunnel2_IV.get(1), 2000, 7680); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_LuV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 2), ItemList.Emitter_LuV.get(2), ItemList.Electric_Pump_LuV.get(2), GT_OreDictUnificator.get(OrePrefixes.wireGt02, Materials.VanadiumGallium, 4), GT_Utility.getIntegratedCircuit(2)}, null, CustomItemList.eM_dynamotunnel2_LuV.get(1), 2000, 30720); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_ZPM.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 2), ItemList.Emitter_ZPM.get(2), ItemList.Electric_Pump_ZPM.get(2), GT_OreDictUnificator.get(OrePrefixes.wireGt02, Materials.Naquadah, 4), GT_Utility.getIntegratedCircuit(2)}, null, CustomItemList.eM_dynamotunnel2_ZPM.get(1), 2000, 122880); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_UV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 2), ItemList.Emitter_UV.get(2), ItemList.Electric_Pump_UV.get(2), GT_OreDictUnificator.get(OrePrefixes.wireGt02, Materials.NaquadahAlloy, 4), GT_Utility.getIntegratedCircuit(2)}, null, CustomItemList.eM_dynamotunnel2_UV.get(1), 2000, 500000); + + //Laser Dynamo IV-UV 4096/t + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_IV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 4), ItemList.Emitter_IV.get(4), ItemList.Electric_Pump_IV.get(4), GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.TungstenSteel, 4), GT_Utility.getIntegratedCircuit(3)}, null, CustomItemList.eM_dynamotunnel3_IV.get(1), 4000, 7680); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_LuV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 4), ItemList.Emitter_LuV.get(4), ItemList.Electric_Pump_LuV.get(4), GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.VanadiumGallium, 4), GT_Utility.getIntegratedCircuit(3)}, null, CustomItemList.eM_dynamotunnel3_LuV.get(1), 4000, 30720); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_ZPM.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 4), ItemList.Emitter_ZPM.get(4), ItemList.Electric_Pump_ZPM.get(4), GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Naquadah, 4), GT_Utility.getIntegratedCircuit(3)}, null, CustomItemList.eM_dynamotunnel3_ZPM.get(1), 4000, 122880); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_UV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 4), ItemList.Emitter_UV.get(4), ItemList.Electric_Pump_UV.get(4), GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.NaquadahAlloy, 4), GT_Utility.getIntegratedCircuit(3)}, null, CustomItemList.eM_dynamotunnel3_UV.get(1), 4000, 500000); + + //Laser Dynamo IV-UV 16384/t + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_IV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 8), ItemList.Emitter_IV.get(8), ItemList.Electric_Pump_IV.get(8), GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.TungstenSteel, 8), GT_Utility.getIntegratedCircuit(4)}, null, CustomItemList.eM_dynamotunnel4_IV.get(1), 8000, 7680); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_LuV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 8), ItemList.Emitter_LuV.get(8), ItemList.Electric_Pump_LuV.get(8), GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.VanadiumGallium, 8), GT_Utility.getIntegratedCircuit(4)}, null, CustomItemList.eM_dynamotunnel4_LuV.get(1), 8000, 30720); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_ZPM.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 8), ItemList.Emitter_ZPM.get(8), ItemList.Electric_Pump_ZPM.get(8), GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Naquadah, 8), GT_Utility.getIntegratedCircuit(4)}, null, CustomItemList.eM_dynamotunnel4_ZPM.get(1), 8000, 122880); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_UV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 8), ItemList.Emitter_UV.get(8), ItemList.Electric_Pump_UV.get(8), GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.NaquadahAlloy, 8), GT_Utility.getIntegratedCircuit(4)}, null, CustomItemList.eM_dynamotunnel4_UV.get(1), 8000, 500000); + + //Laser Dynamo IV-UV 65536/t + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_IV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 16), ItemList.Emitter_IV.get(16), ItemList.Electric_Pump_IV.get(16), GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.TungstenSteel, 8), GT_Utility.getIntegratedCircuit(5)}, null, CustomItemList.eM_dynamotunnel5_IV.get(1), 16000, 7680); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_LuV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 16), ItemList.Emitter_LuV.get(16), ItemList.Electric_Pump_LuV.get(16), GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.VanadiumGallium, 8), GT_Utility.getIntegratedCircuit(5)}, null, CustomItemList.eM_dynamotunnel5_LuV.get(1), 16000, 30720); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_ZPM.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 16), ItemList.Emitter_ZPM.get(16), ItemList.Electric_Pump_ZPM.get(16), GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.Naquadah, 8), GT_Utility.getIntegratedCircuit(5)}, null, CustomItemList.eM_dynamotunnel5_ZPM.get(1), 16000, 122880); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_UV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 16), ItemList.Emitter_UV.get(16), ItemList.Electric_Pump_UV.get(16), GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.NaquadahAlloy, 8), GT_Utility.getIntegratedCircuit(5)}, null, CustomItemList.eM_dynamotunnel5_UV.get(1), 16000, 500000); + + //Laser Dynamo IV-UV 262144/t + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_IV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 32), ItemList.Emitter_IV.get(32), ItemList.Electric_Pump_IV.get(32), GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.TungstenSteel, 16), GT_Utility.getIntegratedCircuit(6)}, null, CustomItemList.eM_dynamotunnel6_IV.get(1), 32000, 7680); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_LuV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 32), ItemList.Emitter_LuV.get(32), ItemList.Electric_Pump_LuV.get(32), GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.VanadiumGallium, 16), GT_Utility.getIntegratedCircuit(6)}, null, CustomItemList.eM_dynamotunnel6_LuV.get(1), 32000, 30720); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_ZPM.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 32), ItemList.Emitter_ZPM.get(32), ItemList.Electric_Pump_ZPM.get(32), GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.Naquadah, 16), GT_Utility.getIntegratedCircuit(6)}, null, CustomItemList.eM_dynamotunnel6_ZPM.get(1), 32000, 122880); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_UV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 32), ItemList.Emitter_UV.get(32), ItemList.Electric_Pump_UV.get(32), GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.NaquadahAlloy, 16), GT_Utility.getIntegratedCircuit(6)}, null, CustomItemList.eM_dynamotunnel6_UV.get(1), 32000, 500000); + + //Laser Dynamo IV-UV 1048576/t + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_IV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 64), ItemList.Emitter_IV.get(64), ItemList.Electric_Pump_IV.get(64), GT_OreDictUnificator.get(OrePrefixes.wireGt16, Materials.TungstenSteel, 16), GT_Utility.getIntegratedCircuit(7)}, null, CustomItemList.eM_dynamotunnel7_IV.get(1), 64000, 7680); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_LuV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 64), ItemList.Emitter_LuV.get(64), ItemList.Electric_Pump_LuV.get(64), GT_OreDictUnificator.get(OrePrefixes.wireGt16, Materials.VanadiumGallium, 16), GT_Utility.getIntegratedCircuit(7)}, null, CustomItemList.eM_dynamotunnel7_LuV.get(1), 64000, 30720); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_ZPM.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 64), ItemList.Emitter_ZPM.get(64), ItemList.Electric_Pump_ZPM.get(64), GT_OreDictUnificator.get(OrePrefixes.wireGt16, Materials.Naquadah, 16), GT_Utility.getIntegratedCircuit(7)}, null, CustomItemList.eM_dynamotunnel7_ZPM.get(1), 64000, 122880); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_UV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 64), ItemList.Emitter_UV.get(64), ItemList.Electric_Pump_UV.get(64), GT_OreDictUnificator.get(OrePrefixes.wireGt16, Materials.NaquadahAlloy, 16), GT_Utility.getIntegratedCircuit(7)}, null, CustomItemList.eM_dynamotunnel7_UV.get(1), 64000, 500000); + + //Laser Target IV-UV 256/t + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_IV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 1), ItemList.Sensor_IV.get(1), ItemList.Electric_Pump_IV.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.TungstenSteel, 2), GT_Utility.getIntegratedCircuit(1)}, null, CustomItemList.eM_energytunnel1_IV.get(1), 1000, 7680); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_LuV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 1), ItemList.Sensor_LuV.get(1), ItemList.Electric_Pump_LuV.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.VanadiumGallium, 2), GT_Utility.getIntegratedCircuit(1)}, null, CustomItemList.eM_energytunnel1_LuV.get(1), 1000, 30720); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_ZPM.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 1), ItemList.Sensor_ZPM.get(1), ItemList.Electric_Pump_ZPM.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.Naquadah, 2), GT_Utility.getIntegratedCircuit(1)}, null, CustomItemList.eM_energytunnel1_ZPM.get(1), 1000, 122880); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_UV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 1), ItemList.Sensor_UV.get(1), ItemList.Electric_Pump_UV.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.NaquadahAlloy, 2), GT_Utility.getIntegratedCircuit(1)}, null, CustomItemList.eM_energytunnel1_UV.get(1), 1000, 500000); + + //Laser Target IV-UV 1024/t + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_IV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 2), ItemList.Sensor_IV.get(2), ItemList.Electric_Pump_IV.get(2), GT_OreDictUnificator.get(OrePrefixes.wireGt02, Materials.TungstenSteel, 4), GT_Utility.getIntegratedCircuit(2)}, null, CustomItemList.eM_energytunnel2_IV.get(1), 2000, 7680); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_LuV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 2), ItemList.Sensor_LuV.get(2), ItemList.Electric_Pump_LuV.get(2), GT_OreDictUnificator.get(OrePrefixes.wireGt02, Materials.VanadiumGallium, 4), GT_Utility.getIntegratedCircuit(2)}, null, CustomItemList.eM_energytunnel2_LuV.get(1), 2000, 30720); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_ZPM.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 2), ItemList.Sensor_ZPM.get(2), ItemList.Electric_Pump_ZPM.get(2), GT_OreDictUnificator.get(OrePrefixes.wireGt02, Materials.Naquadah, 4), GT_Utility.getIntegratedCircuit(2)}, null, CustomItemList.eM_energytunnel2_ZPM.get(1), 2000, 122880); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_UV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 2), ItemList.Sensor_UV.get(2), ItemList.Electric_Pump_UV.get(2), GT_OreDictUnificator.get(OrePrefixes.wireGt02, Materials.NaquadahAlloy, 4), GT_Utility.getIntegratedCircuit(2)}, null, CustomItemList.eM_energytunnel2_UV.get(1), 2000, 500000); + + //Laser Target IV-UV 4096/t + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_IV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 4), ItemList.Sensor_IV.get(4), ItemList.Electric_Pump_IV.get(4), GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.TungstenSteel, 4), GT_Utility.getIntegratedCircuit(3)}, null, CustomItemList.eM_energytunnel3_IV.get(1), 4000, 7680); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_LuV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 4), ItemList.Sensor_LuV.get(4), ItemList.Electric_Pump_LuV.get(4), GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.VanadiumGallium, 4), GT_Utility.getIntegratedCircuit(3)}, null, CustomItemList.eM_energytunnel3_LuV.get(1), 4000, 30720); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_ZPM.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 4), ItemList.Sensor_ZPM.get(4), ItemList.Electric_Pump_ZPM.get(4), GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Naquadah, 4), GT_Utility.getIntegratedCircuit(3)}, null, CustomItemList.eM_energytunnel3_ZPM.get(1), 4000, 122880); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_UV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 4), ItemList.Sensor_UV.get(4), ItemList.Electric_Pump_UV.get(4), GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.NaquadahAlloy, 4), GT_Utility.getIntegratedCircuit(3)}, null, CustomItemList.eM_energytunnel3_UV.get(1), 4000, 500000); + + //Laser Target IV-UV 16384/t + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_IV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 8), ItemList.Sensor_IV.get(8), ItemList.Electric_Pump_IV.get(8), GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.TungstenSteel, 8), GT_Utility.getIntegratedCircuit(4)}, null, CustomItemList.eM_energytunnel4_IV.get(1), 8000, 7680); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_LuV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 8), ItemList.Sensor_LuV.get(8), ItemList.Electric_Pump_LuV.get(8), GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.VanadiumGallium, 8), GT_Utility.getIntegratedCircuit(4)}, null, CustomItemList.eM_energytunnel4_LuV.get(1), 8000, 30720); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_ZPM.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 8), ItemList.Sensor_ZPM.get(8), ItemList.Electric_Pump_ZPM.get(8), GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Naquadah, 8), GT_Utility.getIntegratedCircuit(4)}, null, CustomItemList.eM_energytunnel4_ZPM.get(1), 8000, 122880); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_UV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 8), ItemList.Sensor_UV.get(8), ItemList.Electric_Pump_UV.get(8), GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.NaquadahAlloy, 8), GT_Utility.getIntegratedCircuit(4)}, null, CustomItemList.eM_energytunnel4_UV.get(1), 8000, 500000); + + //Laser Target IV-UV 65536/t + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_IV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 16), ItemList.Sensor_IV.get(16), ItemList.Electric_Pump_IV.get(16), GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.TungstenSteel, 8), GT_Utility.getIntegratedCircuit(5)}, null, CustomItemList.eM_energytunnel5_IV.get(1), 16000, 7680); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_LuV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 16), ItemList.Sensor_LuV.get(16), ItemList.Electric_Pump_LuV.get(16), GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.VanadiumGallium, 8), GT_Utility.getIntegratedCircuit(5)}, null, CustomItemList.eM_energytunnel5_LuV.get(1), 16000, 30720); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_ZPM.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 16), ItemList.Sensor_ZPM.get(16), ItemList.Electric_Pump_ZPM.get(16), GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.Naquadah, 8), GT_Utility.getIntegratedCircuit(5)}, null, CustomItemList.eM_energytunnel5_ZPM.get(1), 16000, 122880); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_UV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 16), ItemList.Sensor_UV.get(16), ItemList.Electric_Pump_UV.get(16), GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.NaquadahAlloy, 8), GT_Utility.getIntegratedCircuit(5)}, null, CustomItemList.eM_energytunnel5_UV.get(1), 16000, 500000); + + //Laser Target IV-UV 262144/t + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_IV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 32), ItemList.Sensor_IV.get(32), ItemList.Electric_Pump_IV.get(32), GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.TungstenSteel, 16), GT_Utility.getIntegratedCircuit(6)}, null, CustomItemList.eM_energytunnel6_IV.get(1), 32000, 7680); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_LuV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 32), ItemList.Sensor_LuV.get(32), ItemList.Electric_Pump_LuV.get(32), GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.VanadiumGallium, 16), GT_Utility.getIntegratedCircuit(6)}, null, CustomItemList.eM_energytunnel6_LuV.get(1), 32000, 30720); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_ZPM.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 32), ItemList.Sensor_ZPM.get(32), ItemList.Electric_Pump_ZPM.get(32), GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.Naquadah, 16), GT_Utility.getIntegratedCircuit(6)}, null, CustomItemList.eM_energytunnel6_ZPM.get(1), 32000, 122880); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_UV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 32), ItemList.Sensor_UV.get(32), ItemList.Electric_Pump_UV.get(32), GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.NaquadahAlloy, 16), GT_Utility.getIntegratedCircuit(6)}, null, CustomItemList.eM_energytunnel6_UV.get(1), 32000, 500000); + + //Laser Target IV-UV 1048576/t + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_IV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 64), ItemList.Sensor_IV.get(64), ItemList.Electric_Pump_IV.get(64), GT_OreDictUnificator.get(OrePrefixes.wireGt16, Materials.TungstenSteel, 16), GT_Utility.getIntegratedCircuit(7)}, null, CustomItemList.eM_energytunnel7_IV.get(1), 64000, 7680); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_LuV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 64), ItemList.Sensor_LuV.get(64), ItemList.Electric_Pump_LuV.get(64), GT_OreDictUnificator.get(OrePrefixes.wireGt16, Materials.VanadiumGallium, 16), GT_Utility.getIntegratedCircuit(7)}, null, CustomItemList.eM_energytunnel7_LuV.get(1), 64000, 30720); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_ZPM.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 64), ItemList.Sensor_ZPM.get(64), ItemList.Electric_Pump_ZPM.get(64), GT_OreDictUnificator.get(OrePrefixes.wireGt16, Materials.Naquadah, 16), GT_Utility.getIntegratedCircuit(7)}, null, CustomItemList.eM_energytunnel7_ZPM.get(1), 64000, 122880); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hull_UV.get(1), GT_OreDictUnificator.get(OrePrefixes.lens, Materials.Diamond, 64), ItemList.Sensor_UV.get(64), ItemList.Electric_Pump_UV.get(64), GT_OreDictUnificator.get(OrePrefixes.wireGt16, Materials.NaquadahAlloy, 16), GT_Utility.getIntegratedCircuit(7)}, null, CustomItemList.eM_energytunnel7_UV.get(1), 64000, 500000); + //Data Input GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ CustomItemList.eM_Computer_Casing.get(1), @@ -627,38 +720,61 @@ public class BloodyRecipeLoader implements Runnable { } private void register_machine_EM_behaviours(){ - GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_Centrifuge(6),ItemList.Machine_IV_Centrifuge.get(1)); + GT_MetaTileEntity_EM_machine.registerBehaviour(()->new Behaviour_Centrifuge(5),ItemList.Machine_IV_Centrifuge.get(1)); + try { + GT_MetaTileEntity_EM_machine.registerBehaviour(()->new Behaviour_Centrifuge(6),ItemList.valueOf("Machine_LuV_Centrifuge").get(1)); + GT_MetaTileEntity_EM_machine.registerBehaviour(()->new Behaviour_Centrifuge(7),ItemList.valueOf("Machine_ZPM_Centrifuge").get(1)); + GT_MetaTileEntity_EM_machine.registerBehaviour(()->new Behaviour_Centrifuge(8),ItemList.valueOf("Machine_UV_Centrifuge").get(1)); + GT_MetaTileEntity_EM_machine.registerBehaviour(()->new Behaviour_Centrifuge(9),ItemList.valueOf("Machine_UV_Centrifuge").get(4)); + GT_MetaTileEntity_EM_machine.registerBehaviour(()->new Behaviour_Centrifuge(10),ItemList.valueOf("Machine_UV_Centrifuge").get(16)); + GT_MetaTileEntity_EM_machine.registerBehaviour(()->new Behaviour_Centrifuge(11),ItemList.valueOf("Machine_UV_Centrifuge").get(40)); + GT_MetaTileEntity_EM_machine.registerBehaviour(()->new Behaviour_Centrifuge(12),ItemList.valueOf("Machine_UV_Centrifuge").get(64)); + }catch (IllegalArgumentException|NullPointerException e){ + GT_MetaTileEntity_EM_machine.registerBehaviour(()->new Behaviour_Centrifuge(6),ItemList.Machine_IV_Centrifuge.get(2)); + GT_MetaTileEntity_EM_machine.registerBehaviour(()->new Behaviour_Centrifuge(7),ItemList.Machine_IV_Centrifuge.get(4)); + GT_MetaTileEntity_EM_machine.registerBehaviour(()->new Behaviour_Centrifuge(8),ItemList.Machine_IV_Centrifuge.get(8)); + GT_MetaTileEntity_EM_machine.registerBehaviour(()->new Behaviour_Centrifuge(9),ItemList.Machine_IV_Centrifuge.get(16)); + GT_MetaTileEntity_EM_machine.registerBehaviour(()->new Behaviour_Centrifuge(10),ItemList.Machine_IV_Centrifuge.get(32)); + GT_MetaTileEntity_EM_machine.registerBehaviour(()->new Behaviour_Centrifuge(11),ItemList.Machine_IV_Centrifuge.get(48)); + GT_MetaTileEntity_EM_machine.registerBehaviour(()->new Behaviour_Centrifuge(12),ItemList.Machine_IV_Centrifuge.get(64)); + } + + GT_MetaTileEntity_EM_machine.registerBehaviour(()->new Behaviour_ElectromagneticSeparator(5),ItemList.Machine_IV_ElectromagneticSeparator.get(1)); try { - GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_Centrifuge(7),ItemList.valueOf("Machine_LuV_Centrifuge").get(1)); - GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_Centrifuge(8),ItemList.valueOf("Machine_ZPM_Centrifuge").get(1)); - GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_Centrifuge(9),ItemList.valueOf("Machine_UV_Centrifuge").get(1)); - GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_Centrifuge(10),ItemList.valueOf("Machine_UV_Centrifuge").get(4)); - GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_Centrifuge(11),ItemList.valueOf("Machine_UV_Centrifuge").get(16)); - GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_Centrifuge(12),ItemList.valueOf("Machine_UV_Centrifuge").get(64)); + GT_MetaTileEntity_EM_machine.registerBehaviour(()->new Behaviour_ElectromagneticSeparator(6),ItemList.valueOf("Machine_LuV_ElectromagneticSeparator").get(1)); + GT_MetaTileEntity_EM_machine.registerBehaviour(()->new Behaviour_ElectromagneticSeparator(7),ItemList.valueOf("Machine_ZPM_ElectromagneticSeparator").get(1)); + GT_MetaTileEntity_EM_machine.registerBehaviour(()->new Behaviour_ElectromagneticSeparator(8),ItemList.valueOf("Machine_UV_ElectromagneticSeparator").get(1)); + GT_MetaTileEntity_EM_machine.registerBehaviour(()->new Behaviour_ElectromagneticSeparator(9),ItemList.valueOf("Machine_UV_ElectromagneticSeparator").get(4)); + GT_MetaTileEntity_EM_machine.registerBehaviour(()->new Behaviour_ElectromagneticSeparator(10),ItemList.valueOf("Machine_UV_ElectromagneticSeparator").get(16)); + GT_MetaTileEntity_EM_machine.registerBehaviour(()->new Behaviour_ElectromagneticSeparator(11),ItemList.valueOf("Machine_UV_ElectromagneticSeparator").get(40)); + GT_MetaTileEntity_EM_machine.registerBehaviour(()->new Behaviour_ElectromagneticSeparator(12),ItemList.valueOf("Machine_UV_ElectromagneticSeparator").get(64)); }catch (IllegalArgumentException|NullPointerException e){ - GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_Centrifuge(7),ItemList.Machine_IV_Centrifuge.get(2)); - GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_Centrifuge(8),ItemList.Machine_IV_Centrifuge.get(4)); - GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_Centrifuge(9),ItemList.Machine_IV_Centrifuge.get(8)); - GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_Centrifuge(10),ItemList.Machine_IV_Centrifuge.get(16)); - GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_Centrifuge(11),ItemList.Machine_IV_Centrifuge.get(32)); - GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_Centrifuge(12),ItemList.Machine_IV_Centrifuge.get(64)); + GT_MetaTileEntity_EM_machine.registerBehaviour(()->new Behaviour_ElectromagneticSeparator(6),ItemList.Machine_IV_ElectromagneticSeparator.get(2)); + GT_MetaTileEntity_EM_machine.registerBehaviour(()->new Behaviour_ElectromagneticSeparator(7),ItemList.Machine_IV_ElectromagneticSeparator.get(4)); + GT_MetaTileEntity_EM_machine.registerBehaviour(()->new Behaviour_ElectromagneticSeparator(8),ItemList.Machine_IV_ElectromagneticSeparator.get(8)); + GT_MetaTileEntity_EM_machine.registerBehaviour(()->new Behaviour_ElectromagneticSeparator(9),ItemList.Machine_IV_ElectromagneticSeparator.get(16)); + GT_MetaTileEntity_EM_machine.registerBehaviour(()->new Behaviour_ElectromagneticSeparator(10),ItemList.Machine_IV_ElectromagneticSeparator.get(32)); + GT_MetaTileEntity_EM_machine.registerBehaviour(()->new Behaviour_ElectromagneticSeparator(11),ItemList.Machine_IV_ElectromagneticSeparator.get(48)); + GT_MetaTileEntity_EM_machine.registerBehaviour(()->new Behaviour_ElectromagneticSeparator(12),ItemList.Machine_IV_ElectromagneticSeparator.get(64)); } - GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_ElectromagneticSeparator(6),ItemList.Machine_IV_ElectromagneticSeparator.get(1)); + GT_MetaTileEntity_EM_machine.registerBehaviour(()->new Behaviour_Recycler(5),ItemList.Machine_IV_Recycler.get(1)); try { - GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_ElectromagneticSeparator(7),ItemList.valueOf("Machine_LuV_ElectromagneticSeparator").get(1)); - GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_ElectromagneticSeparator(8),ItemList.valueOf("Machine_ZPM_ElectromagneticSeparator").get(1)); - GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_ElectromagneticSeparator(9),ItemList.valueOf("Machine_UV_ElectromagneticSeparator").get(1)); - GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_ElectromagneticSeparator(10),ItemList.valueOf("Machine_UV_ElectromagneticSeparator").get(4)); - GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_ElectromagneticSeparator(11),ItemList.valueOf("Machine_UV_ElectromagneticSeparator").get(16)); - GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_ElectromagneticSeparator(12),ItemList.valueOf("Machine_UV_ElectromagneticSeparator").get(64)); + GT_MetaTileEntity_EM_machine.registerBehaviour(()->new Behaviour_Recycler(6),ItemList.valueOf("Machine_LuV_Recycler").get(1)); + GT_MetaTileEntity_EM_machine.registerBehaviour(()->new Behaviour_Recycler(7),ItemList.valueOf("Machine_ZPM_Recycler").get(1)); + GT_MetaTileEntity_EM_machine.registerBehaviour(()->new Behaviour_Recycler(8),ItemList.valueOf("Machine_UV_Recycler").get(1)); + GT_MetaTileEntity_EM_machine.registerBehaviour(()->new Behaviour_Recycler(9),ItemList.valueOf("Machine_UV_Recycler").get(4)); + GT_MetaTileEntity_EM_machine.registerBehaviour(()->new Behaviour_Recycler(10),ItemList.valueOf("Machine_UV_Recycler").get(16)); + GT_MetaTileEntity_EM_machine.registerBehaviour(()->new Behaviour_Recycler(11),ItemList.valueOf("Machine_UV_Recycler").get(40)); + GT_MetaTileEntity_EM_machine.registerBehaviour(()->new Behaviour_Recycler(12),ItemList.valueOf("Machine_UV_Recycler").get(64)); }catch (IllegalArgumentException|NullPointerException e){ - GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_ElectromagneticSeparator(7),ItemList.Machine_IV_ElectromagneticSeparator.get(2)); - GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_ElectromagneticSeparator(8),ItemList.Machine_IV_ElectromagneticSeparator.get(4)); - GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_ElectromagneticSeparator(9),ItemList.Machine_IV_ElectromagneticSeparator.get(8)); - GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_ElectromagneticSeparator(10),ItemList.Machine_IV_ElectromagneticSeparator.get(16)); - GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_ElectromagneticSeparator(11),ItemList.Machine_IV_ElectromagneticSeparator.get(32)); - GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_ElectromagneticSeparator(12),ItemList.Machine_IV_ElectromagneticSeparator.get(64)); + GT_MetaTileEntity_EM_machine.registerBehaviour(()->new Behaviour_Recycler(6),ItemList.Machine_IV_Recycler.get(2)); + GT_MetaTileEntity_EM_machine.registerBehaviour(()->new Behaviour_Recycler(7),ItemList.Machine_IV_Recycler.get(4)); + GT_MetaTileEntity_EM_machine.registerBehaviour(()->new Behaviour_Recycler(8),ItemList.Machine_IV_Recycler.get(8)); + GT_MetaTileEntity_EM_machine.registerBehaviour(()->new Behaviour_Recycler(9),ItemList.Machine_IV_Recycler.get(16)); + GT_MetaTileEntity_EM_machine.registerBehaviour(()->new Behaviour_Recycler(10),ItemList.Machine_IV_Recycler.get(32)); + GT_MetaTileEntity_EM_machine.registerBehaviour(()->new Behaviour_Recycler(11),ItemList.Machine_IV_Recycler.get(48)); + GT_MetaTileEntity_EM_machine.registerBehaviour(()->new Behaviour_Recycler(12),ItemList.Machine_IV_Recycler.get(64)); } } } diff --git a/src/main/java/com/github/technus/tectech/loader/thing/MachineLoader.java b/src/main/java/com/github/technus/tectech/loader/thing/MachineLoader.java index 022f7cec20..e9fe5cfb19 100644 --- a/src/main/java/com/github/technus/tectech/loader/thing/MachineLoader.java +++ b/src/main/java/com/github/technus/tectech/loader/thing/MachineLoader.java @@ -6,15 +6,16 @@ import com.github.technus.tectech.compatibility.thaumcraft.thing.metaTileEntity. import com.github.technus.tectech.compatibility.thaumcraft.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_essentiaQuantizer; import com.github.technus.tectech.thing.metaTileEntity.hatch.*; import com.github.technus.tectech.thing.metaTileEntity.multi.*; -import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; import com.github.technus.tectech.thing.metaTileEntity.multi.em_machine.GT_MetaTileEntity_EM_machine; import com.github.technus.tectech.thing.metaTileEntity.pipe.GT_MetaTileEntity_Pipe_Data; import com.github.technus.tectech.thing.metaTileEntity.pipe.GT_MetaTileEntity_Pipe_EM; +import com.github.technus.tectech.thing.metaTileEntity.pipe.GT_MetaTileEntity_Pipe_Energy; import com.github.technus.tectech.thing.metaTileEntity.single.*; import cpw.mods.fml.common.Loader; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; +import static com.github.technus.tectech.CommonValues.V; import static com.github.technus.tectech.thing.CustomItemList.*; /** @@ -156,6 +157,148 @@ public class MachineLoader implements Runnable { eM_energymulti64_UXV.set(new GT_MetaTileEntity_Hatch_EnergyMulti( 15128, "hatch.energymulti64.tier.13", "UXV 64A Energy Hatch", 13, 64).getStackForm(1L)); + + // =================================================================================================== + // Multi AMP Laser INPUTS + // =================================================================================================== + + eM_energytunnel1_IV.set(new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15130, "hatch.energytunnel1.tier.05", "IV 256/t Laser Target Hatch", 5, 256).getStackForm(1L)); + eM_energytunnel2_IV.set(new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15140, "hatch.energytunnel2.tier.05", "IV 1024/t Laser Target Hatch", 5, 1024).getStackForm(1L)); + eM_energytunnel3_IV.set(new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15150, "hatch.energytunnel3.tier.05", "IV 4096/t Laser Target Hatch", 5, 4096).getStackForm(1L)); + eM_energytunnel4_IV.set(new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15160, "hatch.energytunnel4.tier.05", "IV 16384/t Laser Target Hatch", 5, 16384).getStackForm(1L)); + eM_energytunnel5_IV.set(new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15170, "hatch.energytunnel5.tier.05", "IV 65536/t Laser Target Hatch", 5, 65536).getStackForm(1L)); + eM_energytunnel6_IV.set(new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15180, "hatch.energytunnel6.tier.05", "IV 262144/t Laser Target Hatch", 5, 262144).getStackForm(1L)); + eM_energytunnel7_IV.set(new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15190, "hatch.energytunnel7.tier.05", "IV 1048576/t Laser Target Hatch", 5, 1048576).getStackForm(1L)); + + eM_energytunnel1_LuV.set(new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15131, "hatch.energytunnel1.tier.06", "LuV 256/t Laser Target Hatch", 6, 256).getStackForm(1L)); + eM_energytunnel2_LuV.set(new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15141, "hatch.energytunnel2.tier.06", "LuV 1024/t Laser Target Hatch", 6, 1024).getStackForm(1L)); + eM_energytunnel3_LuV.set(new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15151, "hatch.energytunnel3.tier.06", "LuV 4096/t Laser Target Hatch", 6, 4096).getStackForm(1L)); + eM_energytunnel4_LuV.set(new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15161, "hatch.energytunnel4.tier.06", "LuV 16384/t Laser Target Hatch", 6, 16384).getStackForm(1L)); + eM_energytunnel5_LuV.set(new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15171, "hatch.energytunnel5.tier.06", "LuV 65536/t Laser Target Hatch", 6, 65536).getStackForm(1L)); + eM_energytunnel6_LuV.set(new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15181, "hatch.energytunnel6.tier.06", "LuV 262144/t Laser Target Hatch", 6, 262144).getStackForm(1L)); + eM_energytunnel7_LuV.set(new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15191, "hatch.energytunnel7.tier.06", "LuV 1048576/t Laser Target Hatch", 6, 1048576).getStackForm(1L)); + + eM_energytunnel1_ZPM.set(new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15132, "hatch.energytunnel1.tier.07", "ZPM 256/t Laser Target Hatch", 7, 256).getStackForm(1L)); + eM_energytunnel2_ZPM.set(new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15142, "hatch.energytunnel2.tier.07", "ZPM 1024/t Laser Target Hatch", 7, 1024).getStackForm(1L)); + eM_energytunnel3_ZPM.set(new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15152, "hatch.energytunnel3.tier.07", "ZPM 4096/t Laser Target Hatch", 7, 4096).getStackForm(1L)); + eM_energytunnel4_ZPM.set(new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15162, "hatch.energytunnel4.tier.07", "ZPM 16384/t Laser Target Hatch", 7, 16384).getStackForm(1L)); + eM_energytunnel5_ZPM.set(new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15172, "hatch.energytunnel5.tier.07", "ZPM 65536/t Laser Target Hatch", 7, 65536).getStackForm(1L)); + eM_energytunnel6_ZPM.set(new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15182, "hatch.energytunnel6.tier.07", "ZPM 262144/t Laser Target Hatch", 7, 262144).getStackForm(1L)); + eM_energytunnel7_ZPM.set(new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15192, "hatch.energytunnel7.tier.07", "ZPM 1048576/t Laser Target Hatch", 7, 1048576).getStackForm(1L)); + + eM_energytunnel1_UV.set(new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15133, "hatch.energytunnel1.tier.08", "UV 256/t Laser Target Hatch", 8, 256).getStackForm(1L)); + eM_energytunnel2_UV.set(new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15143, "hatch.energytunnel2.tier.08", "UV 1024/t Laser Target Hatch", 8, 1024).getStackForm(1L)); + eM_energytunnel3_UV.set(new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15153, "hatch.energytunnel3.tier.08", "UV 4096/t Laser Target Hatch", 8, 4096).getStackForm(1L)); + eM_energytunnel4_UV.set(new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15163, "hatch.energytunnel4.tier.08", "UV 16384/t Laser Target Hatch", 8, 16384).getStackForm(1L)); + eM_energytunnel5_UV.set(new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15173, "hatch.energytunnel5.tier.08", "UV 65536/t Laser Target Hatch", 8, 65536).getStackForm(1L)); + eM_energytunnel6_UV.set(new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15183, "hatch.energytunnel6.tier.08", "UV 262144/t Laser Target Hatch", 8, 262144).getStackForm(1L)); + eM_energytunnel7_UV.set(new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15193, "hatch.energytunnel7.tier.08", "UV 1048576/t Laser Target Hatch", 8, 1048576).getStackForm(1L)); + + eM_energytunnel1_UHV.set(new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15134, "hatch.energytunnel1.tier.09", "UHV 256/t Laser Target Hatch", 9, 256).getStackForm(1L)); + eM_energytunnel2_UHV.set(new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15144, "hatch.energytunnel2.tier.09", "UHV 1024/t Laser Target Hatch", 9, 1024).getStackForm(1L)); + eM_energytunnel3_UHV.set(new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15154, "hatch.energytunnel3.tier.09", "UHV 4096/t Laser Target Hatch", 9, 4096).getStackForm(1L)); + eM_energytunnel4_UHV.set(new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15164, "hatch.energytunnel4.tier.09", "UHV 16384/t Laser Target Hatch", 9, 16384).getStackForm(1L)); + eM_energytunnel5_UHV.set(new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15174, "hatch.energytunnel5.tier.09", "UHV 65536/t Laser Target Hatch", 9, 65536).getStackForm(1L)); + eM_energytunnel6_UHV.set(new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15184, "hatch.energytunnel6.tier.09", "UHV 262144/t Laser Target Hatch", 9, 262144).getStackForm(1L)); + eM_energytunnel7_UHV.set(new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15194, "hatch.energytunnel7.tier.09", "UHV 1048576/t Laser Target Hatch", 9, 1048576).getStackForm(1L)); + + eM_energytunnel1_UEV.set(new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15135, "hatch.energytunnel1.tier.10", "UEV 256/t Laser Target Hatch", 10, 256).getStackForm(1L)); + eM_energytunnel2_UEV.set(new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15145, "hatch.energytunnel2.tier.10", "UEV 1024/t Laser Target Hatch", 10, 1024).getStackForm(1L)); + eM_energytunnel3_UEV.set(new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15155, "hatch.energytunnel3.tier.10", "UEV 4096/t Laser Target Hatch", 10, 4096).getStackForm(1L)); + eM_energytunnel4_UEV.set(new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15165, "hatch.energytunnel4.tier.10", "UEV 16384/t Laser Target Hatch", 10, 16384).getStackForm(1L)); + eM_energytunnel5_UEV.set(new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15175, "hatch.energytunnel5.tier.10", "UEV 65536/t Laser Target Hatch", 10, 65536).getStackForm(1L)); + eM_energytunnel6_UEV.set(new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15185, "hatch.energytunnel6.tier.10", "UEV 262144/t Laser Target Hatch", 10, 262144).getStackForm(1L)); + eM_energytunnel7_UEV.set(new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15195, "hatch.energytunnel7.tier.10", "UEV 1048576/t Laser Target Hatch", 10, 1048576).getStackForm(1L)); + + eM_energytunnel1_UIV.set(new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15136, "hatch.energytunnel1.tier.11", "UIV 256/t Laser Target Hatch", 11, 256).getStackForm(1L)); + eM_energytunnel2_UIV.set(new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15146, "hatch.energytunnel2.tier.11", "UIV 1024/t Laser Target Hatch", 11, 1024).getStackForm(1L)); + eM_energytunnel3_UIV.set(new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15156, "hatch.energytunnel3.tier.11", "UIV 4096/t Laser Target Hatch", 11, 4096).getStackForm(1L)); + eM_energytunnel4_UIV.set(new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15166, "hatch.energytunnel4.tier.11", "UIV 16384/t Laser Target Hatch", 11, 16384).getStackForm(1L)); + eM_energytunnel5_UIV.set(new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15176, "hatch.energytunnel5.tier.11", "UIV 65536/t Laser Target Hatch", 11, 65536).getStackForm(1L)); + eM_energytunnel6_UIV.set(new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15186, "hatch.energytunnel6.tier.11", "UIV 262144/t Laser Target Hatch", 11, 262144).getStackForm(1L)); + eM_energytunnel7_UIV.set(new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15196, "hatch.energytunnel7.tier.11", "UIV 1048576/t Laser Target Hatch", 11, 1048576).getStackForm(1L)); + + eM_energytunnel1_UMV.set(new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15137, "hatch.energytunnel1.tier.12", "UMV 256/t Laser Target Hatch", 12, 256).getStackForm(1L)); + eM_energytunnel2_UMV.set(new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15147, "hatch.energytunnel2.tier.12", "UMV 1024/t Laser Target Hatch", 12, 1024).getStackForm(1L)); + eM_energytunnel3_UMV.set(new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15157, "hatch.energytunnel3.tier.12", "UMV 4096/t Laser Target Hatch", 12, 4096).getStackForm(1L)); + eM_energytunnel4_UMV.set(new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15167, "hatch.energytunnel4.tier.12", "UMV 16384/t Laser Target Hatch", 12, 16384).getStackForm(1L)); + eM_energytunnel5_UMV.set(new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15177, "hatch.energytunnel5.tier.12", "UMV 65536/t Laser Target Hatch", 12, 65536).getStackForm(1L)); + eM_energytunnel6_UMV.set(new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15187, "hatch.energytunnel6.tier.12", "UMV 262144/t Laser Target Hatch", 12, 262144).getStackForm(1L)); + eM_energytunnel7_UMV.set(new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15197, "hatch.energytunnel7.tier.12", "UMV 1048576/t Laser Target Hatch", 12, 1048576).getStackForm(1L)); + + eM_energytunnel1_UXV.set(new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15138, "hatch.energytunnel1.tier.13", "UXV 256/t Laser Target Hatch", 13, 256).getStackForm(1L)); + eM_energytunnel2_UXV.set(new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15148, "hatch.energytunnel2.tier.13", "UXV 1024/t Laser Target Hatch", 13, 1024).getStackForm(1L)); + eM_energytunnel3_UXV.set(new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15158, "hatch.energytunnel3.tier.13", "UXV 4096/t Laser Target Hatch", 13, 4096).getStackForm(1L)); + eM_energytunnel4_UXV.set(new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15168, "hatch.energytunnel4.tier.13", "UXV 16384/t Laser Target Hatch", 13, 16384).getStackForm(1L)); + eM_energytunnel5_UXV.set(new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15178, "hatch.energytunnel5.tier.13", "UXV 65536/t Laser Target Hatch", 13, 65536).getStackForm(1L)); + eM_energytunnel6_UXV.set(new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15188, "hatch.energytunnel6.tier.13", "UXV 262144/t Laser Target Hatch", 13, 262144).getStackForm(1L)); + eM_energytunnel7_UXV.set(new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15198, "hatch.energytunnel7.tier.13", "UXV 1048576/t Laser Target Hatch", 13, 1048576).getStackForm(1L)); + eM_energytunnel9001.set(new GT_MetaTileEntity_Hatch_EnergyTunnel( + 15199, "hatch.energytunnel.tier.14", "Legendary Laser Target Hatch", 14, (int)V[14]).getStackForm(1L)); + // =================================================================================================== // Multi AMP Power OUTPUTS // =================================================================================================== @@ -225,6 +368,147 @@ public class MachineLoader implements Runnable { 15228, "hatch.dynamomulti64.tier.13", "UXV 64A Dynamo Hatch", 13, 64).getStackForm(1L)); // =================================================================================================== + // Multi AMP Laser OUTPUTS + // =================================================================================================== + + eM_dynamotunnel1_IV.set(new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15230, "hatch.dynamotunnel1.tier.05", "IV 256/t Laser Source Hatch", 5, 256).getStackForm(1L)); + eM_dynamotunnel2_IV.set(new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15240, "hatch.dynamotunnel2.tier.05", "IV 1024/t Laser Source Hatch", 5, 1024).getStackForm(1L)); + eM_dynamotunnel3_IV.set(new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15250, "hatch.dynamotunnel3.tier.05", "IV 4096/t Laser Source Hatch", 5, 4096).getStackForm(1L)); + eM_dynamotunnel4_IV.set(new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15260, "hatch.dynamotunnel4.tier.05", "IV 16384/t Laser Source Hatch", 5, 16384).getStackForm(1L)); + eM_dynamotunnel5_IV.set(new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15270, "hatch.dynamotunnel5.tier.05", "IV 65536/t Laser Source Hatch", 5, 65536).getStackForm(1L)); + eM_dynamotunnel6_IV.set(new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15280, "hatch.dynamotunnel6.tier.05", "IV 262144/t Laser Source Hatch", 5, 262144).getStackForm(1L)); + eM_dynamotunnel7_IV.set(new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15290, "hatch.dynamotunnel7.tier.05", "IV 1048576/t Laser Source Hatch", 5, 1048576).getStackForm(1L)); + + eM_dynamotunnel1_LuV.set(new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15231, "hatch.dynamotunnel1.tier.06", "LuV 256/t Laser Source Hatch", 6, 256).getStackForm(1L)); + eM_dynamotunnel2_LuV.set(new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15241, "hatch.dynamotunnel2.tier.06", "LuV 1024/t Laser Source Hatch", 6, 1024).getStackForm(1L)); + eM_dynamotunnel3_LuV.set(new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15251, "hatch.dynamotunnel3.tier.06", "LuV 4096/t Laser Source Hatch", 6, 4096).getStackForm(1L)); + eM_dynamotunnel4_LuV.set(new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15261, "hatch.dynamotunnel4.tier.06", "LuV 16384/t Laser Source Hatch", 6, 16384).getStackForm(1L)); + eM_dynamotunnel5_LuV.set(new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15271, "hatch.dynamotunnel5.tier.06", "LuV 65536/t Laser Source Hatch", 6, 65536).getStackForm(1L)); + eM_dynamotunnel6_LuV.set(new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15281, "hatch.dynamotunnel6.tier.06", "LuV 262144/t Laser Source Hatch", 6, 262144).getStackForm(1L)); + eM_dynamotunnel7_LuV.set(new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15291, "hatch.dynamotunnel7.tier.06", "LuV 1048576/t Laser Source Hatch", 6, 1048576).getStackForm(1L)); + + eM_dynamotunnel1_ZPM.set(new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15232, "hatch.dynamotunnel1.tier.07", "ZPM 256/t Laser Source Hatch", 7, 256).getStackForm(1L)); + eM_dynamotunnel2_ZPM.set(new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15242, "hatch.dynamotunnel2.tier.07", "ZPM 1024/t Laser Source Hatch", 7, 1024).getStackForm(1L)); + eM_dynamotunnel3_ZPM.set(new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15252, "hatch.dynamotunnel3.tier.07", "ZPM 4096/t Laser Source Hatch", 7, 4096).getStackForm(1L)); + eM_dynamotunnel4_ZPM.set(new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15262, "hatch.dynamotunnel4.tier.07", "ZPM 16384/t Laser Source Hatch", 7, 16384).getStackForm(1L)); + eM_dynamotunnel5_ZPM.set(new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15272, "hatch.dynamotunnel5.tier.07", "ZPM 65536/t Laser Source Hatch", 7, 65536).getStackForm(1L)); + eM_dynamotunnel6_ZPM.set(new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15282, "hatch.dynamotunnel6.tier.07", "ZPM 262144/t Laser Source Hatch", 7, 262144).getStackForm(1L)); + eM_dynamotunnel7_ZPM.set(new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15292, "hatch.dynamotunnel7.tier.07", "ZPM 1048576/t Laser Source Hatch", 7, 1048576).getStackForm(1L)); + + eM_dynamotunnel1_UV.set(new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15233, "hatch.dynamotunnel1.tier.08", "UV 256/t Laser Source Hatch", 8, 256).getStackForm(1L)); + eM_dynamotunnel2_UV.set(new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15243, "hatch.dynamotunnel2.tier.08", "UV 1024/t Laser Source Hatch", 8, 1024).getStackForm(1L)); + eM_dynamotunnel3_UV.set(new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15253, "hatch.dynamotunnel3.tier.08", "UV 4096/t Laser Source Hatch", 8, 4096).getStackForm(1L)); + eM_dynamotunnel4_UV.set(new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15263, "hatch.dynamotunnel4.tier.08", "UV 16384/t Laser Source Hatch", 8, 16384).getStackForm(1L)); + eM_dynamotunnel5_UV.set(new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15273, "hatch.dynamotunnel5.tier.08", "UV 65536/t Laser Source Hatch", 8, 65536).getStackForm(1L)); + eM_dynamotunnel6_UV.set(new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15283, "hatch.dynamotunnel6.tier.08", "UV 262144/t Laser Source Hatch", 8, 262144).getStackForm(1L)); + eM_dynamotunnel7_UV.set(new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15293, "hatch.dynamotunnel7.tier.08", "UV 1048576/t Laser Source Hatch", 8, 1048576).getStackForm(1L)); + + eM_dynamotunnel1_UHV.set(new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15234, "hatch.dynamotunnel1.tier.09", "UHV 256/t Laser Source Hatch", 9, 256).getStackForm(1L)); + eM_dynamotunnel2_UHV.set(new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15244, "hatch.dynamotunnel2.tier.09", "UHV 1024/t Laser Source Hatch", 9, 1024).getStackForm(1L)); + eM_dynamotunnel3_UHV.set(new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15254, "hatch.dynamotunnel3.tier.09", "UHV 4096/t Laser Source Hatch", 9, 4096).getStackForm(1L)); + eM_dynamotunnel4_UHV.set(new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15264, "hatch.dynamotunnel4.tier.09", "UHV 16384/t Laser Source Hatch", 9, 16384).getStackForm(1L)); + eM_dynamotunnel5_UHV.set(new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15274, "hatch.dynamotunnel5.tier.09", "UHV 65536/t Laser Source Hatch", 9, 65536).getStackForm(1L)); + eM_dynamotunnel6_UHV.set(new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15284, "hatch.dynamotunnel6.tier.09", "UHV 262144/t Laser Source Hatch", 9, 262144).getStackForm(1L)); + eM_dynamotunnel7_UHV.set(new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15294, "hatch.dynamotunnel7.tier.09", "UHV 1048576/t Laser Source Hatch", 9, 1048576).getStackForm(1L)); + + eM_dynamotunnel1_UEV.set(new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15235, "hatch.dynamotunnel1.tier.10", "UEV 256/t Laser Source Hatch", 10, 256).getStackForm(1L)); + eM_dynamotunnel2_UEV.set(new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15245, "hatch.dynamotunnel2.tier.10", "UEV 1024/t Laser Source Hatch", 10, 1024).getStackForm(1L)); + eM_dynamotunnel3_UEV.set(new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15255, "hatch.dynamotunnel3.tier.10", "UEV 4096/t Laser Source Hatch", 10, 4096).getStackForm(1L)); + eM_dynamotunnel4_UEV.set(new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15265, "hatch.dynamotunnel4.tier.10", "UEV 16384/t Laser Source Hatch", 10, 16384).getStackForm(1L)); + eM_dynamotunnel5_UEV.set(new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15275, "hatch.dynamotunnel5.tier.10", "UEV 65536/t Laser Source Hatch", 10, 65536).getStackForm(1L)); + eM_dynamotunnel6_UEV.set(new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15285, "hatch.dynamotunnel6.tier.10", "UEV 262144/t Laser Source Hatch", 10, 262144).getStackForm(1L)); + eM_dynamotunnel7_UEV.set(new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15295, "hatch.dynamotunnel7.tier.10", "UEV 1048576/t Laser Source Hatch", 10, 1048576).getStackForm(1L)); + + eM_dynamotunnel1_UIV.set(new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15236, "hatch.dynamotunnel1.tier.11", "UIV 256/t Laser Source Hatch", 11, 256).getStackForm(1L)); + eM_dynamotunnel2_UIV.set(new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15246, "hatch.dynamotunnel2.tier.11", "UIV 1024/t Laser Source Hatch", 11, 1024).getStackForm(1L)); + eM_dynamotunnel3_UIV.set(new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15256, "hatch.dynamotunnel3.tier.11", "UIV 4096/t Laser Source Hatch", 11, 4096).getStackForm(1L)); + eM_dynamotunnel4_UIV.set(new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15266, "hatch.dynamotunnel4.tier.11", "UIV 16384/t Laser Source Hatch", 11, 16384).getStackForm(1L)); + eM_dynamotunnel5_UIV.set(new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15276, "hatch.dynamotunnel5.tier.11", "UIV 65536/t Laser Source Hatch", 11, 65536).getStackForm(1L)); + eM_dynamotunnel6_UIV.set(new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15286, "hatch.dynamotunnel6.tier.11", "UIV 262144/t Laser Source Hatch", 11, 262144).getStackForm(1L)); + eM_dynamotunnel7_UIV.set(new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15296, "hatch.dynamotunnel7.tier.11", "UIV 1048576/t Laser Source Hatch", 11, 1048576).getStackForm(1L)); + + eM_dynamotunnel1_UMV.set(new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15237, "hatch.dynamotunnel1.tier.12", "UMV 256/t Laser Source Hatch", 12, 256).getStackForm(1L)); + eM_dynamotunnel2_UMV.set(new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15247, "hatch.dynamotunnel2.tier.12", "UMV 1024/t Laser Source Hatch", 12, 1024).getStackForm(1L)); + eM_dynamotunnel3_UMV.set(new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15257, "hatch.dynamotunnel3.tier.12", "UMV 4096/t Laser Source Hatch", 12, 4096).getStackForm(1L)); + eM_dynamotunnel4_UMV.set(new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15267, "hatch.dynamotunnel4.tier.12", "UMV 16384/t Laser Source Hatch", 12, 16384).getStackForm(1L)); + eM_dynamotunnel5_UMV.set(new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15277, "hatch.dynamotunnel5.tier.12", "UMV 65536/t Laser Source Hatch", 12, 65536).getStackForm(1L)); + eM_dynamotunnel6_UMV.set(new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15287, "hatch.dynamotunnel6.tier.12", "UMV 262144/t Laser Source Hatch", 12, 262144).getStackForm(1L)); + eM_dynamotunnel7_UMV.set(new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15297, "hatch.dynamotunnel7.tier.12", "UMV 1048576/t Laser Source Hatch", 12, 1048576).getStackForm(1L)); + + eM_dynamotunnel1_UXV.set(new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15238, "hatch.dynamotunnel1.tier.13", "UXV 256/t Laser Source Hatch", 13, 256).getStackForm(1L)); + eM_dynamotunnel2_UXV.set(new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15248, "hatch.dynamotunnel2.tier.13", "UXV 1024/t Laser Source Hatch", 13, 1024).getStackForm(1L)); + eM_dynamotunnel3_UXV.set(new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15258, "hatch.dynamotunnel3.tier.13", "UXV 4096/t Laser Source Hatch", 13, 4096).getStackForm(1L)); + eM_dynamotunnel4_UXV.set(new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15268, "hatch.dynamotunnel4.tier.13", "UXV 16384/t Laser Source Hatch", 13, 16384).getStackForm(1L)); + eM_dynamotunnel5_UXV.set(new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15278, "hatch.dynamotunnel5.tier.13", "UXV 65536/t Laser Source Hatch", 13, 65536).getStackForm(1L)); + eM_dynamotunnel6_UXV.set(new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15288, "hatch.dynamotunnel6.tier.13", "UXV 262144/t Laser Source Hatch", 13, 262144).getStackForm(1L)); + eM_dynamotunnel7_UXV.set(new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15298, "hatch.dynamotunnel7.tier.13", "UXV 1048576/t Laser Source Hatch", 13, 1048576).getStackForm(1L)); + eM_dynamotunnel9001.set(new GT_MetaTileEntity_Hatch_DynamoTunnel( + 15299, "hatch.dynamotunnel.tier.14", "Legendary Laser Source Hatch", 14, (int)V[14]).getStackForm(1L)); + + // =================================================================================================== // MULTIBLOCKS // =================================================================================================== @@ -288,7 +572,7 @@ public class MachineLoader implements Runnable { // =================================================================================================== EMpipe.set(new GT_MetaTileEntity_Pipe_EM(15460, "pipe.elementalmatter", "Quantum \"Tunnel\"").getStackForm(1L)); - + LASERpipe.set(new GT_MetaTileEntity_Pipe_Energy(15465, "pipe.energystream", "Laser Vacuum Pipe").getStackForm(1L)); DATApipe.set(new GT_MetaTileEntity_Pipe_Data(15470, "pipe.datastream", "Optical Fiber Cable").getStackForm(1L)); // =================================================================================================== @@ -311,6 +595,8 @@ public class MachineLoader implements Runnable { // =================================================================================================== // Debug Stuff // =================================================================================================== + Machine_DebugPollutor.set(new GT_MetaTileEntity_DebugPollutor(15495,"debug.tt.pollutor","Debug Pollution Generator",15).getStackForm(1)); + hatch_CreativeData.set(new GT_MetaTileEntity_Hatch_CreativeData(15496,"debug.tt.data","Debug Data Hatch",15).getStackForm(1)); hatch_CreativeMaitenance.set(new GT_MetaTileEntity_Hatch_CreativeMaintenance(15497, "debug.tt.maintenance", "Debug Maintenance Hatch", 15).getStackForm(1L)); Machine_DebugGenny.set(new GT_MetaTileEntity_DebugPowerGenerator(15498, "debug.tt.genny", "Debug Power Generator", 15).getStackForm(1L)); Machine_DebugWriter.set(new GT_MetaTileEntity_DebugStructureWriter(15499, "debug.tt.writer", "Debug Structure Writer", 15).getStackForm(1L)); @@ -320,13 +606,7 @@ public class MachineLoader implements Runnable { // MetaTE init // =================================================================================================== - GT_MetaTileEntity_MultiblockBase_EM.run(); GT_MetaTileEntity_Hatch_Rack.run(); - GT_MetaTileEntity_EM_computer.run(); - GT_MetaTileEntity_EM_research.run(); - GT_MetaTileEntity_EM_dataBank.run(); - GT_MetaTileEntity_TM_teslaCoil.run(); - GT_MetaTileEntity_DataReader.run(); if (!Loader.isModLoaded(Reference.DREAMCRAFT)) { diff --git a/src/main/java/com/github/technus/tectech/mechanics/anomaly/AnomalyHandler.java b/src/main/java/com/github/technus/tectech/mechanics/anomaly/AnomalyHandler.java new file mode 100644 index 0000000000..dc7e8faef7 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/anomaly/AnomalyHandler.java @@ -0,0 +1,343 @@ +package com.github.technus.tectech.mechanics.anomaly; + +import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.Util; +import com.github.technus.tectech.loader.MainLoader; +import com.github.technus.tectech.loader.NetworkDispatcher; +import com.github.technus.tectech.mechanics.data.ChunkDataHandler; +import com.github.technus.tectech.mechanics.data.ChunkDataMessage; +import com.github.technus.tectech.mechanics.data.IChunkMetaDataHandler; +import com.github.technus.tectech.mechanics.data.PlayerDataMessage; +import com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.atom.dAtomDefinition; +import cpw.mods.fml.common.gameevent.TickEvent; +import gregtech.api.GregTech_API; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.util.GT_Utility; +import net.minecraft.block.Block; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.world.ChunkCoordIntPair; +import net.minecraft.world.World; +import net.minecraft.world.chunk.Chunk; +import net.minecraftforge.event.world.ChunkEvent; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +public class AnomalyHandler implements IChunkMetaDataHandler { + public static final double SWAP_THRESHOLD = dAtomDefinition.getSomethingHeavy().getMass() * 10000D; + public static final int COUNT_DIV=32; + public static final double PER_PARTICLE=SWAP_THRESHOLD/COUNT_DIV; + public static final String INTENSITY = "intensity",SPACE_CANCER="space_cancer", SPACE_CHARGE ="space_charge"; + public static final int MEAN_DELAY =50; + private static final float CHARGE_EFFECTIVENESS = 10; + private static final float CHARGE_EXPLOSIVENESS = 5; + + private boolean fixMe=false; + private final ArrayList<EntityPlayer> playersWithCharge = new ArrayList<>(); + private final ArrayList<Chunk> worldDataArrayList = new ArrayList<>(512); + + @Override + public String getTagName() { + return "anomaly"; + } + + @Override + public void mergeData(NBTTagCompound target, NBTTagCompound loadedData) { + double intensity = target.getDouble(INTENSITY) + loadedData.getDouble(INTENSITY); + target.setDouble(INTENSITY, intensity); + } + + @Override + public NBTTagCompound createData() { + return new NBTTagCompound(); + } + + @Override + public void tickWorld(HashMap<Integer, ChunkDataHandler.ChunkHashMap> data, TickEvent.WorldTickEvent aEvent) { + if (TecTech.RANDOM.nextInt(MEAN_DELAY) == 0) { + int dim = aEvent.world.provider.dimensionId; + data.get(dim).forEach((chunkCoordIntPair, compound) -> { + if (compound.getDouble(INTENSITY) >= SWAP_THRESHOLD) { + Chunk chunk = aEvent.world.getChunkFromChunkCoords(chunkCoordIntPair.chunkXPos, chunkCoordIntPair.chunkZPos); + if (chunk.isChunkLoaded) { + worldDataArrayList.add(chunk); + } + } + }); + if (worldDataArrayList.size() >= 2) { + Chunk a = worldDataArrayList.remove(TecTech.RANDOM.nextInt(worldDataArrayList.size())); + Chunk b = worldDataArrayList.remove(TecTech.RANDOM.nextInt(worldDataArrayList.size())); + double avg = .5 * (data.get(dim).get(a.getChunkCoordIntPair()).getDouble(INTENSITY) + + data.get(dim).get(b.getChunkCoordIntPair()).getDouble(INTENSITY)); + data.get(dim).get(a.getChunkCoordIntPair()).setDouble(INTENSITY, Math.min(SWAP_THRESHOLD, avg * (TecTech.RANDOM.nextFloat() + .5F) * 0.5F)); + data.get(dim).get(b.getChunkCoordIntPair()).setDouble(INTENSITY, Math.min(SWAP_THRESHOLD, avg * (TecTech.RANDOM.nextFloat() + .5F) * 0.5F)); + data.get(dim).markForTransmissionToClient(a.getChunkCoordIntPair()); + data.get(dim).markForTransmissionToClient(b.getChunkCoordIntPair()); + swapSomething(a, b, (float) Math.min(Math.log10(avg), 20)); + } + worldDataArrayList.clear(); + } + for (Object o : aEvent.world.playerEntities) { + if (o instanceof EntityPlayer && !((EntityPlayer) o).capabilities.isCreativeMode) { + float charge = TecTech.playerPersistence.getDataOrSetToNewTag((EntityPlayer) o).getFloat(SPACE_CHARGE); + if (charge != 0) { + playersWithCharge.add((EntityPlayer) o); + } + } + } + if (playersWithCharge.size() > 0) { + outer: + for (EntityPlayer other : playersWithCharge) { + float fieldOther = TecTech.playerPersistence.getDataOrSetToNewTag(other).getFloat(SPACE_CHARGE); + for (EntityPlayer player : playersWithCharge) { + if (other == player) { + continue outer; + } + float field = TecTech.playerPersistence.getDataOrSetToNewTag(player).getFloat(SPACE_CHARGE); + float difference = Math.abs(field - fieldOther); + if (difference != 0) { + if (player.getDistanceSqToEntity(other) < 1) { + float avg = (fieldOther + field) / 2; + addAnomaly(other.worldObj.provider.dimensionId, new ChunkCoordIntPair(other.chunkCoordX, other.chunkCoordZ), Math.min(SWAP_THRESHOLD, PER_PARTICLE * difference)); + other.worldObj.createExplosion(other, other.posX, other.posY, other.posZ, Math.min(CHARGE_EXPLOSIVENESS * difference, 25), true); + player.worldObj.createExplosion(player, player.posX, player.posY, player.posZ, Math.min(CHARGE_EXPLOSIVENESS * difference, 25), true); + TecTech.playerPersistence.getDataOrSetToNewTag(player).setFloat(SPACE_CHARGE, avg); + TecTech.playerPersistence.getDataOrSetToNewTag(other).setFloat(SPACE_CHARGE, avg); + TecTech.playerPersistence.saveData(player); + TecTech.playerPersistence.saveData(other); + NetworkDispatcher.INSTANCE.sendToAll(new PlayerDataMessage.PlayerDataData(player)); + NetworkDispatcher.INSTANCE.sendToAll(new PlayerDataMessage.PlayerDataData(other)); + } + } + } + } + playersWithCharge.clear(); + } + } + + private void swapSomething(Chunk a,Chunk b,float power) { + for (int i = 0; i < 64; i++) { + int x = TecTech.RANDOM.nextInt(16); + int y = TecTech.RANDOM.nextInt(a.worldObj.getActualHeight()); + int z = TecTech.RANDOM.nextInt(16); + Block aBlock = a.getBlock(x, y, z); + Block bBlock = a.getBlock(x, y, z); + int aMeta = a.getBlockMetadata(x, y, z); + int bMeta = a.getBlockMetadata(x, y, z); + if (a.getTileEntityUnsafe(x, y, z) == null && b.getTileEntityUnsafe(x, y, z) == null) { + a.worldObj.setBlock((a.xPosition << 4) + x, y, (a.zPosition << 4) + z, bBlock, bMeta, 3); + b.worldObj.setBlock((b.xPosition << 4) + x, y, (b.zPosition << 4) + z, aBlock, aMeta, 3); + } else if (a.getTileEntityUnsafe(x, y, z) == null) { + b.worldObj.setBlock((b.xPosition << 4) + x, y, (b.zPosition << 4) + z, aBlock, aMeta, 3); + a.worldObj.setBlockToAir((a.xPosition << 4) + x, y, (a.zPosition << 4) + z); + } else if (b.getTileEntityUnsafe(x, y, z) == null) { + a.worldObj.setBlock((a.xPosition << 4) + x, y, (a.zPosition << 4) + z, bBlock, bMeta, 3); + b.worldObj.setBlockToAir((b.xPosition << 4) + x, y, (b.zPosition << 4) + z); + } else { + a.worldObj.setBlockToAir((a.xPosition << 4) + x, y, (a.zPosition << 4) + z); + b.worldObj.setBlockToAir((b.xPosition << 4) + x, y, (b.zPosition << 4) + z); + } + if (TecTech.RANDOM.nextBoolean()) { + a.worldObj.createExplosion(null, (a.xPosition << 4) + x + .5, y + .5, (a.zPosition << 4) + z + .5, power, true); + GT_Utility.sendSoundToPlayers(a.worldObj, GregTech_API.sSoundList.get(209), 1.0F, -1, (a.xPosition << 4) + x, y, (a.zPosition << 4) + z); + } + if (TecTech.RANDOM.nextBoolean()) { + b.worldObj.createExplosion(null, (b.xPosition << 4) + x + .5, y + .5, (b.zPosition << 4) + z + .5, power, true); + GT_Utility.sendSoundToPlayers(b.worldObj, GregTech_API.sSoundList.get(209), 1.0F, -1, (b.xPosition << 4) + x, y, (b.zPosition << 4) + z); + } + } + int x = (b.xPosition - a.xPosition) << 4; + int z = (b.xPosition - a.xPosition) << 4; + List<EntityLivingBase> aE = a.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, Util.fromChunk(a)); + List<EntityLivingBase> bE = b.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, Util.fromChunk(b)); + aE.forEach(o -> { + if (TecTech.RANDOM.nextBoolean()) { + o.setPositionAndUpdate(o.posX + x, o.posY, o.posZ + z); + o.attackEntityFrom(MainLoader.subspace,8+TecTech.RANDOM.nextInt(8)); + if(o instanceof EntityPlayer){ + EntityPlayer player=((EntityPlayer) o); + if(!player.capabilities.isCreativeMode) { + player.addPotionEffect(new PotionEffect(Potion.hunger.id, 1200)); + player.addPotionEffect(new PotionEffect(Potion.weakness.id, 1000)); + player.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 800)); + player.addPotionEffect(new PotionEffect(Potion.digSlowdown.id, 600)); + player.addPotionEffect(new PotionEffect(Potion.confusion.id, 400)); + player.addPotionEffect(new PotionEffect(Potion.poison.id, 200)); + player.addPotionEffect(new PotionEffect(Potion.blindness.id, 100)); + player.addPotionEffect(new PotionEffect(Potion.wither.id, 60)); + TecTech.playerPersistence.getDataOrSetToNewTag(player).setFloat(SPACE_CHARGE, + TecTech.playerPersistence.getDataOrSetToNewTag(player).getFloat(SPACE_CHARGE)-(float)Math.abs(TecTech.RANDOM.nextGaussian())); + TecTech.playerPersistence.saveData(player); + NetworkDispatcher.INSTANCE.sendToAll(new PlayerDataMessage.PlayerDataData(player)); + } + } + } + }); + bE.forEach(o -> { + if (TecTech.RANDOM.nextBoolean()) { + o.setPositionAndUpdate(o.posX - x, o.posY, o.posZ - z); + o.attackEntityFrom(MainLoader.subspace,8+TecTech.RANDOM.nextInt(8)); + if(o instanceof EntityPlayer){ + EntityPlayer player=((EntityPlayer) o); + if(!player.capabilities.isCreativeMode) { + player.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 800)); + player.addPotionEffect(new PotionEffect(Potion.digSpeed.id, 600)); + player.addPotionEffect(new PotionEffect(Potion.damageBoost.id, 400)); + player.addPotionEffect(new PotionEffect(Potion.jump.id, 200)); + player.addPotionEffect(new PotionEffect(Potion.resistance.id, 100)); + player.addPotionEffect(new PotionEffect(Potion.regeneration.id, 60)); + TecTech.playerPersistence.getDataOrSetToNewTag(player).setFloat(SPACE_CHARGE, + TecTech.playerPersistence.getDataOrSetToNewTag(player).getFloat(SPACE_CHARGE)+(float)Math.abs(TecTech.RANDOM.nextGaussian())); + + TecTech.playerPersistence.saveData(player); + NetworkDispatcher.INSTANCE.sendToAll(new PlayerDataMessage.PlayerDataData(player)); + } + } + } + }); + } + + @Override + public void tickPlayer(HashMap<Integer, ChunkDataHandler.ChunkHashMap> data, TickEvent.PlayerTickEvent aEvent) { + if (aEvent.side.isClient()) { + EntityPlayer player = TecTech.proxy.getPlayer(); + ChunkCoordIntPair pair = new ChunkCoordIntPair(player.chunkCoordX, player.chunkCoordZ); + NBTTagCompound compound = data.get(player.worldObj.provider.dimensionId).get(pair); + if (compound != null) { + for (int i = 0, badness = (int) Math.min(COUNT_DIV, compound.getDouble(INTENSITY) / PER_PARTICLE); i < badness; i++) { + TecTech.proxy.em_particle(player.worldObj, + player.posX + TecTech.RANDOM.nextGaussian() * 64D, + player.posY + TecTech.RANDOM.nextGaussian() * 64D, + player.posZ + TecTech.RANDOM.nextGaussian() * 64D); + } + } + + data.get(player.worldObj.provider.dimensionId).forEach((chunkCoordIntPair, dat) -> { + if (Math.abs(chunkCoordIntPair.getCenterXPos() - player.posX) + Math.abs(chunkCoordIntPair.getCenterZPosition() - player.posZ) < 256) { + for (int i = 0, pow = (int) Math.min(32, dat.getDouble(INTENSITY) / PER_PARTICLE); i < pow; i++) { + TecTech.proxy.em_particle(player.worldObj, + chunkCoordIntPair.getCenterXPos() + TecTech.RANDOM.nextGaussian() * 32D, + player.posY + TecTech.RANDOM.nextFloat() * 128D - 64D, + chunkCoordIntPair.getCenterZPosition() + TecTech.RANDOM.nextGaussian() * 32D); + } + } + }); + } else if (TecTech.RANDOM.nextInt(50) == 0) { + EntityPlayer player = aEvent.player; + ChunkCoordIntPair pair = new ChunkCoordIntPair(player.chunkCoordX, player.chunkCoordZ); + NBTTagCompound compound = data.get(player.worldObj.provider.dimensionId).get(pair); + NBTTagCompound playerTag = TecTech.playerPersistence.getDataOrSetToNewTag(player); + if(player.capabilities.isCreativeMode){ + playerTag.setDouble(SPACE_CANCER, 0); + }else { + if (compound != null) { + int badness = (int) Math.min(COUNT_DIV, compound.getDouble(INTENSITY) / PER_PARTICLE); + if (badness > 0) { + playerTag.setDouble(SPACE_CANCER, Math.min(2, playerTag.getDouble(SPACE_CANCER) + 9.765625E-4f * badness)); + player.attackEntityFrom(MainLoader.subspace,Math.max(1,badness/8f)); + } + } else if (playerTag.getDouble(SPACE_CANCER) > 0 && !player.isDead) { + playerTag.setDouble(SPACE_CANCER, Math.max(0, playerTag.getDouble(SPACE_CANCER) - 7.6293945E-6f)); + } + } + TecTech.playerPersistence.saveData(player); + NetworkDispatcher.INSTANCE.sendTo(new PlayerDataMessage.PlayerDataData(player), (EntityPlayerMP) player); + } + } + + @Override + public void tickRender(HashMap<Integer, ChunkDataHandler.ChunkHashMap> data, TickEvent.RenderTickEvent aEvent) { + EntityPlayer player=TecTech.proxy.getPlayer(); + if(player!=null) { + if(!player.capabilities.isCreativeMode) { + NBTTagCompound tagCompound = TecTech.playerPersistence.getDataOrSetToNewTag(player); + if (tagCompound != null) { + float cancer = tagCompound.getFloat(SPACE_CANCER); + if (cancer > 0) { + player.setInvisible(fixMe = TecTech.RANDOM.nextFloat() * 2 < cancer); + player.setAngles((TecTech.RANDOM.nextFloat() - .5F) * 36 * cancer, (TecTech.RANDOM.nextFloat() - .5F) * 36 * cancer); + cancer*=cancer/2F; + if (cancer > 1.75f) { + player.setVelocity((TecTech.RANDOM.nextFloat() - .5F) * cancer, (TecTech.RANDOM.nextFloat() - .5F) * cancer, (TecTech.RANDOM.nextFloat() - .5F) * cancer); + } else { + player.addVelocity((TecTech.RANDOM.nextFloat() - .5F) * cancer, (TecTech.RANDOM.nextFloat() - .5F) * cancer, (TecTech.RANDOM.nextFloat() - .5F) * cancer); + } + } + } + + float charge = TecTech.playerPersistence.getDataOrSetToNewTag(player).getFloat(SPACE_CHARGE); + if(charge!=0) { + for (Object o : player.worldObj.playerEntities) { + if (o instanceof EntityPlayer && !((EntityPlayer) o).capabilities.isCreativeMode) { + EntityPlayer otherPlayer=(EntityPlayer)o; + float chargeOther = TecTech.playerPersistence.getDataOrSetToNewTag(otherPlayer).getFloat(SPACE_CHARGE); + if (chargeOther != 0 && player != o) { + float reaction = chargeOther * charge; + if (reaction !=0) { + double distanceSq = otherPlayer.getDistanceSqToEntity(player); + if (distanceSq >= 1) { + double effect = CHARGE_EFFECTIVENESS * reaction / (distanceSq * distanceSq * distanceSq); + double dX = player.posX - otherPlayer.posX; + double dY = player.posY - otherPlayer.posY; + double dZ = player.posZ - otherPlayer.posZ; + player.addVelocity(effect * dX, effect * dY, effect * dZ); + otherPlayer.addVelocity(-effect * dX, -effect * dY, -effect * dZ); + } + } + } + } + } + } + } + if (fixMe){ + player.setInvisible(false); + fixMe=false; + } + } + } + + @Override + public void pullData(ChunkEvent.Load aEvent) { + NetworkDispatcher.INSTANCE.sendToServer(new ChunkDataMessage.ChunkDataQuery(aEvent, this)); + } + + @Override + public void pushData(World world, ChunkCoordIntPair chunk) { + NetworkDispatcher.INSTANCE.sendToDimension(new ChunkDataMessage.ChunkDataData(world.provider.dimensionId, chunk, this), world.provider.dimensionId); + } + + @Override + public int pushPayloadSpreadPeriod() { + return 100; + } + + public void addAnomaly(IGregTechTileEntity iGregTechTileEntity, double amount) { + if (iGregTechTileEntity.isServerSide()) { + World w = iGregTechTileEntity.getWorld(); + addAnomaly(w.provider.dimensionId, + new ChunkCoordIntPair( + iGregTechTileEntity.getXCoord() >> 4, + iGregTechTileEntity.getZCoord() >> 4), + amount); + } + } + + public void addAnomaly(int world, ChunkCoordIntPair chunk, double amount) { + amount=Math.abs(amount); + NBTTagCompound old = TecTech.chunkDataHandler.getChunkData(this, world, chunk); + if (old == null) { + NBTTagCompound data = new NBTTagCompound(); + data.setDouble(INTENSITY, amount); + TecTech.chunkDataHandler.putChunkData(this, world, chunk, data); + } else { + old.setDouble(INTENSITY, old.getDouble(INTENSITY) + amount); + } + TecTech.chunkDataHandler.getChunkData(this, world).markForTransmissionToClient(chunk); + } +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/anomaly/CancerCommand.java b/src/main/java/com/github/technus/tectech/mechanics/anomaly/CancerCommand.java new file mode 100644 index 0000000000..a153671a59 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/anomaly/CancerCommand.java @@ -0,0 +1,91 @@ +package com.github.technus.tectech.mechanics.anomaly; + +import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.loader.NetworkDispatcher; +import com.github.technus.tectech.mechanics.data.PlayerDataMessage; +import net.minecraft.command.ICommand; +import net.minecraft.command.ICommandSender; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.ChatComponentText; + +import java.util.ArrayList; +import java.util.List; + +import static com.github.technus.tectech.mechanics.anomaly.AnomalyHandler.SPACE_CANCER; + +public class CancerCommand implements ICommand { + ArrayList<String> aliases=new ArrayList<>(); + + public CancerCommand(){ + aliases.add("cancer_EM"); + aliases.add("cancer"); + aliases.add("sanser"); + aliases.add("sancer"); + } + + @Override + public void processCommand(ICommandSender sender, String[] args) { + if (sender instanceof EntityPlayerMP && !sender.getEntityWorld().isRemote) { + double amount; + try { + amount = Double.parseDouble(args[0]); + }catch (NumberFormatException e){ + sender.addChatMessage(new ChatComponentText("Cannot parse amount!")); + return; + } + if(amount<0||amount>2){ + sender.addChatMessage(new ChatComponentText("Invalid amount provided!")); + return; + } + EntityPlayerMP player=(EntityPlayerMP)sender; + NBTTagCompound playerTag = TecTech.playerPersistence.getDataOrSetToNewTag(player); + if(player.capabilities.isCreativeMode){ + sender.addChatMessage(new ChatComponentText("Doesn't really work in creative mode!")); + }else { + playerTag.setDouble(SPACE_CANCER, amount); + TecTech.playerPersistence.saveData(player); + NetworkDispatcher.INSTANCE.sendTo(new PlayerDataMessage.PlayerDataData(player), player); + sender.addChatMessage(new ChatComponentText("Cancer set to: "+amount)); + } + } + } + + @Override + public boolean isUsernameIndex(String[] p_82358_1_, int p_82358_2_) { + return false; + } + + @Override + public List<String> getCommandAliases() { + return aliases; + } + + @Override + public String getCommandName() { + return aliases.get(0); + } + + @Override + public List<String> addTabCompletionOptions(ICommandSender sender, String[] args) { + return null; + } + + @Override + public String getCommandUsage(ICommandSender p_71518_1_) { + return "cancer_EM [Amount 0.0-2.0]"; + } + + @Override + public int compareTo(Object o) { + if(o instanceof ICommand){ + return getCommandName().compareTo(((ICommand) o).getCommandName()); + } + return 0; + } + + @Override + public boolean canCommandSenderUseCommand(ICommandSender sender) { + return true; + } +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/anomaly/ChargeCommand.java b/src/main/java/com/github/technus/tectech/mechanics/anomaly/ChargeCommand.java new file mode 100644 index 0000000000..da365a92f8 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/anomaly/ChargeCommand.java @@ -0,0 +1,85 @@ +package com.github.technus.tectech.mechanics.anomaly; + +import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.loader.NetworkDispatcher; +import com.github.technus.tectech.mechanics.data.PlayerDataMessage; +import net.minecraft.command.ICommand; +import net.minecraft.command.ICommandSender; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.ChatComponentText; + +import java.util.ArrayList; +import java.util.List; + +import static com.github.technus.tectech.mechanics.anomaly.AnomalyHandler.SPACE_CHARGE; + +public class ChargeCommand implements ICommand { + ArrayList<String> aliases=new ArrayList<>(); + + public ChargeCommand(){ + aliases.add("charge_EM"); + aliases.add("charge"); + } + + @Override + public void processCommand(ICommandSender sender, String[] args) { + if (sender instanceof EntityPlayerMP && !sender.getEntityWorld().isRemote) { + double amount; + try { + amount = Double.parseDouble(args[0]); + }catch (NumberFormatException e){ + sender.addChatMessage(new ChatComponentText("Cannot parse amount!")); + return; + } + EntityPlayerMP player=(EntityPlayerMP)sender; + NBTTagCompound playerTag = TecTech.playerPersistence.getDataOrSetToNewTag(player); + if(player.capabilities.isCreativeMode){ + sender.addChatMessage(new ChatComponentText("Doesn't really work in creative mode!")); + }else { + playerTag.setDouble(SPACE_CHARGE, amount); + TecTech.playerPersistence.saveData(player); + NetworkDispatcher.INSTANCE.sendToAll(new PlayerDataMessage.PlayerDataData(player)); + sender.addChatMessage(new ChatComponentText("Charge set to: "+amount)); + } + } + } + + @Override + public boolean isUsernameIndex(String[] p_82358_1_, int p_82358_2_) { + return false; + } + + @Override + public List<String> getCommandAliases() { + return aliases; + } + + @Override + public String getCommandName() { + return aliases.get(0); + } + + @Override + public List<String> addTabCompletionOptions(ICommandSender sender, String[] args) { + return null; + } + + @Override + public String getCommandUsage(ICommandSender p_71518_1_) { + return "charge_EM [Amount]"; + } + + @Override + public int compareTo(Object o) { + if(o instanceof ICommand){ + return getCommandName().compareTo(((ICommand) o).getCommandName()); + } + return 0; + } + + @Override + public boolean canCommandSenderUseCommand(ICommandSender sender) { + return true; + } +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/ConvertFloat.java b/src/main/java/com/github/technus/tectech/mechanics/commands/ConvertFloat.java index 8e25b8908a..61fa56f93a 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/ConvertFloat.java +++ b/src/main/java/com/github/technus/tectech/mechanics/commands/ConvertFloat.java @@ -1,4 +1,4 @@ -package com.github.technus.tectech.mechanics; +package com.github.technus.tectech.mechanics.commands; import com.github.technus.tectech.Util; import net.minecraft.command.ICommand; diff --git a/src/main/java/com/github/technus/tectech/mechanics/ConvertInteger.java b/src/main/java/com/github/technus/tectech/mechanics/commands/ConvertInteger.java index c381f34939..c9767560c3 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/ConvertInteger.java +++ b/src/main/java/com/github/technus/tectech/mechanics/commands/ConvertInteger.java @@ -1,4 +1,4 @@ -package com.github.technus.tectech.mechanics; +package com.github.technus.tectech.mechanics.commands; import com.github.technus.tectech.Util; import net.minecraft.command.ICommand; diff --git a/src/main/java/com/github/technus/tectech/mechanics/data/ChunkDataHandler.java b/src/main/java/com/github/technus/tectech/mechanics/data/ChunkDataHandler.java new file mode 100644 index 0000000000..0d0af5b390 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/data/ChunkDataHandler.java @@ -0,0 +1,368 @@ +package com.github.technus.tectech.mechanics.data; + +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.TickEvent; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.Minecraft; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.ChunkCoordIntPair; +import net.minecraft.world.World; +import net.minecraftforge.event.world.ChunkDataEvent; +import net.minecraftforge.event.world.ChunkEvent; +import net.minecraftforge.event.world.WorldEvent; + +import java.util.*; + +public class ChunkDataHandler { + private final String BASE_TAG_NAME ="TecTechData"; + private final HashMap<Integer,HashMap<ChunkCoordIntPair, NBTChunk>> dimensionWiseChunkData=new HashMap<>(); + private final HashMap<String,HashMap<Integer,ChunkHashMap >> dimensionWiseMetaChunkData=new HashMap<>(); + private final HashMap<String, IChunkMetaDataHandler> metaDataHandlerHashMap =new HashMap<>(); + private final ArrayList<IChunkMetaDataHandler> pushSyncHandlers =new ArrayList<>(); + private final ArrayList<IChunkMetaDataHandler> pullSyncHandlers =new ArrayList<>(); + private final ArrayList<IChunkMetaDataHandler> serverHandlers=new ArrayList<>(); + private final ArrayList<IChunkMetaDataHandler> worldHandlers=new ArrayList<>(); + private final ArrayList<IChunkMetaDataHandler> playerHandlers=new ArrayList<>(); + private final ArrayList<IChunkMetaDataHandler> clientHandlers=new ArrayList<>(); + private final ArrayList<IChunkMetaDataHandler> renderHandlers=new ArrayList<>(); + + @SubscribeEvent + public void onWorldLoad(WorldEvent.Load event){ + int dim=event.world.provider.dimensionId; + dimensionWiseChunkData.computeIfAbsent(dim, m->{ + HashMap<ChunkCoordIntPair, NBTChunk> map = new HashMap<>(); + for (Map.Entry<String,IChunkMetaDataHandler> meta : metaDataHandlerHashMap.entrySet()) { + dimensionWiseMetaChunkData.get(meta.getKey()).put(dim, new ChunkHashMap(meta.getValue(), map)); + } + return map; + }); + } + + @SubscribeEvent + public void handleChunkSaveEvent(ChunkDataEvent.Save event) { + HashMap<ChunkCoordIntPair, NBTChunk> dimensionData = dimensionWiseChunkData.get(event.world.provider.dimensionId); + NBTChunk chunkData = dimensionData != null ? dimensionData.get(event.getChunk().getChunkCoordIntPair()) : null; + if (chunkData == null) { + event.getData().removeTag(BASE_TAG_NAME); + } else { + chunkData.isLoaded = true; + event.getData().setTag(BASE_TAG_NAME, chunkData.data); + } + } + + @SubscribeEvent + public void handleChunkLoadEvent(ChunkDataEvent.Load event) { + NBTTagCompound loadedTag = event.getData().getCompoundTag(BASE_TAG_NAME); + if (loadedTag.hasNoTags()) { + return; + } + int dimId = event.world.provider.dimensionId; + HashMap<ChunkCoordIntPair, NBTChunk> dimensionMemory = dimensionWiseChunkData.get(dimId); + ChunkCoordIntPair chunkCoordIntPair = event.getChunk().getChunkCoordIntPair(); + Set<String> loadedKeys = loadedTag.func_150296_c(); + NBTChunk chunkMemory = dimensionMemory.get(chunkCoordIntPair); + if (chunkMemory == null) { + chunkMemory = new NBTChunk(loadedTag, true); + dimensionMemory.put(chunkCoordIntPair, chunkMemory); + for (String s : loadedKeys) { + dimensionWiseMetaChunkData.get(s).get(dimId).putLoaded(chunkCoordIntPair, loadedTag.getCompoundTag(s)); + } + } else if (!chunkMemory.isLoaded) { + chunkMemory.isLoaded = true; + + Set<String> tagsDuplicated = new HashSet(loadedKeys); + tagsDuplicated.retainAll(chunkMemory.data.func_150296_c()); + + if (tagsDuplicated.isEmpty()) { + for (String s : loadedKeys) { + NBTTagCompound tag = loadedTag.getCompoundTag(s); + chunkMemory.data.setTag(s, tag); + dimensionWiseMetaChunkData.get(s).get(dimId).putLoaded(chunkCoordIntPair, tag); + } + } else { + for (String s : loadedKeys) { + NBTTagCompound memory = chunkMemory.data.getCompoundTag(s); + if (tagsDuplicated.contains(s)) { + metaDataHandlerHashMap.get(s).mergeData(memory, loadedTag.getCompoundTag(s)); + } else { + chunkMemory.data.setTag(s, loadedTag.getCompoundTag(s)); + dimensionWiseMetaChunkData.get(s).get(dimId).putLoaded(chunkCoordIntPair, memory); + } + } + } + } + } + + @SideOnly(Side.CLIENT) + @SubscribeEvent + public void onLoadChunk(ChunkEvent.Load aEvent){ + if(aEvent.world.isRemote && !Minecraft.getMinecraft().isSingleplayer()) {//we already have the data! + pullSyncHandlers.forEach(chunkMetaDataHandler -> chunkMetaDataHandler.pullData(aEvent)); + } + } + + @SideOnly(Side.CLIENT) + @SubscribeEvent + public void onUnloadChunk(ChunkEvent.Unload aEvent){ + if(aEvent.world.isRemote && !Minecraft.getMinecraft().isSingleplayer()) {//we need all data if running local server! + pullSyncHandlers.forEach(chunkMetaDataHandler -> dimensionWiseMetaChunkData + .get(chunkMetaDataHandler.getTagName()) + .get(aEvent.world.provider.dimensionId) + .remove(aEvent.getChunk().getChunkCoordIntPair())); + } + } + + @SideOnly(Side.CLIENT) + @SubscribeEvent + public void onClientTickEvent(TickEvent.ClientTickEvent aEvent) { + clientHandlers.forEach(chunkMetaDataHandler -> + chunkMetaDataHandler.tickClient( + dimensionWiseMetaChunkData.get(chunkMetaDataHandler.getTagName()), aEvent)); + } + + @SideOnly(Side.CLIENT) + @SubscribeEvent + public void onRenderTickEvent(TickEvent.RenderTickEvent aEvent) { + renderHandlers.forEach(chunkMetaDataHandler -> + chunkMetaDataHandler.tickRender( + dimensionWiseMetaChunkData.get(chunkMetaDataHandler.getTagName()), aEvent)); + } + + @SubscribeEvent + public void onServerTickEvent(TickEvent.ServerTickEvent aEvent) { + serverHandlers.forEach(chunkMetaDataHandler -> + chunkMetaDataHandler.tickServer( + dimensionWiseMetaChunkData.get(chunkMetaDataHandler.getTagName()), aEvent)); + } + + //Ticks only on server side (but must be present for client server) + @SubscribeEvent + public void onWorldTickEvent(TickEvent.WorldTickEvent aEvent) { + int dim = aEvent.world.provider.dimensionId; + pushSyncHandlers.forEach(chunkMetaDataHandler -> { + ChunkHashMap data = dimensionWiseMetaChunkData + .get(chunkMetaDataHandler.getTagName()).get(dim); + int cycle = chunkMetaDataHandler.pushPayloadSpreadPeriod(); + int epoch = (int) (aEvent.world.getTotalWorldTime() % cycle); + ArrayList<ChunkCoordIntPair> work; + if (epoch == 0) { + int per = data.dirtyBoys.size() / cycle; + int mod = data.dirtyBoys.size() % cycle; + Iterator<ChunkCoordIntPair> iter = data.dirtyBoys.iterator(); + for (int periodWork = 0; periodWork < cycle; periodWork++) { + work = data.workLoad.get(periodWork); + for (int i = 0; i < per; i++) { + work.add(iter.next()); + } + if (periodWork < mod) { + work.add(iter.next()); + } + } + data.dirtyBoys.clear(); + } + work = data.workLoad.get(epoch); + chunkMetaDataHandler.pushPayload(aEvent.world, work); + work.clear(); + }); + worldHandlers.forEach(chunkMetaDataHandler -> + chunkMetaDataHandler.tickWorld( + dimensionWiseMetaChunkData.get(chunkMetaDataHandler.getTagName()), aEvent)); + } + + @SubscribeEvent + public void onPlayerTickEvent(TickEvent.PlayerTickEvent aEvent) { + playerHandlers.forEach(chunkMetaDataHandler -> + chunkMetaDataHandler.tickPlayer( + dimensionWiseMetaChunkData.get(chunkMetaDataHandler.getTagName()), aEvent)); + } + + + public void clearData() { + dimensionWiseChunkData.clear(); + dimensionWiseMetaChunkData.forEach((k,v)->v.clear()); + } + + public IChunkMetaDataHandler getChunkMetaDataHandler(String s){ + return metaDataHandlerHashMap.get(s); + } + + public void registerChunkMetaDataHandler(IChunkMetaDataHandler handler){ + metaDataHandlerHashMap.put(handler.getTagName(),handler); + dimensionWiseMetaChunkData.put(handler.getTagName(),new HashMap<>()); + Class clazz=handler.getClass(); + try { + if(clazz.getMethod("tickServer", HashMap.class, TickEvent.ServerTickEvent.class).getDeclaringClass()!= IChunkMetaDataHandler.class){ + serverHandlers.add(handler); + } + if(clazz.getMethod("tickPlayer", HashMap.class, TickEvent.PlayerTickEvent.class).getDeclaringClass()!= IChunkMetaDataHandler.class){ + playerHandlers.add(handler); + } + if (clazz.getMethod("pushData", World.class, ChunkCoordIntPair.class).getDeclaringClass()!=IChunkMetaDataHandler.class) { + pushSyncHandlers.add(handler); + } + if(clazz.getMethod("tickWorld", HashMap.class, TickEvent.WorldTickEvent.class).getDeclaringClass()!= IChunkMetaDataHandler.class){ + worldHandlers.add(handler); + } + } catch (NoSuchMethodException e) { + throw new RuntimeException("Cannot register common event handlers!",e); + } + if(FMLCommonHandler.instance().getSide().isClient()) { + try { + if (clazz.getMethod("pullData", ChunkEvent.Load.class).getDeclaringClass() != IChunkMetaDataHandler.class) { + pullSyncHandlers.add(handler); + } + if (clazz.getMethod("tickClient", HashMap.class, TickEvent.ClientTickEvent.class).getDeclaringClass() != IChunkMetaDataHandler.class) { + clientHandlers.add(handler); + } + if (clazz.getMethod("tickRender", HashMap.class, TickEvent.RenderTickEvent.class).getDeclaringClass() != IChunkMetaDataHandler.class) { + renderHandlers.add(handler); + } + } catch (NoSuchMethodException e) { + throw new RuntimeException("Cannot register client event handlers!",e); + } + } + } + + public NBTTagCompound removeChunkData(IChunkMetaDataHandler handler, int world, ChunkCoordIntPair chunk){ + return dimensionWiseMetaChunkData.get(handler.getTagName()).get(world).remove(chunk); + } + + public NBTTagCompound getChunkData(IChunkMetaDataHandler handler, int world, ChunkCoordIntPair chunk){ + return dimensionWiseMetaChunkData.get(handler.getTagName()).get(world).get(chunk); + } + + public NBTTagCompound putChunkData(IChunkMetaDataHandler handler, int world, ChunkCoordIntPair chunk, NBTTagCompound data){ + return dimensionWiseMetaChunkData.get(handler.getTagName()).get(world).put(chunk,data); + } + + public NBTTagCompound createIfAbsentChunkData(IChunkMetaDataHandler handler, int world, ChunkCoordIntPair chunk){ + return dimensionWiseMetaChunkData.get(handler.getTagName()).get(world) + .computeIfAbsent(chunk,chunkCoordIntPair -> handler.createData()); + } + + public HashMap<Integer,ChunkHashMap> getChunkData(IChunkMetaDataHandler chunkMetaDataHandler){ + return dimensionWiseMetaChunkData.get(chunkMetaDataHandler.getTagName()); + } + + public ChunkHashMap getChunkData(IChunkMetaDataHandler chunkMetaDataHandler, int world){ + return dimensionWiseMetaChunkData.get(chunkMetaDataHandler.getTagName()).get(world); + } + + public static final class ChunkHashMap implements Map<ChunkCoordIntPair,NBTTagCompound>{ + private final HashMap<ChunkCoordIntPair,NBTChunk> storage; + private final HashMap<ChunkCoordIntPair,NBTTagCompound> storageMeta=new HashMap<>(1024); + private final HashSet<ChunkCoordIntPair> dirtyBoys=new HashSet<>(1024); + private final ArrayList<ArrayList<ChunkCoordIntPair>> workLoad=new ArrayList<>(); + private final String meta; + + private ChunkHashMap(IChunkMetaDataHandler meta, HashMap<ChunkCoordIntPair, NBTChunk> storage) { + this.storage =storage; + this.meta=meta.getTagName(); + for (int i = 0; i < meta.pushPayloadSpreadPeriod(); i++) { + workLoad.add(new ArrayList<>(128)); + } + } + + public void markForTransmissionToClient(ChunkCoordIntPair chunk){ + dirtyBoys.add(chunk); + } + + private void putLoaded(ChunkCoordIntPair key, NBTTagCompound value) { + storageMeta.put(key, value); + } + + @Override + public NBTTagCompound remove(Object key) { + NBTTagCompound compound=storageMeta.remove(key); + if(compound!=null) { + NBTChunk chunk = storage.get(key); + chunk.data.removeTag(meta); + if(chunk.data.hasNoTags()){ + storage.remove(key); + } + } + return compound; + } + + @Override + public NBTTagCompound put(ChunkCoordIntPair key, NBTTagCompound value) { + if(value==null){ + return remove(key); + } + NBTChunk chunk = storage.get(key); + if(chunk==null){ + NBTTagCompound base=new NBTTagCompound(); + base.setTag(meta,value); + storage.put(key,new NBTChunk(base,false)); + }else { + chunk.data.setTag(meta,value); + } + return storageMeta.put(key, value); + } + + @Override + public int size() { + return storageMeta.size(); + } + + @Override + public boolean isEmpty() { + return storageMeta.isEmpty(); + } + + @Override + public NBTTagCompound get(Object key) { + return storageMeta.get(key); + } + + @Override + public void clear() { + storageMeta.entrySet().forEach(this::remove); + } + + @Override + public void putAll(Map<? extends ChunkCoordIntPair, ? extends NBTTagCompound> m) { + m.forEach(this::put); + } + + @Override + public boolean containsKey(Object key) { + return storageMeta.containsKey(key); + } + + @Override + public boolean containsValue(Object value) { + return storageMeta.containsValue(value); + } + + @Override + public Set<ChunkCoordIntPair> keySet() { + return storageMeta.keySet(); + } + + @Override + public Collection<NBTTagCompound> values() { + return storageMeta.values(); + } + + @Override + public Set<Entry<ChunkCoordIntPair, NBTTagCompound>> entrySet() { + return storageMeta.entrySet(); + } + } + + private static final class NBTChunk { + private final NBTTagCompound data; + private boolean isLoaded; + + private NBTChunk(NBTTagCompound data, boolean isLoaded) { + if(data==null){ + data=new NBTTagCompound(); + } + this.data = data; + this.isLoaded = isLoaded; + } + } +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/data/ChunkDataMessage.java b/src/main/java/com/github/technus/tectech/mechanics/data/ChunkDataMessage.java new file mode 100644 index 0000000000..a8ed9de2c8 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/data/ChunkDataMessage.java @@ -0,0 +1,101 @@ +package com.github.technus.tectech.mechanics.data; + +import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.Util; +import com.github.technus.tectech.loader.NetworkDispatcher; +import cpw.mods.fml.common.network.ByteBufUtils; +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; +import eu.usrv.yamcore.network.client.AbstractClientMessageHandler; +import eu.usrv.yamcore.network.server.AbstractServerMessageHandler; +import io.netty.buffer.ByteBuf; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.ChunkCoordIntPair; +import net.minecraftforge.event.world.ChunkEvent; + +public class ChunkDataMessage implements IMessage { + int worldId; + ChunkCoordIntPair chunk; + NBTTagCompound data; + IChunkMetaDataHandler handler; + + public ChunkDataMessage(){} + + @Override + public void fromBytes(ByteBuf pBuffer) { + NBTTagCompound tag = ByteBufUtils.readTag(pBuffer); + worldId = tag.getInteger("wId"); + chunk=new ChunkCoordIntPair( + tag.getInteger("posx"), + tag.getInteger("posz")); + handler = TecTech.chunkDataHandler.getChunkMetaDataHandler( + tag.getString("handle")); + if(tag.hasKey("data")){ + data=tag.getCompoundTag("data"); + } + } + + @Override + public void toBytes(ByteBuf pBuffer) { + NBTTagCompound tag = new NBTTagCompound(); + tag.setInteger("wId",worldId); + tag.setInteger("posx",chunk.chunkXPos); + tag.setInteger("posz",chunk.chunkZPos); + tag.setString("handle",handler.getTagName()); + if(data!=null){ + tag.setTag("data",data); + } + ByteBufUtils.writeTag(pBuffer, tag); + } + + public static class ChunkDataQuery extends ChunkDataMessage { + public ChunkDataQuery() { + } + public ChunkDataQuery(ChunkEvent.Load aEvent, IChunkMetaDataHandler handler) { + worldId=aEvent.world.provider.dimensionId; + chunk=aEvent.getChunk().getChunkCoordIntPair(); + this.handler=handler; + } + } + + public static class ChunkDataData extends ChunkDataMessage { + public ChunkDataData() { + } + + public ChunkDataData(int worldId, ChunkCoordIntPair chunk, IChunkMetaDataHandler handler){ + this.worldId=worldId; + this.chunk=chunk; + this.handler=handler; + this.data=TecTech.chunkDataHandler.getChunkData(handler,worldId,chunk); + } + + public ChunkDataData(ChunkDataQuery query){ + worldId=query.worldId; + chunk=query.chunk; + handler=query.handler; + data=TecTech.chunkDataHandler.getChunkData(handler,worldId,chunk); + } + } + + public static class ClientHandler extends AbstractClientMessageHandler<ChunkDataData> { + @Override + public IMessage handleClientMessage(EntityPlayer pPlayer, ChunkDataData pMessage, MessageContext pCtx) { + if(Util.checkChunkExist(pPlayer.worldObj,pMessage.chunk)){ + TecTech.chunkDataHandler.putChunkData(pMessage.handler, pMessage.worldId,pMessage.chunk, pMessage.data); + } + return null; + } + } + + public static class ServerHandler extends AbstractServerMessageHandler<ChunkDataQuery> { + @Override + public IMessage handleServerMessage(EntityPlayer pPlayer, ChunkDataQuery pMessage, MessageContext pCtx) { + if(pPlayer instanceof EntityPlayerMP){ + NetworkDispatcher.INSTANCE.sendTo(new ChunkDataData(pMessage),(EntityPlayerMP) pPlayer); + } + return null; + } + } +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/data/IChunkMetaDataHandler.java b/src/main/java/com/github/technus/tectech/mechanics/data/IChunkMetaDataHandler.java new file mode 100644 index 0000000000..0be1fec517 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/data/IChunkMetaDataHandler.java @@ -0,0 +1,35 @@ +package com.github.technus.tectech.mechanics.data; + +import cpw.mods.fml.common.gameevent.TickEvent; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.ChunkCoordIntPair; +import net.minecraft.world.World; +import net.minecraftforge.event.world.ChunkEvent; + +import java.util.ArrayList; +import java.util.HashMap; + +public interface IChunkMetaDataHandler { + String getTagName(); + void mergeData(NBTTagCompound target, NBTTagCompound loadedData); + NBTTagCompound createData(); + @SideOnly(Side.CLIENT) + default void pullData(ChunkEvent.Load aEvent){} + default void pushData(World world, ChunkCoordIntPair chunk){} + default void pushPayload(World world, ArrayList<ChunkCoordIntPair> chunk){ + chunk.forEach(chunkCoordIntPair -> pushData(world,chunkCoordIntPair)); + } + default int pushPayloadSpreadPeriod(){ + return 20;//must be a constant! + } + @SideOnly(Side.CLIENT) + default void tickRender(HashMap<Integer, ChunkDataHandler.ChunkHashMap> data, TickEvent.RenderTickEvent event){} + @SideOnly(Side.CLIENT) + default void tickClient(HashMap<Integer, ChunkDataHandler.ChunkHashMap> data, TickEvent.ClientTickEvent event){} + default void tickServer(HashMap<Integer, ChunkDataHandler.ChunkHashMap> data, TickEvent.ServerTickEvent event){} + default void tickWorld(HashMap<Integer, ChunkDataHandler.ChunkHashMap> data, TickEvent.WorldTickEvent event){} + default void tickPlayer(HashMap<Integer, ChunkDataHandler.ChunkHashMap> data, TickEvent.PlayerTickEvent event){} +} + diff --git a/src/main/java/com/github/technus/tectech/mechanics/data/PlayerDataMessage.java b/src/main/java/com/github/technus/tectech/mechanics/data/PlayerDataMessage.java new file mode 100644 index 0000000000..ca62fb0876 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/data/PlayerDataMessage.java @@ -0,0 +1,90 @@ +package com.github.technus.tectech.mechanics.data; + +import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.loader.NetworkDispatcher; +import cpw.mods.fml.common.network.ByteBufUtils; +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; +import eu.usrv.yamcore.network.client.AbstractClientMessageHandler; +import eu.usrv.yamcore.network.server.AbstractServerMessageHandler; +import io.netty.buffer.ByteBuf; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.nbt.NBTTagCompound; + +import java.util.UUID; + +import static java.nio.charset.Charset.forName; + +public class PlayerDataMessage implements IMessage { + NBTTagCompound data; + UUID uuid1,uuid2; + + public PlayerDataMessage(){} + + @Override + public void fromBytes(ByteBuf pBuffer) { + NBTTagCompound tag = ByteBufUtils.readTag(pBuffer); + uuid1=UUID.fromString(tag.getString("id1")); + uuid2=UUID.fromString(tag.getString("id2")); + if(tag.hasKey("data")){ + data=tag.getCompoundTag("data"); + } + } + + @Override + public void toBytes(ByteBuf pBuffer) { + NBTTagCompound tag = new NBTTagCompound(); + tag.setString("id1",uuid1.toString()); + tag.setString("id2",uuid2.toString()); + if(data!=null){ + tag.setTag("data",data); + } + ByteBufUtils.writeTag(pBuffer, tag); + } + + public static class PlayerDataQuery extends PlayerDataMessage { + public PlayerDataQuery() { + } + + public PlayerDataQuery(EntityPlayer player) { + uuid1=player.getUniqueID(); + uuid2=UUID.nameUUIDFromBytes(player.getCommandSenderName().getBytes(forName("UTF-8"))); + } + } + + public static class PlayerDataData extends PlayerDataMessage { + public PlayerDataData() { + } + + public PlayerDataData(EntityPlayer player){ + uuid1=player.getUniqueID(); + uuid2=UUID.nameUUIDFromBytes(player.getCommandSenderName().getBytes(forName("UTF-8"))); + data=TecTech.playerPersistence.getDataOrSetToNewTag(player); + } + + public PlayerDataData(PlayerDataQuery query){ + uuid1=query.uuid1; + uuid2=query.uuid2; + data= TecTech.playerPersistence.getDataOrSetToNewTag(uuid1,uuid2); + } + } + + public static class ClientHandler extends AbstractClientMessageHandler<PlayerDataData> { + @Override + public IMessage handleClientMessage(EntityPlayer pPlayer, PlayerDataData pMessage, MessageContext pCtx) { + TecTech.playerPersistence.putDataOrSetToNewTag(pMessage.uuid1,pMessage.uuid2,pMessage.data); + return null; + } + } + + public static class ServerHandler extends AbstractServerMessageHandler<PlayerDataQuery> { + @Override + public IMessage handleServerMessage(EntityPlayer pPlayer, PlayerDataQuery pMessage, MessageContext pCtx) { + if(pPlayer instanceof EntityPlayerMP){ + NetworkDispatcher.INSTANCE.sendTo(new PlayerDataData(pMessage),(EntityPlayerMP) pPlayer); + } + return null; + } + } +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/data/PlayerPersistence.java b/src/main/java/com/github/technus/tectech/mechanics/data/PlayerPersistence.java new file mode 100644 index 0000000000..0a829de3e9 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/data/PlayerPersistence.java @@ -0,0 +1,79 @@ +package com.github.technus.tectech.mechanics.data; + +import com.github.technus.tectech.Util; +import com.github.technus.tectech.loader.NetworkDispatcher; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.PlayerEvent; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.server.MinecraftServer; +import net.minecraft.world.WorldServer; + +import java.util.HashMap; +import java.util.UUID; + +import static java.nio.charset.Charset.forName; + +public class PlayerPersistence { + private final HashMap<UUID, NBTTagCompound> map=new HashMap<>(); + private final String extension; + + public PlayerPersistence(String extension) { + this.extension = extension; + } + + public NBTTagCompound getDataOrSetToNewTag(UUID uuid1, UUID uuid2){ + NBTTagCompound tag=map.get(uuid1); + if(tag!=null){ + return tag; + } + tag=map.get(uuid2); + if(tag!=null){ + return tag; + } + tag=Util.getPlayerData(uuid1,uuid2,extension); + if(tag==null){ + tag=new NBTTagCompound(); + } + map.put(uuid1,tag); + map.put(uuid2,tag); + return tag; + } + + public NBTTagCompound getDataOrSetToNewTag(EntityPlayer player){ + return getDataOrSetToNewTag(player.getUniqueID(),UUID.nameUUIDFromBytes(player.getCommandSenderName().getBytes(forName("UTF-8")))); + } + + public void putDataOrSetToNewTag(UUID uuid1, UUID uuid2, NBTTagCompound tagCompound){ + if(tagCompound==null){ + tagCompound=new NBTTagCompound(); + } + map.put(uuid1,tagCompound); + map.put(uuid2,tagCompound); + } + + public void putDataOrSetToNewTag(EntityPlayer player, NBTTagCompound tagCompound){ + putDataOrSetToNewTag(player.getUniqueID(),UUID.nameUUIDFromBytes(player.getCommandSenderName().getBytes(forName("UTF-8"))),tagCompound); + } + + public void saveData(EntityPlayer player){ + Util.savePlayerFile(player,extension,getDataOrSetToNewTag(player)); + } + + @SubscribeEvent + public void onLogin(PlayerEvent.PlayerLoggedInEvent event){ + if(!event.player.worldObj.isRemote){ + for (WorldServer worldServer : MinecraftServer.getServer().worldServers) { + for (Object playerEntity : worldServer.playerEntities) { + NetworkDispatcher.INSTANCE.sendTo(new PlayerDataMessage.PlayerDataData((EntityPlayer) playerEntity),(EntityPlayerMP) event.player); + } + } + NetworkDispatcher.INSTANCE.sendToAll(new PlayerDataMessage.PlayerDataData(event.player)); + } + } + + public void clearData() { + map.clear(); + } +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/data/WorldData.java b/src/main/java/com/github/technus/tectech/mechanics/data/WorldData.java new file mode 100644 index 0000000000..4f6f730c9b --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/data/WorldData.java @@ -0,0 +1,52 @@ +package com.github.technus.tectech.mechanics.data; + +import net.minecraft.world.ChunkCoordIntPair; +import net.minecraft.world.World; +import net.minecraft.world.chunk.Chunk; + +import java.util.Objects; + +public final class WorldData { + private final World world; + private final Chunk chunk; + private final ChunkCoordIntPair coordIntPair; + + public WorldData(World world, Chunk data) { + this.world = world; + this.chunk = data; + coordIntPair=data.getChunkCoordIntPair(); + } + + public WorldData(World world, ChunkCoordIntPair data) { + this.world = world; + this.coordIntPair = data; + chunk= world.getChunkFromChunkCoords(data.chunkXPos,data.chunkZPos); + } + + public World getWorld() { + return world; + } + + public Chunk getChunk() { + return chunk; + } + + public ChunkCoordIntPair getCoordIntPair() { + return coordIntPair; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + WorldData worldData = (WorldData) o; + return world.provider.dimensionId==worldData.world.provider.dimensionId && + coordIntPair.chunkXPos==worldData.coordIntPair.chunkXPos && + coordIntPair.chunkZPos==worldData.coordIntPair.chunkXPos; + } + + @Override + public int hashCode() { + return Objects.hash(world.provider.dimensionId, coordIntPair); + } +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/cElementalDecay.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/cElementalDecay.java index 7f56ee8e5b..7d5e079876 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/cElementalDecay.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/cElementalDecay.java @@ -8,7 +8,7 @@ import com.github.technus.tectech.mechanics.elementalMatter.core.templates.iElem * Created by danie_000 on 22.10.2016. */ public final class cElementalDecay { - public static final cElementalDecay[] noDecay = (cElementalDecay[]) null; + public static final cElementalDecay[] noDecay = null; //DECAY IMPOSSIBLE!!! //Do not use regular NULL java will not make it work with varargs!!! //Or cast null into ARRAY type but this static is more convenient!!! diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/cElementalStackMap.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/cElementalStackMap.java index 19f5789804..fb6acec084 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/cElementalStackMap.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/cElementalStackMap.java @@ -48,12 +48,12 @@ abstract class cElementalStackMap implements Comparable<cElementalStackMap> { public final cElementalDefinitionStack[] values() { Collection<cElementalDefinitionStack> var = map.values(); - return var.toArray(new cElementalDefinitionStack[var.size()]); + return var.toArray(new cElementalDefinitionStack[0]); } public final iElementalDefinition[] keys() { Set<iElementalDefinition> var = map.keySet(); - return var.toArray(new iElementalDefinition[var.size()]); + return var.toArray(new iElementalDefinition[0]); } public long getCountOfAllAmounts(){ diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/commands/GiveEM.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/commands/GiveEM.java index ad8d1ad8c8..333359949f 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/commands/GiveEM.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/commands/GiveEM.java @@ -45,8 +45,7 @@ public class GiveEM implements ICommand { }else{ TecTech.LOGGER.info("Spawninig EM for "+((EntityPlayerMP) sender).getDisplayName()+" - "+Arrays.toString(args)); - ArrayList<String> list=new ArrayList<>(); - list.addAll(Arrays.asList(args)); + ArrayList<String> list = new ArrayList<>(Arrays.asList(args)); String energy=list.remove(0); cElementalDefinitionStack def= getDefinitionStack(list); diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/commands/ListEM.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/commands/ListEM.java index 9e034f4655..20110c0b0d 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/commands/ListEM.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/commands/ListEM.java @@ -29,7 +29,7 @@ public class ListEM implements ICommand { sender.addChatMessage(new ChatComponentText(" Available Classes: tag - name")); Map<Byte,Method> binds= cElementalDefinition.getBindsComplex(); for (Map.Entry<Byte,Method> e:binds.entrySet()) { - sender.addChatMessage(new ChatComponentText(String.valueOf((char)e.getKey().byteValue())+" - "+e.getValue().getReturnType().getSimpleName())); + sender.addChatMessage(new ChatComponentText((char) e.getKey().byteValue() +" - "+e.getValue().getReturnType().getSimpleName())); } }else if(args.length==1){ sender.addChatMessage(new ChatComponentText(" Available Primitives: symbol - name")); diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/iElementalInstanceContainer.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/iElementalInstanceContainer.java index 5244676643..20fe1ffc5b 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/iElementalInstanceContainer.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/iElementalInstanceContainer.java @@ -6,5 +6,5 @@ package com.github.technus.tectech.mechanics.elementalMatter.core; public interface iElementalInstanceContainer extends Cloneable { cElementalInstanceStackMap getContainerHandler(); - float purgeOverflow(); + void purgeOverflow(); } diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/rElementalRecipe.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/rElementalRecipe.java index c2fd9a81d4..e191cc0e0a 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/rElementalRecipe.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/rElementalRecipe.java @@ -38,13 +38,7 @@ public class rElementalRecipe implements Comparable<rElementalRecipe> { if(compare!=0) { return compare; } - if(ID>o.ID) { - return 1; - } - if(ID<o.ID) { - return -1; - } - return 0; + return Short.compare(ID, o.ID); } @Override diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/rElementalRecipeMap.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/rElementalRecipeMap.java index c289fc94ae..ed5e46f43f 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/rElementalRecipeMap.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/rElementalRecipeMap.java @@ -15,11 +15,7 @@ public class rElementalRecipeMap {//TODO FIX } public rElementalRecipe put(rElementalRecipe in) { - HashMap<Short, rElementalRecipe> r = recipes.get(in.inEM); - if (r == null) { - r = new HashMap<>(); - recipes.put(in.inEM, r); - } + HashMap<Short, rElementalRecipe> r = recipes.computeIfAbsent(in.inEM, k -> new HashMap<>()); return r.put(in.ID, in);//IF THIS RETURN SHIT, it means that inputs are using the exact same types of matter as input - (non amount wise collision) //It is either bad, or unimportant if you use different id's } diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/stacks/cElementalInstanceStack.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/stacks/cElementalInstanceStack.java index d97ec5d1f6..7c04fe2c40 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/stacks/cElementalInstanceStack.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/stacks/cElementalInstanceStack.java @@ -275,17 +275,21 @@ public final class cElementalInstanceStack implements iHasElementalDefinition { } cElementalInstanceStackMap products=decays[0].getResults(lifeTimeMult, newProductsAge, newEnergyLevel, amount); if(newProductsAge<0){ - for(cElementalInstanceStack stack:products.values()){ - if(stack.definition.equals(definition)){ - stack.age= age; - stack.setEnergy(energy); + if(products.size()==1) { + if(products.size()==1 && products.get(0).definition.equals(definition)) { + products.get(0).setEnergy(energy); + products.get(0).age=age; + } + }else { + for (cElementalInstanceStack stack : products.values()) { + if (stack.definition.equals(definition)) { + stack.age = age; + } } } }else{ - for(cElementalInstanceStack stack:products.values()){ - if(stack.definition.equals(definition)){ - stack.setEnergy(energy); - } + if(products.size()==1 && products.get(0).definition.equals(definition)) { + products.get(0).setEnergy(energy); } } if(this.energy <= 0 && products.getMass() > getMass()){ @@ -361,18 +365,21 @@ public final class cElementalInstanceStack implements iHasElementalDefinition { } } - if(newProductsAge<0){ - for(cElementalInstanceStack stack:output.values()){ - if(stack.definition.equals(definition)){ - stack.age= age; - stack.setEnergy(energy); + if(newProductsAge<0) { + if (output.size() == 1 && output.get(0).definition.equals(definition)) { + output.get(0).setEnergy(energy); + output.get(0).age = age; + } else { + for (cElementalInstanceStack stack : output.values()) { + if (stack.definition.equals(definition)) { + stack.age = age; + } } } }else{ - for(cElementalInstanceStack stack:output.values()){ - if(stack.definition.equals(definition)){ - stack.setEnergy(energy); - } + if(output.size()==1 && output.get(0).definition.equals(definition)) { + output.get(0).setEnergy(energy); + output.get(0).age=age; } } if(this.energy <= 0 && output.getMass() > getMass()){ @@ -420,9 +427,9 @@ public final class cElementalInstanceStack implements iHasElementalDefinition { } definition.addScanResults(lines,capabilities,energy); if(Util.areBitsSet(SCAN_GET_TIMESPAN_MULT,capabilities)) { - lines.add("TIME SPAN MULTIPLIER = " + lifeTimeMult); + lines.add("TIME MULT = " + lifeTimeMult); if(Util.areBitsSet(SCAN_GET_TIMESPAN_INFO,capabilities)) { - lines.add("TIME SPAN MULTIPLIED = " + lifeTime + " s"); + lines.add("TIME SPAN = " + lifeTime + " s"); } } if(Util.areBitsSet(SCAN_GET_AGE,capabilities)) { @@ -432,7 +439,7 @@ public final class cElementalInstanceStack implements iHasElementalDefinition { lines.add("COLOR = " + color + " RGB or CMY"); } if(Util.areBitsSet(SCAN_GET_ENERGY_LEVEL,capabilities)) { - lines.add("E. LEVEL = " + energy); + lines.add("ENERGY = " + energy); } if(Util.areBitsSet(SCAN_GET_AMOUNT,capabilities)) { lines.add("AMOUNT = " + amount); diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/templates/cElementalPrimitive.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/templates/cElementalPrimitive.java index 738301d50c..749d5c687b 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/templates/cElementalPrimitive.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/templates/cElementalPrimitive.java @@ -1,7 +1,6 @@ package com.github.technus.tectech.mechanics.elementalMatter.core.templates; import com.github.technus.tectech.TecTech; -import com.github.technus.tectech.Util; import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalDecay; import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalDefinitionStackMap; import com.github.technus.tectech.mechanics.elementalMatter.core.tElementalException; @@ -16,6 +15,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.Map; +import static com.github.technus.tectech.Util.areBitsSet; import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.cPrimitiveDefinition.null__; import static com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_scanner.*; @@ -212,23 +212,23 @@ public abstract class cElementalPrimitive extends cElementalDefinition { @Override public void addScanResults(ArrayList<String> lines, int capabilities, long energyLevel) { - if(Util.areBitsSet(SCAN_GET_CLASS_TYPE, capabilities)) { + if(areBitsSet(SCAN_GET_CLASS_TYPE, capabilities)) { lines.add("CLASS = " + nbtType + ' ' + getClassType()); } - if(Util.areBitsSet(SCAN_GET_NOMENCLATURE|SCAN_GET_CHARGE|SCAN_GET_MASS|SCAN_GET_TIMESPAN_INFO, capabilities)) { + if(areBitsSet(SCAN_GET_NOMENCLATURE|SCAN_GET_CHARGE|SCAN_GET_MASS|SCAN_GET_TIMESPAN_INFO, capabilities)) { lines.add("NAME = "+getName()); lines.add("SYMBOL = "+getSymbol()); } - if(Util.areBitsSet(SCAN_GET_CHARGE,capabilities)) { + if(areBitsSet(SCAN_GET_CHARGE,capabilities)) { lines.add("CHARGE = " + getCharge() / 3f + " e"); } - if(Util.areBitsSet(SCAN_GET_COLOR,capabilities)) { + if(areBitsSet(SCAN_GET_COLOR,capabilities)) { lines.add(getColor() < 0 ? "COLORLESS" : "CARRIES COLOR"); } - if(Util.areBitsSet(SCAN_GET_MASS,capabilities)) { + if(areBitsSet(SCAN_GET_MASS,capabilities)) { lines.add("MASS = " + getMass() + " eV/c\u00b2"); } - if(Util.areBitsSet(SCAN_GET_TIMESPAN_INFO, capabilities)){ + if(areBitsSet(SCAN_GET_TIMESPAN_INFO, capabilities)){ lines.add((isTimeSpanHalfLife()?"HALF LIFE = ":"LIFE TIME = ")+getRawTimeSpan(energyLevel)+ " s"); lines.add(" "+"At current energy level"); } @@ -251,13 +251,7 @@ public abstract class cElementalPrimitive extends cElementalDefinition { public final int compareTo(iElementalDefinition o) { if (getClassType() == o.getClassType()) { int oID = ((cElementalPrimitive) o).ID; - if (ID > oID) { - return 1; - } - if (ID < oID) { - return -1; - } - return 0; + return Integer.compare(ID, oID); } return compareClassID(o); } diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/atom/dAtomDefinition.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/atom/dAtomDefinition.java index 23f566075a..86d31bfb1b 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/atom/dAtomDefinition.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/atom/dAtomDefinition.java @@ -396,35 +396,35 @@ public final class dAtomDefinition extends cElementalDefinition { switch (decayMode) { case -2: if(TecTech.RANDOM.nextBoolean() && ElectronCapture(decaysList)) { - return decaysList.toArray(new cElementalDecay[decaysList.size()]); + return decaysList.toArray(new cElementalDecay[0]); } else if(PbetaDecay(decaysList)) { - return decaysList.toArray(new cElementalDecay[decaysList.size()]); + return decaysList.toArray(new cElementalDecay[0]); } break; case -1: if(Emmision(decaysList, dHadronDefinition.hadron_p1)) { - return decaysList.toArray(new cElementalDecay[decaysList.size()]); + return decaysList.toArray(new cElementalDecay[0]); } break; case 0: if(alphaDecay(decaysList)) { - return decaysList.toArray(new cElementalDecay[decaysList.size()]); + return decaysList.toArray(new cElementalDecay[0]); } break; case 1: if(Emmision(decaysList, dHadronDefinition.hadron_n1)) { - return decaysList.toArray(new cElementalDecay[decaysList.size()]); + return decaysList.toArray(new cElementalDecay[0]); } break; case 2: if(MbetaDecay(decaysList)) { - return decaysList.toArray(new cElementalDecay[decaysList.size()]); + return decaysList.toArray(new cElementalDecay[0]); } break; default: if(decayMode>8){ if(iaeaDecay(decaysList,0)) { - return decaysList.toArray(new cElementalDecay[decaysList.size()]); + return decaysList.toArray(new cElementalDecay[0]); } return getDecayArray(decaysList,decayMode- BYTE_OFFSET,false); } @@ -1167,7 +1167,7 @@ public final class dAtomDefinition extends cElementalDefinition { if (iaeaDefinitionExistsAndHasEnergyLevels) { ArrayList<cElementalDecay> decays=new ArrayList<>(4); if(iaeaDecay(decays,energyLevel)){ - return decays.toArray(new cElementalDecay[decays.size()]); + return decays.toArray(new cElementalDecay[0]); } } if(energyLevel< Math.abs(charge)/3+neutralCount) { @@ -1257,7 +1257,7 @@ public final class dAtomDefinition extends cElementalDefinition { decaysInto.add(new cElementalDefinitionStack(boson_Y__, 2)); } } - return new cElementalDecay[]{new cElementalDecay(0.75F, decaysInto.toArray(new cElementalDefinitionStack[decaysInto.size()])), deadEnd}; + return new cElementalDecay[]{new cElementalDecay(0.75F, decaysInto.toArray(new cElementalDefinitionStack[0])), deadEnd}; } //@Override @@ -1357,10 +1357,7 @@ public final class dAtomDefinition extends cElementalDefinition { float rawLifeTime = calculateLifeTime(izoDiff, izoDiffAbs, element, isotope, false); iaeaNuclide nuclide = iaeaNuclide.get(element, isotope); if (rawLifeTime >= STABLE_RAW_LIFE_TIME || nuclide != null && nuclide.halfTime >= STABLE_RAW_LIFE_TIME) { - TreeSet<Integer> isotopes = stableIsotopes.get(element); - if (isotopes == null) { - stableIsotopes.put(element, isotopes = new TreeSet<>()); - } + TreeSet<Integer> isotopes = stableIsotopes.computeIfAbsent(element, k -> new TreeSet<>()); isotopes.add(isotope); } } @@ -1375,10 +1372,7 @@ public final class dAtomDefinition extends cElementalDefinition { int izoDiff = isotope - Isotope; int izoDiffAbs = Math.abs(izoDiff); float rawLifeTime = calculateLifeTime(izoDiff, izoDiffAbs, element, isotope, false); - TreeMap<Float, Integer> isotopes = mostStableUnstableIsotopes.get(element); - if (isotopes == null) { - mostStableUnstableIsotopes.put(element, isotopes = new TreeMap<>()); - } + TreeMap<Float, Integer> isotopes = mostStableUnstableIsotopes.computeIfAbsent(element, k -> new TreeMap<>()); isotopes.put(rawLifeTime, isotope); } } @@ -1652,7 +1646,7 @@ public final class dAtomDefinition extends cElementalDefinition { } if(iaeaDefinitionExistsAndHasEnergyLevels && Util.areBitsSet(SCAN_GET_ENERGY_STATES,capabilities)){ for(int i=1;i<iaea.energeticStatesArray.length;i++){ - lines.add("ENERGY LEVEL "+i+" = "+iaea.energeticStatesArray[i].energy+" eV"); + lines.add("E LEVEL "+i+" = "+iaea.energeticStatesArray[i].energy+" eV"); } } if(Util.areBitsSet(SCAN_GET_TIMESPAN_INFO, capabilities)){ diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/atom/iaeaNuclide.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/atom/iaeaNuclide.java index 10c537ed55..ac44f9242e 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/atom/iaeaNuclide.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/atom/iaeaNuclide.java @@ -134,7 +134,7 @@ public final class iaeaNuclide { if(energeticStates==null || energeticStates.isEmpty()) { energeticStatesArray = empty; } else { - energeticStatesArray = energeticStates.values().toArray(new energeticState[energeticStates.size()]); + energeticStatesArray = energeticStates.values().toArray(new energeticState[0]); } } @@ -273,7 +273,7 @@ public final class iaeaNuclide { //if(DEBUG_MODE){ // System.out.println("INVALID SUM?\t"+normalization+"\t"+decay1+"\t"+chance1+"\t"+decay2+"\t"+chance2+"\t"+decay3+"\t"+chance3); //} - return decays.values().toArray(new iaeaDecay[decays.size()]); + return decays.values().toArray(new iaeaDecay[0]); } public static final class iaeaDecay{ diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/hadron/dHadronDefinition.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/hadron/dHadronDefinition.java index 6b98cd2a99..1d617fcdb9 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/hadron/dHadronDefinition.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/hadron/dHadronDefinition.java @@ -198,7 +198,7 @@ public final class dHadronDefinition extends cElementalDefinition {//TODO Optimi } } return new cElementalDecay[]{ - new cElementalDecay(0.75F, decaysInto.toArray(new cElementalDefinitionStack[decaysInto.size()])), + new cElementalDecay(0.75F, decaysInto.toArray(new cElementalDefinitionStack[0])), eBosonDefinition.deadEnd }; } diff --git a/src/main/java/com/github/technus/tectech/nei/TT_NEI_ResearchHandler.java b/src/main/java/com/github/technus/tectech/nei/TT_NEI_ResearchHandler.java index a797a65d09..1c75dceec7 100644 --- a/src/main/java/com/github/technus/tectech/nei/TT_NEI_ResearchHandler.java +++ b/src/main/java/com/github/technus/tectech/nei/TT_NEI_ResearchHandler.java @@ -365,7 +365,7 @@ public class TT_NEI_ResearchHandler extends TemplateRecipeHandler { } } } - items = tDisplayStacks.toArray(new ItemStack[tDisplayStacks.size()]); + items = tDisplayStacks.toArray(new ItemStack[0]); if (items.length == 0) { items = new ItemStack[]{new ItemStack(Blocks.fire)}; } diff --git a/src/main/java/com/github/technus/tectech/nei/TT_NEI_ScannerHandler.java b/src/main/java/com/github/technus/tectech/nei/TT_NEI_ScannerHandler.java index 8154816cfc..e9624f1b33 100644 --- a/src/main/java/com/github/technus/tectech/nei/TT_NEI_ScannerHandler.java +++ b/src/main/java/com/github/technus/tectech/nei/TT_NEI_ScannerHandler.java @@ -365,7 +365,7 @@ public class TT_NEI_ScannerHandler extends TemplateRecipeHandler { } } } - items = tDisplayStacks.toArray(new ItemStack[tDisplayStacks.size()]); + items = tDisplayStacks.toArray(new ItemStack[0]); if (items.length == 0) { items = new ItemStack[]{new ItemStack(Blocks.fire)}; } diff --git a/src/main/java/com/github/technus/tectech/proxy/ClientProxy.java b/src/main/java/com/github/technus/tectech/proxy/ClientProxy.java index 255cf56e96..232beebfb6 100644 --- a/src/main/java/com/github/technus/tectech/proxy/ClientProxy.java +++ b/src/main/java/com/github/technus/tectech/proxy/ClientProxy.java @@ -4,6 +4,7 @@ import com.github.technus.tectech.Reference; import com.github.technus.tectech.TecTech; import com.github.technus.tectech.compatibility.openmodularturrets.TT_turret_loader; import com.github.technus.tectech.entity.fx.BlockHint; +import com.github.technus.tectech.entity.fx.WeightlessParticleFX; import com.github.technus.tectech.thing.block.QuantumGlassBlock; import com.github.technus.tectech.thing.block.QuantumGlassRender; import com.github.technus.tectech.thing.block.QuantumStuffBlock; @@ -14,9 +15,9 @@ import cpw.mods.fml.common.Loader; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.EntityClientPlayerMP; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiNewChat; -import net.minecraft.client.particle.EntityExplodeFX; import net.minecraft.client.particle.EntityFX; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.AxisAlignedBB; @@ -40,10 +41,10 @@ public class ClientProxy extends CommonProxy { } @Override - public void hint_particle(World world, int x, int y, int z, Block block, int meta) { - Minecraft.getMinecraft().effectRenderer.addEffect(new BlockHint(world,x,y,z,block,meta)); + public void hint_particle(World w,int x, int y, int z, Block block, int meta) { + Minecraft.getMinecraft().effectRenderer.addEffect(new BlockHint(w,x,y,z,block,meta)); - EntityFX particle = new EntityExplodeFX(world, x + TecTech.RANDOM.nextFloat() * 0.5F, y + TecTech.RANDOM.nextFloat() * 0.5F, z + TecTech.RANDOM.nextFloat() * 0.5F, 0, 0, 0); + EntityFX particle = new WeightlessParticleFX(w, x + TecTech.RANDOM.nextFloat() * 0.5F, y + TecTech.RANDOM.nextFloat() * 0.5F, z + TecTech.RANDOM.nextFloat() * 0.5F, 0, 0, 0); particle.setRBGColorF(0, 0.6F * TecTech.RANDOM.nextFloat(), 0.8f); Minecraft.getMinecraft().effectRenderer.addEffect(particle); } @@ -55,23 +56,60 @@ public class ClientProxy extends CommonProxy { float yPos = aDir.offsetY * 0.76F + aMuffler.getYCoord() + 0.25F; float zPos = aDir.offsetZ * 0.76F + aMuffler.getZCoord() + 0.25F; - float ySpd = 0; - //aDir.offsetY*0.1F+0.2F+0.1F*floatGen.nextFloat(); - float xSpd = 0; - float zSpd = 0; - EntityFX particle = new EntityExplodeFX(aMuffler.getWorld(), xPos + TecTech.RANDOM.nextFloat() * 0.5F, yPos + TecTech.RANDOM.nextFloat() * 0.5F, zPos + TecTech.RANDOM.nextFloat() * 0.5F, xSpd, ySpd, zSpd); + EntityFX particle = new WeightlessParticleFX(aMuffler.getWorld(), xPos + TecTech.RANDOM.nextFloat() * 0.5F, yPos + TecTech.RANDOM.nextFloat() * 0.5F, zPos + TecTech.RANDOM.nextFloat() * 0.5F, 0, 0, 0); particle.setRBGColorF(0, 0.6F * TecTech.RANDOM.nextFloat(), 0.8f); Minecraft.getMinecraft().effectRenderer.addEffect(particle); } @Override - public void em_particle(World w,double x,double y,double z) {//CUTE! - EntityFX particle = new EntityExplodeFX(w, x + TecTech.RANDOM.nextFloat() * 0.5F, y + TecTech.RANDOM.nextFloat() * 0.5F, z + TecTech.RANDOM.nextFloat() * 0.5F, 0, 0, 0); + public void pollutor_particle(IGregTechTileEntity aMuffler, byte facing) { + ForgeDirection aDir = ForgeDirection.getOrientation(facing); + float xPos = aDir.offsetX * 0.76F + aMuffler.getXCoord() + 0.25F; + float yPos = aDir.offsetY * 0.76F + aMuffler.getYCoord() + 0.25F; + float zPos = aDir.offsetZ * 0.76F + aMuffler.getZCoord() + 0.25F; + + float ySpd = aDir.offsetY * 0.1F + 0.2F + 0.1F * (float)TecTech.RANDOM.nextGaussian(); + float xSpd; + float zSpd; + + if (aDir.offsetY == -1) { + float temp = TecTech.RANDOM.nextFloat() * 2 * (float) Math.PI; + xSpd = (float) Math.sin(temp) * 0.1F*(float)TecTech.RANDOM.nextGaussian(); + zSpd = (float) Math.cos(temp) * 0.1F*(float)TecTech.RANDOM.nextGaussian(); + } else { + xSpd = aDir.offsetX * (0.1F + 0.2F *(float)TecTech.RANDOM.nextGaussian()); + zSpd = aDir.offsetZ * (0.1F + 0.2F *(float)TecTech.RANDOM.nextGaussian()); + } + aMuffler.getWorld().spawnParticle("largesmoke", xPos + TecTech.RANDOM.nextFloat() * 0.5F, yPos + TecTech.RANDOM.nextFloat() * 0.5F, zPos + TecTech.RANDOM.nextFloat() * 0.5F, xSpd, ySpd, zSpd); + aMuffler.getWorld().spawnParticle("largesmoke", xPos + TecTech.RANDOM.nextFloat() * 0.5F, yPos + TecTech.RANDOM.nextFloat() * 0.5F, zPos + TecTech.RANDOM.nextFloat() * 0.5F, xSpd, ySpd, zSpd); + aMuffler.getWorld().spawnParticle("largesmoke", xPos + TecTech.RANDOM.nextFloat() * 0.5F, yPos + TecTech.RANDOM.nextFloat() * 0.5F, zPos + TecTech.RANDOM.nextFloat() * 0.5F, xSpd, ySpd, zSpd); + } + + @Override + public void em_particle(World w,double x, double y, double z) {//CUTE! + EntityFX particle = new WeightlessParticleFX(w, + x + TecTech.RANDOM.nextFloat() * 0.5F, + y + TecTech.RANDOM.nextFloat() * 0.5F, + z + TecTech.RANDOM.nextFloat() * 0.5F, + 0, + 0, + 0); particle.setRBGColorF(0, 0.6F * TecTech.RANDOM.nextFloat(), 0.8f); Minecraft.getMinecraft().effectRenderer.addEffect(particle); } @Override + public void pollutor_particle(World w,double x, double y, double z) { + w.spawnParticle("largesmoke", + x + TecTech.RANDOM.nextFloat() * 0.5F, + y + TecTech.RANDOM.nextFloat() * 0.5F, + z + TecTech.RANDOM.nextFloat() * 0.5F, + 0, + 0, + 0); + } + + @Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { return null; } @@ -135,7 +173,11 @@ public class ClientProxy extends CommonProxy { } @Override - public void renderAABB(AxisAlignedBB box) { - renderAABB(Minecraft.getMinecraft().theWorld,box); + public EntityClientPlayerMP getPlayer(){ + return Minecraft.getMinecraft().thePlayer; + } + + public boolean isThePlayer(EntityPlayer player){ + return getPlayer()==player; } } diff --git a/src/main/java/com/github/technus/tectech/proxy/CommonProxy.java b/src/main/java/com/github/technus/tectech/proxy/CommonProxy.java index 598a8b148f..296002b527 100644 --- a/src/main/java/com/github/technus/tectech/proxy/CommonProxy.java +++ b/src/main/java/com/github/technus/tectech/proxy/CommonProxy.java @@ -13,9 +13,12 @@ import net.minecraft.world.WorldServer; public class CommonProxy implements IGuiHandler { public void registerRenderInfo() {} - public void hint_particle(World world, int x, int y, int z, Block block, int meta){} + public void hint_particle(World w,int x, int y, int z, Block block, int meta){} public void em_particle(IGregTechTileEntity aMuffler, byte facing) {}//CUTE! - public void em_particle(World w,double x,double y,double z){} + public void pollutor_particle(IGregTechTileEntity aPollutor, byte facing) {}//CUTE! + public void em_particle(World w,double x, double y, double z){} + public void pollutor_particle(World w,double x, double y, double z){} + public void renderAABB(World w,AxisAlignedBB box){} @Override public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { @@ -46,9 +49,6 @@ public class CommonProxy implements IGuiHandler { public void playSound(IGregTechTileEntity base,String name){} - public void renderAABB(AxisAlignedBB box){} - public void renderAABB(World w,AxisAlignedBB box){} - public String getUUID(String name) { for(WorldServer worldServer:MinecraftServer.getServer().worldServers){ for(Object o:worldServer.playerEntities){ @@ -81,4 +81,12 @@ public class CommonProxy implements IGuiHandler { } return false; } + + public EntityPlayer getPlayer(){ + return null; + } + + public boolean isThePlayer(EntityPlayer player){ + return false; + } } diff --git a/src/main/java/com/github/technus/tectech/recipe/TT_recipe.java b/src/main/java/com/github/technus/tectech/recipe/TT_recipe.java index 57d479a705..b4dc5775d7 100644 --- a/src/main/java/com/github/technus/tectech/recipe/TT_recipe.java +++ b/src/main/java/com/github/technus/tectech/recipe/TT_recipe.java @@ -20,12 +20,12 @@ public class TT_recipe extends GT_Recipe { public final cElementalDefinitionStackMap[] input; public final cElementalDefinitionStackMap[] output; public final cElementalDefinitionStackMap[] eCatalyst; - public final AdditionalCheck additionalCheck; + public final IAdditionalCheck additionalCheck; public TT_recipe(boolean aOptimize, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecialItems, int[] aChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue, - cElementalDefinitionStackMap[] in, cElementalDefinitionStackMap[] out, cElementalDefinitionStackMap[] catalyst, AdditionalCheck check){ + cElementalDefinitionStackMap[] in, cElementalDefinitionStackMap[] out, cElementalDefinitionStackMap[] catalyst, IAdditionalCheck check){ super(aOptimize,aInputs,aOutputs,aSpecialItems,aChances,aFluidInputs,aFluidOutputs,aDuration,aEUt,aSpecialValue); input=in; output=out; @@ -127,7 +127,7 @@ public class TT_recipe extends GT_Recipe { return super.isRecipeInputEqual(consume, doNotCheckStackSizes, fluidStacks, itemStacks); } - public interface AdditionalCheck { + public interface IAdditionalCheck { boolean check(TT_recipe thisRecipe, boolean consume, boolean doNotCheckStackSizes, ItemStack[] itemStacks, FluidStack[] fluidStacks, cElementalInstanceStackMap[] in, cElementalInstanceStackMap[] e); boolean check(TT_recipe thisRecipe, boolean consume, boolean doNotCheckStackSizes, ItemStack[] itemStacks, FluidStack[] fluidStacks, cElementalInstanceStackMap in, cElementalInstanceStackMap[] e); } @@ -165,8 +165,8 @@ public class TT_recipe extends GT_Recipe { } public static class GT_Recipe_MapTT extends GT_Recipe.GT_Recipe_Map { - public static GT_Recipe_MapTT sResearchableFakeRecipes =new GT_Recipe_MapTT(new HashSet<GT_Recipe>(32), "gt.recipe.researchStation", "Research station", (String)null, "gregtech:textures/gui/multimachines/ResearchFake", 1, 1,1,0,1,"", 1, "", true, false);//nei to false - using custom handler - public static GT_Recipe_MapTT sScannableFakeRecipes = new GT_Recipe_MapTT(new HashSet<GT_Recipe>(32),"gt.recipe.em_scanner","EM Scanner Research",(String)null,"gregtech:textures/gui/multimachines/ResearchFake",1,1,1,0,1,"",1,"",true,false); + public static GT_Recipe_MapTT sResearchableFakeRecipes =new GT_Recipe_MapTT(new HashSet<>(32), "gt.recipe.researchStation", "Research station", null, "gregtech:textures/gui/multimachines/ResearchFake", 1, 1,1,0,1,"", 1, "", true, false);//nei to false - using custom handler + public static GT_Recipe_MapTT sScannableFakeRecipes = new GT_Recipe_MapTT(new HashSet<>(32),"gt.recipe.em_scanner","EM Scanner Research", null,"gregtech:textures/gui/multimachines/ResearchFake",1,1,1,0,1,"",1,"",true,false); public GT_Recipe_MapTT(Collection<GT_Recipe> aRecipeList, String aUnlocalizedName, String aLocalName, String aNEIName, String aNEIGUIPath, int aUsualInputCount, int aUsualOutputCount, int aMinimalInputItems, int aMinimalInputFluids, int aAmperage, String aNEISpecialValuePre, int aNEISpecialValueMultiplier, String aNEISpecialValuePost, boolean aShowVoltageAmperageInNEI, boolean aNEIAllowed) { super(aRecipeList, aUnlocalizedName, aLocalName, aNEIName, aNEIGUIPath, aUsualInputCount, aUsualOutputCount, aMinimalInputItems, aMinimalInputFluids, aAmperage, aNEISpecialValuePre, aNEISpecialValueMultiplier, aNEISpecialValuePost, aShowVoltageAmperageInNEI, aNEIAllowed); @@ -179,7 +179,7 @@ public class TT_recipe extends GT_Recipe { public TT_assLineRecipe(boolean aOptimize, ItemStack researchItem, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecialItems, FluidStack[] aFluidInputs, int aDuration, int aEUt, int aSpecialValue, - cElementalDefinitionStackMap[] in, cElementalDefinitionStackMap[] out, cElementalDefinitionStackMap[] catalyst, AdditionalCheck check) { + cElementalDefinitionStackMap[] in, cElementalDefinitionStackMap[] out, cElementalDefinitionStackMap[] catalyst, IAdditionalCheck check) { super(aOptimize, aInputs, aOutputs, aSpecialItems, null, aFluidInputs, null, aDuration, aEUt, aSpecialValue, in, out, catalyst, check); mResearchItem=researchItem; } @@ -199,7 +199,7 @@ public class TT_recipe extends GT_Recipe { public TT_EMRecipe(boolean aOptimize, GT_Recipe scannerRecipe, iElementalDefinition researchEM, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecialItems, FluidStack[] aFluidInputs, int aDuration, int aEUt, int aSpecialValue, - cElementalDefinitionStackMap[] in, cElementalDefinitionStackMap[] out, cElementalDefinitionStackMap[] catalyst, AdditionalCheck check) { + cElementalDefinitionStackMap[] in, cElementalDefinitionStackMap[] out, cElementalDefinitionStackMap[] catalyst, IAdditionalCheck check) { super(aOptimize, aInputs, aOutputs, aSpecialItems, null, aFluidInputs, null, aDuration, aEUt, aSpecialValue, in, out, catalyst, check); mResearchEM=researchEM; this.scannerRecipe=scannerRecipe; diff --git a/src/main/java/com/github/technus/tectech/recipe/TT_recipeAdder.java b/src/main/java/com/github/technus/tectech/recipe/TT_recipeAdder.java index 4e352a7610..6fd4d7edaa 100644 --- a/src/main/java/com/github/technus/tectech/recipe/TT_recipeAdder.java +++ b/src/main/java/com/github/technus/tectech/recipe/TT_recipeAdder.java @@ -115,7 +115,7 @@ public class TT_recipeAdder extends GT_RecipeAdder { computationRequiredPerSec = Short.MAX_VALUE; } TT_recipe.GT_Recipe_MapTT.sResearchableFakeRecipes.addFakeRecipe(false, new ItemStack[]{aResearchItem}, new ItemStack[]{aOutput}, new ItemStack[]{ItemList.Tool_DataStick.getWithName(1L, "Writes Research result")}, null, null, totalComputationRequired, researchEUt, researchAmperage| computationRequiredPerSec<<16); - GT_Recipe.GT_Recipe_Map.sAssemblylineVisualRecipes.addFakeRecipe(false,tInputs,new ItemStack[]{aOutput},new ItemStack[]{ItemList.Tool_DataStick.getWithName(1L, "Reads Research result", new Object[0])},aFluidInputs,null,assDuration,assEUt,0,tAlts,true); + GT_Recipe.GT_Recipe_Map.sAssemblylineVisualRecipes.addFakeRecipe(false,tInputs,new ItemStack[]{aOutput},new ItemStack[]{ItemList.Tool_DataStick.getWithName(1L, "Reads Research result")},aFluidInputs,null,assDuration,assEUt,0,tAlts,true); GT_Recipe.GT_Recipe_AssemblyLine.sAssemblylineRecipes.add(new GT_Recipe.GT_Recipe_AssemblyLine( CustomItemList.UnusedStuff.get(1), totalComputationRequired/computationRequiredPerSec, tInputs, aFluidInputs, aOutput, assDuration, assEUt, tAlts)); return true; } @@ -124,7 +124,7 @@ public class TT_recipeAdder extends GT_RecipeAdder { (boolean aOptimize, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecialItems, int[] aChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue, - cElementalDefinitionStackMap[] in, cElementalDefinitionStackMap[] out, cElementalDefinitionStackMap[] catalyst, AdditionalCheck check) + cElementalDefinitionStackMap[] in, cElementalDefinitionStackMap[] out, cElementalDefinitionStackMap[] catalyst, IAdditionalCheck check) */ public static boolean addResearchableEMmachineRecipe( @@ -163,7 +163,7 @@ public class TT_recipeAdder extends GT_RecipeAdder { public static boolean addResearchableEMcrafterRecipe( ItemStack aResearchItem, int totalComputationRequired, int computationRequiredPerSec, int researchEUt, int researchAmperage, - cElementalDefinitionStackMap[] eInputs, cElementalDefinitionStackMap[] catalyst, TT_recipe.AdditionalCheck check, + cElementalDefinitionStackMap[] eInputs, cElementalDefinitionStackMap[] catalyst, TT_recipe.IAdditionalCheck check, ItemStack aOutput, int crafterDuration, int crafterEUt, int crafterAmperage) { if (aResearchItem==null || totalComputationRequired<=0 || aOutput == null) { return false; @@ -222,7 +222,7 @@ public class TT_recipeAdder extends GT_RecipeAdder { public static boolean addScannableEMcrafterRecipe( iElementalDefinition aResearchEM, int totalComputationRequired, int computationRequiredPerSec, int researchEUt, int researchAmperage, - cElementalDefinitionStackMap[] eInputs, cElementalDefinitionStackMap[] catalyst, TT_recipe.AdditionalCheck check, + cElementalDefinitionStackMap[] eInputs, cElementalDefinitionStackMap[] catalyst, TT_recipe.IAdditionalCheck check, ItemStack aOutput, int crafterDuration, int crafterEUt, int crafterAmperage) { if (aResearchEM==null || totalComputationRequired<=0 || aOutput == null) { return false; diff --git a/src/main/java/com/github/technus/tectech/thing/CustomItemList.java b/src/main/java/com/github/technus/tectech/thing/CustomItemList.java index a3284f241d..cd3d1cccd8 100644 --- a/src/main/java/com/github/technus/tectech/thing/CustomItemList.java +++ b/src/main/java/com/github/technus/tectech/thing/CustomItemList.java @@ -23,13 +23,13 @@ public enum CustomItemList implements IItemContainer { Transformer_HA_UEV_UHV,Transformer_HA_UIV_UEV,Transformer_HA_UMV_UIV,Transformer_HA_UXV_UMV, Transformer_HA_OPV_UXV,Transformer_HA_MAXV_OPV, - hatch_CreativeMaitenance, + hatch_CreativeMaitenance,hatch_CreativeData, Machine_OwnerDetector,Machine_DataReader, Machine_BuckConverter_IV,Machine_BuckConverter_LuV,Machine_BuckConverter_ZPM, Machine_BuckConverter_UV,Machine_BuckConverter_UHV,Machine_BuckConverter_UEV, Machine_BuckConverter_UIV,Machine_BuckConverter_UMV, Machine_BuckConverter_UXV, - Machine_DebugWriter,Machine_DebugGenny,UnusedStuff, - EMpipe, DATApipe, rack_Hatch, holder_Hatch, capacitor_Hatch, + Machine_DebugWriter,Machine_DebugGenny,UnusedStuff, Machine_DebugPollutor, + EMpipe, DATApipe, LASERpipe, rack_Hatch, holder_Hatch, capacitor_Hatch, eM_dynamomulti4_IV, eM_dynamomulti16_IV, eM_dynamomulti64_IV, eM_dynamomulti4_LuV, eM_dynamomulti16_LuV, eM_dynamomulti64_LuV, @@ -40,6 +40,16 @@ public enum CustomItemList implements IItemContainer { eM_dynamomulti4_UIV, eM_dynamomulti16_UIV, eM_dynamomulti64_UIV, eM_dynamomulti4_UMV, eM_dynamomulti16_UMV, eM_dynamomulti64_UMV, eM_dynamomulti4_UXV, eM_dynamomulti16_UXV, eM_dynamomulti64_UXV, + eM_dynamotunnel1_IV,eM_dynamotunnel2_IV,eM_dynamotunnel3_IV,eM_dynamotunnel4_IV,eM_dynamotunnel5_IV,eM_dynamotunnel6_IV,eM_dynamotunnel7_IV, + eM_dynamotunnel1_LuV,eM_dynamotunnel2_LuV,eM_dynamotunnel3_LuV,eM_dynamotunnel4_LuV,eM_dynamotunnel5_LuV,eM_dynamotunnel6_LuV,eM_dynamotunnel7_LuV, + eM_dynamotunnel1_ZPM,eM_dynamotunnel2_ZPM,eM_dynamotunnel3_ZPM,eM_dynamotunnel4_ZPM,eM_dynamotunnel5_ZPM,eM_dynamotunnel6_ZPM,eM_dynamotunnel7_ZPM, + eM_dynamotunnel1_UV,eM_dynamotunnel2_UV,eM_dynamotunnel3_UV,eM_dynamotunnel4_UV,eM_dynamotunnel5_UV,eM_dynamotunnel6_UV,eM_dynamotunnel7_UV, + eM_dynamotunnel1_UHV,eM_dynamotunnel2_UHV,eM_dynamotunnel3_UHV,eM_dynamotunnel4_UHV,eM_dynamotunnel5_UHV,eM_dynamotunnel6_UHV,eM_dynamotunnel7_UHV, + eM_dynamotunnel1_UEV,eM_dynamotunnel2_UEV,eM_dynamotunnel3_UEV,eM_dynamotunnel4_UEV,eM_dynamotunnel5_UEV,eM_dynamotunnel6_UEV,eM_dynamotunnel7_UEV, + eM_dynamotunnel1_UIV,eM_dynamotunnel2_UIV,eM_dynamotunnel3_UIV,eM_dynamotunnel4_UIV,eM_dynamotunnel5_UIV,eM_dynamotunnel6_UIV,eM_dynamotunnel7_UIV, + eM_dynamotunnel1_UMV,eM_dynamotunnel2_UMV,eM_dynamotunnel3_UMV,eM_dynamotunnel4_UMV,eM_dynamotunnel5_UMV,eM_dynamotunnel6_UMV,eM_dynamotunnel7_UMV, + eM_dynamotunnel1_UXV,eM_dynamotunnel2_UXV,eM_dynamotunnel3_UXV,eM_dynamotunnel4_UXV,eM_dynamotunnel5_UXV,eM_dynamotunnel6_UXV,eM_dynamotunnel7_UXV, + eM_dynamotunnel9001, eM_energymulti4_IV, eM_energymulti16_IV, eM_energymulti64_IV, eM_energymulti4_LuV, eM_energymulti16_LuV, eM_energymulti64_LuV, @@ -50,6 +60,16 @@ public enum CustomItemList implements IItemContainer { eM_energymulti4_UIV, eM_energymulti16_UIV, eM_energymulti64_UIV, eM_energymulti4_UMV, eM_energymulti16_UMV, eM_energymulti64_UMV, eM_energymulti4_UXV, eM_energymulti16_UXV, eM_energymulti64_UXV, + eM_energytunnel1_IV,eM_energytunnel2_IV,eM_energytunnel3_IV,eM_energytunnel4_IV,eM_energytunnel5_IV,eM_energytunnel6_IV,eM_energytunnel7_IV, + eM_energytunnel1_LuV,eM_energytunnel2_LuV,eM_energytunnel3_LuV,eM_energytunnel4_LuV,eM_energytunnel5_LuV,eM_energytunnel6_LuV,eM_energytunnel7_LuV, + eM_energytunnel1_ZPM,eM_energytunnel2_ZPM,eM_energytunnel3_ZPM,eM_energytunnel4_ZPM,eM_energytunnel5_ZPM,eM_energytunnel6_ZPM,eM_energytunnel7_ZPM, + eM_energytunnel1_UV,eM_energytunnel2_UV,eM_energytunnel3_UV,eM_energytunnel4_UV,eM_energytunnel5_UV,eM_energytunnel6_UV,eM_energytunnel7_UV, + eM_energytunnel1_UHV,eM_energytunnel2_UHV,eM_energytunnel3_UHV,eM_energytunnel4_UHV,eM_energytunnel5_UHV,eM_energytunnel6_UHV,eM_energytunnel7_UHV, + eM_energytunnel1_UEV,eM_energytunnel2_UEV,eM_energytunnel3_UEV,eM_energytunnel4_UEV,eM_energytunnel5_UEV,eM_energytunnel6_UEV,eM_energytunnel7_UEV, + eM_energytunnel1_UIV,eM_energytunnel2_UIV,eM_energytunnel3_UIV,eM_energytunnel4_UIV,eM_energytunnel5_UIV,eM_energytunnel6_UIV,eM_energytunnel7_UIV, + eM_energytunnel1_UMV,eM_energytunnel2_UMV,eM_energytunnel3_UMV,eM_energytunnel4_UMV,eM_energytunnel5_UMV,eM_energytunnel6_UMV,eM_energytunnel7_UMV, + eM_energytunnel1_UXV,eM_energytunnel2_UXV,eM_energytunnel3_UXV,eM_energytunnel4_UXV,eM_energytunnel5_UXV,eM_energytunnel6_UXV,eM_energytunnel7_UXV, + eM_energytunnel9001, eM_in_UV, eM_in_UHV, eM_in_UEV, eM_in_UIV, eM_in_UMV, eM_in_UXV, eM_out_UV, eM_out_UHV, eM_out_UEV, eM_out_UIV, eM_out_UMV, eM_out_UXV, diff --git a/src/main/java/com/github/technus/tectech/thing/block/QuantumGlassBlock.java b/src/main/java/com/github/technus/tectech/thing/block/QuantumGlassBlock.java index ef903cbf38..1a08bdbeec 100644 --- a/src/main/java/com/github/technus/tectech/thing/block/QuantumGlassBlock.java +++ b/src/main/java/com/github/technus/tectech/thing/block/QuantumGlassBlock.java @@ -100,6 +100,7 @@ public final class QuantumGlassBlock extends BlockBase { if (GregTech_API.isMachineBlock(this, aWorld.getBlockMetadata(aX, aY, aZ))) { GregTech_API.causeMachineUpdate(aWorld, aX, aY, aZ); } + } @Override diff --git a/src/main/java/com/github/technus/tectech/thing/item/ConstructableTriggerItem.java b/src/main/java/com/github/technus/tectech/thing/item/ConstructableTriggerItem.java index efb9e6d644..33f0d34ad5 100644 --- a/src/main/java/com/github/technus/tectech/thing/item/ConstructableTriggerItem.java +++ b/src/main/java/com/github/technus/tectech/thing/item/ConstructableTriggerItem.java @@ -10,7 +10,6 @@ import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_ElectricBlastFurnace; import net.minecraft.block.Block; -import net.minecraft.client.entity.EntityClientPlayerMP; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.Item; @@ -33,7 +32,7 @@ import static gregtech.api.GregTech_API.sBlockCasings1; public final class ConstructableTriggerItem extends Item { public static ConstructableTriggerItem INSTANCE; - private static HashMap<String,MultiblockInfoContainer> multiblockMap= new HashMap<>(); + private static HashMap<String, IMultiblockInfoContainer> multiblockMap= new HashMap<>(); private ConstructableTriggerItem() { setUnlocalizedName("em.constructable"); @@ -63,7 +62,7 @@ public final class ConstructableTriggerItem extends Item { } } return true; - }else if (aPlayer instanceof EntityClientPlayerMP){//particles and text client side + }else if (TecTech.proxy.isThePlayer(aPlayer)){//particles and text client side //if ((!aPlayer.isSneaking() || !aPlayer.capabilities.isCreativeMode)) { if(tTileEntity instanceof IGregTechTileEntity) { IMetaTileEntity metaTE = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity(); @@ -121,7 +120,7 @@ public final class ConstructableTriggerItem extends Item { INSTANCE = new ConstructableTriggerItem(); GameRegistry.registerItem(INSTANCE, INSTANCE.getUnlocalizedName()); - registerMetaClass(GT_MetaTileEntity_ElectricBlastFurnace.class, new MultiblockInfoContainer() { + registerMetaClass(GT_MetaTileEntity_ElectricBlastFurnace.class, new IMultiblockInfoContainer() { //region Structure private final String[][] shape = new String[][]{ {"000","\"\"\"","\"\"\""," . ",}, @@ -150,17 +149,17 @@ public final class ConstructableTriggerItem extends Item { }); } - public interface MultiblockInfoContainer { + public interface IMultiblockInfoContainer { void construct(int stackSize, boolean hintsOnly, TileEntity tileEntity, int aSide); @SideOnly(Side.CLIENT) String[] getDescription(int stackSize); } - public static void registerTileClass(Class<? extends TileEntity> clazz,MultiblockInfoContainer info){ + public static void registerTileClass(Class<? extends TileEntity> clazz, IMultiblockInfoContainer info){ multiblockMap.put(clazz.getCanonicalName(),info); } - public static void registerMetaClass(Class<? extends IMetaTileEntity> clazz,MultiblockInfoContainer info){ + public static void registerMetaClass(Class<? extends IMetaTileEntity> clazz, IMultiblockInfoContainer info){ multiblockMap.put(clazz.getCanonicalName(),info); } } diff --git a/src/main/java/com/github/technus/tectech/thing/item/FrontRotationTriggerItem.java b/src/main/java/com/github/technus/tectech/thing/item/FrontRotationTriggerItem.java index 8e2a1c1a9b..15567bc477 100644 --- a/src/main/java/com/github/technus/tectech/thing/item/FrontRotationTriggerItem.java +++ b/src/main/java/com/github/technus/tectech/thing/item/FrontRotationTriggerItem.java @@ -40,7 +40,6 @@ public final class FrontRotationTriggerItem extends Item { IMetaTileEntity metaTE = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity(); if (metaTE instanceof IFrontRotation) { ((IFrontRotation) metaTE).rotateAroundFrontPlane(!aPlayer.isSneaking()); - System.out.println("DID SHIT"); return true; } } else if (tTileEntity instanceof IFrontRotation) { diff --git a/src/main/java/com/github/technus/tectech/thing/item/ParametrizerMemoryCard.java b/src/main/java/com/github/technus/tectech/thing/item/ParametrizerMemoryCard.java index 035b049a99..dafc425163 100644 --- a/src/main/java/com/github/technus/tectech/thing/item/ParametrizerMemoryCard.java +++ b/src/main/java/com/github/technus/tectech/thing/item/ParametrizerMemoryCard.java @@ -57,19 +57,13 @@ public final class ParametrizerMemoryCard extends Item { if (aStack.getItemDamage() == 1) { //write to parametrizer parametrizer.param = tNBT.getInteger("param"); - if (parametrizer.setUsingFloats(tNBT.getBoolean("usesFloats"))) { - parametrizer.value0i = (int) Float.intBitsToFloat(tNBT.getInteger("value0i")); - parametrizer.value1i = (int) Float.intBitsToFloat(tNBT.getInteger("value1i")); - } else { - parametrizer.value0i = tNBT.getInteger("value0i"); - parametrizer.value1i = tNBT.getInteger("value1i"); - } + parametrizer.value0D = tNBT.getDouble("value0D"); + parametrizer.value1D = tNBT.getDouble("value1D"); } else { //read from parametrizer tNBT.setInteger("param", parametrizer.param); - tNBT.setBoolean("usesFloats", parametrizer.isUsingFloats()); - tNBT.setInteger("value0i", parametrizer.value0i); - tNBT.setInteger("value1i", parametrizer.value1i); + tNBT.setDouble("value0D", parametrizer.value0D); + tNBT.setDouble("value1D", parametrizer.value1D); } return true; }else if(metaTE instanceof GT_MetaTileEntity_MultiblockBase_EM){ @@ -79,16 +73,10 @@ public final class ParametrizerMemoryCard extends Item { } NBTTagCompound tNBT = aStack.getTagCompound(); if(aStack.getItemDamage()== 1){ - //write to base - if(tNBT.getBoolean("usesFloats")){ - base.setParameterPairIn_ClearOut(tNBT.getInteger("param"),true - ,Float.intBitsToFloat(tNBT.getInteger("value0i")) - ,Float.intBitsToFloat(tNBT.getInteger("value1i"))); - }else{ - base.setParameterPairIn_ClearOut(tNBT.getInteger("param"),false - ,tNBT.getInteger("value0i") - ,tNBT.getInteger("value1i")); - } + base.parametrization.trySetParameters( + tNBT.getInteger("param"), + tNBT.getDouble("value0D"), + tNBT.getDouble("value1D")); return true; } } @@ -125,17 +113,15 @@ public final class ParametrizerMemoryCard extends Item { } aList.add(EnumChatFormatting.BLUE + "Sneak right click to lock/unlock"); - int temp; + long temp; if(tNBT!=null && tNBT.hasKey("param")) { aList.add("Hatch ID: "+EnumChatFormatting.AQUA + tNBT.getInteger("param")); - temp=tNBT.getInteger("value0i"); - aList.add("Value 0|I: "+EnumChatFormatting.AQUA + temp); - aList.add("Value 0|F: "+EnumChatFormatting.AQUA + Float.intBitsToFloat(temp)); - aList.add("Value 0|B: "+EnumChatFormatting.AQUA + Util.intBitsToShortString(temp)); - temp=tNBT.getInteger("value1i"); - aList.add("Value 1|I: "+EnumChatFormatting.AQUA + temp); - aList.add("Value 1|F: "+EnumChatFormatting.AQUA + Float.intBitsToFloat(temp)); - aList.add("Value 1|B: "+EnumChatFormatting.AQUA + Util.intBitsToShortString(temp)); + temp=tNBT.getInteger("value0D"); + aList.add("Value 0D: "+EnumChatFormatting.AQUA + temp); + aList.add("Value 0B: "+EnumChatFormatting.AQUA + Util.longBitsToShortString(Double.doubleToLongBits(temp))); + temp=tNBT.getInteger("value1D"); + aList.add("Value 1D: "+EnumChatFormatting.AQUA + temp); + aList.add("Value 1B: "+EnumChatFormatting.AQUA + Util.longBitsToShortString(Double.doubleToLongBits(temp))); aList.add("Uses Floats: "+(tNBT.getBoolean("usesFloats")?EnumChatFormatting.GREEN+"TRUE":EnumChatFormatting.RED+"FALSE")); } diff --git a/src/main/java/com/github/technus/tectech/thing/item/gui/ScanDisplayScreen.java b/src/main/java/com/github/technus/tectech/thing/item/gui/ScanDisplayScreen.java index 753581439b..7f4c9b64fe 100644 --- a/src/main/java/com/github/technus/tectech/thing/item/gui/ScanDisplayScreen.java +++ b/src/main/java/com/github/technus/tectech/thing/item/gui/ScanDisplayScreen.java @@ -21,7 +21,7 @@ public class ScanDisplayScreen extends GuiScreen { private int baseX,baseY; private Button up,down,pgUp,pgDown; private final String[] lines; - private int firstLine =0; + private int firstLine; private static final ResourceLocation[] BACKGROUNDS =new ResourceLocation[]{new ResourceLocation(MODID+":textures/gui/scanDisplayScreen1.png"), new ResourceLocation(MODID+":textures/gui/scanDisplayScreen2.png"), @@ -31,7 +31,7 @@ public class ScanDisplayScreen extends GuiScreen { new ResourceLocation(MODID+":textures/gui/scanDisplayScreen6.png"), new ResourceLocation(MODID+":textures/gui/scanDisplayScreen7.png"), new ResourceLocation(MODID+":textures/gui/scanDisplayScreen8.png")}; - private static final ResourceLocation ITEM =new ResourceLocation(MODID+"::textures/gui/scanDisplayItem.png"); + private static final ResourceLocation ITEM =new ResourceLocation(MODID+":textures/gui/scanDisplayItem.png"); public ScanDisplayScreen(EntityPlayer player){ lines=ElementalDefinitionScanStorage_EM.getLines(player.getHeldItem()); @@ -82,6 +82,8 @@ public class ScanDisplayScreen extends GuiScreen { TecTech.proxy.renderUnicodeString(lines[i], textBaseX, textBaseY + 17 - j, 200, itick); } } + TecTech.proxy.renderUnicodeString(Integer.toString(firstLine), textBaseX, baseY+146, 200, itick); + TecTech.proxy.renderUnicodeString(Integer.toString(lines.length), textBaseX, baseY+157, 200, itick); } @Override diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/network/RotationMessage.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/RotationMessage.java index 59b14c16ed..92b38e68ea 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/network/RotationMessage.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/RotationMessage.java @@ -1,6 +1,5 @@ -package com.github.technus.tectech.thing.metaTileEntity.multi.base.network; +package com.github.technus.tectech.thing.metaTileEntity; -import com.github.technus.tectech.thing.metaTileEntity.IFrontRotation; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; import cpw.mods.fml.common.network.ByteBufUtils; import cpw.mods.fml.common.network.simpleimpl.IMessage; diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/Textures.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/Textures.java index 99ff2bea97..d77749d130 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/Textures.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/Textures.java @@ -10,26 +10,28 @@ import static gregtech.api.enums.Dyes.MACHINE_METAL; import static gregtech.api.enums.Textures.BlockIcons.*; public class Textures { - private static IIconContainer OVERLAY_ENERGY_IN_POWER = new CustomIcon("iconsets/OVERLAY_ENERGY_IN_POWER"); - private static IIconContainer OVERLAY_ENERGY_OUT_POWER = new CustomIcon("iconsets/OVERLAY_ENERGY_OUT_POWER"); - private static IIconContainer MACHINE_UEV_SIDE = new CustomIcon("iconsets/MACHINE_UEV_SIDE"); - private static IIconContainer MACHINE_UIV_SIDE = new CustomIcon("iconsets/MACHINE_UIV_SIDE"); - private static IIconContainer MACHINE_UMV_SIDE = new CustomIcon("iconsets/MACHINE_UMV_SIDE"); - private static IIconContainer MACHINE_UXV_SIDE = new CustomIcon("iconsets/MACHINE_UXV_SIDE"); - private static IIconContainer MACHINE_OPV_SIDE = new CustomIcon("iconsets/MACHINE_OPV_SIDE"); - private static IIconContainer MACHINE_MAXV_SIDE = new CustomIcon("iconsets/MACHINE_MAXV_SIDE"); - private static IIconContainer MACHINE_UEV_TOP = new CustomIcon("iconsets/MACHINE_UEV_TOP"); - private static IIconContainer MACHINE_UIV_TOP = new CustomIcon("iconsets/MACHINE_UIV_TOP"); - private static IIconContainer MACHINE_UMV_TOP = new CustomIcon("iconsets/MACHINE_UMV_TOP"); - private static IIconContainer MACHINE_UXV_TOP = new CustomIcon("iconsets/MACHINE_UXV_TOP"); - private static IIconContainer MACHINE_OPV_TOP = new CustomIcon("iconsets/MACHINE_OPV_TOP"); - private static IIconContainer MACHINE_MAXV_TOP = new CustomIcon("iconsets/MACHINE_MAXV_TOP"); - private static IIconContainer MACHINE_UEV_BOTTOM = new CustomIcon("iconsets/MACHINE_UEV_BOTTOM"); - private static IIconContainer MACHINE_UIV_BOTTOM = new CustomIcon("iconsets/MACHINE_UIV_BOTTOM"); - private static IIconContainer MACHINE_UMV_BOTTOM = new CustomIcon("iconsets/MACHINE_UMV_BOTTOM"); - private static IIconContainer MACHINE_UXV_BOTTOM = new CustomIcon("iconsets/MACHINE_UXV_BOTTOM"); - private static IIconContainer MACHINE_OPV_BOTTOM = new CustomIcon("iconsets/MACHINE_OPV_BOTTOM"); - private static IIconContainer MACHINE_MAXV_BOTTOM = new CustomIcon("iconsets/MACHINE_MAXV_BOTTOM"); + private static final IIconContainer OVERLAY_ENERGY_IN_POWER = new CustomIcon("iconsets/OVERLAY_ENERGY_IN_POWER"); + private static final IIconContainer OVERLAY_ENERGY_OUT_POWER = new CustomIcon("iconsets/OVERLAY_ENERGY_OUT_POWER"); + private static final IIconContainer OVERLAY_ENERGY_IN_LASER = new CustomIcon("iconsets/OVERLAY_ENERGY_IN_LASER"); + private static final IIconContainer OVERLAY_ENERGY_OUT_LASER = new CustomIcon("iconsets/OVERLAY_ENERGY_OUT_LASER"); + private static final IIconContainer MACHINE_UEV_SIDE = new CustomIcon("iconsets/MACHINE_UEV_SIDE"); + private static final IIconContainer MACHINE_UIV_SIDE = new CustomIcon("iconsets/MACHINE_UIV_SIDE"); + private static final IIconContainer MACHINE_UMV_SIDE = new CustomIcon("iconsets/MACHINE_UMV_SIDE"); + private static final IIconContainer MACHINE_UXV_SIDE = new CustomIcon("iconsets/MACHINE_UXV_SIDE"); + private static final IIconContainer MACHINE_OPV_SIDE = new CustomIcon("iconsets/MACHINE_OPV_SIDE"); + private static final IIconContainer MACHINE_MAXV_SIDE = new CustomIcon("iconsets/MACHINE_MAXV_SIDE"); + private static final IIconContainer MACHINE_UEV_TOP = new CustomIcon("iconsets/MACHINE_UEV_TOP"); + private static final IIconContainer MACHINE_UIV_TOP = new CustomIcon("iconsets/MACHINE_UIV_TOP"); + private static final IIconContainer MACHINE_UMV_TOP = new CustomIcon("iconsets/MACHINE_UMV_TOP"); + private static final IIconContainer MACHINE_UXV_TOP = new CustomIcon("iconsets/MACHINE_UXV_TOP"); + private static final IIconContainer MACHINE_OPV_TOP = new CustomIcon("iconsets/MACHINE_OPV_TOP"); + private static final IIconContainer MACHINE_MAXV_TOP = new CustomIcon("iconsets/MACHINE_MAXV_TOP"); + private static final IIconContainer MACHINE_UEV_BOTTOM = new CustomIcon("iconsets/MACHINE_UEV_BOTTOM"); + private static final IIconContainer MACHINE_UIV_BOTTOM = new CustomIcon("iconsets/MACHINE_UIV_BOTTOM"); + private static final IIconContainer MACHINE_UMV_BOTTOM = new CustomIcon("iconsets/MACHINE_UMV_BOTTOM"); + private static final IIconContainer MACHINE_UXV_BOTTOM = new CustomIcon("iconsets/MACHINE_UXV_BOTTOM"); + private static final IIconContainer MACHINE_OPV_BOTTOM = new CustomIcon("iconsets/MACHINE_OPV_BOTTOM"); + private static final IIconContainer MACHINE_MAXV_BOTTOM = new CustomIcon("iconsets/MACHINE_MAXV_BOTTOM"); public static IIconContainer[] MACHINECASINGS_SIDE_TT = new IIconContainer[]{ MACHINE_8V_SIDE, MACHINE_LV_SIDE, MACHINE_MV_SIDE, MACHINE_HV_SIDE, @@ -149,6 +151,40 @@ public class Textures { new GT_RenderedTexture(OVERLAY_ENERGY_OUT_POWER, new short[]{80, 80, 245, 0}), new GT_RenderedTexture(OVERLAY_ENERGY_OUT_POWER, new short[]{60, 60, 245, 0}), new GT_RenderedTexture(OVERLAY_ENERGY_OUT_POWER, new short[]{40, 40, 245, 0}), + }, OVERLAYS_ENERGY_IN_LASER_TT = new ITexture[]{ + new GT_RenderedTexture(OVERLAY_ENERGY_IN_LASER, new short[]{180, 180, 180, 0}), + new GT_RenderedTexture(OVERLAY_ENERGY_IN_LASER, new short[]{220, 220, 220, 0}), + new GT_RenderedTexture(OVERLAY_ENERGY_IN_LASER, new short[]{255, 100, 0, 0}), + new GT_RenderedTexture(OVERLAY_ENERGY_IN_LASER, new short[]{255, 255, 30, 0}), + new GT_RenderedTexture(OVERLAY_ENERGY_IN_LASER, new short[]{128, 128, 128, 0}), + new GT_RenderedTexture(OVERLAY_ENERGY_IN_LASER, new short[]{240, 240, 245, 0}), + new GT_RenderedTexture(OVERLAY_ENERGY_IN_LASER, new short[]{220, 220, 245, 0}), + new GT_RenderedTexture(OVERLAY_ENERGY_IN_LASER, new short[]{200, 200, 245, 0}), + new GT_RenderedTexture(OVERLAY_ENERGY_IN_LASER, new short[]{180, 180, 245, 0}), + new GT_RenderedTexture(OVERLAY_ENERGY_IN_LASER, new short[]{160, 160, 245, 0}), + new GT_RenderedTexture(OVERLAY_ENERGY_IN_LASER, new short[]{140, 140, 245, 0}), + new GT_RenderedTexture(OVERLAY_ENERGY_IN_LASER, new short[]{120, 120, 245, 0}), + new GT_RenderedTexture(OVERLAY_ENERGY_IN_LASER, new short[]{100, 100, 245, 0}), + new GT_RenderedTexture(OVERLAY_ENERGY_IN_LASER, new short[]{80, 80, 245, 0}), + new GT_RenderedTexture(OVERLAY_ENERGY_IN_LASER, new short[]{60, 60, 245, 0}), + new GT_RenderedTexture(OVERLAY_ENERGY_IN_LASER, new short[]{40, 40, 245, 0}), + }, OVERLAYS_ENERGY_OUT_LASER_TT = new ITexture[]{ + new GT_RenderedTexture(OVERLAY_ENERGY_OUT_LASER, new short[]{180, 180, 180, 0}), + new GT_RenderedTexture(OVERLAY_ENERGY_OUT_LASER, new short[]{220, 220, 220, 0}), + new GT_RenderedTexture(OVERLAY_ENERGY_OUT_LASER, new short[]{255, 100, 0, 0}), + new GT_RenderedTexture(OVERLAY_ENERGY_OUT_LASER, new short[]{255, 255, 30, 0}), + new GT_RenderedTexture(OVERLAY_ENERGY_OUT_LASER, new short[]{128, 128, 128, 0}), + new GT_RenderedTexture(OVERLAY_ENERGY_OUT_LASER, new short[]{240, 240, 245, 0}), + new GT_RenderedTexture(OVERLAY_ENERGY_OUT_LASER, new short[]{220, 220, 245, 0}), + new GT_RenderedTexture(OVERLAY_ENERGY_OUT_LASER, new short[]{200, 200, 245, 0}), + new GT_RenderedTexture(OVERLAY_ENERGY_OUT_LASER, new short[]{180, 180, 245, 0}), + new GT_RenderedTexture(OVERLAY_ENERGY_OUT_LASER, new short[]{160, 160, 245, 0}), + new GT_RenderedTexture(OVERLAY_ENERGY_OUT_LASER, new short[]{140, 140, 245, 0}), + new GT_RenderedTexture(OVERLAY_ENERGY_OUT_LASER, new short[]{120, 120, 245, 0}), + new GT_RenderedTexture(OVERLAY_ENERGY_OUT_LASER, new short[]{100, 100, 245, 0}), + new GT_RenderedTexture(OVERLAY_ENERGY_OUT_LASER, new short[]{80, 80, 245, 0}), + new GT_RenderedTexture(OVERLAY_ENERGY_OUT_LASER, new short[]{60, 60, 245, 0}), + new GT_RenderedTexture(OVERLAY_ENERGY_OUT_LASER, new short[]{40, 40, 245, 0}), }; public static ITexture[][] MACHINE_CASINGS_TT = new ITexture[16][17]; diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_CreativeData.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_CreativeData.java new file mode 100644 index 0000000000..d12b0d42d8 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_CreativeData.java @@ -0,0 +1,117 @@ +package com.github.technus.tectech.thing.metaTileEntity.hatch; + +import com.github.technus.tectech.Util; +import com.github.technus.tectech.mechanics.dataTransport.QuantumDataPacket; +import com.github.technus.tectech.thing.metaTileEntity.pipe.GT_MetaTileEntity_Pipe_Data; +import com.github.technus.tectech.thing.metaTileEntity.pipe.IConnectsToDataPipe; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.util.GT_Utility; +import net.minecraft.nbt.NBTTagCompound; + +import static com.github.technus.tectech.CommonValues.MOVE_AT; + +/** + * Created by danie_000 on 27.10.2016. + */ +public class GT_MetaTileEntity_Hatch_CreativeData extends GT_MetaTileEntity_Hatch_DataConnector<QuantumDataPacket> { + public GT_MetaTileEntity_Hatch_CreativeData(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, "Quantum Data Output"); + Util.setTier(aTier,this); + } + + public GT_MetaTileEntity_Hatch_CreativeData(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_Hatch_CreativeData(mName, mTier, mDescription, mTextures); + } + + @Override + public boolean isOutputFacing(byte aSide) { + return aSide == getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public boolean isInputFacing(byte aSide) { + return false; + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean isDataInputFacing(byte side) { + return isInputFacing(side); + } + + @Override + protected QuantumDataPacket loadPacketFromNBT(NBTTagCompound nbt) { + return new QuantumDataPacket(nbt); + } + + @Override + public boolean canConnectData(byte side) { + return isOutputFacing(side); + } + + @Override + public void moveAround(IGregTechTileEntity aBaseMetaTileEntity) { + IConnectsToDataPipe current = this, source = this, next; + int range = 0; + while ((next = current.getNext(source)) != null && range++ < 1000) { + if (next instanceof GT_MetaTileEntity_Hatch_InputData) { + ((GT_MetaTileEntity_Hatch_InputData) next).setContents(q); + break; + } + source = current; + current = next; + } + q = null; + } + + @Override + public IConnectsToDataPipe getNext(IConnectsToDataPipe source/*==this*/) { + IGregTechTileEntity base = getBaseMetaTileEntity(); + byte color = base.getColorization(); + if (color < 0) { + return null; + } + IGregTechTileEntity next = base.getIGregTechTileEntityAtSide(base.getFrontFacing()); + if (next == null) { + return null; + } + IMetaTileEntity meta = next.getMetaTileEntity(); + if (meta instanceof GT_MetaTileEntity_Pipe_Data) { + ((GT_MetaTileEntity_Pipe_Data) meta).markUsed(); + return (IConnectsToDataPipe) meta; + }else if (meta instanceof GT_MetaTileEntity_Hatch_InputData && + ((GT_MetaTileEntity_Hatch_InputData) meta).getColorization()==color && + ((GT_MetaTileEntity_Hatch_InputData) meta).canConnectData(GT_Utility.getOppositeSide(base.getFrontFacing()))) { + return (IConnectsToDataPipe) meta; + } + return null; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide()) { + if (MOVE_AT == aTick % 20) { + if (aBaseMetaTileEntity.isAllowedToWork()) { + getBaseMetaTileEntity().setActive(true); + if(q==null) q=new QuantumDataPacket(0xFFFFFFFFL); + moveAround(aBaseMetaTileEntity); + } else { + q=null; + getBaseMetaTileEntity().setActive(false); + } + } + } + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_DynamoMulti.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_DynamoMulti.java index 2ad4593984..1ba4854b62 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_DynamoMulti.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_DynamoMulti.java @@ -29,6 +29,11 @@ public class GT_MetaTileEntity_Hatch_DynamoMulti extends GT_MetaTileEntity_Hatch Amperes = aAmp; } + public GT_MetaTileEntity_Hatch_DynamoMulti(int aID, String aName, String aNameRegional, int aTier, int i, String description, int aAmp) { + super(aID, aName, aNameRegional, aTier, 0, description); + Amperes = aAmp; + } + @Override public ITexture[] getTexturesActive(ITexture aBaseTexture) { return new ITexture[]{aBaseTexture, OVERLAYS_ENERGY_IN_POWER_TT[mTier]}; diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_DynamoTunnel.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_DynamoTunnel.java index eeacf91014..2e1a62f46d 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_DynamoTunnel.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_DynamoTunnel.java @@ -8,57 +8,36 @@ import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; import gregtech.api.util.GT_Utility; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; import static com.github.technus.tectech.CommonValues.TRANSFER_AT; import static com.github.technus.tectech.CommonValues.V; -import static com.github.technus.tectech.thing.metaTileEntity.Textures.OVERLAYS_ENERGY_IN_POWER_TT; +import static com.github.technus.tectech.thing.metaTileEntity.Textures.OVERLAYS_ENERGY_OUT_LASER_TT; /** * Created by danie_000 on 16.12.2016. */ -public class GT_MetaTileEntity_Hatch_DynamoTunnel extends GT_MetaTileEntity_Hatch implements IConnectsToEnergyTunnel { - public final int Amperes; - private final long upkeep; - private long packetsCount=0; - +public class GT_MetaTileEntity_Hatch_DynamoTunnel extends GT_MetaTileEntity_Hatch_DynamoMulti implements IConnectsToEnergyTunnel { public GT_MetaTileEntity_Hatch_DynamoTunnel(int aID, String aName, String aNameRegional, int aTier, int aAmp) { - super(aID, aName, aNameRegional, aTier, 0, "Energy extracting terminal for Multiblocks"); - Amperes = aAmp; + super(aID, aName, aNameRegional, aTier, 0, "Energy extracting terminal for Multiblocks",aAmp); Util.setTier(aTier,this); - upkeep=Math.max(V[mTier]/Amperes,V[4]); } - public GT_MetaTileEntity_Hatch_DynamoTunnel(String aName, int aTier, int aAmp, long aUpkeep, String aDescription, ITexture[][][] aTextures) { - super(aName, aTier, 0, aDescription, aTextures); - Amperes = aAmp; - upkeep=aUpkeep; + public GT_MetaTileEntity_Hatch_DynamoTunnel(String aName, int aTier, int aAmp, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aAmp, aDescription, aTextures); } @Override public ITexture[] getTexturesActive(ITexture aBaseTexture) { - return new ITexture[]{aBaseTexture, OVERLAYS_ENERGY_IN_POWER_TT[mTier]}; + return new ITexture[]{aBaseTexture, OVERLAYS_ENERGY_OUT_LASER_TT[mTier]}; } @Override public ITexture[] getTexturesInactive(ITexture aBaseTexture) { - return new ITexture[]{aBaseTexture, OVERLAYS_ENERGY_IN_POWER_TT[mTier]}; - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - packetsCount=aNBT.getLong("ePackets"); - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - aNBT.setLong("ePackets",packetsCount); + return new ITexture[]{aBaseTexture, OVERLAYS_ENERGY_OUT_LASER_TT[mTier]}; } @Override @@ -108,7 +87,7 @@ public class GT_MetaTileEntity_Hatch_DynamoTunnel extends GT_MetaTileEntity_Hatc @Override public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_Hatch_DynamoTunnel(mName, mTier, Amperes, upkeep, mDescription, mTextures); + return new GT_MetaTileEntity_Hatch_DynamoTunnel(mName, mTier, Amperes, mDescription, mTextures); } @Override @@ -125,7 +104,8 @@ public class GT_MetaTileEntity_Hatch_DynamoTunnel extends GT_MetaTileEntity_Hatc public String[] getDescription() { return new String[]{ CommonValues.TEC_MARK_GENERAL, - mDescription + mDescription, + "Throughput: "+ EnumChatFormatting.YELLOW +(Amperes*maxEUOutput())+EnumChatFormatting.RESET+" EU/t" }; } @@ -134,27 +114,15 @@ public class GT_MetaTileEntity_Hatch_DynamoTunnel extends GT_MetaTileEntity_Hatc if (aBaseMetaTileEntity.isServerSide()) { byte Tick = (byte) (aTick % 20); if (TRANSFER_AT == Tick) { - if(aBaseMetaTileEntity.getStoredEU()>=maxEUOutput()) { - long diff = aBaseMetaTileEntity.getStoredEU() / maxEUOutput(); - setEUVar(aBaseMetaTileEntity.getStoredEU() - diff * maxEUOutput()); - addPackets(diff); - } - if(packetsCount>0){ - moveAround(aBaseMetaTileEntity); - } - if(packetsCount>0){ - long diff=(maxEUStore()-aBaseMetaTileEntity.getStoredEU())/maxEUOutput(); - if(diff>0) { - setEUVar(aBaseMetaTileEntity.getStoredEU() + takePackets(diff) * maxEUOutput()); - } - } if(aBaseMetaTileEntity.getStoredEU()>0){ - setEUVar(aBaseMetaTileEntity.getStoredEU()-upkeep); + setEUVar(aBaseMetaTileEntity.getStoredEU()-Amperes); if(aBaseMetaTileEntity.getStoredEU()<0){ setEUVar(0); } } - getBaseMetaTileEntity().setActive(packetsCount>0); + if(aBaseMetaTileEntity.getStoredEU()>getMinimumStoredEU()){ + moveAround(aBaseMetaTileEntity); + } } } } @@ -175,21 +143,29 @@ public class GT_MetaTileEntity_Hatch_DynamoTunnel extends GT_MetaTileEntity_Hatc opposite == tGTTileEntity.getFrontFacing()) { if(maxEUOutput()>((GT_MetaTileEntity_Hatch_EnergyTunnel) aMetaTileEntity).maxEUInput()){ aMetaTileEntity.doExplosion(maxEUOutput()); - }else if(maxEUOutput()==((GT_MetaTileEntity_Hatch_EnergyTunnel) aMetaTileEntity).maxEUInput()){ - long ampRx=((GT_MetaTileEntity_Hatch_EnergyTunnel) aMetaTileEntity).Amperes; - if(packetsCount > ampRx && Amperes>ampRx){ - tGTTileEntity.setToFire(); - }else if(Amperes>ampRx){ - tGTTileEntity.setOnFire(); - ((GT_MetaTileEntity_Hatch_EnergyTunnel) aMetaTileEntity).addPackets(takePackets(Amperes)); - }else { - ((GT_MetaTileEntity_Hatch_EnergyTunnel) aMetaTileEntity).addPackets(takePackets(Amperes)); - } + setEUVar(aBaseMetaTileEntity.getStoredEU()-maxEUOutput()); + return; + }else if(maxEUOutput()==((GT_MetaTileEntity_Hatch_EnergyTunnel) aMetaTileEntity).maxEUInput()) { + long diff=Math.min( + Amperes*20, + Math.min( + ((GT_MetaTileEntity_Hatch_EnergyTunnel) aMetaTileEntity).maxEUStore()- + aMetaTileEntity.getBaseMetaTileEntity().getStoredEU(), + maxEUStore()-aBaseMetaTileEntity.getStoredEU() + )/maxEUOutput() + )*maxEUOutput(); + + setEUVar(aBaseMetaTileEntity.getStoredEU()-diff); + + ((GT_MetaTileEntity_Hatch_EnergyTunnel) aMetaTileEntity) + .setEUVar(aMetaTileEntity.getBaseMetaTileEntity().getStoredEU()+diff); } return; } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Pipe_Energy) { - if (((GT_MetaTileEntity_Pipe_Energy) aMetaTileEntity).connectionCount > 2) { + if (((GT_MetaTileEntity_Pipe_Energy) aMetaTileEntity).connectionCount < 2) { return; + }else { + ((GT_MetaTileEntity_Pipe_Energy) aMetaTileEntity).markUsed(); } } else { return; @@ -207,19 +183,4 @@ public class GT_MetaTileEntity_Hatch_DynamoTunnel extends GT_MetaTileEntity_Hatc public boolean canConnect(byte side) { return isOutputFacing(side); } - - public void addPackets(long count){ - packetsCount+=count; - } - - public long takePackets(long count){ - if(packetsCount>count){ - packetsCount-=count; - return count; - }else { - count=packetsCount; - packetsCount=0; - return count; - } - } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_ElementalContainer.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_ElementalContainer.java index c84057c121..066bcaa166 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_ElementalContainer.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_ElementalContainer.java @@ -124,7 +124,8 @@ public abstract class GT_MetaTileEntity_Hatch_ElementalContainer extends GT_Meta if (TecTech.configTecTech.BOOM_ENABLE) { tGTTileEntity.doExplosion(V[14]); } else { - TecTech.proxy.broadcast("Container1 BOOM! " + getBaseMetaTileEntity().getXCoord() + ' ' + getBaseMetaTileEntity().getYCoord() + ' ' + getBaseMetaTileEntity().getZCoord()); + TecTech.anomalyHandler.addAnomaly(aBaseMetaTileEntity,overflowMatter*32D); + TecTech.proxy.broadcast("Container1 BOOM! " +aBaseMetaTileEntity.getXCoord() + ' ' + aBaseMetaTileEntity.getYCoord() + ' ' + aBaseMetaTileEntity.getZCoord()); } } deathDelay = 3;//needed in some cases like repetitive failures. Should be 4 since there is -- at end but meh... @@ -132,11 +133,12 @@ public abstract class GT_MetaTileEntity_Hatch_ElementalContainer extends GT_Meta } } else if (deathDelay < 1) { if (TecTech.configTecTech.BOOM_ENABLE) { - getBaseMetaTileEntity().doExplosion(V[14]); + aBaseMetaTileEntity.doExplosion(V[14]); } else { + TecTech.anomalyHandler.addAnomaly(aBaseMetaTileEntity,overflowMatter*32D); deathDelay=3; overflowMatter=0; - TecTech.proxy.broadcast("Container0 BOOM! " + getBaseMetaTileEntity().getXCoord() + ' ' + getBaseMetaTileEntity().getYCoord() + ' ' + getBaseMetaTileEntity().getZCoord()); + TecTech.proxy.broadcast("Container0 BOOM! " + aBaseMetaTileEntity.getXCoord() + ' ' + aBaseMetaTileEntity.getYCoord() + ' ' + aBaseMetaTileEntity.getZCoord()); } } deathDelay--; @@ -207,8 +209,8 @@ public abstract class GT_MetaTileEntity_Hatch_ElementalContainer extends GT_Meta } @Override - public float purgeOverflow() { - return overflowMatter += content.removeOverflow(getMaxStacksCount(), getMaxStackSize()); + public void purgeOverflow() { + overflowMatter += content.removeOverflow(getMaxStacksCount(), getMaxStackSize()); } @Override @@ -248,8 +250,8 @@ public abstract class GT_MetaTileEntity_Hatch_ElementalContainer extends GT_Meta } } - public float updateSlots() { - return purgeOverflow(); + public void updateSlots() { + purgeOverflow(); } @Override @@ -271,10 +273,12 @@ public abstract class GT_MetaTileEntity_Hatch_ElementalContainer extends GT_Meta @Override public void onRemoval() { if (isValidMetaTileEntity(this) && getBaseMetaTileEntity().isActive()) { + TecTech.anomalyHandler.addAnomaly(getBaseMetaTileEntity(),(overflowMatter+content.getMass())*16D); + IGregTechTileEntity base=getBaseMetaTileEntity(); if (TecTech.configTecTech.BOOM_ENABLE) { - getBaseMetaTileEntity().doExplosion(V[15]); + base.doExplosion(V[15]); } else { - TecTech.proxy.broadcast("BOOM! " + getBaseMetaTileEntity().getXCoord() + ' ' + getBaseMetaTileEntity().getYCoord() + ' ' + getBaseMetaTileEntity().getZCoord()); + TecTech.proxy.broadcast("BOOM! " +base.getXCoord() + ' ' + base.getYCoord() + ' ' + base.getZCoord()); } } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_EnergyMulti.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_EnergyMulti.java index 64dda8f84a..06bdd4faba 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_EnergyMulti.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_EnergyMulti.java @@ -30,6 +30,11 @@ public class GT_MetaTileEntity_Hatch_EnergyMulti extends GT_MetaTileEntity_Hatch Amperes = aAmp; } + public GT_MetaTileEntity_Hatch_EnergyMulti(int aID, String aName, String aNameRegional, int aTier, int i, String description,int aAmp) { + super(aID, aName, aNameRegional, aTier, 0, description); + Amperes = aAmp; + } + @Override public ITexture[] getTexturesActive(ITexture aBaseTexture) { return new ITexture[]{aBaseTexture, OVERLAYS_ENERGY_IN_POWER_TT[mTier]}; diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_EnergyTunnel.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_EnergyTunnel.java index 4e7fffcf9f..e074f9dabb 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_EnergyTunnel.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_EnergyTunnel.java @@ -6,56 +6,46 @@ import com.github.technus.tectech.thing.metaTileEntity.pipe.IConnectsToEnergyTun import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; import static com.github.technus.tectech.CommonValues.TRANSFER_AT; import static com.github.technus.tectech.CommonValues.V; -import static com.github.technus.tectech.thing.metaTileEntity.Textures.OVERLAYS_ENERGY_IN_POWER_TT; +import static com.github.technus.tectech.thing.metaTileEntity.Textures.OVERLAYS_ENERGY_IN_LASER_TT; /** * Created by danie_000 on 16.12.2016. */ -public class GT_MetaTileEntity_Hatch_EnergyTunnel extends GT_MetaTileEntity_Hatch implements IConnectsToEnergyTunnel { - public final int Amperes; - private final long upkeep; - private long packetsCount=0; - +public class GT_MetaTileEntity_Hatch_EnergyTunnel extends GT_MetaTileEntity_Hatch_EnergyMulti implements IConnectsToEnergyTunnel { public GT_MetaTileEntity_Hatch_EnergyTunnel(int aID, String aName, String aNameRegional, int aTier, int aAmp) { - super(aID, aName, aNameRegional, aTier, 0, "Energy injecting terminal for Multiblocks"); - Amperes = aAmp; + super(aID, aName, aNameRegional, aTier, 0, "Energy injecting terminal for Multiblocks",aAmp); Util.setTier(aTier,this); - upkeep=Math.max(V[mTier]/Amperes,V[4]); } - public GT_MetaTileEntity_Hatch_EnergyTunnel(String aName, int aTier, int aAmp, long aUpkeep, String aDescription, ITexture[][][] aTextures) { - super(aName, aTier, 0, aDescription, aTextures); - Amperes = aAmp; - this.upkeep=aUpkeep; + public GT_MetaTileEntity_Hatch_EnergyTunnel(String aName, int aTier, int aAmp, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aAmp, aDescription, aTextures); } @Override public ITexture[] getTexturesActive(ITexture aBaseTexture) { - return new ITexture[]{aBaseTexture, OVERLAYS_ENERGY_IN_POWER_TT[mTier]}; + return new ITexture[]{aBaseTexture, OVERLAYS_ENERGY_IN_LASER_TT[mTier]}; } @Override public ITexture[] getTexturesInactive(ITexture aBaseTexture) { - return new ITexture[]{aBaseTexture, OVERLAYS_ENERGY_IN_POWER_TT[mTier]}; + return new ITexture[]{aBaseTexture, OVERLAYS_ENERGY_IN_LASER_TT[mTier]}; } @Override public void loadNBTData(NBTTagCompound aNBT) { super.loadNBTData(aNBT); - packetsCount=aNBT.getLong("ePackets"); } @Override public void saveNBTData(NBTTagCompound aNBT) { super.saveNBTData(aNBT); - aNBT.setLong("ePackets",packetsCount); } @Override @@ -105,7 +95,7 @@ public class GT_MetaTileEntity_Hatch_EnergyTunnel extends GT_MetaTileEntity_Hatc @Override public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_Hatch_EnergyTunnel(mName, mTier, Amperes, upkeep, mDescription, mTextures); + return new GT_MetaTileEntity_Hatch_EnergyTunnel(mName, mTier, Amperes, mDescription, mTextures); } @Override @@ -123,6 +113,7 @@ public class GT_MetaTileEntity_Hatch_EnergyTunnel extends GT_MetaTileEntity_Hatc return new String[]{ CommonValues.TEC_MARK_GENERAL, mDescription, + "Throughput: "+ EnumChatFormatting.YELLOW +(Amperes*maxEUInput())+EnumChatFormatting.RESET+" EU/t" }; } @@ -136,35 +127,13 @@ public class GT_MetaTileEntity_Hatch_EnergyTunnel extends GT_MetaTileEntity_Hatc if (aBaseMetaTileEntity.isServerSide()) { byte Tick = (byte) (aTick % 20); if (TRANSFER_AT == Tick) { - if(packetsCount>0){ - long diff=(maxEUStore()-aBaseMetaTileEntity.getStoredEU())/maxEUInput(); - if(diff>0) { - setEUVar(aBaseMetaTileEntity.getStoredEU() + takePackets(diff) * maxEUInput()); - } - } if(aBaseMetaTileEntity.getStoredEU()>0){ - setEUVar(aBaseMetaTileEntity.getStoredEU()-upkeep); + setEUVar(aBaseMetaTileEntity.getStoredEU()-Amperes); if(aBaseMetaTileEntity.getStoredEU()<0){ setEUVar(0); } } - getBaseMetaTileEntity().setActive(packetsCount>0); } } } - - public void addPackets(long count){ - packetsCount+=count; - } - - public long takePackets(long count){ - if(packetsCount>count){ - packetsCount-=count; - return count; - }else { - count=packetsCount; - packetsCount=0; - return count; - } - } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_InputElemental.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_InputElemental.java index ccf7f1a063..6078c6379a 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_InputElemental.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_InputElemental.java @@ -10,7 +10,7 @@ import gregtech.api.metatileentity.MetaTileEntity; */ public class GT_MetaTileEntity_Hatch_InputElemental extends GT_MetaTileEntity_Hatch_ElementalContainer { public GT_MetaTileEntity_Hatch_InputElemental(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, "Elemental Input for Multiblocks (" + 1000 * aTier * (aTier - 7) + "U, " + aTier * 2 + " stacks)"); + super(aID, aName, aNameRegional, aTier, "Elemental Input for Multiblocks"); Util.setTier(aTier,this); } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OutputData.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OutputData.java index d0e5399f75..7c9f8fba5c 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OutputData.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OutputData.java @@ -87,6 +87,7 @@ public class GT_MetaTileEntity_Hatch_OutputData extends GT_MetaTileEntity_Hatch_ } IMetaTileEntity meta = next.getMetaTileEntity(); if (meta instanceof GT_MetaTileEntity_Pipe_Data){ + ((GT_MetaTileEntity_Pipe_Data) meta).markUsed(); return (IConnectsToDataPipe) meta; }else if (meta instanceof GT_MetaTileEntity_Hatch_InputData && ((GT_MetaTileEntity_Hatch_InputData) meta).getColorization()==color && diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OutputDataItems.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OutputDataItems.java index 82bda9d326..472f998d89 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OutputDataItems.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OutputDataItems.java @@ -127,6 +127,7 @@ public class GT_MetaTileEntity_Hatch_OutputDataItems extends GT_MetaTileEntity_H } IMetaTileEntity meta = next.getMetaTileEntity(); if (meta instanceof GT_MetaTileEntity_Pipe_Data){ + ((GT_MetaTileEntity_Pipe_Data) meta).markUsed(); return (IConnectsToDataPipe) meta; }else if (meta instanceof GT_MetaTileEntity_Hatch_InputDataItems && ((GT_MetaTileEntity_Hatch_InputDataItems) meta).getColorization()==color && diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OutputElemental.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OutputElemental.java index 942dc48256..adfcb1d464 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OutputElemental.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OutputElemental.java @@ -13,7 +13,7 @@ import gregtech.api.util.GT_Utility; */ public class GT_MetaTileEntity_Hatch_OutputElemental extends GT_MetaTileEntity_Hatch_ElementalContainer { public GT_MetaTileEntity_Hatch_OutputElemental(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, "Elemental Output for Multiblocks (" + 1000 * aTier * (aTier - 7) + "U, " + aTier * 2 + " stacks)"); + super(aID, aName, aNameRegional, aTier, "Elemental Output for Multiblocks"); Util.setTier(aTier,this); } @@ -65,8 +65,10 @@ public class GT_MetaTileEntity_Hatch_OutputElemental extends GT_MetaTileEntity_H content.clear(); return; } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Pipe_EM) { - if (((GT_MetaTileEntity_Pipe_EM) aMetaTileEntity).connectionCount > 2) { + if (((GT_MetaTileEntity_Pipe_EM) aMetaTileEntity).connectionCount != 2) { return; + }else { + ((GT_MetaTileEntity_Pipe_EM) aMetaTileEntity).markUsed(); } } else { return; diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OverflowElemental.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OverflowElemental.java index 867f814b63..18eb8b8c72 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OverflowElemental.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OverflowElemental.java @@ -38,9 +38,9 @@ import static gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Mult public class GT_MetaTileEntity_Hatch_OverflowElemental extends GT_MetaTileEntity_Hatch { private static Textures.BlockIcons.CustomIcon EM_T_SIDES; private static Textures.BlockIcons.CustomIcon EM_T_ACTIVE; - private static Textures.BlockIcons.CustomIcon MufflerEM; - private static Textures.BlockIcons.CustomIcon MufflerEMidle; - private float overflowMatter = 0f; + public static Textures.BlockIcons.CustomIcon MufflerEM; + public static Textures.BlockIcons.CustomIcon MufflerEMidle; + private float overflowMatter; public final float overflowMax; private final float overflowDisperse; @@ -142,10 +142,10 @@ public class GT_MetaTileEntity_Hatch_OverflowElemental extends GT_MetaTileEntity if (aBaseMetaTileEntity.isServerSide() && aTick % 20 == DISPERSE_AT) { if (aBaseMetaTileEntity.isActive()) { if (overflowMatter > overflowDisperse) { - //todo add full dose of dispersed pollution (reduced by tier, or make recycler machine only capable of reduction?) + TecTech.anomalyHandler.addAnomaly(aBaseMetaTileEntity,overflowDisperse); overflowMatter -= overflowDisperse; } else { - //todo add partial dose of dispersed pollution (reduced by tier, or make recycler machine only capable of reduction?) + TecTech.anomalyHandler.addAnomaly(aBaseMetaTileEntity,overflowMatter); overflowMatter = 0; aBaseMetaTileEntity.setActive(false); aBaseMetaTileEntity.setLightValue((byte) 0); @@ -159,8 +159,8 @@ public class GT_MetaTileEntity_Hatch_OverflowElemental extends GT_MetaTileEntity aBaseMetaTileEntity.getWorld().updateLightByType(EnumSkyBlock.Block, aBaseMetaTileEntity.getXCoord(), aBaseMetaTileEntity.getYCoord(), aBaseMetaTileEntity.getZCoord()); } } - } else if (aBaseMetaTileEntity.isClientSide() && getBaseMetaTileEntity().isActive()) { - TecTech.proxy.em_particle(getBaseMetaTileEntity(), getBaseMetaTileEntity().getFrontFacing()); + } else if (aBaseMetaTileEntity.isClientSide() && aBaseMetaTileEntity.isActive()) { + TecTech.proxy.em_particle(aBaseMetaTileEntity, aBaseMetaTileEntity.getFrontFacing()); } super.onPostTick(aBaseMetaTileEntity, aTick); //DOES NOT CHECK FOR TOO MUCH, it is done only while putting stuff in (OPTIMIZATION!!!) @@ -195,13 +195,14 @@ public class GT_MetaTileEntity_Hatch_OverflowElemental extends GT_MetaTileEntity "Contained mass:", EnumChatFormatting.RED + Double.toString(overflowMatter) + EnumChatFormatting.RESET + " eV/c\u00b2 /", EnumChatFormatting.GREEN + Double.toString(overflowMax) + EnumChatFormatting.RESET + " eV/c\u00b2", - "Mass Disposal speed: " + EnumChatFormatting.BLUE + Double.toString(overflowDisperse) + EnumChatFormatting.RESET + " (eV/c\u00b2)/s" + "Mass Disposal speed: " + EnumChatFormatting.BLUE + overflowDisperse + EnumChatFormatting.RESET + " (eV/c\u00b2)/s" }; } @Override public void onRemoval() { if (isValidMetaTileEntity(this) && getBaseMetaTileEntity().isActive()) { + TecTech.anomalyHandler.addAnomaly(getBaseMetaTileEntity(),overflowMatter*8D); if (TecTech.configTecTech.BOOM_ENABLE) { getBaseMetaTileEntity().doExplosion(V[15]); } else { diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Param.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Param.java index 2a2812368b..a4a713626c 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Param.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Param.java @@ -26,13 +26,12 @@ import net.minecraftforge.fluids.FluidStack; * Created by danie_000 on 15.12.2016. */ public class GT_MetaTileEntity_Hatch_Param extends GT_MetaTileEntity_Hatch { - private boolean usesFloat = false; public int pointer = 0; public int param = -1; - public int value0i = 0; - public int value1i = 0; - public int input0i = 0; - public int input1i = 0; + public double value0D = 0; + public double value1D = 0; + public double input0D = 0; + public double input1D = 0; private static Textures.BlockIcons.CustomIcon ScreenON; private static Textures.BlockIcons.CustomIcon ScreenOFF; @@ -105,15 +104,12 @@ public class GT_MetaTileEntity_Hatch_Param extends GT_MetaTileEntity_Hatch { @Override public String[] getInfoData() { - if(mTier>7) { - return new String[]{"Parametrizer ID: " + EnumChatFormatting.GREEN + param, "Value 0I: " + EnumChatFormatting.AQUA + value0i, "Value 0FB: " + EnumChatFormatting.AQUA + Float.intBitsToFloat(value0i) + ' ' + Util.intBitsToShortString(value0i), "Value 1I: " + EnumChatFormatting.BLUE + value1i, "Value 1FB: " + EnumChatFormatting.BLUE + Float.intBitsToFloat(value1i) + ' ' + Util.intBitsToShortString(value1i), "Input 0I: " + EnumChatFormatting.GOLD + input0i, "Input 0FB: " + EnumChatFormatting.GOLD + Float.intBitsToFloat(input0i) + ' ' + Util.intBitsToShortString(input0i), "Input 1I: " + EnumChatFormatting.YELLOW + input1i, "Input 1FB: " + EnumChatFormatting.YELLOW + Float.intBitsToFloat(input1i) + ' ' + Util.intBitsToShortString(input1i),}; - } return new String[]{ "Parametrizer ID: " + EnumChatFormatting.GREEN + param, - "Value 0I: " + EnumChatFormatting.AQUA + value0i, - "Value 1I: " + EnumChatFormatting.BLUE + value1i, - "Input 0I: " + EnumChatFormatting.GOLD + input0i, - "Input 1I: " + EnumChatFormatting.YELLOW + input1i, + "Value 0D: " + EnumChatFormatting.AQUA + value0D, + "Value 1D: " + EnumChatFormatting.BLUE + value1D, + "Input 0D: " + EnumChatFormatting.GOLD + input0D, + "Input 1D: " + EnumChatFormatting.YELLOW + input1D, }; } @@ -135,24 +131,41 @@ public class GT_MetaTileEntity_Hatch_Param extends GT_MetaTileEntity_Hatch { @Override public void saveNBTData(NBTTagCompound aNBT) { super.saveNBTData(aNBT); - aNBT.setBoolean("eFloats", usesFloat); aNBT.setInteger("ePointer", pointer); - aNBT.setInteger("eValue0i", value0i); - aNBT.setInteger("eValue1i", value1i); - aNBT.setInteger("eInput0i", value0i); - aNBT.setInteger("eInput1i", value1i); + aNBT.setDouble("eValue0D", value0D); + aNBT.setDouble("eValue1D", value1D); + aNBT.setDouble("eInput0D", input0D); + aNBT.setDouble("eInput1D", input1D); aNBT.setInteger("eParam", param); } @Override public void loadNBTData(NBTTagCompound aNBT) { super.loadNBTData(aNBT); - usesFloat = aNBT.getBoolean("eFloats"); pointer = aNBT.getInteger("ePointer"); - value0i=aNBT.getInteger("eValue0i"); - value1i=aNBT.getInteger("eValue1i"); - value0i=aNBT.getInteger("eInput0i"); - value1i=aNBT.getInteger("eInput1i"); + if(aNBT.hasKey("eFloats") || + aNBT.hasKey("eValue0i") || + aNBT.hasKey("eValue1i") || + aNBT.hasKey("eInput0i") || + aNBT.hasKey("eInput1i")){ + boolean usesFloat = aNBT.getBoolean("eFloats"); + if(usesFloat){ + value0D=Float.intBitsToFloat(aNBT.getInteger("eValue0i")); + value1D=Float.intBitsToFloat(aNBT.getInteger("eValue1i")); + input0D=Float.intBitsToFloat(aNBT.getInteger("eInput0i")); + input1D=Float.intBitsToFloat(aNBT.getInteger("eInput1i")); + }else { + value0D=aNBT.getInteger("eValue0i"); + value1D=aNBT.getInteger("eValue1i"); + input0D=aNBT.getInteger("eInput0i"); + input1D=aNBT.getInteger("eInput1i"); + } + }else{ + value0D=aNBT.getDouble("eValue0D"); + value1D=aNBT.getDouble("eValue1D"); + input0D=aNBT.getDouble("eInput0D"); + input1D=aNBT.getDouble("eInput1D"); + } param = aNBT.getInteger("eParam"); } @@ -198,17 +211,4 @@ public class GT_MetaTileEntity_Hatch_Param extends GT_MetaTileEntity_Hatch { EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + "E=mine*craft\u00b2" }; } - - public boolean isUsingFloats() { - return mTier > 7 && usesFloat; - } - - //returns - succeded - public boolean setUsingFloats(boolean value){ - if(mTier>7){ - usesFloat=value; - return true; - } - return !value; - } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_Container_Param.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_Container_Param.java index fec3be6e20..f9c53090ff 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_Container_Param.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_Container_Param.java @@ -1,6 +1,7 @@ package com.github.technus.tectech.thing.metaTileEntity.hatch.gui; import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.Util; import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_Param; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -15,10 +16,10 @@ import net.minecraft.item.ItemStack; public class GT_Container_Param extends GT_ContainerMetaTile_Machine { public int param = 0; - public int value0f = 0; - public int value1f = 0; - public int input0f = 0; - public int input1f = 0; + public double value0f = 0; + public double value1f = 0; + public double input0f = 0; + public double input1f = 0; public GT_Container_Param(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { super(aInventoryPlayer, aTileEntity); @@ -61,53 +62,53 @@ public class GT_Container_Param extends GT_ContainerMetaTile_Machine { paramH.param -= aShifthold == 1 ? 16 : 4; break; case 1: - paramH.value0i -= aShifthold == 1 ? 4096 : 256; + paramH.value0D -= aShifthold == 1 ? 4096 : 256; break; case 2: - paramH.value1i -= aShifthold == 1 ? 4096 : 256; + paramH.value1D -= aShifthold == 1 ? 4096 : 256; break; case 3: - paramH.value0i >>= aShifthold == 1 ? 16 : 4; - paramH.value1i >>= aShifthold == 1 ? 16 : 4; + paramH.value0D /= aShifthold == 1 ? 4096 : 256; + paramH.value1D /= aShifthold == 1 ? 4096 : 256; break; case 4: paramH.param -= aShifthold == 1 ? 2 : 1; break; case 5: - paramH.value0i -= aShifthold == 1 ? 16 : 1; + paramH.value0D -= aShifthold == 1 ? 16 : 1; break; case 6: - paramH.value1i -= aShifthold == 1 ? 16 : 1; + paramH.value1D -= aShifthold == 1 ? 16 : 1; break; case 7: - paramH.value0i >>= aShifthold == 1 ? 2 : 1; - paramH.value1i >>= aShifthold == 1 ? 2 : 1; + paramH.value0D /= aShifthold == 1 ? 16 : 2; + paramH.value1D /= aShifthold == 1 ? 16 : 2; break; case 8: paramH.param += aShifthold == 1 ? 16 : 4; break; case 9: - paramH.value0i += aShifthold == 1 ? 4096 : 256; + paramH.value0D += aShifthold == 1 ? 4096 : 256; break; case 10: - paramH.value1i += aShifthold == 1 ? 4096 : 256; + paramH.value1D += aShifthold == 1 ? 4096 : 256; break; case 11: - paramH.value0i <<= aShifthold == 1 ? 16 : 4; - paramH.value1i <<= aShifthold == 1 ? 16 : 4; + paramH.value0D *= aShifthold == 1 ? 4096 : 256; + paramH.value1D *= aShifthold == 1 ? 4096 : 256; break; case 12: paramH.param += aShifthold == 1 ? 2 : 1; break; case 13: - paramH.value0i += aShifthold == 1 ? 16 : 1; + paramH.value0D += aShifthold == 1 ? 16 : 1; break; case 14: - paramH.value1i += aShifthold == 1 ? 16 : 1; + paramH.value1D += aShifthold == 1 ? 16 : 1; break; case 15: - paramH.value0i <<= aShifthold == 1 ? 2 : 1; - paramH.value1i <<= aShifthold == 1 ? 2 : 1; + paramH.value0D *= aShifthold == 1 ? 16 : 2; + paramH.value1D *= aShifthold == 1 ? 16 : 2; break; default: doStuff = false; @@ -132,23 +133,18 @@ public class GT_Container_Param extends GT_ContainerMetaTile_Machine { return; } param = ((GT_MetaTileEntity_Hatch_Param) mTileEntity.getMetaTileEntity()).param; - value0f = ((GT_MetaTileEntity_Hatch_Param) mTileEntity.getMetaTileEntity()).value0i; - value1f = ((GT_MetaTileEntity_Hatch_Param) mTileEntity.getMetaTileEntity()).value1i; - input0f = ((GT_MetaTileEntity_Hatch_Param) mTileEntity.getMetaTileEntity()).input0i; - input1f = ((GT_MetaTileEntity_Hatch_Param) mTileEntity.getMetaTileEntity()).input1i; + value0f = ((GT_MetaTileEntity_Hatch_Param) mTileEntity.getMetaTileEntity()).value0D; + value1f = ((GT_MetaTileEntity_Hatch_Param) mTileEntity.getMetaTileEntity()).value1D; + input0f = ((GT_MetaTileEntity_Hatch_Param) mTileEntity.getMetaTileEntity()).input0D; + input1f = ((GT_MetaTileEntity_Hatch_Param) mTileEntity.getMetaTileEntity()).input1D; for (Object crafter : crafters) { ICrafting var1 = (ICrafting) crafter; - var1.sendProgressBarUpdate(this, 100, param & 0xFFFF); - var1.sendProgressBarUpdate(this, 101, param >>> 16); - var1.sendProgressBarUpdate(this, 102, value0f & 0xFFFF); - var1.sendProgressBarUpdate(this, 103, value0f >>> 16); - var1.sendProgressBarUpdate(this, 104, value1f & 0xFFFF); - var1.sendProgressBarUpdate(this, 105, value1f >>> 16); - var1.sendProgressBarUpdate(this, 106, input0f & 0xFFFF); - var1.sendProgressBarUpdate(this, 107, input0f >>> 16); - var1.sendProgressBarUpdate(this, 108, input1f & 0xFFFF); - var1.sendProgressBarUpdate(this, 109, input1f >>> 16); + Util.sendInteger(param,this,var1,100); + Util.sendDouble(value0f,this,var1,102); + Util.sendDouble(value1f,this,var1, 106); + Util.sendDouble(input0f,this,var1, 110); + Util.sendDouble(input1f,this,var1, 114); } } @@ -158,34 +154,32 @@ public class GT_Container_Param extends GT_ContainerMetaTile_Machine { super.updateProgressBar(par1, par2); switch (par1) { case 100: - param = param & 0xFFFF0000 | par2; - return; case 101: - param = param & 0xFFFF | par2 << 16; + param=Util.receiveInteger(param,100,par1,par2); return; case 102: - value0f = value0f & 0xFFFF0000 | par2; - break; case 103: - value0f = value0f & 0xFFFF | par2 << 16; - break; case 104: - value1f = value1f & 0xFFFF0000 | par2; - break; case 105: - value1f = value1f & 0xFFFF | par2 << 16; - break; + value0f=Util.receiveDouble(value0f,102,par1,par2); + return; case 106: - input0f = input0f & 0xFFFF0000 | par2; - break; case 107: - input0f = input0f & 0xFFFF | par2 << 16; - break; case 108: - input1f = input1f & 0xFFFF0000 | par2; - return; case 109: - input1f = input1f & 0xFFFF | par2 << 16; + value1f=Util.receiveDouble(value1f,106,par1,par2); + return; + case 110: + case 111: + case 112: + case 113: + input0f=Util.receiveDouble(input0f,110,par1,par2); + return; + case 114: + case 115: + case 116: + case 117: + input1f=Util.receiveDouble(input1f,114,par1,par2); return; default: } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_Container_ParamAdv.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_Container_ParamAdv.java index 90d8a26d1c..e925ed91e8 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_Container_ParamAdv.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_Container_ParamAdv.java @@ -1,6 +1,7 @@ package com.github.technus.tectech.thing.metaTileEntity.hatch.gui; import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.Util; import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_Param; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -14,13 +15,12 @@ import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; public class GT_Container_ParamAdv extends GT_ContainerMetaTile_Machine { - public boolean usesFloats = false; public int pointer=0; public int param = 0; - public int value1f = 0; - public int value0f = 0; - public int input0f = 0; - public int input1f = 0; + public double value1f = 0; + public double value0f = 0; + public double input0f = 0; + public double input1f = 0; public GT_Container_ParamAdv(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { super(aInventoryPlayer, aTileEntity); @@ -60,7 +60,6 @@ public class GT_Container_ParamAdv extends GT_ContainerMetaTile_Machine { GT_MetaTileEntity_Hatch_Param paramH = (GT_MetaTileEntity_Hatch_Param) mTileEntity.getMetaTileEntity(); int columnPointer=paramH.pointer &0xff; boolean secondRow=(paramH.pointer &0x0100)!=0; - boolean showInts=!paramH.isUsingFloats(); switch (aSlotIndex) { case 0: paramH.param -= aShifthold == 1 ? 16 : 4; @@ -82,15 +81,19 @@ public class GT_Container_ParamAdv extends GT_ContainerMetaTile_Machine { case 3: if (aShifthold == 1) { if (secondRow) { - paramH.value1i = 0xFFFFFFFF; + paramH.value1D = Double.longBitsToDouble(0xFFFF_FFFF_FFFF_FFFFL); } else { - paramH.value0i = 0xFFFFFFFF; + paramH.value0D = Double.longBitsToDouble(0xFFFF_FFFF_FFFF_FFFFL); } } else { if (secondRow) { - paramH.value1i |= 1 << columnPointer; + long temp=Double.doubleToLongBits(paramH.value1D); + temp |= 1 << columnPointer; + paramH.value1D=Double.longBitsToDouble(temp); } else { - paramH.value0i |= 1 << columnPointer; + long temp=Double.doubleToLongBits(paramH.value0D); + temp |= 1 << columnPointer; + paramH.value0D=Double.longBitsToDouble(temp); } } break; @@ -114,15 +117,19 @@ public class GT_Container_ParamAdv extends GT_ContainerMetaTile_Machine { case 7: if (aShifthold == 1) { if (secondRow) { - paramH.value1i = 0; + paramH.value1D = Double.longBitsToDouble(0); } else { - paramH.value0i = 0; + paramH.value0D = Double.longBitsToDouble(0); } } else { if (secondRow) { - paramH.value1i &= ~(1 << columnPointer); + long temp=Double.doubleToLongBits(paramH.value1D); + temp &= ~(1 << columnPointer); + paramH.value1D=Double.longBitsToDouble(temp); } else { - paramH.value0i &= ~(1 << columnPointer); + long temp=Double.doubleToLongBits(paramH.value0D); + temp &= ~(1 << columnPointer); + paramH.value0D=Double.longBitsToDouble(temp); } } break; @@ -144,7 +151,8 @@ public class GT_Container_ParamAdv extends GT_ContainerMetaTile_Machine { } break; case 11: - showInts ^= true; + paramH.value0D=paramH.input0D; + paramH.value1D=paramH.input1D; break; case 12: paramH.param += aShifthold == 1 ? 2 : 1; @@ -166,15 +174,19 @@ public class GT_Container_ParamAdv extends GT_ContainerMetaTile_Machine { case 15: if (aShifthold == 1) { if (secondRow) { - paramH.value1i ^= 0xFFFFFFFF; + paramH.value1D = Double.longBitsToDouble(~Double.doubleToLongBits(paramH.value1D)); } else { - paramH.value0i ^= 0xFFFFFFFF; + paramH.value0D = Double.longBitsToDouble(~Double.doubleToLongBits(paramH.value1D)); } } else { if (secondRow) { - paramH.value1i ^= 1 << columnPointer; + long temp=Double.doubleToLongBits(paramH.value1D); + temp ^= 1 << columnPointer; + paramH.value1D=Double.longBitsToDouble(temp); } else { - paramH.value0i ^= 1 << columnPointer; + long temp=Double.doubleToLongBits(paramH.value0D); + temp ^= 1 << columnPointer; + paramH.value0D=Double.longBitsToDouble(temp); } } break; @@ -184,13 +196,12 @@ public class GT_Container_ParamAdv extends GT_ContainerMetaTile_Machine { if (doStuff) { IGregTechTileEntity base=paramH.getBaseMetaTileEntity(); TecTech.proxy.playSound(base,"fx_click"); - if(columnPointer>=32) { - columnPointer = 31; + if(columnPointer>=64) { + columnPointer = 63; } else if(columnPointer<0) { columnPointer = 0; } paramH.pointer=secondRow?columnPointer+0x100:columnPointer; - paramH.setUsingFloats(!showInts); if (paramH.param > 9) { paramH.param = 9; } else if (paramH.param < -1) { @@ -208,27 +219,20 @@ public class GT_Container_ParamAdv extends GT_ContainerMetaTile_Machine { return; } param = ((GT_MetaTileEntity_Hatch_Param) mTileEntity.getMetaTileEntity()).param; - value0f = ((GT_MetaTileEntity_Hatch_Param) mTileEntity.getMetaTileEntity()).value0i; - value1f = ((GT_MetaTileEntity_Hatch_Param) mTileEntity.getMetaTileEntity()).value1i; - input0f = ((GT_MetaTileEntity_Hatch_Param) mTileEntity.getMetaTileEntity()).input0i; - input1f = ((GT_MetaTileEntity_Hatch_Param) mTileEntity.getMetaTileEntity()).input1i; + value0f = ((GT_MetaTileEntity_Hatch_Param) mTileEntity.getMetaTileEntity()).value0D; + value1f = ((GT_MetaTileEntity_Hatch_Param) mTileEntity.getMetaTileEntity()).value1D; + input0f = ((GT_MetaTileEntity_Hatch_Param) mTileEntity.getMetaTileEntity()).input0D; + input1f = ((GT_MetaTileEntity_Hatch_Param) mTileEntity.getMetaTileEntity()).input1D; pointer = ((GT_MetaTileEntity_Hatch_Param) mTileEntity.getMetaTileEntity()).pointer; - usesFloats =((GT_MetaTileEntity_Hatch_Param) mTileEntity.getMetaTileEntity()).isUsingFloats(); for (Object crafter : crafters) { ICrafting var1 = (ICrafting) crafter; - var1.sendProgressBarUpdate(this, 100, param & 0xFFFF); - var1.sendProgressBarUpdate(this, 101, param >>> 16); - var1.sendProgressBarUpdate(this, 102, value0f & 0xFFFF); - var1.sendProgressBarUpdate(this, 103, value0f >>> 16); - var1.sendProgressBarUpdate(this, 104, value1f & 0xFFFF); - var1.sendProgressBarUpdate(this, 105, value1f >>> 16); - var1.sendProgressBarUpdate(this, 106, input0f & 0xFFFF); - var1.sendProgressBarUpdate(this, 107, input0f >>> 16); - var1.sendProgressBarUpdate(this, 108, input1f & 0xFFFF); - var1.sendProgressBarUpdate(this, 109, input1f >>> 16); - var1.sendProgressBarUpdate(this, 110, pointer); - var1.sendProgressBarUpdate(this, 111, usesFloats ? 1 : 0); + Util.sendInteger(param,this,var1,100); + Util.sendDouble(value0f,this,var1,102); + Util.sendDouble(value1f,this,var1, 106); + Util.sendDouble(input0f,this,var1, 110); + Util.sendDouble(input1f,this,var1, 114); + Util.sendInteger(pointer,this,var1,118); } } @@ -238,39 +242,37 @@ public class GT_Container_ParamAdv extends GT_ContainerMetaTile_Machine { super.updateProgressBar(par1, par2); switch (par1) { case 100: - param = param & 0xFFFF0000 | par2; - return; case 101: - param = param & 0xFFFF | par2 << 16; + param=Util.receiveInteger(param,100,par1,par2); return; case 102: - value0f = value0f & 0xFFFF0000 | par2; - break; case 103: - value0f = value0f & 0xFFFF | par2 << 16; - break; case 104: - value1f = value1f & 0xFFFF0000 | par2; - break; case 105: - value1f = value1f & 0xFFFF | par2 << 16; - break; + value0f=Util.receiveDouble(value0f,102,par1,par2); + return; case 106: - input0f = input0f & 0xFFFF0000 | par2; - break; case 107: - input0f = input0f & 0xFFFF | par2 << 16; - break; case 108: - input1f = input1f & 0xFFFF0000 | par2; - return; case 109: - input1f = input1f & 0xFFFF | par2 << 16; + value1f=Util.receiveDouble(value1f,106,par1,par2); return; case 110: - pointer = par2 & 0xFFFF; case 111: - usesFloats = par2 != 0; + case 112: + case 113: + input0f=Util.receiveDouble(input0f,110,par1,par2); + return; + case 114: + case 115: + case 116: + case 117: + input1f=Util.receiveDouble(input1f,114,par1,par2); + return; + case 118: + case 119: + pointer=Util.receiveInteger(pointer,118,par1,par2); + return; default: } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_Param.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_Param.java index d9502333d8..015c3742cd 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_Param.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_Param.java @@ -4,6 +4,7 @@ import com.github.technus.tectech.Util; import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import net.minecraft.entity.player.InventoryPlayer; +import org.lwjgl.opengl.GL11; import java.util.Locale; @@ -20,12 +21,15 @@ public class GT_GUIContainer_Param extends GT_GUIContainerMetaTile_Machine { if (mContainer != null) { proxy.renderUnicodeString("Parameters: " + ((GT_Container_Param) mContainer).param, 46, 7, 167, 0xffffff); Locale locale= Locale.getDefault(); - proxy.renderUnicodeString("\u24EA\u2b07" + String.format(locale, "%+d", ((GT_Container_Param) mContainer).input0f), 46, 16, 167, 0x22ddff); - proxy.renderUnicodeString("\u2460\u2b07" + String.format(locale, "%+d", ((GT_Container_Param) mContainer).input1f), 46, 24, 167, 0x00ffff); - proxy.renderUnicodeString("\u24EA\u2b06" + String.format(locale, "%+d", ((GT_Container_Param) mContainer).value0f), 46, 33, 167, 0x00bbff); - proxy.renderUnicodeString("\u2460\u2b06" + String.format(locale, "%+d", ((GT_Container_Param) mContainer).value1f), 46, 41, 167, 0x0077ff); - proxy.renderUnicodeString("\u24EA\u2b06" + Util.intBitsToShortString(((GT_Container_Param) mContainer).value0f), 46, 50, 167, 0x00bbff); - proxy.renderUnicodeString("\u2460\u2b06" + Util.intBitsToShortString(((GT_Container_Param) mContainer).value1f), 46, 58, 167, 0x0077ff); + proxy.renderUnicodeString("\u24EA\u2b07" + String.format(locale, "%+.5E", ((GT_Container_Param) mContainer).input0f), 46, 16, 167, 0x22ddff); + proxy.renderUnicodeString("\u2460\u2b07" + String.format(locale, "%+.5E", ((GT_Container_Param) mContainer).input1f), 46, 24, 167, 0x00ffff); + proxy.renderUnicodeString("\u24EA\u2b06" + String.format(locale, "%+.5E", ((GT_Container_Param) mContainer).value0f), 46, 33, 167, 0x00bbff); + proxy.renderUnicodeString("\u2460\u2b06" + String.format(locale, "%+.5E", ((GT_Container_Param) mContainer).value1f), 46, 41, 167, 0x0077ff); + GL11.glPushMatrix(); + GL11.glScalef(.5f,.5f,.5f); + proxy.renderUnicodeString("\u24EA\u2b06" + Util.longBitsToShortString(Double.doubleToLongBits(((GT_Container_Param) mContainer).value0f)), 92, 100, 334, 0x00bbff); + proxy.renderUnicodeString("\u2460\u2b06" + Util.longBitsToShortString(Double.doubleToLongBits(((GT_Container_Param) mContainer).value1f)), 92, 116, 334, 0x0077ff); + GL11.glPopMatrix(); } else { proxy.renderUnicodeString("Parameters", 46, 7, 167, 0xffffff); } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_ParamAdv.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_ParamAdv.java index 245ec91b20..5e83290450 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_ParamAdv.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_ParamAdv.java @@ -4,6 +4,7 @@ import com.github.technus.tectech.Util; import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import net.minecraft.entity.player.InventoryPlayer; +import org.lwjgl.opengl.GL11; import java.util.Locale; @@ -19,20 +20,16 @@ public class GT_GUIContainer_ParamAdv extends GT_GUIContainerMetaTile_Machine { protected void drawGuiContainerForegroundLayer(int par1, int par2) { if (mContainer != null) { proxy.renderUnicodeString("Parameters X: " + ((GT_Container_ParamAdv) mContainer).param, 46, 7, 167, 0xffffff); - Locale locale= Locale.getDefault(); - if (((GT_Container_ParamAdv) mContainer).usesFloats) { - proxy.renderUnicodeString("\u24EA\u2b07" + String.format(locale, "%+.5E", Float.intBitsToFloat(((GT_Container_ParamAdv) mContainer).input0f)), 46, 16, 167, 0x22ddff); - proxy.renderUnicodeString("\u2460\u2b07" + String.format(locale, "%+.5E", Float.intBitsToFloat(((GT_Container_ParamAdv) mContainer).input1f)), 46, 24, 167, 0x00ffff); - proxy.renderUnicodeString("\u24EA\u2b06" + String.format(locale, "%+.5E", Float.intBitsToFloat(((GT_Container_ParamAdv) mContainer).value0f)), 46, 33, 167, 0x00bbff); - proxy.renderUnicodeString("\u2460\u2b06" + String.format(locale, "%+.5E", Float.intBitsToFloat(((GT_Container_ParamAdv) mContainer).value1f)), 46, 41, 167, 0x0077ff); - } else { - proxy.renderUnicodeString("\u24EA\u2b07" + String.format(locale, "%+d", ((GT_Container_ParamAdv) mContainer).input0f), 46, 16, 167, 0x22ddff); - proxy.renderUnicodeString("\u2460\u2b07" + String.format(locale, "%+d", ((GT_Container_ParamAdv) mContainer).input1f), 46, 24, 167, 0x00ffff); - proxy.renderUnicodeString("\u24EA\u2b06" + String.format(locale, "%+d", ((GT_Container_ParamAdv) mContainer).value0f), 46, 33, 167, 0x00bbff); - proxy.renderUnicodeString("\u2460\u2b06" + String.format(locale, "%+d", ((GT_Container_ParamAdv) mContainer).value1f), 46, 41, 167, 0x0077ff); - } - proxy.renderUnicodeString("\u24EA\u2b06" + Util.intBitsToShortString(((GT_Container_ParamAdv) mContainer).value0f), 46, 50, 167, 0x00bbff); - proxy.renderUnicodeString("\u2460\u2b06" + Util.intBitsToShortString(((GT_Container_ParamAdv) mContainer).value1f), 46, 58, 167, 0x0077ff); + Locale locale = Locale.getDefault(); + proxy.renderUnicodeString("\u24EA\u2b07" + String.format(locale, "%+.5E", (((GT_Container_ParamAdv) mContainer).input0f)), 46, 16, 167, 0x22ddff); + proxy.renderUnicodeString("\u2460\u2b07" + String.format(locale, "%+.5E", (((GT_Container_ParamAdv) mContainer).input1f)), 46, 24, 167, 0x00ffff); + proxy.renderUnicodeString("\u24EA\u2b06" + String.format(locale, "%+.5E", (((GT_Container_ParamAdv) mContainer).value0f)), 46, 33, 167, 0x00bbff); + proxy.renderUnicodeString("\u2460\u2b06" + String.format(locale, "%+.5E", (((GT_Container_ParamAdv) mContainer).value1f)), 46, 41, 167, 0x0077ff); + GL11.glPushMatrix(); + GL11.glScalef(.5f,.5f,.5f); + proxy.renderUnicodeString("\u24EA\u2b06" + Util.longBitsToShortString(Double.doubleToLongBits(((GT_Container_ParamAdv) mContainer).value0f)), 92, 100, 334, 0x00bbff); + proxy.renderUnicodeString("\u2460\u2b06" + Util.longBitsToShortString(Double.doubleToLongBits(((GT_Container_ParamAdv) mContainer).value1f)), 92, 116, 334, 0x0077ff); + GL11.glPopMatrix(); proxy.renderUnicodeString("Pointer " + Integer.toHexString(((GT_Container_ParamAdv) mContainer).pointer | 0x10000).substring(1), 46, 66, 167, 0x0033ff); } else { proxy.renderUnicodeString("Parameters X", 46, 7, 167, 0xffffff); diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_annihilation.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_annihilation.java index be9ff21e58..ece8c6ba82 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_annihilation.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_annihilation.java @@ -4,6 +4,7 @@ import com.github.technus.tectech.CommonValues; import com.github.technus.tectech.thing.block.QuantumGlassBlock; import com.github.technus.tectech.thing.metaTileEntity.IConstructable; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.IHatchAdder; import com.github.technus.tectech.thing.metaTileEntity.multi.base.render.TT_RenderedTexture; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -44,7 +45,7 @@ public class GT_MetaTileEntity_EM_annihilation extends GT_MetaTileEntity_Multibl }; private static final Block[] blockType = new Block[]{sBlockCasingsTT, sBlockCasingsTT, sBlockCasingsTT ,sBlockCasingsTT, QuantumGlassBlock.INSTANCE, sBlockCasingsTT}; private static final byte[] blockMeta = new byte[]{4, 5, 12, 6, 0, 10}; - private static final String[] addingMethods = new String[]{"addClassicToMachineList", "addElementalToMachineList"}; + private final IHatchAdder[] addingMethods = new IHatchAdder[]{this::addClassicToMachineList, this::addElementalToMachineList}; private static final short[] casingTextures = new short[]{textureOffset, textureOffset + 4}; private static final Block[] blockTypeFallback = new Block[]{sBlockCasingsTT, sBlockCasingsTT}; private static final byte[] blockMetaFallback = new byte[]{0, 4}; diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_bhg.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_bhg.java index 15e9628b7a..30ee7c4d64 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_bhg.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_bhg.java @@ -4,6 +4,7 @@ import com.github.technus.tectech.CommonValues; import com.github.technus.tectech.thing.block.QuantumGlassBlock; import com.github.technus.tectech.thing.metaTileEntity.IConstructable; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.IHatchAdder; import com.github.technus.tectech.thing.metaTileEntity.multi.base.render.TT_RenderedTexture; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -73,7 +74,7 @@ public class GT_MetaTileEntity_EM_bhg extends GT_MetaTileEntity_MultiblockBase_E }; private static final Block[] blockType = new Block[]{sBlockCasingsTT,sBlockCasingsTT,sBlockCasingsTT,sBlockCasingsTT,sBlockCasingsTT}; private static final byte[] blockMeta = new byte[]{12, 13, 14, 10, 11}; - private static final String[] addingMethods = new String[]{"addClassicToMachineList", "addElementalToMachineList"}; + private final IHatchAdder[] addingMethods = new IHatchAdder[]{this::addClassicToMachineList, this::addElementalToMachineList}; private static final short[] casingTextures = new short[]{textureOffset, textureOffset + 4}; private static final Block[] blockTypeFallback = new Block[]{sBlockCasingsTT, sBlockCasingsTT}; private static final byte[] blockMetaFallback = new byte[]{0, 4}; 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..166ab90ff1 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 @@ -16,6 +16,10 @@ import com.github.technus.tectech.thing.casing.TT_Container_Casings; import com.github.technus.tectech.thing.metaTileEntity.IConstructable; import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_InputElemental; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.IHatchAdder; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.Parameters; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.INameFunction; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.IStatusFunction; import com.github.technus.tectech.thing.metaTileEntity.multi.base.render.TT_RenderedTexture; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -37,6 +41,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. @@ -47,29 +52,28 @@ public class GT_MetaTileEntity_EM_collider extends GT_MetaTileEntity_MultiblockB private static Textures.BlockIcons.CustomIcon ScreenON_Slave; private static Textures.BlockIcons.CustomIcon ScreenOFF_Slave; - private static double MASS_TO_EU_PARTIAL,MASS_TO_EU_INSTANT; + protected static final byte FUSE_MODE=0, COLLIDE_MODE =1; + private static double MASS_TO_EU_INSTANT; private static int STARTUP_COST,KEEPUP_COST; - private long plasmaEnergy; - public static void setValues(int heliumPlasmaValue){ - MASS_TO_EU_PARTIAL = heliumPlasmaValue / 1.75893000478707E07;//mass diff + double MASS_TO_EU_PARTIAL = heliumPlasmaValue / 1.75893000478707E07;//mass diff MASS_TO_EU_INSTANT = MASS_TO_EU_PARTIAL * 20; STARTUP_COST=-heliumPlasmaValue*10000; KEEPUP_COST=-heliumPlasmaValue; } //region collision handlers - public static final HashMap<Integer, ColliderHandler> FUSE_HANDLERS =new HashMap<>(); - public static final HashMap<String, PrimitiveColliderHandler> PRIMITIVE_FUSE_HANDLERS =new HashMap<>(); - public interface PrimitiveColliderHandler { + public static final HashMap<Integer, IColliderHandler> FUSE_HANDLERS =new HashMap<>(); + public static final HashMap<String, IPrimitiveColliderHandler> PRIMITIVE_FUSE_HANDLERS =new HashMap<>(); + public interface IPrimitiveColliderHandler { void collide(cElementalInstanceStack in1, cElementalInstanceStack in2, cElementalInstanceStackMap out); } - public interface ColliderHandler extends PrimitiveColliderHandler { + public interface IColliderHandler extends IPrimitiveColliderHandler { byte getRequiredTier(); } static { - FUSE_HANDLERS.put((dAtomDefinition.getClassTypeStatic() << 16) | dAtomDefinition.getClassTypeStatic(), new ColliderHandler() { + FUSE_HANDLERS.put((dAtomDefinition.getClassTypeStatic() << 16) | dAtomDefinition.getClassTypeStatic(), new IColliderHandler() { @Override public void collide(cElementalInstanceStack in1, cElementalInstanceStack in2, cElementalInstanceStackMap out) { try { @@ -98,7 +102,7 @@ public class GT_MetaTileEntity_EM_collider extends GT_MetaTileEntity_MultiblockB registerSimpleAtomFuse(dComplexAspectDefinition.getClassTypeStatic()); registerSimpleAtomFuse(cElementalPrimitive.getClassTypeStatic()); - FUSE_HANDLERS.put((dHadronDefinition.getClassTypeStatic() << 16) | dHadronDefinition.getClassTypeStatic(), new ColliderHandler() { + FUSE_HANDLERS.put((dHadronDefinition.getClassTypeStatic() << 16) | dHadronDefinition.getClassTypeStatic(), new IColliderHandler() { @Override public void collide(cElementalInstanceStack in1, cElementalInstanceStack in2, cElementalInstanceStackMap out) { try { @@ -123,7 +127,7 @@ public class GT_MetaTileEntity_EM_collider extends GT_MetaTileEntity_MultiblockB return 2; } }); - FUSE_HANDLERS.put((dHadronDefinition.getClassTypeStatic() << 16) | cElementalPrimitive.getClassTypeStatic(), new ColliderHandler() { + FUSE_HANDLERS.put((dHadronDefinition.getClassTypeStatic() << 16) | cElementalPrimitive.getClassTypeStatic(), new IColliderHandler() { @Override public void collide(cElementalInstanceStack in1, cElementalInstanceStack in2, cElementalInstanceStackMap out) { try { @@ -152,10 +156,10 @@ public class GT_MetaTileEntity_EM_collider extends GT_MetaTileEntity_MultiblockB registerSimpleAspectFuse(dComplexAspectDefinition.getClassTypeStatic()); registerSimpleAspectFuse(cElementalPrimitive.getClassTypeStatic()); - FUSE_HANDLERS.put((cElementalPrimitive.getClassTypeStatic() << 16) | cElementalPrimitive.getClassTypeStatic(), new ColliderHandler() { + FUSE_HANDLERS.put((cElementalPrimitive.getClassTypeStatic() << 16) | cElementalPrimitive.getClassTypeStatic(), new IColliderHandler() { @Override public void collide(cElementalInstanceStack in1, cElementalInstanceStack in2, cElementalInstanceStackMap out) { - PrimitiveColliderHandler collisionHandler= PRIMITIVE_FUSE_HANDLERS.get(in1.definition.getClass().getName()+'\0'+in2.definition.getClass().getName()); + IPrimitiveColliderHandler collisionHandler= PRIMITIVE_FUSE_HANDLERS.get(in1.definition.getClass().getName()+'\0'+in2.definition.getClass().getName()); if (collisionHandler != null) { collisionHandler.collide(in2, in1, out); } else { @@ -169,35 +173,29 @@ public class GT_MetaTileEntity_EM_collider extends GT_MetaTileEntity_MultiblockB } }); - PRIMITIVE_FUSE_HANDLERS.put(eQuarkDefinition.class.getName() + '\0' + eQuarkDefinition.class.getName(), new PrimitiveColliderHandler() { - @Override - public void collide(cElementalInstanceStack in1, cElementalInstanceStack in2, cElementalInstanceStackMap out) { - try { - cElementalMutableDefinitionStackMap defs=new cElementalMutableDefinitionStackMap(); - defs.putUnify(in1.definition.getStackForm(1)); - defs.putUnify(in2.definition.getStackForm(1)); - dHadronDefinition hadron = new dHadronDefinition(defs.toImmutable_optimized_unsafeLeavesExposedElementalTree()); - out.putUnify(new cElementalInstanceStack(hadron,Math.min(in1.amount,in2.amount))); - }catch (Exception e){ - out.putUnifyAll(in1,in2); - return; - } - if(in1.amount>in2.amount){ - out.putUnify(new cElementalInstanceStack(in1.definition,in1.amount-in2.amount)); - }else if (in2.amount>in1.amount){ - out.putUnify(new cElementalInstanceStack(in2.definition,in2.amount-in1.amount)); - } + PRIMITIVE_FUSE_HANDLERS.put(eQuarkDefinition.class.getName() + '\0' + eQuarkDefinition.class.getName(), (in1, in2, out) -> { + try { + cElementalMutableDefinitionStackMap defs=new cElementalMutableDefinitionStackMap(); + defs.putUnify(in1.definition.getStackForm(1)); + defs.putUnify(in2.definition.getStackForm(1)); + dHadronDefinition hadron = new dHadronDefinition(defs.toImmutable_optimized_unsafeLeavesExposedElementalTree()); + out.putUnify(new cElementalInstanceStack(hadron,Math.min(in1.amount,in2.amount))); + }catch (Exception e){ + out.putUnifyAll(in1,in2); + return; + } + if(in1.amount>in2.amount){ + out.putUnify(new cElementalInstanceStack(in1.definition,in1.amount-in2.amount)); + }else if (in2.amount>in1.amount){ + out.putUnify(new cElementalInstanceStack(in2.definition,in2.amount-in1.amount)); } }); - PRIMITIVE_FUSE_HANDLERS.put(ePrimalAspectDefinition.class.getName() + '\0' + ePrimalAspectDefinition.class.getName(), new PrimitiveColliderHandler() { - @Override - public void collide(cElementalInstanceStack in1, cElementalInstanceStack in2, cElementalInstanceStackMap out) { - if (fuseAspects(in1, in2, out)) return; - if(in1.amount>in2.amount){ - out.putUnify(new cElementalInstanceStack(in1.definition,in1.amount-in2.amount)); - }else if (in2.amount>in1.amount){ - out.putUnify(new cElementalInstanceStack(in2.definition,in2.amount-in1.amount)); - } + PRIMITIVE_FUSE_HANDLERS.put(ePrimalAspectDefinition.class.getName() + '\0' + ePrimalAspectDefinition.class.getName(), (in1, in2, out) -> { + if (fuseAspects(in1, in2, out)) return; + if(in1.amount>in2.amount){ + out.putUnify(new cElementalInstanceStack(in1.definition,in1.amount-in2.amount)); + }else if (in2.amount>in1.amount){ + out.putUnify(new cElementalInstanceStack(in2.definition,in2.amount-in1.amount)); } }); } @@ -217,7 +215,7 @@ public class GT_MetaTileEntity_EM_collider extends GT_MetaTileEntity_MultiblockB } private static void registerSimpleAspectFuse(byte classTypeStatic) { - FUSE_HANDLERS.put((dComplexAspectDefinition.getClassTypeStatic() << 16) | classTypeStatic, new ColliderHandler() { + FUSE_HANDLERS.put((dComplexAspectDefinition.getClassTypeStatic() << 16) | classTypeStatic, new IColliderHandler() { @Override public void collide(cElementalInstanceStack in1, cElementalInstanceStack in2, cElementalInstanceStackMap out) { if (fuseAspects(in1, in2, out)) return; @@ -236,7 +234,7 @@ public class GT_MetaTileEntity_EM_collider extends GT_MetaTileEntity_MultiblockB } private static void registerSimpleAtomFuse(byte classTypeStatic) { - FUSE_HANDLERS.put((dAtomDefinition.getClassTypeStatic() << 16) | classTypeStatic, new ColliderHandler() { + FUSE_HANDLERS.put((dAtomDefinition.getClassTypeStatic() << 16) | classTypeStatic, new IColliderHandler() { @Override public void collide(cElementalInstanceStack in1, cElementalInstanceStack in2, cElementalInstanceStackMap out) { try { @@ -266,8 +264,38 @@ public class GT_MetaTileEntity_EM_collider extends GT_MetaTileEntity_MultiblockB protected byte eTier = 0; protected cElementalInstanceStack stack; + private long plasmaEnergy; + + //region parameters + protected Parameters.Group.ParameterIn mode; + private static final IStatusFunction<GT_MetaTileEntity_EM_collider> MODE_STATUS = (base_EM, p)->{ + if(base_EM.isMaster()){ + double mode=p.get(); + if (mode == FUSE_MODE || mode == COLLIDE_MODE) { + return STATUS_OK; + } else if (mode > 1) { + return STATUS_TOO_HIGH; + } else if (mode < 0) { + return STATUS_TOO_LOW; + } + return STATUS_WRONG; + } + return STATUS_UNUSED; + }; + private static final INameFunction<GT_MetaTileEntity_EM_collider> MODE_NAME = (base_EM, p)->{ + if(base_EM.isMaster()){ + double mode=p.get(); + if(mode==FUSE_MODE){ + return "Mode: Fuse"; + }else if(mode==COLLIDE_MODE){ + return "Mode: Collide"; + } + return "Mode: Undefined"; + } + return "Currently Slaves..."; + }; + //endregion - protected static final byte FUSE_MODE=0, COLLIDE_MODE =1; protected boolean started=false; //region Structure @@ -305,7 +333,11 @@ public class GT_MetaTileEntity_EM_collider extends GT_MetaTileEntity_MultiblockB }; private static final byte[] blockMeta1 = new byte[]{4, 7, 4, 0, 4, 8}; private static final byte[] blockMeta2 = new byte[]{4, 7, 5, 0, 6, 9}; - private static final String[] addingMethods = new String[]{"addClassicToMachineList", "addElementalInputToMachineList", "addElementalOutputToMachineList", "addElementalMufflerToMachineList"}; + private final IHatchAdder[] addingMethods = new IHatchAdder[]{ + this::addClassicToMachineList, + this::addElementalInputToMachineList, + this::addElementalOutputToMachineList, + this::addElementalMufflerToMachineList}; private static final short[] casingTextures = new short[]{textureOffset, textureOffset + 4, textureOffset + 4, textureOffset + 4}; private static final Block[] blockTypeFallback = new Block[]{sBlockCasingsTT, sBlockCasingsTT, sBlockCasingsTT, sBlockCasingsTT}; private static final byte[] blockMetaFallback = new byte[]{0, 4, 4, 4}; @@ -328,6 +360,12 @@ public class GT_MetaTileEntity_EM_collider extends GT_MetaTileEntity_MultiblockB } @Override + protected void parametersInstantiation_EM() { + Parameters.Group hatch_0=parametrization.getGroup(0); + mode=hatch_0.makeInParameter(0,FUSE_MODE, MODE_NAME, MODE_STATUS); + } + + @Override public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { return new GT_MetaTileEntity_EM_collider(mName); } @@ -438,18 +476,9 @@ public class GT_MetaTileEntity_EM_collider extends GT_MetaTileEntity_MultiblockB } @Override - public void parametersOutAndStatusesWrite_EM(boolean machineBusy) { + public void parametersStatusesWrite_EM(boolean machineBusy) { if(isMaster()) { - double mode = getParameterIn(0, 0); - if (mode == FUSE_MODE || mode == COLLIDE_MODE) { - setStatusOfParameterIn(0, 0, STATUS_OK); - } else if (mode > 1) { - setStatusOfParameterIn(0, 0, STATUS_TOO_HIGH); - } else if (mode < 0) { - setStatusOfParameterIn(0, 0, STATUS_TOO_LOW); - }else{ - setStatusOfParameterIn(0,0,STATUS_WRONG); - } + super.parametersStatusesWrite_EM(machineBusy); } } @@ -505,7 +534,7 @@ public class GT_MetaTileEntity_EM_collider extends GT_MetaTileEntity_MultiblockB //System.out.println("preMass = " + preMass); cElementalInstanceStackMap map = new cElementalInstanceStackMap(); - ColliderHandler colliderHandler; + IColliderHandler colliderHandler; if (stack2.definition.getClassType() > stack.definition.getClassType()) {//always bigger first colliderHandler = FUSE_HANDLERS.get((stack2.definition.getClassType() << 16) | stack.definition.getClassType()); if (handleRecipe(stack2, map, colliderHandler)) return 0; @@ -528,7 +557,7 @@ public class GT_MetaTileEntity_EM_collider extends GT_MetaTileEntity_MultiblockB return 0; } - private boolean handleRecipe(cElementalInstanceStack stack2, cElementalInstanceStackMap map, ColliderHandler colliderHandler) { + private boolean handleRecipe(cElementalInstanceStack stack2, cElementalInstanceStackMap map, IColliderHandler colliderHandler) { if (colliderHandler != null && eTier>= colliderHandler.getRequiredTier()) { colliderHandler.collide(stack2, stack, map); } else { @@ -599,7 +628,7 @@ public class GT_MetaTileEntity_EM_collider extends GT_MetaTileEntity_MultiblockB return; } if (isMaster()) { - switch (getParameterInInt(0,0)){ + switch ((int)mode.get()){ case FUSE_MODE: makeEU(fuse(partner)); break; 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..0facf9e949 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 @@ -10,6 +10,11 @@ import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_H import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_OutputData; import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_Rack; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.IHatchAdder; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.LedStatus; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.Parameters; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.INameFunction; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.IStatusFunction; import com.github.technus.tectech.thing.metaTileEntity.multi.base.render.TT_RenderedTexture; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -30,10 +35,10 @@ import java.util.ArrayList; import static com.github.technus.tectech.CommonValues.V; import static com.github.technus.tectech.Util.StructureBuilderExtreme; -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. @@ -42,8 +47,31 @@ public class GT_MetaTileEntity_EM_computer extends GT_MetaTileEntity_MultiblockB private static Textures.BlockIcons.CustomIcon ScreenOFF; private static Textures.BlockIcons.CustomIcon ScreenON; + //region parameters + protected Parameters.Group.ParameterIn overclock,overvolt; + protected Parameters.Group.ParameterOut maxCurrentTemp,availableData; + private static final INameFunction<GT_MetaTileEntity_EM_computer> OC_NAME = (base, p)-> "Overclock ratio"; + private static final INameFunction<GT_MetaTileEntity_EM_computer> OV_NAME = (base, p)-> "Overvoltage ratio"; + private static final INameFunction<GT_MetaTileEntity_EM_computer> MAX_TEMP_NAME = (base, p)-> "Current max. heat"; + private static final INameFunction<GT_MetaTileEntity_EM_computer> COMPUTE_NAME = (base, p)-> "Produced computation"; + private static final IStatusFunction<GT_MetaTileEntity_EM_computer> OC_STATUS= + (base,p)->LedStatus.fromLimitsInclusiveOuterBoundary(p.get(),0,1,1,3); + private static final IStatusFunction<GT_MetaTileEntity_EM_computer> OV_STATUS= + (base,p)->LedStatus.fromLimitsInclusiveOuterBoundary(p.get(),.7,.8,1.2,2); + private static final IStatusFunction<GT_MetaTileEntity_EM_computer> MAX_TEMP_STATUS= + (base,p)->LedStatus.fromLimitsInclusiveOuterBoundary(p.get(),-10000,0,0,5000); + private static final IStatusFunction<GT_MetaTileEntity_EM_computer> COMPUTE_STATUS=(base, p)->{ + if(base.eAvailableData<0){ + return STATUS_TOO_LOW; + } + if(base.eAvailableData==0){ + return STATUS_NEUTRAL; + } + return STATUS_OK; + }; + //endregion + private final ArrayList<GT_MetaTileEntity_Hatch_Rack> eRacks = new ArrayList<>(); - private int maxCurrentTemp = 0; //region Structure private static final String[][] front = new String[][]{{"A ", "A ", "A. ", "A ",},}; @@ -52,7 +80,7 @@ public class GT_MetaTileEntity_EM_computer extends GT_MetaTileEntity_MultiblockB private static final String[][] slice = new String[][]{{"-01", "A!2", "A!2", "-01",},}; private static final Block[] blockType = new Block[]{sBlockCasingsTT, sBlockCasingsTT, sBlockCasingsTT}; private static final byte[] blockMeta = new byte[]{2, 1, 3}; - private static final String[] addingMethods = new String[]{"addToMachineList", "addRackToMachineList"}; + private final IHatchAdder[] addingMethods = new IHatchAdder[]{this::addToMachineList, this::addRackToMachineList}; private static final short[] casingTextures = new short[]{textureOffset + 1, textureOffset + 3}; private static final Block[] blockTypeFallback = new Block[]{sBlockCasingsTT, sBlockCasingsTT}; private static final byte[] blockMetaFallback = new byte[]{1, 3}; @@ -76,6 +104,15 @@ public class GT_MetaTileEntity_EM_computer extends GT_MetaTileEntity_MultiblockB } @Override + protected void parametersInstantiation_EM() { + Parameters.Group hatch_0=parametrization.getGroup(0); + overclock=hatch_0.makeInParameter(0,1,OC_NAME,OC_STATUS); + overvolt=hatch_0.makeInParameter(1,1,OV_NAME,OV_STATUS); + maxCurrentTemp=hatch_0.makeOutParameter(0,0,MAX_TEMP_NAME,MAX_TEMP_STATUS); + availableData=hatch_0.makeOutParameter(1,0,COMPUTE_NAME,COMPUTE_STATUS); + } + + @Override @SideOnly(Side.CLIENT) protected ResourceLocation getActivitySound(){ return GT_MetaTileEntity_EM_switch.activitySound; @@ -104,14 +141,15 @@ public class GT_MetaTileEntity_EM_computer extends GT_MetaTileEntity_MultiblockB @Override public boolean checkRecipe_EM(ItemStack itemStack) { + parametrization.setToDefaults(false,true); eAvailableData = 0; - maxCurrentTemp = 0; - double overClockRatio= getParameterIn(0,0); - double overVoltageRatio= getParameterIn(0,1); + double maxTemp=0; + double overClockRatio= overclock.get(); + double overVoltageRatio= overvolt.get(); if(Double.isNaN(overClockRatio) || Double.isNaN(overVoltageRatio)) { return false; } - if(overClockRatio>0 && overVoltageRatio>=0.7f && overClockRatio<=3 && overVoltageRatio<=2){ + if(overclock.getStatus(true).isOk && overvolt.getStatus(true).isOk){ float eut=V[8] * (float)overVoltageRatio * (float)overClockRatio; if(eut<Integer.MAX_VALUE-7) { mEUt = -(int) eut; @@ -126,8 +164,8 @@ public class GT_MetaTileEntity_EM_computer extends GT_MetaTileEntity_MultiblockB if (!GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(rack)) { continue; } - if (rack.heat > maxCurrentTemp) { - maxCurrentTemp = rack.heat; + if (rack.heat > maxTemp) { + maxTemp=rack.heat; } rackComputation = rack.tickComponents((float) overClockRatio, (float) overVoltageRatio); if (rackComputation > 0) { @@ -149,6 +187,8 @@ public class GT_MetaTileEntity_EM_computer extends GT_MetaTileEntity_MultiblockB eAmpereFlow = 1 + (thingsActive >> 2); mMaxProgresstime = 20; mEfficiencyIncrease = 10000; + maxCurrentTemp.set(maxTemp); + availableData.set(eAvailableData); return true; } else { eAvailableData=0; @@ -156,6 +196,8 @@ public class GT_MetaTileEntity_EM_computer extends GT_MetaTileEntity_MultiblockB eAmpereFlow = 1; mMaxProgresstime = 20; mEfficiencyIncrease = 10000; + maxCurrentTemp.set(maxTemp); + availableData.set(eAvailableData); return true; } } @@ -194,78 +236,20 @@ public class GT_MetaTileEntity_EM_computer extends GT_MetaTileEntity_MultiblockB @Override protected void afterRecipeCheckFailed() { super.afterRecipeCheckFailed(); - for (GT_MetaTileEntity_Hatch_Rack r : eRacks) { - r.getBaseMetaTileEntity().setActive(false); - } - } - - @Override - protected void parametersLoadDefault_EM() { - setParameterPairIn_ClearOut(0, false, 1, 1); - } - - @Override - public void parametersOutAndStatusesWrite_EM(boolean machineBusy) { - double ocRatio = getParameterIn(0, 0); - if (ocRatio < 0) { - setStatusOfParameterIn(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_LOW); - } else if (ocRatio < 1) { - setStatusOfParameterIn(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_LOW); - } else if (ocRatio == 1) { - setStatusOfParameterIn(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_OK); - } else if (ocRatio <= 3) { - setStatusOfParameterIn(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_HIGH); - } else if (Double.isNaN(ocRatio)) { - setStatusOfParameterIn(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_WRONG); - } else { - setStatusOfParameterIn(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_HIGH); - } - - double ovRatio = getParameterIn(0, 1); - if (ovRatio < 0.7f) { - setStatusOfParameterIn(0, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_LOW); - } else if (ovRatio < 0.8f) { - setStatusOfParameterIn(0, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_LOW); - } else if (ovRatio <= 1.2f) { - setStatusOfParameterIn(0, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_OK); - } else if (ovRatio <= 2) { - setStatusOfParameterIn(0, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_HIGH); - } else if (Double.isNaN(ovRatio)) { - setStatusOfParameterIn(0, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_WRONG); - } else { - setStatusOfParameterIn(0, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_HIGH); - } - - setParameterOut(0, 0, maxCurrentTemp); - setParameterOut(0, 1, eAvailableData); - - if (maxCurrentTemp < -10000) { - setStatusOfParameterOut(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_LOW); - } else if (maxCurrentTemp < 0) { - setStatusOfParameterOut(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_LOW); - } else if (maxCurrentTemp == 0) { - setStatusOfParameterOut(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_OK); - } else if (maxCurrentTemp <= 5000) { - setStatusOfParameterOut(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_HIGH); - } else { - setStatusOfParameterOut(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_HIGH); - } - - if (!machineBusy) { - setStatusOfParameterOut(0, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_NEUTRAL); - } else if (eAvailableData <= 0) { - setStatusOfParameterOut(0, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_LOW); - } else { - setStatusOfParameterOut(0, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_OK); + for (GT_MetaTileEntity_Hatch_Rack rack : eRacks) { + if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(rack)) { + rack.getBaseMetaTileEntity().setActive(false); + } } } - @Override public void onRemoval() { super.onRemoval(); - for (GT_MetaTileEntity_Hatch_Rack r : eRacks) { - r.getBaseMetaTileEntity().setActive(false); + for (GT_MetaTileEntity_Hatch_Rack rack : eRacks) { + if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(rack)) { + rack.getBaseMetaTileEntity().setActive(false); + } } } @@ -273,8 +257,10 @@ public class GT_MetaTileEntity_EM_computer extends GT_MetaTileEntity_MultiblockB public void stopMachine() { super.stopMachine(); eAvailableData=0; - for (GT_MetaTileEntity_Hatch_Rack r : eRacks) { - r.getBaseMetaTileEntity().setActive(false); + for (GT_MetaTileEntity_Hatch_Rack rack : eRacks) { + if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(rack)) { + rack.getBaseMetaTileEntity().setActive(false); + } } } @@ -369,14 +355,4 @@ public class GT_MetaTileEntity_EM_computer extends GT_MetaTileEntity_MultiblockB } return false; } - - public static void run() { - try { - adderMethodMap.put("addRackToMachineList", GT_MetaTileEntity_EM_computer.class.getMethod("addRackToMachineList", IGregTechTileEntity.class, int.class)); - } catch (NoSuchMethodException e) { - if (DEBUG_MODE) { - e.printStackTrace(); - } - } - } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_crafting.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_crafting.java index c48f1fdbfe..a72740e84f 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_crafting.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_crafting.java @@ -4,6 +4,7 @@ import com.github.technus.tectech.CommonValues; import com.github.technus.tectech.thing.block.QuantumGlassBlock; import com.github.technus.tectech.thing.metaTileEntity.IConstructable; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.IHatchAdder; import com.github.technus.tectech.thing.metaTileEntity.multi.base.render.TT_RenderedTexture; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -45,7 +46,7 @@ public class GT_MetaTileEntity_EM_crafting extends GT_MetaTileEntity_MultiblockB }; private static final Block[] blockType = new Block[]{sBlockCasingsTT, sBlockCasingsTT, sBlockCasingsTT , QuantumGlassBlock.INSTANCE, sBlockCasingsTT, sBlockCasingsTT}; private static final byte[] blockMeta = new byte[]{4, 10, 5, 0, 6, 9}; - private static final String[] addingMethods = new String[]{"addClassicToMachineList", "addElementalToMachineList"}; + private final IHatchAdder[] addingMethods = new IHatchAdder[]{this::addClassicToMachineList, this::addElementalToMachineList}; private static final short[] casingTextures = new short[]{textureOffset, textureOffset + 4}; private static final Block[] blockTypeFallback = new Block[]{sBlockCasingsTT, sBlockCasingsTT}; private static final byte[] blockMetaFallback = new byte[]{0, 4}; 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..258a8719e8 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 @@ -2,7 +2,6 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; import com.github.technus.tectech.CommonValues; import com.github.technus.tectech.Reference; -import com.github.technus.tectech.loader.TecTechConfig; import com.github.technus.tectech.mechanics.dataTransport.InventoryDataPacket; import com.github.technus.tectech.thing.metaTileEntity.IConstructable; import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_InputDataItems; @@ -10,6 +9,7 @@ import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_H import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_Container_MultiMachineEM; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_GUIContainer_MultiMachineEM; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.IHatchAdder; import com.github.technus.tectech.thing.metaTileEntity.multi.base.render.TT_RenderedTexture; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -45,7 +45,7 @@ public class GT_MetaTileEntity_EM_dataBank extends GT_MetaTileEntity_MultiblockB }; private static final Block[] blockType = new Block[]{sBlockCasingsTT,sBlockCasingsTT}; private static final byte[] blockMeta = new byte[]{2,1}; - private static final String[] addingMethods = new String[]{"addClassicToMachineList","addDataBankHatchToMachineList"}; + private final IHatchAdder[] addingMethods = new IHatchAdder[]{this::addClassicToMachineList,this::addDataBankHatchToMachineList}; private static final short[] casingTextures = new short[]{textureOffset,textureOffset+1}; private static final Block[] blockTypeFallback = new Block[]{sBlockCasingsTT,sBlockCasingsTT}; private static final byte[] blockMetaFallback = new byte[]{0,1}; @@ -113,20 +113,10 @@ public class GT_MetaTileEntity_EM_dataBank extends GT_MetaTileEntity_MultiblockB } @Override - protected void parametersLoadDefault_EM() { - for(int i=0;i<10;i++){ - setStatusOfParameterIn(i,0,STATUS_UNUSED); - setStatusOfParameterIn(i,1,STATUS_UNUSED); - setStatusOfParameterOut(i,0,STATUS_UNUSED); - setStatusOfParameterOut(i,1,STATUS_UNUSED); - } - } - - @Override public boolean checkRecipe_EM(ItemStack itemStack) { if (eDataAccessHatches.size() > 0 && eStacksDataOutputs.size() > 0) { - mEUt = -(int) V[7]; - eAmpereFlow = 1 + (eStacksDataOutputs.size() >> 2) + eDataAccessHatches.size(); + mEUt = -(int)V[4]; + eAmpereFlow = 1 + eStacksDataOutputs.size()*eDataAccessHatches.size(); mMaxProgresstime = 20; mEfficiencyIncrease = 10000; return true; @@ -185,14 +175,4 @@ public class GT_MetaTileEntity_EM_dataBank extends GT_MetaTileEntity_MultiblockB } return false; } - - public static void run(){ - try { - adderMethodMap.put("addDataBankHatchToMachineList", GT_MetaTileEntity_EM_dataBank.class.getMethod("addDataBankHatchToMachineList", IGregTechTileEntity.class, int.class)); - } catch (NoSuchMethodException e) { - if (TecTechConfig.DEBUG_MODE) { - e.printStackTrace(); - } - } - } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_decay.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_decay.java index 71a6b70dfb..9a4b8021c1 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_decay.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_decay.java @@ -7,6 +7,10 @@ import com.github.technus.tectech.thing.metaTileEntity.IConstructable; import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_EnergyMulti; import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_InputElemental; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.IHatchAdder; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.Parameters; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.INameFunction; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.IStatusFunction; import com.github.technus.tectech.thing.metaTileEntity.multi.base.render.TT_RenderedTexture; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -28,6 +32,8 @@ 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_OK; +import static com.github.technus.tectech.thing.metaTileEntity.multi.base.LedStatus.STATUS_TOO_LOW; /** * Created by danie_000 on 17.12.2016. @@ -40,6 +46,17 @@ public class GT_MetaTileEntity_EM_decay extends GT_MetaTileEntity_MultiblockBase private static final double MASS_TO_EU_PARTIAL = ConfigUtil.getFloat(MainConfig.get(), "balance/energy/generator/nuclear") * 3_000_000.0 / URANIUM_INGOT_MASS_DIFF; private static final double MASS_TO_EU_INSTANT= MASS_TO_EU_PARTIAL *20; + //region parameters + protected Parameters.Group.ParameterIn ampereFlow; + private static final INameFunction<GT_MetaTileEntity_EM_decay> FLOW_NAME= (base, p)->"Ampere divider"; + private static final IStatusFunction<GT_MetaTileEntity_EM_decay> FLOW_STATUS= (base, p)->{ + if(base.eAmpereFlow<=0){ + return STATUS_TOO_LOW; + } + return STATUS_OK; + }; + //endregion + //region structure private static final String[][] shape = new String[][]{ {"0C0","A ","A . ","A ","0C0",}, @@ -54,7 +71,7 @@ public class GT_MetaTileEntity_EM_decay extends GT_MetaTileEntity_MultiblockBase }; private static final Block[] blockType = new Block[]{sBlockCasingsTT, sBlockCasingsTT, sBlockCasingsTT ,sBlockCasingsTT}; private static final byte[] blockMeta = new byte[]{4, 5, 8, 6}; - private static final String[] addingMethods = new String[]{"addClassicToMachineList", "addElementalToMachineList"}; + private final IHatchAdder[] addingMethods = new IHatchAdder[]{this::addClassicToMachineList, this::addElementalToMachineList}; private static final short[] casingTextures = new short[]{textureOffset, textureOffset + 4}; private static final Block[] blockTypeFallback = new Block[]{sBlockCasingsTT, sBlockCasingsTT}; private static final byte[] blockMetaFallback = new byte[]{0, 4}; @@ -74,6 +91,12 @@ public class GT_MetaTileEntity_EM_decay extends GT_MetaTileEntity_MultiblockBase } @Override + protected void parametersInstantiation_EM() { + Parameters.Group hatch_0=parametrization.getGroup(0, true); + ampereFlow=hatch_0.makeInParameter(0,1,FLOW_NAME,FLOW_STATUS); + } + + @Override public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { return new GT_MetaTileEntity_EM_decay(mName); } @@ -139,13 +162,10 @@ public class GT_MetaTileEntity_EM_decay extends GT_MetaTileEntity_MultiblockBase for(cElementalInstanceStack stack:outputEM[0].values()){ - if(stack.getEnergy()==0 && stack.definition.decayMakesEnergy(1)){ - if(getBaseMetaTileEntity().decreaseStoredEnergyUnits((long)(stack.getEnergySettingCost(1)*MASS_TO_EU_INSTANT),false)){ - stack.setEnergy(1); - }else{ - outputEM[0].remove(stack.definition); - outputEM[1].putReplace(stack); - } + if (stack.getEnergy() == 0 && stack.definition.decayMakesEnergy(1) + && getBaseMetaTileEntity().decreaseStoredEnergyUnits( + (long) (stack.getEnergySettingCost(1) * MASS_TO_EU_INSTANT), false)) { + stack.setEnergy(1); }else if(!stack.definition.decayMakesEnergy(stack.getEnergy())){ outputEM[0].remove(stack.definition); outputEM[1].putReplace(stack); @@ -153,13 +173,15 @@ public class GT_MetaTileEntity_EM_decay extends GT_MetaTileEntity_MultiblockBase //System.out.println(stack.definition.getSymbol()+" "+stack.amount); } - float preMass=outputEM[0].getMass(); outputEM[0].tickContent(1,0,1); double energyDose=((preMass-outputEM[0].getMass())* MASS_TO_EU_PARTIAL); - mEUt=(int)(energyDose/getParameterInInt(0,0)); - eAmpereFlow=getParameterInInt(0,0); - + eAmpereFlow=(long) ampereFlow.get(); + if (eAmpereFlow <= 0) { + mEUt=0; + return false; + } + mEUt=(int)(energyDose/eAmpereFlow); return outputEM[0].hasStacks(); } @@ -191,25 +213,20 @@ public class GT_MetaTileEntity_EM_decay extends GT_MetaTileEntity_MultiblockBase return new String[]{ "Progress:", EnumChatFormatting.GREEN + Integer.toString(mProgresstime / 20) + EnumChatFormatting.RESET + " s / " + - EnumChatFormatting.YELLOW + Integer.toString(mMaxProgresstime / 20) + EnumChatFormatting.RESET + " s", + EnumChatFormatting.YELLOW + mMaxProgresstime / 20 + EnumChatFormatting.RESET + " s", "Energy Hatches:", EnumChatFormatting.GREEN + Long.toString(storedEnergy) + EnumChatFormatting.RESET + " EU / " + - EnumChatFormatting.YELLOW + Long.toString(maxEnergy) + EnumChatFormatting.RESET + " EU", + EnumChatFormatting.YELLOW + maxEnergy + EnumChatFormatting.RESET + " EU", (mEUt <= 0 ? "Probably uses: " : "Probably makes: ") + - EnumChatFormatting.RED + Integer.toString(Math.abs(mEUt)) + EnumChatFormatting.RESET + " EU/t at " + + EnumChatFormatting.RED + Math.abs(mEUt) + EnumChatFormatting.RESET + " EU/t at " + EnumChatFormatting.RED + eAmpereFlow + EnumChatFormatting.RESET + " A", "Tier Rating: " + EnumChatFormatting.YELLOW + VN[getMaxEnergyInputTier_EM()] + EnumChatFormatting.RESET + " / " + EnumChatFormatting.GREEN + VN[getMinEnergyInputTier_EM()] + EnumChatFormatting.RESET + " Amp Rating: " + EnumChatFormatting.GREEN + eMaxAmpereFlow + EnumChatFormatting.RESET + " A", "Problems: " + EnumChatFormatting.RED + (getIdealStatus() - getRepairStatus()) + EnumChatFormatting.RESET + - " Efficiency: " + EnumChatFormatting.YELLOW + Float.toString(mEfficiency / 100.0F) + EnumChatFormatting.RESET + " %", + " Efficiency: " + EnumChatFormatting.YELLOW + mEfficiency / 100.0F + EnumChatFormatting.RESET + " %", "PowerPass: " + EnumChatFormatting.BLUE + ePowerPass + EnumChatFormatting.RESET + " SafeVoid: " + EnumChatFormatting.BLUE + eSafeVoid, "Computation: " + EnumChatFormatting.GREEN + eAvailableData + EnumChatFormatting.RESET + " / " + EnumChatFormatting.YELLOW + eRequiredData + EnumChatFormatting.RESET, }; } - - @Override - public long maxEUStore() { - return super.maxEUStore(); - } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_dequantizer.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_dequantizer.java index 5f102c94ab..d379502540 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_dequantizer.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_dequantizer.java @@ -10,6 +10,7 @@ import com.github.technus.tectech.thing.block.QuantumGlassBlock; import com.github.technus.tectech.thing.metaTileEntity.IConstructable; import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_InputElemental; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.IHatchAdder; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; @@ -46,7 +47,10 @@ public class GT_MetaTileEntity_EM_dequantizer extends GT_MetaTileEntity_Multiblo }; private static final Block[] blockType = new Block[]{sBlockCasingsTT, sBlockCasingsTT, QuantumGlassBlock.INSTANCE}; private static final byte[] blockMeta = new byte[]{0, 4, 0}; - private static final String[] addingMethods = new String[]{"addClassicToMachineList", "addElementalInputToMachineList", "addElementalMufflerToMachineList"}; + private final IHatchAdder[] addingMethods = new IHatchAdder[]{ + this::addClassicToMachineList, + this::addElementalInputToMachineList, + this::addElementalMufflerToMachineList}; private static final short[] casingTextures = new short[]{textureOffset, textureOffset + 4, textureOffset + 4}; private static final Block[] blockTypeFallback = new Block[]{sBlockCasingsTT, sBlockCasingsTT, sBlockCasingsTT}; private static final byte[] blockMetaFallback = new byte[]{0, 4, 4}; diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_infuser.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_infuser.java index c6eb10c94a..d0b5b4ff35 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_infuser.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_infuser.java @@ -8,6 +8,7 @@ import com.github.technus.tectech.thing.metaTileEntity.IConstructable; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_Container_MultiMachineEM; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_GUIContainer_MultiMachineEM; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.IHatchAdder; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; @@ -39,7 +40,7 @@ public class GT_MetaTileEntity_EM_infuser extends GT_MetaTileEntity_MultiblockBa }; private static final Block[] blockType = new Block[]{sBlockCasingsTT, sBlockCasingsTT}; private static final byte[] blockMeta = new byte[]{7, 4}; - private static final String[] addingMethods = new String[]{"addClassicToMachineList"}; + private final IHatchAdder[] addingMethods = new IHatchAdder[]{this::addClassicToMachineList}; private static final short[] casingTextures = new short[]{textureOffset}; private static final Block[] blockTypeFallback = new Block[]{sBlockCasingsTT}; private static final byte[] blockMetaFallback = new byte[]{0}; 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..337afd4f32 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 @@ -5,8 +5,13 @@ import com.github.technus.tectech.thing.metaTileEntity.IConstructable; import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_InputElemental; import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_OutputElemental; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.IHatchAdder; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.Parameters; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.INameFunction; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.IStatusFunction; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.util.GT_Utility; import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; @@ -15,6 +20,8 @@ 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.*; +import static gregtech.api.enums.GT_Values.E; /** * Created by danie_000 on 17.12.2016. @@ -28,9 +35,16 @@ public class GT_MetaTileEntity_EM_junction extends GT_MetaTileEntity_MultiblockB {"!!!", "!0!", "!!!",}, {"!!!", "!!!", "!!!",}, }; - private static final Block[] blockType = new Block[]{sBlockCasingsTT}; - private static final byte[] blockMeta = new byte[]{4}; - private static final String[] addingMethods = new String[]{"addClassicToMachineList", "addElementalToMachineList"}; + private static final String[][] shapeBig = new String[][]{ + {E, "A ", "A . ", "A ",}, + {"A!!!", "!000!", "!010!", "!000!", "A!!!",}, + {"!!!!!", "!000!", "!000!", "!000!", "!!!!!",}, + {"A!!!", "!000!", "!000!", "!000!", "A!!!",}, + {"A!!!", "!!!!!", "!!!!!", "!!!!!", "A!!!",}, + }; + private static final Block[] blockType = new Block[]{sBlockCasingsTT,sBlockCasingsTT}; + private static final byte[] blockMeta = new byte[]{4,5}; + private final IHatchAdder[] addingMethods = new IHatchAdder[]{this::addClassicToMachineList, this::addElementalToMachineList}; private static final short[] casingTextures = new short[]{textureOffset, textureOffset + 4}; private static final Block[] blockTypeFallback = new Block[]{sBlockCasingsTT, sBlockCasingsTT}; private static final byte[] blockMetaFallback = new byte[]{0, 4}; @@ -41,6 +55,36 @@ public class GT_MetaTileEntity_EM_junction extends GT_MetaTileEntity_MultiblockB }; //endregion + //region parameters + private static final INameFunction<GT_MetaTileEntity_EM_junction> ROUTE_NAME= + (base,p)->(p.parameterId()==0?"Source ":"Destination ")+p.hatchId(); + private static final IStatusFunction<GT_MetaTileEntity_EM_junction> SRC_STATUS = + (base,p)-> { + double v = p.get(); + if (Double.isNaN(v)) return STATUS_WRONG; + v=(int)v; + if (v < 0) return STATUS_TOO_LOW; + if (v == 0) return STATUS_NEUTRAL; + if (v >= base.eInputHatches.size()) return STATUS_TOO_HIGH; + return STATUS_OK; + }; + private static final IStatusFunction<GT_MetaTileEntity_EM_junction> DST_STATUS = + (base,p)->{ + if(base.src[p.hatchId()].getStatus(false)== STATUS_OK){ + double v = p.get(); + if (Double.isNaN(v)) return STATUS_WRONG; + v=(int)v; + if (v < 0) return STATUS_TOO_LOW; + if (v == 0) return STATUS_LOW; + if (v >= base.eInputHatches.size()) return STATUS_TOO_HIGH; + return STATUS_OK; + } + return STATUS_NEUTRAL; + }; + protected Parameters.Group.ParameterIn[] src; + protected Parameters.Group.ParameterIn[] dst; + //endregion + public GT_MetaTileEntity_EM_junction(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); } @@ -50,13 +94,30 @@ public class GT_MetaTileEntity_EM_junction extends GT_MetaTileEntity_MultiblockB } @Override + protected void parametersInstantiation_EM() { + src=new Parameters.Group.ParameterIn[10]; + dst=new Parameters.Group.ParameterIn[10]; + for (int i = 0; i < 10; i++) { + Parameters.Group hatch = parametrization.getGroup(i); + src[i] = hatch.makeInParameter(0, i, ROUTE_NAME, SRC_STATUS); + dst[i] = hatch.makeInParameter(1, i, ROUTE_NAME, DST_STATUS); + } + } + + @Override public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { return new GT_MetaTileEntity_EM_junction(mName); } @Override public boolean checkMachine_EM(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { - return structureCheck_EM(shape, blockType, blockMeta, addingMethods, casingTextures, blockTypeFallback, blockMetaFallback, 1, 1, 0); + int meta=iGregTechTileEntity.getMetaIDAtSide(GT_Utility.getOppositeSide(iGregTechTileEntity.getFrontFacing())); + if(meta==4){ + return structureCheck_EM(shape, blockType, blockMeta, addingMethods, casingTextures, blockTypeFallback, blockMetaFallback, 1, 1, 0); + }else if(meta==5){ + return structureCheck_EM(shapeBig, blockType, blockMeta, addingMethods, casingTextures, blockTypeFallback, blockMetaFallback, 2, 2, 0); + } + return false; } @Override @@ -79,38 +140,6 @@ public class GT_MetaTileEntity_EM_junction extends GT_MetaTileEntity_MultiblockB } @Override - public void parametersOutAndStatusesWrite_EM(boolean machineBusy) { - double src, dest; - 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); - } else if (src > eInputHatches.size()) { - setStatusOfParameterIn(i, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_HIGH); - setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.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); - } else { - setStatusOfParameterIn(i, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_OK); - dest = getParameterIn(i, 1); - if (dest < 0) { - setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_LOW); - } else if (dest == 0) { - setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_LOW); - } else if (dest > eOutputHatches.size()) { - setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_HIGH); - } else if (Double.isNaN(dest)) { - setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_WRONG); - } else { - setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_OK); - } - } - } - } - - @Override public boolean checkRecipe_EM(ItemStack itemStack) { for (GT_MetaTileEntity_Hatch_InputElemental in : eInputHatches) { if (in.getContainerHandler().hasStacks()) { @@ -126,18 +155,18 @@ public class GT_MetaTileEntity_EM_junction extends GT_MetaTileEntity_MultiblockB @Override public void outputAfterRecipe_EM() { - double src,dest; + double src,dst; for (int i = 0; i < 10; i++) { - src= getParameterIn(i,0); - dest= getParameterIn(i,1); - if(Double.isNaN(src) || Double.isNaN(dest)) { + src= this.src[i].get(); + dst= this.dst[i].get(); + if(Double.isNaN(src) || Double.isNaN(dst)) { continue; } int inIndex = (int)src - 1; if (inIndex < 0 || inIndex >= eInputHatches.size()) { continue; } - int outIndex = (int)dest - 1; + int outIndex = (int)dst - 1; GT_MetaTileEntity_Hatch_InputElemental in = eInputHatches.get(inIndex); if (outIndex == -1) {//param==0 -> null the content cleanHatchContentEM_EM(in); diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_quantizer.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_quantizer.java index a5a3f451ea..1d3d40666f 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_quantizer.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_quantizer.java @@ -13,6 +13,7 @@ import com.github.technus.tectech.mechanics.elementalMatter.core.transformations import com.github.technus.tectech.thing.block.QuantumGlassBlock; import com.github.technus.tectech.thing.metaTileEntity.IConstructable; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.IHatchAdder; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.GregTech_API; @@ -52,7 +53,10 @@ public class GT_MetaTileEntity_EM_quantizer extends GT_MetaTileEntity_Multiblock }; private static final Block[] blockType = new Block[]{sBlockCasingsTT, sBlockCasingsTT, QuantumGlassBlock.INSTANCE}; private static final byte[] blockMeta = new byte[]{4, 0, 0}; - private static final String[] addingMethods = new String[]{"addClassicToMachineList", "addElementalOutputToMachineList", "addElementalMufflerToMachineList"}; + private final IHatchAdder[] addingMethods = new IHatchAdder[]{ + this::addClassicToMachineList, + this::addElementalOutputToMachineList, + this::addElementalMufflerToMachineList}; private static final short[] casingTextures = new short[]{textureOffset, textureOffset + 4, textureOffset + 4}; private static final Block[] blockTypeFallback = new Block[]{sBlockCasingsTT, sBlockCasingsTT, sBlockCasingsTT}; private static final byte[] blockMetaFallback = new byte[]{0, 4, 4}; @@ -113,7 +117,7 @@ public class GT_MetaTileEntity_EM_quantizer extends GT_MetaTileEntity_Multiblock public boolean checkRecipe_EM(ItemStack itemStack) {//TODO implement instance quantization if (GregTech_API.sPostloadFinished) { ArrayList<ItemStack> storedInputs = getStoredInputs(); - ItemStack[] inI = storedInputs.toArray(new ItemStack[storedInputs.size()]); + ItemStack[] inI = storedInputs.toArray(new ItemStack[0]); if (inI.length > 0) { for (ItemStack is : inI) { //ITEM STACK quantization @@ -152,7 +156,7 @@ public class GT_MetaTileEntity_EM_quantizer extends GT_MetaTileEntity_Multiblock } } ArrayList<FluidStack> storedFluids = getStoredFluids(); - FluidStack[] inF = storedFluids.toArray(new FluidStack[storedFluids.size()]); + FluidStack[] inF = storedFluids.toArray(new FluidStack[0]); if (inF.length > 0) { for (FluidStack fs : inF) { aFluidQuantizationInfo aFQI = bTransformationInfo.fluidQuantization.get(fs.getFluid().getID()); diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_research.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_research.java index 377291f59a..11be32f9a5 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_research.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_research.java @@ -1,12 +1,12 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; import com.github.technus.tectech.CommonValues; -import com.github.technus.tectech.loader.TecTechConfig; import com.github.technus.tectech.recipe.TT_recipe; import com.github.technus.tectech.thing.metaTileEntity.IConstructable; import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_EnergyMulti; import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_Holder; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.IHatchAdder; import com.github.technus.tectech.thing.metaTileEntity.multi.base.render.TT_RenderedTexture; import cpw.mods.fml.common.registry.GameRegistry; import gregtech.api.enums.ItemList; @@ -66,7 +66,7 @@ public class GT_MetaTileEntity_EM_research extends GT_MetaTileEntity_MultiblockB }; private static final Block[] blockType = new Block[]{sBlockCasingsTT, sBlockCasingsTT, sBlockCasingsTT}; private static final byte[] blockMeta = new byte[]{1, 3, 2}; - private static final String[] addingMethods = new String[]{"addClassicToMachineList", "addHolderToMachineList"}; + private final IHatchAdder[] addingMethods = new IHatchAdder[]{this::addClassicToMachineList, this::addHolderToMachineList}; private static final short[] casingTextures = new short[]{textureOffset + 1, textureOffset + 3}; private static final Block[] blockTypeFallback = new Block[]{sBlockCasingsTT, Blocks.air}; private static final byte[] blockMetaFallback = new byte[]{1, 0}; @@ -490,16 +490,6 @@ public class GT_MetaTileEntity_EM_research extends GT_MetaTileEntity_MultiblockB return false; } - public static void run() { - try { - adderMethodMap.put("addHolderToMachineList", GT_MetaTileEntity_EM_research.class.getMethod("addHolderToMachineList", IGregTechTileEntity.class, int.class)); - } catch (NoSuchMethodException e) { - if (TecTechConfig.DEBUG_MODE) { - e.printStackTrace(); - } - } - } - @Override public int getInventoryStackLimit() { return 1; @@ -525,20 +515,20 @@ public class GT_MetaTileEntity_EM_research extends GT_MetaTileEntity_MultiblockB return new String[]{ "Energy Hatches:", EnumChatFormatting.GREEN + Long.toString(storedEnergy) + EnumChatFormatting.RESET + " EU / " + - EnumChatFormatting.YELLOW + Long.toString(maxEnergy) + EnumChatFormatting.RESET + " EU", + EnumChatFormatting.YELLOW + maxEnergy + EnumChatFormatting.RESET + " EU", (mEUt <= 0 ? "Probably uses: " : "Probably makes: ") + - EnumChatFormatting.RED + Integer.toString(Math.abs(mEUt)) + EnumChatFormatting.RESET + " EU/t at " + + EnumChatFormatting.RED + Math.abs(mEUt) + EnumChatFormatting.RESET + " EU/t at " + EnumChatFormatting.RED + eAmpereFlow + EnumChatFormatting.RESET + " A", "Tier Rating: " + EnumChatFormatting.YELLOW + VN[getMaxEnergyInputTier_EM()] + EnumChatFormatting.RESET + " / " + EnumChatFormatting.GREEN + VN[getMinEnergyInputTier_EM()] + EnumChatFormatting.RESET + " Amp Rating: " + EnumChatFormatting.GREEN + eMaxAmpereFlow + EnumChatFormatting.RESET + " A", "Problems: " + EnumChatFormatting.RED + (getIdealStatus() - getRepairStatus()) + EnumChatFormatting.RESET + - " Efficiency: " + EnumChatFormatting.YELLOW + Float.toString(mEfficiency / 100.0F) + EnumChatFormatting.RESET + " %", + " Efficiency: " + EnumChatFormatting.YELLOW + mEfficiency / 100.0F + EnumChatFormatting.RESET + " %", "PowerPass: " + EnumChatFormatting.BLUE + ePowerPass + EnumChatFormatting.RESET + " SafeVoid: " + EnumChatFormatting.BLUE + eSafeVoid, "Computation Available: " + EnumChatFormatting.GREEN + eAvailableData + EnumChatFormatting.RESET, "Computation Remaining:", EnumChatFormatting.GREEN + Long.toString(computationRemaining / 20L) + EnumChatFormatting.RESET + " / " + - EnumChatFormatting.YELLOW + Long.toString(computationRequired / 20L) + EnumChatFormatting.YELLOW + computationRequired / 20L }; } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_scanner.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_scanner.java index b2711530ed..96132a889e 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_scanner.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_scanner.java @@ -14,6 +14,11 @@ import com.github.technus.tectech.thing.item.ElementalDefinitionScanStorage_EM; import com.github.technus.tectech.thing.metaTileEntity.IConstructable; import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_EnergyMulti; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.IHatchAdder; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.LedStatus; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.Parameters; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.INameFunction; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.IStatusFunction; import gregtech.api.enums.ItemList; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -57,6 +62,24 @@ public class GT_MetaTileEntity_EM_scanner extends GT_MetaTileEntity_MultiblockBa private long totalComputationRemaining, totalComputationRequired; private int[] scanComplexity; + //region parameters + private static final INameFunction<GT_MetaTileEntity_EM_scanner> CONFIG_NAME= + (base,p)->"Config at Depth: "+(p.hatchId()*2+p.parameterId()); + private static final IStatusFunction<GT_MetaTileEntity_EM_scanner> CONFIG_STATUS= + (base,p)->{ + double v=p.get(); + if(Double.isNaN(v)){ + return LedStatus.STATUS_WRONG; + } + v=(int)v; + if(v==0) return LedStatus.STATUS_NEUTRAL; + if(v>=SCAN_GET_CLASS_TYPE) return LedStatus.STATUS_TOO_HIGH; + if(v<0) return LedStatus.STATUS_TOO_LOW; + return LedStatus.STATUS_OK; + }; + protected Parameters.Group.ParameterIn[] scanConfiguration; + //endregion + //region structure private static final String[][] shape = new String[][]{ {" ", " 222 ", " 2.2 ", " 222 ", " ",}, @@ -70,11 +93,11 @@ public class GT_MetaTileEntity_EM_scanner extends GT_MetaTileEntity_MultiblockBa }; private static final Block[] blockType = new Block[]{sBlockCasingsTT, QuantumGlassBlock.INSTANCE, sBlockCasingsTT}; private static final byte[] blockMeta = new byte[]{4, 0, 0}; - private static final String[] addingMethods = new String[]{ - "addClassicToMachineList", - "addElementalInputToMachineList", - "addElementalOutputToMachineList", - "addElementalMufflerToMachineList"}; + private final IHatchAdder[] addingMethods = new IHatchAdder[]{ + this::addClassicToMachineList, + this::addElementalInputToMachineList, + this::addElementalOutputToMachineList, + this::addElementalMufflerToMachineList}; private static final short[] casingTextures = new short[]{textureOffset, textureOffset + 4, textureOffset + 4, textureOffset + 4}; private static final Block[] blockTypeFallback = new Block[]{sBlockCasingsTT, sBlockCasingsTT, sBlockCasingsTT, sBlockCasingsTT}; private static final byte[] blockMetaFallback = new byte[]{0, 4, 4, 4}; @@ -98,6 +121,16 @@ public class GT_MetaTileEntity_EM_scanner extends GT_MetaTileEntity_MultiblockBa } @Override + protected void parametersInstantiation_EM() { + scanConfiguration=new Parameters.Group.ParameterIn[20]; + for (int i = 0; i < 10; i++) { + Parameters.Group hatch = parametrization.getGroup(i); + scanConfiguration[i*2] = hatch.makeInParameter(0, 0, CONFIG_NAME, CONFIG_STATUS); + scanConfiguration[i*2+1] = hatch.makeInParameter(1, 0, CONFIG_NAME, CONFIG_STATUS); + } + } + + @Override public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { return new GT_MetaTileEntity_EM_scanner(mName); } @@ -248,7 +281,7 @@ public class GT_MetaTileEntity_EM_scanner extends GT_MetaTileEntity_MultiblockBa cleanStackEM_EM(stackEM); researchEM.remove(stackEM.definition); } - if(eRecipe!=null && scannerRecipe!=null){//make sure it werks + if(eRecipe!=null && scannerRecipe!=null){//todo make sure it werks totalComputationRequired = totalComputationRemaining = scannerRecipe.mDuration * 20L; mMaxProgresstime = 20;//const mEfficiencyIncrease = 10000; @@ -272,9 +305,8 @@ public class GT_MetaTileEntity_EM_scanner extends GT_MetaTileEntity_MultiblockBa //get depth scan complexity array { int[] scanComplexityTemp = new int[20]; - for (int i = 0; i < 10; i++) { - scanComplexityTemp[i] = getParameterInInt(i, 0); - scanComplexityTemp[i + 10] = getParameterInInt(i, 1); + for (int i = 0; i < 20; i++) { + scanComplexityTemp[i]=(int)scanConfiguration[i].get(); } int maxDepth = 0; for (int i = 0; i < 20; i++) { @@ -418,20 +450,20 @@ public class GT_MetaTileEntity_EM_scanner extends GT_MetaTileEntity_MultiblockBa return new String[]{ "Energy Hatches:", EnumChatFormatting.GREEN + Long.toString(storedEnergy) + EnumChatFormatting.RESET + " EU / " + - EnumChatFormatting.YELLOW + Long.toString(maxEnergy) + EnumChatFormatting.RESET + " EU", + EnumChatFormatting.YELLOW + maxEnergy + EnumChatFormatting.RESET + " EU", (mEUt <= 0 ? "Probably uses: " : "Probably makes: ") + - EnumChatFormatting.RED + Integer.toString(Math.abs(mEUt)) + EnumChatFormatting.RESET + " EU/t at " + + EnumChatFormatting.RED + Math.abs(mEUt) + EnumChatFormatting.RESET + " EU/t at " + EnumChatFormatting.RED + eAmpereFlow + EnumChatFormatting.RESET + " A", "Tier Rating: " + EnumChatFormatting.YELLOW + VN[getMaxEnergyInputTier_EM()] + EnumChatFormatting.RESET + " / " + EnumChatFormatting.GREEN + VN[getMinEnergyInputTier_EM()] + EnumChatFormatting.RESET + " Amp Rating: " + EnumChatFormatting.GREEN + eMaxAmpereFlow + EnumChatFormatting.RESET + " A", "Problems: " + EnumChatFormatting.RED + (getIdealStatus() - getRepairStatus()) + EnumChatFormatting.RESET + - " Efficiency: " + EnumChatFormatting.YELLOW + Float.toString(mEfficiency / 100.0F) + EnumChatFormatting.RESET + " %", + " Efficiency: " + EnumChatFormatting.YELLOW + mEfficiency / 100.0F + EnumChatFormatting.RESET + " %", "PowerPass: " + EnumChatFormatting.BLUE + ePowerPass + EnumChatFormatting.RESET + " SafeVoid: " + EnumChatFormatting.BLUE + eSafeVoid, "Computation Available: " + EnumChatFormatting.GREEN + eAvailableData +EnumChatFormatting.RESET+" / "+EnumChatFormatting.YELLOW + eRequiredData + EnumChatFormatting.RESET, "Computation Remaining:", EnumChatFormatting.GREEN + Long.toString(totalComputationRemaining / 20L) + EnumChatFormatting.RESET + " / " + - EnumChatFormatting.YELLOW + Long.toString(totalComputationRequired / 20L) + EnumChatFormatting.YELLOW + totalComputationRequired / 20L }; } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_stabilizer.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_stabilizer.java index ce16d939cd..30794ca47e 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_stabilizer.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_stabilizer.java @@ -4,6 +4,7 @@ import com.github.technus.tectech.CommonValues; import com.github.technus.tectech.thing.block.QuantumGlassBlock; import com.github.technus.tectech.thing.metaTileEntity.IConstructable; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.IHatchAdder; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import net.minecraft.block.Block; @@ -28,7 +29,7 @@ public class GT_MetaTileEntity_EM_stabilizer extends GT_MetaTileEntity_Multibloc }; private static final Block[] blockType = new Block[]{sBlockCasingsTT, QuantumGlassBlock.INSTANCE, sBlockCasingsTT ,sBlockCasingsTT, sBlockCasingsTT}; private static final byte[] blockMeta = new byte[]{4, 0, 5, 6, 9}; - private static final String[] addingMethods = new String[]{"addClassicToMachineList", "addElementalToMachineList"}; + private final IHatchAdder[] addingMethods = new IHatchAdder[]{this::addClassicToMachineList, this::addElementalToMachineList}; private static final short[] casingTextures = new short[]{textureOffset, textureOffset + 4}; private static final Block[] blockTypeFallback = new Block[]{sBlockCasingsTT, sBlockCasingsTT}; private static final byte[] blockMetaFallback = new byte[]{0, 4}; 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..1c5d1bccdd 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 @@ -8,6 +8,10 @@ import com.github.technus.tectech.thing.metaTileEntity.IConstructable; import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_InputData; import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_OutputData; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.IHatchAdder; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.Parameters; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.INameFunction; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.IStatusFunction; import com.github.technus.tectech.thing.metaTileEntity.multi.base.render.TT_RenderedTexture; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -25,6 +29,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. @@ -38,7 +43,7 @@ public class GT_MetaTileEntity_EM_switch extends GT_MetaTileEntity_MultiblockBas }; private static final Block[] blockType = new Block[]{sBlockCasingsTT}; private static final byte[] blockMeta = new byte[]{3}; - private static final String[] addingMethods = new String[]{"addClassicToMachineList"}; + private final IHatchAdder[] addingMethods = new IHatchAdder[]{this::addClassicToMachineList}; private static final short[] casingTextures = new short[]{textureOffset+1}; private static final Block[] blockTypeFallback = new Block[]{sBlockCasingsTT}; private static final byte[] blockMetaFallback = new byte[]{1}; @@ -48,6 +53,34 @@ public class GT_MetaTileEntity_EM_switch extends GT_MetaTileEntity_MultiblockBas }; //endregion + //region parameters + private static final INameFunction<GT_MetaTileEntity_EM_switch> ROUTE_NAME= + (base,p)->(p.parameterId()==0?"Destination ":"Weight ")+p.hatchId(); + private static final IStatusFunction<GT_MetaTileEntity_EM_switch> WEI_STATUS = + (base,p)-> { + double v=p.get(); + if (Double.isNaN(v)) return STATUS_WRONG; + if(v<0) return STATUS_TOO_LOW; + if(v==0) return STATUS_LOW; + if(Double.isInfinite(v)) return STATUS_HIGH; + return STATUS_OK; + }; + private static final IStatusFunction<GT_MetaTileEntity_EM_switch> DST_STATUS = + (base,p)->{ + if(base.weight[p.hatchId()].getStatus(false).isOk) { + double v = p.get(); + if (Double.isNaN(v)) return STATUS_WRONG; + v = (int) v; + if (v <= 0) return STATUS_TOO_LOW; + if (v >= base.eOutputHatches.size()) return STATUS_TOO_HIGH; + return STATUS_OK; + } + return STATUS_NEUTRAL; + }; + protected Parameters.Group.ParameterIn[] dst; + protected Parameters.Group.ParameterIn[] weight; + //endregion + public GT_MetaTileEntity_EM_switch(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); } @@ -56,6 +89,17 @@ public class GT_MetaTileEntity_EM_switch extends GT_MetaTileEntity_MultiblockBas super(aName); } + @Override + protected void parametersInstantiation_EM() { + dst=new Parameters.Group.ParameterIn[10]; + weight =new Parameters.Group.ParameterIn[10]; + for (int i = 0; i < 10; i++) { + Parameters.Group hatch = parametrization.getGroup(i); + dst[i] = hatch.makeInParameter(0, i, ROUTE_NAME, DST_STATUS); + weight[i] = hatch.makeInParameter(1,0, ROUTE_NAME, WEI_STATUS); + } + } + public final static ResourceLocation activitySound=new ResourceLocation(Reference.MODID+":fx_hi_freq"); @Override @@ -116,12 +160,10 @@ public class GT_MetaTileEntity_EM_switch extends GT_MetaTileEntity_MultiblockBas public void outputAfterRecipe_EM() { if (!eOutputData.isEmpty()) { double total = 0; - double dest; double weight; for (int i = 0; i < 10; i++) {//each param pair - dest= getParameterIn(i,1); - weight= getParameterIn(i,0); - if (weight > 0 && dest >= 0) { + weight= this.weight[i].get(); + if (weight > 0 && dst[i].get() >= 0) { total += weight;//Total weighted div } } @@ -143,9 +185,10 @@ public class GT_MetaTileEntity_EM_switch extends GT_MetaTileEntity_MultiblockBas long remaining = pack.getContent(); + double dest; for (int i = 0; i < 10; i++) { - dest= getParameterIn(i,1); - weight= getParameterIn(i,0); + dest= dst[i].get(); + weight= this.weight[i].get(); if (weight > 0 && dest >= 0) { int outIndex = (int)dest - 1; if (outIndex < 0 || outIndex >= eOutputData.size()) { @@ -177,35 +220,6 @@ public class GT_MetaTileEntity_EM_switch extends GT_MetaTileEntity_MultiblockBas } @Override - public void parametersOutAndStatusesWrite_EM(boolean machineBusy) { - double weight, dest; - 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); - } else if (Double.isNaN(weight)) { - setStatusOfParameterIn(i, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_WRONG); - setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_NEUTRAL); - } else { - setStatusOfParameterIn(i, 0, weight==0?STATUS_LOW:GT_MetaTileEntity_MultiblockBase_EM.STATUS_OK); - dest = getParameterIn(i, 1); - if (dest < 0) { - setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_LOW); - } else if (dest == 0) { - setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_LOW); - } else if (dest > eOutputData.size()) { - setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_HIGH); - } else if (Double.isNaN(dest)) { - setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_WRONG); - } else { - setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_OK); - } - } - } - } - - @Override public String[] getDescription() { return new String[]{ CommonValues.TEC_MARK_EM, diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_transformer.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_transformer.java index 4584e86122..e384a8d7e2 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_transformer.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_transformer.java @@ -6,6 +6,7 @@ import com.github.technus.tectech.thing.metaTileEntity.IConstructable; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_Container_MultiMachineEM; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_GUIContainer_MultiMachineEM; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.IHatchAdder; import com.github.technus.tectech.thing.metaTileEntity.multi.base.render.TT_RenderedTexture; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -37,7 +38,7 @@ public class GT_MetaTileEntity_EM_transformer extends GT_MetaTileEntity_Multiblo }; private static final Block[] blockType = new Block[]{sBlockCasings1}; private static final byte[] blockMeta = new byte[]{15}; - private static final String[] addingMethods = new String[]{"addEnergyIOToMachineList"}; + private final IHatchAdder[] addingMethods = new IHatchAdder[]{this::addEnergyIOToMachineList}; private static final short[] casingTextures = new short[]{textureOffset}; private static final Block[] blockTypeFallback = new Block[]{sBlockCasingsTT}; private static final byte[] blockMetaFallback = new byte[]{0}; diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_wormhole.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_wormhole.java index 5e60f59807..7f69f459f9 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_wormhole.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_wormhole.java @@ -4,6 +4,7 @@ import com.github.technus.tectech.CommonValues; import com.github.technus.tectech.thing.block.QuantumGlassBlock; import com.github.technus.tectech.thing.metaTileEntity.IConstructable; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.IHatchAdder; import com.github.technus.tectech.thing.metaTileEntity.multi.base.render.TT_RenderedTexture; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -45,7 +46,7 @@ public class GT_MetaTileEntity_EM_wormhole extends GT_MetaTileEntity_MultiblockB }; private static final Block[] blockType = new Block[]{sBlockCasingsTT, sBlockCasingsTT, QuantumGlassBlock.INSTANCE ,sBlockCasingsTT, sBlockCasingsTT}; private static final byte[] blockMeta = new byte[]{12, 10, 0, 5, 11}; - private static final String[] addingMethods = new String[]{"addClassicToMachineList", "addElementalToMachineList"}; + private final IHatchAdder[] addingMethods = new IHatchAdder[]{this::addClassicToMachineList, this::addElementalToMachineList}; private static final short[] casingTextures = new short[]{textureOffset, textureOffset + 4}; private static final Block[] blockTypeFallback = new Block[]{sBlockCasingsTT, sBlockCasingsTT}; private static final byte[] blockMetaFallback = new byte[]{0, 4}; 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..520dbf94fa 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 @@ -3,9 +3,7 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; import com.github.technus.tectech.CommonValues; import com.github.technus.tectech.Reference; import com.github.technus.tectech.thing.metaTileEntity.IConstructable; -import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_Container_MultiMachineEM; -import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_GUIContainer_MultiMachineEM; -import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.*; import com.github.technus.tectech.thing.metaTileEntity.multi.base.render.TT_RenderedTexture; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; @@ -19,7 +17,6 @@ import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.EnumChatFormatting; @@ -28,14 +25,13 @@ 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; /** * Created by danie_000 on 17.12.2016. */ public class GT_MetaTileEntity_TM_microwave extends GT_MetaTileEntity_MultiblockBase_EM implements IConstructable { - public static final int POWER_SETTING_DEFAULT=1000, TIMER_SETTING_DEFAULT=360; - private int powerSetting,timerSetting,timerValue; private boolean hasBeenPausedThisCycle=false; //region Structure @@ -50,7 +46,7 @@ public class GT_MetaTileEntity_TM_microwave extends GT_MetaTileEntity_Multiblock private static final Block[] blockType = new Block[]{sBlockCasings4}; private static final byte[] blockMeta = new byte[]{1}; - private static final String[] addingMethods = new String[]{"addClassicToMachineList"}; + private final IHatchAdder[] addingMethods = new IHatchAdder[]{this::addClassicToMachineList}; private static final short[] casingTextures = new short[]{49}; private static final Block[] blockTypeFallback = new Block[]{sBlockCasings4}; private static final byte[] blockMetaFallback = new byte[]{1}; @@ -61,6 +57,25 @@ public class GT_MetaTileEntity_TM_microwave extends GT_MetaTileEntity_Multiblock }; //endregion + //region parameters + protected Parameters.Group.ParameterIn powerSetting,timerSetting; + protected Parameters.Group.ParameterOut timerValue,remainingTime; + private static final INameFunction<GT_MetaTileEntity_TM_microwave> POWER_NAME = (base, p)-> "Power setting"; + private static final INameFunction<GT_MetaTileEntity_TM_microwave> TIMER_SETTING_NAME = (base, p)-> "Timer setting"; + private static final INameFunction<GT_MetaTileEntity_TM_microwave> TIMER_REMAINING_NAME = (base, p)-> "Timer remaining"; + private static final INameFunction<GT_MetaTileEntity_TM_microwave> TIMER_VALUE_NAME = (base, p)-> "Timer value"; + private static final IStatusFunction<GT_MetaTileEntity_TM_microwave> POWER_STATUS= + (base,p)-> LedStatus.fromLimitsInclusiveOuterBoundary(p.get(),300,1000,1000,Double.POSITIVE_INFINITY); + private static final IStatusFunction<GT_MetaTileEntity_TM_microwave> TIMER_STATUS=(base, p)->{ + double value=p.get(); + if(Double.isNaN(value)) return STATUS_WRONG; + value=(int)value; + if(value<=0) return STATUS_TOO_LOW; + if(value>3000) return STATUS_TOO_HIGH; + return STATUS_OK; + }; + //endregion + public GT_MetaTileEntity_TM_microwave(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); } @@ -70,6 +85,15 @@ public class GT_MetaTileEntity_TM_microwave extends GT_MetaTileEntity_Multiblock } @Override + protected void parametersInstantiation_EM() { + Parameters.Group hatch_0=parametrization.getGroup(0, true); + powerSetting=hatch_0.makeInParameter(0,1000, POWER_NAME,POWER_STATUS); + timerSetting=hatch_0.makeInParameter(1,360, TIMER_SETTING_NAME,TIMER_STATUS); + timerValue=hatch_0.makeOutParameter(0,0,TIMER_VALUE_NAME,TIMER_STATUS); + remainingTime=hatch_0.makeOutParameter(1,360,TIMER_REMAINING_NAME,TIMER_STATUS); + } + + @Override public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { return new GT_MetaTileEntity_TM_microwave(mName); } @@ -122,13 +146,14 @@ public class GT_MetaTileEntity_TM_microwave extends GT_MetaTileEntity_Multiblock @Override public boolean checkRecipe_EM(ItemStack itemStack) { hasBeenPausedThisCycle =false; - if(powerSetting<300 || timerSetting<=0 || timerSetting>3000) { + if((int)powerSetting.get()<300 || timerSetting.get()<=0 || timerSetting.get()>3000) { return false; } - if (timerValue <= 0) { - timerValue=timerSetting; + if (remainingTime.get() <= 0) { + remainingTime.set(timerSetting.get()); + timerValue.set(0); } - mEUt = -(powerSetting >> 1); + mEUt = -((int)powerSetting.get() >> 1); eAmpereFlow = 1; mMaxProgresstime = 20; mEfficiencyIncrease = 10000; @@ -140,7 +165,8 @@ public class GT_MetaTileEntity_TM_microwave extends GT_MetaTileEntity_Multiblock if(hasBeenPausedThisCycle) { return;//skip timer and actions if paused } - timerValue--; + timerValue.set(timerValue.get()+1); + remainingTime.set(timerSetting.get()-timerValue.get()); IGregTechTileEntity mte=getBaseMetaTileEntity(); double[] xyzOffsets= getTranslatedOffsets(0,-1,2); double xPos=mte.getXCoord()+0.5f+xyzOffsets[0]; @@ -152,12 +178,12 @@ public class GT_MetaTileEntity_TM_microwave extends GT_MetaTileEntity_Multiblock for(int i=0;i<3;i++){//gets ABS from translated to get expansion values if(xyzExpansion[i]<0)xyzExpansion[i]=-xyzExpansion[i]; } - + int power=(int)powerSetting.get(); int damagingFactor = - Math.min(powerSetting >> 6,8)+ - Math.min(powerSetting >> 8,24)+ - Math.min(powerSetting >> 12,48)+ - (powerSetting >> 18); + Math.min(power >> 6,8)+ + Math.min(power >> 8,24)+ + Math.min(power >> 12,48)+ + (power >> 18); ArrayList<ItemStack> itemsToOutput=new ArrayList<>(); HashSet<Entity> tickedStuff=new HashSet<>(); @@ -193,60 +219,15 @@ public class GT_MetaTileEntity_TM_microwave extends GT_MetaTileEntity_Multiblock damagingFactor>>=1; } while(damagingFactor>0); - mOutputItems= itemsToOutput.toArray(new ItemStack[itemsToOutput.size()]); + mOutputItems= itemsToOutput.toArray(new ItemStack[0]); - if(timerValue<=0) { + if(remainingTime.get() <=0) { mte.getWorld().playSoundEffect(xPos,yPos,zPos, Reference.MODID+":microwave_ding", 1, 1); stopMachine(); } } @Override - protected void parametersLoadDefault_EM() { - powerSetting = POWER_SETTING_DEFAULT; - timerSetting = TIMER_SETTING_DEFAULT; - setParameterPairIn_ClearOut(0,false, POWER_SETTING_DEFAULT, TIMER_SETTING_DEFAULT); - } - - @Override - protected void parametersInRead_EM() { - powerSetting = (int) getParameterIn(0, 0); - timerSetting = (int) getParameterIn(0, 1); - } - - @Override - public void parametersOutAndStatusesWrite_EM(boolean machineBusy) { - double powerParameter = getParameterIn(0, 0); - if (powerParameter < 300) { - setStatusOfParameterIn(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_LOW); - } else if (powerParameter < 1000) { - setStatusOfParameterIn(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_LOW); - } else if (powerParameter == 1000) { - setStatusOfParameterIn(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_OK); - } else if (powerParameter == Double.POSITIVE_INFINITY) { - setStatusOfParameterIn(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_HIGH); - } else if (Double.isNaN(powerParameter)) { - setStatusOfParameterIn(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_WRONG); - } else { - setStatusOfParameterOut(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_HIGH); - } - - double timerParameter = getParameterIn(0, 1); - if (timerParameter <= 1) { - setStatusOfParameterIn(0, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_LOW); - } else if (timerParameter <= 3000) { - setStatusOfParameterIn(0, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_OK); - } else if (Double.isNaN(timerParameter)) { - setStatusOfParameterIn(0, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_WRONG); - } else { - setStatusOfParameterIn(0, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_HIGH); - } - - setParameterOut(0, 0, timerValue); - setParameterOut(0, 1, timerSetting - timerValue); - } - - @Override public boolean onRunningTick(ItemStack aStack) { if(eSafeVoid) { hasBeenPausedThisCycle = true; @@ -257,19 +238,8 @@ public class GT_MetaTileEntity_TM_microwave extends GT_MetaTileEntity_Multiblock @Override public void stopMachine() { super.stopMachine(); - timerValue=0; - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - aNBT.setInteger("eTimerVal", timerValue); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - timerValue = aNBT.getInteger("eTimerVal"); + remainingTime.set(timerSetting.get()); + timerValue.set(0); } @Override 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 82722e76f9..bbef798982 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 @@ -6,6 +6,7 @@ import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_H import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_DynamoMulti; import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_EnergyMulti; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.IHatchAdder; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.Textures; @@ -23,7 +24,6 @@ import java.util.ArrayList; import static com.github.technus.tectech.CommonValues.V; import static com.github.technus.tectech.Util.StructureBuilder; -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.*; import static gregtech.api.enums.GT_Values.E; @@ -88,7 +88,7 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock private static final byte[] blockMetaT1 = new byte[]{15, 1, 13, 0}; private static final byte[] blockMetaT2 = new byte[]{15, 2, 13, 0}; private static final byte[][] blockMetas = new byte[][]{blockMetaT0,blockMetaT1,blockMetaT2}; - private static final String[] addingMethods = new String[]{"addCapacitorToMachineList", "addFrameToMachineList"}; + private final IHatchAdder[] addingMethods = new IHatchAdder[]{this::addCapacitorToMachineList, this::addFrameToMachineList}; private static final short[] casingTextures = new short[]{29, 0}; private static final Block[] blockTypeFallback = new Block[]{sBlockCasings2, null}; private static final byte[] blockMetaFallback = new byte[]{13, 0}; @@ -288,7 +288,7 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock float yPos = mte.getYCoord() + 0.5f; float zPos = mte.getZCoord() + 0.5f; long reqSum = 0; - for (GT_MetaTileEntity_TM_teslaCoil Rx : eTeslaList.toArray(new GT_MetaTileEntity_TM_teslaCoil[eTeslaList.size()])) { + for (GT_MetaTileEntity_TM_teslaCoil Rx : eTeslaList.toArray(new GT_MetaTileEntity_TM_teslaCoil[0])) { try { reqSum += Rx.maxEUStore() - Rx.getEUVar(); } catch (Exception e) { @@ -348,15 +348,4 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock } return false; } - - public static void run() { - try { - adderMethodMap.put("addFrameToMachineList", GT_MetaTileEntity_TM_teslaCoil.class.getMethod("addFrameToMachineList", IGregTechTileEntity.class, int.class)); - adderMethodMap.put("addCapacitorToMachineList", GT_MetaTileEntity_TM_teslaCoil.class.getMethod("addCapacitorToMachineList", IGregTechTileEntity.class, int.class)); - } catch (NoSuchMethodException e) { - if (DEBUG_MODE) { - e.printStackTrace(); - } - } - } } 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..dd2eb0a7be 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 @@ -1,6 +1,7 @@ package com.github.technus.tectech.thing.metaTileEntity.multi.base; import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.Util; import gregtech.api.gui.GT_ContainerMetaTile_Machine; import gregtech.api.gui.GT_Slot_Holo; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -11,8 +12,10 @@ 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 = LedStatus.makeArray(20,LedStatus.STATUS_UNDEFINED); + public LedStatus[] eParamsOutStatus = LedStatus.makeArray(20,LedStatus.STATUS_UNDEFINED); + public double[] eParamsIn = new double[20];//number I from parametrizers + public double[] eParamsOut = new double[20];//number O to parametrizers public byte eCertainMode = 5, eCertainStatus = 127; public boolean ePowerPass = false, eSafeVoid = false, allowedToWork = false; public final boolean ePowerPassButton, eSafeVoidButton, allowedToWorkButton; @@ -106,8 +109,10 @@ public class GT_Container_MultiMachineEM extends GT_ContainerMetaTile_Machine { if (mTileEntity.isClientSide() || mTileEntity.getMetaTileEntity() == null || eParamsInStatus == null) { return; } - eParamsInStatus = ((GT_MetaTileEntity_MultiblockBase_EM) mTileEntity.getMetaTileEntity()).eParamsInStatus; - eParamsOutStatus = ((GT_MetaTileEntity_MultiblockBase_EM) mTileEntity.getMetaTileEntity()).eParamsOutStatus; + eParamsInStatus = ((GT_MetaTileEntity_MultiblockBase_EM) mTileEntity.getMetaTileEntity()).parametrization.eParamsInStatus; + eParamsOutStatus = ((GT_MetaTileEntity_MultiblockBase_EM) mTileEntity.getMetaTileEntity()).parametrization.eParamsOutStatus; + eParamsIn= ((GT_MetaTileEntity_MultiblockBase_EM) mTileEntity.getMetaTileEntity()).parametrization.iParamsIn; + eParamsOut= ((GT_MetaTileEntity_MultiblockBase_EM) mTileEntity.getMetaTileEntity()).parametrization.iParamsOut; eCertainMode = ((GT_MetaTileEntity_MultiblockBase_EM) mTileEntity.getMetaTileEntity()).eCertainMode; eCertainStatus = ((GT_MetaTileEntity_MultiblockBase_EM) mTileEntity.getMetaTileEntity()).eCertainStatus; ePowerPass = ((GT_MetaTileEntity_MultiblockBase_EM) mTileEntity.getMetaTileEntity()).ePowerPass; @@ -116,12 +121,15 @@ public class GT_Container_MultiMachineEM extends GT_ContainerMetaTile_Machine { for (Object crafter : crafters) { ICrafting var1 = (ICrafting) crafter; - int i = 100; - for (int j = 0; j < eParamsInStatus.length; j++) { - var1.sendProgressBarUpdate(this, i++, eParamsInStatus[j] | eParamsOutStatus[j] << 8); + for (int i=100, j = 0; j < eParamsInStatus.length; j++) { + 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)); + for(int i=128,k=208,j=0;j<20;j++,i+=4,k+=4) { + Util.sendDouble(eParamsOut[j], this, var1, i); + Util.sendDouble(eParamsIn[j], this, var1, k); + } } } @@ -132,8 +140,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); @@ -141,6 +149,12 @@ public class GT_Container_MultiMachineEM extends GT_ContainerMetaTile_Machine { ePowerPass = (par2 & 1) == 1; eSafeVoid = (par2 & 2) == 2; allowedToWork = (par2 & 4) == 4; + } else if(par1>=128 && par1<208){ + int pos=(par1-128)>>2; + eParamsOut[pos]=Util.receiveDouble(eParamsOut[pos],par1&0xFFFFFFFC,par1,par2); + }else if(par1>=208 && par1<288){ + int pos=(par1-208)>>2; + eParamsIn[pos]=Util.receiveDouble(eParamsIn[pos],par1&0xFFFFFFFC,par1,par2); } } 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..5f5ddf6e4a 100644 --- 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 @@ -1,18 +1,16 @@ package com.github.technus.tectech.thing.metaTileEntity.multi.base; -import gregtech.api.GregTech_API; +import com.github.technus.tectech.TecTech; import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import net.minecraft.client.gui.FontRenderer; import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.item.ItemDye; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; import java.util.List; -import static com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM.*; import static gregtech.api.enums.GT_Values.RES_PATH_GUI; /** @@ -23,9 +21,11 @@ public class GT_GUIContainer_MultiMachineEM extends GT_GUIContainerMetaTile_Mach private String mName; private static byte counter = 0; private final boolean ePowerPassButton, eSafeVoidButton, allowedToWorkButton; + private final GT_Container_MultiMachineEM mContainer; public GT_GUIContainer_MultiMachineEM(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName, String aTextureFile, boolean enablePowerPass, boolean enableSafeVoid, boolean enablePowerButton) { super(new GT_Container_MultiMachineEM(aInventoryPlayer, aTileEntity), RES_PATH_GUI + "multimachines/" + (aTextureFile == null ? "MultiblockDisplay" : aTextureFile)); + mContainer=(GT_Container_MultiMachineEM)super.mContainer; mName = aName; ePowerPassButton=enablePowerPass; eSafeVoidButton=enableSafeVoid; @@ -36,6 +36,7 @@ public class GT_GUIContainer_MultiMachineEM extends GT_GUIContainerMetaTile_Mach public GT_GUIContainer_MultiMachineEM(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName, String aTextureFile) { super(new GT_Container_MultiMachineEM(aInventoryPlayer, aTileEntity), RES_PATH_GUI + "multimachines/" + (aTextureFile == null ? "MultiblockDisplay" : aTextureFile)); + mContainer=(GT_Container_MultiMachineEM)super.mContainer; mName = aName; ePowerPassButton=eSafeVoidButton=allowedToWorkButton=true; ySize= 192; @@ -57,36 +58,36 @@ public class GT_GUIContainer_MultiMachineEM extends GT_GUIContainerMetaTile_Mach fontRendererObj.drawString(mName, 7, 8, 16448255); if (mContainer != null) { - if ((((GT_Container_MultiMachineEM) mContainer).mDisplayErrorCode & 1) != 0) { + if ((mContainer.mDisplayErrorCode & 1) != 0) { fontRendererObj.drawString("Pipe is loose.", 7, 16, 16448255); } - if ((((GT_Container_MultiMachineEM) mContainer).mDisplayErrorCode & 2) != 0) { + if ((mContainer.mDisplayErrorCode & 2) != 0) { fontRendererObj.drawString("Screws are loose.", 7, 24, 16448255); } - if ((((GT_Container_MultiMachineEM) mContainer).mDisplayErrorCode & 4) != 0) { + if ((mContainer.mDisplayErrorCode & 4) != 0) { fontRendererObj.drawString("Something is stuck.", 7, 32, 16448255); } - if ((((GT_Container_MultiMachineEM) mContainer).mDisplayErrorCode & 8) != 0) { + if ((mContainer.mDisplayErrorCode & 8) != 0) { fontRendererObj.drawString("Plating is dented.", 7, 40, 16448255); } - if ((((GT_Container_MultiMachineEM) mContainer).mDisplayErrorCode & 16) != 0) { + if ((mContainer.mDisplayErrorCode & 16) != 0) { fontRendererObj.drawString("Circuitry burned out.", 7, 48, 16448255); } - if ((((GT_Container_MultiMachineEM) mContainer).mDisplayErrorCode & 32) != 0) { + if ((mContainer.mDisplayErrorCode & 32) != 0) { fontRendererObj.drawString("That doesn't belong there.", 7, 56, 16448255); } - if ((((GT_Container_MultiMachineEM) mContainer).mDisplayErrorCode & 64) != 0) { + if ((mContainer.mDisplayErrorCode & 64) != 0) { fontRendererObj.drawString("Incomplete Structure.", 7, 64, 16448255); } - if ((((GT_Container_MultiMachineEM) mContainer).mDisplayErrorCode & 128) != 0) { + if ((mContainer.mDisplayErrorCode & 128) != 0) { fontRendererObj.drawString("Too Uncertain.", 7, 72, 16448255); } - if ((((GT_Container_MultiMachineEM) mContainer).mDisplayErrorCode & 256) != 0) { + if ((mContainer.mDisplayErrorCode & 256) != 0) { fontRendererObj.drawString("Invalid Parameters.", 7, 80, 16448255); } - if (((GT_Container_MultiMachineEM) mContainer).mDisplayErrorCode == 0) { - if (((GT_Container_MultiMachineEM) mContainer).mActive == 0) { + if (mContainer.mDisplayErrorCode == 0) { + if (mContainer.mActive == 0) { fontRendererObj.drawString("Soft Hammer or press Button", 7, 16, 16448255); fontRendererObj.drawString("to (re-)start the Machine", 7, 24, 16448255); fontRendererObj.drawString("if it doesn't start.", 7, 32, 16448255); @@ -103,41 +104,41 @@ public class GT_GUIContainer_MultiMachineEM extends GT_GUIContainerMetaTile_Mach int x = (width - xSize) / 2; int y = (height - ySize) / 2; drawTexturedModalRect(x, y, 0, 0, xSize, ySize); - if (mContainer != null && ((GT_Container_MultiMachineEM) mContainer).eParamsInStatus != null) { + if (mContainer != null && mContainer.eParamsInStatus != null) { counter = (byte) ((1 + counter) % 6); GL11.glColor4f(1f, 1f, 1f, 1f); x+= 173; if(!ePowerPassButton) { drawTexturedModalRect(x, y + 115, 231, 23, 18, 18); - } else if (((GT_Container_MultiMachineEM) mContainer).ePowerPass) { + } else if (mContainer.ePowerPass) { drawTexturedModalRect(x, y + 115, 207, 23, 18, 18); } if(!eSafeVoidButton) { drawTexturedModalRect(x, y + 132, 231, 41, 18, 18); - } else if (((GT_Container_MultiMachineEM) mContainer).eSafeVoid) { + } else if (mContainer.eSafeVoid) { drawTexturedModalRect(x, y + 132, 207, 41, 18, 18); } if(!allowedToWorkButton) { drawTexturedModalRect(x, y + 147, 231, 57, 18, 18); - } else if (((GT_Container_MultiMachineEM) mContainer).allowedToWork) { + } else if (mContainer.allowedToWork) { drawTexturedModalRect(x, y + 147, 207, 57, 18, 18); } x -= 162; y += 96; for (int i = 0; i < 20; ) { byte hatch = (byte) (i >>> 1); - LEDdrawP(x, y, i, 0, ((GT_Container_MultiMachineEM) mContainer).eParamsInStatus[hatch]); - LEDdrawP(x, y, i++, 1, ((GT_Container_MultiMachineEM) mContainer).eParamsOutStatus[hatch]); - LEDdrawP(x, y, i, 0, ((GT_Container_MultiMachineEM) mContainer).eParamsInStatus[hatch + 10]); - LEDdrawP(x, y, i++, 1, ((GT_Container_MultiMachineEM) mContainer).eParamsOutStatus[hatch + 10]); + LEDdrawP(x, y, i, 0, mContainer.eParamsInStatus[hatch]); + LEDdrawP(x, y, i++, 1, mContainer.eParamsOutStatus[hatch]); + LEDdrawP(x, y, i, 0, mContainer.eParamsInStatus[hatch + 10]); + LEDdrawP(x, y, i++, 1, mContainer.eParamsOutStatus[hatch + 10]); } short rU = 207, Vs = 77; x += 162; - byte state = ((GT_Container_MultiMachineEM) mContainer).eCertainStatus; - switch (((GT_Container_MultiMachineEM) mContainer).eCertainMode) { + byte state = mContainer.eCertainStatus; + switch (mContainer.eCertainMode) { case 1://ooo oxo ooo drawTexturedModalRect(x + 6, y + 6, rU + (state == 0 ? 30 : 6), @@ -200,47 +201,92 @@ public class GT_GUIContainer_MultiMachineEM extends GT_GUIContainerMetaTile_Mach } } - private void LEDdrawP(int x, int y, int i, int j, byte status) { + private void LEDdrawP(int x, int y, int i, int j, LedStatus status) { int v = 192, su = 8, sv = 6, u = 11; switch (status) { + case STATUS_WTF: { + int c=counter; + if(c>4){ + c= TecTech.RANDOM.nextInt(5); + } + switch (c) { + case 0: + drawTexturedModalRect(x + su * i, y + sv * j, u + su * i, v + sv * j, su, sv);//BLUE + break; + case 1: + drawTexturedModalRect(x + su * i, y + sv * j, u + su * i, v + sv * (2 + j), su, sv);//cyan + break; + case 2: + drawTexturedModalRect(x + su * i, y + sv * j, u + su * i, v + sv * (4 + j), su, sv);//green + break; + case 3: + drawTexturedModalRect(x + su * i, y + sv * j, u + su * i, v + sv * (6 + j), su, sv);//orangeyello + break; + case 4: + drawTexturedModalRect(x + su * i, y + sv * j, u + su * i, v + sv * (8 + j), su, sv);//redd + break; + } + break; + } case STATUS_WRONG: //fallthrough if (counter < 2) { - drawTexturedModalRect(x + su * i, y + sv * j, u + su * i, v + sv * j, su, sv); + drawTexturedModalRect(x + su * i, y + sv * j, u + su * i, v + sv * j, su, sv);//blue break; } else if (counter < 4) { - drawTexturedModalRect(x + su * i, y + sv * j, u + su * i, v + sv * (8 + j), su, sv); + drawTexturedModalRect(x + su * i, y + sv * j, u + su * i, v + sv * (8 + j), su, sv);//red break; } case STATUS_OK://ok - drawTexturedModalRect(x + su * i, y + sv * j, u + su * i, v + sv * (4 + j), su, sv); + drawTexturedModalRect(x + su * i, y + sv * j, u + su * i, v + sv * (4 + j), su, sv);//green break; case STATUS_TOO_LOW://too low blink if (counter < 3) { - drawTexturedModalRect(x + su * i, y + sv * j, u + su * i, v + sv * j, su, sv); + drawTexturedModalRect(x + su * i, y + sv * j, u + su * i, v + sv * j, su, sv);//BLUE break; } case STATUS_LOW:// too low - drawTexturedModalRect(x + su * i, y + sv * j, u + su * i, v + sv * (2 + j), su, sv); + drawTexturedModalRect(x + su * i, y + sv * j, u + su * i, v + sv * (2 + j), su, sv);//cyan break; case STATUS_TOO_HIGH://too high blink if (counter < 3) { - drawTexturedModalRect(x + su * i, y + sv * j, u + su * i, v + sv * (8 + j), su, sv); + drawTexturedModalRect(x + su * i, y + sv * j, u + su * i, v + sv * (8 + j), su, sv);//redd break; } case STATUS_HIGH:// too high - drawTexturedModalRect(x + su * i, y + sv * j, u + su * i, v + sv * (6 + j), su, sv); + drawTexturedModalRect(x + su * i, y + sv * j, u + su * i, v + sv * (6 + j), su, sv);//orangeyello break; - case STATUS_UNUSED: - if (GregTech_API.sColoredGUI && this.mContainer.mTileEntity != null) { - int tColor = this.mContainer.mTileEntity.getColorization() & 15; - if (tColor < ItemDye.field_150922_c.length) { - tColor = ItemDye.field_150922_c[tColor]; - GL11.glColor4f((float)(tColor >> 16 & 255) / 255.0F, (float)(tColor >> 8 & 255) / 255.0F, (float)(tColor & 255) / 255.0F, 1.0F); - } + case STATUS_NEUTRAL: + if(counter<3){ + GL11.glColor4f(.85f, .9f, .95f, .5F); + drawTexturedModalRect(x + su * i, y + sv * j, 212, 96, su+2, sv+2); + }else { + GL11.glColor4f(.8f, .9f, 1f, .5F); + drawTexturedModalRect(x + su * i, y + sv * j, 212, 96, su+2, sv+2); } - drawTexturedModalRect(x + su * i, y + sv * j, 212, 96, su+2, sv+2); GL11.glColor4f(1f, 1f, 1f, 1f); break; + case STATUS_UNDEFINED: + if(counter<3) { + GL11.glColor4f(.5f, .1f, .15f, .5F); + drawTexturedModalRect(x + su * i, y + sv * j, 212, 96, su + 2, sv + 2); + }else { + GL11.glColor4f(0f, .1f, .2f, .5F); + drawTexturedModalRect(x + su * i, y + sv * j, 212, 96, su + 2, sv + 2); + } + GL11.glColor4f(1f, 1f, 1f, 1f); + break; + case STATUS_UNUSED: + default: + //if (GregTech_API.sColoredGUI && this.mContainer.mTileEntity != null) { + // int tColor = this.mContainer.mTileEntity.getColorization() & 15; + // if (tColor < ItemDye.field_150922_c.length) { + // tColor = ItemDye.field_150922_c[tColor]; + // GL11.glColor4f((float)(tColor >> 16 & 255) / 255.0F, (float)(tColor >> 8 & 255) / 255.0F, (float)(tColor & 255) / 255.0F, 1F); + // } + //} + //drawTexturedModalRect(x + su * i, y + sv * j, 212, 96, su+2, sv+2); + //GL11.glColor4f(1f, 1f, 1f, 1f); + //break; } } @@ -253,6 +299,11 @@ public class GT_GUIContainer_MultiMachineEM extends GT_GUIContainerMetaTile_Mach if(mContainer.mTileEntity!=null){ IMetaTileEntity mte=mContainer.mTileEntity.getMetaTileEntity(); if(mte instanceof GT_MetaTileEntity_MultiblockBase_EM){ + Parameters parametrization=((GT_MetaTileEntity_MultiblockBase_EM)mte).parametrization; + parametrization.eParamsInStatus=mContainer.eParamsInStatus; + parametrization.eParamsOutStatus=mContainer.eParamsOutStatus; + parametrization.iParamsIn=mContainer.eParamsIn; + parametrization.iParamsOut=mContainer.eParamsOut; int su = 8, sv = 6, u=11,v=96; if(x<u || y<v) return; v+=sv; @@ -260,15 +311,15 @@ public class GT_GUIContainer_MultiMachineEM extends GT_GUIContainerMetaTile_Mach for(int param=0;param<2;param++){ if(x<(u+=su)){ if(y<v){ - if(((GT_Container_MultiMachineEM) mContainer).eParamsInStatus[hatch + (10*param)]==STATUS_UNUSED){ - return; - } + //if(mContainer.eParamsInStatus[hatch + (10*param)]==STATUS_UNUSED){ + // return; + //} hoveringText(((GT_MetaTileEntity_MultiblockBase_EM) mte).getFullLedDescriptionIn(hatch,param), renderPosX, renderPosY, fontRendererObj); return; }else if(y>=v && y<v+sv){ - if(((GT_Container_MultiMachineEM) mContainer).eParamsOutStatus[hatch + (10*param)]==STATUS_UNUSED){ - return; - } + //if(mContainer.eParamsOutStatus[hatch + (10*param)]==STATUS_UNUSED){ + // return; + //} hoveringText(((GT_MetaTileEntity_MultiblockBase_EM) mte).getFullLedDescriptionOut(hatch,param), renderPosX, renderPosY, fontRendererObj); return; } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_MetaTileEntity_MultiblockBase_EM.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_MetaTileEntity_MultiblockBase_EM.java index ebcc0ef622..19d64910e1 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_MetaTileEntity_MultiblockBase_EM.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_MetaTileEntity_MultiblockBase_EM.java @@ -2,6 +2,7 @@ package com.github.technus.tectech.thing.metaTileEntity.multi.base; import com.github.technus.tectech.Reference; import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.Util; import com.github.technus.tectech.Vec3pos; import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalInstanceStackMap; import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.cElementalDefinitionStack; @@ -9,8 +10,8 @@ import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.cElement import com.github.technus.tectech.mechanics.elementalMatter.core.tElementalException; import com.github.technus.tectech.thing.metaTileEntity.IFrontRotation; import com.github.technus.tectech.thing.metaTileEntity.hatch.*; -import com.github.technus.tectech.thing.metaTileEntity.multi.base.network.RotationMessage; -import com.github.technus.tectech.thing.metaTileEntity.multi.base.network.RotationPacketDispatcher; +import com.github.technus.tectech.thing.metaTileEntity.RotationMessage; +import com.github.technus.tectech.loader.NetworkDispatcher; import com.github.technus.tectech.thing.metaTileEntity.multi.base.render.TT_RenderedTexture; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -35,15 +36,10 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fluids.FluidStack; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; import static com.github.technus.tectech.CommonValues.*; -import static com.github.technus.tectech.Util.StructureCheckerExtreme; -import static com.github.technus.tectech.Util.getTier; +import static com.github.technus.tectech.Util.*; import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.texturePage; @@ -57,12 +53,6 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt public static final FluidStack[] nothingF = new FluidStack[0]; //endregion - //region Reflection based hatch adding... - //Example how to add custom method is in computer and research station - protected static final Map<String, Method> adderMethodMap = new HashMap<>(); - private static Method adderMethod; - //endregion - //region Client side variables (static - one per class) //Front icon holders - static so it is default one for my blocks @@ -95,25 +85,8 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt protected ArrayList<GT_MetaTileEntity_Hatch_InputData> eInputData = new ArrayList<>(); protected ArrayList<GT_MetaTileEntity_Hatch_OutputData> eOutputData = new ArrayList<>(); - //endregion - - //region PARAMETERS! GO AWAY and use proper get/set methods - // 0 and 10 are from first parametrizer - // 1 and 11 are from second etc... - - private final int[] iParamsIn = new int[20];//number I from parametrizers - private final int[] iParamsOut = new int[20];//number O to parametrizers - private final boolean[] bParamsAreFloats = new boolean[10]; - - final byte[] eParamsInStatus = new byte[20];//LED status for I - final byte[] eParamsOutStatus = new byte[20];//LED status for O - public static final byte STATUS_UNUSED =7, STATUS_NEUTRAL = 0, - STATUS_TOO_LOW = 1, STATUS_LOW = 2, - STATUS_WRONG = 3, STATUS_OK = 4, - STATUS_TOO_HIGH = 5, STATUS_HIGH = 6; - // 0,2,4,6 - ok - // 1,3,5 - nok - + //region parameters + public final Parameters parametrization; //endregion //region Control variables @@ -150,10 +123,10 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt protected boolean ePowerPass = false, eSafeVoid = false; //max amperes machine can take in after computing it to the lowest tier (exchange packets to min tier count) - protected long eMaxAmpereFlow = 0; + protected long eMaxAmpereFlow = 0,eMaxAmpereGen=0; //What is the max and minimal tier of eu hatches installed - private long maxEUinputMin = 0, maxEUinputMax = 0; + private long maxEUinputMin = 0, maxEUinputMax = 0,maxEUoutputMin = 0, maxEUoutputMax = 0; //read only unless you are making computation generator - read computer class protected long eAvailableData = 0; // data being available @@ -168,12 +141,16 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt protected GT_MetaTileEntity_MultiblockBase_EM(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); - parametersLoadDefault_EM(); + parametrization=new Parameters(this); + parametersInstantiation_EM(); + parametrization.setToDefaults(true,true); } protected GT_MetaTileEntity_MultiblockBase_EM(String aName) { super(aName); - parametersLoadDefault_EM(); + parametrization=new Parameters(this); + parametersInstantiation_EM(); + parametrization.setToDefaults(true,true); } //region SUPER STRUCT @@ -386,12 +363,12 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt String[][] structure,//0-9 casing, +- air no air, a-z ignore Block[] blockType,//use numbers 0-9 for casing types byte[] blockMeta,//use numbers 0-9 for casing types - String[] addingMethods, + IHatchAdder[] addingMethods, short[] casingTextures, Block[] blockTypeFallback,//use numbers 0-9 for casing types byte[] blockMetaFallback,//use numbers 0-9 for casing types int horizontalOffset, int verticalOffset, int depthOffset) { - return StructureCheckerExtreme(structure, blockType, blockMeta, adderMethod, addingMethods, casingTextures, blockTypeFallback, blockMetaFallback, + return StructureCheckerExtreme(structure, blockType, blockMeta, addingMethods, casingTextures, blockTypeFallback, blockMetaFallback, horizontalOffset, verticalOffset, depthOffset, getBaseMetaTileEntity(), this, !mMachine); } @@ -446,7 +423,6 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt } } } - //endregion //region tooltip and scanner result @@ -464,7 +440,14 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt EnumChatFormatting.YELLOW+ ":" + EnumChatFormatting.AQUA+paramID + EnumChatFormatting.YELLOW+ ":"+ - EnumChatFormatting.AQUA+"I"); + EnumChatFormatting.AQUA+"I "+parametrization.getStatusIn(hatchNo, paramID).name.get()); + list.add(EnumChatFormatting.WHITE+"Value: "+ + EnumChatFormatting.AQUA+ Util.doubleToString(parametrization.getIn(hatchNo,paramID))); + try{ + list.add(parametrization.groups[hatchNo].parameterIn[paramID].getBrief()); + }catch (NullPointerException|IndexOutOfBoundsException e){ + list.add("Unused"); + } return list; } @@ -481,7 +464,14 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt EnumChatFormatting.YELLOW+ ":" + EnumChatFormatting.AQUA+paramID + EnumChatFormatting.YELLOW+ ":"+ - EnumChatFormatting.AQUA+"O"); + EnumChatFormatting.AQUA+"O "+parametrization.getStatusOut(hatchNo, paramID).name.get()); + list.add(EnumChatFormatting.WHITE+"Value: "+ + EnumChatFormatting.AQUA+Util.doubleToString(parametrization.getOut(hatchNo,paramID))); + try{ + list.add(parametrization.groups[hatchNo].parameterOut[paramID].getBrief()); + }catch (NullPointerException|IndexOutOfBoundsException e){ + list.add("Unused"); + } return list; } @@ -521,17 +511,17 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt return new String[]{ "Progress:", EnumChatFormatting.GREEN + Integer.toString(mProgresstime / 20) + EnumChatFormatting.RESET + " s / " + - EnumChatFormatting.YELLOW + Integer.toString(mMaxProgresstime / 20) + EnumChatFormatting.RESET + " s", + EnumChatFormatting.YELLOW + mMaxProgresstime / 20 + EnumChatFormatting.RESET + " s", "Energy Hatches:", EnumChatFormatting.GREEN + Long.toString(storedEnergy) + EnumChatFormatting.RESET + " EU / " + - EnumChatFormatting.YELLOW + Long.toString(maxEnergy) + EnumChatFormatting.RESET + " EU", - (mEUt <= 0 ? "Probably uses: " : "Probably makes: ") + - EnumChatFormatting.RED + Integer.toString(Math.abs(mEUt)) + EnumChatFormatting.RESET + " EU/t at " + + EnumChatFormatting.YELLOW + maxEnergy + EnumChatFormatting.RESET + " EU", + (mEUt*eAmpereFlow <= 0 ? "Probably uses: " : "Probably makes: ") + + EnumChatFormatting.RED + Math.abs(mEUt) + EnumChatFormatting.RESET + " EU/t at " + EnumChatFormatting.RED + eAmpereFlow + EnumChatFormatting.RESET + " A", "Tier Rating: " + EnumChatFormatting.YELLOW + VN[getMaxEnergyInputTier_EM()] + EnumChatFormatting.RESET + " / " + EnumChatFormatting.GREEN + VN[getMinEnergyInputTier_EM()] + EnumChatFormatting.RESET + " Amp Rating: " + EnumChatFormatting.GREEN + eMaxAmpereFlow + EnumChatFormatting.RESET + " A", "Problems: " + EnumChatFormatting.RED + (getIdealStatus() - getRepairStatus()) + EnumChatFormatting.RESET + - " Efficiency: " + EnumChatFormatting.YELLOW + Float.toString(mEfficiency / 100.0F) + EnumChatFormatting.RESET + " %", + " Efficiency: " + EnumChatFormatting.YELLOW + mEfficiency / 100.0F + EnumChatFormatting.RESET + " %", "PowerPass: " + EnumChatFormatting.BLUE + ePowerPass + EnumChatFormatting.RESET + " SafeVoid: " + EnumChatFormatting.BLUE + eSafeVoid, "Computation: " + EnumChatFormatting.GREEN + eAvailableData + EnumChatFormatting.RESET + " / " + EnumChatFormatting.YELLOW + eRequiredData + EnumChatFormatting.RESET @@ -635,80 +625,6 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt //endregion - //region PARAMETERS AND STATUSES - actually use it to work with parameters in other overrides - - public final boolean setParameterPairIn_ClearOut(int hatchNo, boolean usesFloats, double value0, double value1) { - if (mMaxProgresstime > 0) { - return false; - } - bParamsAreFloats[hatchNo] = usesFloats; - if (usesFloats) { - iParamsIn[hatchNo] = Float.floatToIntBits((float) value0); - iParamsIn[hatchNo + 10] = Float.floatToIntBits((float) value1); - } else { - iParamsIn[hatchNo] = (int) value0; - iParamsIn[hatchNo + 10] = (int) value1; - } - iParamsOut[hatchNo] = 0; - iParamsOut[hatchNo + 10] = 0; - return true; - } - - public final boolean isParametrizerUsingFloat(int hatchNo){ - return bParamsAreFloats[hatchNo]; - } - - public final double getParameterIn(int hatchNo, int paramID){ - return bParamsAreFloats[hatchNo]?Float.intBitsToFloat(iParamsIn[hatchNo+10*paramID]):iParamsIn[hatchNo+10*paramID]; - } - - public final int getParameterInInt(int hatchNo, int paramID){ - if(bParamsAreFloats[hatchNo]) { - return (int) Float.intBitsToFloat(iParamsIn[hatchNo + 10 * paramID]); - } - return iParamsIn[hatchNo+10*paramID]; - } - - //public final int getParameterInIntRaw(int hatchNo, int paramID){ - // return iParamsIn[hatchNo+10*paramID]; - //} - - //public final float getParameterInFloatRaw(int hatchNo, int paramID){ - // return Float.intBitsToFloat(iParamsIn[hatchNo+10*paramID]); - //} - - public final void setParameterOut(int hatchNo, int paramID, double value){ - if(bParamsAreFloats[hatchNo]) { - iParamsOut[hatchNo+10*paramID]=Float.floatToIntBits((float) value); - }else{ - iParamsOut[hatchNo+10*paramID]=(int)value; - } - } - - //public final boolean setParameterOutInt(int hatchNo, int paramID, int value){ - // if(bParamsAreFloats[hatchNo]) return false; - // iParamsOut[hatchNo+10*paramID]=value; - // return true; - //} - - //public final boolean setParameterOutFloat(int hatchNo, int paramID, float value){ - // if(bParamsAreFloats[hatchNo]) { - // iParamsOut[hatchNo + 10 * paramID] = Float.floatToIntBits(value); - // return true; - // } - // return false; - //} - - public final void setStatusOfParameterIn(int hatchNo, int paramID, byte status){ - eParamsInStatus[hatchNo+10*paramID]=status; - } - - public final void setStatusOfParameterOut(int hatchNo, int paramID, byte status){ - eParamsOutStatus[hatchNo+10*paramID]=status; - } - - //endregion - //region Methods to maybe override (if u implement certain stuff) /** @@ -758,16 +674,10 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt hatch.getBaseMetaTileEntity().setActive(false); } } + cleanOutputEM_EM(); if (ePowerPass && getEUVar()>V[3] || eDismantleBoom && mMaxProgresstime > 0 && areChunksAroundLoaded_EM()) { explodeMultiblock(); } - if (outputEM != null) { - for (cElementalInstanceStackMap output : outputEM) { - if (output != null && output.hasStacks()) { - explodeMultiblock(); - } - } - } } catch (Exception e) { if (DEBUG_MODE) { e.printStackTrace(); @@ -791,30 +701,43 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt } /** - * loads default parameters in CONSTRUCTOR! CALLED ONCE on creation, don't call it in your classes + * instantiate parameters in CONSTRUCTOR! CALLED ONCE on creation, don't call it in your classes */ - protected void parametersLoadDefault_EM(){ - //load default parameters with setParameterPairIn_ClearOut - } - - /** - * This is called automatically when there was parameters data update, copy it to your variables for safe storage - * although the base code only downloads the values from parametrizers when machines is NOT OPERATING - * - * good place to get Parameters - */ - protected void parametersInRead_EM(){} + protected void parametersInstantiation_EM(){} /** * It is automatically called OFTEN * update status of parameters in guis (and "machine state" if u wish) - * Called before check recipe, before outputting, and every second the machine is active + * Called before check recipe, before outputting, and every second the machine is complete * - * good place for set Parameters + * good place to update parameter statuses, default implementation handles it well * * @param machineBusy is machine doing SHIT */ - public void parametersOutAndStatusesWrite_EM(boolean machineBusy){} + protected void parametersStatusesWrite_EM(boolean machineBusy) {//todo unimplement? + if(!machineBusy){ + for (Parameters.Group.ParameterIn parameterIn : parametrization.parameterInArrayList) { + if (parameterIn != null) { + parameterIn.updateStatus(); + } + } + }else{ + for (Parameters.Group hatch:parametrization.groups){ + if(hatch!=null && hatch.updateWhileRunning){ + for (Parameters.Group.ParameterIn in:hatch.parameterIn) { + if(in!=null){ + in.updateStatus(); + } + } + } + } + } + for (Parameters.Group.ParameterOut parameterOut : parametrization.parameterOutArrayList) { + if (parameterOut != null) { + parameterOut.updateStatus(); + } + } + } /** * For extra types of hatches initiation, LOOK HOW IT IS CALLED! in onPostTick @@ -890,7 +813,9 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt @Override public void saveNBTData(NBTTagCompound aNBT) { super.saveNBTData(aNBT); - + aNBT.setLong("eMaxGenEUmin", maxEUoutputMin); + aNBT.setLong("eMaxGenEUmax", maxEUoutputMax); + aNBT.setLong("eGenRating", eMaxAmpereGen); aNBT.setLong("eMaxEUmin", maxEUinputMin); aNBT.setLong("eMaxEUmax", maxEUinputMax); aNBT.setLong("eRating", eAmpereFlow); @@ -946,32 +871,26 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt } NBTTagCompound paramI = new NBTTagCompound(); - for (int i = 0; i < iParamsIn.length; i++) { - paramI.setInteger(Integer.toString(i), iParamsIn[i]); + for (int i = 0; i < parametrization.iParamsIn.length; i++) { + paramI.setDouble(Integer.toString(i), parametrization.iParamsIn[i]); } - aNBT.setTag("eParamsIn", paramI); + aNBT.setTag("eParamsInD", paramI); NBTTagCompound paramO = new NBTTagCompound(); - for (int i = 0; i < iParamsOut.length; i++) { - paramO.setInteger(Integer.toString(i), iParamsOut[i]); - } - aNBT.setTag("eParamsOut", paramO); - - NBTTagCompound paramB = new NBTTagCompound(); - for (int i = 0; i < bParamsAreFloats.length; i++) { - paramB.setBoolean(Integer.toString(i), bParamsAreFloats[i]); + for (int i = 0; i < parametrization.iParamsOut.length; i++) { + paramO.setDouble(Integer.toString(i), parametrization.iParamsOut[i]); } - aNBT.setTag("eParamsB", paramB); + aNBT.setTag("eParamsOutD", paramO); NBTTagCompound paramIs = new NBTTagCompound(); - for (int i = 0; i < eParamsInStatus.length; i++) { - paramIs.setByte(Integer.toString(i), eParamsInStatus[i]); + for (int i = 0; i < parametrization.eParamsInStatus.length; i++) { + paramIs.setByte(Integer.toString(i), parametrization.eParamsInStatus[i].getOrdinalByte()); } aNBT.setTag("eParamsInS", paramIs); NBTTagCompound paramOs = new NBTTagCompound(); - for (int i = 0; i < eParamsOutStatus.length; i++) { - paramOs.setByte(Integer.toString(i), eParamsOutStatus[i]); + for (int i = 0; i < parametrization.eParamsOutStatus.length; i++) { + paramOs.setByte(Integer.toString(i), parametrization.eParamsOutStatus[i].getOrdinalByte()); } aNBT.setTag("eParamsOutS", paramOs); } @@ -983,7 +902,9 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt @Override public void loadNBTData(NBTTagCompound aNBT) { super.loadNBTData(aNBT); - + maxEUoutputMin = aNBT.getLong("eMaxGenEUmin"); + maxEUoutputMax = aNBT.getLong("eMaxGenEUmax"); + eMaxAmpereGen = aNBT.getLong("eGenRating"); maxEUinputMin = aNBT.getLong("eMaxEUmin"); maxEUinputMax = aNBT.getLong("eMaxEUmax"); eAmpereFlow = aNBT.getLong("eRating"); @@ -1038,29 +959,38 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt outputEM = null; } - NBTTagCompound paramI = aNBT.getCompoundTag("eParamsIn"); - for (int i = 0; i < iParamsIn.length; i++) { - iParamsIn[i] = paramI.getInteger(Integer.toString(i)); - } - - NBTTagCompound paramO = aNBT.getCompoundTag("eParamsOut"); - for (int i = 0; i < iParamsOut.length; i++) { - iParamsOut[i] = paramO.getInteger(Integer.toString(i)); - } - - NBTTagCompound paramB = aNBT.getCompoundTag("eParamsB"); - for (int i = 0; i < bParamsAreFloats.length; i++) { - bParamsAreFloats[i] = paramB.getBoolean(Integer.toString(i)); + if(aNBT.hasKey("eParamsIn") && aNBT.hasKey("eParamsOut") && aNBT.hasKey("eParamsB")){ + NBTTagCompound paramI = aNBT.getCompoundTag("eParamsIn"); + NBTTagCompound paramO = aNBT.getCompoundTag("eParamsOut"); + NBTTagCompound paramB = aNBT.getCompoundTag("eParamsB"); + for (int i = 0; i < 10; i++) { + if(paramB.getBoolean(Integer.toString(i))){ + parametrization.iParamsIn[i] = Float.intBitsToFloat(paramI.getInteger(Integer.toString(i))); + parametrization.iParamsOut[i] =Float.intBitsToFloat(paramO.getInteger(Integer.toString(i))); + }else { + parametrization.iParamsIn[i] = paramI.getInteger(Integer.toString(i)); + parametrization.iParamsOut[i] = paramO.getInteger(Integer.toString(i)); + } + } + }else{ + NBTTagCompound paramI = aNBT.getCompoundTag("eParamsInD"); + for (int i = 0; i < parametrization.iParamsIn.length; i++) { + parametrization.iParamsIn[i] = paramI.getDouble(Integer.toString(i)); + } + NBTTagCompound paramO = aNBT.getCompoundTag("eParamsOutD"); + for (int i = 0; i < parametrization.iParamsOut.length; i++) { + parametrization.iParamsOut[i] = paramO.getDouble(Integer.toString(i)); + } } NBTTagCompound paramIs = aNBT.getCompoundTag("eParamsInS"); - for (int i = 0; i < eParamsInStatus.length; i++) { - eParamsInStatus[i] = paramIs.getByte(Integer.toString(i)); + for (int i = 0; i < parametrization.eParamsInStatus.length; i++) { + parametrization.eParamsInStatus[i] = LedStatus.getStatus(paramIs.getByte(Integer.toString(i))); } NBTTagCompound paramOs = aNBT.getCompoundTag("eParamsOutS"); - for (int i = 0; i < eParamsOutStatus.length; i++) { - eParamsOutStatus[i] = paramOs.getByte(Integer.toString(i)); + for (int i = 0; i < parametrization.eParamsOutStatus.length; i++) { + parametrization.eParamsOutStatus[i] = LedStatus.getStatus(paramOs.getByte(Integer.toString(i))); } } @@ -1190,14 +1120,14 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt frontRotation = rotation; IGregTechTileEntity base=getBaseMetaTileEntity(); if(base.isClientSide()) { - base.getWorld().markBlockRangeForRenderUpdate(base.getXCoord(), base.getYCoord(), base.getZCoord(), base.getXCoord(), base.getYCoord(), base.getZCoord()); + base.issueTextureUpdate(); } } protected final void updateRotationOnClients(){ if(getBaseMetaTileEntity().isServerSide()){ IGregTechTileEntity base=getBaseMetaTileEntity(); - RotationPacketDispatcher.INSTANCE.sendToAllAround(new RotationMessage.RotationData(this), + NetworkDispatcher.INSTANCE.sendToAllAround(new RotationMessage.RotationData(this), base.getWorld().provider.dimensionId, base.getXCoord(), base.getYCoord(), @@ -1239,46 +1169,43 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt } /** - * callback for updating parameters, change this if u really need dynamic (inside recipe time) parameter updates + * callback for updating parameters and new hatches */ protected void hatchesStatusUpdate_EM() { + if(getBaseMetaTileEntity().isClientSide()){ + return; + } boolean busy=mMaxProgresstime>0; if (busy) {//write from buffer to hatches only for (GT_MetaTileEntity_Hatch_Param hatch : eParamHatches) { if (!GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(hatch) || hatch.param < 0) { continue; } - int paramID = hatch.param; - if(bParamsAreFloats[hatch.param] == hatch.isUsingFloats()){ - hatch.input0i = iParamsOut[paramID]; - hatch.input1i = iParamsOut[paramID + 10]; - }else if(hatch.isUsingFloats()){ - hatch.input0i = Float.floatToIntBits((float)iParamsOut[paramID]); - hatch.input1i = Float.floatToIntBits((float)iParamsOut[paramID + 10]); - }else { - hatch.input0i = (int)Float.intBitsToFloat(iParamsOut[paramID]); - hatch.input1i = (int)Float.intBitsToFloat(iParamsOut[paramID + 10]); + int hatchId = hatch.param; + if(parametrization.groups[hatchId]!=null && parametrization.groups[hatchId].updateWhileRunning){ + parametrization.iParamsIn[hatchId] = hatch.value0D; + parametrization.iParamsIn[hatchId + 10] = hatch.value1D; } + hatch.input0D = parametrization.iParamsOut[hatchId]; + hatch.input1D = parametrization.iParamsOut[hatchId + 10]; } - parametersInRead_EM(); } else {//if has nothing to do update all for (GT_MetaTileEntity_Hatch_Param hatch : eParamHatches) { if (!GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(hatch) || hatch.param < 0) { continue; } - int paramID = hatch.param; - bParamsAreFloats[hatch.param] = hatch.isUsingFloats(); - iParamsIn[paramID] = hatch.value0i; - iParamsIn[paramID + 10] = hatch.value1i; - hatch.input0i = iParamsOut[paramID]; - hatch.input1i = iParamsOut[paramID + 10]; + int hatchId = hatch.param; + parametrization.iParamsIn[hatchId] = hatch.value0D; + parametrization.iParamsIn[hatchId + 10] = hatch.value1D; + hatch.input0D = parametrization.iParamsOut[hatchId]; + hatch.input1D = parametrization.iParamsOut[hatchId + 10]; } } for (GT_MetaTileEntity_Hatch_Uncertainty uncertainty : eUncertainHatches) { eCertainStatus = uncertainty.update(eCertainMode); } eAvailableData = getAvailableData_EM(); - parametersOutAndStatusesWrite_EM(busy); + parametersStatusesWrite_EM(busy); } @Deprecated @@ -1295,7 +1222,7 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt public final void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { isFacingValid(aBaseMetaTileEntity.getFrontFacing()); if(getBaseMetaTileEntity().isClientSide()){ - RotationPacketDispatcher.INSTANCE.sendToServer(new RotationMessage.RotationQuery(this)); + NetworkDispatcher.INSTANCE.sendToServer(new RotationMessage.RotationQuery(this)); } onFirstTick_EM(aBaseMetaTileEntity); } @@ -1380,8 +1307,8 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt eOutputData.clear(); eInputData.clear(); - if (getBaseMetaTileEntity() instanceof BaseTileEntity) { - ((BaseTileEntity) getBaseMetaTileEntity()).ignoreUnloadedChunks = mMachine; + if (aBaseMetaTileEntity instanceof BaseTileEntity) { + ((BaseTileEntity) aBaseMetaTileEntity).ignoreUnloadedChunks = mMachine; } mMachine = checkMachine(aBaseMetaTileEntity, mInventory[1]); @@ -1429,9 +1356,11 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt } } - if (!mEnergyHatches.isEmpty() || !eEnergyMulti.isEmpty()) { + if (!mEnergyHatches.isEmpty() || !eEnergyMulti.isEmpty() || !mDynamoHatches.isEmpty() || !eDynamoMulti.isEmpty()) { maxEUinputMin = V[15]; maxEUinputMax = V[0]; + maxEUoutputMin = V[15]; + maxEUoutputMax = V[0]; for (GT_MetaTileEntity_Hatch_Energy hatch : mEnergyHatches) { if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(hatch)) { if (hatch.maxEUInput() < maxEUinputMin) { @@ -1452,7 +1381,28 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt } } } + for (GT_MetaTileEntity_Hatch_Dynamo hatch : mDynamoHatches) { + if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(hatch)) { + if (hatch.maxEUOutput() < maxEUoutputMin) { + maxEUoutputMin = hatch.maxEUOutput(); + } + if (hatch.maxEUOutput() > maxEUoutputMax) { + maxEUoutputMax = hatch.maxEUOutput(); + } + } + } + for (GT_MetaTileEntity_Hatch_DynamoMulti hatch : eDynamoMulti) { + if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(hatch)) { + if (hatch.maxEUOutput() < maxEUoutputMin) { + maxEUoutputMin = hatch.maxEUOutput(); + } + if (hatch.maxEUOutput() > maxEUoutputMax) { + maxEUoutputMax = hatch.maxEUOutput(); + } + } + } eMaxAmpereFlow = 0; + eMaxAmpereGen = 0; //counts only full amps for (GT_MetaTileEntity_Hatch_Energy hatch : mEnergyHatches) { if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(hatch)) { @@ -1464,6 +1414,16 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt eMaxAmpereFlow += hatch.maxEUInput() / maxEUinputMin * hatch.Amperes; } } + for (GT_MetaTileEntity_Hatch_Dynamo hatch : mDynamoHatches) { + if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(hatch)) { + eMaxAmpereGen += hatch.maxEUOutput() / maxEUoutputMin; + } + } + for (GT_MetaTileEntity_Hatch_DynamoMulti hatch : eDynamoMulti) { + if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(hatch)) { + eMaxAmpereGen += hatch.maxEUOutput() / maxEUoutputMin * hatch.Amperes; + } + } if (getEUVar() > maxEUStore()) { setEUVar(maxEUStore()); } @@ -1471,6 +1431,9 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt maxEUinputMin = 0; maxEUinputMax = 0; eMaxAmpereFlow = 0; + maxEUoutputMin = 0; + maxEUoutputMax = 0; + eMaxAmpereGen = 0; setEUVar(0); } @@ -1482,9 +1445,6 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt for (GT_MetaTileEntity_Hatch_Param hatch : eParamHatches){ if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(hatch)) { hatch.getBaseMetaTileEntity().setActive(true); - if(hatch.param>=0) { - bParamsAreFloats[hatch.param] = hatch.isUsingFloats(); - } } } } else { @@ -1763,7 +1723,7 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt @Override public long maxEUStore() { - return maxEUinputMin * eMaxAmpereFlow << 3; + return Math.max(maxEUinputMin * (eMaxAmpereFlow << 3),maxEUoutputMin*(eMaxAmpereGen << 3)); } @Override @@ -2018,35 +1978,14 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt mass += tHatch.overflowMatter; tHatch.overflowMatter = 0; } - if (mass > 0) { - if (eMufflerHatches.size() < 1) { - explodeMultiblock(); - } - mass /= eMufflerHatches.size(); - for (GT_MetaTileEntity_Hatch_OverflowElemental dump : eMufflerHatches) { - if (dump.addOverflowMatter(mass)) { - explodeMultiblock(); - } - } - } + cleanMassEM_EM(mass); } public void cleanHatchContentEM_EM(GT_MetaTileEntity_Hatch_ElementalContainer target) { if (target == null) { return; } - float mass = target.getContainerHandler().getMass(); - if (mass > 0) { - if (eMufflerHatches.size() < 1) { - explodeMultiblock(); - } - mass /= eMufflerHatches.size(); - for (GT_MetaTileEntity_Hatch_OverflowElemental dump : eMufflerHatches) { - if (dump.addOverflowMatter(mass)) { - explodeMultiblock(); - } - } - } + cleanMassEM_EM(target.getContainerHandler().getMass()); } public void cleanStackEM_EM(cElementalInstanceStack target) { @@ -2059,14 +1998,20 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt public void cleanMassEM_EM(float mass) { if (mass > 0) { if (eMufflerHatches.size() < 1) { + TecTech.anomalyHandler.addAnomaly(getBaseMetaTileEntity(),mass); explodeMultiblock(); + return; } mass /= eMufflerHatches.size(); + boolean shouldExplode=false; for (GT_MetaTileEntity_Hatch_OverflowElemental dump : eMufflerHatches) { if (dump.addOverflowMatter(mass)) { - explodeMultiblock(); + shouldExplode=true; } } + if(shouldExplode){ + explodeMultiblock(); + } } } @@ -2080,19 +2025,8 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt mass += map.getMass(); } } - - if (mass > 0) { - if (eMufflerHatches.size() < 1) { - explodeMultiblock(); - } - mass /= eMufflerHatches.size(); - for (GT_MetaTileEntity_Hatch_OverflowElemental dump : eMufflerHatches) { - if (dump.addOverflowMatter(mass)) { - explodeMultiblock(); - } - } - } outputEM = null; + cleanMassEM_EM(mass); } //endregion @@ -2668,48 +2602,4 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt } return false; } - - public static void run() { - try { - adderMethodMap.put("addToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addToMachineList", IGregTechTileEntity.class, int.class)); - adderMethodMap.put("addClassicToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addClassicToMachineList", IGregTechTileEntity.class, int.class)); - adderMethodMap.put("addElementalToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addElementalToMachineList", IGregTechTileEntity.class, int.class)); - adderMethodMap.put("addMufflerToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addMufflerToMachineList", IGregTechTileEntity.class, int.class)); - adderMethodMap.put("addClassicMufflerToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addClassicMufflerToMachineList", IGregTechTileEntity.class, int.class)); - adderMethodMap.put("addElementalMufflerToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addElementalMufflerToMachineList", IGregTechTileEntity.class, int.class)); - adderMethodMap.put("addInputToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addInputToMachineList", IGregTechTileEntity.class, int.class)); - adderMethodMap.put("addOutputToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addOutputToMachineList", IGregTechTileEntity.class, int.class)); - adderMethodMap.put("addEnergyInputToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addEnergyInputToMachineList", IGregTechTileEntity.class, int.class)); - adderMethodMap.put("addDynamoToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addDynamoToMachineList", IGregTechTileEntity.class, int.class)); - adderMethodMap.put("addEnergyIOToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addEnergyIOToMachineList", IGregTechTileEntity.class, int.class)); - adderMethodMap.put("addElementalInputToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addElementalInputToMachineList", IGregTechTileEntity.class, int.class)); - adderMethodMap.put("addElementalOutputToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addElementalOutputToMachineList", IGregTechTileEntity.class, int.class)); - adderMethodMap.put("addClassicInputToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addClassicInputToMachineList", IGregTechTileEntity.class, int.class)); - adderMethodMap.put("addClassicOutputToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addClassicOutputToMachineList", IGregTechTileEntity.class, int.class)); - adderMethodMap.put("addParametrizerToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addParametrizerToMachineList", IGregTechTileEntity.class, int.class)); - adderMethodMap.put("addUncertainToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addUncertainToMachineList", IGregTechTileEntity.class, int.class)); - adderMethodMap.put("addMaintenanceToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addMaintenanceToMachineList", IGregTechTileEntity.class, int.class)); - adderMethodMap.put("addClassicMaintenanceToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addClassicMaintenanceToMachineList", IGregTechTileEntity.class, int.class)); - adderMethodMap.put("addDataConnectorToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addDataConnectorToMachineList", IGregTechTileEntity.class, int.class)); - adderMethod = GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addThing", String.class, IGregTechTileEntity.class, int.class); - } catch (NoSuchMethodException e) { - if (DEBUG_MODE) { - e.printStackTrace(); - } - } - } - - //CALLBACK from hatches adders - public boolean addThing(String methodName, IGregTechTileEntity igt, int casing) { - try { - return (boolean) adderMethodMap.get(methodName).invoke(this, igt, casing); - } catch (InvocationTargetException | IllegalAccessException e) { - if (DEBUG_MODE) { - e.printStackTrace(); - } - } - return false; - } - - //endregion } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/IHatchAdder.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/IHatchAdder.java new file mode 100644 index 0000000000..b695472012 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/IHatchAdder.java @@ -0,0 +1,8 @@ +package com.github.technus.tectech.thing.metaTileEntity.multi.base; + + +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; + +public interface IHatchAdder { + Boolean apply(IGregTechTileEntity iGregTechTileEntity, Short aShort); +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/INameFunction.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/INameFunction.java new file mode 100644 index 0000000000..1c2a8bd477 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/INameFunction.java @@ -0,0 +1,5 @@ +package com.github.technus.tectech.thing.metaTileEntity.multi.base; + +public interface INameFunction<T extends GT_MetaTileEntity_MultiblockBase_EM>{ + String apply(T t, Parameters.IParameter iParameter); +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/IStatusFunction.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/IStatusFunction.java new file mode 100644 index 0000000000..0c7616093a --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/IStatusFunction.java @@ -0,0 +1,5 @@ +package com.github.technus.tectech.thing.metaTileEntity.multi.base; + +public interface IStatusFunction<T extends GT_MetaTileEntity_MultiblockBase_EM>{ + LedStatus apply(T t, Parameters.IParameter iParameter); +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/LedStatus.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/LedStatus.java new file mode 100644 index 0000000000..5fce024cfc --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/LedStatus.java @@ -0,0 +1,97 @@ +package com.github.technus.tectech.thing.metaTileEntity.multi.base; + +import com.github.technus.tectech.TecTech; +import net.minecraft.util.EnumChatFormatting; + +import java.util.function.Supplier; + +public enum LedStatus { + STATUS_UNUSED(()->EnumChatFormatting.DARK_GRAY +"Unused",true),// + STATUS_TOO_LOW(()->EnumChatFormatting.BLUE+"Too Low",false),// + STATUS_LOW(()->EnumChatFormatting.AQUA+"Low",true),// + STATUS_WRONG(()->EnumChatFormatting.DARK_PURPLE+"Wrong",false),// + STATUS_OK(()->EnumChatFormatting.GREEN+"Valid",true),// + STATUS_TOO_HIGH(()->EnumChatFormatting.RED+"Too High",false),// + STATUS_HIGH(()->EnumChatFormatting.GOLD+"High",true),// + STATUS_UNDEFINED(()->EnumChatFormatting.GRAY+"Unknown",false), + STATUS_NEUTRAL(()->EnumChatFormatting.WHITE+"Neutral",true),// + STATUS_WTF(()->{ + return LedStatus.values()[TecTech.RANDOM.nextInt(9)].name.get(); + },false);// + + public final Supplier<String> name; + public final boolean isOk; + + LedStatus(Supplier<String> name, boolean ok){ + this.name=name; + this.isOk=ok; + } + + public byte getOrdinalByte(){ + return (byte)ordinal(); + } + + public static LedStatus getStatus(byte value){ + try{ + return LedStatus.values()[value]; + }catch (Exception e){ + return STATUS_UNDEFINED; + } + } + + public static LedStatus[] makeArray(int count,LedStatus defaultValue){ + LedStatus[] statuses=new LedStatus[count]; + for (int i = 0; i < count; i++) { + statuses[i]=defaultValue; + } + return statuses; + } + + public static LedStatus fromLimitsInclusiveOuterBoundary(double value, double min,double low, double high, double max, double... excludedNumbers){ + if(value<min) return STATUS_TOO_LOW; + if(value>max) return STATUS_TOO_HIGH; + + if(value<low) return STATUS_LOW; + if(value>high) return STATUS_HIGH; + for (double val : excludedNumbers) { + if(val==value) return STATUS_WRONG; + } + if(Double.isNaN(value)) return STATUS_WRONG; + return STATUS_UNDEFINED; + } + + public static LedStatus fromLimitsExclusiveOuterBoundary(double value, double min,double low, double high,double max, double... excludedNumbers){ + if(value<=min) return STATUS_TOO_LOW; + if(value>=max) return STATUS_TOO_HIGH; + + if(value<low) return STATUS_LOW; + if(value>high) return STATUS_HIGH; + for (double val : excludedNumbers) { + if(val==value) return STATUS_WRONG; + } + if(Double.isNaN(value)) return STATUS_WRONG; + return STATUS_OK; + } + + public static LedStatus fromLimitsInclusiveBoundary(double value, double min, double max, double... excludedNumbers){ + if(value<min) return STATUS_TOO_LOW; + if(value>max) return STATUS_TOO_HIGH; + + for (double val : excludedNumbers) { + if(val==value) return STATUS_WRONG; + } + if(Double.isNaN(value)) return STATUS_WRONG; + return STATUS_OK; + } + + public static LedStatus fromLimitsExclusiveBoundary(double value, double min, double max, double... excludedNumbers){ + if(value<=min) return STATUS_TOO_LOW; + if(value>=max) return STATUS_TOO_HIGH; + + for (double val : excludedNumbers) { + if(val==value) return STATUS_WRONG; + } + if(Double.isNaN(value)) return STATUS_WRONG; + return STATUS_OK; + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/Parameters.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/Parameters.java new file mode 100644 index 0000000000..23250a5b02 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/Parameters.java @@ -0,0 +1,334 @@ +package com.github.technus.tectech.thing.metaTileEntity.multi.base; + +import java.util.ArrayList; + +/** + * Instantiate parameters as field in parametersInstantiation_EM(); + */ +public class Parameters { + private static final IStatusFunction LED_STATUS_FUNCTION_DEFAULT = (b, p)->LedStatus.STATUS_UNDEFINED; + private static final INameFunction NAME_FUNCTION_DEFAULT= (b, p)->"Undefined"; + + final Group[] groups = new Group[10]; + + double[] iParamsIn = new double[20];//number I from parametrizers + double[] iParamsOut = new double[20];//number O to parametrizers + final ArrayList<Group.ParameterIn> parameterInArrayList =new ArrayList<>(); + final ArrayList<Group.ParameterOut> parameterOutArrayList =new ArrayList<>(); + + //package private for use in gui + LedStatus[] eParamsInStatus = LedStatus.makeArray(20,LedStatus.STATUS_UNUSED);//LED status for I + LedStatus[] eParamsOutStatus = LedStatus.makeArray(20,LedStatus.STATUS_UNUSED);//LED status for O + + double getIn(int hatchNo,int parameterId){ + return iParamsIn[hatchNo+10*parameterId]; + } + + double getOut(int hatchNo,int parameterId){ + return iParamsOut[hatchNo+10*parameterId]; + } + + LedStatus getStatusIn(int hatchNo,int parameterId){ + return eParamsInStatus[hatchNo+10*parameterId]; + } + + LedStatus getStatusOut(int hatchNo,int parameterId){ + return eParamsOutStatus[hatchNo+10*parameterId]; + } + + private final GT_MetaTileEntity_MultiblockBase_EM parent; + + Parameters(GT_MetaTileEntity_MultiblockBase_EM parent){ + this.parent=parent; + } + + public boolean trySetParameters(int hatch,double parameter0,double parameter1){ + Group p=groups[hatch]; + if(parent.mMaxProgresstime<=0 || (p!=null && p.updateWhileRunning)){ + iParamsIn[hatch]=parameter0; + iParamsIn[hatch+10]=parameter1; + return true; + } + return false; + } + + public void setToDefaults(int hatch,boolean defaultIn, boolean defaultOut) { + Group p= groups[hatch]; + if (p == null) { + if (defaultIn) { + iParamsIn[hatch] = 0; + iParamsIn[hatch + 10] = 0; + } + if (defaultOut) { + iParamsOut[hatch] = 0; + iParamsOut[hatch + 10] = 0; + } + } else { + p.setToDefaults(defaultIn,defaultOut); + } + } + + public void setToDefaults(boolean defaultIn, boolean defaultOut){ + for (int hatch=0;hatch<10;hatch++) { + setToDefaults(hatch,defaultIn,defaultOut); + } + } + + public void ClearDefinitions(){ + parameterInArrayList.clear(); + parameterOutArrayList.clear(); + for(int i = 0; i< groups.length; i++){ + groups[i]=null; + } + } + + public void removeGroup(Group group){ + if(group==groups[group.hatchNo]){ + removeGroup(group.hatchNo); + }else{ + throw new IllegalArgumentException("Group does not exists in this parametrization!"); + } + } + + public void removeGroup(int hatchNo){ + Group hatch=groups[hatchNo]; + if(hatch!=null){ + for (Group.ParameterOut p:hatch.parameterOut) { + parameterOutArrayList.remove(p); + } + for (Group.ParameterIn p:hatch.parameterIn) { + parameterInArrayList.remove(p); + } + groups[hatchNo]=null; + } + } + + public Group getGroup(int hatchNo, boolean updateWhileRunning){ + return groups[hatchNo]!=null?groups[hatchNo]:new Group( hatchNo, updateWhileRunning); + } + + public Group getGroup(int hatchNo){ + return groups[hatchNo]!=null?groups[hatchNo]:new Group( hatchNo, false); + } + + public interface IParameter{ + double get(); + double getDefault(); + void updateStatus(); + LedStatus getStatus(boolean update); + int id(); + int hatchId(); + int parameterId(); + String getBrief(); + } + + /** + * most likely used locally in parametersInstantiation_EM() + */ + public class Group { + private final int hatchNo; + final ParameterIn[] parameterIn =new ParameterIn[2]; + final ParameterOut[] parameterOut =new ParameterOut[2]; + public boolean updateWhileRunning; + + private Group(int hatchNo, boolean updateWhileRunning){ + if(hatchNo<0 || hatchNo>=10){ + throw new IllegalArgumentException("Hatch id must be in 0 to 9 range"); + } + this.hatchNo=hatchNo; + this.updateWhileRunning=updateWhileRunning; + groups[hatchNo]=this; + } + + public ParameterIn makeInParameter(int paramID, double defaultValue, INameFunction name, IStatusFunction status){ + return new ParameterIn(paramID, defaultValue,name, status); + } + + public ParameterOut makeOutParameter(int paramID, double defaultValue, INameFunction name, IStatusFunction status){ + return new ParameterOut(paramID, defaultValue, name, status); + } + + public void setToDefaults(boolean defaultIn, boolean defaultOut) { + if(defaultIn){ + if (this.parameterIn[0] != null) { + this.parameterIn[0].setDefault(); + } else { + iParamsIn[hatchNo] = 0; + } + if (this.parameterIn[1] != null) { + this.parameterIn[1].setDefault(); + } else { + iParamsIn[hatchNo + 10] = 0; + } + } + if(defaultOut){ + if (this.parameterOut[0] != null) { + this.parameterOut[0].setDefault(); + } else { + iParamsOut[hatchNo] = 0; + } + if (this.parameterOut[1] != null) { + this.parameterOut[1].setDefault(); + } else { + iParamsOut[hatchNo + 10] = 0; + } + } + } + + /** + * Make a field out of this... + */ + public class ParameterOut implements IParameter { + public final int id; + public final double defaultValue; + IStatusFunction status; + INameFunction name; + + private ParameterOut(int paramID, double defaultValue, INameFunction name, IStatusFunction status){ + this.name= name==null?NAME_FUNCTION_DEFAULT:name; + if(paramID<0 || paramID>2){ + throw new IllegalArgumentException("Parameter id must be in 0 to 1 range"); + } + if(parameterOut[paramID]!=null){ + throw new IllegalArgumentException("Parameter id already occupied"); + } + this.id=hatchNo+10*paramID; + this.defaultValue=defaultValue; + this.status = status==null?LED_STATUS_FUNCTION_DEFAULT:status; + parameterOutArrayList.add(this); + parameterOut[paramID]=this; + } + + void setDefault() { + set(defaultValue); + } + + @Override + public double get(){ + return iParamsOut[id]; + } + + @Override + public double getDefault() { + return defaultValue; + } + + public void set(double value){ + iParamsOut[id]=value; + } + + @SuppressWarnings("unchecked") + @Override + public void updateStatus(){ + eParamsOutStatus[id]=status.apply(parent,this); + } + + @Override + public LedStatus getStatus(boolean update){ + if(update){ + updateStatus(); + } + return eParamsOutStatus[id]; + } + + @Override + public String getBrief(){ + return name.apply(parent,this); + } + + @Override + public int id() { + return id; + } + + @Override + public int hatchId() { + return id%10; + } + + @Override + public int parameterId() { + return id/10; + } + } + + /** + * Make a field out of this... + */ + public class ParameterIn implements IParameter { + public final int id; + public final double defaultValue; + IStatusFunction status; + INameFunction name; + + private ParameterIn(int paramID, double defaultValue, INameFunction name, IStatusFunction status){ + this.name= name==null?NAME_FUNCTION_DEFAULT:name; + this.id=hatchNo+10*paramID; + if(paramID<0 || paramID>2){ + throw new IllegalArgumentException("Parameter id must be in 0 to 1 range"); + } + if(parameterIn[paramID]!=null){ + throw new IllegalArgumentException("Parameter id already occupied"); + } + this.defaultValue=defaultValue; + this.status = status==null?LED_STATUS_FUNCTION_DEFAULT:status; + parameterInArrayList.add(this); + parameterIn[paramID]=this; + } + + void setDefault() { + set(defaultValue); + } + + @Override + public double get(){ + return iParamsIn[id]; + } + + void set(double value){ + iParamsIn[id]=value; + } + + @Override + public double getDefault() { + return defaultValue; + } + + @SuppressWarnings("unchecked") + @Override + public void updateStatus(){ + eParamsInStatus[id]=status.apply(parent,this); + } + + @Override + public LedStatus getStatus(boolean update){ + if(update){ + updateStatus(); + } + return eParamsInStatus[id]; + } + + @Override + public String getBrief(){ + return name.apply(parent,this); + } + + + @Override + public int id() { + return id; + } + + @Override + public int hatchId() { + return id%10; + } + + @Override + public int parameterId() { + return id/10; + } + } + } +} + diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/network/RotationPacketDispatcher.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/network/RotationPacketDispatcher.java deleted file mode 100644 index 29a8f0bcf6..0000000000 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/network/RotationPacketDispatcher.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.github.technus.tectech.thing.metaTileEntity.multi.base.network; - -import eu.usrv.yamcore.network.PacketDispatcher; - -import static com.github.technus.tectech.Reference.MODID; - -public class RotationPacketDispatcher extends PacketDispatcher { - public static RotationPacketDispatcher INSTANCE; - - public RotationPacketDispatcher() { - super(MODID); - INSTANCE = this; - registerPackets(); - } - - @Override - public void registerPackets() { - registerMessage(RotationMessage.ServerHandler.class, RotationMessage.RotationQuery.class); - registerMessage(RotationMessage.ClientHandler.class, RotationMessage.RotationData.class); - } -} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Centrifuge.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Centrifuge.java index 4b7d41494b..56f535f32a 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Centrifuge.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Centrifuge.java @@ -4,24 +4,52 @@ import com.github.technus.tectech.TecTech; import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalInstanceStackMap; import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.cElementalInstanceStack; import com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.atom.dAtomDefinition; -import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; import com.github.technus.tectech.thing.metaTileEntity.multi.base.MultiblockControl; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.INameFunction; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.Parameters; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.IStatusFunction; -import java.util.ArrayList; import java.util.Arrays; -import java.util.Comparator; import static com.github.technus.tectech.CommonValues.V; import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; +import static com.github.technus.tectech.thing.metaTileEntity.multi.base.LedStatus.*; /** * Created by danie_000 on 24.12.2017. */ -public class Behaviour_Centrifuge extends GT_MetaTileEntity_EM_machine.Behaviour { - private final float radius, maxRPM, maxRCF, maxForce, maxCapacity; +public class Behaviour_Centrifuge implements GT_MetaTileEntity_EM_machine.IBehaviour { private final byte tier; - private final static String[] DESCRIPTION_I =new String[]{"RPM Input","Fraction Count Input"}; - private final static String[] DESCRIPTION_O =new String[]{"RPM Setting","RCF Setting","Radius [mm]","Max RPM","Max Force [eV/c^2 * m/s]","Max Capacity [eV/c^2]","Max Power Usage[EU/t]","Max Recipe Rime [tick]"}; + private float radius, maxRPM, maxRCF, maxForce, maxCapacity; + private Parameters.Group.ParameterIn settingRPM, settingFraction; + private final static INameFunction<GT_MetaTileEntity_EM_machine> rpmName= (gt_metaTileEntity_em_machine, iParameter) -> "RPM Setting"; + private final IStatusFunction<GT_MetaTileEntity_EM_machine> rpmStatus= (gt_metaTileEntity_em_machine, iParameter) -> { + double v=iParameter.get(); + if(Double.isNaN(v)){ + return STATUS_WRONG; + } + if (v <=0) { + return STATUS_TOO_LOW; + }else if (v>maxRPM){ + return STATUS_TOO_HIGH; + } + return STATUS_OK; + }; + private final static INameFunction<GT_MetaTileEntity_EM_machine> fractionName= (gt_metaTileEntity_em_machine, iParameter) -> "Fraction Count"; + private static final IStatusFunction<GT_MetaTileEntity_EM_machine> fractionStatus= (gt_metaTileEntity_em_machine, iParameter) -> { + double v=iParameter.get(); + if(Double.isNaN(v)){ + return STATUS_WRONG; + } + v=(int)v; + if (v <= 1) { + return STATUS_TOO_LOW; + }else if (v>6){ + return STATUS_TOO_HIGH; + } + return STATUS_OK; + }; + //private final static String[] DESCRIPTION_O =new String[]{"RPM Setting","RCF Setting","Radius [mm]","Max RPM","Max Force [eV/c^2 * m/s]","Max Capacity [eV/c^2]","Max Power Usage[EU/t]","Max Recipe Rime [tick]"}; private static final double[/*tier+5*/][/*outputHatches+2*/] MIXING_FACTORS =new double[][]{ {.45,.85,.95,1,1,}, @@ -45,91 +73,40 @@ public class Behaviour_Centrifuge extends GT_MetaTileEntity_EM_machine.Behaviour maxCapacity = maxSafeMass * 4f * radius;// eV/c^2 } - @Override - protected void getFullLedDescriptionIn(ArrayList<String> baseDescr, int hatchNo, int paramID) { - if(hatchNo==0) { - baseDescr.add(DESCRIPTION_I[(hatchNo << 1) + paramID]); - } + private double getRCF(double RPM) { + return RPM * RPM * radius * 0.001118; } - @Override - protected void getFullLedDescriptionOut(ArrayList<String> baseDescr, int hatchNo, int paramID) { - if(hatchNo<=2) { - baseDescr.add(DESCRIPTION_O[(hatchNo<<1)+paramID]); + private void addRandomly(cElementalInstanceStack me, cElementalInstanceStackMap[] toThis, int fractionCount) { + long amountPerFraction = me.amount / fractionCount; + cElementalInstanceStack[] stacks = new cElementalInstanceStack[fractionCount]; + for (int i = 0; i < fractionCount; i++) { + stacks[i] = me.clone(); + stacks[i].amount = amountPerFraction; + toThis[i].putReplace(stacks[i]); + } + int remainingAmount = (int) (me.amount % fractionCount); + while (remainingAmount > 0) { + int amountToAdd = TecTech.RANDOM.nextInt(remainingAmount) + 1; + stacks[TecTech.RANDOM.nextInt(fractionCount)].amount += amountToAdd; + remainingAmount -= amountToAdd; } } @Override - public boolean setAndCheckParametersOutAndStatuses(GT_MetaTileEntity_EM_machine te, double[] parametersToCheckAndFix) { - boolean check=true; - - te.setParameterOut(1, 0, radius * 1000);//in mm - te.setParameterOut(1, 1, maxRPM); - te.setParameterOut(2, 0, maxForce * 9.80665);// (eV/c^2 * m/s) - te.setParameterOut(2, 1, maxCapacity);// eV/c^2 - - for(int i=4;i<=9;i++) { - te.setStatusOfParameterOut(i, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_UNUSED); - te.setStatusOfParameterOut(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_UNUSED); - } - for(int i=1;i<=3;i++) { - te.setStatusOfParameterIn(i, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_UNUSED); - te.setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_UNUSED); - } - - double RPM = parametersToCheckAndFix[0]; - if (RPM > maxRPM) { - te.setStatusOfParameterIn(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_HIGH); - te.setParameterOut(0, 0, maxRPM);//rpm - te.setParameterOut(0, 1, maxRCF);//rcf - check=false; - } else if (RPM > maxRPM / 3f * 2f) { - te.setStatusOfParameterIn(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_HIGH); - } else if (RPM > maxRPM / 3f) { - te.setStatusOfParameterIn(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_OK); - } else if (RPM > 0) { - te.setStatusOfParameterIn(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_LOW); - } else if (RPM <= 0) { - te.setStatusOfParameterIn(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_LOW); - te.setParameterOut(0, 0, 0);//rpm - te.setParameterOut(0, 1, 0);//rcf - check=false; - } else { - te.setStatusOfParameterIn(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_WRONG); - te.setParameterOut(0, 0, 0);//rpm - te.setParameterOut(0, 1, 0);//rcf - check=false; - } - - if(check) { - te.setParameterOut(0, 0, RPM); - te.setParameterOut(0, 1, getRCF(RPM)); - } - - double fractionCount = parametersToCheckAndFix[1]; - if (fractionCount > 6) { - parametersToCheckAndFix[1] = 6; - te.setStatusOfParameterIn(0, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_HIGH); - check=false; - } else if (fractionCount >= 2) { - te.setStatusOfParameterIn(0, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_OK); - } else if (fractionCount < 2) { - parametersToCheckAndFix[1] = 2; - te.setStatusOfParameterIn(0, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_LOW); - check=false; - } else { - te.setStatusOfParameterIn(0, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_WRONG); - check=false; - } - - te.setParameterOut(3,0,(int) (Math.pow(parametersToCheckAndFix[0] / maxRPM, 3f) * V[tier]));//max eut - te.setParameterOut(3,1,(int) (20 * (fractionCount - 1)));//max time + public void parametersInstantiation(GT_MetaTileEntity_EM_machine te, Parameters parameters) { + Parameters.Group hatch1=parameters.getGroup(7); + settingRPM=hatch1.makeInParameter(0,0,rpmName,rpmStatus); + settingFraction=hatch1.makeInParameter(1,2,fractionName,fractionStatus); + } - return check; + @Override + public boolean checkParametersInAndSetStatuses(GT_MetaTileEntity_EM_machine te, Parameters parameters) { + return settingRPM.getStatus(true).isOk && settingFraction.getStatus(true).isOk; } @Override - public MultiblockControl<cElementalInstanceStackMap[]> process(cElementalInstanceStackMap[] inputs, double[] checkedAndFixedParameters) { + public MultiblockControl<cElementalInstanceStackMap[]> process(cElementalInstanceStackMap[] inputs, GT_MetaTileEntity_EM_machine te, Parameters parameters) { cElementalInstanceStackMap input = inputs[0]; if (input == null || input.isEmpty()) return null;//nothing in only valid input @@ -154,11 +131,11 @@ public class Behaviour_Centrifuge extends GT_MetaTileEntity_EM_machine.Behaviour inputMass = Math.abs(input.getMass()); - double RCF = getRCF(checkedAndFixedParameters[0]); + double RCF = getRCF(settingRPM.get()); if (inputMass * RCF > maxForce) return new MultiblockControl<>(excessMass);//AND THEN IT EXPLODES // how many output hatches to use - int fractionCount = (int) checkedAndFixedParameters[1]; + int fractionCount = (int) settingFraction.get(); cElementalInstanceStackMap[] outputs = new cElementalInstanceStackMap[fractionCount]; for (int i = 0; i < fractionCount; i++) { outputs[i] = new cElementalInstanceStackMap(); @@ -170,7 +147,7 @@ public class Behaviour_Centrifuge extends GT_MetaTileEntity_EM_machine.Behaviour TecTech.LOGGER.info("mixingFactor "+mixingFactor); } - int mEut = (int) (Math.pow(checkedAndFixedParameters[0] / maxRPM, 3f) * V[tier]); + int mEut = (int) (Math.pow(settingRPM.get() / maxRPM, 3f) * V[tier]); mEut = Math.max(mEut, 512); mEut = -mEut; int mTicks = (int) (20 * (inputMass / maxCapacity) * (fractionCount - 1)); @@ -180,15 +157,12 @@ public class Behaviour_Centrifuge extends GT_MetaTileEntity_EM_machine.Behaviour //take all from hatch handler and put into new map - this takes from hatch to inner data storage stacks = input.takeAllToNewMap().values();//cleanup stacks if (stacks.length > 1) { - Arrays.sort(stacks, new Comparator<cElementalInstanceStack>() { - @Override - public int compare(cElementalInstanceStack o1, cElementalInstanceStack o2) { - float m1 = o1.definition.getMass(); - float m2 = o2.definition.getMass(); - if (m1 < m2) return -1; - if (m1 > m2) return 1; - return o1.compareTo(o2); - } + Arrays.sort(stacks, (o1, o2) -> { + float m1 = o1.definition.getMass(); + float m2 = o2.definition.getMass(); + if (m1 < m2) return -1; + if (m1 > m2) return 1; + return o1.compareTo(o2); }); double absMassPerOutput = 0;//"volume" @@ -257,24 +231,4 @@ public class Behaviour_Centrifuge extends GT_MetaTileEntity_EM_machine.Behaviour } return new MultiblockControl<>(outputs, mEut, 1, 0, 10000, mTicks, 0, excessMass); } - - private double getRCF(double RPM) { - return RPM * RPM * radius * 0.001118; - } - - private void addRandomly(cElementalInstanceStack me, cElementalInstanceStackMap[] toThis, int fractionCount) { - long amountPerFraction = me.amount / fractionCount; - cElementalInstanceStack[] stacks = new cElementalInstanceStack[fractionCount]; - for (int i = 0; i < fractionCount; i++) { - stacks[i] = me.clone(); - stacks[i].amount = amountPerFraction; - toThis[i].putReplace(stacks[i]); - } - int remainingAmount = (int) (me.amount % fractionCount); - while (remainingAmount > 0) { - int amountToAdd = TecTech.RANDOM.nextInt(remainingAmount) + 1; - stacks[TecTech.RANDOM.nextInt(fractionCount)].amount += amountToAdd; - remainingAmount -= amountToAdd; - } - } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Electrolyzer.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Electrolyzer.java index 9fe54588bc..df21feb9f2 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Electrolyzer.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Electrolyzer.java @@ -2,23 +2,29 @@ package com.github.technus.tectech.thing.metaTileEntity.multi.em_machine; import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalInstanceStackMap; import com.github.technus.tectech.thing.metaTileEntity.multi.base.MultiblockControl; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.Parameters; /** * Created by danie_000 on 24.12.2017. */ -public class Behaviour_Electrolyzer extends GT_MetaTileEntity_EM_machine.Behaviour { +public class Behaviour_Electrolyzer implements GT_MetaTileEntity_EM_machine.IBehaviour { final int tier; public Behaviour_Electrolyzer(int tier){ this.tier=tier; } @Override - public boolean setAndCheckParametersOutAndStatuses(GT_MetaTileEntity_EM_machine te, double[] parametersToCheckAndFix) { + public void parametersInstantiation(GT_MetaTileEntity_EM_machine te, Parameters parameters) { + + } + + @Override + public boolean checkParametersInAndSetStatuses(GT_MetaTileEntity_EM_machine te, Parameters parameters) { return false; } @Override - public MultiblockControl<cElementalInstanceStackMap[]> process(cElementalInstanceStackMap[] inputs, double[] checkedAndFixedParameters) { + public MultiblockControl<cElementalInstanceStackMap[]> process(cElementalInstanceStackMap[] inputs, GT_MetaTileEntity_EM_machine te, Parameters parameters) { return null; } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_ElectromagneticSeparator.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_ElectromagneticSeparator.java index 8c912dd38d..6d95900af0 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_ElectromagneticSeparator.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_ElectromagneticSeparator.java @@ -4,26 +4,83 @@ import com.github.technus.tectech.TecTech; import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalInstanceStackMap; import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.cElementalInstanceStack; import com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.atom.dAtomDefinition; -import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; import com.github.technus.tectech.thing.metaTileEntity.multi.base.MultiblockControl; - -import java.util.ArrayList; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.INameFunction; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.Parameters; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.IStatusFunction; import static com.github.technus.tectech.CommonValues.V; +import static com.github.technus.tectech.thing.metaTileEntity.multi.base.LedStatus.*; /** * Created by danie_000 on 24.12.2017. */ -public class Behaviour_ElectromagneticSeparator extends GT_MetaTileEntity_EM_machine.Behaviour { +public class Behaviour_ElectromagneticSeparator implements GT_MetaTileEntity_EM_machine.IBehaviour { private final byte tier; - private final int ticks; - private final byte precisionFull; - private final byte precisionMinimal; - private final float maxCapacity; - private final long maxCharge; - private final int offsetMax; - private final static String[] DESCRIPTION_I =new String[]{"Full Precision Input [e/3]","Minimal Precision Input [e/3]","Offset Input [e/3]",null}; - private final static String[] DESCRIPTION_O =new String[]{"Full Precision Limit [e/3]","Minimal Precision Limit [e/3]","Offset Limit [e/3]",null,"Max Charge [e/3]","Max Capacity [eV/c^2]","Max Power Usage[EU/t]","Max Recipe Rime [tick]"}; + private int ticks; + private byte precisionFull,precisionMinimal; + private float maxCapacity; + private long maxCharge; + private int offsetMax; + private Parameters.Group.ParameterIn fullSetting,minimalSetting,offsetSetting; + private final static INameFunction<GT_MetaTileEntity_EM_machine> fullName= (gt_metaTileEntity_em_machine, iParameter) -> "Full Precision Input [e/3]"; + private final IStatusFunction<GT_MetaTileEntity_EM_machine> fullStatus= (gt_metaTileEntity_em_machine, iParameter) -> { + double v=iParameter.get(); + if(Double.isNaN(v)){ + return STATUS_WRONG; + } + v=(int)v; + if(Double.isInfinite(v) && v>0) { + return STATUS_TOO_HIGH; + }else if(v>precisionFull){ + return STATUS_HIGH; + }else if(v<precisionFull){ + return STATUS_TOO_LOW; + } + return STATUS_OK; + }; + private final static INameFunction<GT_MetaTileEntity_EM_machine> minimalName= (gt_metaTileEntity_em_machine, iParameter) -> "Minimal Precision Input [e/3]"; + private final IStatusFunction<GT_MetaTileEntity_EM_machine> minimalStatus= (gt_metaTileEntity_em_machine, iParameter) -> { + double minimal=iParameter.get(); + double full=fullSetting.get(); + if(Double.isInfinite(minimal) && minimal>0) { + return STATUS_TOO_HIGH; + }else if(minimal>precisionMinimal){ + if(minimal>full){ + return STATUS_TOO_HIGH; + }else { + return STATUS_HIGH; + } + }else if(minimal==precisionMinimal){ + if(minimal>full){ + return STATUS_TOO_HIGH; + }else { + return STATUS_OK; + } + }else if(minimal<precisionMinimal){ + return STATUS_TOO_LOW; + }else { + return STATUS_WRONG; + } + }; + private final static INameFunction<GT_MetaTileEntity_EM_machine> offsetName= (gt_metaTileEntity_em_machine, iParameter) -> "Offset Input [e/3]"; + private final IStatusFunction<GT_MetaTileEntity_EM_machine> offsetStatus= (gt_metaTileEntity_em_machine, iParameter) -> { + double offset=iParameter.get(); + if(offset>offsetMax){ + return STATUS_TOO_HIGH; + }else if(offset>0){ + return STATUS_HIGH; + }else if(offset==0){ + return STATUS_OK; + }else if(offset>=-offsetMax){ + return STATUS_LOW; + }else if(offset<-offsetMax){ + return STATUS_TOO_LOW; + }else { + return STATUS_WRONG; + } + }; + //private final static String[] DESCRIPTION_O =new String[]{"Full Precision Limit [e/3]","Minimal Precision Limit [e/3]","Offset Limit [e/3]",null,"Max Charge [e/3]","Max Capacity [eV/c^2]","Max Power Usage[EU/t]","Max Recipe Rime [tick]"}; public Behaviour_ElectromagneticSeparator(int desiredTier){ tier=(byte) desiredTier; @@ -69,113 +126,21 @@ public class Behaviour_ElectromagneticSeparator extends GT_MetaTileEntity_EM_mac } @Override - protected void getFullLedDescriptionIn(ArrayList<String> baseDescr, int hatchNo, int paramID) { - if(hatchNo<=1) { - String desc=DESCRIPTION_I[(hatchNo << 1) + paramID]; - if(desc!=null){ - baseDescr.add(desc); - } - } - } - - @Override - protected void getFullLedDescriptionOut(ArrayList<String> baseDescr, int hatchNo, int paramID) { - if(hatchNo<=3){ - String desc=DESCRIPTION_O[(hatchNo<<1)+paramID]; - if(desc!=null){ - baseDescr.add(desc); - } - } + public void parametersInstantiation(GT_MetaTileEntity_EM_machine te, Parameters parameters) { + Parameters.Group hatch1=parameters.getGroup(7); + fullSetting=hatch1.makeInParameter(0,0,fullName,fullStatus); + minimalSetting=hatch1.makeInParameter(1,2,minimalName,minimalStatus); + Parameters.Group hatch2=parameters.getGroup(8); + offsetSetting=hatch2.makeInParameter(0,0,offsetName,offsetStatus); } @Override - public boolean setAndCheckParametersOutAndStatuses(GT_MetaTileEntity_EM_machine te, double[] parametersToCheckAndFix) { - boolean check=true; - - te.setParameterOut(0,0,precisionFull); - te.setParameterOut(0,1,precisionMinimal); - te.setParameterOut(1,0,offsetMax); - te.setStatusOfParameterOut(1,1,GT_MetaTileEntity_MultiblockBase_EM.STATUS_UNUSED); - te.setParameterOut(2,0,maxCharge); - te.setParameterOut(2,1,maxCapacity); - te.setParameterOut(3,0,V[tier]); - te.setParameterOut(3,1,ticks); - - for(int i=4;i<=9;i++) { - te.setStatusOfParameterOut(i, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_UNUSED); - te.setStatusOfParameterOut(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_UNUSED); - } - te.setStatusOfParameterIn(1, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_UNUSED); - for(int i=2;i<=3;i++) { - te.setStatusOfParameterIn(i, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_UNUSED); - te.setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_UNUSED); - } - - double full=parametersToCheckAndFix[0]; - if(Double.isInfinite(full) && full>0) { - te.setStatusOfParameterIn(0,0,GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_HIGH); - check=false; - }else if(full>precisionFull){ - te.setStatusOfParameterIn(0,0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_HIGH); - }else if(full==precisionFull){ - te.setStatusOfParameterIn(0,0,GT_MetaTileEntity_MultiblockBase_EM.STATUS_OK); - }else if(full<precisionFull){ - te.setStatusOfParameterIn(0,0,GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_LOW); - check=false; - }else { - te.setStatusOfParameterIn(0,0,GT_MetaTileEntity_MultiblockBase_EM.STATUS_WRONG); - check=false; - } - - double minimal=parametersToCheckAndFix[1]; - if(Double.isInfinite(minimal) && minimal>0) { - te.setStatusOfParameterIn(0,1,GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_HIGH); - check=false; - }else if(minimal>precisionMinimal){ - if(minimal>full){ - te.setStatusOfParameterIn(0,1,GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_HIGH); - check=false; - }else { - te.setStatusOfParameterIn(0,1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_HIGH); - } - }else if(minimal==precisionMinimal){ - if(minimal>full){ - te.setStatusOfParameterIn(0,1,GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_HIGH); - check=false; - }else { - te.setStatusOfParameterIn(0,1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_OK); - } - }else if(minimal<precisionMinimal){ - te.setStatusOfParameterIn(0,1,GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_LOW); - check=false; - }else { - te.setStatusOfParameterIn(0,1,GT_MetaTileEntity_MultiblockBase_EM.STATUS_WRONG); - check=false; - } - - double offset=parametersToCheckAndFix[2]; - if(offset>offsetMax){ - te.setStatusOfParameterIn(1,0,GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_HIGH); - check=false; - }else if(offset>0){ - te.setStatusOfParameterIn(1,0,GT_MetaTileEntity_MultiblockBase_EM.STATUS_HIGH); - }else if(offset==0){ - te.setStatusOfParameterIn(1,0,GT_MetaTileEntity_MultiblockBase_EM.STATUS_OK); - }else if(offset>=-offsetMax){ - te.setStatusOfParameterIn(1,0,GT_MetaTileEntity_MultiblockBase_EM.STATUS_LOW); - }else if(offset<-offsetMax){ - te.setStatusOfParameterIn(1,0,GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_LOW); - check=false; - }else { - te.setStatusOfParameterIn(1,0,GT_MetaTileEntity_MultiblockBase_EM.STATUS_WRONG); - check=false; - } - - return check; + public boolean checkParametersInAndSetStatuses(GT_MetaTileEntity_EM_machine te, Parameters parameters) { + return fullSetting.getStatus(true).isOk && minimalSetting.getStatus(true).isOk && offsetSetting.getStatus(true).isOk; } @Override - public MultiblockControl<cElementalInstanceStackMap[]> process(cElementalInstanceStackMap[] inputs, double[] checkedAndFixedParameters) { + public MultiblockControl<cElementalInstanceStackMap[]> process(cElementalInstanceStackMap[] inputs, GT_MetaTileEntity_EM_machine te, Parameters parameters) { cElementalInstanceStackMap input = inputs[0]; if (input == null || input.isEmpty()) return null;//nothing in only valid input @@ -211,9 +176,9 @@ public class Behaviour_ElectromagneticSeparator extends GT_MetaTileEntity_EM_mac outputs[i] = new cElementalInstanceStackMap(); } - double offsetIn=checkedAndFixedParameters[2]; - double precisionFullIn=checkedAndFixedParameters[0]; - double precisionMinimalIn=checkedAndFixedParameters[1]; + double offsetIn=offsetSetting.get(); + double precisionFullIn=fullSetting.get(); + double precisionMinimalIn=minimalSetting.get(); double levelsCountPlus1=precisionFullIn-precisionMinimalIn+1; //take all from hatch handler and put into new map - this takes from hatch to inner data storage diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_PrecisionLaser.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_PrecisionLaser.java index bae032cd9e..cd6f637d61 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_PrecisionLaser.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_PrecisionLaser.java @@ -2,23 +2,29 @@ package com.github.technus.tectech.thing.metaTileEntity.multi.em_machine; import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalInstanceStackMap; import com.github.technus.tectech.thing.metaTileEntity.multi.base.MultiblockControl; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.Parameters; /** * Created by danie_000 on 24.12.2017. */ -public class Behaviour_PrecisionLaser extends GT_MetaTileEntity_EM_machine.Behaviour { +public class Behaviour_PrecisionLaser implements GT_MetaTileEntity_EM_machine.IBehaviour { final int tier; public Behaviour_PrecisionLaser(int tier){ this.tier=tier; } @Override - public boolean setAndCheckParametersOutAndStatuses(GT_MetaTileEntity_EM_machine te, double[] parametersToCheckAndFix) { + public void parametersInstantiation(GT_MetaTileEntity_EM_machine te, Parameters parameters) { + + } + + @Override + public boolean checkParametersInAndSetStatuses(GT_MetaTileEntity_EM_machine te, Parameters parameters) { return false; } @Override - public MultiblockControl<cElementalInstanceStackMap[]> process(cElementalInstanceStackMap[] inputs, double[] checkedAndFixedParameters) { + public MultiblockControl<cElementalInstanceStackMap[]> process(cElementalInstanceStackMap[] inputs, GT_MetaTileEntity_EM_machine te, Parameters parameters) { return null; } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Recycler.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Recycler.java index 4f6d555fdc..6742f99e99 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Recycler.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Recycler.java @@ -2,23 +2,38 @@ package com.github.technus.tectech.thing.metaTileEntity.multi.em_machine; import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalInstanceStackMap; import com.github.technus.tectech.thing.metaTileEntity.multi.base.MultiblockControl; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.Parameters; + +import static com.github.technus.tectech.CommonValues.V; /** * Created by danie_000 on 24.12.2017. */ -public class Behaviour_Recycler extends GT_MetaTileEntity_EM_machine.Behaviour { - final int tier; +public class Behaviour_Recycler implements GT_MetaTileEntity_EM_machine.IBehaviour { + private final int tier; + private final float coeff; public Behaviour_Recycler(int tier){ this.tier=tier; + coeff=(float)(1/Math.pow(2,tier-4)); } @Override - public boolean setAndCheckParametersOutAndStatuses(GT_MetaTileEntity_EM_machine te, double[] parametersToCheckAndFix) { - return false; + public void parametersInstantiation(GT_MetaTileEntity_EM_machine te, Parameters parameters) {} + + @Override + public boolean checkParametersInAndSetStatuses(GT_MetaTileEntity_EM_machine te, Parameters parameters) { + return true; } @Override - public MultiblockControl<cElementalInstanceStackMap[]> process(cElementalInstanceStackMap[] inputs, double[] checkedAndFixedParameters) { - return null; + public MultiblockControl<cElementalInstanceStackMap[]> process(cElementalInstanceStackMap[] inputs, GT_MetaTileEntity_EM_machine te, Parameters parameters) { + float mass=0; + for (int i = 0; i < inputs.length; i++) { + if(inputs[i]!=null) { + mass+=inputs[i].getMass(); + } + } + return new MultiblockControl<>(null,(int)V[tier], 4, + 0,10000,20, 0,mass*coeff); } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Scanner.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Scanner.java index 32d8b81fdd..95bb8dce40 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Scanner.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Scanner.java @@ -2,23 +2,29 @@ package com.github.technus.tectech.thing.metaTileEntity.multi.em_machine; import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalInstanceStackMap; import com.github.technus.tectech.thing.metaTileEntity.multi.base.MultiblockControl; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.Parameters; /** * Created by danie_000 on 24.12.2017. */ -public class Behaviour_Scanner extends GT_MetaTileEntity_EM_machine.Behaviour { +public class Behaviour_Scanner implements GT_MetaTileEntity_EM_machine.IBehaviour { final int tier; public Behaviour_Scanner(int tier){ this.tier=tier; } @Override - public boolean setAndCheckParametersOutAndStatuses(GT_MetaTileEntity_EM_machine te, double[] parametersToCheckAndFix) { + public void parametersInstantiation(GT_MetaTileEntity_EM_machine te, Parameters parameters) { + + } + + @Override + public boolean checkParametersInAndSetStatuses(GT_MetaTileEntity_EM_machine te, Parameters parameters) { return false; } @Override - public MultiblockControl<cElementalInstanceStackMap[]> process(cElementalInstanceStackMap[] inputs, double[] checkedAndFixedParameters) { + public MultiblockControl<cElementalInstanceStackMap[]> process(cElementalInstanceStackMap[] inputs, GT_MetaTileEntity_EM_machine te, Parameters parameters) { return null; } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/GT_MetaTileEntity_EM_machine.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/GT_MetaTileEntity_EM_machine.java index 46e4ede660..39871910d9 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/GT_MetaTileEntity_EM_machine.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/GT_MetaTileEntity_EM_machine.java @@ -7,33 +7,33 @@ import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalInsta import com.github.technus.tectech.thing.block.QuantumGlassBlock; import com.github.technus.tectech.thing.block.QuantumStuffBlock; import com.github.technus.tectech.thing.metaTileEntity.IConstructable; -import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; -import com.github.technus.tectech.thing.metaTileEntity.multi.base.MultiblockControl; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.*; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.common.util.ForgeDirection; -import java.util.ArrayList; -import java.util.BitSet; import java.util.HashMap; +import java.util.function.Supplier; 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. */ public class GT_MetaTileEntity_EM_machine extends GT_MetaTileEntity_MultiblockBase_EM implements IConstructable { - public static final String machine = "EM Machinery"; - private Behaviour currentBehaviour; + private ItemStack loadedMachine; + private IBehaviour currentBehaviour; //region structure private static final String[][] shape = new String[][]{ @@ -46,7 +46,7 @@ public class GT_MetaTileEntity_EM_machine extends GT_MetaTileEntity_MultiblockBa {"B0", "A!!!", "0!!!0", "A!!!", "B0",},}; private static final Block[] blockType = new Block[]{sBlockCasingsTT, QuantumGlassBlock.INSTANCE, sBlockCasingsTT, sBlockCasingsTT}; private static final byte[] blockMeta = new byte[]{4, 0, 5, 6}; - private static final String[] addingMethods = new String[]{"addClassicToMachineList", "addElementalToMachineList"}; + private final IHatchAdder[] addingMethods = new IHatchAdder[]{this::addClassicToMachineList,this::addElementalToMachineList}; private static final short[] casingTextures = new short[]{textureOffset, textureOffset + 4}; private static final Block[] blockTypeFallback = new Block[]{sBlockCasingsTT, sBlockCasingsTT}; private static final byte[] blockMetaFallback = new byte[]{0, 4}; @@ -56,6 +56,36 @@ public class GT_MetaTileEntity_EM_machine extends GT_MetaTileEntity_MultiblockBa "2 - Elemental Hatches or Molecular Casing",}; //endregion + //region parameters + protected Parameters.Group.ParameterIn[] inputMux; + protected Parameters.Group.ParameterIn[] outputMux; + private static final IStatusFunction<GT_MetaTileEntity_EM_machine> SRC_STATUS = + (base,p)-> { + double v = p.get(); + if (Double.isNaN(v)) return STATUS_WRONG; + v=(int)v; + if (v < 0) return STATUS_TOO_LOW; + if (v == 0) return STATUS_NEUTRAL; + if (v >= base.eInputHatches.size()) return STATUS_TOO_HIGH; + return STATUS_OK; + }; + private static final IStatusFunction<GT_MetaTileEntity_EM_machine> DST_STATUS = + (base,p)->{ + if(base.inputMux[p.hatchId()].getStatus(false)== STATUS_OK){ + double v = p.get(); + if (Double.isNaN(v)) return STATUS_WRONG; + v=(int)v; + if (v < 0) return STATUS_TOO_LOW; + if (v == 0) return STATUS_LOW; + if (v >= base.eInputHatches.size()) return STATUS_TOO_HIGH; + return STATUS_OK; + } + return STATUS_NEUTRAL; + }; + private static final INameFunction<GT_MetaTileEntity_EM_machine> ROUTE_NAME= + (base,p)->(p.parameterId()==0?"Source ":"Destination ")+p.hatchId(); + //endregion + public GT_MetaTileEntity_EM_machine(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); } @@ -65,6 +95,33 @@ public class GT_MetaTileEntity_EM_machine extends GT_MetaTileEntity_MultiblockBa } @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + if(aNBT.hasKey("eLoadedMachine")){ + loadedMachine = ItemStack.loadItemStackFromNBT(aNBT.getCompoundTag("eLoadedMachine")); + } + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + if(loadedMachine !=null) { + aNBT.setTag("eLoadedMachine", loadedMachine.writeToNBT(new NBTTagCompound())); + } + } + + @Override + protected void parametersInstantiation_EM() { + inputMux=new Parameters.Group.ParameterIn[6]; + outputMux=new Parameters.Group.ParameterIn[6]; + for (int i=0;i<6;i++){ + Parameters.Group hatch=parametrization.getGroup(i); + inputMux[i]=hatch.makeInParameter(0,i,ROUTE_NAME,SRC_STATUS); + outputMux[i]=hatch.makeInParameter(1,i,ROUTE_NAME,DST_STATUS); + } + } + + @Override public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { return new GT_MetaTileEntity_EM_machine(mName); } @@ -91,6 +148,7 @@ public class GT_MetaTileEntity_EM_machine extends GT_MetaTileEntity_MultiblockBa @Override public void onFirstTick_EM(IGregTechTileEntity aBaseMetaTileEntity) { + setCurrentBehaviour(); if(aBaseMetaTileEntity.isServerSide()) { quantumStuff(aBaseMetaTileEntity.isActive()); } @@ -99,7 +157,9 @@ public class GT_MetaTileEntity_EM_machine extends GT_MetaTileEntity_MultiblockBa @Override public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { if(aBaseMetaTileEntity.isClientSide() && (aTick & 0x2)==0){ - currentBehaviour=GT_MetaTileEntity_EM_machine.map.get(new Util.TT_ItemStack(mInventory[1])); + if((aTick&0x10)==0) { + setCurrentBehaviour(); + } if(aBaseMetaTileEntity.isActive()){ int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX*2+aBaseMetaTileEntity.getXCoord(); int yDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetY*2+aBaseMetaTileEntity.getYCoord(); @@ -109,28 +169,6 @@ public class GT_MetaTileEntity_EM_machine extends GT_MetaTileEntity_MultiblockBa } } - private boolean setCurrentBehaviour(Behaviour newBehaviour){ - boolean changed=currentBehaviour!=newBehaviour; - if(changed){ - setDefaultParametersAndStatuses(); - } - currentBehaviour=newBehaviour; - return changed; - } - - private void setDefaultParametersAndStatuses() { - for (int i = 0; i <= 3; i++) { - setStatusOfParameterIn(i, 0, STATUS_NEUTRAL); - setStatusOfParameterIn(i, 1, STATUS_NEUTRAL); - } - for (int i = 0; i <= 9; i++) { - setStatusOfParameterOut(i, 0, STATUS_NEUTRAL); - setStatusOfParameterOut(i, 1, STATUS_NEUTRAL); - setParameterOut(i, 0, 0); - setParameterOut(i, 1, 0); - } - } - @Override public void onRemoval() { quantumStuff(false); @@ -139,48 +177,21 @@ public class GT_MetaTileEntity_EM_machine extends GT_MetaTileEntity_MultiblockBa @Override public boolean checkRecipe_EM(ItemStack itemStack) { - setCurrentBehaviour(GT_MetaTileEntity_EM_machine.map.get(new Util.TT_ItemStack(itemStack))); + setCurrentBehaviour(); if(currentBehaviour==null){ return false; } - //mux input - double[] parameters = new double[]{ - getParameterIn(0, 0), - getParameterIn(0, 1), - getParameterIn(1, 0), - getParameterIn(1, 1), - getParameterIn(2, 0), - getParameterIn(2, 1), - getParameterIn(3, 0), - getParameterIn(3, 1)}; - if (!currentBehaviour.setAndCheckParametersOutAndStatuses(this, parameters)) { + + if (!currentBehaviour.checkParametersInAndSetStatuses(this, parametrization)) { return false; } cElementalInstanceStackMap[] handles = new cElementalInstanceStackMap[6]; - int pointer = getParameterInInt(4, 0) - 1; - if (pointer >= 0 && pointer < eInputHatches.size()) { - handles[0] = eInputHatches.get(pointer).getContainerHandler(); - } - pointer = getParameterInInt(4, 1) - 1; - if (pointer >= 0 && pointer < eInputHatches.size()) { - handles[1] = eInputHatches.get(pointer).getContainerHandler(); - } - pointer = getParameterInInt(5, 0) - 1; - if (pointer >= 0 && pointer < eInputHatches.size()) { - handles[2] = eInputHatches.get(pointer).getContainerHandler(); - } - pointer = getParameterInInt(5, 1) - 1; - if (pointer >= 0 && pointer < eInputHatches.size()) { - handles[3] = eInputHatches.get(pointer).getContainerHandler(); - } - pointer = getParameterInInt(6, 0) - 1; - if (pointer >= 0 && pointer < eInputHatches.size()) { - handles[4] = eInputHatches.get(pointer).getContainerHandler(); - } - pointer = getParameterInInt(6, 1) - 1; - if (pointer >= 0 && pointer < eInputHatches.size()) { - handles[5] = eInputHatches.get(pointer).getContainerHandler(); + for (int i = 0; i < 6; i++) { + int pointer = (int)inputMux[i].get(); + if (pointer >= 0 && pointer < eInputHatches.size()) { + handles[i] = eInputHatches.get(pointer).getContainerHandler(); + } } for (int i = 1; i < 6; i++) { @@ -193,7 +204,7 @@ public class GT_MetaTileEntity_EM_machine extends GT_MetaTileEntity_MultiblockBa } } - MultiblockControl<cElementalInstanceStackMap[]> control = currentBehaviour.process(handles, parameters); + MultiblockControl<cElementalInstanceStackMap[]> control = currentBehaviour.process(handles,this, parametrization); if (control == null) { return false; } @@ -222,33 +233,16 @@ public class GT_MetaTileEntity_EM_machine extends GT_MetaTileEntity_MultiblockBa @Override public void outputAfterRecipe_EM() { - if (setCurrentBehaviour(GT_MetaTileEntity_EM_machine.map.get(new Util.TT_ItemStack(mInventory[1])))) { + if (setCurrentBehaviour()) { return; } + cElementalInstanceStackMap[] handles = new cElementalInstanceStackMap[6]; - int pointer = getParameterInInt(7, 0) - 1; - if (pointer >= 0 && pointer < eOutputHatches.size()) { - handles[0] = eOutputHatches.get(pointer).getContainerHandler(); - } - pointer = getParameterInInt(7, 1) - 1; - if (pointer >= 0 && pointer < eOutputHatches.size()) { - handles[1] = eOutputHatches.get(pointer).getContainerHandler(); - } - pointer = getParameterInInt(8, 0) - 1; - if (pointer >= 0 && pointer < eOutputHatches.size()) { - handles[2] = eOutputHatches.get(pointer).getContainerHandler(); - } - pointer = getParameterInInt(8, 1) - 1; - if (pointer >= 0 && pointer < eOutputHatches.size()) { - handles[3] = eOutputHatches.get(pointer).getContainerHandler(); - } - pointer = getParameterInInt(9, 0) - 1; - if (pointer >= 0 && pointer < eOutputHatches.size()) { - handles[4] = eOutputHatches.get(pointer).getContainerHandler(); - } - pointer = getParameterInInt(9, 1) - 1; - if (pointer >= 0 && pointer < eOutputHatches.size()) { - handles[5] = eOutputHatches.get(pointer).getContainerHandler(); + for (int i = 0; i < 6; i++) { + int pointer = (int)outputMux[i].get(); + if (pointer >= 0 && pointer < eOutputHatches.size()) { + handles[i] = eOutputHatches.get(pointer).getContainerHandler(); + } } //output for (int i = 0; i < 6 && i < outputEM.length; i++) { @@ -268,168 +262,71 @@ public class GT_MetaTileEntity_EM_machine extends GT_MetaTileEntity_MultiblockBa } @Override - protected void parametersLoadDefault_EM() {//default routing table - setParameterPairIn_ClearOut(4, false, 1, 2);//I - setParameterPairIn_ClearOut(5, false, 3, 4);//I - setParameterPairIn_ClearOut(6, false, 5, 6);//I - - setParameterPairIn_ClearOut(7, false, 1, 2);//O - setParameterPairIn_ClearOut(8, false, 3, 4);//O - setParameterPairIn_ClearOut(9, false, 5, 6);//O + public void parametersStatusesWrite_EM(boolean machineBusy) { + if (!machineBusy) { + setCurrentBehaviour(); + } + super.parametersStatusesWrite_EM(machineBusy); } - @Override - public void parametersOutAndStatusesWrite_EM(boolean machineBusy) { - int pointer; - { - BitSet checkArray = new BitSet(); - for (int i = 4; i <= 6; i++) { - pointer = getParameterInInt(i, 0); - if (Double.isNaN(pointer)) { - setStatusOfParameterIn(i, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_WRONG); - } else if (pointer <= 0) { - setStatusOfParameterIn(i, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_LOW); - }//else if(pointer==0) - // setStatusOfParameterIn(i,0,STATUS_LOW); - else if (pointer <= eInputHatches.size()) { - if (checkArray.get(pointer)) { - setStatusOfParameterIn(i, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_WRONG); - } else { - setStatusOfParameterIn(i, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_OK); - checkArray.set(pointer); - } - } else { - setStatusOfParameterIn(i, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_HIGH); - } - pointer = getParameterInInt(i, 1); - if (Double.isNaN(pointer)) { - setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_WRONG); - } else if (pointer < 0) { - setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_LOW); - } else if (pointer == 0) { - setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_LOW); - } else if (pointer <= eInputHatches.size()) { - if (checkArray.get(pointer)) { - setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_WRONG); - } else { - setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_OK); - checkArray.set(pointer); - } - } else { - setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_HIGH); - } - } + private boolean setCurrentBehaviour(){ + ItemStack newMachine=mInventory[1]; + if(ItemStack.areItemStacksEqual(newMachine, loadedMachine)){ + return false; } - { - for (int i = 7; i <= 9; i++) { - pointer = getParameterInInt(i, 0); - if (Double.isNaN(pointer)) { - setStatusOfParameterIn(i, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_WRONG); - } else if (pointer < 0) { - setStatusOfParameterIn(i, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_LOW); - } else if (pointer == 0) { - setStatusOfParameterIn(i, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_LOW); - } else if (pointer <= eOutputHatches.size()) { - setStatusOfParameterIn(i, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_OK); - } else { - setStatusOfParameterIn(i, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_HIGH); - } - pointer = getParameterInInt(i, 1); - if (Double.isNaN(pointer)) { - setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_WRONG); - } else if (pointer < 0) { - setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_LOW); - } else if (pointer == 0) { - setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_LOW); - } else if (pointer <= eOutputHatches.size()) { - setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_OK); - } else { - setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_HIGH); - } + loadedMachine=newMachine; + Supplier<IBehaviour> behaviourSupplier=GT_MetaTileEntity_EM_machine.BEHAVIOUR_MAP.get(new Util.ItemStack_NoNBT(newMachine)); + if(currentBehaviour==null && behaviourSupplier==null) { + return false; + } + if(currentBehaviour!=null){ + for(int i=6;i<10;i++){ + parametrization.removeGroup(i); } } - setCurrentBehaviour(GT_MetaTileEntity_EM_machine.map.get(new Util.TT_ItemStack(mInventory[1]))); - if (currentBehaviour == null) { - setDefaultParametersAndStatuses(); + if(behaviourSupplier!=null){ + currentBehaviour=behaviourSupplier.get(); + currentBehaviour.parametersInstantiation(this, parametrization); + for(int i=6;i<10;i++){ + parametrization.setToDefaults(i,true,true); + } } else { - double[] parameters = new double[]{ - getParameterIn(0, 0), - getParameterIn(0, 1), - getParameterIn(1, 0), - getParameterIn(1, 1), - getParameterIn(2, 0), - getParameterIn(2, 1), - getParameterIn(3, 0), - getParameterIn(3, 1)}; - currentBehaviour.setAndCheckParametersOutAndStatuses(this,parameters); + currentBehaviour=null; } + + return true; } - private static final HashMap<Util.TT_ItemStack, Behaviour> map = new HashMap<>(); + private static final HashMap<Util.ItemStack_NoNBT, Supplier<IBehaviour>> BEHAVIOUR_MAP = new HashMap<>(); - public static void registerBehaviour(Behaviour behaviour, ItemStack is) { - map.put(new Util.TT_ItemStack(is), behaviour); - TecTech.LOGGER.info("Registered EM machine behaviour "+behaviour.getClass().getSimpleName()+' '+new Util.TT_ItemStack(is).toString()); + public static void registerBehaviour(Supplier<IBehaviour> behaviour, ItemStack is) { + BEHAVIOUR_MAP.put(new Util.ItemStack_NoNBT(is), behaviour); + TecTech.LOGGER.info("Registered EM machine behaviour "+behaviour.get().getClass().getSimpleName()+' '+new Util.ItemStack_NoNBT(is).toString()); } - public static abstract class Behaviour { - public Behaviour(){} + public interface IBehaviour { + /** + * instantiate parameters, u can also check machine tier here + * @param te + * @param parameters + */ + void parametersInstantiation(GT_MetaTileEntity_EM_machine te, Parameters parameters); /** - * handle parameters pre recipe, and cyclically - * this shouldn't write to input parameters! only to the provided array and/or output parameters - * @param te this - * @param parametersToCheckAndFix array of 6 parameters to pass to the process method (can be modified) - * this allows to pass different numbers if u want to employ automatic parameter correction here + * handle parameters per recipe + * @param te this te instance + * @param parameters of this te * @return return true if machine can start with current parameters, false if not */ - public abstract boolean setAndCheckParametersOutAndStatuses(GT_MetaTileEntity_EM_machine te, double[] parametersToCheckAndFix); + boolean checkParametersInAndSetStatuses(GT_MetaTileEntity_EM_machine te, Parameters parameters); /** * do recipe handling * @param inputs from muxed inputs - * @param checkedAndFixedParameters array passed from previous method! + * @param parameters array passed from previous method! * @return null if recipe should not start, control object to set machine state and start recipe */ - public abstract MultiblockControl<cElementalInstanceStackMap[]> process(cElementalInstanceStackMap[] inputs, double[] checkedAndFixedParameters); - - /** - * get input param description, only for 4 first hatches - * @param baseDescr - * @param hatchNo - * @param paramID - */ - protected void getFullLedDescriptionIn(ArrayList<String> baseDescr, int hatchNo, int paramID){} - - /** - * get output param description - * @param baseDescr - * @param hatchNo - * @param paramID - */ - protected void getFullLedDescriptionOut(ArrayList<String> baseDescr, int hatchNo, int paramID){} - } - - @Override - public ArrayList<String> getFullLedDescriptionIn(int hatchNo, int paramID) { - ArrayList<String> base=super.getFullLedDescriptionIn(hatchNo, paramID); - if(hatchNo>=7){ - base.add("Output mux "+((hatchNo-7)*2+paramID+1)); - }else if(hatchNo>=4){ - base.add("Input mux "+((hatchNo-4)*2+paramID+1)); - }else if(currentBehaviour!=null){ - currentBehaviour.getFullLedDescriptionIn(base,hatchNo,paramID); - } - return base; - } - - @Override - public ArrayList<String> getFullLedDescriptionOut(int hatchNo, int paramID) { - ArrayList<String> base=super.getFullLedDescriptionOut(hatchNo, paramID); - if(currentBehaviour!=null){ - currentBehaviour.getFullLedDescriptionOut(base,hatchNo,paramID); - } - return base; + MultiblockControl<cElementalInstanceStackMap[]> process(cElementalInstanceStackMap[] inputs, GT_MetaTileEntity_EM_machine te, Parameters parameters); } private void quantumStuff(boolean shouldExist){ diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/GT_MetaTileEntity_Pipe_Data.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/GT_MetaTileEntity_Pipe_Data.java index 5234de7129..6c406313fb 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/GT_MetaTileEntity_Pipe_Data.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/GT_MetaTileEntity_Pipe_Data.java @@ -1,6 +1,8 @@ package com.github.technus.tectech.thing.metaTileEntity.pipe; import com.github.technus.tectech.CommonValues; +import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.loader.NetworkDispatcher; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.GT_Mod; @@ -28,11 +30,13 @@ import static gregtech.api.enums.Dyes.MACHINE_METAL; /** * Created by Tec on 26.02.2017. */ -public class GT_MetaTileEntity_Pipe_Data extends MetaPipeEntity implements IConnectsToDataPipe { +public class GT_MetaTileEntity_Pipe_Data extends MetaPipeEntity implements IConnectsToDataPipe,IActivePipe { private static Textures.BlockIcons.CustomIcon EMpipe; - private static Textures.BlockIcons.CustomIcon EMbar; + private static Textures.BlockIcons.CustomIcon EMbar,EMbarActive; public byte connectionCount = 0; + private boolean active; + public GT_MetaTileEntity_Pipe_Data(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional, 0); } @@ -51,12 +55,13 @@ public class GT_MetaTileEntity_Pipe_Data extends MetaPipeEntity implements IConn public void registerIcons(IIconRegister aBlockIconRegister) { EMpipe = new Textures.BlockIcons.CustomIcon("iconsets/EM_DATA"); EMbar = new Textures.BlockIcons.CustomIcon("iconsets/EM_BAR"); + EMbarActive = new Textures.BlockIcons.CustomIcon("iconsets/EM_BAR_ACTIVE"); super.registerIcons(aBlockIconRegister); } @Override public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aConnections, byte aColorIndex, boolean aConnected, boolean aRedstone) { - return new ITexture[]{new GT_RenderedTexture(EMpipe), new GT_RenderedTexture(EMbar, Dyes.getModulation(aColorIndex, MACHINE_METAL.getRGBA()))}; + return new ITexture[]{new GT_RenderedTexture(EMpipe), new GT_RenderedTexture(getActive()?EMbarActive:EMbar, Dyes.getModulation(aColorIndex, MACHINE_METAL.getRGBA()))}; } @Override @@ -71,10 +76,12 @@ public class GT_MetaTileEntity_Pipe_Data extends MetaPipeEntity implements IConn @Override public void loadNBTData(NBTTagCompound nbtTagCompound) { + active=nbtTagCompound.getBoolean("eActive"); } @Override public void saveNBTData(NBTTagCompound nbtTagCompound) { + nbtTagCompound.setBoolean("eActive",active); } @Override @@ -100,6 +107,9 @@ public class GT_MetaTileEntity_Pipe_Data extends MetaPipeEntity implements IConn @Override public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { + if(aBaseMetaTileEntity.isClientSide()){ + NetworkDispatcher.INSTANCE.sendToServer(new PipeActivityMessage.PipeActivityQuery(this)); + } onPostTick(aBaseMetaTileEntity, 31); } @@ -107,6 +117,26 @@ public class GT_MetaTileEntity_Pipe_Data extends MetaPipeEntity implements IConn public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { if (aBaseMetaTileEntity.isServerSide()) { if ((aTick & 31) == 31) { + if(active){ + if(TecTech.RANDOM.nextInt(15)==0) { + NetworkDispatcher.INSTANCE.sendToAllAround(new PipeActivityMessage.PipeActivityData(this), + aBaseMetaTileEntity.getWorld().provider.dimensionId, + aBaseMetaTileEntity.getXCoord(), + aBaseMetaTileEntity.getYCoord(), + aBaseMetaTileEntity.getZCoord(), + 256); + } + active=false; + }else if(getActive()){ + if(TecTech.RANDOM.nextInt(15)==0) { + NetworkDispatcher.INSTANCE.sendToAllAround(new PipeActivityMessage.PipeActivityData(this), + aBaseMetaTileEntity.getWorld().provider.dimensionId, + aBaseMetaTileEntity.getXCoord(), + aBaseMetaTileEntity.getYCoord(), + aBaseMetaTileEntity.getZCoord(), + 256); + } + } mConnections = 0; connectionCount = 0; byte myColor=aBaseMetaTileEntity.getColorization(); @@ -237,4 +267,20 @@ public class GT_MetaTileEntity_Pipe_Data extends MetaPipeEntity implements IConn public byte getColorization() { return getBaseMetaTileEntity().getColorization(); } + + @Override + public void markUsed() { + this.active = true; + } + + @Override + public void setActive(boolean active) { + this.active=active; + getBaseMetaTileEntity().issueTextureUpdate(); + } + + @Override + public boolean getActive() { + return active; + } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/GT_MetaTileEntity_Pipe_EM.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/GT_MetaTileEntity_Pipe_EM.java index 6b7b36fb54..742d298bc6 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/GT_MetaTileEntity_Pipe_EM.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/GT_MetaTileEntity_Pipe_EM.java @@ -1,6 +1,8 @@ package com.github.technus.tectech.thing.metaTileEntity.pipe; import com.github.technus.tectech.CommonValues; +import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.loader.NetworkDispatcher; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.GT_Mod; @@ -29,11 +31,13 @@ import static gregtech.api.enums.Dyes.MACHINE_METAL; /** * Created by Tec on 26.02.2017. */ -public class GT_MetaTileEntity_Pipe_EM extends MetaPipeEntity implements IConnectsToElementalPipe { +public class GT_MetaTileEntity_Pipe_EM extends MetaPipeEntity implements IConnectsToElementalPipe,IActivePipe { private static Textures.BlockIcons.CustomIcon EMpipe; - private static Textures.BlockIcons.CustomIcon EMcandy; + static Textures.BlockIcons.CustomIcon EMcandy,EMCandyActive; public byte connectionCount = 0; + private boolean active; + public GT_MetaTileEntity_Pipe_EM(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional, 0); } @@ -52,12 +56,13 @@ public class GT_MetaTileEntity_Pipe_EM extends MetaPipeEntity implements IConnec public void registerIcons(IIconRegister aBlockIconRegister) { EMpipe = new Textures.BlockIcons.CustomIcon("iconsets/EM_PIPE"); EMcandy = new Textures.BlockIcons.CustomIcon("iconsets/EM_CANDY"); + EMCandyActive = new Textures.BlockIcons.CustomIcon("iconsets/EM_CANDY_ACTIVE"); super.registerIcons(aBlockIconRegister); } @Override public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aConnections, byte aColorIndex, boolean aConnected, boolean aRedstone) { - return new ITexture[]{new GT_RenderedTexture(EMpipe), new GT_RenderedTexture(EMcandy, Dyes.getModulation(aColorIndex, MACHINE_METAL.getRGBA()))}; + return new ITexture[]{new GT_RenderedTexture(EMpipe), new GT_RenderedTexture(getActive()?EMCandyActive:EMcandy, Dyes.getModulation(aColorIndex, MACHINE_METAL.getRGBA()))}; } @Override @@ -72,10 +77,12 @@ public class GT_MetaTileEntity_Pipe_EM extends MetaPipeEntity implements IConnec @Override public void loadNBTData(NBTTagCompound nbtTagCompound) { + active=nbtTagCompound.getBoolean("eActive"); } @Override public void saveNBTData(NBTTagCompound nbtTagCompound) { + nbtTagCompound.setBoolean("eActive",active); } @Override @@ -101,6 +108,9 @@ public class GT_MetaTileEntity_Pipe_EM extends MetaPipeEntity implements IConnec @Override public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { + if(getBaseMetaTileEntity().isClientSide()){ + NetworkDispatcher.INSTANCE.sendToServer(new PipeActivityMessage.PipeActivityQuery(this)); + } onPostTick(aBaseMetaTileEntity, 31); } @@ -108,6 +118,26 @@ public class GT_MetaTileEntity_Pipe_EM extends MetaPipeEntity implements IConnec public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { if (aBaseMetaTileEntity.isServerSide()) { if ((aTick & 31) == 31) { + if(active){ + if(TecTech.RANDOM.nextInt(7)==0) { + NetworkDispatcher.INSTANCE.sendToAllAround(new PipeActivityMessage.PipeActivityData(this), + aBaseMetaTileEntity.getWorld().provider.dimensionId, + aBaseMetaTileEntity.getXCoord(), + aBaseMetaTileEntity.getYCoord(), + aBaseMetaTileEntity.getZCoord(), + 256); + } + active=false; + }else if(getActive()){ + if(TecTech.RANDOM.nextInt(7)==0) { + NetworkDispatcher.INSTANCE.sendToAllAround(new PipeActivityMessage.PipeActivityData(this), + aBaseMetaTileEntity.getWorld().provider.dimensionId, + aBaseMetaTileEntity.getXCoord(), + aBaseMetaTileEntity.getYCoord(), + aBaseMetaTileEntity.getZCoord(), + 256); + } + } mConnections = 0; connectionCount = 0; if (aBaseMetaTileEntity.getColorization() < 0) { @@ -145,7 +175,6 @@ public class GT_MetaTileEntity_Pipe_EM extends MetaPipeEntity implements IConnec //} } } - } else if (aBaseMetaTileEntity.isClientSide() && GT_Client.changeDetected == 4) { aBaseMetaTileEntity.issueTextureUpdate(); } @@ -203,4 +232,27 @@ public class GT_MetaTileEntity_Pipe_EM extends MetaPipeEntity implements IConnec } return 0.5f; } + + @Override + public void markUsed() { + this.active = true; + } + + @Override + public void setActive(boolean active) { + this.active=active; + getBaseMetaTileEntity().issueTextureUpdate(); + } + + @Override + public boolean getActive() { + return active; + } + + @Override + public void onRemoval() { + if(getActive()){ + TecTech.anomalyHandler.addAnomaly(getBaseMetaTileEntity(),1e10f); + } + } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/GT_MetaTileEntity_Pipe_Energy.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/GT_MetaTileEntity_Pipe_Energy.java index 6d4be98634..4cc40b471c 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/GT_MetaTileEntity_Pipe_Energy.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/GT_MetaTileEntity_Pipe_Energy.java @@ -1,6 +1,8 @@ package com.github.technus.tectech.thing.metaTileEntity.pipe; import com.github.technus.tectech.CommonValues; +import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.loader.NetworkDispatcher; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.GT_Mod; @@ -24,13 +26,16 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; +import static com.github.technus.tectech.thing.metaTileEntity.pipe.GT_MetaTileEntity_Pipe_EM.EMCandyActive; +import static com.github.technus.tectech.thing.metaTileEntity.pipe.GT_MetaTileEntity_Pipe_EM.EMcandy; import static gregtech.api.enums.Dyes.MACHINE_METAL; -public class GT_MetaTileEntity_Pipe_Energy extends MetaPipeEntity implements IConnectsToEnergyTunnel { +public class GT_MetaTileEntity_Pipe_Energy extends MetaPipeEntity implements IConnectsToEnergyTunnel,IActivePipe { private static Textures.BlockIcons.CustomIcon EMpipe; - private static Textures.BlockIcons.CustomIcon EMcandy; public byte connectionCount = 0; + private boolean active; + public GT_MetaTileEntity_Pipe_Energy(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional, 0); } @@ -48,13 +53,12 @@ public class GT_MetaTileEntity_Pipe_Energy extends MetaPipeEntity implements ICo @SideOnly(Side.CLIENT) public void registerIcons(IIconRegister aBlockIconRegister) { EMpipe = new Textures.BlockIcons.CustomIcon("iconsets/EM_LASER"); - EMcandy = new Textures.BlockIcons.CustomIcon("iconsets/EM_CANDY"); super.registerIcons(aBlockIconRegister); } @Override public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aConnections, byte aColorIndex, boolean aConnected, boolean aRedstone) { - return new ITexture[]{new GT_RenderedTexture(EMpipe), new GT_RenderedTexture(EMcandy, Dyes.getModulation(aColorIndex, MACHINE_METAL.getRGBA()))}; + return new ITexture[]{new GT_RenderedTexture(EMpipe), new GT_RenderedTexture(getActive()?EMCandyActive:EMcandy, Dyes.getModulation(aColorIndex, MACHINE_METAL.getRGBA()))}; } @Override @@ -69,10 +73,12 @@ public class GT_MetaTileEntity_Pipe_Energy extends MetaPipeEntity implements ICo @Override public void loadNBTData(NBTTagCompound nbtTagCompound) { + active=nbtTagCompound.getBoolean("eActive"); } @Override public void saveNBTData(NBTTagCompound nbtTagCompound) { + nbtTagCompound.setBoolean("eActive",active); } @Override @@ -89,15 +95,18 @@ public class GT_MetaTileEntity_Pipe_Energy extends MetaPipeEntity implements ICo public String[] getDescription() { return new String[]{ CommonValues.TEC_MARK_EM, - "Energy tunneling device.", - EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + "Not a portal!!!", + "Laser tunneling device.", + EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + "Bright Vacuum!!!", EnumChatFormatting.AQUA + "Must be painted to work", - EnumChatFormatting.AQUA + "Do not cross,split or turn" + EnumChatFormatting.AQUA + "Do not split or turn" }; } @Override public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { + if(getBaseMetaTileEntity().isClientSide()){ + NetworkDispatcher.INSTANCE.sendToServer(new PipeActivityMessage.PipeActivityQuery(this)); + } onPostTick(aBaseMetaTileEntity, 31); } @@ -105,6 +114,26 @@ public class GT_MetaTileEntity_Pipe_Energy extends MetaPipeEntity implements ICo public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { if (aBaseMetaTileEntity.isServerSide()) { if ((aTick & 31) == 31) { + if(active){ + if(TecTech.RANDOM.nextInt(31)==0) { + NetworkDispatcher.INSTANCE.sendToAllAround(new PipeActivityMessage.PipeActivityData(this), + aBaseMetaTileEntity.getWorld().provider.dimensionId, + aBaseMetaTileEntity.getXCoord(), + aBaseMetaTileEntity.getYCoord(), + aBaseMetaTileEntity.getZCoord(), + 256); + } + active=false; + }else if(getActive()){ + if(TecTech.RANDOM.nextInt(31)==0) { + NetworkDispatcher.INSTANCE.sendToAllAround(new PipeActivityMessage.PipeActivityData(this), + aBaseMetaTileEntity.getWorld().provider.dimensionId, + aBaseMetaTileEntity.getXCoord(), + aBaseMetaTileEntity.getYCoord(), + aBaseMetaTileEntity.getZCoord(), + 256); + } + } mConnections = 0; connectionCount = 0; if (aBaseMetaTileEntity.getColorization() < 0) { @@ -149,6 +178,22 @@ public class GT_MetaTileEntity_Pipe_Energy extends MetaPipeEntity implements ICo } @Override + public void setActive(boolean state){ + this.active=state; + getBaseMetaTileEntity().issueTextureUpdate(); + } + + @Override + public boolean getActive() { + return active; + } + + @Override + public void markUsed() { + this.active = true; + } + + @Override public boolean canConnect(byte side) { return true; } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/IActivePipe.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/IActivePipe.java new file mode 100644 index 0000000000..5552992e56 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/IActivePipe.java @@ -0,0 +1,9 @@ +package com.github.technus.tectech.thing.metaTileEntity.pipe; + +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; + +public interface IActivePipe extends IMetaTileEntity { + void setActive(boolean active); + boolean getActive(); + void markUsed(); +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/PipeActivityMessage.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/PipeActivityMessage.java new file mode 100644 index 0000000000..e7183b8838 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/PipeActivityMessage.java @@ -0,0 +1,133 @@ +package com.github.technus.tectech.thing.metaTileEntity.pipe; + +import cpw.mods.fml.common.network.ByteBufUtils; +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; +import eu.usrv.yamcore.network.client.AbstractClientMessageHandler; +import eu.usrv.yamcore.network.server.AbstractServerMessageHandler; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import io.netty.buffer.ByteBuf; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; +import net.minecraftforge.common.DimensionManager; + +public class PipeActivityMessage implements IMessage { + int mPosX; + int mPosY; + int mPosZ; + int mPosD; + int mActive; + + public PipeActivityMessage() { + } + + private PipeActivityMessage(IActivePipe metaTile) { + IGregTechTileEntity base=metaTile.getBaseMetaTileEntity(); + mPosX=base.getXCoord(); + mPosY=base.getYCoord(); + mPosZ=base.getZCoord(); + mPosD=base.getWorld().provider.dimensionId; + mActive=metaTile.getActive()?1:0; + } + + private PipeActivityMessage(World world, int x, int y, int z, boolean active) { + mPosX=x; + mPosY=y; + mPosZ=z; + mPosD=world.provider.dimensionId; + mActive=active?1:0; + } + + @Override + public void fromBytes(ByteBuf pBuffer) { + NBTTagCompound tTag = ByteBufUtils.readTag(pBuffer); + mPosX = tTag.getInteger("posx"); + mPosY = tTag.getInteger("posy"); + mPosZ = tTag.getInteger("posz"); + mPosD = tTag.getInteger("posd"); + mActive = tTag.getInteger("active"); + } + + @Override + public void toBytes(ByteBuf pBuffer) { + NBTTagCompound tFXTag = new NBTTagCompound(); + tFXTag.setInteger("posx", mPosX); + tFXTag.setInteger("posy", mPosY); + tFXTag.setInteger("posz", mPosZ); + tFXTag.setInteger("posd", mPosD); + tFXTag.setInteger("active", mActive); + + ByteBufUtils.writeTag(pBuffer, tFXTag); + } + + public static class PipeActivityQuery extends PipeActivityMessage { + public PipeActivityQuery() { + } + + public PipeActivityQuery(IActivePipe metaTile) { + super(metaTile); + } + + public PipeActivityQuery(World world, int x,int y,int z, boolean active) { + super(world,x,y,z,active); + } + } + + public static class PipeActivityData extends PipeActivityMessage { + public PipeActivityData() { + } + + private PipeActivityData(PipeActivityQuery query){ + mPosX=query.mPosX; + mPosY=query.mPosY; + mPosZ=query.mPosZ; + mPosD=query.mPosD; + mActive=query.mActive; + } + + public PipeActivityData(IActivePipe metaTile) { + super(metaTile); + } + + public PipeActivityData(World world, int x,int y,int z, boolean active) { + super(world,x,y,z,active); + } + } + + public static class ClientHandler extends AbstractClientMessageHandler<PipeActivityData> { + @Override + public IMessage handleClientMessage(EntityPlayer pPlayer, PipeActivityData pMessage, MessageContext pCtx) { + if(pPlayer.worldObj.provider.dimensionId==pMessage.mPosD){ + TileEntity te=pPlayer.worldObj.getTileEntity(pMessage.mPosX,pMessage.mPosY,pMessage.mPosZ); + if(te instanceof IGregTechTileEntity){ + IMetaTileEntity meta = ((IGregTechTileEntity) te).getMetaTileEntity(); + if(meta instanceof IActivePipe){ + ((IActivePipe) meta).setActive((byte)pMessage.mActive==1); + } + } + } + return null; + } + } + + public static class ServerHandler extends AbstractServerMessageHandler<PipeActivityQuery> { + @Override + public IMessage handleServerMessage(EntityPlayer pPlayer, PipeActivityQuery pMessage, MessageContext pCtx) { + World world= DimensionManager.getWorld(pMessage.mPosD); + if(world!=null) { + TileEntity te = world.getTileEntity(pMessage.mPosX, pMessage.mPosY, pMessage.mPosZ); + if (te instanceof IGregTechTileEntity) { + IMetaTileEntity meta = ((IGregTechTileEntity) te).getMetaTileEntity(); + if (meta instanceof IActivePipe) { + pMessage.mActive=((IActivePipe) meta).getActive()?1:0; + return new PipeActivityData(pMessage); + } + } + } + return null; + } + } +}
\ No newline at end of file diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_BuckConverter.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_BuckConverter.java index f2648d2c2f..86c484059b 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_BuckConverter.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_BuckConverter.java @@ -35,6 +35,7 @@ public class GT_MetaTileEntity_BuckConverter extends GT_MetaTileEntity_TieredMac public GT_MetaTileEntity_BuckConverter(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { super(aName, aTier, 0, aDescription, aTextures); + Util.setTier(aTier,this); } @Override diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_DataReader.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_DataReader.java index 6612167e5f..86dd48a877 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_DataReader.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_DataReader.java @@ -37,7 +37,7 @@ import static com.github.technus.tectech.Reference.MODID; * Created by Tec on 23.03.2017. */ public class GT_MetaTileEntity_DataReader extends GT_MetaTileEntity_BasicMachine { - private static final HashMap<Util.TT_ItemStack,ArrayList<DataRender>> RENDER_REGISTRY =new HashMap<>(); + private static final HashMap<Util.ItemStack_NoNBT,ArrayList<IDataRender>> RENDER_REGISTRY =new HashMap<>(); private static GT_RenderedTexture READER_ONLINE, READER_OFFLINE; public GT_MetaTileEntity_DataReader(int aID, String aName, String aNameRegional, int aTier) { @@ -47,6 +47,7 @@ public class GT_MetaTileEntity_DataReader extends GT_MetaTileEntity_BasicMachine public GT_MetaTileEntity_DataReader(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { super(aName,aTier,1,aDescription,aTextures,1,1,"dataReader.png",""); + Util.setTier(aTier,this); } @Override @@ -89,8 +90,8 @@ public class GT_MetaTileEntity_DataReader extends GT_MetaTileEntity_BasicMachine return DID_NOT_FIND_RECIPE; } ItemStack input=getInputAt(0); - ArrayList<DataRender> renders=getRenders(new Util.TT_ItemStack(input)); - for(DataRender render:renders){ + ArrayList<IDataRender> renders=getRenders(new Util.ItemStack_NoNBT(input)); + for(IDataRender render:renders){ if(render.canRender(input,mTier)){ mOutputItems[0]=input.copy(); input.stackSize-=1; @@ -173,22 +174,19 @@ public class GT_MetaTileEntity_DataReader extends GT_MetaTileEntity_BasicMachine return maxEUInput()*4L; } - public static void addDataRender(Util.TT_ItemStack stack,DataRender render){ - ArrayList<DataRender> renders=RENDER_REGISTRY.get(stack); - if(renders==null){ - RENDER_REGISTRY.put(stack,renders=new ArrayList<>()); - } + public static void addDataRender(Util.ItemStack_NoNBT stack, IDataRender render){ + ArrayList<IDataRender> renders = RENDER_REGISTRY.computeIfAbsent(stack, k -> new ArrayList<>()); if(FMLCommonHandler.instance().getEffectiveSide().isClient()) { render.loadResources(); } renders.add(render); } - public static ArrayList<DataRender> getRenders(Util.TT_ItemStack stack){ + public static ArrayList<IDataRender> getRenders(Util.ItemStack_NoNBT stack){ return RENDER_REGISTRY.get(stack); } - public interface DataRender{ + public interface IDataRender { @SideOnly(Side.CLIENT) void loadResources(); @SideOnly(Side.CLIENT) @@ -205,7 +203,7 @@ public class GT_MetaTileEntity_DataReader extends GT_MetaTileEntity_BasicMachine } public static void run(){ - addDataRender(new Util.TT_ItemStack(ItemList.Tool_DataStick.get(1)),new DataRender() { + addDataRender(new Util.ItemStack_NoNBT(ItemList.Tool_DataStick.get(1)),new IDataRender() { @SideOnly(Side.CLIENT) private ResourceLocation bg; @SideOnly(Side.CLIENT) @@ -298,10 +296,7 @@ public class GT_MetaTileEntity_DataReader extends GT_MetaTileEntity_BasicMachine @Override public boolean canRender(ItemStack itemStack,byte tier) { NBTTagCompound nbtTagCompound=itemStack.stackTagCompound; - if(nbtTagCompound!=null && nbtTagCompound.hasKey("output")){ - return true; - } - return false; + return nbtTagCompound != null && nbtTagCompound.hasKey("output"); } @Override diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_DebugPollutor.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_DebugPollutor.java new file mode 100644 index 0000000000..0e1c389006 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_DebugPollutor.java @@ -0,0 +1,160 @@ +package com.github.technus.tectech.thing.metaTileEntity.single; + +import com.github.technus.tectech.CommonValues; +import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.Util; +import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_OverflowElemental; +import com.github.technus.tectech.thing.metaTileEntity.single.gui.GT_Container_DebugPollutor; +import com.github.technus.tectech.thing.metaTileEntity.single.gui.GT_GUIContainer_DebugPollutor; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_TieredMachineBlock; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.common.GT_Pollution; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_CASINGS; + +/** + * Created by Tec on 23.03.2017. + */ +public class GT_MetaTileEntity_DebugPollutor extends GT_MetaTileEntity_TieredMachineBlock { + private static GT_RenderedTexture POLLUTOR; + public int pollution=0; + public float anomaly=0; + + public GT_MetaTileEntity_DebugPollutor(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, 0, "Shit genny broke!"); + Util.setTier(aTier,this); + } + + public GT_MetaTileEntity_DebugPollutor(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 0, aDescription, aTextures); + Util.setTier(aTier,this); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_DebugPollutor(mName, mTier, mDescription, mTextures); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister aBlockIconRegister) { + super.registerIcons(aBlockIconRegister); + POLLUTOR = new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("iconsets/POLLUTOR")); + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + return new ITexture[]{MACHINE_CASINGS[mTier][aColorIndex + 1], aSide != aFacing ? aActive? new GT_RenderedTexture(GT_MetaTileEntity_Hatch_OverflowElemental.MufflerEM): new GT_RenderedTexture(GT_MetaTileEntity_Hatch_OverflowElemental.MufflerEMidle) : POLLUTOR}; + } + + @Override + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + return null; + } + + @Override + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_Container_DebugPollutor(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_DebugPollutor(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public boolean allowPutStack(IGregTechTileEntity iGregTechTileEntity, int i, byte b, ItemStack itemStack) { + return false; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity iGregTechTileEntity, int i, byte b, ItemStack itemStack) { + return false; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setInteger("ePollution",pollution); + aNBT.setFloat("eAnomaly",anomaly); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + pollution=aNBT.getInteger("ePollution"); + anomaly=aNBT.getFloat("eAnomaly"); + getBaseMetaTileEntity().setActive(anomaly>0||pollution>0); + } + + @Override + public boolean isSimpleMachine() { + return false; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide()) { + aBaseMetaTileEntity.setActive(anomaly>0||pollution>0); + if (anomaly > 0) { + TecTech.anomalyHandler.addAnomaly(aBaseMetaTileEntity,anomaly); + } + if (pollution > 0) { + GT_Pollution.addPollution(aBaseMetaTileEntity, pollution); + } + } else if (aBaseMetaTileEntity.isClientSide() && aBaseMetaTileEntity.isActive()) { + for(byte i=0;i<6;i++){ + if(i!=aBaseMetaTileEntity.getFrontFacing()){ + TecTech.proxy.em_particle(aBaseMetaTileEntity, i); + TecTech.proxy.pollutor_particle(aBaseMetaTileEntity,i); + } + } + } + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return true; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public String[] getDescription() { + return new String[]{ + CommonValues.TEC_MARK_GENERAL, mDescription, + EnumChatFormatting.BLUE + "Infinite Producer/Consumer", + EnumChatFormatting.BLUE + "Since i wanted one..." + }; + } + + @Override + public boolean isElectric() { + return false; + } + +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_DebugPowerGenerator.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_DebugPowerGenerator.java index 92ac88b180..b809f18ab0 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_DebugPowerGenerator.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_DebugPowerGenerator.java @@ -38,6 +38,7 @@ public class GT_MetaTileEntity_DebugPowerGenerator extends GT_MetaTileEntity_Tie public GT_MetaTileEntity_DebugPowerGenerator(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { super(aName, aTier, 0, aDescription, aTextures); + Util.setTier(aTier,this); } @Override diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_DebugStructureWriter.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_DebugStructureWriter.java index 2e2e4f032a..28390e2a71 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_DebugStructureWriter.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_DebugStructureWriter.java @@ -38,6 +38,7 @@ public class GT_MetaTileEntity_DebugStructureWriter extends GT_MetaTileEntity_Ti public GT_MetaTileEntity_DebugStructureWriter(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { super(aName, aTier, 0, aDescription, aTextures); + Util.setTier(aTier,this); } @Override diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_OwnerDetector.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_OwnerDetector.java index ca2ff72f20..7f44fb45ca 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_OwnerDetector.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_OwnerDetector.java @@ -36,6 +36,7 @@ public class GT_MetaTileEntity_OwnerDetector extends GT_MetaTileEntity_TieredMac public GT_MetaTileEntity_OwnerDetector(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { super(aName, aTier, 0, aDescription, aTextures); + Util.setTier(aTier,this); } @Override diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_WetTransformer.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_WetTransformer.java index f32fc270e9..375e8ba655 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_WetTransformer.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_WetTransformer.java @@ -19,6 +19,7 @@ public class GT_MetaTileEntity_WetTransformer extends GT_MetaTileEntity_Transfor public GT_MetaTileEntity_WetTransformer(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { super(aName,aTier,aDescription,aTextures); + Util.setTier(aTier,this); } @Override diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/gui/GT_Container_DebugPollutor.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/gui/GT_Container_DebugPollutor.java new file mode 100644 index 0000000000..3374d874d4 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/gui/GT_Container_DebugPollutor.java @@ -0,0 +1,150 @@ +package com.github.technus.tectech.thing.metaTileEntity.single.gui; + +import com.github.technus.tectech.Util; +import com.github.technus.tectech.thing.metaTileEntity.single.GT_MetaTileEntity_DebugPollutor; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.gui.GT_ContainerMetaTile_Machine; +import gregtech.api.gui.GT_Slot_Holo; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +public class GT_Container_DebugPollutor + extends GT_ContainerMetaTile_Machine { + public int pollution =0; + public float anomaly =0; + + public GT_Container_DebugPollutor(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { + super(aInventoryPlayer, aTileEntity); + } + + @Override + public void addSlots(InventoryPlayer aInventoryPlayer) { + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 8, 5, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 8, 23, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 8, 41, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 8, 59, false, false, 1)); + + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 26, 5, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 26, 23, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 26, 41, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 26, 59, false, false, 1)); + + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 152, 5, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 152, 23, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 152, 41, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 152, 59, false, false, 1)); + + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 134, 5, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 134, 23, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 134, 41, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 134, 59, false, false, 1)); + } + + @Override + public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { + if (aSlotIndex < 0) { + return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + } + Slot tSlot = (Slot) inventorySlots.get(aSlotIndex); + if (tSlot != null && mTileEntity.getMetaTileEntity() != null) { + GT_MetaTileEntity_DebugPollutor dpg = (GT_MetaTileEntity_DebugPollutor) mTileEntity.getMetaTileEntity(); + switch (aSlotIndex) { + case 0: + dpg.pollution -= aShifthold == 1 ? 512 : 64; + break; + case 1: + dpg.pollution /= aShifthold == 1 ? 512 : 64; + break; + case 2: + dpg.anomaly -= aShifthold == 1 ? 512 : 64; + break; + case 3: + dpg.anomaly /= aShifthold == 1 ? 512 : 64; + break; + case 4: + dpg.pollution -= aShifthold == 1 ? 16 : 1; + break; + case 5: + dpg.pollution /= aShifthold == 1 ? 16 : 2; + break; + case 6: + dpg.anomaly -= aShifthold == 1 ? 16 : 1; + break; + case 7: + dpg.anomaly /= aShifthold == 1 ? 16 : 2; + break; + case 8: + dpg.pollution += aShifthold == 1 ? 512 : 64; + break; + case 9: + dpg.pollution *= aShifthold == 1 ? 512 : 64; + break; + case 10: + dpg.anomaly += aShifthold == 1 ? 512 : 64; + break; + case 11: + dpg.anomaly *= aShifthold == 1 ? 512 : 64; + break; + case 12: + dpg.pollution += aShifthold == 1 ? 16 : 1; + break; + case 13: + dpg.pollution *= aShifthold == 1 ? 16 : 2; + break; + case 14: + dpg.anomaly += aShifthold == 1 ? 16 : 1; + break; + case 15: + dpg.anomaly *= aShifthold == 1 ? 16 : 2; + break; + default: return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + } + if(dpg.anomaly==Float.POSITIVE_INFINITY){ + dpg.anomaly=Float.MAX_VALUE; + }else if (dpg.anomaly==Float.NEGATIVE_INFINITY){ + dpg.anomaly=-Float.MAX_VALUE; + } + return null; + } + return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + } + + @Override + public void detectAndSendChanges() { + super.detectAndSendChanges(); + if (mTileEntity.isClientSide() || mTileEntity.getMetaTileEntity() == null) { + return; + } + + GT_MetaTileEntity_DebugPollutor dpg = (GT_MetaTileEntity_DebugPollutor) mTileEntity.getMetaTileEntity(); + pollution =dpg.pollution; + anomaly =dpg.anomaly; + + for (Object crafter : crafters) { + ICrafting var1 = (ICrafting) crafter; + Util.sendInteger(pollution,this,var1,100); + Util.sendFloat(anomaly,this,var1,102); + } + } + + @Override + @SideOnly(Side.CLIENT) + public void updateProgressBar(int par1, int par2) { + super.updateProgressBar(par1, par2); + switch (par1) { + case 100: + case 101: + pollution = Util.receiveInteger(pollution,100,par1,par2); + break; + case 102: + case 103: + anomaly = Util.receiveFloat(anomaly,102,par1,par2); + break; + } + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/gui/GT_GUIContainer_DataReader.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/gui/GT_GUIContainer_DataReader.java index 97e7601b67..eb2c2e4112 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/gui/GT_GUIContainer_DataReader.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/gui/GT_GUIContainer_DataReader.java @@ -115,8 +115,8 @@ public class GT_GUIContainer_DataReader extends GT_GUIContainerMetaTile_Machine private void renderDataBG(ItemStack thing, int mouseX, int mouseY, int x, int y, byte mTier) { if (thing != null) { - ArrayList<GT_MetaTileEntity_DataReader.DataRender> renders = GT_MetaTileEntity_DataReader.getRenders(new Util.TT_ItemStack(thing)); - for (GT_MetaTileEntity_DataReader.DataRender render : renders) { + ArrayList<GT_MetaTileEntity_DataReader.IDataRender> renders = GT_MetaTileEntity_DataReader.getRenders(new Util.ItemStack_NoNBT(thing)); + for (GT_MetaTileEntity_DataReader.IDataRender render : renders) { if (render.canRender(thing, mTier)) { if (!GT_Utility.areStacksEqual(stack, thing, false)) { render.initRender(thing); @@ -133,8 +133,8 @@ public class GT_GUIContainer_DataReader extends GT_GUIContainerMetaTile_Machine if(stack==null){ return false; } - ArrayList<GT_MetaTileEntity_DataReader.DataRender> renders = GT_MetaTileEntity_DataReader.getRenders(new Util.TT_ItemStack(stack)); - for (GT_MetaTileEntity_DataReader.DataRender render : renders) { + ArrayList<GT_MetaTileEntity_DataReader.IDataRender> renders = GT_MetaTileEntity_DataReader.getRenders(new Util.ItemStack_NoNBT(stack)); + for (GT_MetaTileEntity_DataReader.IDataRender render : renders) { if (render.canRender(stack, mTier)) { render.renderForeground(stack, mouseX, mouseY, this, fontRendererObj); return true; @@ -147,8 +147,8 @@ public class GT_GUIContainer_DataReader extends GT_GUIContainerMetaTile_Machine if(stack==null){ return false; } - ArrayList<GT_MetaTileEntity_DataReader.DataRender> renders = GT_MetaTileEntity_DataReader.getRenders(new Util.TT_ItemStack(stack)); - for (GT_MetaTileEntity_DataReader.DataRender render : renders) { + ArrayList<GT_MetaTileEntity_DataReader.IDataRender> renders = GT_MetaTileEntity_DataReader.getRenders(new Util.ItemStack_NoNBT(stack)); + for (GT_MetaTileEntity_DataReader.IDataRender render : renders) { if (render.canRender(stack, mTier)) { render.renderTooltips(stack, mouseX, mouseY, this); return true; diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/gui/GT_GUIContainer_DebugPollutor.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/gui/GT_GUIContainer_DebugPollutor.java new file mode 100644 index 0000000000..39c67f1b50 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/gui/GT_GUIContainer_DebugPollutor.java @@ -0,0 +1,31 @@ +package com.github.technus.tectech.thing.metaTileEntity.single.gui; + +import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import net.minecraft.entity.player.InventoryPlayer; + +import static gregtech.api.enums.GT_Values.RES_PATH_GUI; + +public class GT_GUIContainer_DebugPollutor extends GT_GUIContainerMetaTile_Machine { + public GT_GUIContainer_DebugPollutor(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { + super(new GT_Container_DebugPollutor(aInventoryPlayer, aTileEntity), RES_PATH_GUI + "Teleporter.png"); + } + + @Override + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + fontRendererObj.drawString("Pollutor", 46, 8, 16448255); + if (mContainer != null) { + GT_Container_DebugPollutor dpg = (GT_Container_DebugPollutor) mContainer; + fontRendererObj.drawString("Pollution: " + dpg.pollution, 46, 24, 16448255); + fontRendererObj.drawString("Anomaly: " + dpg.anomaly, 46, 32, 16448255); + } + } + + @Override + protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { + super.drawGuiContainerBackgroundLayer(par1, par2, par3); + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + drawTexturedModalRect(x, y, 0, 0, xSize, ySize); + } +} diff --git a/src/main/resources/assets/gregtech/textures/blocks/iconsets/EM_LASER.png b/src/main/resources/assets/gregtech/textures/blocks/iconsets/EM_LASER.png Binary files differnew file mode 100644 index 0000000000..72e277673e --- /dev/null +++ b/src/main/resources/assets/gregtech/textures/blocks/iconsets/EM_LASER.png diff --git a/src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_ENERGY_IN_LASER.png b/src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_ENERGY_IN_LASER.png Binary files differnew file mode 100644 index 0000000000..51f387ba35 --- /dev/null +++ b/src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_ENERGY_IN_LASER.png diff --git a/src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_ENERGY_OUT_LASER.png b/src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_ENERGY_OUT_LASER.png Binary files differnew file mode 100644 index 0000000000..4706e3cf6a --- /dev/null +++ b/src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_ENERGY_OUT_LASER.png diff --git a/src/main/resources/assets/gregtech/textures/blocks/iconsets/POLLUTOR.png b/src/main/resources/assets/gregtech/textures/blocks/iconsets/POLLUTOR.png Binary files differnew file mode 100644 index 0000000000..c8c32d0ab4 --- /dev/null +++ b/src/main/resources/assets/gregtech/textures/blocks/iconsets/POLLUTOR.png diff --git a/src/main/resources/assets/tectech/lang/en_US.lang b/src/main/resources/assets/tectech/lang/en_US.lang index ccb17a8a0c..59a0d720de 100644 --- a/src/main/resources/assets/tectech/lang/en_US.lang +++ b/src/main/resources/assets/tectech/lang/en_US.lang @@ -13,4 +13,7 @@ death.attack.microwaving=%1$s was dehydrated by radiation. death.attack.microwaving.player=%1$s was dehydrated by radiation while fighting %2$s. death.attack.elementalPollution=%1$s was vaping from the wrong hole. -death.attack.elementalPollution.player=%1$s was vaping from the wrong hole while fighting %2$s.
\ No newline at end of file +death.attack.elementalPollution.player=%1$s was vaping from the wrong hole while fighting %2$s. + +death.attack.subspace=%1$s was N-th dimensionally displeased. +death.attack.subspace.player=%1$s N-th dimensionally displeased while fighting %2$s.
\ No newline at end of file |