From e47085d1eae7fcd3f1e858c67e75bb4ed936e351 Mon Sep 17 00:00:00 2001 From: bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> Date: Sun, 7 Apr 2019 07:08:39 +0200 Subject: Giant Materials/Space Compat update +added ASM +added a shit ton of materials and got my own Materials system up and running +added Ross128 when GC is installed Signed-off-by: bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> Former-commit-id: 6e298a2662d8874903210037f7faa53d9aa83f40 --- build.gradle | 36 +- build.properties | 6 +- .../java/com/github/bartimaeusnek/ASM/BWCore.java | 79 +++ .../com/github/bartimaeusnek/ASM/BWCorePlugin.java | 63 +++ .../ASM/BWCoreStaticReplacementMethodes.java | 31 ++ .../bartimaeusnek/ASM/BWCoreTransformer.java | 212 +++++++ .../bartworks/API/WerkstoffAdderRegistry.java | 48 ++ .../github/bartimaeusnek/bartworks/MainMod.java | 6 + .../client/renderer/BW_Renderer_Block_Ores.java | 92 +++ .../bartworks/common/loaders/ItemRegistry.java | 5 +- .../bartworks/common/net/BW_Network.java | 2 +- .../bartworks/common/net/OrePacket.java | 95 ++++ .../BW_TileEntity_ExperimentalFloodGate.java | 206 +++++++ .../bartworks/neiHandler/BW_NEI_OreHandler.java | 233 ++++++++ .../bartworks/neiHandler/NEI_BW_Config.java | 1 + .../system/material/BW_MetaGeneratedOreTE.java | 101 ++++ .../system/material/BW_MetaGeneratedOre_Item.java | 67 +++ .../system/material/BW_MetaGenerated_Items.java | 172 ++++++ .../system/material/BW_MetaGenerated_Ores.java | 180 ++++++ .../bartworks/system/material/Werkstoff.java | 390 +++++++++++++ .../bartworks/system/material/WerkstoffLoader.java | 616 +++++++++++++++++++++ .../bartimaeusnek/bartworks/util/BioCulture.java | 8 +- .../github/bartimaeusnek/bartworks/util/Pair.java | 74 +++ .../bartimaeusnek/crossmod/BartWorksCrossmod.java | 65 +++ .../crossmod/galacticraft/GalacticraftProxy.java | 84 +++ .../galacticraft/UniversalTeleportType.java | 81 +++ .../galacticraft/blocks/UniversalSpaceBlocks.java | 46 ++ .../galacticraft/creativetabs/SpaceTab.java | 45 ++ .../ross128/world/oregen/BW_WordGenerator.java | 126 +++++ .../ross128/world/oregen/BW_WorldGenRoss128.java | 195 +++++++ .../world/worldprovider/ChunkProviderRoss128b.java | 186 +++++++ .../world/worldprovider/SkyProviderRoss128b.java | 33 ++ .../world/worldprovider/WorldProviderRoss128b.java | 178 ++++++ .../galacticraft/solarsystems/Ross128.java | 91 +++ .../resources/assets/bartworks/lang/en_US.lang | 9 +- .../galacticraft/Ross128b/MapObjs/Ross128.png | Bin 0 -> 934 bytes .../galacticraft/Ross128b/MapObjs/Ross128b.png | Bin 0 -> 1048 bytes .../galacticraft/Ross128b/MapObjs/Ross128ba.png | Bin 0 -> 990 bytes .../galacticraft/Ross128b/World/SunRoss128.png | Bin 0 -> 1260 bytes 39 files changed, 3854 insertions(+), 8 deletions(-) create mode 100644 src/main/java/com/github/bartimaeusnek/ASM/BWCore.java create mode 100644 src/main/java/com/github/bartimaeusnek/ASM/BWCorePlugin.java create mode 100644 src/main/java/com/github/bartimaeusnek/ASM/BWCoreStaticReplacementMethodes.java create mode 100644 src/main/java/com/github/bartimaeusnek/ASM/BWCoreTransformer.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/API/WerkstoffAdderRegistry.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/BW_Renderer_Block_Ores.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/net/OrePacket.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BW_TileEntity_ExperimentalFloodGate.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_OreHandler.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedOreTE.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedOre_Item.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Items.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Ores.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/material/Werkstoff.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/material/WerkstoffLoader.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/util/Pair.java create mode 100644 src/main/java/com/github/bartimaeusnek/crossmod/BartWorksCrossmod.java create mode 100644 src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/GalacticraftProxy.java create mode 100644 src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/UniversalTeleportType.java create mode 100644 src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/blocks/UniversalSpaceBlocks.java create mode 100644 src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/creativetabs/SpaceTab.java create mode 100644 src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128/world/oregen/BW_WordGenerator.java create mode 100644 src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128/world/oregen/BW_WorldGenRoss128.java create mode 100644 src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128/world/worldprovider/ChunkProviderRoss128b.java create mode 100644 src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128/world/worldprovider/SkyProviderRoss128b.java create mode 100644 src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128/world/worldprovider/WorldProviderRoss128b.java create mode 100644 src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/solarsystems/Ross128.java create mode 100644 src/main/resources/assets/bartworkscrossmod/galacticraft/Ross128b/MapObjs/Ross128.png create mode 100644 src/main/resources/assets/bartworkscrossmod/galacticraft/Ross128b/MapObjs/Ross128b.png create mode 100644 src/main/resources/assets/bartworkscrossmod/galacticraft/Ross128b/MapObjs/Ross128ba.png create mode 100644 src/main/resources/assets/bartworkscrossmod/galacticraft/Ross128b/World/SunRoss128.png diff --git a/build.gradle b/build.gradle index ae10e3f9a3..f2592e24f6 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,31 @@ 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:1.7.10-3.1.1:api" } //task getGregTech(type: Download) { @@ -102,6 +129,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..8045287543 100644 --- a/build.properties +++ b/build.properties @@ -22,9 +22,9 @@ mc_version=1.7.10 majorUpdate=0 -minorUpdate=3 -buildNumber=24 -APIVersion=4 +minorUpdate=4 +buildNumber=1 +APIVersion=5 ic2.version=2.2.828-experimental gregtech.version=5.09.32.36 gregtech.jenkinsbuild=143 \ No newline at end of file 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..bddf66ae5e --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/ASM/BWCore.java @@ -0,0 +1,79 @@ +/* + * 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 net.minecraftforge.common.config.Configuration; +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) { + Configuration asmconfighandler = new Configuration(event.getSuggestedConfigurationFile()); + 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 List getDependants() { + List ret = new ArrayList(); + 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..becd28f524 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/ASM/BWCorePlugin.java @@ -0,0 +1,63 @@ +/* + * 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.IFMLLoadingPlugin; + +import java.util.Map; + +@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"; + + @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 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..0d98c72564 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/ASM/BWCoreStaticReplacementMethodes.java @@ -0,0 +1,31 @@ +/* + * 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.galacticraft.planets.ross128.world.worldprovider.WorldProviderRoss128b; +import net.minecraft.client.multiplayer.WorldClient; + +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..0a6f44712d --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/ASM/BWCoreTransformer.java @@ -0,0 +1,212 @@ +/* + * 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.Opcodes; +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 boolean obfs = false; + 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[] shouldTransform = ArrayUtils.toPrimitive(new Boolean[BWCoreTransformer.CLASSESBEEINGTRANSFORMED.length],true); + + @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])) + return BWCoreTransformer.transform(i,basicClass); + } + return basicClass; + } + + public static byte[] transform(int id, byte[] basicClass) { + if (!BWCoreTransformer.shouldTransform[id]) + 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 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(Opcodes.ACC_PUBLIC, name_deObfs, + /*obfs ? dsc_Obfs :*/ dsc_deObfs, + name_deObfs+dsc_deObfs.substring(0,dsc_deObfs.length()-1), + new String[0] + ); + InsnList insnList = new InsnList(); + insnList.add(new InsnNode(Opcodes.ICONST_0)); + insnList.add(new InsnNode(Opcodes.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_Obfs = "func_73155_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 ((methods.get(i).name.equalsIgnoreCase(obfs?name_Obfs:name_deObfs) && methods.get(i).desc.equalsIgnoreCase(obfs?dsc_Obfs:dsc_deObfs))||(methods.get(i).name.equalsIgnoreCase(!obfs?name_Obfs:name_deObfs) && methods.get(i).desc.equalsIgnoreCase(!obfs?dsc_Obfs:dsc_deObfs))) { + BWCore.BWCORE_LOG.info("Found "+(name_deObfs)+"! Patching!"); + MethodNode toPatch = methods.get(i); + InsnList insnList = new InsnList(); + insnList.add(new InsnNode(Opcodes.ACONST_NULL)); + insnList.add(new InsnNode(Opcodes.ARETURN)); + toPatch.instructions = insnList; + toPatch.maxStack = 1; + toPatch.maxLocals = 5; + methods.set(i, toPatch); + break; + } + } + break; + } + case 2:{ + String name_deObfs = "renderSky"; + String name_Obfs = "func_72714_a"; + String dsc_deObfs = "(F)V"; + BWCore.BWCORE_LOG.info("Could find: "+CLASSESBEEINGTRANSFORMED[id]); + for (int i = 0; i < methods.size(); i++) { + MethodNode toPatch = methods.get(i); + if ((toPatch.name.equalsIgnoreCase(name_Obfs) || toPatch.name.equalsIgnoreCase(name_deObfs)) && methods.get(i).desc.equalsIgnoreCase(dsc_deObfs)) { + BWCore.BWCORE_LOG.info("Found "+(name_deObfs)+"! Patching!"); + InsnList nu = new InsnList(); + LabelNode[] LabelNodes = { new LabelNode(),new LabelNode()}; + for (int j = 0; j < toPatch.instructions.size(); j++) { + if (toPatch.instructions.get(j) instanceof LineNumberNode && ((LineNumberNode) toPatch.instructions.get(j)).line == 1190) { + nu.add(toPatch.instructions.get(j)); + nu.add(new VarInsnNode(ALOAD, 0)); + nu.add(new FieldInsnNode(GETFIELD, "net/minecraft/client/renderer/RenderGlobal", "theWorld", "Lnet/minecraft/client/multiplayer/WorldClient;")); + nu.add(new FieldInsnNode(GETFIELD, "net/minecraft/client/multiplayer/WorldClient", "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", "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", "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", "renderEngine", "Lnet/minecraft/client/renderer/texture/TextureManager;")); + nu.add(new FieldInsnNode(GETSTATIC, "net/minecraft/client/renderer/RenderGlobal", "locationSunPng", "Lnet/minecraft/util/ResourceLocation;")); + nu.add(new MethodInsnNode(INVOKEVIRTUAL, "net/minecraft/client/renderer/texture/TextureManager", "bindTexture", "(Lnet/minecraft/util/ResourceLocation;)V", false)); + nu.add(LabelNodes[1]); + j+=5; + +// if (toPatch.instructions.get(j) instanceof LineNumberNode && ((LineNumberNode) toPatch.instructions.get(j)).line == 308) { +// nu.add(toPatch.instructions.get(j)); +// nu.add(new VarInsnNode(ALOAD, 0)); +// nu.add(new TypeInsnNode(INSTANCEOF, "com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128/world/worldprovider/SkyProviderRoss128b")); +// nu.add(new JumpInsnNode(IFEQ, LabelNodes[0])); +// nu.add(new VarInsnNode(ALOAD, 0)); +// nu.add(new FieldInsnNode(GETFIELD, "micdoodle8/mods/galacticraft/core/client/SkyProviderOverworld", "minecraft", "Lnet/minecraft/client/Minecraft;")); +// nu.add(new FieldInsnNode(GETFIELD, "net/minecraft/client/Minecraft", "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", "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, "micdoodle8/mods/galacticraft/core/client/SkyProviderOverworld", "minecraft", "Lnet/minecraft/client/Minecraft;")); +// nu.add(new FieldInsnNode(GETFIELD, "net/minecraft/client/Minecraft", "renderEngine", "Lnet/minecraft/client/renderer/texture/TextureManager;")); +// nu.add(new FieldInsnNode(GETSTATIC, "micdoodle8/mods/galacticraft/core/client/SkyProviderOverworld", "sunTexture", "Lnet/minecraft/util/ResourceLocation;")); +// nu.add(new MethodInsnNode(INVOKEVIRTUAL, "net/minecraft/client/renderer/texture/TextureManager", "bindTexture", "(Lnet/minecraft/util/ResourceLocation;)V", false)); +// nu.add(LabelNodes[1]); +// j+=5; + } else { + 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]); +// try { +// OutputStream os = new FileOutputStream(new File("C:/test/"+CLASSESBEEINGTRANSFORMED[id]+".class")); +// os.write(classWriter.toByteArray()); +// } catch (FileNotFoundException e) { +// e.printStackTrace(); +// } catch (IOException e) { +// e.printStackTrace(); +// } + + return ret; + } + return basicClass; + } + + +} 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..29c45e5074 --- /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 WerkstoffAdderRegistry(){} + + static final WerkstoffAdderRegistry INSTANCE = new WerkstoffAdderRegistry(); + + final HashSet toRun= new HashSet<>(); + + public static final WerkstoffAdderRegistry getINSTANCE() { + return INSTANCE; + } + + public static void addWerkstoffAdder(Runnable adder){ + INSTANCE.toRun.add(adder); + } + + @Override + public 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..461d8e0f81 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java @@ -35,7 +35,9 @@ 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.system.material.WerkstoffLoader; import com.github.bartimaeusnek.bartworks.util.BW_Util; +import com.github.bartimaeusnek.crossmod.galacticraft.planets.ross128.world.oregen.BW_WordGenerator; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.Mod; @@ -104,6 +106,7 @@ public final class MainMod { BioCultureLoader bioCultureLoader = new BioCultureLoader(); bioCultureLoader.run(); } + WerkstoffLoader.INSTANCE.init(); } @Mod.EventHandler @@ -113,6 +116,7 @@ public final class MainMod { new LoaderRegistry().run(); if (ConfigHandler.BioLab) new BioLabLoader().run(); + WerkstoffLoader.INSTANCE.runInit(); } @Mod.EventHandler @@ -121,6 +125,8 @@ public final class MainMod { if (ConfigHandler.BioLab) new GTNHBlocks().run(); BioObjectAdder.regenerateBioFluids(); + new BW_WordGenerator(); + WerkstoffLoader.INSTANCE.run(); } @Mod.EventHandler 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..1105ae39ea --- /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/loaders/ItemRegistry.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/ItemRegistry.java index c945a19d14..c4b70a6a54 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; @@ -72,6 +73,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( @@ -146,7 +148,8 @@ 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); 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 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 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..74f8aad3ee --- /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/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..86b9ed0e20 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BW_TileEntity_ExperimentalFloodGate.java @@ -0,0 +1,206 @@ +/* + * 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.MainMod; +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 { + + private long ticks = 0; + recursiveBelowCheck check = new recursiveBelowCheck(); + 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 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 { + + int called = -1; + private final List hashset = new ArrayList(); + + public int getCalled() { + return this.called; + } + + public void setCalled(int called) { + this.called = called; + } + + public synchronized List 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/neiHandler/BW_NEI_OreHandler.java b/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_OreHandler.java new file mode 100644 index 0000000000..1c76a84a05 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_OreHandler.java @@ -0,0 +1,233 @@ +/* + * 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_WorldGenRoss128; +import cpw.mods.fml.common.event.FMLInterModComms; +import gregtech.api.GregTech_API; +import gregtech.common.GT_Worldgen_GT_Ore_Layer; +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; + +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 void loadCraftingRecipes(String outputId, Object... results) { + if (outputId.equalsIgnoreCase("quickanddirtyneihandler")){ + for (int i = 0; i < Werkstoff.werkstoffHashMap.values().size(); i++) { + ItemStack result = new ItemStack(WerkstoffLoader.BWOres,1,i); + 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 getOtherStacks() { + ArrayList ret = new ArrayList<>(); + for (int i = 0; i < GT_Worldgen_GT_Ore_Layer.sList.size(); i++) { + if (BW_WorldGenRoss128.sList.get(i) instanceof BW_WorldGenRoss128) { + int baseMeta = result.getItemDamage(); + BW_WorldGenRoss128 worldGen = ((BW_WorldGenRoss128) BW_WorldGenRoss128.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); + } + } + } else super.loadCraftingRecipes(outputId, results); + } + + @Override + public void drawExtras(int recipe) { + + 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 getOtherStacks() { + ArrayList ret = new ArrayList<>(); + for (int i = 0; i < GT_Worldgen_GT_Ore_Layer.sList.size(); i++) { + if (BW_WorldGenRoss128.sList.get(i) instanceof BW_WorldGenRoss128) { + int baseMeta = result.getItemDamage(); + BW_WorldGenRoss128 worldGen = ((BW_WorldGenRoss128) BW_WorldGenRoss128.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 "OreShit"; + } +} 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/system/material/BW_MetaGeneratedOreTE.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedOreTE.java new file mode 100644 index 0000000000..1db9bcb8aa --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedOreTE.java @@ -0,0 +1,101 @@ +/* + * 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 gregtech.common.blocks.GT_Packet_Ores; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.Packet; +import net.minecraft.network.play.server.S35PacketUpdateTileEntity; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.IBlockAccess; +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 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 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 ArrayList getDrops(Block aDroppedOre) { + ArrayList 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..4ebf9a47b8 --- /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..dfd192863f --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Items.java @@ -0,0 +1,172 @@ +/* + * 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 com.github.bartimaeusnek.bartworks.util.ChatColorHelper; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.GregTech_API; +import gregtech.api.enums.ItemList; +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 java.util.List; + +import static com.github.bartimaeusnek.bartworks.system.material.Werkstoff.werkstoffHashMap; + +public class BW_MetaGenerated_Items extends GT_MetaGenerated_Item { + + private final short aNumToGen= (short) werkstoffHashMap.size(); + + protected final OrePrefixes orePrefixes; + + 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.getFeatures().toGenerate & 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(),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.getFeatures().toGenerate & 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; + } + + public static final CreativeTabs metaTab = new CreativeTabs("bartworksMetaMaterials") { + + @Override + public Item getTabIconItem() { + return new ItemStack(Blocks.iron_ore).getItem(); + } + }; +} 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..599b93dbf9 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Ores.java @@ -0,0 +1,180 @@ +/* + * 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.GregTech_API; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GT_LanguageManager; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.common.blocks.GT_Block_Ores_Abstract; +import gregtech.common.blocks.GT_TileEntity_Ores; +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 BW_MetaGenerated_Ores(Material p_i45386_1_, Class 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.getFeatures().toGenerate & 0b1000) == 0) + continue; + GT_ModHandler.addValuableOre(this, w.getmID(), 1); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + "." + w.getmID() +".name", w.getDefaultName() + OrePrefixes.ore.mLocalizedMaterialPost); + GT_OreDictUnificator.registerOre(OrePrefixes.ore + w.getDefaultName(), new ItemStack(this, 1, w.getmID())); + } + } + } + + 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 static ThreadLocal mTemporaryTileEntity = new ThreadLocal(); + + public void breakBlock(World aWorld, int aX, int aY, int aZ, Block par5, int par6) { + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if ((tTileEntity instanceof BW_MetaGeneratedOreTE)) { + mTemporaryTileEntity.set((BW_MetaGeneratedOreTE) tTileEntity); + } + super.breakBlock(aWorld, aX, aY, aZ, par5, par6); + aWorld.removeTileEntity(aX, aY, aZ); + } + + public ArrayList 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.getFeatures().toGenerate & 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(); + } + + 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; + } + } +} 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..7522c40205 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/Werkstoff.java @@ -0,0 +1,390 @@ +/* + * 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.MurmurHash3; +import com.github.bartimaeusnek.bartworks.util.Pair; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.SubTag; +import gregtech.api.enums.TextureSet; +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 { + + public static final LinkedHashSet werkstoffHashSet = new LinkedHashSet<>(); + private static final HashSet idHashSet = new HashSet<>(); + + public static final LinkedHashMap werkstoffHashMap = new LinkedHashMap<>(); + + public static final Werkstoff.Stats default_null_stats = new Werkstoff.Stats(); + public static final Werkstoff.Features default_null_features = new Werkstoff.Features(); + public static final Werkstoff default_null_Werkstoff = new Werkstoff(new short[3], "_NULL", "Default null Werkstoff", default_null_stats, Werkstoff.Types.UNDEFINED, default_null_features, -1, TextureSet.SET_NONE); + + private final List mOreByProducts = new ArrayList(); + + public Pair>> getContents() { + int ret = 0; + switch (this.type) { + case COMPOUND: + case BIOLOGICAL: { + for (int i = 0; i < contents.toArray().length; i++) { + ret += ((Pair) contents.toArray()[i]).getValue(); + } + break; + } + default: + ret = 1; + break; + } + return new Pair<>(ret, this.contents); + } + + private final LinkedHashSet> contents = new LinkedHashSet<>(); + private byte[] rgb = new byte[3]; + private String defaultName; + + public int getNoOfByProducts(){ + return mOreByProducts.size(); + } + + public ItemStack getOreByProduct(int aNumber, OrePrefixes prefixes) { + if (mOreByProducts.size() == 0) + return null; + if (aNumber < 0) + aNumber = mOreByProducts.size() + aNumber; + while (aNumber >= mOreByProducts.size()) + aNumber--; + Object o = mOreByProducts.get(aNumber); + if (o == null || o.equals(default_null_Werkstoff) || o.equals(Materials._NULL)) + return null; + 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; + } + + private String toolTip; + private Fluid fluid; + private Fluid gas; + private Werkstoff.Stats stats; + private Werkstoff.Types type; + private Werkstoff.Features features; + + public Werkstoff.Stats getStats() { + return this.stats; + } + + public short getmID() { + return this.mID; + } + + private short mID; + + public Werkstoff.Features getFeatures() { + return this.features; + } + + public TextureSet getTexSet() { + return this.texSet; + } + + private TextureSet texSet; + + public Werkstoff(short[] rgba, String defaultName, Werkstoff.Types type, Werkstoff.Features features, int mID, TextureSet texSet, List oreByProduct, Pair... contents) { + this(rgba,defaultName,Types.getDefaultStatForType(type),type,features,mID,texSet,oreByProduct,contents); + } + + public Werkstoff(short[] rgba, String defaultName, Werkstoff.Stats stats, Werkstoff.Types type, Werkstoff.Features features, int mID, TextureSet texSet, List oreByProduct, Pair... contents) { + this(rgba,defaultName,"",stats,type,features,mID,texSet,contents); + this.mOreByProducts.addAll(oreByProduct); + } + + public Werkstoff(short[] rgba, String defaultName, Werkstoff.Stats stats, Werkstoff.Types type, Werkstoff.Features features, int mID, TextureSet texSet, Pair... contents) { + this(rgba,defaultName,"",stats,type,features,mID,texSet,contents); + } + public Werkstoff(short[] rgba, String defaultName, String toolTip, Werkstoff.Stats stats, Werkstoff.Types type, Werkstoff.Features features, int mID, TextureSet texSet, List oreByProduct, Pair... contents) { + this(rgba, defaultName, toolTip, stats, type, features, mID, texSet, contents); + this.mOreByProducts.addAll(oreByProduct); + } + + public Werkstoff(short[] rgba, String defaultName, String toolTip, Werkstoff.Stats stats, Werkstoff.Types type, Werkstoff.Features features, int mID, TextureSet texSet, Pair... contents) { + + if (idHashSet.contains((short) mID)) + throw new UnsupportedOperationException("ID ("+mID+") is already in use!"); + + if (type == null) + type = Werkstoff.Types.UNDEFINED; + + this.defaultName=defaultName; + + this.type = type; + this.mID = (short) mID; + this.features=features; + this.setRgb(rgba); + this.contents.addAll(Arrays.asList(contents)); + this.toolTip=""; + if (toolTip.isEmpty()) { + for (Pair 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 p : contents) { + if (p.getKey() instanceof Materials) { + tmpprotons += ((Materials) p.getKey()).getProtons()* p.getValue(); + } + } + this.stats = stats.setProtons(tmpprotons); + + long tmpmass=0; + for (Pair p : contents) { + if (p.getKey() instanceof Materials) { + tmpmass += ((Materials) p.getKey()).getMass()* p.getValue(); + } + } + this.stats = stats.setMass(tmpmass); + + this.texSet=texSet; + werkstoffHashSet.add(this); + werkstoffHashMap.put(this.mID,this); + } + + 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) (rgb[0]+128), (short) (rgb[1]+128), (short) (rgb[2]+128),0}; + } + + HashSet subtags = new HashSet<>(); + + @Override + public boolean contains(SubTag subTag) { + for (Pair p: contents) + if (p.getKey().contains(subTag)) + return true; + if (subtags.contains(subTag)) + return true; + return false; + } + + @Override + public ISubTagContainer add(SubTag... subTags) { + subtags.addAll(Arrays.asList(subTags)); + return this; + } + + @Override + public boolean remove(SubTag subTag) { + return subtags.remove(subTag); + } + + public ItemStack get(OrePrefixes prefixes){ + return WerkstoffLoader.getCorresopndingItemStack(prefixes,this); + } + + public ItemStack get(OrePrefixes prefixes, int amount){ + return WerkstoffLoader.getCorresopndingItemStack(prefixes,this, amount); + } + + public static class Features { + //logic gate shit + /* + dust 1 + metal 10 + gem 100 + ore 1000 + */ + public byte toGenerate = 0b0001001; + + public boolean hasGems(){ + return (toGenerate & 4) != 0; + } + + public Features onlyDust(){ + toGenerate = (byte) (1); + return this; + } + + public Features addGems(){ + toGenerate = (byte) (toGenerate | 0x4); + return this; + } + + + } + + + public static class Stats { + + @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(quality).putInt(boilingPoint).putInt(meltingPoint).putLong(protons).putLong(neutrons).putLong(electrons).putLong(mass).array(),0,49,31); + } + + int boilingPoint; + int meltingPoint; + long protons; + long neutrons; + long electrons; + long mass; + + + + public Stats setMass(long mass) { + this.mass = protons; + return this; + } + public Stats setProtons(long protons) { + this.protons = protons; + return this; + } + + //logic gate shit + byte quality = ~0b111111; + + public boolean isSublimation() { + return (quality&0b1) == 0b1; + } + + public boolean isToxic() { + return (quality>>1&0b1) == 0b1; + } + + public boolean isRadioactive() { + return (quality>>2&0b1) == 0b1; + } + + public boolean isBlastFurnace() { + return (quality>>3&0b1) == 0b1; + } + + public boolean isElektrolysis() { + return (quality>>4&0b1) == 0b1; + } + + public boolean isCentrifuge() { + return (quality>>5&0b1) == 0b1; + } + + public Werkstoff.Stats setSublimation(boolean sublimation) { + if(sublimation) + quality= (byte) (quality|0b000001); + else + quality= (byte) (quality&0b111110); + return this; + } + + public Werkstoff.Stats setToxic(boolean toxic) { + if(toxic) + quality= (byte) (quality|0b000010); + else + quality= (byte) (quality&0b111101); + return this; + } + + public Werkstoff.Stats setRadioactive(boolean radioactive) { + if(radioactive) + quality= (byte) (quality|0b000100); + else + quality= (byte) (quality&0b111011); + return this; + } + + public Werkstoff.Stats setBlastFurnace(boolean blastFurnace) { + if(blastFurnace) + quality= (byte) (quality|0b001000); + else + quality= (byte) (quality&0b110111); + return this; + } + + public Werkstoff.Stats setElektrolysis(boolean elektrolysis) { + if(elektrolysis) + quality= (byte) (quality|0b010000); + else + quality= (byte) (quality&0b101111); + return this; + } + + public Werkstoff.Stats setCentrifuge(boolean centrifuge) { + if(centrifuge) + quality= (byte) (quality|0b100000); + else + quality=(byte) (quality&0b011111); + return this; + } + } + + public enum Types { + MATERIAL, COMPOUND, MIXTURE, BIOLOGICAL, UNDEFINED; + public static Stats getDefaultStatForType(Types T){ + switch (T){ + case COMPOUND: case BIOLOGICAL: return new Stats().setElektrolysis(true); + case MIXTURE: return new Stats().setCentrifuge(true); + default:return new Stats(); + } + } + } + +} 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..89f69948fa --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/WerkstoffLoader.java @@ -0,0 +1,616 @@ +/* + * 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.util.Pair; +import cpw.mods.fml.client.registry.RenderingRegistry; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.ProgressManager; +import cpw.mods.fml.common.registry.GameRegistry; +import gregtech.GT_Mod; +import gregtech.api.enums.*; +import gregtech.api.interfaces.ISubTagContainer; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +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 WerkstoffLoader INSTANCE = new WerkstoffLoader(); + + public boolean registered = false; + + public void init(){ + } + + public static HashMap items = new HashMap<>(); + public static Block BWOres; + + public static final Werkstoff Bismutite = new Werkstoff( + new short[]{255, 233, 0, 0}, + "Bismutite", + Werkstoff.Types.COMPOUND, + new Werkstoff.Features().addGems(), + 1, + TextureSet.SET_FLINT, + Arrays.asList(Materials.Bismuth), + new Pair(Materials.Bismuth, 2), + new Pair(Materials.Oxygen, 2), + new Pair(Materials.CarbonDioxide, 2) + ); + public static final Werkstoff Bismuthinit = new Werkstoff( + new short[]{192, 192, 192, 0}, + "Bismuthinite", + Werkstoff.Types.COMPOUND, + new Werkstoff.Features(), + 2, + TextureSet.SET_METALLIC, + Arrays.asList(Materials.Bismuth, Materials.Sulfur), + new Pair(Materials.Bismuth, 2), + new Pair(Materials.Sulfur, 3) + ); + + public static final Werkstoff CyclosilicateSi6O18 = new Werkstoff( + new short[]{255,255,255,0}, + "CycloHexaSilicate", + "(Si6O18)", + Werkstoff.Types.getDefaultStatForType(Werkstoff.Types.COMPOUND), + Werkstoff.Types.COMPOUND, + new Werkstoff.Features().onlyDust(), + 3, + TextureSet.SET_DULL, + new Pair(Materials.Silicon, 6), + new Pair(Materials.Oxygen, 18) + ); + + public static final Werkstoff Borat = new Werkstoff( + new short[]{255,255,255,0}, + "Borate", + "(BO3)", + Werkstoff.Types.getDefaultStatForType(Werkstoff.Types.COMPOUND), + Werkstoff.Types.COMPOUND, + new Werkstoff.Features().onlyDust(), + 4, + TextureSet.SET_DULL, + new Pair(Materials.Boron, 1), + new Pair(Materials.Oxygen, 3) + ); + + //Na Fe3+3 Al6 (Si6O18) (BO3)3 O3 F + public static final Werkstoff FluorBuergerit = new Werkstoff( + new short[]{0x20,0x20,0x20,0}, + "Fluor-Buergerit", + Werkstoff.Types.COMPOUND, + new Werkstoff.Features().addGems(), + 5, + TextureSet.SET_RUBY, + Arrays.asList(Materials.Sodium,Materials.Boron,Materials.Silicon), + new Pair(Materials.Sodium, 1), + new Pair(Materials.Iron, 3), + new Pair(Materials.Aluminium, 6), + new Pair(CyclosilicateSi6O18, 1), + new Pair(Borat, 3), + new Pair(Materials.Oxygen, 1), + new Pair(Materials.Fluorine, 1) + ); + + public static final Werkstoff AluminiumMagnesite = new Werkstoff( + new short[]{255,255,255,0}, + "AluminiumMagnesite", + "(Al4Mg2)", + Werkstoff.Types.getDefaultStatForType(Werkstoff.Types.COMPOUND), + Werkstoff.Types.COMPOUND, + new Werkstoff.Features().onlyDust(), + 6, + TextureSet.SET_DULL, + new Pair(Materials.Aluminium, 4), + new Pair(Materials.Magnesium, 2) + ); + +// public static final Werkstoff Hydroxide = new Werkstoff( +// new short[]{255,255,255,0}, +// "Hydroxide", +// "(OH)", +// new Werkstoff.Stats(), +// Werkstoff.Types.COMPOUND, +// new Werkstoff.Features().onlyDust(), +// 7, +// TextureSet.SET_DULL, +// new Pair(Materials.Aluminium, 4), +// new Pair(Materials.Magnesium, 2) +// ); + + 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.Features().addGems(), + 7, + TextureSet.SET_RUBY, + Arrays.asList(Materials.Sodium,Materials.Boron,Materials.Silicon), + //Na Cr3 (Al4Mg2) (Si6O18) (BO3)3 (OH)3 O + new Pair(Materials.Sodium, 1), + new Pair(Materials.Chrome, 3), + new Pair(AluminiumMagnesite,1), + new Pair(CyclosilicateSi6O18, 1), + new Pair(Borat, 3), + new Pair(Materials.Oxygen, 4), + new Pair(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.Features().addGems(), + 8, + TextureSet.SET_RUBY, + Arrays.asList(Materials.Sodium,Materials.Boron,Materials.Silicon), + //Na Cr3 (Al4Mg2) (Si6O18) (BO3)3 (OH)3 O + new Pair(Materials.Sodium, 1), + new Pair(Materials.Vanadium, 3), + new Pair(AluminiumMagnesite,1), + new Pair(CyclosilicateSi6O18, 1), + new Pair(Borat, 3), + new Pair(Materials.Oxygen, 4), + new Pair(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.Features().addGems(), + 9, + TextureSet.SET_RUBY, + Arrays.asList(Materials.Sodium,Materials.Boron,Materials.Silicon), + //Na Cr3 (Al4Mg2) (Si6O18) (BO3)3 (OH)3 O + new Pair(Materials.Sodium, 1), + new Pair(Materials.Aluminium, 9), + new Pair(Materials.Silicon, 6), + new Pair(Borat, 3), + new Pair(Materials.Oxygen, 22), + new Pair(Materials.Hydrogen, 1) + ); + + public static final Werkstoff Arsenopyrite = new Werkstoff( + new short[]{0xB0, 0xB0, 0xB0, 0}, + "Arsenopyrite", + Werkstoff.Types.COMPOUND, + new Werkstoff.Features(), + 10, + TextureSet.SET_METALLIC, + Arrays.asList(Materials.Sulfur, Materials.Arsenic,Materials.Iron), + new Pair(Materials.Iron, 1), + new Pair(Materials.Arsenic, 1), + new Pair(Materials.Sulfur, 1) + ); + + public static final Werkstoff Ferberite = new Werkstoff( + new short[]{0xB0, 0xB0, 0xB0, 0}, + "Ferberite", + Werkstoff.Types.COMPOUND, + new Werkstoff.Features(), + 11, + TextureSet.SET_METALLIC, + Arrays.asList(Materials.Iron, Materials.Tungsten), + new Pair(Materials.Iron, 1), + new Pair(Materials.Tungsten, 1), + new Pair(Materials.Oxygen, 3) + ); + + public static final Werkstoff Loellingit = new Werkstoff( + new short[]{0xD0, 0xD0, 0xD0, 0}, + "Loellingite", + Werkstoff.Types.COMPOUND, + new Werkstoff.Features(), + 12, + TextureSet.SET_METALLIC, + Arrays.asList(Materials.Iron, Materials.Arsenic), + new Pair(Materials.Iron, 1), + new Pair(Materials.Arsenic, 2) + ); + + public static final Werkstoff Roquesit= new Werkstoff( + new short[]{0xA0, 0xA0, 0xA0, 0}, + "Roquesite", + Werkstoff.Types.COMPOUND, + new Werkstoff.Features(), + 13, + TextureSet.SET_METALLIC, + Arrays.asList(Materials.Copper, Materials.Sulfur), + new Pair(Materials.Copper, 1), + new Pair(Materials.Indium, 1), + new Pair(Materials.Sulfur, 2) + ); + public static final Werkstoff Bornite= new Werkstoff( + new short[]{0x97, 0x66, 0x2B, 0}, + "Bornite", + Werkstoff.Types.COMPOUND, + new Werkstoff.Features(), + 14, + TextureSet.SET_METALLIC, + Arrays.asList(Materials.Copper,Materials.Iron, Materials.Sulfur), + new Pair(Materials.Copper, 5), + new Pair(Materials.Iron, 1), + new Pair(Materials.Sulfur, 4) + ); + public static final Werkstoff Wittichenit= new Werkstoff( + Materials.Copper.mRGBa, + "Wittichenite", + Werkstoff.Types.COMPOUND, + new Werkstoff.Features(), + 15, + TextureSet.SET_METALLIC, + Arrays.asList(Materials.Copper,Materials.Bismuth, Materials.Sulfur), + new Pair(Materials.Copper, 5), + new Pair(Materials.Bismuth, 1), + new Pair(Materials.Sulfur, 4) + ); + public static final Werkstoff Djurleit = new Werkstoff( + new short[]{0x60, 0x60, 0x60, 0}, + "Djurleite", + Werkstoff.Types.COMPOUND, + new Werkstoff.Features(), + 16, + TextureSet.SET_METALLIC, + Arrays.asList(Materials.Copper,Materials.Copper, Materials.Sulfur), + new Pair(Materials.Copper, 31), + new Pair(Materials.Sulfur, 16) + ); + + public static final Werkstoff Huebnerit = new Werkstoff( + new short[]{0x80, 0x60, 0x60, 0}, + "Huebnerite", + Werkstoff.Types.COMPOUND, + new Werkstoff.Features(), + 17, + TextureSet.SET_METALLIC, + Arrays.asList(Materials.Manganese,Materials.Tungsten), + new Pair(Materials.Manganese, 1), + new Pair(Materials.Tungsten, 1), + new Pair(Materials.Oxygen, 3) + ); + + public static final Werkstoff Thorianit = new Werkstoff( + new short[]{0x30, 0x30, 0x30, 0}, + "Thorianit", + Werkstoff.Types.COMPOUND, + new Werkstoff.Features(), + 18, + TextureSet.SET_METALLIC, + Arrays.asList(Materials.Thorium), + new Pair(Materials.Thorium, 1), + new Pair(Materials.Oxygen, 2) + ); + + + + + public void runInit() { + WerkstoffAdderRegistry.getINSTANCE().run(); + addSubTags(); + addItemsForGeneration(); + } + @Override + public void run(){ + if (!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()); + + for (short i = 0; i < Werkstoff.werkstoffHashMap.size(); i++) { + Werkstoff werkstoff = Werkstoff.werkstoffHashMap.get(i); + if (werkstoff == null || werkstoff.getmID() < 0) { + progressBar.step(""); + continue; + } + addDustRecipes(werkstoff); + addGemRecipes(werkstoff); + addOreRecipes(werkstoff); + addCrushedRecipes(werkstoff); + progressBar.step(werkstoff.getDefaultName()); + } + 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!"); + registered=true; + } + } + + private void addSubTags(){ + for (Werkstoff W : Werkstoff.werkstoffHashMap.values()){ + for (Pair pair : W.getContents().getValue().toArray(new Pair[0])){ + if (pair.getKey() instanceof Materials && ((Materials)pair.getKey()) == Materials.Neodymium){ + W.add(SubTag.ELECTROMAGNETIC_SEPERATION_NEODYMIUM); + break; + } + else if (pair.getKey() instanceof Materials && ((Materials)pair.getKey()) == Materials.Iron){ + W.add(SubTag.ELECTROMAGNETIC_SEPERATION_IRON); + break; + } + else if (pair.getKey() instanceof Materials && ((Materials)pair.getKey()) == Materials.Gold){ + W.add(SubTag.ELECTROMAGNETIC_SEPERATION_GOLD); + break; + } + } + if (W.getFeatures().hasGems()){ + W.add(SubTag.CRYSTAL); + W.add(SubTag.CRYSTALLISABLE); + } + } + + + } + + private void addItemsForGeneration(){ + int toGenerateGlobal = 0b0000000; + + for (Werkstoff werkstoff : Werkstoff.werkstoffHashSet) + toGenerateGlobal = (toGenerateGlobal | werkstoff.getFeatures().toGenerate); + + if ((toGenerateGlobal & 0b1) != 0) { + items.put(dust, new BW_MetaGenerated_Items(dust)); + items.put(dustTiny, new BW_MetaGenerated_Items(dustTiny)); + items.put(dustSmall, new BW_MetaGenerated_Items(dustSmall)); + } + if ((toGenerateGlobal & 0b10) != 0) { + items.put(ingot, new BW_MetaGenerated_Items(ingot)); + + } + if ((toGenerateGlobal & 0b100) != 0) { + items.put(gem, new BW_MetaGenerated_Items(gem)); + items.put(gemChipped, new BW_MetaGenerated_Items(gemChipped)); + items.put(gemExquisite, new BW_MetaGenerated_Items(gemExquisite)); + items.put(gemFlawed, new BW_MetaGenerated_Items(gemFlawed)); + items.put(gemFlawless, new BW_MetaGenerated_Items(gemFlawless)); + } + if ((toGenerateGlobal & 0b1000) != 0) { + if (FMLCommonHandler.instance().getSide().isClient()) + RenderingRegistry.registerBlockHandler(BW_Renderer_Block_Ores.INSTANCE); + GameRegistry.registerTileEntity(BW_MetaGeneratedOreTE.class,"bw.blockoresTE"); + BWOres = new BW_MetaGenerated_Ores(Material.rock,BW_MetaGeneratedOreTE.class,"bw.blockores"); + GameRegistry.registerBlock(BWOres,BW_MetaGeneratedOre_Item.class,"bw.blockores.01"); + + items.put(crushed, new BW_MetaGenerated_Items(crushed)); + items.put(crushedPurified, new BW_MetaGenerated_Items(crushedPurified)); + items.put(crushedCentrifuged, new BW_MetaGenerated_Items(crushedCentrifuged)); + items.put(dustPure, new BW_MetaGenerated_Items(dustPure)); + items.put(dustImpure, new BW_MetaGenerated_Items(dustImpure)); + } + } + + private void addGemRecipes(Werkstoff werkstoff){ + if (werkstoff.getFeatures().hasGems()) { + GT_Values.RA.addForgeHammerRecipe(getCorresopndingItemStack(crushedCentrifuged, werkstoff), getCorresopndingItemStack(dust, werkstoff), 10, 16); + GT_ModHandler.addPulverisationRecipe(getCorresopndingItemStack(crushedCentrifuged, werkstoff), + getCorresopndingItemStack(dust, werkstoff), + werkstoff.getOreByProduct(-1, gem), + 10, true); + + GT_Values.RA.addSifterRecipe( + getCorresopndingItemStack(crushedPurified, werkstoff), + new ItemStack[]{ + getCorresopndingItemStack(gemExquisite, werkstoff), + getCorresopndingItemStack(gemFlawless, werkstoff), + getCorresopndingItemStack(gem, werkstoff), + getCorresopndingItemStack(gemFlawed, werkstoff), + getCorresopndingItemStack(gemChipped, werkstoff), + 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_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); + } + } + + private void addDustRecipes(Werkstoff werkstoff){ + if ((werkstoff.getFeatures().toGenerate & 0b1) != 0){ + + List flOutputs = new ArrayList<>(); + List stOutputs = new ArrayList<>(); + HashMap> tracker = new HashMap<>(); + int cells = 0; + + if (werkstoff.getStats().isElektrolysis() || werkstoff.getStats().isCentrifuge()) { + for (Pair 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 = 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]), (Object)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]), (Object)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); + } + + GT_ModHandler.addShapelessCraftingRecipe(getCorresopndingItemStack(dust,werkstoff), 0,new Object[]{ + getCorresopndingItemStack(dustTiny,werkstoff), + getCorresopndingItemStack(dustTiny,werkstoff), + getCorresopndingItemStack(dustTiny,werkstoff), + getCorresopndingItemStack(dustTiny,werkstoff), + getCorresopndingItemStack(dustTiny,werkstoff), + getCorresopndingItemStack(dustTiny,werkstoff), + getCorresopndingItemStack(dustTiny,werkstoff), + getCorresopndingItemStack(dustTiny,werkstoff), + getCorresopndingItemStack(dustTiny,werkstoff) + }); + GT_ModHandler.addShapelessCraftingRecipe(getCorresopndingItemStack(dust,werkstoff),0,new Object[]{ + getCorresopndingItemStack(dustSmall,werkstoff), + getCorresopndingItemStack(dustSmall,werkstoff), + getCorresopndingItemStack(dustSmall,werkstoff), + getCorresopndingItemStack(dustSmall,werkstoff) + }); + GT_ModHandler.addCraftingRecipe(getCorresopndingItemStack(dustSmall,werkstoff,4),new Object[]{ + " T ",'T',getCorresopndingItemStack(dust,werkstoff) + }); + GT_ModHandler.addCraftingRecipe(getCorresopndingItemStack(dustTiny,werkstoff,9),new Object[]{ + "T ",'T',getCorresopndingItemStack(dust,werkstoff) + }); + if ((werkstoff.getFeatures().toGenerate & 2) != 0 && !werkstoff.getStats().isBlastFurnace()) { + GT_ModHandler.addSmeltingRecipe(getCorresopndingItemStack(dust, werkstoff), getCorresopndingItemStack(ingot, werkstoff)); + GT_ModHandler.addSmeltingRecipe(getCorresopndingItemStack(dustTiny, werkstoff), getCorresopndingItemStack(nugget, werkstoff)); + } + + 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); + } + + } + } + + private void addOreRecipes(Werkstoff werkstoff){ + if ((werkstoff.getFeatures().toGenerate & 2) != 0 && !werkstoff.getStats().isBlastFurnace()) + GT_ModHandler.addSmeltingRecipe(getCorresopndingItemStack(ore,werkstoff),getCorresopndingItemStack(ingot,werkstoff)); + + if ((werkstoff.getFeatures().toGenerate & 0b1000) != 0) { + GT_Values.RA.addForgeHammerRecipe(werkstoff.get(ore), werkstoff.getFeatures().hasGems() ? werkstoff.get(gem) : werkstoff.get(crushed), 16, 10); + GT_ModHandler.addPulverisationRecipe( + werkstoff.get(ore), + GT_Utility.mul(2L, werkstoff.get(crushed)), + werkstoff.getOreByProduct(0,dust), werkstoff.getNoOfByProducts() > 0 ? 10 : 0, Materials.Stone.getDust(1), 50, true); + } + } + + private void addCrushedRecipes(Werkstoff werkstoff) { + if ((werkstoff.getFeatures().toGenerate & 0b1000) == 0 || (werkstoff.getFeatures().toGenerate & 0b1) == 0) + return; + + 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(OrePrefixes.dust, Materials.Stone, 1L)); + GT_ModHandler.addThermalCentrifugeRecipe(werkstoff.get(crushed), (int) Math.min(5000L, Math.abs(werkstoff.getStats().protons * 20L)), new Object[]{werkstoff.get(crushedCentrifuged), werkstoff.getOreByProduct(1, dustTiny), GT_OreDictUnificator.get(OrePrefixes.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); + + 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(OrePrefixes.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(OrePrefixes.dust, Materials.Stone, 1L), new int[]{10000, 7000, 4000}, 800, 8); + 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.ELECTROMAGNETIC_SEPERATION_GOLD)) + GT_Values.RA.addElectromagneticSeparatorRecipe(werkstoff.get(dustPure), werkstoff.get(dust), GT_OreDictUnificator.get(OrePrefixes.dustSmall, Materials.Gold, 1L), GT_OreDictUnificator.get(OrePrefixes.nugget, Materials.Gold, 1L), new int[]{10000, 4000, 2000}, 400, 24); + if (werkstoff.contains(SubTag.ELECTROMAGNETIC_SEPERATION_IRON)) + GT_Values.RA.addElectromagneticSeparatorRecipe(werkstoff.get(dustPure), werkstoff.get(dust), GT_OreDictUnificator.get(OrePrefixes.dustSmall, Materials.Iron, 1L), GT_OreDictUnificator.get(OrePrefixes.nugget, Materials.Iron, 1L), new int[]{10000, 4000, 2000}, 400, 24); + if (werkstoff.contains(SubTag.ELECTROMAGNETIC_SEPERATION_NEODYMIUM)) + GT_Values.RA.addElectromagneticSeparatorRecipe(werkstoff.get(dustPure), werkstoff.get(dust), GT_OreDictUnificator.get(OrePrefixes.dustSmall, Materials.Neodymium, 1L), GT_OreDictUnificator.get(OrePrefixes.nugget, Materials.Neodymium, 1L), new int[]{10000, 4000, 2000}, 400, 24); + + } + + public static ItemStack getCorresopndingItemStack(OrePrefixes orePrefixes, Werkstoff werkstoff) { + return getCorresopndingItemStack(orePrefixes,werkstoff,1); + } + + public static ItemStack getCorresopndingItemStack(OrePrefixes orePrefixes, Werkstoff werkstoff, int amount) { + if (orePrefixes == ore) + return new ItemStack(BWOres,amount,werkstoff.getmID()); + return new ItemStack(items.get(orePrefixes), amount, werkstoff.getmID()).copy(); + } + +} \ No newline at end of file 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..08e4f3269c 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; @@ -35,7 +36,7 @@ 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 BIO_CULTURE_ARRAY_LIST = new ArrayList(); public static final BioCulture NULLCULTURE = BioCulture.createAndRegisterBioCulture(Color.BLUE, "", BioPlasmid.NULLPLASMID,BioDNA.NULLDNA, false); //fallback NULL culture, also Blue =) @@ -197,4 +198,9 @@ public class BioCulture extends BioData { 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); } + + @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/Pair.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/Pair.java new file mode 100644 index 0000000000..f61eee3c3c --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/Pair.java @@ -0,0 +1,74 @@ +/* + * 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 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]; + } +} 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..58d9f52d66 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/crossmod/BartWorksCrossmod.java @@ -0,0 +1,65 @@ +/* + * 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 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 net.minecraftforge.common.config.Configuration; +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); + + } + + @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..ccc11bef56 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/GalacticraftProxy.java @@ -0,0 +1,84 @@ +/* + * 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.Ross128; +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.*; + +public class GalacticraftProxy { + private GalacticraftProxy(){} + static Configuration gtConf; + public static GT_UO_DimensionList uo_dimensionList = new GT_UO_DimensionList(); + + public static void preInit(FMLPreInitializationEvent e){ + if (FMLCommonHandler.instance().getSide().isServer() || FMLCommonHandler.instance().getEffectiveSide().isServer()){ + serverpreInit(e); + } else { + clientpreInit(e); + } + commonpreInit(e); + } + + private static void serverpreInit(FMLPreInitializationEvent e){ + + } + private static void clientpreInit(FMLPreInitializationEvent e){ + } + private static void commonpreInit(FMLPreInitializationEvent e){ + Configuration c = new Configuration(e.getSuggestedConfigurationFile()); + gtConf = new Configuration(new File(new File(e.getModConfigurationDirectory(), "GregTech"), "GregTech.cfg")); + uo_dimensionList.getConfig(gtConf, "undergroundfluid"); + init_undergroundFluidsRoss128(); + gtConf.save(); + Ross128.ross128ID=c.get("System","DimID",-64,"The Dim ID for Ross128").getInt(-64); + init_OresRoss128(); + } + + public static void init(FMLInitializationEvent e){ + if (FMLCommonHandler.instance().getSide().isServer() || FMLCommonHandler.instance().getEffectiveSide().isServer()){ + serverInit(e); + } else { + clientInit(e); + } + commonInit(e); + } + + private static void serverInit(FMLInitializationEvent e){ + + } + private static void clientInit(FMLInitializationEvent e){ + + } + private static void commonInit(FMLInitializationEvent e){ + Ross128.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..91c66768ab --- /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..49a1bf9475 --- /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"); + + public static SpaceTab getInstance(){ + return instance; + } + + private SpaceTab(String label) { + super(label); + } + + @Override + public Item getTabIconItem() { + return ItemRegistry.DESTRUCTOPACK; + } +} 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..e222ab8c9c --- /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... +// GameRegistry.registerWorldGenerator(this, 1073741823); + } + + public synchronized void generate(Random aRandom, int aX, int aZ, World aWorld, IChunkProvider aChunkGenerator, IChunkProvider aChunkProvider) { + new WorldGenContainer(aX * 16, aZ * 16, aWorld.provider.dimensionId, aWorld, aChunkGenerator, aChunkProvider).run(); + } + + public static class WorldGenContainer implements Runnable { + public int mX; + public int mZ; + public final int mDimensionType; + public final World mWorld; + public final IChunkProvider mChunkGenerator; + public final IChunkProvider mChunkProvider; + public static HashSet mGenerated = new HashSet<>(2000); + + 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 mWorld.checkChunksExist(xCenter - 16, 0, zCenter - 16, xCenter + 16, 0, zCenter + 16); + } + + public XSTR getRandom(int xChunk, int zChunk) { + long worldSeed = 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 = getVeinCenterCoordinate(mX >> 4); + int zCenter = getVeinCenterCoordinate(mZ >> 4); + Random random = getRandom(xCenter, zCenter); + xCenter <<= 4; + zCenter <<= 4; + ChunkCoordIntPair centerChunk = new ChunkCoordIntPair(xCenter, zCenter); + if (!mGenerated.contains(centerChunk) && surroundingChunksLoaded(xCenter, zCenter)) { + mGenerated.add(centerChunk); + if ((BW_WorldGenRoss128.sWeight > 0) && (BW_WorldGenRoss128.sList.size() > 0)) { + boolean temp = true; + int tRandomWeight; + for (int i = 0; (i < 256) && (temp); i++) { + tRandomWeight = random.nextInt(BW_WorldGenRoss128.sWeight); + for (GT_Worldgen tWorldGen : BW_WorldGenRoss128.sList) { + tRandomWeight -= ((BW_WorldGenRoss128) 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..3a1c3c2c95 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128/world/oregen/BW_WorldGenRoss128.java @@ -0,0 +1,195 @@ +/* + * 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 com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader; +import com.github.bartimaeusnek.crossmod.galacticraft.planets.ross128.world.worldprovider.WorldProviderRoss128b; +import com.github.bartimaeusnek.crossmod.galacticraft.solarsystems.Ross128; +import cpw.mods.fml.common.event.FMLInitializationEvent; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import gregtech.GT_Mod; +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.util.StatCollector; +import net.minecraft.world.World; +import net.minecraft.world.chunk.IChunkProvider; +import net.minecraftforge.common.config.Configuration; +import net.minecraftforge.fluids.FluidRegistry; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +import static com.github.bartimaeusnek.crossmod.galacticraft.GalacticraftProxy.uo_dimensionList; + +/** + * Original GT File Stripped and adjusted to work with this mod + */ +public class BW_WorldGenRoss128 extends GT_Worldgen { + + private static final boolean logOregenRoss128 = false; + + 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.Graphene); + 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.magnetite", true, 60, 180, 50, 2, 32, Materials.Magnetite, Materials.Magnetite, Materials.Iron, Materials.VanadiumMagnetite); + new BW_WorldGenRoss128("ore.mix.ross128.gold", true, 30, 60, 50, 2, 32, Materials.Magnetite, Materials.Magnetite, Materials.VanadiumMagnetite, Materials.Gold); + new BW_WorldGenRoss128("ore.mix.ross128.iron", true, 10, 40, 40, 3, 24, Materials.BrownLimonite, Materials.YellowLimonite, Materials.BandedIron, Materials.Malachite); + } + + 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,80000,5,5); + uo_dimensionList.SetConfigValues(ross128b,ross128b,"gas_natural_gas", "gas_natural_gas",0,625,65,5); + + } + + public byte bwOres = 0b0000; + public int mMinY,mWeight,mDensity,mSize,mMaxY,mPrimaryMeta,mSecondaryMeta,mBetweenMeta,mSporadicMeta; + public static int sWeight; + public static final List sList = new ArrayList<>(); + + 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, 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 (mEnabled) + sWeight += this.mWeight; + + if (top instanceof Werkstoff) + bwOres = (byte) (bwOres | 0b1000); + if (bottom instanceof Werkstoff) + bwOres = (byte) (bwOres | 0b0100); + if (between instanceof Werkstoff) + bwOres = (byte) (bwOres | 0b0010); + if (sprinkled instanceof Werkstoff) + bwOres = (byte) (bwOres | 0b0001); + + short aPrimary = top instanceof Materials ? + (short) ((Materials)top).mMetaItemSubID: + top instanceof Werkstoff ? + (short) ((Werkstoff)top).getmID(): + 0 + ; + short aSecondary = bottom instanceof Materials ? + (short) ((Materials)bottom).mMetaItemSubID: + bottom instanceof Werkstoff ? + (short) ((Werkstoff)bottom).getmID(): + 0 + ; + short aBetween = between instanceof Materials ? + (short) ((Materials)between).mMetaItemSubID: + between instanceof Werkstoff ? + (short) ((Werkstoff)between).getmID(): + 0 + ; + short aSporadic = sprinkled instanceof Materials ? + (short) ((Materials)sprinkled).mMetaItemSubID: + sprinkled instanceof Werkstoff ? + (short) ((Werkstoff)sprinkled).getmID(): + 0 + ; + this.mPrimaryMeta = (short) aPrimary; + this.mSecondaryMeta = (short) aSecondary; + this.mBetweenMeta = (short) aBetween; + this.mSporadicMeta = (short) aSporadic; + + } + + @Override + public boolean isGenerationAllowed(World aWorld, int aDimensionType, int aAllowedDimensionType) { + return aWorld.provider instanceof WorldProviderRoss128b; + } + + @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) { + 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)) { + 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) { + 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)) { + setOreBlock(aWorld, tX, tMinY - 1 + aRandom.nextInt(7), tZ, this.mSporadicMeta, false); + } + } + } + + if (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 == mSporadicMeta && (bwOres & 0b0001) != 0) || (aMetaData == mBetweenMeta && (bwOres & 0b0010) != 0) || (aMetaData == mPrimaryMeta && (bwOres & 0b1000) != 0) || (aMetaData == mSecondaryMeta && (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/worldprovider/ChunkProviderRoss128b.java b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128/world/worldprovider/ChunkProviderRoss128b.java new file mode 100644 index 0000000000..1f9ce77b26 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128/world/worldprovider/ChunkProviderRoss128b.java @@ -0,0 +1,186 @@ +/* + * 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 gregtech.api.GregTech_API; +import gregtech.api.objects.XSTR; +import gregtech.api.world.GT_Worldgen_Ore; +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.biome.BiomeGenForest; +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.WorldGenCanopyTree; +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 { + private BiomeGenBase[] biomesForGeneration; + + private BW_WordGenerator BWOreGen = new BW_WordGenerator(); + XSTR rand = new XSTR(); + 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 super.getPossibleCreatures(p_73155_1_, p_73155_2_, p_73155_3_, p_73155_4_); + } + + 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; + } + } + 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..a8039d0282 --- /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..c2b1e9d68a --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128/world/worldprovider/WorldProviderRoss128b.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.solarsystems.Ross128; +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 getChunkProviderClass() { + return ChunkProviderRoss128b.class; + } + + @Override + public Class 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 Ross128.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 Ross128.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/Ross128.java b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/solarsystems/Ross128.java new file mode 100644 index 0000000000..5ce0d75e27 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/solarsystems/Ross128.java @@ -0,0 +1,91 @@ +/* + * 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.blocks.UniversalSpaceBlocks; +import com.github.bartimaeusnek.crossmod.galacticraft.planets.ross128.world.worldprovider.WorldProviderRoss128b; +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.registry.GameRegistry; +import micdoodle8.mods.galacticraft.api.GalacticraftRegistry; +import micdoodle8.mods.galacticraft.api.galaxies.*; +import micdoodle8.mods.galacticraft.api.prefab.core.BlockMetaPair; +import micdoodle8.mods.galacticraft.api.vector.Vector3; +import micdoodle8.mods.galacticraft.api.world.IAtmosphericGas; +import micdoodle8.mods.galacticraft.core.GalacticraftCore; +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; + +import java.util.Arrays; + +public class Ross128 { + + private Ross128(){} + + 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; + public static void init() { + +// Ross128bBlocks = new UniversalSpaceBlocks("Ross128bBlocks",new String[]{BartWorksCrossmod.MOD_ID+":Ross128bStone",BartWorksCrossmod.MOD_ID+":Ross128bDirt",BartWorksCrossmod.MOD_ID+":Ross128bGrass"}); + + Ross128System = new SolarSystem("Ross128System", "milkyWay").setMapPosition(new Vector3(-1.0D, 1.3D, 0.0D)); + Ross128 = (Star) new Star("Ross128").setParentSolarSystem(Ross128System).setTierRequired(-1); + Ross128.setUnreachable(); + Ross128.setBodyIcon(new ResourceLocation(BartWorksCrossmod.MOD_ID+":galacticraft/Ross128b/MapObjs/Ross128.png")); + Ross128System.setMainStar(Ross128); + + Ross128b = new Planet("Ross128b").setParentSolarSystem(Ross128System); + Ross128b.setRingColorRGB((0x9F)/255f, (0x8A)/255f, (0x79)/255f); + Ross128b.setPhaseShift(1.25F); + Ross128b.setBodyIcon(new ResourceLocation(BartWorksCrossmod.MOD_ID+":galacticraft/Ross128b/MapObjs/Ross128b.png")); + Ross128b.setRelativeDistanceFromCenter(new CelestialBody.ScalableDistance(0.75F, 1.75F)); + Ross128b.setRelativeOrbitTime(0.65F); + Ross128b.atmosphere.addAll(Arrays.asList(IAtmosphericGas.OXYGEN,IAtmosphericGas.NITROGEN,IAtmosphericGas.ARGON)); + Ross128b.setDimensionInfo(ross128ID, WorldProviderRoss128b.class); + Ross128b.setTierRequired(Loader.isModLoaded("galaxyspace") ? 4 : Loader.isModLoaded("GalacticraftMars") ? 3 : -1); + + Ross128ba = new Moon("Ross128ba").setParentPlanet(Ross128b); + Ross128ba.setRelativeDistanceFromCenter(new CelestialBody.ScalableDistance(10f,15f)).setRelativeOrbitTime(1 / 0.01F); + Ross128ba.setBodyIcon(new ResourceLocation(BartWorksCrossmod.MOD_ID+":galacticraft/Ross128b/MapObjs/Ross128ba.png")); + 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(Ross128b); + GalaxyRegistry.registerMoon(Ross128ba); + GalaxyRegistry.registerSolarSystem(Ross128System); + GalacticraftRegistry.registerTeleportType(WorldProviderRoss128b.class, new UniversalTeleportType()); + } + +} diff --git a/src/main/resources/assets/bartworks/lang/en_US.lang b/src/main/resources/assets/bartworks/lang/en_US.lang index fb9f53db31..773214b1f7 100644 --- a/src/main/resources/assets/bartworks/lang/en_US.lang +++ b/src/main/resources/assets/bartworks/lang/en_US.lang @@ -141,4 +141,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/bartworkscrossmod/galacticraft/Ross128b/MapObjs/Ross128.png b/src/main/resources/assets/bartworkscrossmod/galacticraft/Ross128b/MapObjs/Ross128.png new file mode 100644 index 0000000000..18e7cd3b3c Binary files /dev/null and b/src/main/resources/assets/bartworkscrossmod/galacticraft/Ross128b/MapObjs/Ross128.png differ diff --git a/src/main/resources/assets/bartworkscrossmod/galacticraft/Ross128b/MapObjs/Ross128b.png b/src/main/resources/assets/bartworkscrossmod/galacticraft/Ross128b/MapObjs/Ross128b.png new file mode 100644 index 0000000000..85b66ad2a5 Binary files /dev/null and b/src/main/resources/assets/bartworkscrossmod/galacticraft/Ross128b/MapObjs/Ross128b.png differ diff --git a/src/main/resources/assets/bartworkscrossmod/galacticraft/Ross128b/MapObjs/Ross128ba.png b/src/main/resources/assets/bartworkscrossmod/galacticraft/Ross128b/MapObjs/Ross128ba.png new file mode 100644 index 0000000000..745d1131c3 Binary files /dev/null and b/src/main/resources/assets/bartworkscrossmod/galacticraft/Ross128b/MapObjs/Ross128ba.png differ diff --git a/src/main/resources/assets/bartworkscrossmod/galacticraft/Ross128b/World/SunRoss128.png b/src/main/resources/assets/bartworkscrossmod/galacticraft/Ross128b/World/SunRoss128.png new file mode 100644 index 0000000000..d966674e54 Binary files /dev/null and b/src/main/resources/assets/bartworkscrossmod/galacticraft/Ross128b/World/SunRoss128.png differ -- cgit