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 --- .../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 37 files changed, 3816 insertions(+), 4 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 (limited to 'src/main') 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); +