diff options
92 files changed, 5514 insertions, 365 deletions
diff --git a/build.gradle b/build.gradle index ae10e3f9a3..229a4f71c1 100644 --- a/build.gradle +++ b/build.gradle @@ -21,8 +21,14 @@ plugins { } apply plugin: 'forge' -apply plugin: 'idea' apply plugin: 'signing' +apply plugin: 'idea' +idea{ + module { + downloadJavadoc = true + downloadSources = true + } +} import de.undercouch.gradle.tasks.download.Download @@ -61,10 +67,34 @@ repositories { name = "ic2" url = "http://maven.ic2.player.to/" } + maven { // AppleCore + url "http://www.ryanliptak.com/maven/" + } + maven { // GalacticGreg, YAMCore,.. + name 'UsrvDE' + url "http://jenkins.usrv.eu:8081/nexus/content/repositories/releases/" + } + ivy { + name 'gtnh_download_source_stupid_underscore_typo' + artifactPattern "http://downloads.gtnewhorizons.com/Mods_for_Jenkins/[module]_[revision].[ext]" + } + ivy { + name 'gtnh_download_source' + artifactPattern "http://downloads.gtnewhorizons.com/Mods_for_Jenkins/[module]-[revision].[ext]" + } + maven { + name = "gt" + url = "https://gregtech.overminddl1.com/" + } + } dependencies { compile "net.industrial-craft:industrialcraft-2:${config.ic2.version}:dev" + compileOnly "applecore:AppleCore:${config.applecore.version}:api" + compile "micdoodle8.mods:MicdoodleCore:${config.galacticraft.version}:Dev" + compile "micdoodle8.mods:GalacticraftCore:${config.galacticraft.version}:Dev" + compile "micdoodle8.mods:Galacticraft-Planets:${config.galacticraft.version}:Dev" } //task getGregTech(type: Download) { @@ -102,6 +132,13 @@ processResources } } +jar { + manifest { + attributes 'FMLCorePlugin': 'com.github.bartimaeusnek.ASM.BWCorePlugin', + 'FMLCorePluginContainsFMLMod': 'true' + } +} + task apiJar(type: Jar){ from(sourceSets.main.output) { include 'com/github/bartimaeusnek/bartworks/API/**' diff --git a/build.properties b/build.properties index 72b745fd12..22690fd078 100644 --- a/build.properties +++ b/build.properties @@ -22,9 +22,11 @@ mc_version=1.7.10 majorUpdate=0 -minorUpdate=3 -buildNumber=24 -APIVersion=4 +minorUpdate=4 +buildNumber=7 +APIVersion=6 ic2.version=2.2.828-experimental gregtech.version=5.09.32.36 -gregtech.jenkinsbuild=143
\ No newline at end of file +gregtech.jenkinsbuild=143 +applecore.version=1.7.10-3.1.1 +galacticraft.version=1.7-3.0.12.504
\ No newline at end of file diff --git a/src/main/java/com/github/bartimaeusnek/ASM/ASMUtils.java b/src/main/java/com/github/bartimaeusnek/ASM/ASMUtils.java new file mode 100644 index 0000000000..f4b61a17ba --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/ASM/ASMUtils.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2019 bartimaeusnek + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.bartimaeusnek.ASM; + +import org.objectweb.asm.tree.MethodNode; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; + +public class ASMUtils { + + public static String matchAny(String toCompare, String... args) { + for (int i = 0; i < args.length; i++) { + if (toCompare.equalsIgnoreCase(args[i])) + return args[i]; + } + return ""; + } + + /** + * Call this Method twice, one time for the Descriptor and one time for the Name. + */ + public static boolean isCorrectMethod(MethodNode methodNode, String... args) { + for (int i = 0; i < args.length; i++) { + if (methodNode.name.equalsIgnoreCase(args[i]) || methodNode.desc.equalsIgnoreCase(args[i])) + return true; + } + return false; + } + + public static boolean writeClassToDisk(byte[] towrite, String Classname, String Path) { + try { + OutputStream os = new FileOutputStream(new File(Path + Classname + ".class")); + os.write(towrite); + } catch (IOException e) { + e.printStackTrace(); + return false; + } + return true; + } + +} diff --git a/src/main/java/com/github/bartimaeusnek/ASM/BWCore.java b/src/main/java/com/github/bartimaeusnek/ASM/BWCore.java new file mode 100644 index 0000000000..9c76b3dd82 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/ASM/BWCore.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2019 bartimaeusnek + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.bartimaeusnek.ASM; + +import com.github.bartimaeusnek.crossmod.BartWorksCrossmod; +import com.google.common.eventbus.EventBus; +import com.google.common.eventbus.Subscribe; +import cpw.mods.fml.common.DummyModContainer; +import cpw.mods.fml.common.LoadController; +import cpw.mods.fml.common.ModMetadata; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import cpw.mods.fml.common.versioning.ArtifactVersion; +import cpw.mods.fml.common.versioning.DefaultArtifactVersion; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import java.util.ArrayList; +import java.util.List; + +public class BWCore extends DummyModContainer { + + public static final String BWCORE_NAME = "BartWorks ASM Core"; + public static final Logger BWCORE_LOG = LogManager.getLogger(BWCORE_NAME); + + public BWCore() { + super(new ModMetadata()); + ModMetadata metadata = getMetadata(); + metadata.modId = "BWCore"; + metadata.name = BWCORE_NAME; + metadata.version = "0.0.1"; + metadata.authorList.add("bartimaeusnek"); + metadata.dependants = getDependants(); + } + + @Subscribe + public void preInit(FMLPreInitializationEvent event) { + } + + @Override + public List<ArtifactVersion> getDependants() { + List<ArtifactVersion> ret = new ArrayList<ArtifactVersion>(); + ret.add(new DefaultArtifactVersion("ExtraUtilities", true)); + ret.add(new DefaultArtifactVersion(BartWorksCrossmod.MOD_ID, true)); + return ret; + } + + @Override + public boolean registerBus(EventBus bus, LoadController controller) { + bus.register(this); + return true; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/ASM/BWCorePlugin.java b/src/main/java/com/github/bartimaeusnek/ASM/BWCorePlugin.java new file mode 100644 index 0000000000..018690d312 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/ASM/BWCorePlugin.java @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2019 bartimaeusnek + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.bartimaeusnek.ASM; + +import cpw.mods.fml.relauncher.FMLInjectionData; +import cpw.mods.fml.relauncher.IFMLLoadingPlugin; +import net.minecraftforge.common.config.Configuration; + +import java.io.File; +import java.util.Map; + +@IFMLLoadingPlugin.SortingIndex(999999999)//Load as late as possible (after fastcraft/OptiFine). +@IFMLLoadingPlugin.MCVersion("1.7.10") +@IFMLLoadingPlugin.TransformerExclusions({"com.github.bartimaeusnek.ASM"}) +@IFMLLoadingPlugin.Name(BWCorePlugin.BWCORE_PLUGIN_NAME) +public class BWCorePlugin implements IFMLLoadingPlugin { + + public static final String BWCORE_PLUGIN_NAME = "BartWorks ASM Core Plugin"; + + public static File minecraftDir = null; + + public BWCorePlugin() { + //Injection Code taken from CodeChickenLib + if (minecraftDir != null) + return;//get called twice, once for IFMLCallHook + minecraftDir = (File) FMLInjectionData.data()[6]; + + Configuration asmconfighandler = new Configuration(new File(new File(minecraftDir, "config"), "bartworks.cfg")); + for (int i = 0; i < BWCoreTransformer.CLASSESBEEINGTRANSFORMED.length; i++) { + BWCoreTransformer.shouldTransform[i] = asmconfighandler.get("ASM fixes", BWCoreTransformer.DESCRIPTIONFORCONFIG[i] + " in class: " + BWCoreTransformer.CLASSESBEEINGTRANSFORMED[i], true).getBoolean(true); + } + if (asmconfighandler.hasChanged()) + asmconfighandler.save(); + } + + @Override + public String[] getASMTransformerClass() { + return new String[]{BWCoreTransformer.class.getName()}; + } + + @Override + public String getModContainerClass() { + return BWCore.class.getName(); + } + + @Override + public String getSetupClass() { + return null; + } + + @Override + public void injectData(Map<String, Object> data) { + if (data.get("runtimeDeobfuscationEnabled") != null) { + BWCoreTransformer.obfs = (boolean) data.get("runtimeDeobfuscationEnabled"); + } + } + + @Override + public String getAccessTransformerClass() { + return null; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/ASM/BWCoreStaticReplacementMethodes.java b/src/main/java/com/github/bartimaeusnek/ASM/BWCoreStaticReplacementMethodes.java new file mode 100644 index 0000000000..505612cd35 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/ASM/BWCoreStaticReplacementMethodes.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2019 bartimaeusnek + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.bartimaeusnek.ASM; + +public class BWCoreStaticReplacementMethodes { + private BWCoreStaticReplacementMethodes() { + } + +} diff --git a/src/main/java/com/github/bartimaeusnek/ASM/BWCoreTransformer.java b/src/main/java/com/github/bartimaeusnek/ASM/BWCoreTransformer.java new file mode 100644 index 0000000000..6a9850e4fe --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/ASM/BWCoreTransformer.java @@ -0,0 +1,205 @@ +/* + * Copyright (c) 2019 bartimaeusnek + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.bartimaeusnek.ASM; + +import net.minecraft.launchwrapper.IClassTransformer; +import org.apache.commons.lang3.ArrayUtils; +import org.objectweb.asm.ClassReader; +import org.objectweb.asm.ClassWriter; +import org.objectweb.asm.tree.*; + +import java.util.Arrays; +import java.util.List; + +import static org.objectweb.asm.Opcodes.*; + +public class BWCoreTransformer implements IClassTransformer { + public static final String[] DESCRIPTIONFORCONFIG = { + "REMOVING RAIN FROM LAST MILLENIUM (EXU)", + "REMVOING CREATURES FROM LAST MILLENIUM (EXU)", + "PATCHING GLOBAL RENDERER FOR USE WITH MY GALACTIC DIMS" + }; + public static final String[] CLASSESBEEINGTRANSFORMED = { + "com.rwtema.extrautils.worldgen.endoftime.WorldProviderEndOfTime", + "com.rwtema.extrautils.worldgen.endoftime.ChunkProviderEndOfTime", + //"micdoodle8.mods.galacticraft.core.client.SkyProviderOverworld", + "net.minecraft.client.renderer.RenderGlobal", + }; + public static boolean obfs = false; + public static boolean[] shouldTransform = ArrayUtils.toPrimitive(new Boolean[BWCoreTransformer.CLASSESBEEINGTRANSFORMED.length], true); + + public static byte[] transform(int id, byte[] basicClass) { + if (!BWCoreTransformer.shouldTransform[id]) { + BWCore.BWCORE_LOG.info("Patch: " + DESCRIPTIONFORCONFIG[id] + " is disabled, will not patch!"); + return basicClass; + } + + if (id < BWCoreTransformer.CLASSESBEEINGTRANSFORMED.length) { + BWCore.BWCORE_LOG.info(DESCRIPTIONFORCONFIG[id]); + ClassReader classReader = new ClassReader(basicClass); + ClassNode classNode = new ClassNode(); + classReader.accept(classNode, ClassReader.SKIP_FRAMES); + List<MethodNode> methods = classNode.methods; + switch (id) { + case 0: { + BWCore.BWCORE_LOG.info("Could find: " + CLASSESBEEINGTRANSFORMED[id]); + String name_deObfs = "canDoRainSnowIce"; + + String dsc_deObfs = "(Lnet/minecraft/world/chunk/Chunk;)Z"; + String dsc_Obfs = "(Lapx;)Z"; + for (int i = 0; i < methods.size(); i++) { + if (methods.get(i).name.equalsIgnoreCase(name_deObfs)) { + BWCore.BWCORE_LOG.info("Found " + name_deObfs + "! Removing!"); + methods.remove(i); + break; + } + } + BWCore.BWCORE_LOG.info("Creating new " + name_deObfs + "!"); + MethodNode nu = new MethodNode(ACC_PUBLIC, name_deObfs, + /*obfs ? dsc_Obfs :*/ dsc_deObfs, + null, + new String[0] + ); + InsnList insnList = new InsnList(); + insnList.add(new InsnNode(ICONST_0)); + insnList.add(new InsnNode(IRETURN)); + nu.instructions = insnList; + nu.maxLocals = 1; + nu.maxStack = 1; + methods.add(nu); + break; + } + case 1: { + BWCore.BWCORE_LOG.info("Could find: " + CLASSESBEEINGTRANSFORMED[id]); + String name_deObfs = "getPossibleCreatures"; + String name_src = "func_73155_a"; + String name_Obfs = "a"; + String dsc_deObfs = "(Lnet/minecraft/entity/EnumCreatureType;III)Ljava/util/List;"; + String dsc_Obfs = "(Lsx;III)Ljava/util/List;"; + + for (int i = 0; i < methods.size(); i++) { + if (ASMUtils.isCorrectMethod(methods.get(i), name_deObfs, name_Obfs, name_src) && ASMUtils.isCorrectMethod(methods.get(i), dsc_deObfs, dsc_Obfs)) { + BWCore.BWCORE_LOG.info("Found " + (name_deObfs) + "! Patching!"); + MethodNode toPatch = methods.get(i); + InsnList insnList = new InsnList(); + insnList.add(new InsnNode(ACONST_NULL)); + insnList.add(new InsnNode(ARETURN)); + toPatch.instructions = insnList; + toPatch.maxStack = 1; + toPatch.maxLocals = 5; + methods.set(i, toPatch); + break; + } + } + break; + } + case 2: { + String name_deObfs = "renderSky"; + String name_src = "func_72714_a"; + String name_Obfs = "a"; + String dsc_universal = "(F)V"; + String field_deObfs = "locationSunPng"; + String field_src = "field_110928_i"; + BWCore.BWCORE_LOG.info("Could find: " + CLASSESBEEINGTRANSFORMED[id]); + for (int i = 0; i < methods.size(); i++) { + MethodNode toPatch = methods.get(i); + if (ASMUtils.isCorrectMethod(methods.get(i), name_deObfs, name_Obfs, name_src) && ASMUtils.isCorrectMethod(methods.get(i), dsc_universal)) { + BWCore.BWCORE_LOG.info("Found " + (name_deObfs) + "! Patching!"); + InsnList nu = new InsnList(); + LabelNode[] LabelNodes = {new LabelNode(), new LabelNode()}; + + String theWorld_src = "field_72769_h"; + String renderEngine_src = "field_72770_i"; + String provider_src = "field_73011_w"; + String bindTexture_src = "func_110577_a"; + String nameFieldToPatch; + + for (int j = 0; j < toPatch.instructions.size(); j++) { + if (toPatch.instructions.get(j) instanceof FieldInsnNode && ((FieldInsnNode) toPatch.instructions.get(j)).getOpcode() == GETSTATIC && !(nameFieldToPatch = ASMUtils.matchAny(((FieldInsnNode) toPatch.instructions.get(j)).name, field_deObfs, field_src)).isEmpty()) { + boolean useSrc = nameFieldToPatch.equals(field_src); + if (useSrc) + BWCore.BWCORE_LOG.info("Found either Optifine or Fastcraft... this patch was annoying to make compatible to them..."); + + nu.add(new VarInsnNode(ALOAD, 0)); + nu.add(new FieldInsnNode(GETFIELD, "net/minecraft/client/renderer/RenderGlobal", useSrc ? theWorld_src : "theWorld", "Lnet/minecraft/client/multiplayer/WorldClient;")); + nu.add(new FieldInsnNode(GETFIELD, "net/minecraft/client/multiplayer/WorldClient", useSrc ? provider_src : "provider", "Lnet/minecraft/world/WorldProvider;")); + nu.add(new TypeInsnNode(INSTANCEOF, "com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128/world/worldprovider/WorldProviderRoss128b")); + nu.add(new JumpInsnNode(IFEQ, LabelNodes[0])); + nu.add(new VarInsnNode(ALOAD, 0)); + nu.add(new FieldInsnNode(GETFIELD, "net/minecraft/client/renderer/RenderGlobal", useSrc ? renderEngine_src : "renderEngine", "Lnet/minecraft/client/renderer/texture/TextureManager;")); + nu.add(new FieldInsnNode(GETSTATIC, "com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128/world/worldprovider/SkyProviderRoss128b", "sunTex", "Lnet/minecraft/util/ResourceLocation;")); + nu.add(new MethodInsnNode(INVOKEVIRTUAL, "net/minecraft/client/renderer/texture/TextureManager", useSrc ? bindTexture_src : "bindTexture", "(Lnet/minecraft/util/ResourceLocation;)V", false)); + nu.add(new JumpInsnNode(GOTO, LabelNodes[1])); + nu.add(LabelNodes[0]); + nu.add(new VarInsnNode(ALOAD, 0)); + nu.add(new FieldInsnNode(GETFIELD, "net/minecraft/client/renderer/RenderGlobal", useSrc ? renderEngine_src : "renderEngine", "Lnet/minecraft/client/renderer/texture/TextureManager;")); + nu.add(new FieldInsnNode(GETSTATIC, "net/minecraft/client/renderer/RenderGlobal", useSrc ? field_src : "locationSunPng", "Lnet/minecraft/util/ResourceLocation;")); + nu.add(new MethodInsnNode(INVOKEVIRTUAL, "net/minecraft/client/renderer/texture/TextureManager", useSrc ? bindTexture_src : "bindTexture", "(Lnet/minecraft/util/ResourceLocation;)V", false)); + nu.add(LabelNodes[1]); + j++; + + } else { + if (j < toPatch.instructions.size() - 2) { + if (toPatch.instructions.get(j + 2) instanceof FieldInsnNode && ((FieldInsnNode) toPatch.instructions.get(j + 2)).getOpcode() == GETSTATIC && !ASMUtils.matchAny(((FieldInsnNode) toPatch.instructions.get(j + 2)).name, field_deObfs, field_src).isEmpty()) + continue; + if (toPatch.instructions.get(j + 1) instanceof FieldInsnNode && ((FieldInsnNode) toPatch.instructions.get(j + 1)).getOpcode() == GETSTATIC && !ASMUtils.matchAny(((FieldInsnNode) toPatch.instructions.get(j + 1)).name, field_deObfs, field_src).isEmpty()) + continue; + } + nu.add(toPatch.instructions.get(j)); + } + } + toPatch.instructions = nu; + break; + } + } + break; + } + default: { + BWCore.BWCORE_LOG.info("Could not find: " + CLASSESBEEINGTRANSFORMED[id]); + return basicClass; + } + } + + classNode.methods = methods; + ClassWriter classWriter = new ClassWriter(ClassWriter.COMPUTE_FRAMES); + classNode.accept(classWriter); + byte[] ret = classWriter.toByteArray(); + if (Arrays.hashCode(basicClass) == Arrays.hashCode(ret)) + BWCore.BWCORE_LOG.warn("Could not patch: " + CLASSESBEEINGTRANSFORMED[id]); + + return ret; + } + return basicClass; + } + + @Override + public byte[] transform(String name, String transformedName, byte[] basicClass) { + for (int i = 0; i < BWCoreTransformer.CLASSESBEEINGTRANSFORMED.length; i++) { + if (name.equalsIgnoreCase(BWCoreTransformer.CLASSESBEEINGTRANSFORMED[i]) || transformedName.equalsIgnoreCase(BWCoreTransformer.CLASSESBEEINGTRANSFORMED[i])) + return BWCoreTransformer.transform(i, basicClass); + } + return basicClass; + } + + +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/API/BioObjectAdder.java b/src/main/java/com/github/bartimaeusnek/bartworks/API/BioObjectAdder.java index 92600b5bfe..3dcd7596fb 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/API/BioObjectAdder.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/API/BioObjectAdder.java @@ -150,19 +150,19 @@ public final class BioObjectAdder { * @param voltageTier (i.e. 6 for LuV, 7 for ZPM, only intresting for LuV+) * @return the propper Bacteria Tier (at least 0) */ - public static int getBacteriaTierFromVoltageTier(int voltageTier){ - return voltageTier-6 > 0 ? voltageTier-6 : 0; + public static int getBacteriaTierFromVoltageTier(int voltageTier) { + return voltageTier - 6 > 0 ? voltageTier - 6 : 0; } /** * If you get NPE's related to BioCultures (most likely because of Load Order or creating BioCultures after the postinit Phase) execute this. */ - public static void regenerateBioFluids(){ + public static void regenerateBioFluids() { for (BioCulture B : BioCulture.BIO_CULTURE_ARRAY_LIST) { if (B.getFluidNotSet()) { B.setFluid(new GT_Fluid(B.getName().replaceAll(" ", "").toLowerCase() + "fluid", "molten.autogenerated", new short[]{(short) B.getColor().getRed(), (short) B.getColor().getBlue(), (short) B.getColor().getGreen()})); if (!FluidRegistry.registerFluid(B.getFluid())) - new Exception("FAILED TO REGISTER FLUID FOR: "+B.getName()).printStackTrace(); + new Exception("FAILED TO REGISTER FLUID FOR: " + B.getName()).printStackTrace(); } } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/API/ITileDropsContent.java b/src/main/java/com/github/bartimaeusnek/bartworks/API/ITileDropsContent.java new file mode 100644 index 0000000000..a84f254d8a --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/API/ITileDropsContent.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2019 bartimaeusnek + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.API; + +import net.minecraft.inventory.ISidedInventory; + +public interface ITileDropsContent extends ISidedInventory { + default int[] getDropSlots(){ + return new int[] {0}; + }; + +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/API/WerkstoffAdderRegistry.java b/src/main/java/com/github/bartimaeusnek/bartworks/API/WerkstoffAdderRegistry.java new file mode 100644 index 0000000000..6437ad1087 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/API/WerkstoffAdderRegistry.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2019 bartimaeusnek + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.API; + +import java.util.HashSet; + +public final class WerkstoffAdderRegistry implements Runnable { + + private static final WerkstoffAdderRegistry INSTANCE = new WerkstoffAdderRegistry(); + private final HashSet<Runnable> toRun = new HashSet<>(); + + private WerkstoffAdderRegistry() { + } + + public static final WerkstoffAdderRegistry getINSTANCE() { + return INSTANCE; + } + + public static final void addWerkstoffAdder(Runnable adder) { + INSTANCE.toRun.add(adder); + } + + @Override + public final void run() { + for (Runnable r : toRun) + r.run(); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java b/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java index 56d15fa479..2156adb295 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java @@ -35,32 +35,26 @@ import com.github.bartimaeusnek.bartworks.common.loaders.BioLabLoader; import com.github.bartimaeusnek.bartworks.common.loaders.GTNHBlocks; import com.github.bartimaeusnek.bartworks.common.loaders.LoaderRegistry; import com.github.bartimaeusnek.bartworks.common.net.BW_Network; -import com.github.bartimaeusnek.bartworks.util.BW_Util; +import com.github.bartimaeusnek.bartworks.system.log.DebugLog; +import com.github.bartimaeusnek.bartworks.system.material.ThreadedLoader; +import com.github.bartimaeusnek.bartworks.system.material.Werkstoff; +import com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.Mod; 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.FMLServerStartedEvent; import cpw.mods.fml.common.network.IGuiHandler; import cpw.mods.fml.common.network.NetworkRegistry; -import gregtech.api.enums.ItemList; import gregtech.api.enums.Materials; import gregtech.api.enums.SubTag; -import gregtech.api.util.GT_ModHandler; -import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GT_Utility; import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; import net.minecraftforge.common.MinecraftForge; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import java.util.HashSet; - -import static com.github.bartimaeusnek.bartworks.common.tileentities.multis.GT_TileEntity_ElectricImplosionCompressor.eicMap; +import java.io.IOException; @Mod( modid = MainMod.MOD_ID, name = MainMod.NAME, version = MainMod.VERSION, @@ -97,6 +91,13 @@ public final class MainMod { GTNH = true; } CHandler = new ConfigHandler(preinit); + if (ConfigHandler.debugLog) { + try { + new DebugLog(preinit); + } catch (IOException e) { + e.printStackTrace(); + } + } if (GTNH) LOGGER.info("GTNH-Detected . . . ACTIVATE HARDMODE."); @@ -104,6 +105,10 @@ public final class MainMod { BioCultureLoader bioCultureLoader = new BioCultureLoader(); bioCultureLoader.run(); } + if (ConfigHandler.newStuff) { + WerkstoffLoader.INSTANCE.init(); + Werkstoff.init(); + } } @Mod.EventHandler @@ -113,6 +118,12 @@ public final class MainMod { new LoaderRegistry().run(); if (ConfigHandler.BioLab) new BioLabLoader().run(); + if (ConfigHandler.newStuff) { + if (ConfigHandler.experimentalThreadedLoader) + new ThreadedLoader().runInit(); + else + WerkstoffLoader.INSTANCE.runInit(); + } } @Mod.EventHandler @@ -121,30 +132,37 @@ public final class MainMod { if (ConfigHandler.BioLab) new GTNHBlocks().run(); BioObjectAdder.regenerateBioFluids(); - } - - @Mod.EventHandler - public void onServerStarted(FMLServerStartedEvent event){ - eicMap = new GT_Recipe.GT_Recipe_Map(new HashSet(GT_Recipe.GT_Recipe_Map.sImplosionRecipes.mRecipeList.size()), "gt.recipe.electricimplosioncompressor", "Electric Implosion Compressor", (String)null, "gregtech:textures/gui/basicmachines/Default", 1, 2, 1, 0, 1, "", 1, "", true, true); - for (GT_Recipe recipe : GT_Recipe.GT_Recipe_Map.sImplosionRecipes.mRecipeList){ - if (recipe == null || recipe.mInputs == null) - continue; - ItemStack input = recipe.mInputs[0]; - int i = 0; - while(checkForExplosives(input)){ - try { - i++; - input = recipe.mInputs[i]; - }catch (ArrayIndexOutOfBoundsException e){ - LOGGER.error("CAUGHT DEFECTIVE IMPLOSION COMPRESSOR RECIPE."); - e.printStackTrace(); - } - } - eicMap.addRecipe(true,new ItemStack[]{input}, recipe.mOutputs,null,null,null,recipe.mDuration, BW_Util.getMachineVoltageFromTier(10),0); + if (ConfigHandler.newStuff) { + if (ConfigHandler.experimentalThreadedLoader) + new ThreadedLoader().run(); + else + WerkstoffLoader.INSTANCE.run(); } + ConfigHandler.setUpComments(); } - private boolean checkForExplosives(ItemStack input){ - return (GT_Utility.areStacksEqual(input,new ItemStack(Blocks.tnt)) || GT_Utility.areStacksEqual(input, GT_ModHandler.getIC2Item("industrialTnt", 1L)) || GT_Utility.areStacksEqual(input, GT_ModHandler.getIC2Item("dynamite", 1L))|| GT_Utility.areStacksEqual(input, ItemList.Block_Powderbarrel.get(1L))); - } +// @Mod.EventHandler +// public void onServerStarted(FMLServerStartedEvent event) { +// eicMap = new GT_Recipe.GT_Recipe_Map(new HashSet(GT_Recipe.GT_Recipe_Map.sImplosionRecipes.mRecipeList.size()), "gt.recipe.electricimplosioncompressor", "Electric Implosion Compressor", (String) null, "gregtech:textures/gui/basicmachines/Default", 1, 2, 1, 0, 1, "", 1, "", true, true); +// for (GT_Recipe recipe : GT_Recipe.GT_Recipe_Map.sImplosionRecipes.mRecipeList) { +// if (recipe == null || recipe.mInputs == null) +// continue; +// ItemStack input = recipe.mInputs[0]; +// int i = 0; +// while (checkForExplosives(input)) { +// try { +// i++; +// input = recipe.mInputs[i]; +// } catch (ArrayIndexOutOfBoundsException e) { +// LOGGER.error("CAUGHT DEFECTIVE IMPLOSION COMPRESSOR RECIPE."); +// e.printStackTrace(); +// } +// } +// eicMap.addRecipe(true, new ItemStack[]{input}, recipe.mOutputs, null, null, null, recipe.mDuration, BW_Util.getMachineVoltageFromTier(10), 0); +// } +// } +// +// private boolean checkForExplosives(ItemStack input) { +// return (GT_Utility.areStacksEqual(input, new ItemStack(Blocks.tnt)) || GT_Utility.areStacksEqual(input, GT_ModHandler.getIC2Item("industrialTnt", 1L)) || GT_Utility.areStacksEqual(input, GT_ModHandler.getIC2Item("dynamite", 1L)) || GT_Utility.areStacksEqual(input, ItemList.Block_Powderbarrel.get(1L))); +// } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/client/ClientEventHandler/ClientEventHandler.java b/src/main/java/com/github/bartimaeusnek/bartworks/client/ClientEventHandler/ClientEventHandler.java index 79f3cf387e..5888b88ef2 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/client/ClientEventHandler/ClientEventHandler.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/client/ClientEventHandler/ClientEventHandler.java @@ -23,46 +23,85 @@ package com.github.bartimaeusnek.bartworks.client.ClientEventHandler; import com.github.bartimaeusnek.bartworks.API.BioVatLogicAdder; +import com.github.bartimaeusnek.bartworks.MainMod; import com.github.bartimaeusnek.bartworks.common.blocks.BW_Blocks; -import com.github.bartimaeusnek.bartworks.util.BW_Util; +import com.github.bartimaeusnek.bartworks.system.material.OreDictHandler; +import com.github.bartimaeusnek.bartworks.util.BW_ColorUtil; import com.github.bartimaeusnek.bartworks.util.ChatColorHelper; +import com.github.bartimaeusnek.crossmod.BartWorksCrossmod; +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.ModContainer; import cpw.mods.fml.common.eventhandler.EventPriority; import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.GT_Values; +import gregtech.api.util.GT_Utility; import net.minecraft.block.Block; import net.minecraft.block.material.Material; +import net.minecraft.item.ItemStack; import net.minecraft.util.StatCollector; import net.minecraftforge.event.entity.player.ItemTooltipEvent; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; @SideOnly(Side.CLIENT) public class ClientEventHandler { + HashMap<ItemStack, List<String>> cache = new HashMap<>(); + @SideOnly(Side.CLIENT) @SubscribeEvent(priority = EventPriority.HIGHEST) public void getTooltip(ItemTooltipEvent event) { - if (event.itemStack == null || event.itemStack.getItem() == null || Block.getBlockFromItem(event.itemStack.getItem()) == null || event.itemStack.getItemDamage() > 127) + if (event.itemStack == null || event.itemStack.getItem() == null || Block.getBlockFromItem(event.itemStack.getItem()) == null) return; - final Block BLOCK = Block.getBlockFromItem(event.itemStack.getItem()); - if (BLOCK instanceof BW_Blocks) { - return; - } - final BioVatLogicAdder.BlockMetaPair PAIR = new BioVatLogicAdder.BlockMetaPair(BLOCK, (byte) event.itemStack.getItemDamage()); - final HashMap<BioVatLogicAdder.BlockMetaPair, Byte> GLASSMAP = BioVatLogicAdder.BioVatGlass.getGlassMap(); - if (GLASSMAP.containsKey(PAIR)) { - int tier = GLASSMAP.get(PAIR); - event.toolTip.add( - StatCollector.translateToLocal("tooltip.glas.0.name")+ - " " - + BW_Util.getColorForTier(tier) + GT_Values.VN[tier] + ChatColorHelper.RESET); - } else if (BLOCK.getMaterial().equals(Material.glass)) { - event.toolTip.add(StatCollector.translateToLocal("tooltip.glas.0.name")+ - " " - + BW_Util.getColorForTier(3) + GT_Values.VN[3] + ChatColorHelper.RESET); + if (!cache.containsKey(event.itemStack)) { + List<String> tooAdd = new ArrayList<>(); + + for (ItemStack stack : OreDictHandler.getCache().values()) { + if (GT_Utility.areStacksEqual(event.itemStack, stack)) { + GameRegistry.UniqueIdentifier UI = GameRegistry.findUniqueIdentifierFor(stack.getItem()); + if (UI == null) + UI = GameRegistry.findUniqueIdentifierFor(Block.getBlockFromItem(stack.getItem())); + if (UI != null) { + for (ModContainer modContainer : Loader.instance().getModList()) { + if (UI.modId.equals(MainMod.MOD_ID) || UI.modId.equals(BartWorksCrossmod.MOD_ID) || UI.modId.equals("BWCore")) + break; + if (UI.modId.equals(modContainer.getModId())) { + tooAdd.add("Shared ItemStack between " + ChatColorHelper.DARKGREEN + "BartWorks" + ChatColorHelper.GRAY + " and " + ChatColorHelper.RED + modContainer.getName()); + } + } + } else + tooAdd.add("Shared ItemStack between " + ChatColorHelper.DARKGREEN + "BartWorks" + ChatColorHelper.GRAY + " and another Mod, that doesn't use the ModContainer propperly!"); + } + } + + final Block BLOCK = Block.getBlockFromItem(event.itemStack.getItem()); + if (BLOCK instanceof BW_Blocks) { + cache.put(event.itemStack, tooAdd); + return; + } + final BioVatLogicAdder.BlockMetaPair PAIR = new BioVatLogicAdder.BlockMetaPair(BLOCK, (byte) event.itemStack.getItemDamage()); + final HashMap<BioVatLogicAdder.BlockMetaPair, Byte> GLASSMAP = BioVatLogicAdder.BioVatGlass.getGlassMap(); + if (GLASSMAP.containsKey(PAIR)) { + int tier = GLASSMAP.get(PAIR); + tooAdd.add( + StatCollector.translateToLocal("tooltip.glas.0.name") + + " " + + BW_ColorUtil.getColorForTier(tier) + GT_Values.VN[tier] + ChatColorHelper.RESET); + } else if (BLOCK.getMaterial().equals(Material.glass)) { + tooAdd.add(StatCollector.translateToLocal("tooltip.glas.0.name") + + " " + + BW_ColorUtil.getColorForTier(3) + GT_Values.VN[3] + ChatColorHelper.RESET); + } + cache.put(event.itemStack, tooAdd); + event.toolTip.addAll(tooAdd); + } else { + event.toolTip.addAll(cache.get(event.itemStack)); } } }
\ No newline at end of file diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/client/gui/GT_GUIContainer_RadioHatch.java b/src/main/java/com/github/bartimaeusnek/bartworks/client/gui/GT_GUIContainer_RadioHatch.java index 3cdaddc85b..2ae5bf6317 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/client/gui/GT_GUIContainer_RadioHatch.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/client/gui/GT_GUIContainer_RadioHatch.java @@ -64,9 +64,9 @@ public class GT_GUIContainer_RadioHatch extends GT_GUIContainerMetaTile_Machine this.drawTexturedModalRect(65, 13, 192, 0, (48 * (((GT_Container_RadioHatch) mContainer).sv)) / (maxSv), 16); -// this.fontRendererObj.drawString("Sv: " + ((GT_Container_RadioHatch) mContainer).sievert, 8, 50, BW_Util.getColorFromArray(new short[]{((GT_Container_RadioHatch) mContainer).r, ((GT_Container_RadioHatch) mContainer).g, ((GT_Container_RadioHatch) mContainer).b})); -// this.fontRendererObj.drawString("Kg: " + ((GT_Container_RadioHatch) mContainer).mass, 8, 68, BW_Util.getColorFromArray(new short[]{((GT_Container_RadioHatch) mContainer).r, ((GT_Container_RadioHatch) mContainer).g, ((GT_Container_RadioHatch) mContainer).b})); -// this.fontRendererObj.drawString("Time: " + timer, 8, 76, BW_Util.getColorFromArray(new short[]{((GT_Container_RadioHatch) mContainer).r, ((GT_Container_RadioHatch) mContainer).g, ((GT_Container_RadioHatch) mContainer).b})); +// this.fontRendererObj.drawString("Sv: " + ((GT_Container_RadioHatch) mContainer).sievert, 8, 50, BW_Util.getColorFromRGBArray(new short[]{((GT_Container_RadioHatch) mContainer).r, ((GT_Container_RadioHatch) mContainer).g, ((GT_Container_RadioHatch) mContainer).b})); +// this.fontRendererObj.drawString("Kg: " + ((GT_Container_RadioHatch) mContainer).mass, 8, 68, BW_Util.getColorFromRGBArray(new short[]{((GT_Container_RadioHatch) mContainer).r, ((GT_Container_RadioHatch) mContainer).g, ((GT_Container_RadioHatch) mContainer).b})); +// this.fontRendererObj.drawString("Time: " + timer, 8, 76, BW_Util.getColorFromRGBArray(new short[]{((GT_Container_RadioHatch) mContainer).r, ((GT_Container_RadioHatch) mContainer).g, ((GT_Container_RadioHatch) mContainer).b})); } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/BW_Renderer_Block_Ores.java b/src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/BW_Renderer_Block_Ores.java new file mode 100644 index 0000000000..7f537b5054 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/BW_Renderer_Block_Ores.java @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2019 bartimaeusnek + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.client.renderer; + +import com.github.bartimaeusnek.bartworks.system.material.BW_MetaGeneratedOreTE; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; +import cpw.mods.fml.client.registry.RenderingRegistry; +import gregtech.common.render.GT_Renderer_Block; +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.world.IBlockAccess; +import org.lwjgl.opengl.GL11; + +import static gregtech.common.render.GT_Renderer_Block.*; + +public class BW_Renderer_Block_Ores implements ISimpleBlockRenderingHandler { + public static BW_Renderer_Block_Ores INSTANCE = new BW_Renderer_Block_Ores(); + public final int mRenderID = RenderingRegistry.getNextAvailableRenderId(); + + @Override + public void renderInventoryBlock(Block aBlock, int aMeta, int modelId, RenderBlocks aRenderer) { + BW_MetaGeneratedOreTE tTileEntity = new BW_MetaGeneratedOreTE(); + tTileEntity.mMetaData = (short) aMeta; + aBlock.setBlockBoundsForItemRender(); + aRenderer.setRenderBoundsFromBlock(aBlock); + GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setNormal(0.0F, -1.0F, 0.0F); + renderNegativeYFacing((IBlockAccess) null, aRenderer, aBlock, 0, 0, 0, tTileEntity.getTexture(aBlock, (byte) 0), true); + Tessellator.instance.draw(); + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setNormal(0.0F, 1.0F, 0.0F); + renderPositiveYFacing((IBlockAccess) null, aRenderer, aBlock, 0, 0, 0, tTileEntity.getTexture(aBlock, (byte) 1), true); + Tessellator.instance.draw(); + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setNormal(0.0F, 0.0F, -1.0F); + renderNegativeZFacing((IBlockAccess) null, aRenderer, aBlock, 0, 0, 0, tTileEntity.getTexture(aBlock, (byte) 2), true); + Tessellator.instance.draw(); + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setNormal(0.0F, 0.0F, 1.0F); + renderPositiveZFacing((IBlockAccess) null, aRenderer, aBlock, 0, 0, 0, tTileEntity.getTexture(aBlock, (byte) 3), true); + Tessellator.instance.draw(); + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setNormal(-1.0F, 0.0F, 0.0F); + renderNegativeXFacing((IBlockAccess) null, aRenderer, aBlock, 0, 0, 0, tTileEntity.getTexture(aBlock, (byte) 4), true); + Tessellator.instance.draw(); + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setNormal(1.0F, 0.0F, 0.0F); + renderPositiveXFacing((IBlockAccess) null, aRenderer, aBlock, 0, 0, 0, tTileEntity.getTexture(aBlock, (byte) 5), true); + Tessellator.instance.draw(); + aBlock.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + aRenderer.setRenderBoundsFromBlock(aBlock); + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + } + + @Override + public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { + return GT_Renderer_Block.renderStandardBlock(world, x, y, z, block, renderer); + } + + @Override + public boolean shouldRender3DInInventory(int modelId) { + return true; + } + + @Override + public int getRenderId() { + return mRenderID; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_TileEntityContainer.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_TileEntityContainer.java index 6cbca9b7ad..4cc851df67 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_TileEntityContainer.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_TileEntityContainer.java @@ -23,6 +23,7 @@ package com.github.bartimaeusnek.bartworks.common.blocks; import com.github.bartimaeusnek.bartworks.API.ITileAddsInformation; +import com.github.bartimaeusnek.bartworks.API.ITileDropsContent; import com.github.bartimaeusnek.bartworks.API.ITileHasDifferentTextureSides; import com.github.bartimaeusnek.bartworks.API.ITileWithGUI; import com.github.bartimaeusnek.bartworks.MainMod; @@ -32,14 +33,17 @@ import cpw.mods.fml.relauncher.SideOnly; import ic2.api.tile.IWrenchable; import ic2.core.IC2; import ic2.core.IHasGui; +import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EnumCreatureType; +import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; +import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; @@ -65,7 +69,7 @@ public class BW_TileEntityContainer extends BlockContainer implements ITileAddsI @Override public boolean onBlockActivated(World worldObj, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) { if (worldObj.isRemote) { - return true; + return false; } final TileEntity tile = worldObj.getTileEntity(x, y, z); if (tile instanceof BW_TileEntity_HeatedWaterPump) { @@ -116,6 +120,19 @@ public class BW_TileEntityContainer extends BlockContainer implements ITileAddsI } @Override + public void breakBlock(World world, int x, int y, int z, Block block, int meta) { + TileEntity t = world.getTileEntity(x,y,z); + if (t instanceof ITileDropsContent){ + int[] dropSlots = ((ITileDropsContent)t).getDropSlots(); + for (int i = 0; i < dropSlots.length; i++) { + if (((ITileDropsContent)t).getStackInSlot(dropSlots[i]) != null) + world.spawnEntityInWorld(new EntityItem(world,x,y,z,((BW_TileEntity_HeatedWaterPump)t).getStackInSlot(dropSlots[i]))); + } + } + super.breakBlock(world, x, y, z, block, meta); + } + + @Override @SideOnly(Side.CLIENT) public IIcon getIcon(int side, int meta) { if (ITileHasDifferentTextureSides.class.isAssignableFrom(this.tileEntity)) { diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/configs/ConfigHandler.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/configs/ConfigHandler.java index cf5e0aab78..186f12c4e6 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/configs/ConfigHandler.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/configs/ConfigHandler.java @@ -43,6 +43,8 @@ public class ConfigHandler { public static int megaMachinesMax = 256; public static int mbWaterperSec = 150; private static boolean ezmode = false; + public static boolean debugLog = false; + public static boolean experimentalThreadedLoader = false; public ConfigHandler(@Nonnull FMLPreInitializationEvent e) { c = new Configuration(new File(e.getModConfigurationDirectory().toString() + "/" + MainMod.MOD_ID + ".cfg")); @@ -61,10 +63,20 @@ public class ConfigHandler { ConfigHandler.IDOffset = 12600; c.get("System", "ID Offset", 12600, "ID Offset for this mod. This Mod uses " + IDU + " IDs. DO NOT CHANGE IF YOU DONT KNOW WHAT THIS IS").set(12600); } - + debugLog=c.get("System","Enable Debug Log",false,"Enables or Disables the debug log.").getBoolean(false); + experimentalThreadedLoader =c.get("System","Enable Experimental Threaded Material Loader",false,"Enables or Disables the Experimental Threaded Material Loader.").getBoolean(false); if (c.hasChanged()) c.save(); } + public static void setUpComments(){ + c.addCustomCategoryComment("ASM fixes","Disable ASM fixes here."); + c.addCustomCategoryComment("Multiblocks","Multliblock Options can be set here."); + c.addCustomCategoryComment("Singleblocks","Singleblock Options can be set here."); + c.addCustomCategoryComment("System","Different System Settings can be set here."); + c.addCustomCategoryComment("CrossMod Interactions","CrossMod Interaction Settings can be set here. For Underground Fluid settings change the Gregtech.cfg!"); + c.save(); + } + } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/BW_ItemBlocks.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/BW_ItemBlocks.java index c9286aec26..86ea3198eb 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/BW_ItemBlocks.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/BW_ItemBlocks.java @@ -25,6 +25,7 @@ package com.github.bartimaeusnek.bartworks.common.items; import com.github.bartimaeusnek.bartworks.API.ITileAddsInformation; import com.github.bartimaeusnek.bartworks.MainMod; import com.github.bartimaeusnek.bartworks.common.blocks.BW_GlasBlocks; +import com.github.bartimaeusnek.bartworks.util.BW_ColorUtil; import com.github.bartimaeusnek.bartworks.util.BW_Util; import com.github.bartimaeusnek.bartworks.util.ChatColorHelper; import cpw.mods.fml.relauncher.Side; @@ -67,7 +68,7 @@ public class BW_ItemBlocks extends ItemBlock { @SideOnly(Side.CLIENT) public void addInformation(final ItemStack aStack, final EntityPlayer aPlayer, final List aList, final boolean aF3_H) { if (this.field_150939_a instanceof BW_GlasBlocks) - aList.add(StatCollector.translateToLocal("tooltip.glas.0.name") +" " + BW_Util.getColorForTier(BW_Util.getTierFromGlasMeta(aStack.getItemDamage())) + GT_Values.VN[BW_Util.getTierFromGlasMeta(aStack.getItemDamage())]); + aList.add(StatCollector.translateToLocal("tooltip.glas.0.name") + " " + BW_ColorUtil.getColorForTier(BW_Util.getTierFromGlasMeta(aStack.getItemDamage())) + GT_Values.VN[BW_Util.getTierFromGlasMeta(aStack.getItemDamage())]); if (this.field_150939_a instanceof ITileAddsInformation) { for (int i = 0; i < ((ITileAddsInformation) this.field_150939_a).getInfoData().length; i++) { aList.add(((ITileAddsInformation) this.field_150939_a).getInfoData()[i]); @@ -77,7 +78,7 @@ public class BW_ItemBlocks extends ItemBlock { if (!(this.field_150939_a instanceof ITileEntityProvider)) aList.add(this.mNoTileEntityToolTip); - aList.add(StatCollector.translateToLocal("tooltip.bw.0.name")+ ChatColorHelper.DARKGREEN + " BartWorks"); + aList.add(StatCollector.translateToLocal("tooltip.bw.0.name") + ChatColorHelper.DARKGREEN + " BartWorks"); } @Override diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/BW_SimpleWindMeter.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/BW_SimpleWindMeter.java index 66ff1725de..f308420d14 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/BW_SimpleWindMeter.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/BW_SimpleWindMeter.java @@ -57,7 +57,7 @@ public class BW_SimpleWindMeter extends Item { public void addInformation(ItemStack itemStack, EntityPlayer entityPlayer, List list, boolean p_77624_4_) { super.addInformation(itemStack, entityPlayer, list, p_77624_4_); list.add(StatCollector.translateToLocal("tooltip.windmeter.0.name")); - list.add(StatCollector.translateToLocal("tooltip.windmeter.1.name")+" " + (this.getMaxDamage() - this.getDamage(itemStack)) + "/" + this.getMaxDamage()); + list.add(StatCollector.translateToLocal("tooltip.windmeter.1.name") + " " + (this.getMaxDamage() - this.getDamage(itemStack)) + "/" + this.getMaxDamage()); list.add(StatCollector.translateToLocal("tooltip.bw.0.name") + ChatColorHelper.DARKGREEN + " BartWorks"); } @@ -68,7 +68,7 @@ public class BW_SimpleWindMeter extends Item { float windStrength = (float) WorldData.get(world).windSim.getWindAt(entityPlayer.posY); String windS = windStrength < 1f ? StatCollector.translateToLocal("tooltip.windmeter.2.name") : windStrength < 10f ? StatCollector.translateToLocal("tooltip.windmeter.3.name") : windStrength < 20f ? StatCollector.translateToLocal("tooltip.windmeter.4.name") : windStrength < 30f ? StatCollector.translateToLocal("tooltip.windmeter.5.name") : windStrength < 50f ? StatCollector.translateToLocal("tooltip.windmeter.6.name") : StatCollector.translateToLocal("tooltip.windmeter.7.name"); - entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("tooltip.windmeter.8.name")+" " + windS + ".")); + entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("tooltip.windmeter.8.name") + " " + windS + ".")); itemStack.damageItem(1, entityPlayer); return itemStack; } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/BW_Stonage_Rotors.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/BW_Stonage_Rotors.java index 71d9b0886f..f67a912aee 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/BW_Stonage_Rotors.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/BW_Stonage_Rotors.java @@ -76,9 +76,9 @@ public class BW_Stonage_Rotors extends Item implements IKineticRotor { } else if (Minecraft.getMinecraft().currentScreen instanceof GuiWindKineticGenerator) { type = WIND; } - info.add(StatCollector.translateToLocal("tooltip.rotor.0.name")+" " + this.DiaMinMax[0]); - info.add(StatCollector.translateToLocal("tooltip.rotor.1.name")+" " + (this.getMaxDamage() - this.getDamage(itemStack)) + "/" + this.getMaxDamage()); - info.add(StatCollector.translateToLocal("tooltip.rotor.2.name")+" " + this.eff); + info.add(StatCollector.translateToLocal("tooltip.rotor.0.name") + " " + this.DiaMinMax[0]); + info.add(StatCollector.translateToLocal("tooltip.rotor.1.name") + " " + (this.getMaxDamage() - this.getDamage(itemStack)) + "/" + this.getMaxDamage()); + info.add(StatCollector.translateToLocal("tooltip.rotor.2.name") + " " + this.eff); if (type != null) { info.add(StatCollector.translateToLocal(("ic2.itemrotor.fitsin." + this.isAcceptedType(itemStack, type)))); } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/Circuit_Programmer.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/Circuit_Programmer.java index 621394d199..c3491ca6f3 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/Circuit_Programmer.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/Circuit_Programmer.java @@ -54,7 +54,7 @@ public class Circuit_Programmer extends GT_Generic_Item implements IElectricItem public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { super.addInformation(aStack, aPlayer, aList, aF3_H); if (aStack != null && aStack.getTagCompound() != null) - aList.add(StatCollector.translateToLocal("tooltip.cp.0.name")+" " + (aStack.getTagCompound().getBoolean("HasChip") ? StatCollector.translateToLocal("tooltip.bw.yes.name") : StatCollector.translateToLocal("tooltip.bw.no.name"))); + aList.add(StatCollector.translateToLocal("tooltip.cp.0.name") + " " + (aStack.getTagCompound().getBoolean("HasChip") ? StatCollector.translateToLocal("tooltip.bw.yes.name") : StatCollector.translateToLocal("tooltip.bw.no.name"))); aList.add(StatCollector.translateToLocal("tooltip.bw.0.name") + ChatColorHelper.DARKGREEN + " BartWorks"); } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/GT_Destructopack_Item.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/GT_Destructopack_Item.java index 9d06a3e752..ea43784383 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/GT_Destructopack_Item.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/GT_Destructopack_Item.java @@ -48,7 +48,7 @@ public class GT_Destructopack_Item extends GT_Generic_Item { @Override public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { super.addInformation(aStack, aPlayer, aList, aF3_H); - aList.add(StatCollector.translateToLocal("tooltip.bw.0.name") + ChatColorHelper.DARKGREEN + " BartWorks"); + aList.add(StatCollector.translateToLocal("tooltip.bw.0.name") + ChatColorHelper.DARKGREEN + " BartWorks"); } @Override diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/GT_Rockcutter_Item.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/GT_Rockcutter_Item.java index bcca88531f..f744be70b7 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/GT_Rockcutter_Item.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/GT_Rockcutter_Item.java @@ -75,8 +75,8 @@ public class GT_Rockcutter_Item extends ItemTool implements IElectricItem { } public void addInformation(final ItemStack aStack, final EntityPlayer aPlayer, final List aList, final boolean aF3_H) { - aList.add(StatCollector.translateToLocal("tooltip.bw.tier.name") +" " + GT_Values.VN[this.mTier]); - aList.add(StatCollector.translateToLocal("tooltip.bw.0.name") + ChatColorHelper.DARKGREEN + " BartWorks"); + aList.add(StatCollector.translateToLocal("tooltip.bw.tier.name") + " " + GT_Values.VN[this.mTier]); + aList.add(StatCollector.translateToLocal("tooltip.bw.0.name") + ChatColorHelper.DARKGREEN + " BartWorks"); } public void onUpdate(ItemStack aStack, World p_77663_2_, Entity p_77663_3_, int p_77663_4_, boolean p_77663_5_) { diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/LabParts.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/LabParts.java index 4ae906c96e..5aeed95774 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/LabParts.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/LabParts.java @@ -23,6 +23,7 @@ package com.github.bartimaeusnek.bartworks.common.items; import com.github.bartimaeusnek.bartworks.MainMod; +import com.github.bartimaeusnek.bartworks.util.BW_ColorUtil; import com.github.bartimaeusnek.bartworks.util.BW_Util; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -66,7 +67,7 @@ public class LabParts extends SimpleSubItemClass { public int getColorFromItemStack(ItemStack stack, int p_82790_2_) { if (stack.getItemDamage() == 0 && stack.getTagCompound() != null && stack.getTagCompound().getIntArray("Color") != null && stack.getTagCompound().getIntArray("Color").length > 0) { int[] rgb = stack.getTagCompound().getIntArray("Color"); - return BW_Util.getColorFromArray(rgb); + return BW_ColorUtil.getColorFromRGBArray(rgb); } return super.getColorFromItemStack(stack, p_82790_2_); } @@ -103,16 +104,16 @@ public class LabParts extends SimpleSubItemClass { switch (itemStack.getItemDamage()) { case 0: - list.add(StatCollector.translateToLocal("tooltip.labparts.5.name")+" " + itemStack.getTagCompound().getString("Name")); + list.add(StatCollector.translateToLocal("tooltip.labparts.5.name") + " " + itemStack.getTagCompound().getString("Name")); if (!itemStack.getTagCompound().getBoolean("Breedable")) { list.add(StatCollector.translateToLocal("tooltip.labparts.6.name")); } break; case 1: - list.add(StatCollector.translateToLocal("tooltip.labparts.7.name")+" " + itemStack.getTagCompound().getString("Name")); + list.add(StatCollector.translateToLocal("tooltip.labparts.7.name") + " " + itemStack.getTagCompound().getString("Name")); break; case 2: - list.add(StatCollector.translateToLocal("tooltip.labparts.8.name")+" "+ itemStack.getTagCompound().getString("Name")); + list.add(StatCollector.translateToLocal("tooltip.labparts.8.name") + " " + itemStack.getTagCompound().getString("Name")); break; default: break; diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/SimpleSubItemClass.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/SimpleSubItemClass.java index c4abbe95b9..f5abfeecf7 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/SimpleSubItemClass.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/SimpleSubItemClass.java @@ -59,7 +59,7 @@ public class SimpleSubItemClass extends Item { @Override public void addInformation(ItemStack p_77624_1_, EntityPlayer p_77624_2_, List aList, boolean p_77624_4_) { super.addInformation(p_77624_1_, p_77624_2_, aList, p_77624_4_); - aList.add(StatCollector.translateToLocal("tooltip.bw.0.name") + ChatColorHelper.DARKGREEN + " BartWorks"); + aList.add(StatCollector.translateToLocal("tooltip.bw.0.name") + ChatColorHelper.DARKGREEN + " BartWorks"); } @Override diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/BioRecipeLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/BioRecipeLoader.java index 00546d6453..fab53818a7 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/BioRecipeLoader.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/BioRecipeLoader.java @@ -28,7 +28,6 @@ import com.github.bartimaeusnek.bartworks.common.tileentities.tiered.GT_MetaTile import com.github.bartimaeusnek.bartworks.common.tileentities.tiered.GT_MetaTileEntity_RadioHatch; import com.github.bartimaeusnek.bartworks.util.BWRecipes; import com.github.bartimaeusnek.bartworks.util.BW_Util; -import com.github.bartimaeusnek.bartworks.util.BioCulture; import cpw.mods.fml.common.Loader; import gregtech.api.enums.GT_Values; import gregtech.api.enums.ItemList; @@ -158,8 +157,8 @@ public class BioRecipeLoader extends RecipeLoader { Materials[] circuits = {Materials.Advanced, Materials.Data, Materials.Elite, Materials.Master, Materials.Ultimate, Materials.Superconductor}; for (int i = 3; i < GT_Values.VN.length; i++) { //12625 - BioLab[(i - 3)] = new GT_MetaTileEntity_BioLab(ConfigHandler.IDOffset + GT_Values.VN.length * 6 + i, "bw.biolab"+GT_Values.VN[i], GT_Values.VN[i] + " "+StatCollector.translateToLocal("tile.biolab.name"), i).getStackForm(1L); - RadioHatch[(i - 3)] = new GT_MetaTileEntity_RadioHatch(ConfigHandler.IDOffset + GT_Values.VN.length * 7 - 2 + i ,"bw.radiohatch"+ GT_Values.VN[i], GT_Values.VN[i] + " "+StatCollector.translateToLocal("tile.radiohatch.name"), i).getStackForm(1L); + BioLab[(i - 3)] = new GT_MetaTileEntity_BioLab(ConfigHandler.IDOffset + GT_Values.VN.length * 6 + i, "bw.biolab" + GT_Values.VN[i], GT_Values.VN[i] + " " + StatCollector.translateToLocal("tile.biolab.name"), i).getStackForm(1L); + RadioHatch[(i - 3)] = new GT_MetaTileEntity_RadioHatch(ConfigHandler.IDOffset + GT_Values.VN.length * 7 - 2 + i, "bw.radiohatch" + GT_Values.VN[i], GT_Values.VN[i] + " " + StatCollector.translateToLocal("tile.radiohatch.name"), i).getStackForm(1L); try { ItemStack machinehull = ItemList.MACHINE_HULLS[i].get(1L); GT_ModHandler.addCraftingRecipe( diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/FluidLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/FluidLoader.java index 00bd28bde6..1b56e588c5 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/FluidLoader.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/FluidLoader.java @@ -26,7 +26,6 @@ import com.github.bartimaeusnek.bartworks.client.renderer.RendererGlasBlock; import com.github.bartimaeusnek.bartworks.client.renderer.RendererSwitchingColorFluid; import com.github.bartimaeusnek.bartworks.common.blocks.BioFluidBlock; import com.github.bartimaeusnek.bartworks.common.tileentities.classic.BWTileEntityDimIDBridge; -import com.github.bartimaeusnek.bartworks.util.BW_Util; import com.github.bartimaeusnek.bartworks.util.BioCulture; import cpw.mods.fml.client.registry.RenderingRegistry; import cpw.mods.fml.common.FMLCommonHandler; @@ -70,7 +69,7 @@ public class FluidLoader implements Runnable { BioLabFluidCells[i] = ItemFluidCell.getUniversalFluidCell(new FluidStack(BioLabFluidMaterials[i], 1000)); } -// BioCulture.BIO_CULTURE_ARRAY_LIST.get(0).setFluid(new GT_Fluid("_NULL", "molten.autogenerated", BW_Util.splitColortoArray(BioCulture.BIO_CULTURE_ARRAY_LIST.get(0).getColorRGB()))); +// BioCulture.BIO_CULTURE_ARRAY_LIST.get(0).setFluid(new GT_Fluid("_NULL", "molten.autogenerated", BW_Util.splitColorToRBGArray(BioCulture.BIO_CULTURE_ARRAY_LIST.get(0).getColorRGB()))); for (BioCulture B : BioCulture.BIO_CULTURE_ARRAY_LIST) { if (B.isBreedable()) { diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/ItemRegistry.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/ItemRegistry.java index c945a19d14..20911d4361 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/ItemRegistry.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/ItemRegistry.java @@ -29,6 +29,7 @@ import com.github.bartimaeusnek.bartworks.common.blocks.BW_TileEntityContainer; import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; import com.github.bartimaeusnek.bartworks.common.items.*; import com.github.bartimaeusnek.bartworks.common.tileentities.classic.BW_RotorBlock; +import com.github.bartimaeusnek.bartworks.common.tileentities.classic.BW_TileEntity_ExperimentalFloodGate; import com.github.bartimaeusnek.bartworks.common.tileentities.classic.BW_TileEntity_HeatedWaterPump; import com.github.bartimaeusnek.bartworks.common.tileentities.multis.GT_TileEntity_DEHP; import com.github.bartimaeusnek.bartworks.common.tileentities.multis.GT_TileEntity_ElectricImplosionCompressor; @@ -37,6 +38,7 @@ import com.github.bartimaeusnek.bartworks.common.tileentities.multis.mega.GT_Til import com.github.bartimaeusnek.bartworks.common.tileentities.tiered.GT_MetaTileEntity_AcidGenerator; import com.github.bartimaeusnek.bartworks.common.tileentities.tiered.GT_MetaTileEntity_Diode; import com.github.bartimaeusnek.bartworks.common.tileentities.tiered.GT_MetaTileEntity_EnergyDistributor; +import com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader; import cpw.mods.fml.common.registry.GameRegistry; import gregtech.api.enums.GT_Values; import gregtech.api.enums.Materials; @@ -72,6 +74,7 @@ public class ItemRegistry { public static final Item WINDMETER = new BW_SimpleWindMeter(); public static final Block PUMPBLOCK = new BW_TileEntityContainer(Material.anvil, BW_TileEntity_HeatedWaterPump.class, "BWHeatedWaterPump"); public static final Item PUMPPARTS = new SimpleSubItemClass(new String[]{"BWrawtube", "BWmotor"}); + public static final Block EXPPUMP = new BW_TileEntityContainer(Material.coral, BW_TileEntity_ExperimentalFloodGate.class, "ExpReversePump"); public static final Block[] bw_glasses = { new BW_GlasBlocks( @@ -89,8 +92,9 @@ public class ItemRegistry { MainMod.MOD_ID + ":ColoredBoronSilicateGlassBlock4", MainMod.MOD_ID + ":ColoredBoronSilicateGlassBlock5", MainMod.MOD_ID + ":ColoredBoronSilicateGlassBlock6", + MainMod.MOD_ID + ":ThoriumYttriumGlass", }, - new short[][]{Materials.BorosilicateGlass.getRGBA(), Materials.Nickel.getRGBA(), Materials.Tungsten.getRGBA(), Materials.Chrome.getRGBA(), Materials.Iridium.getRGBA(), Materials.Osmium.getRGBA(), new short[]{0xff, 0, 0}, new short[]{0, 0xff, 0}, new short[]{0x80, 0, 0xff}, new short[]{0xff, 0xff, 0}, new short[]{0, 0xff, 0x80}, new short[]{0x80, 0x33, 0}}, + new short[][]{Materials.BorosilicateGlass.getRGBA(), Materials.Nickel.getRGBA(), Materials.Tungsten.getRGBA(), Materials.Chrome.getRGBA(), Materials.Iridium.getRGBA(), Materials.Osmium.getRGBA(), new short[]{0xff, 0, 0}, new short[]{0, 0xff, 0}, new short[]{0x80, 0, 0xff}, new short[]{0xff, 0xff, 0}, new short[]{0, 0xff, 0x80}, new short[]{0x80, 0x33, 0}, WerkstoffLoader.YttriumOxide.getRGBA()}, MainMod.BIO_TAB, true, false ) @@ -146,23 +150,24 @@ public class ItemRegistry { GameRegistry.registerBlock(PUMPBLOCK, BW_ItemBlocks.class, "BWHeatedWaterPumpBlock"); GameRegistry.registerItem(PUMPPARTS, "BWPumpParts"); GameRegistry.registerItem(WINDMETER, "BW_SimpleWindMeter"); - + GameRegistry.registerTileEntity(BW_TileEntity_ExperimentalFloodGate.class, "BWExpReversePump"); + GameRegistry.registerBlock(EXPPUMP, BW_ItemBlocks.class, "BWExpReversePumpBlock"); for (int i = 0; i < GT_Values.VN.length; i++) { - ItemRegistry.diode2A[i] = new GT_MetaTileEntity_Diode(ConfigHandler.IDOffset + GT_Values.VN.length + 1 + i, "diode"+"2A" + GT_Values.VN[i], StatCollector.translateToLocal("tile.diode.name")+" 2A " + GT_Values.VN[i], i).getStackForm(1L); - ItemRegistry.diode4A[i] = new GT_MetaTileEntity_Diode(ConfigHandler.IDOffset + GT_Values.VN.length * 2 + 1 + i, "diode"+"4A" + GT_Values.VN[i], StatCollector.translateToLocal("tile.diode.name")+" 4A " + GT_Values.VN[i], i).getStackForm(1L); - ItemRegistry.diode8A[i] = new GT_MetaTileEntity_Diode(ConfigHandler.IDOffset + GT_Values.VN.length * 3 + 1 + i, "diode"+"8A" + GT_Values.VN[i], StatCollector.translateToLocal("tile.diode.name")+" 8A " + GT_Values.VN[i], i).getStackForm(1L); - ItemRegistry.diode12A[i] = new GT_MetaTileEntity_Diode(ConfigHandler.IDOffset + GT_Values.VN.length * 4 + 1 + i, "diode"+"12A" + GT_Values.VN[i], StatCollector.translateToLocal("tile.diode.name")+" 12A " + GT_Values.VN[i], i).getStackForm(1L); - ItemRegistry.diode16A[i] = new GT_MetaTileEntity_Diode(ConfigHandler.IDOffset + GT_Values.VN.length * 5 + 1 + i, "diode"+"16A" + GT_Values.VN[i], StatCollector.translateToLocal("tile.diode.name")+" 16A " + GT_Values.VN[i], i).getStackForm(1L); - ItemRegistry.energyDistributor[i] = new GT_MetaTileEntity_EnergyDistributor(ConfigHandler.IDOffset + 1 + i, "energydistributor" + GT_Values.VN[i], StatCollector.translateToLocal("tile.energydistributor.name")+ " " + GT_Values.VN[i], i).getStackForm(1L); + ItemRegistry.diode2A[i] = new GT_MetaTileEntity_Diode(ConfigHandler.IDOffset + GT_Values.VN.length + 1 + i, "diode" + "2A" + GT_Values.VN[i], StatCollector.translateToLocal("tile.diode.name") + " 2A " + GT_Values.VN[i], i).getStackForm(1L); + ItemRegistry.diode4A[i] = new GT_MetaTileEntity_Diode(ConfigHandler.IDOffset + GT_Values.VN.length * 2 + 1 + i, "diode" + "4A" + GT_Values.VN[i], StatCollector.translateToLocal("tile.diode.name") + " 4A " + GT_Values.VN[i], i).getStackForm(1L); + ItemRegistry.diode8A[i] = new GT_MetaTileEntity_Diode(ConfigHandler.IDOffset + GT_Values.VN.length * 3 + 1 + i, "diode" + "8A" + GT_Values.VN[i], StatCollector.translateToLocal("tile.diode.name") + " 8A " + GT_Values.VN[i], i).getStackForm(1L); + ItemRegistry.diode12A[i] = new GT_MetaTileEntity_Diode(ConfigHandler.IDOffset + GT_Values.VN.length * 4 + 1 + i, "diode" + "12A" + GT_Values.VN[i], StatCollector.translateToLocal("tile.diode.name") + " 12A " + GT_Values.VN[i], i).getStackForm(1L); + ItemRegistry.diode16A[i] = new GT_MetaTileEntity_Diode(ConfigHandler.IDOffset + GT_Values.VN.length * 5 + 1 + i, "diode" + "16A" + GT_Values.VN[i], StatCollector.translateToLocal("tile.diode.name") + " 16A " + GT_Values.VN[i], i).getStackForm(1L); + ItemRegistry.energyDistributor[i] = new GT_MetaTileEntity_EnergyDistributor(ConfigHandler.IDOffset + 1 + i, "energydistributor" + GT_Values.VN[i], StatCollector.translateToLocal("tile.energydistributor.name") + " " + GT_Values.VN[i], i).getStackForm(1L); } for (int i = 0; i < 3; i++) { - ItemRegistry.acidGens[i] = new GT_MetaTileEntity_AcidGenerator(ConfigHandler.IDOffset + GT_Values.VN.length * 8 - 2 + i, "acidgenerator"+GT_Values.VN[i + 2], StatCollector.translateToLocal("tile.acidgenerator.name")+" " + GT_Values.VN[i + 2], i + 2).getStackForm(1); + ItemRegistry.acidGens[i] = new GT_MetaTileEntity_AcidGenerator(ConfigHandler.IDOffset + GT_Values.VN.length * 8 - 2 + i, "acidgenerator" + GT_Values.VN[i + 2], StatCollector.translateToLocal("tile.acidgenerator.name") + " " + GT_Values.VN[i + 2], i + 2).getStackForm(1); } dehp = new GT_TileEntity_DEHP(ConfigHandler.IDOffset + GT_Values.VN.length * 8 + 1, 1, "DEHP", "Deep Earth Heating Pump").getStackForm(1L); megaMachines[0] = new GT_TileEntity_MegaBlastFurnace(ConfigHandler.IDOffset + GT_Values.VN.length * 8 + 2, "MegaBlastFurnace", StatCollector.translateToLocal("tile.bw.mbf.name")).getStackForm(1L); megaMachines[1] = new GT_TileEntity_MegaVacuumFreezer(ConfigHandler.IDOffset + GT_Values.VN.length * 8 + 3, "MegaVacuumFreezer", StatCollector.translateToLocal("tile.bw.mvf.name")).getStackForm(1L); - new GT_TileEntity_ElectricImplosionCompressor( ConfigHandler.IDOffset + GT_Values.VN.length * 8 + 4,"Electric Implosion Compressor","Electric Implosion Compressor"); +// new GT_TileEntity_ElectricImplosionCompressor(ConfigHandler.IDOffset + GT_Values.VN.length * 8 + 4, "Electric Implosion Compressor", "Electric Implosion Compressor"); } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/RecipeLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/RecipeLoader.java index fe2af47746..eef7b29c49 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/RecipeLoader.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/RecipeLoader.java @@ -24,7 +24,6 @@ package com.github.bartimaeusnek.bartworks.common.loaders; import com.github.bartimaeusnek.bartworks.MainMod; import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; -import com.github.bartimaeusnek.bartworks.common.tileentities.multis.GT_TileEntity_ElectricImplosionCompressor; import com.github.bartimaeusnek.bartworks.common.tileentities.multis.GT_TileEntity_LESU; import com.github.bartimaeusnek.bartworks.common.tileentities.multis.GT_TileEntity_ManualTrafo; import com.github.bartimaeusnek.bartworks.common.tileentities.multis.GT_TileEntity_Windmill; @@ -730,6 +729,6 @@ public class RecipeLoader implements Runnable { ); } - } + } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/net/BW_Network.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/net/BW_Network.java index 9629eec1c9..cca0c39712 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/net/BW_Network.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/net/BW_Network.java @@ -59,7 +59,7 @@ public class BW_Network extends MessageToMessageCodec<FMLProxyPacket, GT_Packet> public BW_Network() { this.mChannel = NetworkRegistry.INSTANCE.newChannel("BartWorks", new ChannelHandler[]{this, new HandlerShared()}); - this.mSubChannels = new GT_Packet[]{new RendererPacket(), new CircuitProgrammerPacket()}; + this.mSubChannels = new GT_Packet[]{new RendererPacket(), new CircuitProgrammerPacket(), new OrePacket()}; } protected void encode(ChannelHandlerContext aContext, GT_Packet aPacket, List<Object> aOutput) throws Exception { diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/net/OrePacket.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/net/OrePacket.java new file mode 100644 index 0000000000..36fd4dfa36 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/net/OrePacket.java @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2019 bartimaeusnek + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.net; + +import com.github.bartimaeusnek.bartworks.MainMod; +import com.github.bartimaeusnek.bartworks.system.material.BW_MetaGeneratedOreTE; +import com.github.bartimaeusnek.bartworks.util.MurmurHash3; +import com.google.common.io.ByteArrayDataInput; +import gregtech.api.net.GT_Packet; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +import java.nio.ByteBuffer; + +public class OrePacket extends GT_Packet { + + int x; + short y; + int z; + short meta; + + public OrePacket(int x, int y, int z, int meta) { + super(false); + this.x = x; + this.y = (short) y; + this.z = z; + this.meta = (short) meta; + } + + public OrePacket() { + super(true); + } + + @Override + public byte getPacketID() { + return 2; + } + + @Override + public byte[] encode() { + int hash = MurmurHash3.murmurhash3_x86_32(ByteBuffer.allocate(12).putInt(x).putInt(z).putShort(y).putShort(meta).array(), 0, 12, 31); + return ByteBuffer.allocate(16).putInt(x).putInt(z).putShort(y).putShort(meta).putInt(hash).array(); + } + + @Override + public GT_Packet decode(ByteArrayDataInput byteArrayDataInput) { + byte[] tmp = new byte[16]; + byteArrayDataInput.readFully(tmp); + ByteBuffer buff = ByteBuffer.wrap(tmp); + x = buff.getInt(); + z = buff.getInt(); + y = buff.getShort(); + meta = buff.getShort(); + OrePacket todecode = new OrePacket(x, y, z, meta); + if (buff.getInt() != MurmurHash3.murmurhash3_x86_32(ByteBuffer.allocate(12).putInt(x).putInt(z).putShort(y).putShort(meta).array(), 0, 12, 31)) { + MainMod.LOGGER.error("PACKET HASH DOES NOT MATCH!"); + return null; + } + return todecode; + } + + @Override + public void process(IBlockAccess iBlockAccess) { + if (iBlockAccess != null) { + TileEntity tTileEntity = iBlockAccess.getTileEntity(this.x, this.y, this.z); + if ((tTileEntity instanceof BW_MetaGeneratedOreTE)) { + ((BW_MetaGeneratedOreTE) tTileEntity).mMetaData = this.meta; + } + if (((iBlockAccess instanceof World)) && (((World) iBlockAccess).isRemote)) { + ((World) iBlockAccess).markBlockForUpdate(this.x, this.y, this.z); + } + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/net/RendererPacket.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/net/RendererPacket.java index 71aa50c824..a5f5f4089f 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/net/RendererPacket.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/net/RendererPacket.java @@ -24,7 +24,7 @@ package com.github.bartimaeusnek.bartworks.common.net; import com.github.bartimaeusnek.bartworks.MainMod; import com.github.bartimaeusnek.bartworks.common.tileentities.multis.GT_TileEntity_BioVat; -import com.github.bartimaeusnek.bartworks.util.BW_Util; +import com.github.bartimaeusnek.bartworks.util.BW_ColorUtil; import com.github.bartimaeusnek.bartworks.util.Coords; import com.google.common.io.ByteArrayDataInput; import cpw.mods.fml.common.FMLCommonHandler; @@ -73,7 +73,7 @@ public class RendererPacket extends GT_Packet { // public void decodetest (byte[] buffer){ // this.coords=new Coords(ByteBuffer.wrap(buffer).getInt(0),ByteBuffer.wrap(buffer).getShort(4),ByteBuffer.wrap(buffer).getInt(6),ByteBuffer.wrap(buffer).getInt(10)); // int[] rgb = {ByteBuffer.wrap(buffer).get(14)-Byte.MIN_VALUE, ByteBuffer.wrap(buffer).get(15)-Byte.MIN_VALUE, ByteBuffer.wrap(buffer).get(16)-Byte.MIN_VALUE}; -// this.integer= BW_Util.getColorFromArray(rgb); +// this.integer= BW_Util.getColorFromRGBArray(rgb); // this.removal=ByteBuffer.wrap(buffer).get(17); // // byte checksum = (byte) (coords.x%25+coords.y%25+coords.z%25+coords.wID%25+integer%25+removal); @@ -87,7 +87,7 @@ public class RendererPacket extends GT_Packet { this.coords = new Coords(ByteBuffer.wrap(buffer).getInt(0), ByteBuffer.wrap(buffer).getShort(4), ByteBuffer.wrap(buffer).getInt(6), ByteBuffer.wrap(buffer).getInt(10)); int[] rgb = {ByteBuffer.wrap(buffer).get(14) - Byte.MIN_VALUE, ByteBuffer.wrap(buffer).get(15) - Byte.MIN_VALUE, ByteBuffer.wrap(buffer).get(16) - Byte.MIN_VALUE}; - this.integer = BW_Util.getColorFromArray(rgb); + this.integer = BW_ColorUtil.getColorFromRGBArray(rgb); this.removal = ByteBuffer.wrap(buffer).get(17); byte checksum = (byte) (coords.x % 25 + coords.y % 25 + coords.z % 25 + coords.wID % 25 + integer % 25 + removal); diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BW_TileEntity_ExperimentalFloodGate.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BW_TileEntity_ExperimentalFloodGate.java new file mode 100644 index 0000000000..d71969e12b --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BW_TileEntity_ExperimentalFloodGate.java @@ -0,0 +1,205 @@ +/* + * Copyright (c) 2019 bartimaeusnek + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.tileentities.classic; + +import com.github.bartimaeusnek.bartworks.API.ITileAddsInformation; +import com.github.bartimaeusnek.bartworks.util.Coords; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; +import net.minecraftforge.fluids.TileFluidHandler; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; + +public class BW_TileEntity_ExperimentalFloodGate extends TileFluidHandler implements ITileAddsInformation { + + recursiveBelowCheck check = new recursiveBelowCheck(); + private long ticks = 0; + private long noOfIts = 0; + private Coords paused; + + public BW_TileEntity_ExperimentalFloodGate() { + + } + + @Override + public void updateEntity() { + if (paused == null) { + this.paused = new Coords(this.xCoord, this.yCoord, this.zCoord, this.worldObj.provider.dimensionId); + } + ticks++; + if (check.called != -1) { + if (ticks % 20 == 0) { + HashSet<Coords> toRem = new HashSet<>(); + for (Coords c : check.hashset) { + this.worldObj.setBlock(c.x, c.y, c.z, Blocks.water, 0, 4); + toRem.add(c); + } + check.hashset.removeAll(toRem); + } + } else { + noOfIts = 0; + setUpHashSet(); + this.paused = check.hashset.get(check.hashset.size() - 1); + } + if (ticks % 50 == 0) + ticks = 0; + } + + private synchronized void setUpHashSet() { + check = new recursiveBelowCheck(); + Thread t = new Thread(check); + t.run(); + while (t.isAlive()) { + try { + this.wait(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + check.hashset.remove(new Coords(this.xCoord, this.yCoord, this.zCoord, this.worldObj.provider.dimensionId)); + } + + @Override + public String[] getInfoData() { + return new String[]{"Experimental Machine to fill Holes with Fluids"}; + } + + private class recursiveBelowCheck implements Runnable { + + private final List<Coords> hashset = new ArrayList<Coords>(); + int called = -1; + + public int getCalled() { + return this.called; + } + + public void setCalled(int called) { + this.called = called; + } + + public synchronized List<Coords> getHashset() { + return this.hashset; + } + + public byte check_sourroundings(World w, int x, int y, int z, Block b) { + byte ret = 0; + int wID = w.provider.dimensionId; + + if (hashset.contains(new Coords(x, y, z, wID))) + return ret; + + hashset.add(new Coords(x, y, z, wID)); + + if (w.getBlock(x, y + 1, z).equals(b)) + ret = (byte) (ret | 0b000001); + + if (w.getBlock(x, y - 1, z).equals(b)) + ret = (byte) (ret | 0b000010); + + if (w.getBlock(x + 1, y, z).equals(b)) + ret = (byte) (ret | 0b000100); + + if (w.getBlock(x - 1, y, z).equals(b)) + ret = (byte) (ret | 0b001000); + + if (w.getBlock(x, y, z + 1).equals(b)) + ret = (byte) (ret | 0b010000); + + if (w.getBlock(x, y, z - 1).equals(b)) + ret = (byte) (ret | 0b100000); + + return ret; + } + + public int get_connected(World w, int x, int y, int z, Block b, int iterations) { + + if (iterations >= 5000) + return -1; + int tail = 0; + int ret = 0; + iterations++; + int wID = w.provider.dimensionId; + byte sides = check_sourroundings(w, x, y, z, b); + + if (((sides | 0b111110) == 0b111111) && !hashset.contains(new Coords(x, y + 1, z, wID)) && y + 1 <= yCoord) { + tail = get_connected(w, x, y + 1, z, b, iterations); + if (tail == -1) + return tail; + ret++; + ret += tail; + } + + if (((sides | 0b111101) == 0b111111) && !hashset.contains(new Coords(x, y - 1, z, wID))) { + tail = get_connected(w, x, y - 1, z, b, iterations); + if (tail == -1) + return tail; + ret++; + ret += tail; + } + + if (((sides | 0b111011) == 0b111111) && !hashset.contains(new Coords(x + 1, y, z, wID))) { + tail = get_connected(w, x + 1, y, z, b, iterations); + if (tail == -1) + return tail; + ret++; + ret += tail; + } + + if (((sides | 0b110111) == 0b111111) && !hashset.contains(new Coords(x - 1, y, z, wID))) { + tail = get_connected(w, x - 1, y, z, b, iterations); + if (tail == -1) + return tail; + ret++; + ret += tail; + } + + if (((sides | 0b101111) == 0b111111) && !hashset.contains(new Coords(x, y, z + 1, wID))) { + tail = get_connected(w, x, y, z + 1, b, iterations); + if (tail == -1) + return tail; + ret++; + ret += tail; + + } + + if (((sides | 0b011111) == 0b111111) && !hashset.contains(new Coords(x, y, z - 1, wID))) { + tail = get_connected(w, x, y, z - 1, b, iterations); + if (tail == -1) + return tail; + ret++; + ret += tail; + } + + return ret; + } + + @Override + public synchronized void run() { + called = check.get_connected(worldObj, paused.x, paused.y, paused.z, Blocks.air, 0); + notifyAll(); + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BW_TileEntity_HeatedWaterPump.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BW_TileEntity_HeatedWaterPump.java index cca50bce6a..416e4fb56e 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BW_TileEntity_HeatedWaterPump.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BW_TileEntity_HeatedWaterPump.java @@ -23,6 +23,7 @@ package com.github.bartimaeusnek.bartworks.common.tileentities.classic; import com.github.bartimaeusnek.bartworks.API.ITileAddsInformation; +import com.github.bartimaeusnek.bartworks.API.ITileDropsContent; import com.github.bartimaeusnek.bartworks.API.ITileHasDifferentTextureSides; import com.github.bartimaeusnek.bartworks.API.ITileWithGUI; import com.github.bartimaeusnek.bartworks.MainMod; @@ -39,7 +40,7 @@ import net.minecraft.util.StatCollector; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.*; -public class BW_TileEntity_HeatedWaterPump extends TileEntity implements ISidedInventory, IFluidHandler, IFluidTank, ITileWithGUI, ITileAddsInformation, ITileHasDifferentTextureSides { +public class BW_TileEntity_HeatedWaterPump extends TileEntity implements ITileDropsContent, IFluidHandler, IFluidTank, ITileWithGUI, ITileAddsInformation, ITileHasDifferentTextureSides { public static final int FUELSLOT = 0; public static final Fluid WATER = FluidRegistry.WATER; @@ -268,7 +269,7 @@ public class BW_TileEntity_HeatedWaterPump extends TileEntity implements ISidedI @Override public String[] getInfoData() { - return new String[]{StatCollector.translateToLocal("tooltip.tile.waterpump.0.name")+" " + ConfigHandler.mbWaterperSec + StatCollector.translateToLocal("tooltip.tile.waterpump.1.name"), StatCollector.translateToLocal("tooltip.tile.waterpump.2.name")}; + return new String[]{StatCollector.translateToLocal("tooltip.tile.waterpump.0.name") + " " + ConfigHandler.mbWaterperSec + StatCollector.translateToLocal("tooltip.tile.waterpump.1.name"), StatCollector.translateToLocal("tooltip.tile.waterpump.2.name")}; } @Override diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BW_TileEntity_InfinityTank.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BW_TileEntity_InfinityTank.java index 79ac59f5c1..989e1618b9 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BW_TileEntity_InfinityTank.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BW_TileEntity_InfinityTank.java @@ -35,7 +35,7 @@ import java.util.HashSet; public class BW_TileEntity_InfinityTank extends TileEntity implements IFluidTank, IFluidHandler, ITileWithGUI { - final ArrayList<FluidStack> INTERNALTANKS =new ArrayList<FluidStack>(); + final ArrayList<FluidStack> INTERNALTANKS = new ArrayList<FluidStack>(); int selectedTank; @@ -46,12 +46,12 @@ public class BW_TileEntity_InfinityTank extends TileEntity implements IFluidTank @Override public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { - return drain(from,resource != null ? resource.amount : 0,doDrain); + return drain(from, resource != null ? resource.amount : 0, doDrain); } @Override public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { - return drain(maxDrain,doDrain); + return drain(maxDrain, doDrain); } @Override @@ -78,8 +78,8 @@ public class BW_TileEntity_InfinityTank extends TileEntity implements IFluidTank @Override public FluidStack getFluid() { if (INTERNALTANKS.get(selectedTank) == null || INTERNALTANKS.get(selectedTank).amount == 0) - if (selectedTank>0) - selectedTank = this.INTERNALTANKS.size()-1; + if (selectedTank > 0) + selectedTank = this.INTERNALTANKS.size() - 1; return INTERNALTANKS.get(selectedTank); } @@ -103,10 +103,9 @@ public class BW_TileEntity_InfinityTank extends TileEntity implements IFluidTank lInternalTank.appendTag(entry); } } - p_145841_1_.setTag("InternalTank",lInternalTank); + p_145841_1_.setTag("InternalTank", lInternalTank); } - @Override public int getCapacity() { @@ -128,7 +127,7 @@ public class BW_TileEntity_InfinityTank extends TileEntity implements IFluidTank int id = 0; - if (canDrain(null,resource.getFluid())) { + if (canDrain(null, resource.getFluid())) { for (FluidStack stack : INTERNALTANKS) if (GT_Utility.areFluidsEqual(stack, resource)) { this.INTERNALTANKS.get(id = this.INTERNALTANKS.indexOf(stack)).amount += resource.amount; @@ -136,7 +135,7 @@ public class BW_TileEntity_InfinityTank extends TileEntity implements IFluidTank } } else { this.INTERNALTANKS.add(resource); - id = this.INTERNALTANKS.size()-1; + id = this.INTERNALTANKS.size() - 1; selectedTank = id; } return this.INTERNALTANKS.get(id).amount; diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_BioVat.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_BioVat.java index f8801f25af..76625e06bc 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_BioVat.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_BioVat.java @@ -336,7 +336,7 @@ public class GT_TileEntity_BioVat extends GT_MetaTileEntity_MultiBlockBase { private byte calculateGlassTier(@Nonnull Block block, @Nonnegative Byte meta) { if (block.equals(ItemRegistry.bw_glasses[0])) - return meta > 1 && meta < 6 ? (byte) (meta + 3) : 4; + return meta == 12 ? 5 : meta > 1 && meta < 6 ? (byte) (meta + 3) : 4; if (block.getUnlocalizedName().equals("blockAlloyGlass")) return 4; @@ -600,10 +600,10 @@ public class GT_TileEntity_BioVat extends GT_MetaTileEntity_MultiBlockBase { @Override public String[] getDescription() { String[] dsc = StatCollector.translateToLocal("tooltip.tile.bvat.0.name").split(";"); - String[] fdsc = new String[dsc.length+1]; + String[] fdsc = new String[dsc.length + 1]; for (int i = 0; i < dsc.length; i++) { - fdsc[i]=dsc[i]; - fdsc[dsc.length]=StatCollector.translateToLocal("tooltip.bw.1.name") + ChatColorHelper.DARKGREEN + " BartWorks"; + fdsc[i] = dsc[i]; + fdsc[dsc.length] = StatCollector.translateToLocal("tooltip.bw.1.name") + ChatColorHelper.DARKGREEN + " BartWorks"; } return fdsc; } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_CrackingDistillTower.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_CrackingDistillTower.java index d0a242b23f..f7ac05a7f9 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_CrackingDistillTower.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_CrackingDistillTower.java @@ -45,33 +45,33 @@ public class GT_TileEntity_CrackingDistillTower extends GT_MetaTileEntity_Distil @Override public boolean checkRecipe(ItemStack itemStack) { - if (!GT_Utility.areStacksEqual(itemStack, GT_Utility.getIntegratedCircuit(0),true)) + if (!GT_Utility.areStacksEqual(itemStack, GT_Utility.getIntegratedCircuit(0), true)) return false; - else{ + else { FluidStack[] array = new FluidStack[0]; ArrayList<FluidStack> fluidInputs = new ArrayList<FluidStack>(); - for (GT_MetaTileEntity_Hatch_Input hatch : this.mInputHatches){ - if (hatch != null){ + for (GT_MetaTileEntity_Hatch_Input hatch : this.mInputHatches) { + if (hatch != null) { fluidInputs.add(hatch.getFluid()); } } array = fluidInputs.toArray(array); GT_Recipe.GT_Recipe_Map rMapCracking = GT_Recipe.GT_Recipe_Map.sCrakingRecipes; GT_Recipe.GT_Recipe_Map rMapDistillTower = GT_Recipe.GT_Recipe_Map.sDistillationRecipes; - GT_Recipe recipeCracking = rMapCracking.findRecipe(this.getBaseMetaTileEntity(),false,this.getMaxInputVoltage(),array,itemStack); + GT_Recipe recipeCracking = rMapCracking.findRecipe(this.getBaseMetaTileEntity(), false, this.getMaxInputVoltage(), array, itemStack); if (recipeCracking == null) return false; - GT_Recipe recipeDistill = rMapDistillTower.findRecipe(this.getBaseMetaTileEntity(),false,this.getMaxInputVoltage(),recipeCracking.mFluidOutputs); + GT_Recipe recipeDistill = rMapDistillTower.findRecipe(this.getBaseMetaTileEntity(), false, this.getMaxInputVoltage(), recipeCracking.mFluidOutputs); if (recipeDistill == null) return false; - float ratio = (float)recipeCracking.mFluidOutputs[0].amount/(float)recipeDistill.mFluidInputs[0].amount; + float ratio = (float) recipeCracking.mFluidOutputs[0].amount / (float) recipeDistill.mFluidInputs[0].amount; FluidStack[] nuoutputs = new FluidStack[recipeDistill.mFluidOutputs.length]; for (int i = 0; i < nuoutputs.length; i++) { - nuoutputs[i]=recipeDistill.mFluidOutputs[i]; - nuoutputs[i].amount=(int)(Math.floor(recipeDistill.mFluidOutputs[i].amount*ratio)); + nuoutputs[i] = recipeDistill.mFluidOutputs[i]; + nuoutputs[i].amount = (int) (Math.floor(recipeDistill.mFluidOutputs[i].amount * ratio)); } - BWRecipes.DynamicGTRecipe combined = new BWRecipes.DynamicGTRecipe(true,null,recipeDistill.mOutputs,null,recipeDistill.mChances,recipeCracking.mFluidInputs,nuoutputs,(int)(Math.floor(recipeDistill.mDuration*ratio))+recipeCracking.mDuration,Math.max((int)(Math.floor(recipeDistill.mEUt*ratio)),recipeCracking.mEUt),0); - if (combined.isRecipeInputEqual(true, array)){ + BWRecipes.DynamicGTRecipe combined = new BWRecipes.DynamicGTRecipe(true, null, recipeDistill.mOutputs, null, recipeDistill.mChances, recipeCracking.mFluidInputs, nuoutputs, (int) (Math.floor(recipeDistill.mDuration * ratio)) + recipeCracking.mDuration, Math.max((int) (Math.floor(recipeDistill.mEUt * ratio)), recipeCracking.mEUt), 0); + if (combined.isRecipeInputEqual(true, array)) { this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); this.mEfficiencyIncrease = 10000; BW_Util.calculateOverclockedNessMulti(combined.mEUt, combined.mDuration, 1, this.getMaxInputVoltage(), this); @@ -81,8 +81,8 @@ public class GT_TileEntity_CrackingDistillTower extends GT_MetaTileEntity_Distil this.mEUt = (-this.mEUt); } this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - this.mOutputFluids=combined.mFluidOutputs.clone(); - this.mOutputItems=combined.mOutputs.clone(); + this.mOutputFluids = combined.mFluidOutputs.clone(); + this.mOutputItems = combined.mOutputs.clone(); this.updateSlots(); return true; } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_ElectricImplosionCompressor.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_ElectricImplosionCompressor.java index 2c326887ed..74efa145e5 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_ElectricImplosionCompressor.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_ElectricImplosionCompressor.java @@ -23,29 +23,25 @@ package com.github.bartimaeusnek.bartworks.common.tileentities.multis; import gregtech.api.GregTech_API; -import gregtech.api.enums.GT_Values; import gregtech.api.enums.Materials; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; -import gregtech.common.GT_Pollution; import gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_ImplosionCompressor; import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; import java.util.ArrayList; -import java.util.Iterator; import static com.github.bartimaeusnek.bartworks.common.loaders.ItemRegistry.BW_BLOCKS; public class GT_TileEntity_ElectricImplosionCompressor extends GT_MetaTileEntity_ImplosionCompressor { + public static GT_Recipe.GT_Recipe_Map eicMap; private boolean piston; public GT_TileEntity_ElectricImplosionCompressor(int aID, String aName, String aNameRegional) { @@ -56,21 +52,19 @@ public class GT_TileEntity_ElectricImplosionCompressor extends GT_MetaTileEntity super(aName); } - public static GT_Recipe.GT_Recipe_Map eicMap; - @Override public boolean checkRecipe(ItemStack aStack) { - if (this.mEnergyHatches.get(0).getEUVar() <= 0 || this.mEnergyHatches.get(1).getEUVar() <= 0 ) + if (this.mEnergyHatches.get(0).getEUVar() <= 0 || this.mEnergyHatches.get(1).getEUVar() <= 0) return false; ArrayList<ItemStack> tInputList = this.getStoredInputs(); int tInputList_sS = tInputList.size(); - for(int i = 0; i < tInputList_sS - 1; ++i) { - for(int j = i + 1; j < tInputList_sS; ++j) { - if (GT_Utility.areStacksEqual((ItemStack)tInputList.get(i), (ItemStack)tInputList.get(j))) { - if (((ItemStack)tInputList.get(i)).stackSize < ((ItemStack)tInputList.get(j)).stackSize) { + for (int i = 0; i < tInputList_sS - 1; ++i) { + for (int j = i + 1; j < tInputList_sS; ++j) { + if (GT_Utility.areStacksEqual((ItemStack) tInputList.get(i), (ItemStack) tInputList.get(j))) { + if (((ItemStack) tInputList.get(i)).stackSize < ((ItemStack) tInputList.get(j)).stackSize) { tInputList.remove(i--); tInputList_sS = tInputList.size(); break; @@ -82,16 +76,16 @@ public class GT_TileEntity_ElectricImplosionCompressor extends GT_MetaTileEntity } } - ItemStack[] tInputs = (ItemStack[])tInputList.toArray(new ItemStack[tInputList.size()]); + ItemStack[] tInputs = (ItemStack[]) tInputList.toArray(new ItemStack[tInputList.size()]); if (tInputList.size() > 0) { - GT_Recipe tRecipe = eicMap.findRecipe(this.getBaseMetaTileEntity(), false, 9223372036854775807L, (FluidStack[])null, tInputs); - if (tRecipe != null && tRecipe.isRecipeInputEqual(true, (FluidStack[])null, tInputs)) { + GT_Recipe tRecipe = eicMap.findRecipe(this.getBaseMetaTileEntity(), false, 9223372036854775807L, (FluidStack[]) null, tInputs); + if (tRecipe != null && tRecipe.isRecipeInputEqual(true, (FluidStack[]) null, tInputs)) { this.mEfficiency = 10000 - (this.getIdealStatus() - this.getRepairStatus()) * 1000; this.mEfficiencyIncrease = 10000; this.mEUt = -tRecipe.mEUt; this.mMaxProgresstime = Math.max(1, tRecipe.mDuration); this.mOutputItems = new ItemStack[]{tRecipe.getOutput(0), tRecipe.getOutput(1)}; - this.sendLoopStart((byte)20); + this.sendLoopStart((byte) 20); this.updateSlots(); return true; } @@ -107,7 +101,7 @@ public class GT_TileEntity_ElectricImplosionCompressor extends GT_MetaTileEntity return super.onRunningTick(aStack); } - public void stopMachine(){ + public void stopMachine() { resetPiston(); super.stopMachine(); } @@ -117,13 +111,13 @@ public class GT_TileEntity_ElectricImplosionCompressor extends GT_MetaTileEntity piston = true; } - private void resetPiston(){ + private void resetPiston() { if (this.getBaseMetaTileEntity().getWorld().isRemote) return; - if (!piston){ + if (!piston) { int xDir = ForgeDirection.getOrientation(this.getBaseMetaTileEntity().getBackFacing()).offsetX; int zDir = ForgeDirection.getOrientation(this.getBaseMetaTileEntity().getBackFacing()).offsetZ; - int aX = this.getBaseMetaTileEntity().getXCoord(),aY = this.getBaseMetaTileEntity().getYCoord() ,aZ = this.getBaseMetaTileEntity().getZCoord(); + int aX = this.getBaseMetaTileEntity().getXCoord(), aY = this.getBaseMetaTileEntity().getYCoord(), aZ = this.getBaseMetaTileEntity().getZCoord(); for (int x = -1; x <= 1; x++) { for (int z = -1; z <= 1; z++) { if (!(Math.abs(x) == 1 && Math.abs(z) == 1)) @@ -134,34 +128,35 @@ public class GT_TileEntity_ElectricImplosionCompressor extends GT_MetaTileEntity piston = !piston; } } + private void togglePiston() { if (this.getBaseMetaTileEntity().getWorld().isRemote) return; int xDir = ForgeDirection.getOrientation(this.getBaseMetaTileEntity().getBackFacing()).offsetX; int zDir = ForgeDirection.getOrientation(this.getBaseMetaTileEntity().getBackFacing()).offsetZ; - int aX = this.getBaseMetaTileEntity().getXCoord(),aY = this.getBaseMetaTileEntity().getYCoord() ,aZ = this.getBaseMetaTileEntity().getZCoord(); + int aX = this.getBaseMetaTileEntity().getXCoord(), aY = this.getBaseMetaTileEntity().getYCoord(), aZ = this.getBaseMetaTileEntity().getZCoord(); boolean hax = false; - if(piston){ + if (piston) { for (int x = -1; x <= 1; x++) { for (int z = -1; z <= 1; z++) { if (!(Math.abs(x) == 1 && Math.abs(z) == 1)) { - if (this.getBaseMetaTileEntity().getBlock(xDir+aX+x,aY+2,zDir+aZ+z) != GregTech_API.sBlockMetal5 && this.getBaseMetaTileEntity().getMetaID(xDir+aX+x,aY+2,zDir+aZ+z) != 2 ) { + if (this.getBaseMetaTileEntity().getBlock(xDir + aX + x, aY + 2, zDir + aZ + z) != GregTech_API.sBlockMetal5 && this.getBaseMetaTileEntity().getMetaID(xDir + aX + x, aY + 2, zDir + aZ + z) != 2) { hax = true; } this.getBaseMetaTileEntity().getWorld().setBlockToAir(xDir + aX + x, aY + 2, zDir + aZ + z); } } } - GT_Utility.doSoundAtClient((String)GregTech_API.sSoundList.get(5), 10, 1.0F, aX, aY, aZ); - piston=!piston; + GT_Utility.doSoundAtClient((String) GregTech_API.sSoundList.get(5), 10, 1.0F, aX, aY, aZ); + piston = !piston; } else { for (int x = -1; x <= 1; x++) { for (int z = -1; z <= 1; z++) { if (!(Math.abs(x) == 1 && Math.abs(z) == 1)) - this.getBaseMetaTileEntity().getWorld().setBlock(xDir+aX+x,aY+2,zDir+aZ+z,GregTech_API.sBlockMetal5,2,3); + this.getBaseMetaTileEntity().getWorld().setBlock(xDir + aX + x, aY + 2, zDir + aZ + z, GregTech_API.sBlockMetal5, 2, 3); } } - GT_Utility.doSoundAtClient((String)GregTech_API.sSoundList.get(5), 10, 1.0F, aX, aY, aZ); + GT_Utility.doSoundAtClient((String) GregTech_API.sSoundList.get(5), 10, 1.0F, aX, aY, aZ); piston = !piston; } if (hax) @@ -170,13 +165,13 @@ public class GT_TileEntity_ElectricImplosionCompressor extends GT_MetaTileEntity @Override public void saveNBTData(NBTTagCompound aNBT) { - aNBT.setBoolean("piston",piston); + aNBT.setBoolean("piston", piston); super.saveNBTData(aNBT); } @Override public void loadNBTData(NBTTagCompound aNBT) { - piston=aNBT.getBoolean("piston"); + piston = aNBT.getBoolean("piston"); super.loadNBTData(aNBT); } @@ -188,18 +183,17 @@ public class GT_TileEntity_ElectricImplosionCompressor extends GT_MetaTileEntity for (int x = -1; x <= 1; x++) { for (int y = -2; y < 7; y++) { for (int z = -1; z <= 1; z++) { - IGregTechTileEntity te = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir+x,y,z+zDir); + IGregTechTileEntity te = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + x, y, z + zDir); if (y == -2 || y == 6) { if (!(x == 0 && z == 0)) { if (!this.addMaintenanceToMachineList(te, 16) && !this.addMufflerToMachineList(te, 16) && !this.addInputToMachineList(te, 16) && !this.addOutputToMachineList(te, 16)) { - Block tBlock = aBaseMetaTileEntity.getBlockOffset(xDir + x, y, zDir + z); - byte tMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + x, y, zDir + z); - if ((tBlock != GregTech_API.sBlockCasings2 || tMeta != 0) && (tBlock != GregTech_API.sBlockCasings3 || tMeta != 4)) { - return false; - } + Block tBlock = aBaseMetaTileEntity.getBlockOffset(xDir + x, y, zDir + z); + byte tMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + x, y, zDir + z); + if ((tBlock != GregTech_API.sBlockCasings2 || tMeta != 0) && (tBlock != GregTech_API.sBlockCasings3 || tMeta != 4)) { + return false; } - } - else if (x == 0 && z == 0) { + } + } else if (x == 0 && z == 0) { if (y == -2) if (!this.addEnergyInputToMachineList(te, 16)) return false; @@ -207,36 +201,32 @@ public class GT_TileEntity_ElectricImplosionCompressor extends GT_MetaTileEntity if (!this.addEnergyInputToMachineList(te, 16)) return false; } - } - else if ((y > -2 && y < 1) || (y > 3 && y < 6)){ - if (y == 0 && xDir+x == 0 && zDir+z==0) + } else if ((y > -2 && y < 1) || (y > 3 && y < 6)) { + if (y == 0 && xDir + x == 0 && zDir + z == 0) continue; Block tBlock = aBaseMetaTileEntity.getBlockOffset(xDir + x, y, zDir + z); byte tMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + x, y, zDir + z); if (x == 0 && z == 0) { if (tBlock != BW_BLOCKS[2] || tMeta != 0) return false; - }else{ + } else { if (tBlock != BW_BLOCKS[2] || tMeta != 1) return false; } - } - else if (y == 1) { - if (!GT_Utility.areStacksEqual(new ItemStack(aBaseMetaTileEntity.getBlockOffset(xDir + x, 1, zDir + z),1,aBaseMetaTileEntity.getMetaIDOffset(xDir + x, y, zDir + z)), Materials.Neutronium.getBlocks(1))) + } else if (y == 1) { + if (!GT_Utility.areStacksEqual(new ItemStack(aBaseMetaTileEntity.getBlockOffset(xDir + x, 1, zDir + z), 1, aBaseMetaTileEntity.getMetaIDOffset(xDir + x, y, zDir + z)), Materials.Neutronium.getBlocks(1))) return false; - } - else if (y == 2) { + } else if (y == 2) { if (!piston) { if (Math.abs(x) == 1 && Math.abs(z) == 1) { - if (!GT_Utility.areStacksEqual(new ItemStack(aBaseMetaTileEntity.getBlockOffset(xDir + x, 2, zDir + z),1,aBaseMetaTileEntity.getMetaIDOffset(xDir + x, y, zDir + z)), Materials.Neutronium.getBlocks(1))) + if (!GT_Utility.areStacksEqual(new ItemStack(aBaseMetaTileEntity.getBlockOffset(xDir + x, 2, zDir + z), 1, aBaseMetaTileEntity.getMetaIDOffset(xDir + x, y, zDir + z)), Materials.Neutronium.getBlocks(1))) return false; } - }else if (!GT_Utility.areStacksEqual(new ItemStack(aBaseMetaTileEntity.getBlockOffset(xDir + x, 2, zDir + z),1,aBaseMetaTileEntity.getMetaIDOffset(xDir + x, y, zDir + z)), Materials.Neutronium.getBlocks(1))) + } else if (!GT_Utility.areStacksEqual(new ItemStack(aBaseMetaTileEntity.getBlockOffset(xDir + x, 2, zDir + z), 1, aBaseMetaTileEntity.getMetaIDOffset(xDir + x, y, zDir + z)), Materials.Neutronium.getBlocks(1))) return false; - } - else if (y == 3) { - if (!GT_Utility.areStacksEqual(new ItemStack(aBaseMetaTileEntity.getBlockOffset(xDir + x, 3, zDir + z),1,aBaseMetaTileEntity.getMetaIDOffset(xDir + x, y, zDir + z)), Materials.Neutronium.getBlocks(1))) + } else if (y == 3) { + if (!GT_Utility.areStacksEqual(new ItemStack(aBaseMetaTileEntity.getBlockOffset(xDir + x, 3, zDir + z), 1, aBaseMetaTileEntity.getMetaIDOffset(xDir + x, y, zDir + z)), Materials.Neutronium.getBlocks(1))) return false; } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_LESU.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_LESU.java index c3aabbd0da..42eeada394 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_LESU.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_LESU.java @@ -160,12 +160,12 @@ public class GT_TileEntity_LESU extends GT_MetaTileEntity_MultiBlockBase { for (int i = 0; i < dsc.length; i++) { e.add(dsc[i]); } - e.add(StatCollector.translateToLocal("tooltip.tile.lesu.1.name")+" " + ConfigHandler.energyPerCell + "EU"); + e.add(StatCollector.translateToLocal("tooltip.tile.lesu.1.name") + " " + ConfigHandler.energyPerCell + "EU"); dsc = StatCollector.translateToLocal("tooltip.tile.lesu.2.name").split(";"); for (int i = 0; i < dsc.length; i++) { e.add(dsc[i]); } - e.add(ChatColorHelper.RED +StatCollector.translateToLocal("tooltip.tile.lesu.3.name")); + e.add(ChatColorHelper.RED + StatCollector.translateToLocal("tooltip.tile.lesu.3.name")); e.add(StatCollector.translateToLocal("tooltip.bw.1.name") + ChatColorHelper.DARKGREEN + " BartWorks"); return e.toArray(new String[0]); } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_ManualTrafo.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_ManualTrafo.java index 0cf9d1f2df..c403d990d6 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_ManualTrafo.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_ManualTrafo.java @@ -382,10 +382,10 @@ public class GT_TileEntity_ManualTrafo extends GT_MetaTileEntity_MultiBlockBase @Override public String[] getDescription() { String[] dsc = StatCollector.translateToLocal("tooltip.tile.manualtravo.0.name").split(";"); - String[] fdsc = new String[dsc.length+1]; + String[] fdsc = new String[dsc.length + 1]; for (int i = 0; i < dsc.length; i++) { - fdsc[i]=dsc[i]; - fdsc[dsc.length]=StatCollector.translateToLocal("tooltip.bw.1.name") + ChatColorHelper.DARKGREEN + " BartWorks"; + fdsc[i] = dsc[i]; + fdsc[dsc.length] = StatCollector.translateToLocal("tooltip.bw.1.name") + ChatColorHelper.DARKGREEN + " BartWorks"; } return fdsc; } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_Windmill.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_Windmill.java index a7d4ce12ba..5cd012821c 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_Windmill.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_Windmill.java @@ -114,11 +114,11 @@ public class GT_TileEntity_Windmill extends GT_MetaTileEntity_MultiBlockBase { if (new XSTR().nextInt(2) == 0) { if (tRecipe.getOutput(1) != null) mOutputItems[1] = tRecipe.getOutput(1); - else if( !BW_Util.checkStackAndPrefix(mOutputItems[0]) || + else if (!BW_Util.checkStackAndPrefix(mOutputItems[0]) || !( BW_Util.checkStackAndPrefix(mOutputItems[0]) && GT_OreDictUnificator.getAssociation(mOutputItems[0]).mMaterial.mMaterial.mSubTags.contains(SubTag.METAL) || - BW_Util.checkStackAndPrefix(mOutputItems[0]) && GT_OreDictUnificator.getAssociation(mOutputItems[0]).mMaterial.mMaterial.mSubTags.contains(SubTag.CRYSTAL)|| - BW_Util.checkStackAndPrefix(mOutputItems[0]) && GT_OreDictUnificator.getAssociation(mOutputItems[0]).mMaterial.mMaterial.mSubTags.contains(SubTag.CRYSTALLISABLE) + BW_Util.checkStackAndPrefix(mOutputItems[0]) && GT_OreDictUnificator.getAssociation(mOutputItems[0]).mMaterial.mMaterial.mSubTags.contains(SubTag.CRYSTAL) || + BW_Util.checkStackAndPrefix(mOutputItems[0]) && GT_OreDictUnificator.getAssociation(mOutputItems[0]).mMaterial.mMaterial.mSubTags.contains(SubTag.CRYSTALLISABLE) ) || BW_Util.checkStackAndPrefix(mOutputItems[0]) && GT_OreDictUnificator.getAssociation(mOutputItems[0]).mMaterial.mMaterial == Materials.Flint || @@ -563,10 +563,10 @@ public class GT_TileEntity_Windmill extends GT_MetaTileEntity_MultiBlockBase { @Override public String[] getDescription() { String[] dsc = StatCollector.translateToLocal("tooltip.tile.windmill.0.name").split(";"); - String[] fdsc = new String[dsc.length+1]; + String[] fdsc = new String[dsc.length + 1]; for (int i = 0; i < dsc.length; i++) { - fdsc[i]=dsc[i]; - fdsc[dsc.length]=StatCollector.translateToLocal("tooltip.bw.1.name") + ChatColorHelper.DARKGREEN + " BartWorks"; + fdsc[i] = dsc[i]; + fdsc[dsc.length] = StatCollector.translateToLocal("tooltip.bw.1.name") + ChatColorHelper.DARKGREEN + " BartWorks"; } return fdsc; } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaBlastFurnace.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaBlastFurnace.java index 97e7bb9fac..b74b826da5 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaBlastFurnace.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaBlastFurnace.java @@ -31,7 +31,6 @@ import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; import gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_ElectricBlastFurnace; @@ -41,7 +40,9 @@ import net.minecraft.util.StatCollector; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; -import java.util.*; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; import static gregtech.api.enums.GT_Values.V; @@ -61,16 +62,38 @@ public class GT_TileEntity_MegaBlastFurnace extends GT_MetaTileEntity_ElectricBl public String[] getDescription() { String[] dsc = StatCollector.translateToLocal("tooltip.tile.mbf.0.name").split(";"); - String tmp = dsc[dsc.length-1]; - dsc[dsc.length-1]=tmp+" "+Integer.toString(20 * this.getPollutionPerTick((ItemStack) null))+" "+StatCollector.translateToLocal("tooltip.tile.mbf.1.name"); - String[] fdsc = new String[dsc.length+1]; + String tmp = dsc[dsc.length - 1]; + dsc[dsc.length - 1] = tmp + " " + Integer.toString(20 * this.getPollutionPerTick((ItemStack) null)) + " " + StatCollector.translateToLocal("tooltip.tile.mbf.1.name"); + String[] fdsc = new String[dsc.length + 1]; for (int i = 0; i < dsc.length; i++) { - fdsc[i]=dsc[i]; - fdsc[dsc.length]=StatCollector.translateToLocal("tooltip.bw.1.name") + ChatColorHelper.DARKGREEN + " BartWorks"; + fdsc[i] = dsc[i]; + fdsc[dsc.length] = StatCollector.translateToLocal("tooltip.bw.1.name") + ChatColorHelper.DARKGREEN + " BartWorks"; } return fdsc; } + public boolean drainEnergyInput(long aEU) { + if (aEU <= 0) + return true; + long allTheEu = 0; + int hatches = 0; + for (GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches) + if (isValidMetaTileEntity(tHatch)) { + allTheEu += tHatch.getEUVar(); + hatches++; + } + if (allTheEu < aEU) + return false; + long euperhatch = aEU / hatches; + HashSet<Boolean> returnset = new HashSet<>(); + for (GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches) + if (tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(euperhatch, false)) + returnset.add(true); + else + returnset.add(false); + return returnset.size() > 0 && !returnset.contains(false); + } + @Override public boolean checkRecipe(ItemStack itemStack) { ItemStack[] tInputs = (ItemStack[]) this.getStoredInputs().toArray(new ItemStack[0]); @@ -90,10 +113,10 @@ public class GT_TileEntity_MegaBlastFurnace extends GT_MetaTileEntity_ElectricBl long nominalV = BW_Util.getnominalVoltage(this); int tHeatCapacityDivTiers = (mHeatingCapacity - tRecipe.mSpecialValue) / 900; - long precutRecipeVoltage = (long) (tRecipe.mEUt*Math.pow(0.95, tHeatCapacityDivTiers)); + long precutRecipeVoltage = (long) (tRecipe.mEUt * Math.pow(0.95, tHeatCapacityDivTiers)); while (this.getStoredInputs().size() > 0 && processed < ConfigHandler.megaMachinesMax) { - if (this.mHeatingCapacity >= tRecipe.mSpecialValue && (precutRecipeVoltage*(processed+1)) < nominalV && tRecipe.isRecipeInputEqual(true, tFluids, tInputs)) { + if (this.mHeatingCapacity >= tRecipe.mSpecialValue && (precutRecipeVoltage * (processed + 1)) < nominalV && tRecipe.isRecipeInputEqual(true, tFluids, tInputs)) { found_Recipe = true; for (int i = 0; i < tRecipe.mOutputs.length; i++) { outputItems.add(tRecipe.getOutput(i)); @@ -118,9 +141,9 @@ public class GT_TileEntity_MegaBlastFurnace extends GT_MetaTileEntity_ElectricBl actualEUT = actualEUT / 2; divider++; } - overclockCount = calculateOverclockednessEBF((int) (actualEUT / (divider * 2)), tRecipe.mDuration * (divider * 2), tVoltage); + overclockCount = calculateOverclockednessEBF((int) (actualEUT / (divider * 2)), tRecipe.mDuration * (divider * 2), nominalV); } else - overclockCount = calculateOverclockednessEBF(actualEUT, tRecipe.mDuration, tVoltage); + overclockCount = calculateOverclockednessEBF(actualEUT, tRecipe.mDuration, nominalV); //In case recipe is too OP for that machine if (mMaxProgresstime == Integer.MAX_VALUE - 1 && mEUt == Integer.MAX_VALUE - 1) return false; @@ -129,7 +152,7 @@ public class GT_TileEntity_MegaBlastFurnace extends GT_MetaTileEntity_ElectricBl } if (tHeatCapacityDivTiers > 0) { this.mEUt = (int) (this.mEUt * (Math.pow(0.95, tHeatCapacityDivTiers))); - this.mMaxProgresstime >>= Math.min(tHeatCapacityDivTiers / 2, overclockCount);//extra free overclocking if possible + this.mMaxProgresstime >>= Math.min(tHeatCapacityDivTiers / 2, overclockCount); //extra free overclocking if possible if (this.mMaxProgresstime < 1) this.mMaxProgresstime = 1;//no eu efficiency correction } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaProcessingArray.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaProcessingArray.java index 414b7b3122..56b9197a2d 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaProcessingArray.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaProcessingArray.java @@ -39,6 +39,11 @@ import java.util.List; import static gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine.isValidForLowGravity; public class GT_TileEntity_MegaProcessingArray extends GT_MetaTileEntity_ProcessingArray { + private GT_Recipe mLastRecipe; + private int tTier = 0; + private int mMult = 0; + private String mMachine = ""; + private GT_MetaTileEntity_Hatch_InputBus machineBus; public GT_TileEntity_MegaProcessingArray(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); } @@ -47,13 +52,6 @@ public class GT_TileEntity_MegaProcessingArray extends GT_MetaTileEntity_Process super(aName); } - private GT_Recipe mLastRecipe; - private int tTier = 0; - private int mMult = 0; - private String mMachine = ""; - - private GT_MetaTileEntity_Hatch_InputBus machineBus; - public boolean checkRecipe(ItemStack aStack) { if (!isCorrectMachinePart(machineBus.mInventory[0])) { return false; @@ -138,7 +136,7 @@ public class GT_TileEntity_MegaProcessingArray extends GT_MetaTileEntity_Process this.mMaxProgresstime = tRecipe.mDuration; this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); this.mEfficiencyIncrease = 10000; - BW_Util.calculateOverclockedNessMulti(tRecipe.mEUt, tRecipe.mDuration, map.mAmperage, GT_Values.V[tTier],this); + BW_Util.calculateOverclockedNessMulti(tRecipe.mEUt, tRecipe.mDuration, map.mAmperage, GT_Values.V[tTier], this); //In case recipe is too OP for that machine if (mMaxProgresstime == Integer.MAX_VALUE - 1 && mEUt == Integer.MAX_VALUE - 1) return false; diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaVacuumFreezer.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaVacuumFreezer.java index 14af3300a9..a2227eb7a4 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaVacuumFreezer.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaVacuumFreezer.java @@ -28,6 +28,7 @@ import com.github.bartimaeusnek.bartworks.util.ChatColorHelper; import gregtech.api.GregTech_API; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; import gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_VacuumFreezer; @@ -52,10 +53,10 @@ public class GT_TileEntity_MegaVacuumFreezer extends GT_MetaTileEntity_VacuumFre public String[] getDescription() { String[] dsc = StatCollector.translateToLocal("tooltip.tile.mvf.0.name").split(";"); - String[] fdsc = new String[dsc.length+1]; + String[] fdsc = new String[dsc.length + 1]; for (int i = 0; i < dsc.length; i++) { - fdsc[i]=dsc[i]; - fdsc[dsc.length]=StatCollector.translateToLocal("tooltip.bw.1.name") + ChatColorHelper.DARKGREEN + " BartWorks"; + fdsc[i] = dsc[i]; + fdsc[dsc.length] = StatCollector.translateToLocal("tooltip.bw.1.name") + ChatColorHelper.DARKGREEN + " BartWorks"; } return fdsc; } @@ -65,6 +66,28 @@ public class GT_TileEntity_MegaVacuumFreezer extends GT_MetaTileEntity_VacuumFre return new GT_TileEntity_MegaVacuumFreezer(this.mName); } + public boolean drainEnergyInput(long aEU) { + if (aEU <= 0) + return true; + long allTheEu = 0; + int hatches = 0; + for (GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches) + if (isValidMetaTileEntity(tHatch)) { + allTheEu += tHatch.getEUVar(); + hatches++; + } + if (allTheEu < aEU) + return false; + long euperhatch = aEU / hatches; + HashSet<Boolean> returnset = new HashSet<>(); + for (GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches) + if (tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(euperhatch, false)) + returnset.add(true); + else + returnset.add(false); + return returnset.size() > 0 && !returnset.contains(false); + } + @Override public boolean checkRecipe(ItemStack itemStack) { ItemStack[] tInputs = (ItemStack[]) this.getStoredInputs().toArray(new ItemStack[0]); @@ -78,7 +101,7 @@ public class GT_TileEntity_MegaVacuumFreezer extends GT_MetaTileEntity_VacuumFre int processed = 0; long nominalV = BW_Util.getnominalVoltage(this); while (this.getStoredInputs().size() > 0 && processed < ConfigHandler.megaMachinesMax) { - if (tRecipe != null && (tRecipe.mEUt*(processed+1)) < nominalV && tRecipe.isRecipeInputEqual(true, null, tInputs)) { + if (tRecipe != null && (tRecipe.mEUt * (processed + 1)) < nominalV && tRecipe.isRecipeInputEqual(true, null, tInputs)) { found_Recipe = true; for (int i = 0; i < tRecipe.mOutputs.length; i++) { outputItems.add(tRecipe.getOutput(i)); @@ -98,9 +121,9 @@ public class GT_TileEntity_MegaVacuumFreezer extends GT_MetaTileEntity_VacuumFre actualEUT = actualEUT / 2; divider++; } - BW_Util.calculateOverclockedNessMulti((int) (actualEUT / (divider * 2)), tRecipe.mDuration * (divider * 2), 1, this.getMaxInputVoltage(), this); + BW_Util.calculateOverclockedNessMulti((int) (actualEUT / (divider * 2)), tRecipe.mDuration * (divider * 2), 1, nominalV, this); } else - BW_Util.calculateOverclockedNessMulti((int) actualEUT, tRecipe.mDuration, 1, this.getMaxInputVoltage(), this); + BW_Util.calculateOverclockedNessMulti((int) actualEUT, tRecipe.mDuration, 1, nominalV, this); //In case recipe is too OP for that machine if (mMaxProgresstime == Integer.MAX_VALUE - 1 && mEUt == Integer.MAX_VALUE - 1) return false; diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_AcidGenerator.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_AcidGenerator.java index d749ce3c54..e138445f01 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_AcidGenerator.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_AcidGenerator.java @@ -36,7 +36,7 @@ import net.minecraft.util.StatCollector; public class GT_MetaTileEntity_AcidGenerator extends GT_MetaTileEntity_BasicGenerator { - public GT_MetaTileEntity_AcidGenerator(int aID, String aName, String aNameRegional, int aTier, ITexture... aTextures) { + public GT_MetaTileEntity_AcidGenerator(int aID, String aName, String aNameRegional, int aTier, ITexture... aTextures) { super(aID, aName, aNameRegional, aTier, new String[]{}, aTextures); } @@ -110,6 +110,6 @@ public class GT_MetaTileEntity_AcidGenerator extends GT_MetaTileEntity_BasicGene @SuppressWarnings("deprecation") public String[] getDescription() { - return new String[]{StatCollector.translateToLocal("tooltip.tile.acidgen.0.name"), StatCollector.translateToLocal("tooltip.tile.acidgen.1.name"), StatCollector.translateToLocal("tooltip.tile.tiereddsc.0.name")+" "+ ChatColorHelper.YELLOW + GT_Values.V[this.mTier], StatCollector.translateToLocal("tooltip.rotor.2.name")+" "+ ChatColorHelper.YELLOW + getEfficiency(), StatCollector.translateToLocal("tooltip.tile.tiereddsc.2.name")+" "+ ChatColorHelper.YELLOW + maxAmperesOut(), StatCollector.translateToLocal("tooltip.bw.1.name") + ChatColorHelper.DARKGREEN + " BartWorks"}; + return new String[]{StatCollector.translateToLocal("tooltip.tile.acidgen.0.name"), StatCollector.translateToLocal("tooltip.tile.acidgen.1.name"), StatCollector.translateToLocal("tooltip.tile.tiereddsc.0.name") + " " + ChatColorHelper.YELLOW + GT_Values.V[this.mTier], StatCollector.translateToLocal("tooltip.rotor.2.name") + " " + ChatColorHelper.YELLOW + getEfficiency(), StatCollector.translateToLocal("tooltip.tile.tiereddsc.2.name") + " " + ChatColorHelper.YELLOW + maxAmperesOut(), StatCollector.translateToLocal("tooltip.bw.1.name") + ChatColorHelper.DARKGREEN + " BartWorks"}; } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_BioLab.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_BioLab.java index 1fd3cfcfd6..e26b50cdd1 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_BioLab.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_BioLab.java @@ -194,9 +194,9 @@ public class GT_MetaTileEntity_BioLab extends GT_MetaTileEntity_BasicMachine { case 3: { if ( GT_Utility.isStackValid(this.mInventory[4]) && GT_Utility.areStacksEqual(this.mInventory[4], BioItemList.getPetriDish(null), true) && this.mInventory[4].getTagCompound() != null && - GT_Utility.isStackValid(this.mInventory[5]) && GT_Utility.areStacksEqual(this.mInventory[5], BioItemList.getPlasmidCell(null), true) && this.mInventory[5].getTagCompound() != null && - GT_Utility.isStackValid(this.mInventory[6]) && GT_Utility.areStacksEqual(this.mInventory[6], FluidLoader.BioLabFluidCells[2]) && - this.mFluid.isFluidEqual(FluidRegistry.getFluidStack("ic2distilledwater", 1000)) && this.mFluid.amount >= 1000) { + GT_Utility.isStackValid(this.mInventory[5]) && GT_Utility.areStacksEqual(this.mInventory[5], BioItemList.getPlasmidCell(null), true) && this.mInventory[5].getTagCompound() != null && + GT_Utility.isStackValid(this.mInventory[6]) && GT_Utility.areStacksEqual(this.mInventory[6], FluidLoader.BioLabFluidCells[2]) && + this.mFluid.isFluidEqual(FluidRegistry.getFluidStack("ic2distilledwater", 1000)) && this.mFluid.amount >= 1000) { BioData cultureDNABioData = BioData.getBioDataFromNBTTag(this.mInventory[5].getTagCompound()); BioCulture bioCulture = BioCulture.getBioCultureFromNBTTag(this.mInventory[4].getTagCompound()); if (cultureDNABioData == null || bioCulture == null) @@ -257,7 +257,7 @@ public class GT_MetaTileEntity_BioLab extends GT_MetaTileEntity_BasicMachine { return super.checkRecipe(skipOC); } - private BioCulture checkForExisting(BioCulture culture){ + private BioCulture checkForExisting(BioCulture culture) { if (culture == null) return null; for (BioCulture bc : BioCulture.BIO_CULTURE_ARRAY_LIST) @@ -269,6 +269,6 @@ public class GT_MetaTileEntity_BioLab extends GT_MetaTileEntity_BasicMachine { @Override @SuppressWarnings("deprecation") public String[] getDescription() { - return new String[]{ StatCollector.translateToLocal("tooltip.tile.biolab.0.name"), StatCollector.translateToLocal("tooltip.bw.1.name") + ChatColorHelper.DARKGREEN + " BartWorks"}; + return new String[]{StatCollector.translateToLocal("tooltip.tile.biolab.0.name"), StatCollector.translateToLocal("tooltip.bw.1.name") + ChatColorHelper.DARKGREEN + " BartWorks"}; } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_Diode.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_Diode.java index b85e1137fe..e3a1da3966 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_Diode.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_Diode.java @@ -42,7 +42,7 @@ public class GT_MetaTileEntity_Diode extends GT_MetaTileEntity_BasicHull { public GT_MetaTileEntity_Diode(int aID, String aName, String aNameRegional, int aTier) { super(aID, aName, aNameRegional, aTier, StatCollector.translateToLocal("tooltip.tile.diode.0.name")); maxAmps = getAmpsfromMeta(aID); - aAmps=maxAmps; + aAmps = maxAmps; } public GT_MetaTileEntity_Diode(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { @@ -54,7 +54,7 @@ public class GT_MetaTileEntity_Diode extends GT_MetaTileEntity_BasicHull { super.onFirstTick(aBaseMetaTileEntity); if (maxAmps == 0 && !this.getBaseMetaTileEntity().getWorld().isRemote) { maxAmps = getAmpsfromMeta(this.getBaseMetaTileEntity().getMetaTileID()); - aAmps=maxAmps; + aAmps = maxAmps; } } @@ -100,16 +100,16 @@ public class GT_MetaTileEntity_Diode extends GT_MetaTileEntity_BasicHull { return new GT_MetaTileEntity_Diode(this.mName, this.mTier, this.mDescriptionArray, this.mTextures); } - private long getAmpsfromMeta(int meta){ - if (meta > ConfigHandler.IDOffset + GT_Values.VN.length && meta <= ConfigHandler.IDOffset + GT_Values.VN.length*2) + private long getAmpsfromMeta(int meta) { + if (meta > ConfigHandler.IDOffset + GT_Values.VN.length && meta <= ConfigHandler.IDOffset + GT_Values.VN.length * 2) return 2L; - else if (meta > ConfigHandler.IDOffset + GT_Values.VN.length*2 && meta <= ConfigHandler.IDOffset + GT_Values.VN.length*3) + else if (meta > ConfigHandler.IDOffset + GT_Values.VN.length * 2 && meta <= ConfigHandler.IDOffset + GT_Values.VN.length * 3) return 4L; - else if (meta > ConfigHandler.IDOffset + GT_Values.VN.length*3 && meta <= ConfigHandler.IDOffset + GT_Values.VN.length*4) + else if (meta > ConfigHandler.IDOffset + GT_Values.VN.length * 3 && meta <= ConfigHandler.IDOffset + GT_Values.VN.length * 4) return 8L; - else if (meta > ConfigHandler.IDOffset + GT_Values.VN.length*4 && meta <= ConfigHandler.IDOffset + GT_Values.VN.length*5) + else if (meta > ConfigHandler.IDOffset + GT_Values.VN.length * 4 && meta <= ConfigHandler.IDOffset + GT_Values.VN.length * 5) return 12L; - else if (meta > ConfigHandler.IDOffset + GT_Values.VN.length*5 && meta <= ConfigHandler.IDOffset + GT_Values.VN.length*6) + else if (meta > ConfigHandler.IDOffset + GT_Values.VN.length * 5 && meta <= ConfigHandler.IDOffset + GT_Values.VN.length * 6) return 16L; else return 0L; @@ -117,6 +117,6 @@ public class GT_MetaTileEntity_Diode extends GT_MetaTileEntity_BasicHull { @SuppressWarnings("deprecation") public String[] getDescription() { - return new String[]{mDescription, StatCollector.translateToLocal("tooltip.tile.tiereddsc.0.name")+ " " + ChatColorHelper.YELLOW + GT_Values.V[this.mTier], StatCollector.translateToLocal("tooltip.tile.tiereddsc.1.name") + " " + ChatColorHelper.YELLOW + maxAmperesIn(), StatCollector.translateToLocal("tooltip.tile.tiereddsc.2.name") +" " + ChatColorHelper.YELLOW + maxAmperesOut(), StatCollector.translateToLocal("tooltip.bw.1.name") + ChatColorHelper.DARKGREEN + " BartWorks"}; + return new String[]{mDescription, StatCollector.translateToLocal("tooltip.tile.tiereddsc.0.name") + " " + ChatColorHelper.YELLOW + GT_Values.V[this.mTier], StatCollector.translateToLocal("tooltip.tile.tiereddsc.1.name") + " " + ChatColorHelper.YELLOW + maxAmperesIn(), StatCollector.translateToLocal("tooltip.tile.tiereddsc.2.name") + " " + ChatColorHelper.YELLOW + maxAmperesOut(), StatCollector.translateToLocal("tooltip.bw.1.name") + ChatColorHelper.DARKGREEN + " BartWorks"}; } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_EnergyDistributor.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_EnergyDistributor.java index 25fad9103e..8c4c13d171 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_EnergyDistributor.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_EnergyDistributor.java @@ -71,7 +71,7 @@ public class GT_MetaTileEntity_EnergyDistributor extends GT_MetaTileEntity_Trans @SuppressWarnings("deprecation") public String[] getDescription() { - return new String[]{StatCollector.translateToLocal("tooltip.tile.energydistributor.0.name"), StatCollector.translateToLocal("tooltip.tile.tiereddsc.0.name")+ " " + ChatColorHelper.YELLOW + GT_Values.V[this.mTier], StatCollector.translateToLocal("tooltip.tile.tiereddsc.1.name")+ " " + ChatColorHelper.YELLOW + this.maxAmperesIn(), StatCollector.translateToLocal("tooltip.tile.tiereddsc.2.name")+ " " + ChatColorHelper.YELLOW + this.maxAmperesOut(), StatCollector.translateToLocal("tooltip.bw.1.name") + ChatColorHelper.DARKGREEN + " BartWorks"}; + return new String[]{StatCollector.translateToLocal("tooltip.tile.energydistributor.0.name"), StatCollector.translateToLocal("tooltip.tile.tiereddsc.0.name") + " " + ChatColorHelper.YELLOW + GT_Values.V[this.mTier], StatCollector.translateToLocal("tooltip.tile.tiereddsc.1.name") + " " + ChatColorHelper.YELLOW + this.maxAmperesIn(), StatCollector.translateToLocal("tooltip.tile.tiereddsc.2.name") + " " + ChatColorHelper.YELLOW + this.maxAmperesOut(), StatCollector.translateToLocal("tooltip.bw.1.name") + ChatColorHelper.DARKGREEN + " BartWorks"}; } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_RadioHatch.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_RadioHatch.java index 6ee28527c4..63ba6660a1 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_RadioHatch.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_RadioHatch.java @@ -26,7 +26,7 @@ import com.github.bartimaeusnek.bartworks.API.BioVatLogicAdder; import com.github.bartimaeusnek.bartworks.MainMod; import com.github.bartimaeusnek.bartworks.client.gui.GT_GUIContainer_RadioHatch; import com.github.bartimaeusnek.bartworks.server.container.GT_Container_RadioHatch; -import com.github.bartimaeusnek.bartworks.util.BW_Util; +import com.github.bartimaeusnek.bartworks.util.BW_ColorUtil; import com.github.bartimaeusnek.bartworks.util.ChatColorHelper; import gregtech.api.enums.ItemList; import gregtech.api.enums.Materials; @@ -58,7 +58,7 @@ public class GT_MetaTileEntity_RadioHatch extends GT_MetaTileEntity_Hatch { private byte coverage = 0; public GT_MetaTileEntity_RadioHatch(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, 1, new String[]{StatCollector.translateToLocal("tooltip.tile.radhatch.0.name"), StatCollector.translateToLocal("tooltip.tile.tiereddsc.3.name")+" " + (aTier - 2) + " " + ((aTier - 2) >= 2 ? StatCollector.translateToLocal("tooltip.bw.kg.1.name") : StatCollector.translateToLocal("tooltip.bw.kg.0.name")), StatCollector.translateToLocal("tooltip.tile.radhatch.1.name"), StatCollector.translateToLocal("tooltip.bw.1.name") + ChatColorHelper.DARKGREEN + " BartWorks"}); + super(aID, aName, aNameRegional, aTier, 1, new String[]{StatCollector.translateToLocal("tooltip.tile.radhatch.0.name"), StatCollector.translateToLocal("tooltip.tile.tiereddsc.3.name") + " " + (aTier - 2) + " " + ((aTier - 2) >= 2 ? StatCollector.translateToLocal("tooltip.bw.kg.1.name") : StatCollector.translateToLocal("tooltip.bw.kg.0.name")), StatCollector.translateToLocal("tooltip.tile.radhatch.1.name"), StatCollector.translateToLocal("tooltip.bw.1.name") + ChatColorHelper.DARKGREEN + " BartWorks"}); cap = aTier - 2; } @@ -253,8 +253,9 @@ public class GT_MetaTileEntity_RadioHatch extends GT_MetaTileEntity_Hatch { @Override public String[] getInfoData() { if (calcDecayTicks(this.sievert) != 0) - return new String[]{StatCollector.translateToLocal("tooltip.tile.radhatch.2.name")+" "+ material, StatCollector.translateToLocal("tooltip.tile.radhatch.3.name")+" "+ sievert, StatCollector.translateToLocal("tooltip.tile.radhatch.4.name")+" "+mass, StatCollector.translateToLocal("tooltip.tile.radhatch.5.name")+" "+ + ((calcDecayTicks(this.sievert)) - timer % (calcDecayTicks(this.sievert) * 60)) + StatCollector.translateToLocal("tooltip.tile.radhatch.6.name")+"/" + ((calcDecayTicks(this.sievert)) - timer % (calcDecayTicks(this.sievert))) / 20 + StatCollector.translateToLocal("tooltip.tile.radhatch.7.name")+"/" + ((calcDecayTicks(this.sievert)) - timer % (calcDecayTicks(this.sievert))) / 20 / 60 + StatCollector.translateToLocal("tooltip.tile.radhatch.8.name")+"/" + ((calcDecayTicks(this.sievert)) - timer % (calcDecayTicks(this.sievert))) / 20 / 60 / 60 + StatCollector.translateToLocal("tooltip.tile.radhatch.9.name")}; - else return new String[]{StatCollector.translateToLocal("tooltip.tile.radhatch.2.name")+" "+StatCollector.translateToLocal("tooltip.bw.empty.name"), StatCollector.translateToLocal("tooltip.tile.radhatch.3.name")+" "+"0", StatCollector.translateToLocal("tooltip.tile.radhatch.4.name")+" "+"0"}; + return new String[]{StatCollector.translateToLocal("tooltip.tile.radhatch.2.name") + " " + material, StatCollector.translateToLocal("tooltip.tile.radhatch.3.name") + " " + sievert, StatCollector.translateToLocal("tooltip.tile.radhatch.4.name") + " " + mass, StatCollector.translateToLocal("tooltip.tile.radhatch.5.name") + " " + +((calcDecayTicks(this.sievert)) - timer % (calcDecayTicks(this.sievert) * 60)) + StatCollector.translateToLocal("tooltip.tile.radhatch.6.name") + "/" + ((calcDecayTicks(this.sievert)) - timer % (calcDecayTicks(this.sievert))) / 20 + StatCollector.translateToLocal("tooltip.tile.radhatch.7.name") + "/" + ((calcDecayTicks(this.sievert)) - timer % (calcDecayTicks(this.sievert))) / 20 / 60 + StatCollector.translateToLocal("tooltip.tile.radhatch.8.name") + "/" + ((calcDecayTicks(this.sievert)) - timer % (calcDecayTicks(this.sievert))) / 20 / 60 / 60 + StatCollector.translateToLocal("tooltip.tile.radhatch.9.name")}; + else + return new String[]{StatCollector.translateToLocal("tooltip.tile.radhatch.2.name") + " " + StatCollector.translateToLocal("tooltip.bw.empty.name"), StatCollector.translateToLocal("tooltip.tile.radhatch.3.name") + " " + "0", StatCollector.translateToLocal("tooltip.tile.radhatch.4.name") + " " + "0"}; } public boolean isSimpleMachine() { @@ -294,7 +295,7 @@ public class GT_MetaTileEntity_RadioHatch extends GT_MetaTileEntity_Hatch { aNBT.setByte("mMass", mass); aNBT.setByte("mSv", (byte) (sievert - 100)); aNBT.setByte("mCoverage", coverage); - aNBT.setInteger("mTextColor", BW_Util.getColorFromArray(getColorForGUI())); + aNBT.setInteger("mTextColor", BW_ColorUtil.getColorFromRGBArray(getColorForGUI())); if (material != null && !material.isEmpty()) aNBT.setString("mMaterial", material); aNBT.setLong("timer", timer); @@ -311,7 +312,7 @@ public class GT_MetaTileEntity_RadioHatch extends GT_MetaTileEntity_Hatch { mass = aNBT.getByte("mMass"); sievert = aNBT.getByte("mSv") + 100; coverage = aNBT.getByte("mCoverage"); - colorForGUI = BW_Util.splitColortoArray(aNBT.getInteger("mTextColor")); + colorForGUI = BW_ColorUtil.splitColorToRBGArray(aNBT.getInteger("mTextColor")); material = aNBT.getString("mMaterial"); super.loadNBTData(aNBT); } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_BioLabHandler.java b/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_BioLabHandler.java index b0b1fe61df..8590f1f713 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_BioLabHandler.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_BioLabHandler.java @@ -62,8 +62,7 @@ public class BW_NEI_BioLabHandler extends GT_NEI_DefaultHandler { } } - } - else + } else super.loadCraftingRecipes(aResult); } @@ -81,8 +80,7 @@ public class BW_NEI_BioLabHandler extends GT_NEI_DefaultHandler { } } - } - else + } else super.loadCraftingRecipes(aResult); } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_BioVatHandler.java b/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_BioVatHandler.java index dda5661c69..4cf03fb000 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_BioVatHandler.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_BioVatHandler.java @@ -56,17 +56,17 @@ public class BW_NEI_BioVatHandler extends GT_NEI_DefaultHandler { public void drawExtras(int aRecipeIndex) { int base = 70; - int[] lines ={ base,base+8,base+16,base+24,base+32,base+40,base+48,base+56,base+64}; - int tEUt = ((GT_NEI_DefaultHandler.CachedDefaultRecipe)this.arecipes.get(aRecipeIndex)).mRecipe.mEUt; - int tDuration = ((GT_NEI_DefaultHandler.CachedDefaultRecipe)this.arecipes.get(aRecipeIndex)).mRecipe.mDuration; - String[] recipeDesc = ((GT_NEI_DefaultHandler.CachedDefaultRecipe)this.arecipes.get(aRecipeIndex)).mRecipe.getNeiDesc(); + int[] lines = {base, base + 8, base + 16, base + 24, base + 32, base + 40, base + 48, base + 56, base + 64}; + int tEUt = ((GT_NEI_DefaultHandler.CachedDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.mEUt; + int tDuration = ((GT_NEI_DefaultHandler.CachedDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.mDuration; + String[] recipeDesc = ((GT_NEI_DefaultHandler.CachedDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.getNeiDesc(); int tSpecial; if (recipeDesc == null) { if (tEUt != 0) { - drawText(10, lines[0], this.trans("152", "Total: ") + (long)tDuration * (long)tEUt + " EU", -16777216); + drawText(10, lines[0], this.trans("152", "Total: ") + (long) tDuration * (long) tEUt + " EU", -16777216); drawText(10, lines[1], this.trans("153", "Usage: ") + tEUt + " EU/t", -16777216); if (this.mRecipeMap.mShowVoltageAmperageInNEI) { - drawText(10,lines[2], this.trans("154", "Voltage: ") + tEUt / this.mRecipeMap.mAmperage + " EU", -16777216); + drawText(10, lines[2], this.trans("154", "Voltage: ") + tEUt / this.mRecipeMap.mAmperage + " EU", -16777216); drawText(10, lines[3], this.trans("155", "Amperage: ") + this.mRecipeMap.mAmperage, -16777216); } else { drawText(10, lines[2], this.trans("156", "Voltage: unspecified"), -16777216); @@ -75,16 +75,15 @@ public class BW_NEI_BioVatHandler extends GT_NEI_DefaultHandler { } - if (tDuration > 0) { - drawText(10, lines[4], this.trans("158", "Time: ") + String.format("%.2f " + this.trans("161", " secs"), 0.05F * (float)tDuration), -16777216); + drawText(10, lines[4], this.trans("158", "Time: ") + String.format("%.2f " + this.trans("161", " secs"), 0.05F * (float) tDuration), -16777216); } - tSpecial = ((GT_NEI_DefaultHandler.CachedDefaultRecipe)this.arecipes.get(aRecipeIndex)).mRecipe.mSpecialValue; + tSpecial = ((GT_NEI_DefaultHandler.CachedDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.mSpecialValue; int[] tSpecialA = GT_TileEntity_BioVat.specialValueUnpack(tSpecial); - drawText(10, lines[5], StatCollector.translateToLocal("nei.biovat.0.name")+" " + tSpecialA[0],-16777216); + drawText(10, lines[5], StatCollector.translateToLocal("nei.biovat.0.name") + " " + tSpecialA[0], -16777216); if (tSpecialA[1] == -100 && GT_Mod.gregtechproxy.mLowGravProcessing) { drawText(10, lines[7], this.trans("159", "Needs Low Gravity"), -16777216); @@ -95,14 +94,14 @@ public class BW_NEI_BioVatHandler extends GT_NEI_DefaultHandler { } else if (tSpecialA[1] == -400) { drawText(10, lines[7], this.trans("216", "Deprecated Recipe"), -16777216); } else if (GT_Utility.isStringValid(this.mRecipeMap.mNEISpecialValuePre) || GT_Utility.isStringValid(this.mRecipeMap.mNEISpecialValuePost)) { - drawText(10, lines[6],(tSpecialA[2] == 1 ? StatCollector.translateToLocal("nei.biovat.1.name"): StatCollector.translateToLocal("nei.biovat.2.name")) + this.mRecipeMap.mNEISpecialValuePre + tSpecialA[3] * this.mRecipeMap.mNEISpecialValueMultiplier + this.mRecipeMap.mNEISpecialValuePost, -16777216); + drawText(10, lines[6], (tSpecialA[2] == 1 ? StatCollector.translateToLocal("nei.biovat.1.name") : StatCollector.translateToLocal("nei.biovat.2.name")) + this.mRecipeMap.mNEISpecialValuePre + tSpecialA[3] * this.mRecipeMap.mNEISpecialValueMultiplier + this.mRecipeMap.mNEISpecialValuePost, -16777216); } } else { tSpecial = 0; String[] var6 = recipeDesc; int var7 = recipeDesc.length; - for(int var8 = 0; var8 < var7; ++var8) { + for (int var8 = 0; var8 < var7; ++var8) { String descLine = var6[var8]; drawText(10, 73 + 10 * tSpecial, descLine, -16777216); ++tSpecial; @@ -127,7 +126,7 @@ public class BW_NEI_BioVatHandler extends GT_NEI_DefaultHandler { @Override public void loadCraftingRecipes(ItemStack aResult) { - if (aResult == null || !(aResult.getItem() instanceof LabParts && aResult.getItemDamage() < 3 )) { + if (aResult == null || !(aResult.getItem() instanceof LabParts && aResult.getItemDamage() < 3)) { super.loadCraftingRecipes(aResult); } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_OreHandler.java b/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_OreHandler.java new file mode 100644 index 0000000000..5360268200 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_OreHandler.java @@ -0,0 +1,253 @@ +/* + * Copyright (c) 2019 bartimaeusnek + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.neiHandler; + +import codechicken.lib.gui.GuiDraw; +import codechicken.nei.PositionedStack; +import codechicken.nei.recipe.GuiCraftingRecipe; +import codechicken.nei.recipe.TemplateRecipeHandler; +import com.github.bartimaeusnek.bartworks.MainMod; +import com.github.bartimaeusnek.bartworks.system.material.BW_MetaGenerated_Ores; +import com.github.bartimaeusnek.bartworks.system.material.Werkstoff; +import com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader; +import com.github.bartimaeusnek.bartworks.util.ChatColorHelper; +import com.github.bartimaeusnek.crossmod.galacticraft.planets.ross128.world.oregen.BW_OreLayer; +import com.github.bartimaeusnek.crossmod.galacticraft.planets.ross128.world.oregen.BW_WorldGenRoss128; +import cpw.mods.fml.common.event.FMLInterModComms; +import gregtech.api.GregTech_API; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GT_Utility; +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; + +import java.awt.*; +import java.util.ArrayList; +import java.util.List; + +public class BW_NEI_OreHandler extends TemplateRecipeHandler { + + public BW_NEI_OreHandler() { + if (!NEI_BW_Config.sIsAdded) { + FMLInterModComms.sendRuntimeMessage(MainMod.MOD_ID, "NEIPlugins", "register-crafting-handler", MainMod.MOD_ID + "@" + getRecipeName() + "@" + getOverlayIdentifier()); + GuiCraftingRecipe.craftinghandlers.add(this); +// GuiUsageRecipe.usagehandlers.add(this); + } + } + + @Override + public void drawBackground(int recipe) { + GuiDraw.drawRect(0, 0, 166, 65, 0x888888); + } + + @Override + public void loadTransferRects() { + transferRects.add(new RecipeTransferRect(new Rectangle(0,40,40,10),"quickanddirtyneihandler")); + } + + @Override + public int recipiesPerPage() { + return 1; + } + + @Override + public void loadCraftingRecipes(String outputId, Object... results) { + if (outputId.equalsIgnoreCase("quickanddirtyneihandler")) { + for (int i = 0; i < Werkstoff.werkstoffHashMap.values().size(); i++) { + Werkstoff w = Werkstoff.werkstoffHashMap.get((short)i); + if (w == null || w == Werkstoff.default_null_Werkstoff) + continue; + if (w.getGenerationFeatures().hasOres()) { + ItemStack result = w.get(OrePrefixes.ore); + CachedRecipe tmp = new CachedRecipe() { + + PositionedStack stack = new PositionedStack(result, 0, 0); + + @Override + public PositionedStack getResult() { + return stack; + } + + @Override + public List<PositionedStack> getOtherStacks() { + ArrayList<PositionedStack> ret = new ArrayList<>(); + for (int i = 0; i < BW_OreLayer.sList.size(); i++) { + if (BW_OreLayer.sList.get(i) instanceof BW_WorldGenRoss128) { + int baseMeta = result.getItemDamage(); + BW_WorldGenRoss128 worldGen = ((BW_WorldGenRoss128) BW_OreLayer.sList.get(i)); + if (worldGen.mPrimaryMeta == baseMeta || worldGen.mSecondaryMeta == baseMeta || worldGen.mBetweenMeta == baseMeta || worldGen.mSporadicMeta == baseMeta) { + ItemStack other; + other = result.copy().setStackDisplayName(result.getDisplayName().replaceAll("Ore", "Vein")); + stack = new PositionedStack(other, 83, 0); + if (((worldGen.bwOres & 0b1000) != 0)) { + other = result.copy(); + other.setItemDamage(worldGen.mPrimaryMeta); + ret.add(new PositionedStack(other, 0, 12)); + } else { + other = new ItemStack(GregTech_API.sBlockOres1); + other.setItemDamage(worldGen.mPrimaryMeta); + ret.add(new PositionedStack(other, 0, 12)); + } + if (((worldGen.bwOres & 0b0100) != 0)) { + other = result.copy(); + other.setItemDamage(worldGen.mSecondaryMeta); + ret.add(new PositionedStack(other, 20, 12)); + } else { + other = new ItemStack(GregTech_API.sBlockOres1); + other.setItemDamage(worldGen.mSecondaryMeta); + ret.add(new PositionedStack(other, 20, 12)); + } + if (((worldGen.bwOres & 0b0010) != 0)) { + other = result.copy(); + other.setItemDamage(worldGen.mBetweenMeta); + ret.add(new PositionedStack(other, 40, 12)); + } else { + other = new ItemStack(GregTech_API.sBlockOres1); + other.setItemDamage(worldGen.mBetweenMeta); + ret.add(new PositionedStack(other, 40, 12)); + } + if (((worldGen.bwOres & 0b0001) != 0)) { + other = result.copy(); + other.setItemDamage(worldGen.mSporadicMeta); + ret.add(new PositionedStack(other, 60, 12)); + } else { + other = new ItemStack(GregTech_API.sBlockOres1); + other.setItemDamage(worldGen.mSporadicMeta); + ret.add(new PositionedStack(other, 60, 12)); + } + break; + } + } + } + return ret; + } + }; + boolean add = true; + for (TemplateRecipeHandler.CachedRecipe recipe: arecipes) { + if (recipe == null || recipe.getOtherStacks() == null || recipe.getOtherStacks().get(0) == null || recipe.getOtherStacks().get(0).item == null) + continue; + if (GT_Utility.areStacksEqual(recipe.getOtherStacks().get(0).item,tmp.getOtherStacks().get(0).item)) + add = false; + } + if (add) + this.arecipes.add(tmp); + } + } + } else super.loadCraftingRecipes(outputId, results); + } + + @Override + public void drawExtras(int recipe) { + if ((recipe < this.arecipes.size()) && (this.arecipes.get(recipe).getOtherStacks().size() >= 4) ) { + GuiDraw.drawString(ChatColorHelper.BOLD + "DIM:" + ChatColorHelper.RESET + " Ross128", 0, 40, 0, false); + GuiDraw.drawString(ChatColorHelper.BOLD + "Primary:", 0, 50, 0, false); + GuiDraw.drawString(this.arecipes.get(recipe).getOtherStacks().get(0).item.getDisplayName(), 0, 60, 0, false); + GuiDraw.drawString(ChatColorHelper.BOLD + "Secondary:", 0, 70, 0, false); + GuiDraw.drawString(this.arecipes.get(recipe).getOtherStacks().get(1).item.getDisplayName(), 0, 80, 0, false); + GuiDraw.drawString(ChatColorHelper.BOLD + "InBetween:", 0, 90, 0, false); + GuiDraw.drawString(this.arecipes.get(recipe).getOtherStacks().get(2).item.getDisplayName(), 0, 100, 0, false); + GuiDraw.drawString(ChatColorHelper.BOLD + "Sporadic:", 0, 110, 0, false); + GuiDraw.drawString(this.arecipes.get(recipe).getOtherStacks().get(3).item.getDisplayName(), 0, 120, 0, false); + } + super.drawExtras(recipe); + } + + @Override + public void loadCraftingRecipes(ItemStack result) { + if (Block.getBlockFromItem(result.getItem()) instanceof BW_MetaGenerated_Ores) { + CachedRecipe tmp = new CachedRecipe() { + + PositionedStack stack = new PositionedStack(result, 0, 0); + + @Override + public PositionedStack getResult() { + return stack; + } + + @Override + public List<PositionedStack> getOtherStacks() { + ArrayList<PositionedStack> ret = new ArrayList<>(); + for (int i = 0; i < BW_OreLayer.sList.size(); i++) { + if (BW_OreLayer.sList.get(i) instanceof BW_WorldGenRoss128) { + int baseMeta = result.getItemDamage(); + BW_WorldGenRoss128 worldGen = ((BW_WorldGenRoss128) BW_OreLayer.sList.get(i)); + if (worldGen.mPrimaryMeta == baseMeta || worldGen.mSecondaryMeta == baseMeta || worldGen.mBetweenMeta == baseMeta || worldGen.mSporadicMeta == baseMeta) { + ItemStack other; + other = result.copy().setStackDisplayName(result.getDisplayName().replaceAll("Ore", "Vein")); + stack = new PositionedStack(other, 83, 0); + if (((worldGen.bwOres & 0b1000) != 0)) { + other = result.copy(); + other.setItemDamage(worldGen.mPrimaryMeta); + ret.add(new PositionedStack(other, 0, 12)); + } else { + other = new ItemStack(GregTech_API.sBlockOres1); + other.setItemDamage(worldGen.mPrimaryMeta); + ret.add(new PositionedStack(other, 0, 12)); + } + if (((worldGen.bwOres & 0b0100) != 0)) { + other = result.copy(); + other.setItemDamage(worldGen.mSecondaryMeta); + ret.add(new PositionedStack(other, 20, 12)); + } else { + other = new ItemStack(GregTech_API.sBlockOres1); + other.setItemDamage(worldGen.mSecondaryMeta); + ret.add(new PositionedStack(other, 20, 12)); + } + if (((worldGen.bwOres & 0b0010) != 0)) { + other = result.copy(); + other.setItemDamage(worldGen.mBetweenMeta); + ret.add(new PositionedStack(other, 40, 12)); + } else { + other = new ItemStack(GregTech_API.sBlockOres1); + other.setItemDamage(worldGen.mBetweenMeta); + ret.add(new PositionedStack(other, 40, 12)); + } + if (((worldGen.bwOres & 0b0001) != 0)) { + other = result.copy(); + other.setItemDamage(worldGen.mSporadicMeta); + ret.add(new PositionedStack(other, 60, 12)); + } else { + other = new ItemStack(GregTech_API.sBlockOres1); + other.setItemDamage(worldGen.mSporadicMeta); + ret.add(new PositionedStack(other, 60, 12)); + } + break; + } + } + } + return ret; + } + }; + this.arecipes.add(tmp); + } + } + + @Override + public String getGuiTexture() { + return "textures/gui/container/brewing_stand.png"; + } + + @Override + public String getRecipeName() { + return "BartWorks Ores"; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/NEI_BW_Config.java b/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/NEI_BW_Config.java index 3614f608b1..39aae565bf 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/NEI_BW_Config.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/NEI_BW_Config.java @@ -32,6 +32,7 @@ public class NEI_BW_Config implements IConfigureNEI { public void loadConfig() { sIsAdded = false; + new BW_NEI_OreHandler(); new BW_NEI_BioVatHandler(BWRecipes.instance.getMappingsFor(BWRecipes.BACTERIALVATBYTE)); new BW_NEI_BioLabHandler(BWRecipes.instance.getMappingsFor(BWRecipes.BIOLABBYTE)); sIsAdded = true; diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/server/container/BW_Container_HeatedWaterPump.java b/src/main/java/com/github/bartimaeusnek/bartworks/server/container/BW_Container_HeatedWaterPump.java index a3b951b34e..121f628df8 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/server/container/BW_Container_HeatedWaterPump.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/server/container/BW_Container_HeatedWaterPump.java @@ -23,6 +23,7 @@ package com.github.bartimaeusnek.bartworks.server.container; import com.github.bartimaeusnek.bartworks.common.tileentities.classic.BW_TileEntity_HeatedWaterPump; +import com.github.bartimaeusnek.bartworks.server.container.Slots.BW_FuelSlot; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.gui.GT_Slot_Render; @@ -48,7 +49,7 @@ public class BW_Container_HeatedWaterPump extends Container { this.TILE = TILE; this.INVENTORY = INVENTORY.inventory; - this.addSlotToContainer(new Slot(TILE, 0, 56, 53)); + this.addSlotToContainer(new BW_FuelSlot(TILE, 0, 56, 53)); this.addSlotToContainer(new GT_Slot_Render(TILE, 1, 86, 33)); int i; diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/server/container/GT_Container_Item_Destructopack.java b/src/main/java/com/github/bartimaeusnek/bartworks/server/container/GT_Container_Item_Destructopack.java index edfc722bbd..b983ea27d7 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/server/container/GT_Container_Item_Destructopack.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/server/container/GT_Container_Item_Destructopack.java @@ -22,6 +22,7 @@ package com.github.bartimaeusnek.bartworks.server.container; +import com.github.bartimaeusnek.bartworks.server.container.Slots.BW_DelSlot; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; @@ -33,7 +34,7 @@ public class GT_Container_Item_Destructopack extends Container { public GT_Container_Item_Destructopack(InventoryPlayer inventory) { - addSlotToContainer(new delslot()); + addSlotToContainer(new BW_DelSlot()); for (int i = 0; i < 3; i++) { for (int j = 0; j < 9; j++) { @@ -62,18 +63,4 @@ public class GT_Container_Item_Destructopack extends Container { final Slot slotObject = (Slot) this.inventorySlots.get(0); slotObject.decrStackSize(0); } - - - class delslot extends Slot { - public delslot() { - super(new InventoryPlayer(null), 0, 80, 17); - } - - public void putStack(ItemStack p_75215_1_) { - p_75215_1_ = null; - this.onSlotChanged(); - } - - - } }
\ No newline at end of file diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/server/container/Slots/BW_DelSlot.java b/src/main/java/com/github/bartimaeusnek/bartworks/server/container/Slots/BW_DelSlot.java new file mode 100644 index 0000000000..133bc2dfbb --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/server/container/Slots/BW_DelSlot.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2019 bartimaeusnek + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.server.container.Slots; + +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +public class BW_DelSlot extends Slot { + public BW_DelSlot() { + super(new InventoryPlayer(null), 0, 80, 17); + } + + public void putStack(ItemStack p_75215_1_) { + p_75215_1_ = null; + this.onSlotChanged(); + } + + +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/server/container/Slots/BW_FuelSlot.java b/src/main/java/com/github/bartimaeusnek/bartworks/server/container/Slots/BW_FuelSlot.java new file mode 100644 index 0000000000..71ed548559 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/server/container/Slots/BW_FuelSlot.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2019 bartimaeusnek + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.server.container.Slots; + +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntityFurnace; + +public class BW_FuelSlot extends Slot { + public BW_FuelSlot(IInventory p_i1824_1_, int p_i1824_2_, int p_i1824_3_, int p_i1824_4_) { + super(p_i1824_1_, p_i1824_2_, p_i1824_3_, p_i1824_4_); + } + + @Override + public boolean isItemValid(ItemStack itemStack) { + return TileEntityFurnace.getItemBurnTime(itemStack) > 0; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/log/DebugLog.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/log/DebugLog.java new file mode 100644 index 0000000000..ba85a38e79 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/log/DebugLog.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2019 bartimaeusnek + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.log; + +import cpw.mods.fml.common.event.FMLPreInitializationEvent; + +import java.io.File; +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.GregorianCalendar; +import java.util.logging.FileHandler; +import java.util.logging.Formatter; +import java.util.logging.LogRecord; +import java.util.logging.Logger; + +public class DebugLog { + private static boolean init = false; + private static FileHandler fh; + private static Logger utilLog; + public DebugLog(FMLPreInitializationEvent event) throws IOException { + if (init) + return; + fh = new FileHandler(new File(new File(event.getModConfigurationDirectory().getParentFile(),"logs"),"BWLog.log").toString()); + utilLog = Logger.getLogger("DebugLog"); + utilLog.setUseParentHandlers(false); + utilLog.addHandler(fh); + Formatter formatter = new Formatter() { + @Override + public String format(LogRecord record) { + SimpleDateFormat logTime = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss"); + Calendar cal = new GregorianCalendar(); + cal.setTimeInMillis(record.getMillis()); + return "Level: " + record.getLevel() + +" at " + logTime.format(cal.getTime()) + + " " + record.getMessage() + "\n"; + } + }; + fh.setFormatter(formatter); + init = true; + } + + public static void log(String record){ + if (!init) + return; + utilLog.info(record); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedOreTE.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedOreTE.java new file mode 100644 index 0000000000..81ab1e54b9 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedOreTE.java @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2019 bartimaeusnek + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.material; + +import com.github.bartimaeusnek.bartworks.common.net.OrePacket; +import com.github.bartimaeusnek.bartworks.util.Coords; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.ITexturedTileEntity; +import gregtech.api.objects.GT_CopiedBlockTexture; +import gregtech.api.objects.GT_RenderedTexture; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.Packet; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +import java.util.ArrayList; + +import static com.github.bartimaeusnek.bartworks.MainMod.BW_Network_instance; + +public class BW_MetaGeneratedOreTE extends TileEntity implements ITexturedTileEntity { + + public short mMetaData = 0; + + public static boolean placeOre(World aWorld, Coords coords, Werkstoff werkstoff) { + short meta = werkstoff.getmID(); + aWorld.setBlock(coords.x, coords.y, coords.z, WerkstoffLoader.BWOres, 0, 0); + TileEntity tTileEntity = aWorld.getTileEntity(coords.x, coords.y, coords.z); + if ((tTileEntity instanceof BW_MetaGeneratedOreTE)) { + ((BW_MetaGeneratedOreTE) tTileEntity).mMetaData = meta; + } + return true; + } + + public boolean canUpdate() { + return false; + } + + public void readFromNBT(NBTTagCompound aNBT) { + super.readFromNBT(aNBT); + this.mMetaData = aNBT.getShort("m"); + } + + public void writeToNBT(NBTTagCompound aNBT) { + super.writeToNBT(aNBT); + aNBT.setShort("m", this.mMetaData); + } + + public ArrayList<ItemStack> getDrops(Block aDroppedOre) { + ArrayList<ItemStack> rList = new ArrayList(); + if (this.mMetaData < 0) { + rList.add(new ItemStack(Blocks.cobblestone, 1, 0)); + return rList; + } + rList.add(new ItemStack(aDroppedOre, 1, this.mMetaData)); + return rList; + } + + public Packet getDescriptionPacket() { + if (!this.worldObj.isRemote) + BW_Network_instance.sendPacketToAllPlayersInRange(this.worldObj, new OrePacket(this.xCoord, (short) this.yCoord, this.zCoord, this.mMetaData), this.xCoord, this.zCoord); + return null; + } + + @Override + public ITexture[] getTexture(Block aBlock, byte aSide) { + Werkstoff aMaterial = Werkstoff.werkstoffHashMap.get(this.mMetaData); + if ((aMaterial != null)) { + GT_RenderedTexture aIconSet = new GT_RenderedTexture(aMaterial.getTexSet().mTextures[OrePrefixes.ore.mTextureIndex], aMaterial.getRGBA()); + return new ITexture[]{new GT_CopiedBlockTexture(Blocks.stone, 0, 0), aIconSet}; + } + return new ITexture[]{new GT_CopiedBlockTexture(Blocks.stone, 0, 0), new GT_RenderedTexture(gregtech.api.enums.TextureSet.SET_NONE.mTextures[OrePrefixes.ore.mTextureIndex])}; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedOre_Item.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedOre_Item.java new file mode 100644 index 0000000000..46a9894572 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedOre_Item.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2019 bartimaeusnek + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.material; + +import com.github.bartimaeusnek.bartworks.common.items.BW_ItemBlocks; +import gregtech.api.util.GT_LanguageManager; +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +public class BW_MetaGeneratedOre_Item extends BW_ItemBlocks { + + public BW_MetaGeneratedOre_Item(Block par1) { + super(par1); + } + + public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) { + return false; + } + + public String getUnlocalizedName(ItemStack aStack) { + return this.field_150939_a.getUnlocalizedName() + "." + getDamage(aStack); + } + + public String getItemStackDisplayName(ItemStack aStack) { + return GT_LanguageManager.getTranslation("bw.blockores.01." + aStack.getItemDamage() + ".name"); + } + + public boolean placeBlockAt(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int side, float hitX, float hitY, float hitZ, int aMeta) { + short tDamage = (short) getDamage(aStack); + if (tDamage > 0) { + if (!aWorld.setBlock(aX, aY, aZ, this.field_150939_a, tDamage, 3)) { + return false; + } + BW_MetaGeneratedOreTE tTileEntity = (BW_MetaGeneratedOreTE) aWorld.getTileEntity(aX, aY, aZ); + tTileEntity.mMetaData = tDamage; + } else if (!aWorld.setBlock(aX, aY, aZ, this.field_150939_a, 0, 3)) { + return false; + } + if (aWorld.getBlock(aX, aY, aZ) == this.field_150939_a) { + this.field_150939_a.onBlockPlacedBy(aWorld, aX, aY, aZ, aPlayer, aStack); + this.field_150939_a.onPostBlockPlaced(aWorld, aX, aY, aZ, tDamage); + } + return true; + } +}
\ No newline at end of file diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Items.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Items.java new file mode 100644 index 0000000000..72db71e58d --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Items.java @@ -0,0 +1,169 @@ +/* + * Copyright (c) 2019 bartimaeusnek + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.material; + +import com.github.bartimaeusnek.bartworks.util.ChatColorHelper; +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.items.GT_MetaGenerated_Item; +import gregtech.api.util.GT_LanguageManager; +import gregtech.api.util.GT_OreDictUnificator; +import net.minecraft.block.Block; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.util.StatCollector; +import net.minecraftforge.oredict.OreDictionary; + +import java.util.List; + +import static com.github.bartimaeusnek.bartworks.system.material.Werkstoff.werkstoffHashMap; + +public class BW_MetaGenerated_Items extends GT_MetaGenerated_Item { + + public static final CreativeTabs metaTab = new CreativeTabs("bartworksMetaMaterials") { + + @Override + public Item getTabIconItem() { + return new ItemStack(Blocks.iron_ore).getItem(); + } + }; + protected final OrePrefixes orePrefixes; + private final short aNumToGen = (short) werkstoffHashMap.size(); + + public BW_MetaGenerated_Items(OrePrefixes orePrefixes) { + super("bwMetaGenerated" + orePrefixes.name(), (short) 32766, (short) 0); + this.orePrefixes = orePrefixes; + this.setCreativeTab(metaTab); + for (int i = 0; i < aNumToGen; i++) { + ItemStack tStack = new ItemStack(this, 1, i); + Werkstoff w = werkstoffHashMap.get((short) i); + if (w == null || ((w.getGenerationFeatures().toGenerate & orePrefixes.mMaterialGenerationBits) == 0) || ((w.getGenerationFeatures().blacklist & orePrefixes.mMaterialGenerationBits) != 0) ) + continue; + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName(tStack) + ".name", this.getDefaultLocalization(w)); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName(tStack) + ".tooltip", w.getToolTip()); + GT_OreDictUnificator.registerOre(this.orePrefixes.name() + w.getDefaultName().replaceAll(" ",""), tStack); + } + } + + public boolean onEntityItemUpdate(EntityItem aItemEntity) { + int aDamage = aItemEntity.getEntityItem().getItemDamage(); + if ((aDamage >= 0) && (!aItemEntity.worldObj.isRemote)) { + Werkstoff aMaterial = werkstoffHashMap.get((short) aDamage); + if ((aMaterial != null) && (aMaterial != Werkstoff.default_null_Werkstoff)) { + int tX = MathHelper.floor_double(aItemEntity.posX); + int tY = MathHelper.floor_double(aItemEntity.posY); + int tZ = MathHelper.floor_double(aItemEntity.posZ); + if ((orePrefixes == OrePrefixes.dustImpure) || (orePrefixes == OrePrefixes.dustPure)) { + Block tBlock = aItemEntity.worldObj.getBlock(tX, tY, tZ); + byte tMetaData = (byte) aItemEntity.worldObj.getBlockMetadata(tX, tY, tZ); + if ((tBlock == Blocks.cauldron) && (tMetaData > 0)) { + aItemEntity.setEntityItemStack(WerkstoffLoader.getCorresopndingItemStack(OrePrefixes.dust, aMaterial, aItemEntity.getEntityItem().stackSize)); + aItemEntity.worldObj.setBlockMetadataWithNotify(tX, tY, tZ, tMetaData - 1, 3); + return true; + } + } else if (orePrefixes == OrePrefixes.crushed) { + Block tBlock = aItemEntity.worldObj.getBlock(tX, tY, tZ); + byte tMetaData = (byte) aItemEntity.worldObj.getBlockMetadata(tX, tY, tZ); + if ((tBlock == Blocks.cauldron) && (tMetaData > 0)) { + aItemEntity.setEntityItemStack(WerkstoffLoader.getCorresopndingItemStack(OrePrefixes.crushedPurified, aMaterial, aItemEntity.getEntityItem().stackSize)); + aItemEntity.worldObj.setBlockMetadataWithNotify(tX, tY, tZ, tMetaData - 1, 3); + return true; + } + } + } + } + return false; + } + + @Override + protected void addAdditionalToolTips(List aList, ItemStack aStack, EntityPlayer aPlayer) { +// String tooltip = GT_LanguageManager.getTranslation(this.getUnlocalizedName(aStack) + ".tooltip"); +// if (!tooltip.isEmpty()) +// aList.add(tooltip); + if (orePrefixes == OrePrefixes.dustImpure || orePrefixes == OrePrefixes.dustPure) { + aList.add(GT_LanguageManager.getTranslation("metaitem.01.tooltip.purify")); + } + aList.add(StatCollector.translateToLocal("tooltip.bw.0.name") + ChatColorHelper.DARKGREEN + " BartWorks"); + } + + public String getDefaultLocalization(Werkstoff werkstoff) { + return werkstoff != null ? orePrefixes.mLocalizedMaterialPre + werkstoff.getDefaultName() + orePrefixes.mLocalizedMaterialPost : Werkstoff.default_null_Werkstoff.getDefaultName(); + } + + @Override + public String getItemStackDisplayName(ItemStack aStack) { + return GT_LanguageManager.getTranslation(this.getUnlocalizedName(aStack) + ".name"); + } + + @Override + public final IIconContainer getIconContainer(int aMetaData) { + return werkstoffHashMap.get((short) aMetaData) == null ? null : werkstoffHashMap.get((short) aMetaData).getTexSet().mTextures[orePrefixes.mTextureIndex]; + } + + @Override + @SideOnly(Side.CLIENT) + public final void getSubItems(Item var1, CreativeTabs aCreativeTab, List aList) { + for (int i = 0; i < aNumToGen; i++) { + Werkstoff werkstoff = werkstoffHashMap.get((short) i); + if (werkstoff != null && ((werkstoff.getGenerationFeatures().toGenerate & orePrefixes.mMaterialGenerationBits) != 0) && ((werkstoff.getGenerationFeatures().blacklist & orePrefixes.mMaterialGenerationBits) == 0)) { + ItemStack tStack = new ItemStack(this, 1, i); + aList.add(tStack); + } + } + super.getSubItems(var1, aCreativeTab, aList); + } + + @Override + public short[] getRGBa(ItemStack aStack) { + Werkstoff werkstoff = werkstoffHashMap.get((short) getDamage(aStack)); + return werkstoff == null ? Materials._NULL.mRGBa : werkstoff.getRGBA(); + } + + @Override + public final IIcon getIconFromDamage(int aMetaData) { + if (aMetaData < 0) + return null; + Werkstoff tMaterial = werkstoffHashMap.get((short) aMetaData); + if (tMaterial == null) + return null; + IIconContainer tIcon = getIconContainer(aMetaData); + if (tIcon != null) + return tIcon.getIcon(); + return null; + } + + @Override + public int getItemStackLimit(ItemStack aStack) { + return 64; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Ores.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Ores.java new file mode 100644 index 0000000000..fd8e39ebcb --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Ores.java @@ -0,0 +1,175 @@ +/* + * Copyright (c) 2019 bartimaeusnek + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.material; + +import com.github.bartimaeusnek.bartworks.client.renderer.BW_Renderer_Block_Ores; +import com.github.bartimaeusnek.bartworks.common.blocks.BW_TileEntityContainer; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GT_LanguageManager; +import gregtech.api.util.GT_ModHandler; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.util.StatCollector; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +import java.util.ArrayList; +import java.util.List; + +import static com.github.bartimaeusnek.bartworks.system.material.BW_MetaGenerated_Items.metaTab; + +public class BW_MetaGenerated_Ores extends BW_TileEntityContainer { + + public static ThreadLocal<BW_MetaGeneratedOreTE> mTemporaryTileEntity = new ThreadLocal(); + + public BW_MetaGenerated_Ores(Material p_i45386_1_, Class<? extends TileEntity> tileEntity, String blockName) { + super(p_i45386_1_, tileEntity, blockName); + + this.setHardness(5.0F); + this.setResistance(5.0F); + this.setBlockTextureName("stone"); + this.setCreativeTab(metaTab); + for (Werkstoff w : Werkstoff.werkstoffHashSet) { + if (w != null) { + if ((w.getGenerationFeatures().toGenerate & 0b1000) == 0 || ((w.getGenerationFeatures().blacklist & 0b1000) != 0)) + continue; + GT_ModHandler.addValuableOre(this, w.getmID(), 1); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + "." + w.getmID() + ".name", w.getDefaultName() + OrePrefixes.ore.mLocalizedMaterialPost); + } + } + } + + public static boolean setOreBlock(World aWorld, int aX, int aY, int aZ, int aMetaData, boolean air) { + if (!air) { + aY = Math.min(aWorld.getActualHeight(), Math.max(aY, 1)); + } + + Block tBlock = aWorld.getBlock(aX, aY, aZ); + Block tOreBlock = WerkstoffLoader.BWOres; + if (aMetaData < 0 || tBlock == Blocks.air && !air) { + return false; + } else { + + if (!tBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Blocks.stone)) { + return false; + } + + aWorld.setBlock(aX, aY, aZ, tOreBlock, aMetaData, 0); + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof BW_MetaGeneratedOreTE) { + ((BW_MetaGeneratedOreTE) tTileEntity).mMetaData = (short) aMetaData; + } + + return true; + } + } + + public String getLocalizedName() { + return StatCollector.translateToLocal(getUnlocalizedName() + ".name"); + } + + @Override + public IIcon getIcon(int side, int meta) { + return Blocks.stone.getIcon(0, 0); + } + + @Override + public IIcon getIcon(IBlockAccess p_149673_1_, int p_149673_2_, int p_149673_3_, int p_149673_4_, int p_149673_5_) { + return Blocks.stone.getIcon(0, 0); + } + + @Override + public String getHarvestTool(int metadata) { + return "pickaxe"; + } + + protected boolean canSilkHarvest() { + return false; + } + + public int getRenderType() { + if (BW_Renderer_Block_Ores.INSTANCE == null) { + return super.getRenderType(); + } + return BW_Renderer_Block_Ores.INSTANCE.mRenderID; + } + + public int getDamageValue(World aWorld, int aX, int aY, int aZ) { + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (((tTileEntity instanceof BW_MetaGeneratedOreTE))) { + return ((BW_MetaGeneratedOreTE) tTileEntity).mMetaData; + } + return 0; + } + + public void breakBlock(World world, int x, int y, int z, Block block, int meta) { + TileEntity tTileEntity = world.getTileEntity(x, y, z); + if ((tTileEntity instanceof BW_MetaGeneratedOreTE)) { + mTemporaryTileEntity.set((BW_MetaGeneratedOreTE) tTileEntity); + } + super.breakBlock(world, x, y, z, block, meta); + } + + public ArrayList<ItemStack> getDrops(World aWorld, int aX, int aY, int aZ, int aMeta, int aFortune) { + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if ((tTileEntity instanceof BW_MetaGeneratedOreTE)) { + return ((BW_MetaGeneratedOreTE) tTileEntity).getDrops(WerkstoffLoader.BWOres); + } + return mTemporaryTileEntity.get() == null ? new ArrayList() : ((BW_MetaGeneratedOreTE) mTemporaryTileEntity.get()).getDrops(WerkstoffLoader.BWOres); + } + + public int getHarvestLevel(int metadata) { + return 3; + } + + @Override + public String getUnlocalizedName() { + return "bw.blockores.01"; + } + + @Override + public void getSubBlocks(Item aItem, CreativeTabs aTab, List aList) { + for (int i = 0; i < Werkstoff.werkstoffHashSet.size(); i++) { + Werkstoff tMaterial = Werkstoff.werkstoffHashMap.get((short) i); + if ((tMaterial != null) && ((tMaterial.getGenerationFeatures().toGenerate & 0x8) != 0) && ((tMaterial.getGenerationFeatures().blacklist & 0x8) == 0)) { + aList.add(new ItemStack(aItem, 1, i)); + } + } + } + + @Override + public void onNeighborBlockChange(World aWorld, int aX, int aY, int aZ, Block p_149695_5_) { + aWorld.getTileEntity(aX, aY, aZ).getDescriptionPacket(); + } + + @Override + public void onNeighborChange(IBlockAccess aWorld, int aX, int aY, int aZ, int tileX, int tileY, int tileZ) { + aWorld.getTileEntity(aX, aY, aZ).getDescriptionPacket(); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/OreDictHandler.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/OreDictHandler.java new file mode 100644 index 0000000000..0715d00a90 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/OreDictHandler.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2019 bartimaeusnek + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.material; + +import gregtech.api.enums.OrePrefixes; +import net.minecraft.item.ItemStack; +import net.minecraftforge.oredict.OreDictionary; + +import java.util.HashMap; + +public class OreDictHandler { + + private static final HashMap<String,ItemStack> cache = new HashMap<>(); + + public static HashMap<String, ItemStack> getCache() { + return OreDictHandler.cache; + } + + public static ItemStack getItemStack(String elementName, OrePrefixes prefixes, int amount){ + if (cache.get(prefixes+elementName.replaceAll(" ","")) != null){ + ItemStack tmp = cache.get(prefixes+elementName.replaceAll(" ","")).copy(); + tmp.stackSize=amount; + return tmp; + } else if (!OreDictionary.getOres(prefixes+elementName.replaceAll(" ","")).isEmpty()){ + ItemStack tmp = OreDictionary.getOres(prefixes+elementName.replaceAll(" ","")).get(0).copy(); + tmp.stackSize=amount; + cache.put(prefixes+elementName.replaceAll(" ",""),tmp); + return tmp; + } + return null; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/ThreadedLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/ThreadedLoader.java new file mode 100644 index 0000000000..d34fd03818 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/ThreadedLoader.java @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2019 bartimaeusnek + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.material; + +import com.github.bartimaeusnek.bartworks.MainMod; +import cpw.mods.fml.common.FMLCommonHandler; + +import java.util.ArrayList; +import java.util.List; + +public class ThreadedLoader implements Runnable { + + List<Thread> threads = new ArrayList<>(); + List<Thread> threadsInit = new ArrayList<>(); + + + @Override + public synchronized void run() { + MainMod.LOGGER.warn("EXPERIMENTAL THREADED-LOADER ENABLED!"); + MainMod.LOGGER.info("Starting to register BartWorks Materials Recipes to Gregtech"); + threads.add(new AllRecipes()); + threads.forEach(Thread::start); + } + + public synchronized void runInit() { + MainMod.LOGGER.warn("EXPERIMENTAL THREADED-LOADER ENABLED!"); + MainMod.LOGGER.info("Starting the Material Generation Thread"); + threadsInit.add(new MaterialGen()); + threadsInit.forEach(Thread::start); + for (Thread thread : threadsInit) { + try { + MainMod.LOGGER.info("Trying to join the Material Generation Thread"); + thread.join(); + }catch (InterruptedException e){ + e.printStackTrace(); + FMLCommonHandler.instance().exitJava(500,true); + } + } + MainMod.LOGGER.info("Successfully joined the Material Generation Thread, Registering the Items/Blocks to the GameRegistry"); + if ((WerkstoffLoader.toGenerateGlobal & 0b1000) != 0) + WerkstoffLoader.INSTANCE.gameRegistryHandler(); + + } + + class AllRecipes extends Thread { + + public synchronized void run() { + WerkstoffLoader.INSTANCE.run(); + } + } + + class MaterialGen extends Thread { + public synchronized void run() { + WerkstoffLoader.INSTANCE.runInit(); + } + } + + + +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/Werkstoff.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/Werkstoff.java new file mode 100644 index 0000000000..c1bd80e0ea --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/Werkstoff.java @@ -0,0 +1,523 @@ +/* + * Copyright (c) 2019 bartimaeusnek + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.material; + +import com.github.bartimaeusnek.bartworks.util.BW_ColorUtil; +import com.github.bartimaeusnek.bartworks.util.MurmurHash3; +import com.github.bartimaeusnek.bartworks.util.Pair; +import gregtech.api.enums.*; +import gregtech.api.interfaces.IColorModulationContainer; +import gregtech.api.interfaces.ISubTagContainer; +import gregtech.api.util.GT_OreDictUnificator; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.Fluid; + +import java.nio.ByteBuffer; +import java.util.*; + +public class Werkstoff implements IColorModulationContainer, ISubTagContainer { + + static final LinkedHashSet<Werkstoff> werkstoffHashSet = new LinkedHashSet<>(); + public static final LinkedHashMap<Short, Werkstoff> werkstoffHashMap = new LinkedHashMap<>(); + private static final HashSet<Short> idHashSet = new HashSet<>(); + + private static final Werkstoff.Stats DEFAULT_NULL_STATS = new Werkstoff.Stats(); + private static final Werkstoff.GenerationFeatures DEFAULT_NULL_GENERATION_FEATURES = new Werkstoff.GenerationFeatures().disable(); + public static Werkstoff default_null_Werkstoff; + + private final List<ISubTagContainer> mOreByProducts = new ArrayList<ISubTagContainer>(); + private final LinkedHashSet<Pair<ISubTagContainer, Integer>> contents = new LinkedHashSet<>(); + HashSet<SubTag> subtags = new HashSet<>(); + private byte[] rgb = new byte[3]; + private final String defaultName; + private String toolTip; + private Fluid fluid; + private Fluid gas; + + private Werkstoff.Stats stats; + private final Werkstoff.Types type; + private final Werkstoff.GenerationFeatures generationFeatures; + private final short mID; + private final TextureSet texSet; + + public static void init(){ + Werkstoff.default_null_Werkstoff = new Werkstoff(new short[3], "_NULL", "Default null Werkstoff", Werkstoff.DEFAULT_NULL_STATS, Werkstoff.Types.UNDEFINED, Werkstoff.DEFAULT_NULL_GENERATION_FEATURES, -1, TextureSet.SET_NONE); + } + + public Werkstoff(short[] rgba, String defaultName, Werkstoff.Types type, Werkstoff.GenerationFeatures generationFeatures, int mID, TextureSet texSet, Pair<ISubTagContainer, Integer>... contents) { + this(rgba, defaultName, Werkstoff.Types.getDefaultStatForType(type), type, generationFeatures, mID, texSet, contents); + } + public Werkstoff(short[] rgba, String defaultName, Werkstoff.Types type, Werkstoff.GenerationFeatures generationFeatures, int mID, TextureSet texSet, List<ISubTagContainer> oreByProduct, Pair<ISubTagContainer, Integer>... contents) { + this(rgba, defaultName, Werkstoff.Types.getDefaultStatForType(type), type, generationFeatures, mID, texSet, oreByProduct, contents); + } + public Werkstoff(short[] rgba, String toolTip, String defaultName, Werkstoff.Types type, Werkstoff.GenerationFeatures generationFeatures, int mID, TextureSet texSet, List<ISubTagContainer> oreByProduct, Pair<ISubTagContainer, Integer>... contents) { + this(rgba, toolTip, defaultName, Werkstoff.Types.getDefaultStatForType(type), type, generationFeatures, mID, texSet, oreByProduct, contents); + } + + public Werkstoff(short[] rgba, String defaultName, Werkstoff.Stats stats, Werkstoff.Types type, Werkstoff.GenerationFeatures generationFeatures, int mID, TextureSet texSet, List<ISubTagContainer> oreByProduct, Pair<ISubTagContainer, Integer>... contents) { + this(rgba, defaultName, "", stats, type, generationFeatures, mID, texSet, contents); + this.mOreByProducts.addAll(oreByProduct); + } + + public Werkstoff(short[] rgba, String defaultName, Werkstoff.Stats stats, Werkstoff.Types type, Werkstoff.GenerationFeatures generationFeatures, int mID, TextureSet texSet, Pair<ISubTagContainer, Integer>... contents) { + this(rgba, defaultName, "", stats, type, generationFeatures, mID, texSet, contents); + } + + public Werkstoff(short[] rgba, String defaultName, String toolTip, Werkstoff.Stats stats, Werkstoff.Types type, Werkstoff.GenerationFeatures generationFeatures, int mID, TextureSet texSet, List<ISubTagContainer> oreByProduct, Pair<ISubTagContainer, Integer>... contents) { + this(rgba, defaultName, toolTip, stats, type, generationFeatures, mID, texSet, contents); + this.mOreByProducts.addAll(oreByProduct); + } + + public Werkstoff(short[] rgba, String defaultName, String toolTip, Werkstoff.Stats stats, Werkstoff.Types type, Werkstoff.GenerationFeatures generationFeatures, int mID, TextureSet texSet, Pair<ISubTagContainer, Integer>... contents) { + + if (Werkstoff.idHashSet.contains((short) mID)) + throw new UnsupportedOperationException("ID (" + mID + ") is already in use!"); + Werkstoff.idHashSet.add((short) mID); + if (type == null) + type = Werkstoff.Types.UNDEFINED; + + this.defaultName = defaultName; + + this.type = type; + this.mID = (short) mID; + this.generationFeatures = generationFeatures; + this.setRgb(BW_ColorUtil.correctCorlorArray(rgba)); + this.contents.addAll(Arrays.asList(contents)); + this.toolTip = ""; + if (toolTip.isEmpty()) { + for (Pair<ISubTagContainer, Integer> p : contents) { + if (p.getKey() instanceof Materials) { + this.toolTip += ((Materials) p.getKey()).mChemicalFormula + (p.getValue() > 1 ? p.getValue() : ""); + } + if (p.getKey() instanceof Werkstoff) + this.toolTip += ((Werkstoff) p.getKey()).toolTip + (p.getValue() > 1 ? p.getValue() : ""); + } + } else + this.toolTip = toolTip; + long tmpprotons = 0; + for (Pair<ISubTagContainer, Integer> p : contents) { + if (p.getKey() instanceof Materials) { + tmpprotons += ((Materials) p.getKey()).getProtons() * p.getValue(); + } else if (p.getKey() instanceof Werkstoff) { + tmpprotons += ((Werkstoff) p.getKey()).getStats().protons * p.getValue(); + } + } + this.stats = stats.setProtons(tmpprotons); + + long tmpmass = 0; + for (Pair<ISubTagContainer, Integer> p : contents) { + if (p.getKey() instanceof Materials) { + tmpmass += ((Materials) p.getKey()).getMass() * p.getValue(); + } else if (p.getKey() instanceof Werkstoff) { + tmpprotons += ((Werkstoff) p.getKey()).getStats().mass * p.getValue(); + } + } + this.stats = stats.setMass(tmpmass); + + this.texSet = texSet; + Werkstoff.werkstoffHashSet.add(this); + Werkstoff.werkstoffHashMap.put(this.mID, this); + } + + + public void setTCAspects(Pair<Object,Integer>... pAspectsArr){ + this.stats.mTC_Aspects=pAspectsArr; + } + + public Pair<Object,Integer>[] getTCAspects(int ratio){ + if (this.stats.mTC_Aspects == null) { + HashSet<TC_Aspects.TC_AspectStack> tc_aspectStacks = new HashSet<>(); + HashSet<Pair<Object, Integer>> set = new HashSet<>(); + for (Pair p : this.getContents().getValue()) { + if (p.getKey() instanceof Materials) + tc_aspectStacks.addAll(((Materials) p.getKey()).mAspects); + if (p.getKey() instanceof Werkstoff) + set.addAll(Arrays.asList(((Werkstoff) p.getKey()).getTCAspects())); + } + tc_aspectStacks.forEach(tc_aspectStack -> set.add(new Pair<Object, Integer>(tc_aspectStack.mAspect.mAspect, (int) tc_aspectStack.mAmount))); + this.stats.mTC_Aspects = set.toArray(new Pair[0]); + } + Pair<Object,Integer>[] ret = this.stats.mTC_Aspects.clone(); + for (int i = 0; i < ret.length; i++) { + ret[i]=ret[i].copyWithNewValue(ret[i].getValue() * ratio); + } + return ret; + } + + public Pair<Object,Integer>[] getTCAspects(){ + return getTCAspects(1); + } + + public Werkstoff.Types getType() { + return this.type; + } + + public Pair<Integer, LinkedHashSet<Pair<ISubTagContainer, Integer>>> getContents() { + int ret = 0; + switch (this.type) { + case COMPOUND: + case BIOLOGICAL: { + for (int i = 0; i < this.contents.toArray().length; i++) { + ret += ((Pair<ISubTagContainer, Integer>) this.contents.toArray()[i]).getValue(); + } + break; + } + default: + ret = 1; + break; + } + return new Pair<>(ret, this.contents); + } + + public int getNoOfByProducts() { + return this.mOreByProducts.size(); + } + + public ISubTagContainer getOreByProductRaw(int aNumber){ + if (this.mOreByProducts.size() == 0) + return null; + if (aNumber < 0) + aNumber = this.mOreByProducts.size() + aNumber; + while (aNumber >= this.mOreByProducts.size()) + aNumber--; + ISubTagContainer o = this.mOreByProducts.get(aNumber); + if (o == null || o.equals(Werkstoff.default_null_Werkstoff) || o.equals(Materials._NULL)) + return this; + return o; + } + + public ItemStack getOreByProduct(int aNumber, OrePrefixes prefixes) { + if (this.mOreByProducts.size() == 0) + return null; + if (aNumber < 0) + aNumber = this.mOreByProducts.size() + aNumber; + while (aNumber >= this.mOreByProducts.size()) + aNumber--; + Object o = this.mOreByProducts.get(aNumber); + if (o == null||o.equals(Werkstoff.default_null_Werkstoff) || o.equals(Materials._NULL)) + return this.get(prefixes); + if (o instanceof Werkstoff) + return WerkstoffLoader.getCorresopndingItemStack(prefixes, (Werkstoff) o); + if (o instanceof Materials) + return GT_OreDictUnificator.get(prefixes, o, 1L); + return null; + } + + public String getDefaultName() { + return this.defaultName; + } + + public String getToolTip() { + return this.toolTip; + } + + public Werkstoff.Stats getStats() { + return this.stats; + } + + public short getmID() { + return this.mID; + } + + public Werkstoff.GenerationFeatures getGenerationFeatures() { + return this.generationFeatures; + } + + public TextureSet getTexSet() { + return this.texSet; + } + + public void setRgb(short[] rgb) { + this.rgb = new byte[]{(byte) (rgb[0] - 128), (byte) (rgb[1] - 128), (byte) (rgb[2] - 128)}; + } + + @Override + public short[] getRGBA() { + return new short[]{(short) (this.rgb[0] + 128), (short) (this.rgb[1] + 128), (short) (this.rgb[2] + 128), 0}; + } + + @Override + public boolean contains(SubTag subTag) { + for (Pair<ISubTagContainer, Integer> p : this.contents) + if (p.getKey().contains(subTag)) + return true; + return this.subtags.contains(subTag); + } + + @Override + public ISubTagContainer add(SubTag... subTags) { + this.subtags.addAll(Arrays.asList(subTags)); + return this; + } + + @Override + public boolean remove(SubTag subTag) { + return this.subtags.remove(subTag); + } + + public void getAndAddToCollection(OrePrefixes prefixes,int amount,Collection<ItemStack> stacks){ + stacks.add(this.get(prefixes,amount)); + } + + public ItemStack get(OrePrefixes prefixes) { + return WerkstoffLoader.getCorresopndingItemStack(prefixes, this); + } + + public ItemStack get(OrePrefixes prefixes, int amount) { + return WerkstoffLoader.getCorresopndingItemStack(prefixes, this, amount); + } + + public enum Types { + MATERIAL, COMPOUND, MIXTURE, BIOLOGICAL, ELEMENT, UNDEFINED; + + public static Werkstoff.Stats getDefaultStatForType(Werkstoff.Types T) { + switch (T) { + case COMPOUND: + case BIOLOGICAL: + return new Werkstoff.Stats().setElektrolysis(true); + case MIXTURE: + return new Werkstoff.Stats().setCentrifuge(true); + default: + return new Werkstoff.Stats(); + } + } + } + + public static class GenerationFeatures { + //logic gate shit + /* + dust 1 + metal 10 + gem 100 + ore 1000 + */ + public byte toGenerate = 0b0001001; + public byte blacklist; + + /* + * Auto add Chemical Recipes 1 + * Auto add mixer Recipes 10 + * Auto add Sifter Recipe 100 + */ + public byte extraRecipes; + + public Werkstoff.GenerationFeatures setBlacklist(OrePrefixes p){ + if (p == OrePrefixes.dustTiny || p == OrePrefixes.dust || p == OrePrefixes.dustSmall || p == OrePrefixes.crateGtDust){ + this.blacklist |= 1; + }else + this.blacklist |= p.mMaterialGenerationBits; + return this; + } + + public boolean hasDusts() { + return (this.toGenerate & 0b1) != 0; + } + public boolean hasGems() { + return (this.toGenerate & 0b100) != 0; + } + public boolean hasOres() { + return (this.toGenerate & 0b1000) != 0; + } + + public Werkstoff.GenerationFeatures removeGems(){ + if (this.hasGems()) + this.toGenerate = (byte) (this.toGenerate ^ 0b100); + return this; + } + + public Werkstoff.GenerationFeatures removeDusts(){ + if (this.hasDusts()) + this.toGenerate = (byte) (this.toGenerate ^ 0b1); + return this; + } + public Werkstoff.GenerationFeatures removeOres(){ + if (this.hasOres()) + this.toGenerate = (byte) (this.toGenerate ^ 0b1000); + return this; + } + + public Werkstoff.GenerationFeatures addChemicalRecipes(){ + this.extraRecipes = (byte) (this.extraRecipes | 1); + return this; + } + public boolean hasChemicalRecipes() { + return (this.extraRecipes & 1) != 0; + } + + public Werkstoff.GenerationFeatures addSifterRecipes(){ + this.extraRecipes = (byte) (this.extraRecipes | 100); + return this; + } + public boolean hasSifterRecipes() { + return (this.extraRecipes & 100) != 0; + } + + public Werkstoff.GenerationFeatures onlyDust() { + this.toGenerate = (byte) (1); + return this; + } + + public Werkstoff.GenerationFeatures disable() { + this.toGenerate = (byte) (0); + return this; + } + + public Werkstoff.GenerationFeatures addGems() { + this.toGenerate = (byte) (this.toGenerate | 0x4); + return this; + } + + + } + + public static class Stats { + + int boilingPoint; + int meltingPoint; + long protons; + long neutrons; + long electrons; + long mass; + private Pair<Object,Integer>[] mTC_Aspects; + //logic gate shit + byte quality = ~0b111111; + + public Stats setmTC_AspectsArray(Pair<Object, Integer>[] mTC_Aspects) { + this.mTC_Aspects = mTC_Aspects; + return this; + } + + public Stats setmTC_AspectsVarArg(Pair<Object, Integer>... mTC_Aspects) { + this.mTC_Aspects = mTC_Aspects; + return this; + } + + Pair<Object, Integer>[] getmTC_Aspects() { + return this.mTC_Aspects; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof Werkstoff.Stats)) return false; + + Werkstoff.Stats that = (Werkstoff.Stats) o; + + if (this.boilingPoint != that.boilingPoint) return false; + if (this.meltingPoint != that.meltingPoint) return false; + if (this.mass != that.mass) return false; + if (this.protons != that.protons) return false; + if (this.neutrons != that.neutrons) return false; + if (this.electrons != that.electrons) return false; + return this.quality == that.quality; + } + + @Override + public int hashCode() { + return MurmurHash3.murmurhash3_x86_32(ByteBuffer.allocate(49).put(this.quality).putInt(this.boilingPoint).putInt(this.meltingPoint).putLong(this.protons).putLong(this.neutrons).putLong(this.electrons).putLong(this.mass).array(), 0, 49, 31); + } + + public Werkstoff.Stats setMass(long mass) { + this.mass = this.protons; + return this; + } + + public Werkstoff.Stats setProtons(long protons) { + this.protons = protons; + return this; + } + + public boolean isSublimation() { + return (this.quality & 0b1) == 0b1; + } + + public Werkstoff.Stats setSublimation(boolean sublimation) { + if (sublimation) + this.quality = (byte) (this.quality | 0b000001); + else + this.quality = (byte) (this.quality & 0b111110); + return this; + } + + public boolean isToxic() { + return (this.quality >> 1 & 0b1) == 0b1; + } + + public Werkstoff.Stats setToxic(boolean toxic) { + if (toxic) + this.quality = (byte) (this.quality | 0b000010); + else + this.quality = (byte) (this.quality & 0b111101); + return this; + } + + public boolean isRadioactive() { + return (this.quality >> 2 & 0b1) == 0b1; + } + + public Werkstoff.Stats setRadioactive(boolean radioactive) { + if (radioactive) + this.quality = (byte) (this.quality | 0b000100); + else + this.quality = (byte) (this.quality & 0b111011); + return this; + } + + public boolean isBlastFurnace() { + return (this.quality >> 3 & 0b1) == 0b1; + } + + public Werkstoff.Stats setBlastFurnace(boolean blastFurnace) { + if (blastFurnace) + this.quality = (byte) (this.quality | 0b001000); + else + this.quality = (byte) (this.quality & 0b110111); + return this; + } + + public boolean isElektrolysis() { + return (this.quality >> 4 & 0b1) == 0b1; + } + + public Werkstoff.Stats setElektrolysis(boolean elektrolysis) { + if (elektrolysis) + this.quality = (byte) (this.quality | 0b010000); + else + this.quality = (byte) (this.quality & 0b101111); + return this; + } + + public boolean isCentrifuge() { + return (this.quality >> 5 & 0b1) == 0b1; + } + + public Werkstoff.Stats setCentrifuge(boolean centrifuge) { + if (centrifuge) + this.quality = (byte) (this.quality | 0b100000); + else + this.quality = (byte) (this.quality & 0b011111); + return this; + } + } + +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/WerkstoffLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/WerkstoffLoader.java new file mode 100644 index 0000000000..1a805cd8d0 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/WerkstoffLoader.java @@ -0,0 +1,809 @@ +/* + * Copyright (c) 2019 bartimaeusnek + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.material; + +import com.github.bartimaeusnek.bartworks.API.WerkstoffAdderRegistry; +import com.github.bartimaeusnek.bartworks.MainMod; +import com.github.bartimaeusnek.bartworks.client.renderer.BW_Renderer_Block_Ores; +import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; +import com.github.bartimaeusnek.bartworks.system.log.DebugLog; +import com.github.bartimaeusnek.bartworks.system.material.processingLoaders.AdditionalRecipes; +import com.github.bartimaeusnek.bartworks.util.BW_ColorUtil; +import com.github.bartimaeusnek.bartworks.util.Pair; +import com.github.bartimaeusnek.crossmod.thaumcraft.util.ThaumcraftHandler; +import cpw.mods.fml.client.registry.RenderingRegistry; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.ProgressManager; +import cpw.mods.fml.common.registry.GameRegistry; +import gregtech.GT_Mod; +import gregtech.api.GregTech_API; +import gregtech.api.enums.*; +import gregtech.api.interfaces.ISubTagContainer; +import gregtech.api.objects.GT_MultiTexture; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Recipe; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.oredict.OreDictionary; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; + +import static gregtech.api.enums.OrePrefixes.*; + +public class WerkstoffLoader implements Runnable { + + private WerkstoffLoader() {} + + public static final WerkstoffLoader INSTANCE = new WerkstoffLoader(); + + //TODO: FREE ID RANGE: 19-32766 + + public static final Werkstoff Bismutite = new Werkstoff( + new short[]{255, 233, 0, 0}, + "Bismutite", + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().addGems(), + 1, + TextureSet.SET_FLINT, + Arrays.asList(Materials.Bismuth), + new Pair<ISubTagContainer, Integer>(Materials.Bismuth, 2), + new Pair<ISubTagContainer, Integer>(Materials.Oxygen, 2), + new Pair<ISubTagContainer, Integer>(Materials.CarbonDioxide, 2) + ); + public static final Werkstoff Bismuthinit = new Werkstoff( + new short[]{192, 192, 192, 0}, + "Bismuthinite", + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures(), + 2, + TextureSet.SET_METALLIC, + Arrays.asList(Materials.Bismuth, Materials.Sulfur), + new Pair<ISubTagContainer, Integer>(Materials.Bismuth, 2), + new Pair<ISubTagContainer, Integer>(Materials.Sulfur, 3) + ); + public static final Werkstoff Zirconium = new Werkstoff( + new short[]{175, 175, 175, 0}, + "Zirconium", + "Zr", + new Werkstoff.Stats().setProtons(40), + Werkstoff.Types.ELEMENT, + new Werkstoff.GenerationFeatures().onlyDust(), + 3, + TextureSet.SET_METALLIC, + Arrays.asList() + ); + public static final Werkstoff Zirconia = new Werkstoff( + new short[]{255, 255, 255, 0}, + "Cubic Zirconia", + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().onlyDust().addGems(), + 4, + TextureSet.SET_DIAMOND, + Arrays.asList(Zirconium), + new Pair<ISubTagContainer, Integer>(Zirconium, 1), + new Pair<ISubTagContainer, Integer>(Materials.Oxygen, 2) + ); + public static final Werkstoff FluorBuergerit = new Werkstoff( + new short[]{0x20, 0x20, 0x20, 0}, + "Fluor-Buergerite", + "NaFe3Al6(Si6O18)(BO3)3O3F", + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().addGems(), + 5, + TextureSet.SET_RUBY, + Arrays.asList(Materials.Sodium, Materials.Boron, Materials.Silicon), + new Pair<ISubTagContainer, Integer>(Materials.Sodium, 1), + new Pair<ISubTagContainer, Integer>(Materials.Iron, 3), + new Pair<ISubTagContainer, Integer>(Materials.Aluminium, 6), + new Pair<ISubTagContainer, Integer>(Materials.Silicon, 6), + new Pair<ISubTagContainer, Integer>(Materials.Boron, 3), + new Pair<ISubTagContainer, Integer>(Materials.Oxygen, 30), + new Pair<ISubTagContainer, Integer>(Materials.Fluorine, 1) + ); + public static final Werkstoff YttriumOxide = new Werkstoff( + new short[]{255,255,255,0}, + "Yttrium Oxide", + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().onlyDust(), //No autoadd here to gate this material by hand + 6, + TextureSet.SET_DULL, + new Pair<ISubTagContainer, Integer>(Materials.Yttrium, 2), + new Pair<ISubTagContainer, Integer>(Materials.Oxygen, 3) + ); + public static final Werkstoff ChromoAluminoPovondrait = new Werkstoff( + new short[]{0, 0x79, 0x6A, 0}, + "Chromo-Alumino-Povondraite", + "NaCr3(Al4Mg2)(Si6O18)(BO3)3(OH)3O", + Werkstoff.Types.getDefaultStatForType(Werkstoff.Types.COMPOUND), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().addGems(), + 7, + TextureSet.SET_RUBY, + Arrays.asList(Materials.Sodium, Materials.Boron, Materials.Silicon), + new Pair<ISubTagContainer, Integer>(Materials.Sodium, 1), + new Pair<ISubTagContainer, Integer>(Materials.Chrome, 3), + new Pair<ISubTagContainer, Integer>(Materials.Magnalium, 6), + new Pair<ISubTagContainer, Integer>(Materials.Silicon, 6), + new Pair<ISubTagContainer, Integer>(Materials.Boron, 3), + new Pair<ISubTagContainer, Integer>(Materials.Oxygen, 31), + new Pair<ISubTagContainer, Integer>(Materials.Hydrogen, 3) + ); + public static final Werkstoff VanadioOxyDravit = new Werkstoff( + new short[]{0x60, 0xA0, 0xA0, 0}, + "Vanadio-Oxy-Dravite", + "NaV3(Al4Mg2)(Si6O18)(BO3)3(OH)3O", + Werkstoff.Types.getDefaultStatForType(Werkstoff.Types.COMPOUND), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().addGems(), + 8, + TextureSet.SET_RUBY, + Arrays.asList(Materials.Sodium, Materials.Boron, Materials.Silicon), + new Pair<ISubTagContainer, Integer>(Materials.Sodium, 1), + new Pair<ISubTagContainer, Integer>(Materials.Vanadium, 3), + new Pair<ISubTagContainer, Integer>(Materials.Magnalium, 6), + new Pair<ISubTagContainer, Integer>(Materials.Silicon, 6), + new Pair<ISubTagContainer, Integer>(Materials.Boron, 3), + new Pair<ISubTagContainer, Integer>(Materials.Oxygen, 31), + new Pair<ISubTagContainer, Integer>(Materials.Hydrogen, 3) + ); + public static final Werkstoff Olenit = new Werkstoff( + new short[]{210, 210, 210, 0}, + "Olenite", + "NaAl3Al6(Si6O18)(BO3)3O3OH", + Werkstoff.Types.getDefaultStatForType(Werkstoff.Types.COMPOUND), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().addGems(), + 9, + TextureSet.SET_RUBY, + Arrays.asList(Materials.Sodium, Materials.Boron, Materials.Silicon), + new Pair<ISubTagContainer, Integer>(Materials.Sodium, 1), + new Pair<ISubTagContainer, Integer>(Materials.Aluminium, 9), + new Pair<ISubTagContainer, Integer>(Materials.Silicon, 6), + new Pair<ISubTagContainer, Integer>(Materials.Boron, 3), + new Pair<ISubTagContainer, Integer>(Materials.Oxygen, 31), + new Pair<ISubTagContainer, Integer>(Materials.Hydrogen, 1) + ); + public static final Werkstoff Arsenopyrite = new Werkstoff( + new short[]{0xB0, 0xB0, 0xB0, 0}, + "Arsenopyrite", + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures(), + 10, + TextureSet.SET_METALLIC, + Arrays.asList(Materials.Sulfur, Materials.Arsenic, Materials.Iron), + new Pair<ISubTagContainer, Integer>(Materials.Iron, 1), + new Pair<ISubTagContainer, Integer>(Materials.Arsenic, 1), + new Pair<ISubTagContainer, Integer>(Materials.Sulfur, 1) + ); + public static final Werkstoff Ferberite = new Werkstoff( + new short[]{0xB0, 0xB0, 0xB0, 0}, + "Ferberite", + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures(), + 11, + TextureSet.SET_METALLIC, + Arrays.asList(Materials.Iron, Materials.Tungsten), + new Pair<ISubTagContainer, Integer>(Materials.Iron, 1), + new Pair<ISubTagContainer, Integer>(Materials.Tungsten, 1), + new Pair<ISubTagContainer, Integer>(Materials.Oxygen, 3) + ); + public static final Werkstoff Loellingit = new Werkstoff( + new short[]{0xD0, 0xD0, 0xD0, 0}, + "Loellingite", + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures(), + 12, + TextureSet.SET_METALLIC, + Arrays.asList(Materials.Iron, Materials.Arsenic), + new Pair<ISubTagContainer, Integer>(Materials.Iron, 1), + new Pair<ISubTagContainer, Integer>(Materials.Arsenic, 2) + ); + public static final Werkstoff Roquesit = new Werkstoff( + new short[]{0xA0, 0xA0, 0xA0, 0}, + "Roquesite", + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures(), + 13, + TextureSet.SET_METALLIC, + Arrays.asList(Materials.Copper, Materials.Sulfur), + new Pair<ISubTagContainer, Integer>(Materials.Copper, 1), + new Pair<ISubTagContainer, Integer>(Materials.Indium, 1), + new Pair<ISubTagContainer, Integer>(Materials.Sulfur, 2) + ); + public static final Werkstoff Bornite = new Werkstoff( + new short[]{0x97, 0x66, 0x2B, 0}, + "Bornite", + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures(), + 14, + TextureSet.SET_METALLIC, + Arrays.asList(Materials.Copper, Materials.Iron, Materials.Sulfur), + new Pair<ISubTagContainer, Integer>(Materials.Copper, 5), + new Pair<ISubTagContainer, Integer>(Materials.Iron, 1), + new Pair<ISubTagContainer, Integer>(Materials.Sulfur, 4) + ); + public static final Werkstoff Wittichenit = new Werkstoff( + Materials.Copper.mRGBa, + "Wittichenite", + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures(), + 15, + TextureSet.SET_METALLIC, + Arrays.asList(Materials.Copper, Materials.Bismuth, Materials.Sulfur), + new Pair<ISubTagContainer, Integer>(Materials.Copper, 5), + new Pair<ISubTagContainer, Integer>(Materials.Bismuth, 1), + new Pair<ISubTagContainer, Integer>(Materials.Sulfur, 4) + ); + public static final Werkstoff Djurleit = new Werkstoff( + new short[]{0x60, 0x60, 0x60, 0}, + "Djurleite", + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures(), + 16, + TextureSet.SET_METALLIC, + Arrays.asList(Materials.Copper, Materials.Copper, Materials.Sulfur), + new Pair<ISubTagContainer, Integer>(Materials.Copper, 31), + new Pair<ISubTagContainer, Integer>(Materials.Sulfur, 16) + ); + public static final Werkstoff Huebnerit = new Werkstoff( + new short[]{0x80, 0x60, 0x60, 0}, + "Huebnerite", + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures(), + 17, + TextureSet.SET_METALLIC, + Arrays.asList(Materials.Manganese, Materials.Tungsten), + new Pair<ISubTagContainer, Integer>(Materials.Manganese, 1), + new Pair<ISubTagContainer, Integer>(Materials.Tungsten, 1), + new Pair<ISubTagContainer, Integer>(Materials.Oxygen, 3) + ); + public static final Werkstoff Thorianit = new Werkstoff( + new short[]{0x30, 0x30, 0x30, 0}, + "Thorianite", + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().addChemicalRecipes(), + 18, + TextureSet.SET_METALLIC, + Arrays.asList(Materials.Thorium), + new Pair<ISubTagContainer, Integer>(Materials.Thorium, 1), + new Pair<ISubTagContainer, Integer>(Materials.Oxygen, 2) + ); + public static final Werkstoff RedZircon = new Werkstoff( + new short[]{195, 19, 19, 0}, + "Red Zircon", + new Werkstoff.Stats().setElektrolysis(true), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().addGems(), + 19, + TextureSet.SET_GEM_VERTICAL, + Arrays.asList(Zirconium,Materials.Silicon), + new Pair<ISubTagContainer, Integer>(Zirconium, 1), + new Pair<ISubTagContainer, Integer>(Materials.Silicon, 1), + new Pair<ISubTagContainer, Integer>(Materials.Oxygen, 4) + ); + + //GT Enhancements + public static final Werkstoff Salt = new Werkstoff( + Materials.Salt.mRGBa, + "Salt", + new Werkstoff.Stats(), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().disable().addGems().addSifterRecipes(), + 20, + TextureSet.SET_FLINT, + Arrays.asList(Materials.RockSalt,Materials.Borax), + new Pair<ISubTagContainer, Integer>(Materials.Salt, 1) + ); + public static final Werkstoff Spodumen = new Werkstoff( + Materials.Spodumene.mRGBa, + "Spodumene", + new Werkstoff.Stats(), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().disable().addGems().addSifterRecipes(), + 21, + TextureSet.SET_FLINT, + Arrays.asList(Materials.Spodumene), + new Pair<ISubTagContainer, Integer>(Materials.Spodumene, 1) + ); + public static final Werkstoff RockSalt = new Werkstoff( + Materials.RockSalt.mRGBa, + "Rock Salt", + new Werkstoff.Stats(), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().disable().addGems().addSifterRecipes(), + 22, + TextureSet.SET_FLINT, + Arrays.asList(Materials.RockSalt,Materials.Borax), + new Pair<ISubTagContainer, Integer>(Materials.RockSalt, 1) + ); + public static final Werkstoff Fayalit = new Werkstoff( + new short[]{50,50,50,0}, + "Fayalite", + new Werkstoff.Stats().setElektrolysis(true), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().addGems(), + 23, + TextureSet.SET_QUARTZ, + Arrays.asList(Materials.Iron,Materials.Silicon), + new Pair<ISubTagContainer, Integer>(Materials.Iron, 2), + new Pair<ISubTagContainer, Integer>(Materials.Silicon, 1), + new Pair<ISubTagContainer, Integer>(Materials.Oxygen, 4) + ); + public static final Werkstoff Forsterit = new Werkstoff( + new short[]{255,255,255,0}, + "Forsterite", + new Werkstoff.Stats().setElektrolysis(true), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().addGems(), + 24, + TextureSet.SET_QUARTZ, + Arrays.asList(Materials.Magnesium,Materials.Silicon), + new Pair<ISubTagContainer, Integer>(Materials.Magnesium, 2), + new Pair<ISubTagContainer, Integer>(Materials.Silicon, 1), + new Pair<ISubTagContainer, Integer>(Materials.Oxygen, 4) + ); + public static final Werkstoff Hedenbergit = new Werkstoff( + new short[]{100,150,100,0}, + "Hedenbergite", + new Werkstoff.Stats().setElektrolysis(true), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().addGems(), + 25, + TextureSet.SET_QUARTZ, + Arrays.asList(Materials.Iron,Materials.Calcium,Materials.Silicon), + new Pair<ISubTagContainer, Integer>(Materials.Calcium, 1), + new Pair<ISubTagContainer, Integer>(Materials.Iron, 1), + new Pair<ISubTagContainer, Integer>(Materials.Silicon, 2), + new Pair<ISubTagContainer, Integer>(Materials.Oxygen, 6) + ); + public static final Werkstoff DescloiziteZNVO4 = new Werkstoff( + new short[]{0xBF,0x18,0x0F,0}, + "Red Descloizite",//Pb(Zn,Cu)[OH|VO4 + new Werkstoff.Stats().setElektrolysis(true), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures(), + 26, + TextureSet.SET_QUARTZ, + Arrays.asList(Materials.Lead,Materials.Copper,Materials.Vanadium), + new Pair<ISubTagContainer, Integer>(Materials.Lead, 1), + new Pair<ISubTagContainer, Integer>(Materials.Zinc, 1), + new Pair<ISubTagContainer, Integer>(Materials.Vanadium, 1), + new Pair<ISubTagContainer, Integer>(Materials.Oxygen, 4) + ); + public static final Werkstoff DescloiziteCUVO4 = new Werkstoff( + new short[]{0xf9,0x6d,0x18,0}, + "Orange Descolizite",//Pb(Zn,Cu)[OH|VO4 + new Werkstoff.Stats().setElektrolysis(true), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures(), + 27, + TextureSet.SET_QUARTZ, + Arrays.asList(Materials.Lead,Materials.Zinc,Materials.Vanadium), + new Pair<ISubTagContainer, Integer>(Materials.Lead, 1), + new Pair<ISubTagContainer, Integer>(Materials.Copper, 1), + new Pair<ISubTagContainer, Integer>(Materials.Vanadium, 1), + new Pair<ISubTagContainer, Integer>(Materials.Oxygen, 4) + ); + public static final Werkstoff FuchsitAL = new Werkstoff( + new short[]{0x4D,0x7F,0x64,0}, + "Green Fuchsite", + "KAl3Si3O10(OH)2", + new Werkstoff.Stats().setElektrolysis(true), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures(), + 28, + TextureSet.SET_METALLIC, + Arrays.asList(Materials.Potassium,Materials.Aluminium,Materials.Silicon), + new Pair<ISubTagContainer, Integer>(Materials.Potassium, 1), + new Pair<ISubTagContainer, Integer>(Materials.Aluminium, 3), + new Pair<ISubTagContainer, Integer>(Materials.Silicon, 3), + new Pair<ISubTagContainer, Integer>(Materials.Oxygen, 12), + new Pair<ISubTagContainer, Integer>(Materials.Hydrogen, 2) + + ); + public static final Werkstoff FuchsitCR = new Werkstoff( + new short[]{128,0,0,0}, + "Red Fuchsite", + "KCr3Si3O10(OH)2", + new Werkstoff.Stats().setElektrolysis(true), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures(), + 29, + TextureSet.SET_METALLIC, + Arrays.asList(Materials.Potassium,Materials.Chrome,Materials.Silicon), + new Pair<ISubTagContainer, Integer>(Materials.Potassium, 1), + new Pair<ISubTagContainer, Integer>(Materials.Chrome, 3), + new Pair<ISubTagContainer, Integer>(Materials.Silicon, 3), + new Pair<ISubTagContainer, Integer>(Materials.Oxygen, 12), + new Pair<ISubTagContainer, Integer>(Materials.Hydrogen, 2) + + ); + + public static HashMap<OrePrefixes, BW_MetaGenerated_Items> items = new HashMap<>(); + public static Block BWOres; + public boolean registered; + + public static ItemStack getCorresopndingItemStack(OrePrefixes orePrefixes, Werkstoff werkstoff) { + return WerkstoffLoader.getCorresopndingItemStack(orePrefixes, werkstoff, 1); + } + + public static ItemStack getCorresopndingItemStack(OrePrefixes orePrefixes, Werkstoff werkstoff, int amount) { + ItemStack ret = OreDictHandler.getItemStack(werkstoff.getDefaultName(),orePrefixes,amount); + if (ret != null) + return ret; + if (orePrefixes == ore) + return new ItemStack(WerkstoffLoader.BWOres, amount, werkstoff.getmID()); + return new ItemStack(WerkstoffLoader.items.get(orePrefixes), amount, werkstoff.getmID()).copy(); + } + + public void init() { + if (WerkstoffLoader.INSTANCE == null) + MainMod.LOGGER.error("INSTANCE IS NULL THIS SHOULD NEVER HAPPEN!"); + } + + public void runInit() { + MainMod.LOGGER.info("Making Meta Items for BW Materials"); + long timepre = System.nanoTime(); + WerkstoffAdderRegistry.getINSTANCE().run(); + this.addSubTags(); + this.addItemsForGeneration(); + this.runAdditionalOreDict(); + long timepost = System.nanoTime(); + MainMod.LOGGER.info("Making Meta Items for BW Materials took " + (timepost - timepre) + "ns/" + ((timepost - timepre) / 1000000) + "ms/" + ((timepost - timepre) / 1000000000) + "s!"); + } + + @Override + public void run() { + if (!this.registered) { + MainMod.LOGGER.info("Loading Processing Recipes for BW Materials"); + long timepre = System.nanoTime(); + ProgressManager.ProgressBar progressBar = ProgressManager.push("Register BW Materials", Werkstoff.werkstoffHashMap.size()+1); + DebugLog.log("Loading Recipes"+(System.nanoTime()-timepre)); + for (short i = 0; i < Werkstoff.werkstoffHashMap.size(); i++) { + long timepreone = System.nanoTime(); + Werkstoff werkstoff = Werkstoff.werkstoffHashMap.get(i); + DebugLog.log("Werkstoff is null or id < 0 ? "+ (werkstoff==null || werkstoff.getmID() < 0) + " " + (System.nanoTime()-timepreone)); + if (werkstoff == null || werkstoff.getmID() < 0) { + progressBar.step(""); + continue; + } + DebugLog.log("Werkstoff: "+ werkstoff.getDefaultName() +" " +(System.nanoTime()-timepreone)); + DebugLog.log("Loading Dusts Recipes"+" " +(System.nanoTime()-timepreone)); + this.addDustRecipes(werkstoff); + DebugLog.log("Loading Gem Recipes"+" " +(System.nanoTime()-timepreone)); + this.addGemRecipes(werkstoff); + DebugLog.log("Loading Ore Recipes"+" " +(System.nanoTime()-timepreone)); + this.addOreRecipes(werkstoff); + DebugLog.log("Loading Crushed Recipes"+" " +(System.nanoTime()-timepreone)); + this.addCrushedRecipes(werkstoff); + if (Loader.isModLoaded("Thaumcraft")) { + DebugLog.log("Loading Aspects"+" " +(System.nanoTime()-timepreone)); + ThaumcraftHandler.AspectAdder.addAspectToAll(werkstoff); + } + DebugLog.log("Done"+" " +(System.nanoTime()-timepreone)); + progressBar.step(werkstoff.getDefaultName()); + } + progressBar.step("Load Additional Recipes"); + new AdditionalRecipes().run(); + ProgressManager.pop(progressBar); + long timepost = System.nanoTime(); + MainMod.LOGGER.info("Loading Processing Recipes for BW Materials took " + (timepost - timepre) + "ns/" + ((timepost - timepre) / 1000000) + "ms/" + ((timepost - timepre) / 1000000000) + "s!"); + this.registered = true; + } + } + + private void addSubTags() { + for (Werkstoff W : Werkstoff.werkstoffHashMap.values()) { + for (Pair<ISubTagContainer, Integer> pair : W.getContents().getValue().toArray(new Pair[0])) { + + if (pair.getKey() instanceof Materials && pair.getKey() == Materials.Neodymium) { + W.add(SubTag.ELECTROMAGNETIC_SEPERATION_NEODYMIUM); + break; + } else if (pair.getKey() instanceof Materials && pair.getKey() == Materials.Iron) { + W.add(SubTag.ELECTROMAGNETIC_SEPERATION_IRON); + break; + } else if (pair.getKey() instanceof Materials && pair.getKey() == Materials.Gold) { + W.add(SubTag.ELECTROMAGNETIC_SEPERATION_GOLD); + break; + } + } + if (W.getGenerationFeatures().hasGems()) { + W.add(SubTag.CRYSTAL); + W.add(SubTag.CRYSTALLISABLE); + } + } + } + + public static int toGenerateGlobal = 0b0000000; + private void addItemsForGeneration() { + for (Werkstoff werkstoff : Werkstoff.werkstoffHashSet) { + for (OrePrefixes p : values()) + if ((werkstoff.getGenerationFeatures().toGenerate & p.mMaterialGenerationBits) != 0 && OreDictHandler.getItemStack(werkstoff.getDefaultName(),p,1) != null) { + MainMod.LOGGER.info("Found: "+(p+werkstoff.getDefaultName().replaceAll(" ",""))+" in oreDict, disable and reroute my Items to that, also add a Tooltip."); + werkstoff.getGenerationFeatures().setBlacklist(p); + } + toGenerateGlobal = (toGenerateGlobal | werkstoff.getGenerationFeatures().toGenerate); + } + + if ((toGenerateGlobal & 0b1) != 0) { + WerkstoffLoader.items.put(dust, new BW_MetaGenerated_Items(dust)); + WerkstoffLoader.items.put(dustTiny, new BW_MetaGenerated_Items(dustTiny)); + WerkstoffLoader.items.put(dustSmall, new BW_MetaGenerated_Items(dustSmall)); + } + if ((toGenerateGlobal & 0b10) != 0) { + WerkstoffLoader.items.put(ingot, new BW_MetaGenerated_Items(ingot)); + + } + if ((toGenerateGlobal & 0b100) != 0) { + WerkstoffLoader.items.put(gem, new BW_MetaGenerated_Items(gem)); + WerkstoffLoader.items.put(gemChipped, new BW_MetaGenerated_Items(gemChipped)); + WerkstoffLoader.items.put(gemExquisite, new BW_MetaGenerated_Items(gemExquisite)); + WerkstoffLoader.items.put(gemFlawed, new BW_MetaGenerated_Items(gemFlawed)); + WerkstoffLoader.items.put(gemFlawless, new BW_MetaGenerated_Items(gemFlawless)); + WerkstoffLoader.items.put(lens,new BW_MetaGenerated_Items(lens)); + } + if ((toGenerateGlobal & 0b1000) != 0) { + if (!ConfigHandler.experimentalThreadedLoader) + gameRegistryHandler(); + WerkstoffLoader.items.put(crushed, new BW_MetaGenerated_Items(crushed)); + WerkstoffLoader.items.put(crushedPurified, new BW_MetaGenerated_Items(crushedPurified)); + WerkstoffLoader.items.put(crushedCentrifuged, new BW_MetaGenerated_Items(crushedCentrifuged)); + WerkstoffLoader.items.put(dustPure, new BW_MetaGenerated_Items(dustPure)); + WerkstoffLoader.items.put(dustImpure, new BW_MetaGenerated_Items(dustImpure)); + } + } + + public void gameRegistryHandler(){ + if (FMLCommonHandler.instance().getSide().isClient()) + RenderingRegistry.registerBlockHandler(BW_Renderer_Block_Ores.INSTANCE); + GameRegistry.registerTileEntity(BW_MetaGeneratedOreTE.class, "bw.blockoresTE"); + WerkstoffLoader.BWOres = new BW_MetaGenerated_Ores(Material.rock, BW_MetaGeneratedOreTE.class, "bw.blockores"); + GameRegistry.registerBlock(WerkstoffLoader.BWOres, BW_MetaGeneratedOre_Item.class, "bw.blockores.01"); + } + + private void runAdditionalOreDict(){ + for (Werkstoff werkstoff : Werkstoff.werkstoffHashSet) { + if (werkstoff.getGenerationFeatures().hasOres()) + GT_OreDictUnificator.registerOre(ore + werkstoff.getDefaultName().replaceAll(" ",""), werkstoff.get(ore)); + if (werkstoff.getGenerationFeatures().hasGems()) + OreDictionary.registerOre("craftingLens" + BW_ColorUtil.getDyeFromColor(werkstoff.getRGBA()).mName.replace(" ", ""), werkstoff.get(lens)); + } + + GT_OreDictUnificator.registerOre("craftingIndustrialDiamond", WerkstoffLoader.Zirconia.get(gemExquisite)); + } + + private void addGemRecipes(Werkstoff werkstoff) { + if (werkstoff.getGenerationFeatures().hasGems()) { + if (werkstoff.getGenerationFeatures().hasSifterRecipes() || ((werkstoff.getGenerationFeatures().toGenerate & 0b1000) != 0 && (werkstoff.getGenerationFeatures().toGenerate & 0b1) != 0)) { + GT_Values.RA.addSifterRecipe( + WerkstoffLoader.getCorresopndingItemStack(crushedPurified, werkstoff), + new ItemStack[]{ + WerkstoffLoader.getCorresopndingItemStack(gemExquisite, werkstoff), + WerkstoffLoader.getCorresopndingItemStack(gemFlawless, werkstoff), + WerkstoffLoader.getCorresopndingItemStack(gem, werkstoff), + WerkstoffLoader.getCorresopndingItemStack(gemFlawed, werkstoff), + WerkstoffLoader.getCorresopndingItemStack(gemChipped, werkstoff), + WerkstoffLoader.getCorresopndingItemStack(dust, werkstoff) + }, + new int[]{ + 100, 400, 1500, 2000, 4000, 5000 + }, + 800, + 16 + ); + } + GT_ModHandler.addPulverisationRecipe(werkstoff.get(gemExquisite), werkstoff.get(dust, 4)); + GT_ModHandler.addPulverisationRecipe(werkstoff.get(gemFlawless), werkstoff.get(dust, 2)); + GT_ModHandler.addPulverisationRecipe(werkstoff.get(gem), werkstoff.get(dust)); + GT_ModHandler.addPulverisationRecipe(werkstoff.get(gemFlawed), werkstoff.get(dustSmall, 1)); + GT_ModHandler.addPulverisationRecipe(werkstoff.get(gemChipped), werkstoff.get(dustTiny)); + + GT_ModHandler.addCraftingRecipe(werkstoff.get(gemFlawless,2),0,new Object[]{"h ", "W ",'W',werkstoff.get(gemExquisite)}); + GT_ModHandler.addCraftingRecipe(werkstoff.get(gem, 2),0,new Object[]{"h ", "W ",'W',werkstoff.get(gemFlawless)}); + GT_ModHandler.addCraftingRecipe(werkstoff.get(gemFlawed, 2),0,new Object[]{"h ", "W ",'W',werkstoff.get(gem)}); + GT_ModHandler.addCraftingRecipe(werkstoff.get(gemChipped, 2),0,new Object[]{"h ", "W ",'W',werkstoff.get(gemFlawed)}); + + GT_Values.RA.addForgeHammerRecipe(werkstoff.get(gemExquisite), werkstoff.get(gemFlawless, 2), 64, 16); + GT_Values.RA.addForgeHammerRecipe(werkstoff.get(gemFlawless), werkstoff.get(gem, 2), 64, 16); + GT_Values.RA.addForgeHammerRecipe(werkstoff.get(gem), werkstoff.get(gemFlawed, 2), 64, 16); + GT_Values.RA.addForgeHammerRecipe(werkstoff.get(gemFlawed), werkstoff.get(gemChipped, 2), 64, 16); + GT_Values.RA.addForgeHammerRecipe(werkstoff.get(gemChipped), werkstoff.get(dustTiny), 64, 16); + + GT_Values.RA.addImplosionRecipe(werkstoff.get(gemFlawless, 3), 8, werkstoff.get(gemExquisite), GT_OreDictUnificator.get(dustTiny, Materials.DarkAsh, 2)); + GT_Values.RA.addImplosionRecipe(werkstoff.get(gem, 3), 8, werkstoff.get(gemFlawless), GT_OreDictUnificator.get(dustTiny, Materials.DarkAsh, 2)); + GT_Values.RA.addImplosionRecipe(werkstoff.get(gemFlawed, 3), 8, werkstoff.get(gem), GT_OreDictUnificator.get(dustTiny, Materials.DarkAsh, 2)); + GT_Values.RA.addImplosionRecipe(werkstoff.get(gemChipped, 3), 8, werkstoff.get(gemFlawed), GT_OreDictUnificator.get(dustTiny, Materials.DarkAsh, 2)); + + GT_Values.RA.addImplosionRecipe(werkstoff.get(dust, 4), 24, werkstoff.get(gem, 3), GT_OreDictUnificator.get(dustTiny, Materials.DarkAsh, 8)); + + if ((werkstoff.getGenerationFeatures().toGenerate & 2) != 0){ + GT_Values.RA.addLatheRecipe(werkstoff.get(plate),werkstoff.get(lens),werkstoff.get(dustSmall), 1200, 120); + } + GT_Values.RA.addLatheRecipe(werkstoff.get(gemExquisite),werkstoff.get(lens),werkstoff.get(dust,2), 2400, 30); + GregTech_API.registerCover(werkstoff.get(lens), new GT_MultiTexture(Textures.BlockIcons.MACHINE_CASINGS[2][0], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_LENS, werkstoff.getRGBA(), false)), new gregtech.common.covers.GT_Cover_Lens(BW_ColorUtil.getDyeFromColor(werkstoff.getRGBA()).mIndex)); + GT_ModHandler.addPulverisationRecipe(werkstoff.get(lens), werkstoff.get(dustSmall,3)); + // if (MainMod.GTNH) { + //Engraver Recipe adder + for (ItemStack is : OreDictionary.getOres("craftingLens" + BW_ColorUtil.getDyeFromColor(werkstoff.getRGBA()).mName.replace(" ", ""))) { + is.stackSize = 0; + GT_Values.RA.addLaserEngraverRecipe(werkstoff.get(gemChipped, 3), is, werkstoff.get(gemFlawed, 1), 600, 30); + GT_Values.RA.addLaserEngraverRecipe(werkstoff.get(gemFlawed, 3), is, werkstoff.get(gem, 1), 600, 120); + GT_Values.RA.addLaserEngraverRecipe(werkstoff.get(gem, 3), is, werkstoff.get(gemFlawless, 1), 1200, 480); + GT_Values.RA.addLaserEngraverRecipe(werkstoff.get(gemFlawless, 3), is, werkstoff.get(gemExquisite, 1), 2400, 2000); + } +// } + } + } + + private void addDustRecipes(Werkstoff werkstoff) { + if ((werkstoff.getGenerationFeatures().toGenerate & 0b1) != 0) { + + List<FluidStack> flOutputs = new ArrayList<>(); + List<ItemStack> stOutputs = new ArrayList<>(); + HashMap<ISubTagContainer, Pair<Integer, Integer>> tracker = new HashMap<>(); + int cells = 0; + + if (werkstoff.getStats().isElektrolysis() || werkstoff.getStats().isCentrifuge() || werkstoff.getGenerationFeatures().hasChemicalRecipes()) { + for (Pair<ISubTagContainer, Integer> container : werkstoff.getContents().getValue().toArray(new Pair[0])) { + if (container.getKey() instanceof Materials) { + if (((Materials) container.getKey()).hasCorrespondingGas() || ((Materials) container.getKey()).hasCorrespondingFluid() || ((Materials) container.getKey()).mIconSet == TextureSet.SET_FLUID) { + FluidStack tmpFl = ((Materials) container.getKey()).getGas(1000 * container.getValue()); + if (tmpFl == null || tmpFl.getFluid() == null) { + tmpFl = ((Materials) container.getKey()).getFluid(1000 * container.getValue()); + } + flOutputs.add(tmpFl); + if (flOutputs.size() > 1) { + if (!tracker.containsKey(container.getKey())) { + stOutputs.add(((Materials) container.getKey()).getCells(container.getValue())); + tracker.put(container.getKey(), new Pair<>(container.getValue(), stOutputs.size() - 1)); + } else { + stOutputs.add(((Materials) container.getKey()).getCells(tracker.get(container.getKey()).getKey() + container.getValue())); + stOutputs.remove(tracker.get(container.getKey()).getValue() + 1); + } + cells += container.getValue(); + } + } else { + if (!tracker.containsKey(container.getKey())) { + stOutputs.add(((Materials) container.getKey()).getDust(container.getValue())); + tracker.put(container.getKey(), new Pair<>(container.getValue(), stOutputs.size() - 1)); + } else { + stOutputs.add(((Materials) container.getKey()).getDust(tracker.get(container.getKey()).getKey() + container.getValue())); + stOutputs.remove(tracker.get(container.getKey()).getValue() + 1); + } + } + } else if (container.getKey() instanceof Werkstoff) { + if (((Werkstoff) container.getKey()).getTexSet() == TextureSet.SET_FLUID) { + //not yet implemented no fluids from me... + } else { + if (!tracker.containsKey(container.getKey())) { + stOutputs.add(((Werkstoff) container.getKey()).get(dust, container.getValue())); + tracker.put(container.getKey(), new Pair<>(container.getValue(), stOutputs.size() - 1)); + } else { + stOutputs.add(((Werkstoff) container.getKey()).get(dust, (tracker.get(container.getKey()).getKey() + container.getValue()))); + stOutputs.remove(tracker.get(container.getKey()).getValue() + 1); + } + } + } + } + ItemStack input = WerkstoffLoader.getCorresopndingItemStack(dust, werkstoff); + input.stackSize = werkstoff.getContents().getKey(); + if (werkstoff.getStats().isElektrolysis()) + GT_Recipe.GT_Recipe_Map.sElectrolyzerRecipes.addRecipe(true, new ItemStack[]{input, cells > 0 ? Materials.Empty.getCells(cells) : null}, stOutputs.toArray(new ItemStack[0]), null, null, new FluidStack[]{null}, new FluidStack[]{flOutputs.size() > 0 ? flOutputs.get(0) : null}, (int) Math.max(1L, Math.abs(werkstoff.getStats().protons * werkstoff.getContents().getValue().size())), Math.min(4, werkstoff.getContents().getValue().size()) * 30, 0); + if (werkstoff.getStats().isCentrifuge()) + GT_Recipe.GT_Recipe_Map.sCentrifugeRecipes.addRecipe(true, new ItemStack[]{input, cells > 0 ? Materials.Empty.getCells(cells) : null}, stOutputs.toArray(new ItemStack[0]), null, null, new FluidStack[]{null}, new FluidStack[]{flOutputs.size() > 0 ? flOutputs.get(0) : null}, (int) Math.max(1L, Math.abs(werkstoff.getStats().mass * werkstoff.getContents().getValue().size())), Math.min(4, werkstoff.getContents().getValue().size()) * 5, 0); + if (werkstoff.getGenerationFeatures().hasChemicalRecipes()) { + if (cells > 0) + stOutputs.add(Materials.Empty.getCells(cells)); + GT_Recipe.GT_Recipe_Map.sChemicalRecipes.addRecipe(true, stOutputs.toArray(new ItemStack[0]),new ItemStack[]{input},null,null,new FluidStack[]{flOutputs.size() > 0 ? flOutputs.get(0) : null},null,(int) Math.max(1L, Math.abs(werkstoff.getStats().protons * werkstoff.getContents().getValue().size())), Math.min(4, werkstoff.getContents().getValue().size()) * 30,0); + } + } + + GT_ModHandler.addCraftingRecipe(WerkstoffLoader.getCorresopndingItemStack(dust, werkstoff), new Object[]{ + "TTT","TTT","TTT",'T', + WerkstoffLoader.getCorresopndingItemStack(dustTiny, werkstoff) + }); + GT_ModHandler.addCraftingRecipe(WerkstoffLoader.getCorresopndingItemStack(dust, werkstoff), new Object[]{ + "TT ","TT ",'T', + WerkstoffLoader.getCorresopndingItemStack(dustSmall, werkstoff) + }); + GT_ModHandler.addCraftingRecipe(WerkstoffLoader.getCorresopndingItemStack(dustSmall, werkstoff, 4), new Object[]{ + " T ", 'T', WerkstoffLoader.getCorresopndingItemStack(dust, werkstoff) + }); + GT_ModHandler.addCraftingRecipe(WerkstoffLoader.getCorresopndingItemStack(dustTiny, werkstoff, 9), new Object[]{ + "T ", 'T', WerkstoffLoader.getCorresopndingItemStack(dust, werkstoff) + }); + + if ((werkstoff.getGenerationFeatures().toGenerate & 2) != 0 && !werkstoff.getStats().isBlastFurnace()) { + GT_ModHandler.addSmeltingRecipe(WerkstoffLoader.getCorresopndingItemStack(dust, werkstoff), WerkstoffLoader.getCorresopndingItemStack(ingot, werkstoff)); + GT_ModHandler.addSmeltingRecipe(WerkstoffLoader.getCorresopndingItemStack(dustTiny, werkstoff), WerkstoffLoader.getCorresopndingItemStack(nugget, werkstoff)); + } + } + } + + private void addOreRecipes(Werkstoff werkstoff) { + if ((werkstoff.getGenerationFeatures().toGenerate & 2) != 0 && !werkstoff.getStats().isBlastFurnace()) + GT_ModHandler.addSmeltingRecipe(WerkstoffLoader.getCorresopndingItemStack(ore, werkstoff), WerkstoffLoader.getCorresopndingItemStack(ingot, werkstoff)); + + if ((werkstoff.getGenerationFeatures().toGenerate & 0b1000) != 0) { + GT_Values.RA.addForgeHammerRecipe(werkstoff.get(ore), werkstoff.getGenerationFeatures().hasGems() ? werkstoff.get(gem) : werkstoff.get(crushed), 16, 10); + GT_ModHandler.addPulverisationRecipe( + werkstoff.get(ore), + werkstoff.get(crushed, 2), + werkstoff.contains(SubTag.CRYSTAL) ? werkstoff.get(gem) : werkstoff.getOreByProduct(0, dust), + werkstoff.getNoOfByProducts() > 0 ? 10 : 0, + Materials.Stone.getDust(1), + 50, + true); + } + } + + private void addCrushedRecipes(Werkstoff werkstoff) { + if ((werkstoff.getGenerationFeatures().toGenerate & 0b1000) == 0 || (werkstoff.getGenerationFeatures().toGenerate & 0b1) == 0) + return; + + GT_ModHandler.addCraftingRecipe(werkstoff.get(dustImpure),new Object[]{"h ", "W ",'W',werkstoff.get(crushed)}); + GT_ModHandler.addCraftingRecipe(werkstoff.get(dustPure),new Object[]{"h ", "W ",'W',werkstoff.get(crushedPurified)}); + GT_ModHandler.addCraftingRecipe(werkstoff.get(dust),new Object[]{"h ", "W ",'W',werkstoff.get(crushedCentrifuged)}); + + GT_Values.RA.addForgeHammerRecipe(werkstoff.get(crushed), werkstoff.get(dustImpure), 10, 16); + GT_ModHandler.addPulverisationRecipe(werkstoff.get(crushed), werkstoff.get(dustImpure), werkstoff.getOreByProduct(0, dust), 10, false); + GT_ModHandler.addOreWasherRecipe(werkstoff.get(crushed), 1000, werkstoff.get(crushedPurified), werkstoff.getOreByProduct(0, dustTiny), GT_OreDictUnificator.get(dust, Materials.Stone, 1L)); + GT_ModHandler.addThermalCentrifugeRecipe(werkstoff.get(crushed), (int) Math.min(5000L, Math.abs(werkstoff.getStats().protons * 20L)), werkstoff.get(crushedCentrifuged), werkstoff.getOreByProduct(1, dustTiny), GT_OreDictUnificator.get(dust, Materials.Stone, 1L)); + + GT_Values.RA.addForgeHammerRecipe(werkstoff.get(crushedPurified), werkstoff.get(dustPure), 10, 16); + GT_ModHandler.addPulverisationRecipe(werkstoff.get(crushedPurified), werkstoff.get(dustPure), werkstoff.getOreByProduct(1, dust), 10, false); + GT_ModHandler.addThermalCentrifugeRecipe(werkstoff.get(crushedPurified), (int) Math.min(5000L, Math.abs(werkstoff.getStats().protons * 20L)), werkstoff.get(crushedCentrifuged), werkstoff.getOreByProduct(1, dustTiny)); + + GT_Values.RA.addForgeHammerRecipe(werkstoff.get(crushedCentrifuged), werkstoff.get(dust), 10, 16); + GT_ModHandler.addPulverisationRecipe(werkstoff.get(crushedCentrifuged), werkstoff.get(dust), werkstoff.getOreByProduct(2, dust), 10, false); + + GT_Values.RA.addCentrifugeRecipe(werkstoff.get(dustImpure), 0, werkstoff.get(dust), werkstoff.getOreByProduct(0, dustTiny), null, null, null, null, (int) Math.max(1L, werkstoff.getStats().mass * 8L)); + GT_Values.RA.addCentrifugeRecipe(werkstoff.get(dustPure), 0, werkstoff.get(dust), werkstoff.getOreByProduct(1, dustTiny), null, null, null, null, (int) Math.max(1L, werkstoff.getStats().mass * 8L)); + + if (werkstoff.contains(SubTag.CRYSTALLISABLE)) { + GT_Values.RA.addAutoclaveRecipe(werkstoff.get(dustPure), Materials.Water.getFluid(200L), werkstoff.get(gem), 9000, 2000, 24); + GT_Values.RA.addAutoclaveRecipe(werkstoff.get(dustImpure), Materials.Water.getFluid(200L), werkstoff.get(gem), 9000, 2000, 24); + GT_Values.RA.addAutoclaveRecipe(werkstoff.get(dustPure), gregtech.api.util.GT_ModHandler.getDistilledWater(200L), werkstoff.get(gem), 9500, 1500, 24); + GT_Values.RA.addAutoclaveRecipe(werkstoff.get(dustImpure), gregtech.api.util.GT_ModHandler.getDistilledWater(200L), werkstoff.get(gem), 9500, 1500, 24); + } + if (werkstoff.contains(SubTag.WASHING_MERCURY)) + GT_Values.RA.addChemicalBathRecipe(werkstoff.get(crushed), Materials.Mercury.getFluid(1000L), werkstoff.get(crushedPurified), werkstoff.getOreByProduct(1, dust), GT_OreDictUnificator.get(dust, Materials.Stone, 1L), new int[]{10000, 7000, 4000}, 800, 8); + if (werkstoff.contains(SubTag.WASHING_SODIUMPERSULFATE)) + GT_Values.RA.addChemicalBathRecipe(werkstoff.get(crushed), Materials.SodiumPersulfate.getFluid(GT_Mod.gregtechproxy.mDisableOldChemicalRecipes ? 1000L : 100L), werkstoff.get(crushedPurified), werkstoff.getOreByProduct(1, dust), GT_OreDictUnificator.get(dust, Materials.Stone, 1L), new int[]{10000, 7000, 4000}, 800, 8); + if (werkstoff.contains(SubTag.ELECTROMAGNETIC_SEPERATION_GOLD)) + GT_Values.RA.addElectromagneticSeparatorRecipe(werkstoff.get(dustPure), werkstoff.get(dust), GT_OreDictUnificator.get(dustSmall, Materials.Gold, 1L), GT_OreDictUnificator.get(nugget, Materials.Gold, 1L), new int[]{10000, 4000, 2000}, 400, 24); + else if (werkstoff.contains(SubTag.ELECTROMAGNETIC_SEPERATION_IRON)) + GT_Values.RA.addElectromagneticSeparatorRecipe(werkstoff.get(dustPure), werkstoff.get(dust), GT_OreDictUnificator.get(dustSmall, Materials.Iron, 1L), GT_OreDictUnificator.get(nugget, Materials.Iron, 1L), new int[]{10000, 4000, 2000}, 400, 24); + else if (werkstoff.contains(SubTag.ELECTROMAGNETIC_SEPERATION_NEODYMIUM)) + GT_Values.RA.addElectromagneticSeparatorRecipe(werkstoff.get(dustPure), werkstoff.get(dust), GT_OreDictUnificator.get(dustSmall, Materials.Neodymium, 1L), GT_OreDictUnificator.get(nugget, Materials.Neodymium, 1L), new int[]{10000, 4000, 2000}, 400, 24); + } + +}
\ No newline at end of file diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/processingLoaders/AdditionalRecipes.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/processingLoaders/AdditionalRecipes.java new file mode 100644 index 0000000000..29300cdbbe --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/processingLoaders/AdditionalRecipes.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2019 bartimaeusnek + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.material.processingLoaders; + +import com.github.bartimaeusnek.bartworks.common.loaders.ItemRegistry; +import com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader; +import com.github.bartimaeusnek.bartworks.util.BW_Util; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Materials; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +import static gregtech.api.enums.OrePrefixes.*; + +public class AdditionalRecipes implements Runnable { + + @Override + public void run() { + GT_Values.RA.addChemicalRecipe(Materials.Yttrium.getDust(2), GT_Utility.getIntegratedCircuit(11),Materials.Oxygen.getGas(3000),null, WerkstoffLoader.YttriumOxide.get(dust),64, BW_Util.getMachineVoltageFromTier(4)); + GT_Recipe.GT_Recipe_Map.sBlastRecipes.addRecipe(false, new ItemStack[]{WerkstoffLoader.Zirconium.get(dust,10), WerkstoffLoader.YttriumOxide.get(dust)}, new ItemStack[]{WerkstoffLoader.YttriumOxide.get(dust), WerkstoffLoader.Zirconia.get(gemFlawed, 40)}, (Object) null, (int[]) null, new FluidStack[]{Materials.Oxygen.getGas(20000)}, null, 14400, BW_Util.getMachineVoltageFromTier(4), 2953); + GT_Values.RA.addBlastRecipe(WerkstoffLoader.YttriumOxide.get(dustSmall,2),WerkstoffLoader.Thorianit.get(dustSmall,2),Materials.Glass.getMolten(144),null,new ItemStack(ItemRegistry.bw_glasses[0],1,12),null,800,BW_Util.getMachineVoltageFromTier(5),3663); + } + +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/BWRecipes.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/BWRecipes.java index 1ee1be96f3..b07c84d493 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/util/BWRecipes.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/BWRecipes.java @@ -89,7 +89,6 @@ public class BWRecipes { ); - public BWRecipes() { if (ConfigHandler.BioLab) { @@ -484,7 +483,7 @@ public class BWRecipes { return false; } - public static class DynamicGTRecipe extends GT_Recipe{ + public static class DynamicGTRecipe extends GT_Recipe { public DynamicGTRecipe(boolean aOptimize, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecialItems, int[] aChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) { super(aOptimize, aInputs, aOutputs, aSpecialItems, aChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue); } @@ -510,13 +509,6 @@ public class BWRecipes { } - class BioLabRecipe extends GT_Recipe { - protected BioLabRecipe(boolean aOptimize, ItemStack[] aInputs, ItemStack[] aOutputs, ItemStack aSpecialItems, int[] aChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) { - super(aOptimize, aInputs, aOutputs, aSpecialItems, aChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue); - } - - } - public static class BacteriaVatRecipe extends GT_Recipe { protected BacteriaVatRecipe(boolean aOptimize, ItemStack[] aInputs, ItemStack[] aOutputs, ItemStack aSpecialItems, int[] aChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) { super(aOptimize, aInputs, aOutputs, aSpecialItems, aChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue); @@ -645,4 +637,11 @@ public class BWRecipes { return this.addRecipe(aRecipe, false, false, false); } } + + class BioLabRecipe extends GT_Recipe { + protected BioLabRecipe(boolean aOptimize, ItemStack[] aInputs, ItemStack[] aOutputs, ItemStack aSpecialItems, int[] aChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) { + super(aOptimize, aInputs, aOutputs, aSpecialItems, aChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue); + } + + } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/BW_ColorUtil.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/BW_ColorUtil.java new file mode 100644 index 0000000000..f1ae2667ee --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/BW_ColorUtil.java @@ -0,0 +1,284 @@ +/* + * Copyright (c) 2019 bartimaeusnek + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.util; + +import gregtech.api.enums.Dyes; + +import java.util.Arrays; + +public class BW_ColorUtil { + private BW_ColorUtil(){} + + public static byte getDarknessFromColor (short[] rgba, int index){ + int g = rgba[index]; + if (g >= 0 && g < 64) + return 0; + else if (g >= 64 && g < 160) + return 1; + else if (g >= 160 && g < 223) + return 2; + else if (g >= 233 && g <= 255) + return 3; + return 4; + } + + public static Dyes getDyeFromColor(short[] rgba){ + rgba=correctCorlorArray(rgba); + if (isGrayScale(rgba,2)){ + switch (getDarknessFromColor(rgba,0)) { + case 0: + return Dyes.dyeBlack; + case 1: + return Dyes.dyeGray; + case 2: + return Dyes.dyeLightGray; + case 3: + return Dyes.dyeWhite; + } + } else { + short[] tmp = roundColor(rgba, 2); + if (isRedScale(tmp)){ + if (isPurpleScale(tmp)) { + switch (getDarknessFromColor(rgba, 0)) { + case 0: + case 1: + if (rgba[3] - 50 > rgba[0]) + return Dyes.dyePurple; + else return Dyes.dyeRed; + case 2: + case 3: + if (rgba[3] - 50 > rgba[0]) + return Dyes.dyeMagenta; + else if (rgba[0] > 200 && rgba[2] > 140) + return Dyes.dyePink; + else if (rgba[0] > rgba[1]+rgba[1]/10 && rgba[0] > rgba[2]+rgba[2]/10 && rgba[1]>>4 == rgba[2]>>4 && rgba[1]+50 > rgba[0]) { + return Dyes.dyeBrown; + } + else + return Dyes.dyeRed; + case 4: + return Dyes._NULL; + } + } + if (isYellowScale(tmp)) + switch (getDarknessFromColor(rgba, 0)) { + case 0: + case 1: + return Dyes.dyeBrown; + case 2: + case 3:{ + if (rgba[0]>>5 > rgba[1]>>5) + return Dyes.dyeOrange; + else + return Dyes.dyeYellow; + } + case 4: + return Dyes._NULL; + } + return Dyes.dyePink; + } else if (isGrenScale(tmp)){ + if (isCyanScale(tmp)) { + if (rgba[2]+40 < rgba[1]) + switch (getDarknessFromColor(rgba,0)) { + case 0: + case 1: + return Dyes.dyeGreen; + case 2: + case 3: + return Dyes.dyeLime; + } + return Dyes.dyeCyan; + } + if (isYellowScale(tmp)) + switch (getDarknessFromColor(rgba, 0)) { + case 0: + case 1: + return Dyes.dyeBrown; + case 2: + case 3:{ + if (rgba[0]>>5 > rgba[1]>>5) + return Dyes.dyeOrange; + else + return Dyes.dyeYellow; + } + } + switch (getDarknessFromColor(rgba,0)) { + case 0: + case 1: + return Dyes.dyeGreen; + case 2: + case 3: + return Dyes.dyeLime; + } + } else if (isBlueScale(tmp)){ + if (isPurpleScale(tmp)) { + switch (getDarknessFromColor(rgba, 0)) { + case 0: + case 1: + return Dyes.dyePurple; + case 2: + case 3: + return Dyes.dyeMagenta; + } + } + else if (isCyanScale(tmp)){ + return Dyes.dyeCyan; + } + switch (getDarknessFromColor(rgba,0)) { + case 0: + case 1: + return Dyes.dyeBlue; + case 2: + case 3: + return Dyes.dyeLightBlue; + } + } + } + return Dyes._NULL; + } + + public static boolean isCyanScale(short[] rgba){ + return !isRedScale(rgba); + } + + public static boolean isPurpleScale(short[] rgba){ + return !isGrenScale(rgba); + } + + public static boolean isYellowScale(short[] rgba){ + return !isBlueScale(rgba); + } + + public static boolean isBlueScale(short[] rgba){ + rgba=correctCorlorArray(rgba); + return (rgba[2]*2) >= (rgba[1]+rgba[0]); + } + + public static boolean isGrenScale(short[] rgba){ + rgba=correctCorlorArray(rgba); + return (rgba[1]*2) >= (rgba[0]+rgba[2]); + } + + public static boolean isRedScale(short[] rgba){ + rgba=correctCorlorArray(rgba); + return (rgba[0]*2) >= (rgba[1]+rgba[2]); + } + + public static boolean isGrayScale(short[] rgba, int magin){ + rgba=correctCorlorArray(rgba); + return rgba[0]>>magin==rgba[1]>>magin && rgba[1]>>magin==rgba[2]>>magin; + } + + public static short[] roundColor(short[] rgba, int magin){ + short[]tmp = Arrays.copyOf(rgba,4); + tmp[0] = (short) (rgba[0]>>magin); + tmp[1] = (short) (rgba[1]>>magin); + tmp[2] = (short) (rgba[2]>>magin); + return tmp; + } + + public static boolean isGrayScale(short[] rgba){ + rgba=correctCorlorArray(rgba); + return rgba[0]==rgba[1] && rgba[1] == rgba[2]; + } + + public static short[] correctCorlorArray(short[] rgba){ + if (rgba.length<4) { + short[] tmp = Arrays.copyOf(rgba, 4); + Arrays.fill(tmp,rgba.length-1,4, (short) 0); + rgba = tmp; + } + if (rgba[0] > 255) + rgba[0] = 255; + if (rgba[1] > 255) + rgba[1] = 255; + if (rgba[2] > 255) + rgba[2] = 255; + if (rgba[3] > 255) + rgba[3] = 255; + if (rgba[0] < 0) + rgba[0] = 0; + if (rgba[1] < 0) + rgba[1] = 0; + if (rgba[2] < 0) + rgba[2] = 0; + if (rgba[3] < 0) + rgba[3] = 0; + return rgba; + } + + public static short[] splitColorToRBGArray(int rgb) { + return new short[]{(short) ((rgb >> 16) & 0xFF), (short) ((rgb >> 8) & 0xFF), (short) (rgb & 0xFF)}; + } + + public static int getColorFromRGBArray(short[] color) { + return ((color[0] & 0x0ff) << 16) | ((color[1] & 0x0ff) << 8) | (color[2] & 0x0ff); + } + + public static int getColorFromRGBArray(int[] color) { + return ((color[0] & 0x0ff) << 16) | ((color[1] & 0x0ff) << 8) | (color[2] & 0x0ff); + } + + public static String getColorForTier(int tier) { + String ret; + switch (tier) { + case 0: + ret = ChatColorHelper.RED; + break; + case 1: + ret = ChatColorHelper.GRAY; + break; + case 2: + ret = ChatColorHelper.AQUA; + break; + case 3: + ret = ChatColorHelper.GOLD; + break; + case 4: + ret = ChatColorHelper.DARKPURPLE; + break; + case 5: + ret = ChatColorHelper.DARKBLUE; + break; + case 6: + ret = ChatColorHelper.LIGHT_PURPLE; + break; + case 7: + ret = ChatColorHelper.WHITE; + break; + case 8: + ret = ChatColorHelper.DARKAQUA; + break; + case 9: + ret = ChatColorHelper.DARKRED; + break; + case 10: + ret = ChatColorHelper.GREEN; + break; + default: + ret = ChatColorHelper.OBFUSCATED; + break; + } + return ret; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/BW_Util.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/BW_Util.java index 51572b0543..c775313f1a 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/util/BW_Util.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/BW_Util.java @@ -24,6 +24,7 @@ package com.github.bartimaeusnek.bartworks.util; import com.github.bartimaeusnek.bartworks.API.BioVatLogicAdder; import gregtech.api.enums.Materials; +import gregtech.api.interfaces.ISubTagContainer; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; @@ -36,8 +37,10 @@ import net.minecraftforge.common.util.ForgeDirection; import javax.annotation.Nonnegative; import java.util.ArrayList; +import java.util.Arrays; import java.util.Iterator; import java.util.List; +import java.util.function.UnaryOperator; import static gregtech.api.enums.GT_Values.V; @@ -92,18 +95,6 @@ public class BW_Util { return (int) (30 * Math.pow(4, (tier - 1))); } - public static short[] splitColortoArray(int rgb) { - return new short[]{(short) ((rgb >> 16) & 0xFF), (short) ((rgb >> 8) & 0xFF), (short) (rgb & 0xFF)}; - } - - public static int getColorFromArray(short[] color) { - return ((color[0] & 0x0ff) << 16) | ((color[1] & 0x0ff) << 8) | (color[2] & 0x0ff); - } - - public static int getColorFromArray(int[] color) { - return ((color[0] & 0x0ff) << 16) | ((color[1] & 0x0ff) << 8) | (color[2] & 0x0ff); - } - public static boolean areStacksEqual(ItemStack aStack1, ItemStack aStack2) { return (aStack1 == null && aStack2 == null) || GT_Utility.areStacksEqual(aStack1, aStack2); } @@ -136,51 +127,11 @@ public class BW_Util { case 5: ret = 8; break; - default: - ret = 3; - } - return ret; - } - - public static String getColorForTier(int tier) { - String ret; - switch (tier) { - case 0: - ret = ChatColorHelper.RED; - break; - case 1: - ret = ChatColorHelper.GRAY; - break; - case 2: - ret = ChatColorHelper.AQUA; - break; - case 3: - ret = ChatColorHelper.GOLD; - break; - case 4: - ret = ChatColorHelper.DARKPURPLE; - break; - case 5: - ret = ChatColorHelper.DARKBLUE; - break; - case 6: - ret = ChatColorHelper.LIGHT_PURPLE; - break; - case 7: - ret = ChatColorHelper.WHITE; - break; - case 8: - ret = ChatColorHelper.DARKAQUA; - break; - case 9: - ret = ChatColorHelper.DARKRED; - break; - case 10: - ret = ChatColorHelper.GREEN; + case 12: + ret = 5; break; default: - ret = ChatColorHelper.OBFUSCATED; - break; + ret = 3; } return ret; } @@ -233,15 +184,16 @@ public class BW_Util { } } - public static long getnominalVoltage(GT_MetaTileEntity_MultiBlockBase base){ + public static long getnominalVoltage(GT_MetaTileEntity_MultiBlockBase base) { long rVoltage = 0L; long rAmperage = 0L; Iterator var3 = base.mEnergyHatches.iterator(); - while(var3.hasNext()) { - GT_MetaTileEntity_Hatch_Energy tHatch = (GT_MetaTileEntity_Hatch_Energy)var3.next(); + while (var3.hasNext()) { + GT_MetaTileEntity_Hatch_Energy tHatch = (GT_MetaTileEntity_Hatch_Energy) var3.next(); if (base.isValidMetaTileEntity(tHatch)) { - rVoltage += tHatch.getBaseMetaTileEntity().getInputVoltage(); + if (rVoltage == 0 || rVoltage > tHatch.getBaseMetaTileEntity().getInputVoltage()) + rVoltage = tHatch.getBaseMetaTileEntity().getInputVoltage(); rAmperage += tHatch.getBaseMetaTileEntity().getInputAmperage(); } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/BioCulture.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/BioCulture.java index 98601e568c..001b747be8 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/util/BioCulture.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/BioCulture.java @@ -24,6 +24,7 @@ package com.github.bartimaeusnek.bartworks.util; import com.github.bartimaeusnek.bartworks.MainMod; +import gregtech.api.interfaces.IColorModulationContainer; import net.minecraft.item.EnumRarity; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.fluids.Fluid; @@ -32,13 +33,12 @@ import net.minecraftforge.fluids.FluidRegistry; import java.awt.*; import java.nio.ByteBuffer; import java.util.ArrayList; -import java.util.Arrays; import java.util.Objects; -public class BioCulture extends BioData { +public class BioCulture extends BioData implements IColorModulationContainer { public static final ArrayList<BioCulture> BIO_CULTURE_ARRAY_LIST = new ArrayList<BioCulture>(); - public static final BioCulture NULLCULTURE = BioCulture.createAndRegisterBioCulture(Color.BLUE, "", BioPlasmid.NULLPLASMID,BioDNA.NULLDNA, false); //fallback NULL culture, also Blue =) + public static final BioCulture NULLCULTURE = BioCulture.createAndRegisterBioCulture(Color.BLUE, "", BioPlasmid.NULLPLASMID, BioDNA.NULLDNA, false); //fallback NULL culture, also Blue =) Color color; BioPlasmid plasmid; @@ -95,14 +95,14 @@ public class BioCulture extends BioData { BioCulture ret = getBioCulture(tag.getString("Name")); if (ret == null) - ret = createAndRegisterBioCulture( - new Color(tag.getIntArray("Color")[0], tag.getIntArray("Color")[1], tag.getIntArray("Color")[2]), - tag.getString("Name"), - BioPlasmid.convertDataToPlasmid(getBioDataFromNBTTag(tag.getCompoundTag("Plasmid"))), - BioDNA.convertDataToDNA(getBioDataFromNBTTag(tag.getCompoundTag("DNA"))), - BW_Util.getRarityFromByte(tag.getByte("Rarety")), - tag.getBoolean("Breedable") - ); + ret = createAndRegisterBioCulture( + new Color(tag.getIntArray("Color")[0], tag.getIntArray("Color")[1], tag.getIntArray("Color")[2]), + tag.getString("Name"), + BioPlasmid.convertDataToPlasmid(getBioDataFromNBTTag(tag.getCompoundTag("Plasmid"))), + BioDNA.convertDataToDNA(getBioDataFromNBTTag(tag.getCompoundTag("DNA"))), + BW_Util.getRarityFromByte(tag.getByte("Rarety")), + tag.getBoolean("Breedable") + ); if (ret.bBreedable) ret.setFluid(FluidRegistry.getFluid(tag.getString("Fluid"))); if (ret.getFluidNotSet()) //should never happen, but better safe than sorry @@ -130,14 +130,14 @@ public class BioCulture extends BioData { return this.mFluid; } - public boolean getFluidNotSet(){ - return this.mFluid == null && this.isBreedable(); - } - public void setFluid(Fluid mFluid) { this.mFluid = mFluid; } + public boolean getFluidNotSet() { + return this.mFluid == null && this.isBreedable(); + } + public boolean isBreedable() { return this.bBreedable; } @@ -147,7 +147,7 @@ public class BioCulture extends BioData { } public int getColorRGB() { - return BW_Util.getColorFromArray(new int[]{this.color.getRed(), this.color.getGreen(), this.color.getBlue()}); + return BW_ColorUtil.getColorFromRGBArray(new int[]{this.color.getRed(), this.color.getGreen(), this.color.getBlue()}); } public Color getColor() { @@ -195,6 +195,11 @@ public class BioCulture extends BioData { @Override public int hashCode() { - return MurmurHash3.murmurhash3_x86_32(ByteBuffer.allocate(17).putInt(MurmurHash3.murmurhash3_x86_32(this.getName(),0,this.getName().length(),31)).putInt(this.getColorRGB()).putInt(this.getPlasmid().ID).putInt(this.getdDNA().ID).put((byte) (isBreedable() ? 1 : 0)).array(),0,17,31); + return MurmurHash3.murmurhash3_x86_32(ByteBuffer.allocate(17).putInt(MurmurHash3.murmurhash3_x86_32(this.getName(), 0, this.getName().length(), 31)).putInt(this.getColorRGB()).putInt(this.getPlasmid().ID).putInt(this.getdDNA().ID).put((byte) (isBreedable() ? 1 : 0)).array(), 0, 17, 31); + } + + @Override + public short[] getRGBA() { + return new short[]{(short) getColor().getRed(), (short) getColor().getGreen(), (short) getColor().getBlue(), (short) getColor().getAlpha()}; } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/BioData.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/BioData.java index f4e8917e67..1421f75c40 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/util/BioData.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/BioData.java @@ -111,14 +111,14 @@ public class BioData { BioData bioData = (BioData) o; return this.getID() == bioData.getID() || ( this.getChance() == bioData.getChance() && - this.getTier() == bioData.getTier() && - Objects.equals(this.getName(), bioData.getName()) && - this.getRarity() == bioData.getRarity()); + this.getTier() == bioData.getTier() && + Objects.equals(this.getName(), bioData.getName()) && + this.getRarity() == bioData.getRarity()); } @Override public int hashCode() { - return MurmurHash3.murmurhash3_x86_32(ByteBuffer.allocate(13).putInt(MurmurHash3.murmurhash3_x86_32(this.getName(),0,this.getName().length(),31)).put(BW_Util.getByteFromRarity(this.getRarity())).putInt(this.getChance()).putInt(this.getTier()).array(),0,13,31); + return MurmurHash3.murmurhash3_x86_32(ByteBuffer.allocate(13).putInt(MurmurHash3.murmurhash3_x86_32(this.getName(), 0, this.getName().length(), 31)).put(BW_Util.getByteFromRarity(this.getRarity())).putInt(this.getChance()).putInt(this.getTier()).array(), 0, 13, 31); } public int getTier() { diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/Pair.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/Pair.java new file mode 100644 index 0000000000..acc6da7b14 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/Pair.java @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2019 bartimaeusnek + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.util; + +import java.nio.ByteBuffer; +import java.util.Arrays; +import java.util.Map; + +public class Pair<A, B> implements Map.Entry { + Object[] pair = new Object[2]; + + + public Pair(Object[] pair) { + this.pair = pair; + } + + public Pair(A k, B v) { + this.pair[0] = k; + this.pair[1] = v; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof Pair)) return false; + + Pair<?, ?> pair1 = (Pair<?, ?>) o; + + // Probably incorrect - comparing Object[] arrays with Arrays.equals + return Arrays.equals(this.pair, pair1.pair); + } + + @Override + public int hashCode() { + return MurmurHash3.murmurhash3_x86_32(ByteBuffer.allocate(8).putInt(pair[0].hashCode()).putInt(pair[1].hashCode()).array(), 0, 8, 31); + } + + @Override + public A getKey() { + return (A) pair[0]; + } + + @Override + public B getValue() { + return (B) pair[1]; + } + + @Override + public B setValue(Object value) { + pair[1] = value; + return (B) pair[1]; + } + + public Pair<A,B> copyWithNewValue(B value){ + return new Pair<>((A)this.pair[0],value); + } + + public Pair<A,B> replaceValue(B value){ + this.setValue(value); + return this; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/BartWorksCrossmod.java b/src/main/java/com/github/bartimaeusnek/crossmod/BartWorksCrossmod.java new file mode 100644 index 0000000000..cd420afdcb --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/crossmod/BartWorksCrossmod.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2019 bartimaeusnek + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.bartimaeusnek.crossmod; + +import com.github.bartimaeusnek.crossmod.galacticraft.GalacticraftProxy; +import com.github.bartimaeusnek.crossmod.thaumcraft.CustomAspects; +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.Mod; +import cpw.mods.fml.common.event.FMLInitializationEvent; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +@Mod( + modid = BartWorksCrossmod.MOD_ID, name = BartWorksCrossmod.NAME, version = BartWorksCrossmod.VERSION, + dependencies = "required-after:IC2; " + + "required-after:gregtech; " + + "required-after:bartworks;" + + "after:GalacticraftCore;" +) +public class BartWorksCrossmod { + public static final String NAME = "BartWorks Mod Additions"; + public static final String VERSION = "0.0.1"; + public static final String MOD_ID = "bartworkscrossmod"; + public static final Logger LOGGER = LogManager.getLogger(NAME); + + @Mod.Instance(MOD_ID) + public static BartWorksCrossmod instance; + + @Mod.EventHandler + public void preInit(FMLPreInitializationEvent preinit) { + if (Loader.isModLoaded("GalacticraftCore")) + GalacticraftProxy.preInit(preinit); + if (Loader.isModLoaded("Thaumcraft")) + new CustomAspects(); + } + + @Mod.EventHandler + public void init(FMLInitializationEvent init) { + if (Loader.isModLoaded("GalacticraftCore")) + GalacticraftProxy.init(init); + } + +} diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/GalacticraftProxy.java b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/GalacticraftProxy.java new file mode 100644 index 0000000000..505350d401 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/GalacticraftProxy.java @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2019 bartimaeusnek + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.bartimaeusnek.crossmod.galacticraft; + +import com.github.bartimaeusnek.crossmod.galacticraft.solarsystems.Ross128SolarSystem; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.event.FMLInitializationEvent; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import gregtech.api.objects.GT_UO_DimensionList; +import net.minecraftforge.common.config.Configuration; + +import java.io.File; + +import static com.github.bartimaeusnek.crossmod.galacticraft.planets.ross128.world.oregen.BW_WorldGenRoss128.init_OresRoss128; +import static com.github.bartimaeusnek.crossmod.galacticraft.planets.ross128.world.oregen.BW_WorldGenRoss128.init_undergroundFluidsRoss128; + +public class GalacticraftProxy { + public static GT_UO_DimensionList uo_dimensionList = new GT_UO_DimensionList(); + static Configuration gtConf; + private GalacticraftProxy() { + } + + public static void preInit(FMLPreInitializationEvent e) { + if (FMLCommonHandler.instance().getSide().isServer() || FMLCommonHandler.instance().getEffectiveSide().isServer()) { + GalacticraftProxy.serverpreInit(e); + } else { + GalacticraftProxy.clientpreInit(e); + } + GalacticraftProxy.commonpreInit(e); + } + + private static void serverpreInit(FMLPreInitializationEvent e) { + + } + + private static void clientpreInit(FMLPreInitializationEvent e) { + } + + private static void commonpreInit(FMLPreInitializationEvent e) { + GalacticraftProxy.gtConf = new Configuration(new File(new File(e.getModConfigurationDirectory(), "GregTech"), "GregTech.cfg")); + GalacticraftProxy.uo_dimensionList.getConfig(GalacticraftProxy.gtConf, "undergroundfluid"); + init_undergroundFluidsRoss128(); + if (GalacticraftProxy.gtConf.hasChanged()) + GalacticraftProxy.gtConf.save(); + + Configuration c = new Configuration(new File(e.getModConfigurationDirectory(), "bartworks.cfg")); + Ross128SolarSystem.ross128ID = c.get("CrossMod Interactions", "DimID - Ross128b", -64, "The Dim ID for Ross128b").getInt(-64); + Ross128SolarSystem.enabled = c.get("CrossMod Interactions", "Galacticraft - Activate Ross128 System", true, "If the Ross128 System should be activated").getBoolean(true); + if (c.hasChanged()) + c.save(); + + init_OresRoss128(); + } + + public static void init(FMLInitializationEvent e) { + if (FMLCommonHandler.instance().getSide().isServer() || FMLCommonHandler.instance().getEffectiveSide().isServer()) { + GalacticraftProxy.serverInit(e); + } else { + GalacticraftProxy.clientInit(e); + } + GalacticraftProxy.commonInit(e); + } + + private static void serverInit(FMLInitializationEvent e) { + + } + + private static void clientInit(FMLInitializationEvent e) { + + } + + private static void commonInit(FMLInitializationEvent e) { + if (Ross128SolarSystem.enabled) + Ross128SolarSystem.init(); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/UniversalTeleportType.java b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/UniversalTeleportType.java new file mode 100644 index 0000000000..742cee9a10 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/UniversalTeleportType.java @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2019 bartimaeusnek + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.bartimaeusnek.crossmod.galacticraft; + +import micdoodle8.mods.galacticraft.api.vector.Vector3; +import micdoodle8.mods.galacticraft.api.world.ITeleportType; +import micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats; +import micdoodle8.mods.galacticraft.planets.mars.entities.EntityLandingBalloons; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.world.World; +import net.minecraft.world.WorldServer; + +import java.util.Random; + +public class UniversalTeleportType implements ITeleportType { + + @Override + public boolean useParachute() { + return false; + } + + @Override + public Vector3 getPlayerSpawnLocation(WorldServer world, EntityPlayerMP player) { + return getEntitySpawnLocation(world, player); + } + + @Override + public Vector3 getEntitySpawnLocation(WorldServer world, Entity entity) { + if (entity instanceof EntityPlayerMP) { + GCPlayerStats stats = GCPlayerStats.get((EntityPlayerMP) entity); + return new Vector3(stats.coordsTeleportedFromX, 500D, stats.coordsTeleportedFromZ); + } + return new Vector3(entity.posX, 500D, entity.posZ); + } + + @Override + public Vector3 getParaChestSpawnLocation(WorldServer world, EntityPlayerMP player, Random rand) { + return null; + } + + @Override + public void onSpaceDimensionChanged(World newWorld, EntityPlayerMP player, boolean ridingAutoRocket) { + if ((player != null) && (GCPlayerStats.get(player).teleportCooldown <= 0)) { + if (player.capabilities.isFlying) { + player.capabilities.isFlying = false; + } + + EntityLandingBalloons entityLandingBalloons = new EntityLandingBalloons(player); + if (!newWorld.isRemote) { + newWorld.spawnEntityInWorld(entityLandingBalloons); + } + GCPlayerStats.get(player).teleportCooldown = 10; + } + } + + @Override + public void setupAdventureSpawn(EntityPlayerMP player) { + + } +} diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/blocks/UniversalSpaceBlocks.java b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/blocks/UniversalSpaceBlocks.java new file mode 100644 index 0000000000..a404c30e34 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/blocks/UniversalSpaceBlocks.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2019 bartimaeusnek + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.bartimaeusnek.crossmod.galacticraft.blocks; + +import com.github.bartimaeusnek.bartworks.common.blocks.BW_Blocks; +import com.github.bartimaeusnek.crossmod.galacticraft.creativetabs.SpaceTab; +import net.minecraft.block.material.Material; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.world.IBlockAccess; + +public class UniversalSpaceBlocks extends BW_Blocks { + + public UniversalSpaceBlocks(String name, String[] texture) { + super(name, texture, SpaceTab.getInstance(), Material.rock); + } + + @Override + public boolean canBeReplacedByLeaves(IBlockAccess world, int x, int y, int z) { + return true; + } + + @Override + public boolean canCreatureSpawn(EnumCreatureType type, IBlockAccess world, int x, int y, int z) { + return true; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/creativetabs/SpaceTab.java b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/creativetabs/SpaceTab.java new file mode 100644 index 0000000000..e3b8aaf3cf --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/creativetabs/SpaceTab.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2019 bartimaeusnek + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.bartimaeusnek.crossmod.galacticraft.creativetabs; + +import com.github.bartimaeusnek.bartworks.common.loaders.ItemRegistry; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; + +public class SpaceTab extends CreativeTabs { + + private static final SpaceTab instance = new SpaceTab("SpaceTab"); + + private SpaceTab(String label) { + super(label); + } + + public static SpaceTab getInstance() { + return instance; + } + + @Override + public Item getTabIconItem() { + return ItemRegistry.DESTRUCTOPACK; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128/world/oregen/BW_OreLayer.java b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128/world/oregen/BW_OreLayer.java new file mode 100644 index 0000000000..4f15b27b60 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128/world/oregen/BW_OreLayer.java @@ -0,0 +1,150 @@ +/* + * Copyright (c) 2019 bartimaeusnek + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.bartimaeusnek.crossmod.galacticraft.planets.ross128.world.oregen; + +import com.github.bartimaeusnek.bartworks.MainMod; +import com.github.bartimaeusnek.bartworks.system.material.BW_MetaGenerated_Ores; +import com.github.bartimaeusnek.bartworks.system.material.Werkstoff; +import gregtech.api.enums.Materials; +import gregtech.api.interfaces.ISubTagContainer; +import gregtech.api.world.GT_Worldgen; +import gregtech.common.blocks.GT_TileEntity_Ores; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; +import net.minecraft.world.chunk.IChunkProvider; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +/** + * Original GT File Stripped and adjusted to work with this mod + */ +public class BW_OreLayer extends GT_Worldgen { + public static final List<BW_OreLayer> sList = new ArrayList<>(); + private static final boolean logOregenRoss128 = false; + public static int sWeight; + public byte bwOres; + public int mMinY, mWeight, mDensity, mSize, mMaxY, mPrimaryMeta, mSecondaryMeta, mBetweenMeta, mSporadicMeta; + + public BW_OreLayer(String aName, boolean aDefault, int aMinY, int aMaxY, int aWeight, int aDensity, int aSize, ISubTagContainer top, ISubTagContainer bottom, ISubTagContainer between, ISubTagContainer sprinkled) { + super(aName, BW_OreLayer.sList, aDefault); + this.mMinY = (short) aMinY; + this.mMaxY = (short) aMaxY; + this.mWeight = (short) aWeight; + this.mDensity = (short) aDensity; + this.mSize = (short) Math.max(1, aSize); + + if (this.mEnabled) + BW_OreLayer.sWeight += this.mWeight; + + if (top instanceof Werkstoff) + this.bwOres = (byte) (this.bwOres | 0b1000); + if (bottom instanceof Werkstoff) + this.bwOres = (byte) (this.bwOres | 0b0100); + if (between instanceof Werkstoff) + this.bwOres = (byte) (this.bwOres | 0b0010); + if (sprinkled instanceof Werkstoff) + this.bwOres = (byte) (this.bwOres | 0b0001); + + short aPrimary = top instanceof Materials ? + (short) ((Materials) top).mMetaItemSubID : + top instanceof Werkstoff ? + ((Werkstoff) top).getmID() : + 0; + short aSecondary = bottom instanceof Materials ? + (short) ((Materials) bottom).mMetaItemSubID : + bottom instanceof Werkstoff ? + ((Werkstoff) bottom).getmID() : + 0; + short aBetween = between instanceof Materials ? + (short) ((Materials) between).mMetaItemSubID : + between instanceof Werkstoff ? + ((Werkstoff) between).getmID() : + 0; + short aSporadic = sprinkled instanceof Materials ? + (short) ((Materials) sprinkled).mMetaItemSubID : + sprinkled instanceof Werkstoff ? + ((Werkstoff) sprinkled).getmID() : + 0; + this.mPrimaryMeta = aPrimary; + this.mSecondaryMeta = aSecondary; + this.mBetweenMeta = aBetween; + this.mSporadicMeta = aSporadic; + + } + + @Override + public boolean executeWorldgen(World aWorld, Random aRandom, String aBiome, int aDimensionType, int aChunkX, int aChunkZ, IChunkProvider aChunkGenerator, IChunkProvider aChunkProvider) { + { + int tMinY = this.mMinY + aRandom.nextInt(this.mMaxY - this.mMinY - 5); + int cX = aChunkX - aRandom.nextInt(this.mSize); + int eX = aChunkX + 16 + aRandom.nextInt(this.mSize); + + for (int tX = cX; tX <= eX; ++tX) { + int cZ = aChunkZ - aRandom.nextInt(this.mSize); + int eZ = aChunkZ + 16 + aRandom.nextInt(this.mSize); + + for (int tZ = cZ; tZ <= eZ; ++tZ) { + int i; + if (this.mSecondaryMeta > 0) { + for (i = tMinY - 1; i < tMinY + 2; ++i) { + if (aRandom.nextInt(Math.max(1, Math.max(MathHelper.abs_int(cZ - tZ), MathHelper.abs_int(eZ - tZ)) / this.mDensity)) == 0 || aRandom.nextInt(Math.max(1, Math.max(MathHelper.abs_int(cX - tX), MathHelper.abs_int(eX - tX)) / this.mDensity)) == 0) { + this.setOreBlock(aWorld, tX, i, tZ, this.mSecondaryMeta, false); + } + } + } + + if (this.mBetweenMeta > 0 && (aRandom.nextInt(Math.max(1, Math.max(MathHelper.abs_int(cZ - tZ), MathHelper.abs_int(eZ - tZ)) / this.mDensity)) == 0 || aRandom.nextInt(Math.max(1, Math.max(MathHelper.abs_int(cX - tX), MathHelper.abs_int(eX - tX)) / this.mDensity)) == 0)) { + this.setOreBlock(aWorld, tX, tMinY + 2 + aRandom.nextInt(2), tZ, this.mBetweenMeta, false); + } + + if (this.mPrimaryMeta > 0) { + for (i = tMinY + 3; i < tMinY + 6; ++i) { + if (aRandom.nextInt(Math.max(1, Math.max(MathHelper.abs_int(cZ - tZ), MathHelper.abs_int(eZ - tZ)) / this.mDensity)) == 0 || aRandom.nextInt(Math.max(1, Math.max(MathHelper.abs_int(cX - tX), MathHelper.abs_int(eX - tX)) / this.mDensity)) == 0) { + this.setOreBlock(aWorld, tX, i, tZ, this.mPrimaryMeta, false); + } + } + } + + if (this.mSporadicMeta > 0 && (aRandom.nextInt(Math.max(1, Math.max(MathHelper.abs_int(cZ - tZ), MathHelper.abs_int(eZ - tZ)) / this.mDensity)) == 0 || aRandom.nextInt(Math.max(1, Math.max(MathHelper.abs_int(cX - tX), MathHelper.abs_int(eX - tX)) / this.mDensity)) == 0)) { + this.setOreBlock(aWorld, tX, tMinY - 1 + aRandom.nextInt(7), tZ, this.mSporadicMeta, false); + } + } + } + + if (BW_OreLayer.logOregenRoss128) { + MainMod.LOGGER.info("Generated Orevein: " + this.mWorldGenName + " " + aChunkX + " " + aChunkZ); + } + + return true; + } + } + + public boolean setOreBlock(World aWorld, int aX, int aY, int aZ, int aMetaData, boolean isSmallOre) { + if ((aMetaData == this.mSporadicMeta && (this.bwOres & 0b0001) != 0) || (aMetaData == this.mBetweenMeta && (this.bwOres & 0b0010) != 0) || (aMetaData == this.mPrimaryMeta && (this.bwOres & 0b1000) != 0) || (aMetaData == this.mSecondaryMeta && (this.bwOres & 0b0100) != 0)) { + return BW_MetaGenerated_Ores.setOreBlock(aWorld, aX, aY, aZ, aMetaData, false); + } + return GT_TileEntity_Ores.setOreBlock(aWorld, aX, aY, aZ, aMetaData, isSmallOre, false); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128/world/oregen/BW_WordGenerator.java b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128/world/oregen/BW_WordGenerator.java new file mode 100644 index 0000000000..36e017d626 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128/world/oregen/BW_WordGenerator.java @@ -0,0 +1,126 @@ +/* + * Copyright (c) 2019 bartimaeusnek + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.bartimaeusnek.crossmod.galacticraft.planets.ross128.world.oregen; + + +import cpw.mods.fml.common.IWorldGenerator; +import gregtech.api.objects.XSTR; +import gregtech.api.util.GT_Log; +import gregtech.api.world.GT_Worldgen; +import net.minecraft.world.ChunkCoordIntPair; +import net.minecraft.world.World; +import net.minecraft.world.chunk.Chunk; +import net.minecraft.world.chunk.IChunkProvider; + +import java.util.HashSet; +import java.util.Random; + +/** + * Original GT File Stripped and adjusted to work with this mod + */ +public class BW_WordGenerator implements IWorldGenerator { + + public BW_WordGenerator() { + //GT_NH Override... wont be actually registered to force its generation directly in the ChunkProvider + //GameRegistry.registerWorldGenerator(this, 1073741823); + } + + public synchronized void generate(Random aRandom, int aX, int aZ, World aWorld, IChunkProvider aChunkGenerator, IChunkProvider aChunkProvider) { + new BW_WordGenerator.WorldGenContainer(aX * 16, aZ * 16, aWorld.provider.dimensionId, aWorld, aChunkGenerator, aChunkProvider).run(); + } + + public static class WorldGenContainer implements Runnable { + public static HashSet<ChunkCoordIntPair> mGenerated = new HashSet<>(2000); + public final int mDimensionType; + public final World mWorld; + public final IChunkProvider mChunkGenerator; + public final IChunkProvider mChunkProvider; + public int mX; + public int mZ; + + public WorldGenContainer(int aX, int aZ, int aDimensionType, World aWorld, IChunkProvider aChunkGenerator, IChunkProvider aChunkProvider) { + this.mX = aX; + this.mZ = aZ; + this.mDimensionType = aDimensionType; + this.mWorld = aWorld; + this.mChunkGenerator = aChunkGenerator; + this.mChunkProvider = aChunkProvider; + } + + //returns a coordinate of a center chunk of 3x3 square; the argument belongs to this square + public int getVeinCenterCoordinate(int c) { + c += c < 0 ? 1 : 3; + return c - c % 3 - 2; + } + + public boolean surroundingChunksLoaded(int xCenter, int zCenter) { + return this.mWorld.checkChunksExist(xCenter - 16, 0, zCenter - 16, xCenter + 16, 0, zCenter + 16); + } + + public XSTR getRandom(int xChunk, int zChunk) { + long worldSeed = this.mWorld.getSeed(); + XSTR fmlRandom = new XSTR(worldSeed); + long xSeed = fmlRandom.nextLong() >> 2 + 1L; + long zSeed = fmlRandom.nextLong() >> 2 + 1L; + long chunkSeed = (xSeed * xChunk + zSeed * zChunk) ^ worldSeed; + fmlRandom.setSeed(chunkSeed); + return new XSTR(fmlRandom.nextInt()); + } + + public void run() { + int xCenter = this.getVeinCenterCoordinate(this.mX >> 4); + int zCenter = this.getVeinCenterCoordinate(this.mZ >> 4); + Random random = this.getRandom(xCenter, zCenter); + xCenter <<= 4; + zCenter <<= 4; + ChunkCoordIntPair centerChunk = new ChunkCoordIntPair(xCenter, zCenter); + if (!BW_WordGenerator.WorldGenContainer.mGenerated.contains(centerChunk) && this.surroundingChunksLoaded(xCenter, zCenter)) { + BW_WordGenerator.WorldGenContainer.mGenerated.add(centerChunk); + if ((BW_OreLayer.sWeight > 0) && (BW_OreLayer.sList.size() > 0)) { + boolean temp = true; + int tRandomWeight; + for (int i = 0; (i < 256) && (temp); i++) { + tRandomWeight = random.nextInt(BW_OreLayer.sWeight); + for (BW_OreLayer tWorldGen : BW_OreLayer.sList) { + tRandomWeight -= tWorldGen.mWeight; + if (tRandomWeight <= 0) { + try { + if (tWorldGen.executeWorldgen(this.mWorld, random, "", this.mDimensionType, xCenter, zCenter, this.mChunkGenerator, this.mChunkProvider)) { + temp = false; + } + break; + } catch (Throwable e) { + e.printStackTrace(GT_Log.err); + } + } + } + } + } + } + Chunk tChunk = this.mWorld.getChunkFromBlockCoords(this.mX, this.mZ); + if (tChunk != null) { + tChunk.isModified = true; + } + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128/world/oregen/BW_WorldGenRoss128.java b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128/world/oregen/BW_WorldGenRoss128.java new file mode 100644 index 0000000000..d01e782acf --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128/world/oregen/BW_WorldGenRoss128.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2019 bartimaeusnek + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.bartimaeusnek.crossmod.galacticraft.planets.ross128.world.oregen; + +import com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader; +import com.github.bartimaeusnek.crossmod.galacticraft.solarsystems.Ross128SolarSystem; +import gregtech.api.enums.Materials; +import gregtech.api.interfaces.ISubTagContainer; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; +import net.minecraftforge.fluids.FluidRegistry; + +import static com.github.bartimaeusnek.crossmod.galacticraft.GalacticraftProxy.uo_dimensionList; + + +public class BW_WorldGenRoss128 extends BW_OreLayer { + + + public BW_WorldGenRoss128(String aName, boolean aDefault, int aMinY, int aMaxY, int aWeight, int aDensity, int aSize, ISubTagContainer top, ISubTagContainer bottom, ISubTagContainer between, ISubTagContainer sprinkled) { + super(aName, aDefault, aMinY, aMaxY, aWeight, aDensity, aSize, top, bottom, between, sprinkled); + } + + public static void init_OresRoss128() { + new BW_WorldGenRoss128("ore.mix.ross128.Thorianit", true, 30, 60, 17, 1, 16, WerkstoffLoader.Thorianit, Materials.Uraninite, Materials.Lepidolite, Materials.Spodumene); + new BW_WorldGenRoss128("ore.mix.ross128.carbon", true, 5, 25, 5, 4, 12, Materials.Graphite, Materials.Diamond, Materials.Coal, Materials.Graphite); + new BW_WorldGenRoss128("ore.mix.ross128.bismuth", true, 5, 80, 30, 1, 16, WerkstoffLoader.Bismuthinit, Materials.Stibnite, Materials.Bismuth, WerkstoffLoader.Bismutite); + new BW_WorldGenRoss128("ore.mix.ross128.TurmalinAlkali", true, 5, 200, 15, 4, 48, WerkstoffLoader.Olenit, WerkstoffLoader.FluorBuergerit, WerkstoffLoader.ChromoAluminoPovondrait, WerkstoffLoader.VanadioOxyDravit); + new BW_WorldGenRoss128("ore.mix.ross128.Roquesit", true, 5, 250, 3, 1, 12, WerkstoffLoader.Arsenopyrite, WerkstoffLoader.Ferberite, WerkstoffLoader.Loellingit, WerkstoffLoader.Roquesit); + new BW_WorldGenRoss128("ore.mix.ross128.Tungstate", true, 5, 250, 10, 4, 14, WerkstoffLoader.Ferberite, WerkstoffLoader.Huebnerit, WerkstoffLoader.Loellingit, Materials.Scheelite); + new BW_WorldGenRoss128("ore.mix.ross128.CopperSulfits", true, 40, 70, 80, 3, 24, WerkstoffLoader.Djurleit, WerkstoffLoader.Bornite, WerkstoffLoader.Wittichenit, Materials.Tetrahedrite); + new BW_WorldGenRoss128("ore.mix.ross128.Forsterit", true, 20, 180, 50, 2, 32, WerkstoffLoader.Forsterit, WerkstoffLoader.Fayalit, WerkstoffLoader.DescloiziteCUVO4, WerkstoffLoader.DescloiziteZNVO4); + new BW_WorldGenRoss128("ore.mix.ross128.Hedenbergit", true, 20, 180, 50, 2, 32, WerkstoffLoader.Hedenbergit, WerkstoffLoader.Fayalit, WerkstoffLoader.DescloiziteCUVO4, WerkstoffLoader.DescloiziteZNVO4); + new BW_WorldGenRoss128("ore.mix.ross128.RedZircon", true, 10, 40, 40, 3, 24, WerkstoffLoader.Fayalit,WerkstoffLoader.FuchsitAL , WerkstoffLoader.RedZircon,WerkstoffLoader.FuchsitCR); + } + + public static void init_undergroundFluidsRoss128() { + String ross128b = StatCollector.translateToLocal("planet.Ross128b"); + uo_dimensionList.SetConfigValues(ross128b, ross128b, "veryheavyoil", "liquid_extra_heavy_oil", 0, 625, 40, 5); + uo_dimensionList.SetConfigValues(ross128b, ross128b, "lava", FluidRegistry.getFluidName(FluidRegistry.LAVA), 0, 32767, 5, 5); + uo_dimensionList.SetConfigValues(ross128b, ross128b, "gas_natural_gas", "gas_natural_gas", 0, 625, 65, 5); + + } + + @Override + public boolean isGenerationAllowed(World aWorld, int aDimensionType, int aAllowedDimensionType) { + return aWorld.provider.dimensionId == Ross128SolarSystem.ross128ID; + } + +} diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128/world/worldprovider/ChunkProviderRoss128b.java b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128/world/worldprovider/ChunkProviderRoss128b.java new file mode 100644 index 0000000000..956810dd7f --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128/world/worldprovider/ChunkProviderRoss128b.java @@ -0,0 +1,178 @@ +/* + * Copyright (c) 2019 bartimaeusnek + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.bartimaeusnek.crossmod.galacticraft.planets.ross128.world.worldprovider; + +import com.github.bartimaeusnek.crossmod.galacticraft.planets.ross128.world.oregen.BW_WordGenerator; +import com.github.bartimaeusnek.crossmod.thaumcraft.util.ThaumcraftHandler; +import cpw.mods.fml.common.Loader; +import gregtech.api.objects.XSTR; +import net.minecraft.block.Block; +import net.minecraft.block.BlockFalling; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.chunk.Chunk; +import net.minecraft.world.chunk.IChunkProvider; +import net.minecraft.world.gen.ChunkProviderGenerate; +import net.minecraft.world.gen.MapGenBase; +import net.minecraft.world.gen.MapGenCaves; +import net.minecraft.world.gen.MapGenRavine; +import net.minecraft.world.gen.feature.WorldGenLakes; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.terraingen.PopulateChunkEvent; +import net.minecraftforge.event.terraingen.TerrainGen; + +import java.util.List; + +import static net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.ICE; +import static net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.LAKE; + +public class ChunkProviderRoss128b extends ChunkProviderGenerate { + XSTR rand = new XSTR(); + private BiomeGenBase[] biomesForGeneration; + private BW_WordGenerator BWOreGen = new BW_WordGenerator(); + private World worldObj; + private MapGenBase caveGenerator = new MapGenCaves(); + private MapGenBase ravineGenerator = new MapGenRavine(); + + public ChunkProviderRoss128b(World par1World, long seed, boolean mapFeaturesEnabled) { + super(par1World, seed, mapFeaturesEnabled); + worldObj = par1World; + } + + @Override + public List getPossibleCreatures(EnumCreatureType p_73155_1_, int p_73155_2_, int p_73155_3_, int p_73155_4_) { + return null; + } + + public Chunk provideChunk(int p_73154_1_, int p_73154_2_) { + this.rand.setSeed((long) p_73154_1_ * 341873128712L + (long) p_73154_2_ * 132897987541L); + Block[] ablock = new Block[65536]; + byte[] abyte = new byte[65536]; + this.func_147424_a(p_73154_1_, p_73154_2_, ablock); + this.biomesForGeneration = this.worldObj.getWorldChunkManager().loadBlockGeneratorData(this.biomesForGeneration, p_73154_1_ * 16, p_73154_2_ * 16, 16, 16); + for (int i = 0; i < biomesForGeneration.length; i++) { + BiomeGenBase biomeGenBase = biomesForGeneration[i]; + if (biomeGenBase.biomeID == BiomeGenBase.mushroomIsland.biomeID) { + this.biomesForGeneration[i] = BiomeGenBase.taiga; + } else if (biomeGenBase.biomeID == BiomeGenBase.mushroomIslandShore.biomeID) { + this.biomesForGeneration[i] = BiomeGenBase.stoneBeach; + } + if (Loader.isModLoaded("Thaumcraft")) { + if (ThaumcraftHandler.isTaintBiome(biomeGenBase.biomeID)) + this.biomesForGeneration[i] = BiomeGenBase.taiga; + } + } + this.replaceBlocksForBiome(p_73154_1_, p_73154_2_, ablock, abyte, this.biomesForGeneration); + this.caveGenerator.func_151539_a(this, this.worldObj, p_73154_1_, p_73154_2_, ablock); + this.ravineGenerator.func_151539_a(this, this.worldObj, p_73154_1_, p_73154_2_, ablock); + + Chunk chunk = new Chunk(this.worldObj, ablock, abyte, p_73154_1_, p_73154_2_); + byte[] abyte1 = chunk.getBiomeArray(); + + for (int k = 0; k < abyte1.length; ++k) { + abyte1[k] = (byte) this.biomesForGeneration[k].biomeID; + } + + chunk.generateSkylightMap(); + return chunk; + } + + @Override + public void populate(IChunkProvider p_73153_1_, int p_73153_2_, int p_73153_3_) { + BlockFalling.fallInstantly = true; + int k = p_73153_2_ * 16; + int l = p_73153_3_ * 16; + BiomeGenBase biomegenbase = this.worldObj.getBiomeGenForCoords(k + 16, l + 16); + this.rand.setSeed(this.worldObj.getSeed()); + if (p_73153_2_ % 4 == 0 || p_73153_3_ % 4 == 0) { + long i1 = this.rand.nextLong() / 2L * 2L + 1L; + long j1 = this.rand.nextLong() / 2L * 2L + 1L; + this.rand.setSeed((long) p_73153_2_ * i1 + (long) p_73153_3_ * j1 ^ this.worldObj.getSeed()); + } + boolean flag = false; + + MinecraftForge.EVENT_BUS.post(new PopulateChunkEvent.Pre(p_73153_1_, worldObj, rand, p_73153_2_, p_73153_3_, flag)); + + int k1; + int l1; + int i2; + + if (biomegenbase != BiomeGenBase.desert && biomegenbase != BiomeGenBase.desertHills && !flag && this.rand.nextInt(4) == 0 + && TerrainGen.populate(p_73153_1_, worldObj, rand, p_73153_2_, p_73153_3_, flag, LAKE)) { + k1 = k + this.rand.nextInt(16) + 8; + l1 = this.rand.nextInt(256); + i2 = l + this.rand.nextInt(16) + 8; + (new WorldGenLakes(Blocks.water)).generate(this.worldObj, this.rand, k1, l1, i2); + } + + biomegenbase.decorate(this.worldObj, this.rand, k, l); + + k += 8; + l += 8; + + boolean doGen = TerrainGen.populate(p_73153_1_, worldObj, rand, p_73153_2_, p_73153_3_, flag, ICE); + for (k1 = 0; doGen && k1 < 16; ++k1) { + for (l1 = 0; l1 < 16; ++l1) { + i2 = this.worldObj.getPrecipitationHeight(k + k1, l + l1); + + if (this.worldObj.isBlockFreezable(k1 + k, i2 - 1, l1 + l)) { + this.worldObj.setBlock(k1 + k, i2 - 1, l1 + l, Blocks.ice, 0, 2); + } + + if (this.worldObj.func_147478_e(k1 + k, i2, l1 + l, true)) { + this.worldObj.setBlock(k1 + k, i2, l1 + l, Blocks.snow_layer, 0, 2); + } + } + } + MinecraftForge.EVENT_BUS.post(new PopulateChunkEvent.Post(p_73153_1_, worldObj, rand, p_73153_2_, p_73153_3_, flag)); + + BWOreGen.generate(rand, p_73153_2_, p_73153_3_, worldObj, this, this); + + BlockFalling.fallInstantly = false; + } + + @Override + public void recreateStructures(int p_82695_1_, int p_82695_2_) { + } + + @Override + public void replaceBlocksForBiome(int p_147422_1_, int p_147422_2_, Block[] blocks, byte[] metas, BiomeGenBase[] p_147422_5_) { + super.replaceBlocksForBiome(p_147422_1_, p_147422_2_, blocks, metas, p_147422_5_); + for (int i = 0; i < blocks.length; i++) { +// if (blocks[i] == Blocks.stone) { +// blocks[i] = Ross128.Ross128bStone.getBlock(); +// metas[i] = Ross128.Ross128bStone.getMetadata(); +// }else + if (blocks[i] == Blocks.grass) { + blocks[i] = Blocks.dirt; + metas[i] = 2; + } +// else if (blocks[i] == Blocks.dirt) { +// blocks[i] = Ross128.Ross128bDirt.getBlock(); +// metas[i] = Ross128.Ross128bDirt.getMetadata(); +// } + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128/world/worldprovider/SkyProviderRoss128b.java b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128/world/worldprovider/SkyProviderRoss128b.java new file mode 100644 index 0000000000..c6785ee78b --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128/world/worldprovider/SkyProviderRoss128b.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2019 bartimaeusnek + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.bartimaeusnek.crossmod.galacticraft.planets.ross128.world.worldprovider; + +import com.github.bartimaeusnek.crossmod.BartWorksCrossmod; +import micdoodle8.mods.galacticraft.core.client.SkyProviderOverworld; +import net.minecraft.util.ResourceLocation; + +public class SkyProviderRoss128b extends SkyProviderOverworld { + + //ASM enables this texture + public static final ResourceLocation sunTex = new ResourceLocation(BartWorksCrossmod.MOD_ID + ":galacticraft/Ross128b/World/SunRoss128.png"); +} diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128/world/worldprovider/WorldProviderRoss128b.java b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128/world/worldprovider/WorldProviderRoss128b.java new file mode 100644 index 0000000000..9b2b9fc75a --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128/world/worldprovider/WorldProviderRoss128b.java @@ -0,0 +1,175 @@ +/* + * Copyright (c) 2019 bartimaeusnek + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.bartimaeusnek.crossmod.galacticraft.planets.ross128.world.worldprovider; + +import com.github.bartimaeusnek.crossmod.galacticraft.solarsystems.Ross128SolarSystem; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import micdoodle8.mods.galacticraft.api.galaxies.CelestialBody; +import micdoodle8.mods.galacticraft.api.prefab.world.gen.WorldProviderSpace; +import micdoodle8.mods.galacticraft.api.vector.Vector3; +import micdoodle8.mods.galacticraft.api.world.IExitHeight; +import micdoodle8.mods.galacticraft.api.world.ISolarLevel; +import net.minecraft.util.MathHelper; +import net.minecraft.util.Vec3; +import net.minecraft.world.biome.WorldChunkManager; +import net.minecraft.world.chunk.IChunkProvider; + +public class WorldProviderRoss128b extends WorldProviderSpace implements IExitHeight, ISolarLevel { + + @Override + public boolean canRespawnHere() { + return true; + } + + @SideOnly(Side.CLIENT) + public Vec3 getFogColor(float cy, float noidea) { + float angle = MathHelper.cos(cy * (float) Math.PI * 2.0F) * 2.0F + 0.5F; + + if (angle < 0.0F) { + angle = 0.0F; + } + + if (angle > 1.0F) { + angle = 1.0F; + } + + float red = 200 / 255f; + float green = 80 / 255f; + float blue = 0.0F; + red *= angle * 0.94F + 0.06F; + green *= angle * 0.94F + 0.06F; + return Vec3.createVectorHelper((double) red, (double) green, (double) blue); + } + + + @Override + public Vector3 getFogColor() { + //unused + return null; + } + + @Override + public float getSunBrightness(float par1) { + return super.getSunBrightness(par1) * 0.975f; + } + + @Override + public float calculateCelestialAngle(long par1, float par3) { + return super.calculateCelestialAngle(par1, par3); + } + + @Override + public Vector3 getSkyColor() { + float red = 200 / 255f; + float green = 120 / 255f; + float blue = 0.0F; + return new Vector3(red, green, blue); + } + + @Override + public boolean canRainOrSnow() { + return false; + } + + @Override + public boolean hasSunset() { + return true; + } + + @Override + public long getDayLength() { + return (long) (24000 * 9.9f); + } + + @Override + public Class<? extends IChunkProvider> getChunkProviderClass() { + return ChunkProviderRoss128b.class; + } + + @Override + public Class<? extends WorldChunkManager> getWorldChunkManagerClass() { + return WorldChunkManager.class; + } + + @Override + public float getGravity() { + return -0.0035F; + } + + @Override + public double getMeteorFrequency() { + return 0D; + } + + @Override + public double getFuelUsageMultiplier() { + return 1.35D; + } + + @Override + public boolean canSpaceshipTierPass(int tier) { + return Ross128SolarSystem.Ross128b.getTierRequirement() <= tier; + } + + @Override + public float getFallDamageModifier() { + return 1.35F; + } + + @Override + public float getSoundVolReductionAmount() { + return 1F; + } + + @Override + public float getThermalLevelModifier() { + return 0.01f; + } + + @Override + public float getWindLevel() { + return 1.35f; + } + + @Override + public CelestialBody getCelestialBody() { + return Ross128SolarSystem.Ross128b; + } + + @Override + public double getYCoordinateToTeleport() { + return 500D; + } + + @Override + public double getSolarEnergyMultiplier() { + return 1.38D; + } + + @Override + public boolean hasBreathableAtmosphere() { + return true; + } + +} diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/solarsystems/Ross128SolarSystem.java b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/solarsystems/Ross128SolarSystem.java new file mode 100644 index 0000000000..e7d539f969 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/solarsystems/Ross128SolarSystem.java @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2019 bartimaeusnek + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.bartimaeusnek.crossmod.galacticraft.solarsystems; + +import com.github.bartimaeusnek.crossmod.BartWorksCrossmod; +import com.github.bartimaeusnek.crossmod.galacticraft.UniversalTeleportType; +import com.github.bartimaeusnek.crossmod.galacticraft.planets.ross128.world.worldprovider.WorldProviderRoss128b; +import cpw.mods.fml.common.Loader; +import micdoodle8.mods.galacticraft.api.GalacticraftRegistry; +import micdoodle8.mods.galacticraft.api.galaxies.*; +import micdoodle8.mods.galacticraft.api.vector.Vector3; +import micdoodle8.mods.galacticraft.api.world.IAtmosphericGas; +import net.minecraft.util.ResourceLocation; + +import java.util.Arrays; + +public class Ross128SolarSystem { + + public static boolean enabled = true; + + public static SolarSystem Ross128System; + public static Star Ross128; + public static Planet Ross128b; + public static Moon Ross128ba; + // public static Block Ross128bBlocks; +// public static BlockMetaPair Ross128bStone,Ross128bDirt,Ross128bGrass; + public static int ross128ID = -64; + private Ross128SolarSystem() { + } + + public static void init() { + +// Ross128bBlocks = new UniversalSpaceBlocks("Ross128bBlocks",new String[]{BartWorksCrossmod.MOD_ID+":Ross128bStone",BartWorksCrossmod.MOD_ID+":Ross128bDirt",BartWorksCrossmod.MOD_ID+":Ross128bGrass"}); + + Ross128SolarSystem.Ross128System = new SolarSystem("Ross128System", "milkyWay").setMapPosition(new Vector3(-1.0D, 1.3D, 0.0D)); + Ross128SolarSystem.Ross128 = (Star) new Star("Ross128").setParentSolarSystem(Ross128SolarSystem.Ross128System).setTierRequired(-1); + Ross128SolarSystem.Ross128.setUnreachable(); + Ross128SolarSystem.Ross128.setBodyIcon(new ResourceLocation(BartWorksCrossmod.MOD_ID + ":galacticraft/Ross128b/MapObjs/Ross128.png")); + Ross128SolarSystem.Ross128System.setMainStar(Ross128SolarSystem.Ross128); + + Ross128SolarSystem.Ross128b = new Planet("Ross128b").setParentSolarSystem(Ross128SolarSystem.Ross128System); + Ross128SolarSystem.Ross128b.setRingColorRGB((0x9F) / 255f, (0x8A) / 255f, (0x79) / 255f); + Ross128SolarSystem.Ross128b.setPhaseShift(1.25F); + Ross128SolarSystem.Ross128b.setBodyIcon(new ResourceLocation(BartWorksCrossmod.MOD_ID + ":galacticraft/Ross128b/MapObjs/Ross128b.png")); + Ross128SolarSystem.Ross128b.setRelativeDistanceFromCenter(new CelestialBody.ScalableDistance(0.75F, 1.75F)); + Ross128SolarSystem.Ross128b.setRelativeOrbitTime(0.65F); + Ross128SolarSystem.Ross128b.atmosphere.addAll(Arrays.asList(IAtmosphericGas.OXYGEN, IAtmosphericGas.NITROGEN, IAtmosphericGas.ARGON)); + Ross128SolarSystem.Ross128b.setDimensionInfo(Ross128SolarSystem.ross128ID, WorldProviderRoss128b.class); + Ross128SolarSystem.Ross128b.setTierRequired(Loader.isModLoaded("galaxyspace") ? 4 : Loader.isModLoaded("GalacticraftMars") ? 3 : -1); + + Ross128SolarSystem.Ross128ba = new Moon("Ross128ba").setParentPlanet(Ross128SolarSystem.Ross128b); + Ross128SolarSystem.Ross128ba.setRelativeDistanceFromCenter(new CelestialBody.ScalableDistance(10f, 15f)).setRelativeOrbitTime(1 / 0.01F); + Ross128SolarSystem.Ross128ba.setBodyIcon(new ResourceLocation(BartWorksCrossmod.MOD_ID + ":galacticraft/Ross128b/MapObjs/Ross128ba.png")); + Ross128SolarSystem.Ross128ba.setUnreachable(); //for now + +// GameRegistry.registerBlock(Ross128bBlocks,Ross128bBlocks.getUnlocalizedName()); +// +// Ross128bStone=new BlockMetaPair(Ross128bBlocks, (byte) 0); +// Ross128bDirt=new BlockMetaPair(Ross128bBlocks, (byte) 1); +// Ross128bGrass=new BlockMetaPair(Ross128bBlocks, (byte) 2); + + GalaxyRegistry.registerPlanet(Ross128SolarSystem.Ross128b); + GalaxyRegistry.registerMoon(Ross128SolarSystem.Ross128ba); + GalaxyRegistry.registerSolarSystem(Ross128SolarSystem.Ross128System); + GalacticraftRegistry.registerTeleportType(WorldProviderRoss128b.class, new UniversalTeleportType()); + } + +} diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/thaumcraft/CustomAspects.java b/src/main/java/com/github/bartimaeusnek/crossmod/thaumcraft/CustomAspects.java new file mode 100644 index 0000000000..542501ccce --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/crossmod/thaumcraft/CustomAspects.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2019 bartimaeusnek + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.bartimaeusnek.crossmod.thaumcraft; + +import com.github.bartimaeusnek.bartworks.MainMod; + +import com.github.bartimaeusnek.crossmod.thaumcraft.util.ThaumcraftHandler; +import net.minecraft.util.ResourceLocation; + +import java.lang.reflect.Array; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; + +public class CustomAspects { +// static Constructor aspectConstructor; +// static Object TRADE; +// static Object UNIVERSE; +// static Object SCIENCE; +// static Object[] tmpArray = new Object[3]; +// static{ +// try { +// aspectConstructor = ThaumcraftHandler.AspectAdder.mAspectClass.getConstructor(String.class,int.class, Array.newInstance(ThaumcraftHandler.AspectAdder.mAspectClass,1).getClass(), ResourceLocation.class,int.class); +// tmpArray[0] = Array.newInstance(ThaumcraftHandler.AspectAdder.mAspectClass,2); +// tmpArray[1] = Array.newInstance(ThaumcraftHandler.AspectAdder.mAspectClass,2); +// tmpArray[2] = Array.newInstance(ThaumcraftHandler.AspectAdder.mAspectClass,2); +// Array.set(tmpArray[0],0,ThaumcraftHandler.AspectAdder.mAspectClass.getField("EXCHANGE").get(null)); +// Array.set(tmpArray[0],1,ThaumcraftHandler.AspectAdder.mAspectClass.getField("GREED").get(null)); +// TRADE = aspectConstructor.newInstance("Artis",0x00FF00, tmpArray[0],new ResourceLocation(MainMod.MOD_ID+":Aspects/Artis.png"),1); +// Array.set(tmpArray[1],0,ThaumcraftHandler.AspectAdder.mAspectClass.getField("MAGIC").get(null)); +// Array.set(tmpArray[1],1,ThaumcraftHandler.AspectAdder.mAspectClass.getField("ELDRITCH").get(null)); +// UNIVERSE = aspectConstructor.newInstance("Universum",0x0000FF, tmpArray[1],new ResourceLocation(MainMod.MOD_ID+":Aspects/Universum.png"),1); +// Array.set(tmpArray[2],0,ThaumcraftHandler.AspectAdder.mAspectClass.getField("MAN").get(null)); +// Array.set(tmpArray[2],1,UNIVERSE); +// SCIENCE = aspectConstructor.newInstance("Scientia",0x00FFFF, tmpArray[2],new ResourceLocation(MainMod.MOD_ID+":Aspects/Scientia.png"),1); +// } catch (NoSuchMethodException | NoSuchFieldException | IllegalAccessException | InstantiationException | InvocationTargetException e) { +// e.printStackTrace(); +// } +// } +} diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/thaumcraft/util/ThaumcraftHandler.java b/src/main/java/com/github/bartimaeusnek/crossmod/thaumcraft/util/ThaumcraftHandler.java new file mode 100644 index 0000000000..d0df9188a2 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/crossmod/thaumcraft/util/ThaumcraftHandler.java @@ -0,0 +1,117 @@ +/* + * Copyright (c) 2019 bartimaeusnek + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.bartimaeusnek.crossmod.thaumcraft.util; + +import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; +import com.github.bartimaeusnek.bartworks.system.log.DebugLog; +import com.github.bartimaeusnek.bartworks.system.material.Werkstoff; +import com.github.bartimaeusnek.bartworks.util.Pair; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.TC_Aspects; +import net.minecraft.item.ItemStack; +import net.minecraft.world.biome.BiomeGenBase; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +public class ThaumcraftHandler { + private ThaumcraftHandler(){} + + private static Integer taintBiomeID; + + public static boolean isTaintBiome(int biomeID){ + if (ThaumcraftHandler.taintBiomeID == null) { + try { + BiomeGenBase TaintBiome = (BiomeGenBase) Class.forName("thaumcraft.common.lib.world.ThaumcraftWorldGenerator").getField("biomeTaint").get(null); + return biomeID == (ThaumcraftHandler.taintBiomeID = TaintBiome.biomeID); + } catch (ClassCastException | ClassNotFoundException | NoSuchFieldException | IllegalAccessException e) { + e.printStackTrace(); + return false; + } + } + return biomeID == ThaumcraftHandler.taintBiomeID; + } + + public static class AspectAdder { + private static Class mAspectListClass; + public static Class mAspectClass; + private static Method registerObjectTag; + private static Method addToList; + private static Method getName; + + static { + try { + ThaumcraftHandler.AspectAdder.mAspectListClass = Class.forName("thaumcraft.api.aspects.AspectList"); + ThaumcraftHandler.AspectAdder.mAspectClass = Class.forName("thaumcraft.api.aspects.Aspect"); + ThaumcraftHandler.AspectAdder.addToList = ThaumcraftHandler.AspectAdder.mAspectListClass.getMethod("add", ThaumcraftHandler.AspectAdder.mAspectClass,int.class); + ThaumcraftHandler.AspectAdder.registerObjectTag = Class.forName("thaumcraft.api.ThaumcraftApi").getMethod("registerObjectTag",ItemStack.class, ThaumcraftHandler.AspectAdder.mAspectListClass); + ThaumcraftHandler.AspectAdder.getName = mAspectClass.getMethod("getName"); + } catch (ClassNotFoundException | NoSuchMethodException e) { + e.printStackTrace(); + } + } + + public static void addAspectViaBW(ItemStack stack, Pair<Object,Integer>... aspectPair) { + if (stack == null || stack.getItem() == null || stack.getUnlocalizedName() == null) + return; + try { + Object aspectList = ThaumcraftHandler.AspectAdder.mAspectListClass.newInstance(); + for (Pair a : aspectPair) { + if (ConfigHandler.debugLog) + DebugLog.log("Stack:"+ stack.getDisplayName() + " Damage:" +stack.getItemDamage() + " aspectPair: " + getName.invoke(a.getKey()) + " / " + a.getValue()); + ThaumcraftHandler.AspectAdder.addToList.invoke(aspectList, a.getKey(), a.getValue()); + } + ThaumcraftHandler.AspectAdder.registerObjectTag.invoke(null, stack, aspectList); + }catch (IllegalAccessException | InstantiationException | InvocationTargetException e){ + e.printStackTrace(); + } + } + + public static void addAspectViaGT(ItemStack stack, TC_Aspects.TC_AspectStack... tc_aspectStacks) { + try { + Object aspectList = ThaumcraftHandler.AspectAdder.mAspectListClass.newInstance(); + for (TC_Aspects.TC_AspectStack tc_aspects : tc_aspectStacks) + ThaumcraftHandler.AspectAdder.addToList.invoke(aspectList, tc_aspects.mAspect.mAspect, (int) tc_aspects.mAmount); + ThaumcraftHandler.AspectAdder.registerObjectTag.invoke(null, stack, aspectList); + }catch (IllegalAccessException | InstantiationException | InvocationTargetException e){ + e.printStackTrace(); + } + } + + public static void addAspectToAll(Werkstoff werkstoff){ + for (OrePrefixes element : OrePrefixes.values()) { + if ((werkstoff.getGenerationFeatures().toGenerate & element.mMaterialGenerationBits) != 0 && (werkstoff.getGenerationFeatures().blacklist & element.mMaterialGenerationBits) == 0) { + if (element.mMaterialAmount >= 3628800L || element == OrePrefixes.ore) { + DebugLog.log("OrePrefix: "+element.name() + " mMaterialAmount: " + element.mMaterialAmount/3628800L); + ThaumcraftHandler.AspectAdder.addAspectViaBW(werkstoff.get(element), werkstoff.getTCAspects(element == OrePrefixes.ore ? 1 : (int) (element.mMaterialAmount / 3628800L))); + } + else if (element.mMaterialAmount >= 0L) { + ThaumcraftHandler.AspectAdder.addAspectViaBW(werkstoff.get(element), new Pair<Object, Integer>(TC_Aspects.PERDITIO.mAspect, 1)); + } + } + } + } + + + } +} diff --git a/src/main/resources/assets/bartworks/lang/en_US.lang b/src/main/resources/assets/bartworks/lang/en_US.lang index fb9f53db31..d7976f0caa 100644 --- a/src/main/resources/assets/bartworks/lang/en_US.lang +++ b/src/main/resources/assets/bartworks/lang/en_US.lang @@ -55,6 +55,7 @@ BW_GlasBlocks.8.name=Colored Borosilicate Glass Block (Purple) BW_GlasBlocks.9.name=Colored Borosilicate Glass Block (Yellow) BW_GlasBlocks.10.name=Colored Borosilicate Glass Block (Light Green) BW_GlasBlocks.11.name=Colored Borosilicate Glass Block (Brown) +BW_GlasBlocks.12.name=Thorium Yttrium Glass Block tooltip.glas.0.name=Glass-Tier: tooltip.LESU.0.name=Maximum Capacity! @@ -141,4 +142,11 @@ tile.biolab.name=Bio Lab tile.biovat.name=Bacterial Vat tile.radiohatch.name=Radio Hatch tile.bw.windmill.name=Windmill -tile.manutrafo.name=Manual Trafo
\ No newline at end of file +tile.manutrafo.name=Manual Trafo + +itemGroup.bartworksMetaMaterials=BartWorks' Meta Materials + +planet.Ross128b=Ross128b +moon.Ross128ba=Ross128ba +star.Ross128=Ross128 +solarsystem.Ross128System=Ross128-System
\ No newline at end of file diff --git a/src/main/resources/assets/bartworks/textures/blocks/ThoriumYttriumGlass.png b/src/main/resources/assets/bartworks/textures/blocks/ThoriumYttriumGlass.png Binary files differnew file mode 100644 index 0000000000..5d97902f87 --- /dev/null +++ b/src/main/resources/assets/bartworks/textures/blocks/ThoriumYttriumGlass.png diff --git a/src/main/resources/assets/bartworkscrossmod/galacticraft/Ross128b/MapObjs/Ross128.png b/src/main/resources/assets/bartworkscrossmod/galacticraft/Ross128b/MapObjs/Ross128.png Binary files differnew file mode 100644 index 0000000000..18e7cd3b3c --- /dev/null +++ b/src/main/resources/assets/bartworkscrossmod/galacticraft/Ross128b/MapObjs/Ross128.png diff --git a/src/main/resources/assets/bartworkscrossmod/galacticraft/Ross128b/MapObjs/Ross128b.png b/src/main/resources/assets/bartworkscrossmod/galacticraft/Ross128b/MapObjs/Ross128b.png Binary files differnew file mode 100644 index 0000000000..85b66ad2a5 --- /dev/null +++ b/src/main/resources/assets/bartworkscrossmod/galacticraft/Ross128b/MapObjs/Ross128b.png diff --git a/src/main/resources/assets/bartworkscrossmod/galacticraft/Ross128b/MapObjs/Ross128ba.png b/src/main/resources/assets/bartworkscrossmod/galacticraft/Ross128b/MapObjs/Ross128ba.png Binary files differnew file mode 100644 index 0000000000..745d1131c3 --- /dev/null +++ b/src/main/resources/assets/bartworkscrossmod/galacticraft/Ross128b/MapObjs/Ross128ba.png diff --git a/src/main/resources/assets/bartworkscrossmod/galacticraft/Ross128b/World/SunRoss128.png b/src/main/resources/assets/bartworkscrossmod/galacticraft/Ross128b/World/SunRoss128.png Binary files differnew file mode 100644 index 0000000000..d966674e54 --- /dev/null +++ b/src/main/resources/assets/bartworkscrossmod/galacticraft/Ross128b/World/SunRoss128.png |