diff options
author | bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> | 2019-09-03 08:56:00 +0200 |
---|---|---|
committer | bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> | 2019-09-03 08:56:00 +0200 |
commit | e353a91980806712ef011d542bfb2c64f9f7ba26 (patch) | |
tree | 754d12fcff18e9aefcc3267dbf7faeb16f5e9b48 | |
parent | c9fa2faffad73b649c662cefd630aac65f2c7367 (diff) | |
download | GT5-Unofficial-e353a91980806712ef011d542bfb2c64f9f7ba26.tar.gz GT5-Unofficial-e353a91980806712ef011d542bfb2c64f9f7ba26.tar.bz2 GT5-Unofficial-e353a91980806712ef011d542bfb2c64f9f7ba26.zip |
final 5.1 commit
-changed Loading behavior
-added oredict for glassblocks
-fixed crash when galacticraft.planets is not installed, but only galacticraft.core
-started to work on 5.2 content,loading of which is disabled
Signed-off-by: bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com>
Former-commit-id: b3f46ee3a6870d9ae9c35a725fe69f6bebae07ca
13 files changed, 766 insertions, 60 deletions
diff --git a/build.properties b/build.properties index 73e4cadd19..7daca1c59d 100644 --- a/build.properties +++ b/build.properties @@ -23,8 +23,8 @@ mc_version=1.7.10 majorUpdate=0 minorUpdate=5 -buildNumber=0_pre14 -APIVersion=7 +buildNumber=1 +APIVersion=8 ic2.version=2.2.828-experimental gregtech.version=5.09.32.36 gregtech.jenkinsbuild=143 diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java b/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java index bee7086eb9..9a5e86b39c 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java @@ -25,6 +25,7 @@ package com.github.bartimaeusnek.bartworks; import com.github.bartimaeusnek.bartworks.API.API_REFERENCE; import com.github.bartimaeusnek.bartworks.API.BioObjectAdder; +import com.github.bartimaeusnek.bartworks.API.BioVatLogicAdder; import com.github.bartimaeusnek.bartworks.client.ClientEventHandler.TooltipEventHandler; import com.github.bartimaeusnek.bartworks.client.creativetabs.BioTab; import com.github.bartimaeusnek.bartworks.client.creativetabs.GT2Tab; @@ -79,6 +80,7 @@ import java.util.*; import static com.github.bartimaeusnek.bartworks.common.tileentities.multis.GT_TileEntity_ElectricImplosionCompressor.eicMap; import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.*; +import static gregtech.api.enums.GT_Values.VN; @Mod( modid = MainMod.MOD_ID, name = MainMod.NAME, version = MainMod.VERSION, @@ -161,8 +163,13 @@ public final class MainMod { @Mod.EventHandler public void postInit(FMLPostInitializationEvent postinit) { NetworkRegistry.INSTANCE.registerGuiHandler(MainMod.instance, MainMod.GH); - if (ConfigHandler.BioLab) + if (ConfigHandler.BioLab) { new GTNHBlocks().run(); + for (Map.Entry<BioVatLogicAdder.BlockMetaPair, Byte>pair : BioVatLogicAdder.BioVatGlass.getGlassMap().entrySet()){ + GT_OreDictUnificator.registerOre("blockGlass"+VN[pair.getValue()],new ItemStack(pair.getKey().getBlock(),1,pair.getKey().getaByte())); + } + } + BioObjectAdder.regenerateBioFluids(); if (ConfigHandler.newStuff) { if (ConfigHandler.experimentalThreadedLoader) diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/BeforeGTPreload.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/BeforeGTPreload.java new file mode 100644 index 0000000000..de0e57a138 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/BeforeGTPreload.java @@ -0,0 +1,128 @@ +/* + * 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.loaders; + +import com.github.bartimaeusnek.bartworks.MainMod; +import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; +import com.github.bartimaeusnek.bartworks.common.items.BW_ItemBlocks; +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 cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.LoadController; +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.ModContainer; +import cpw.mods.fml.common.registry.GameRegistry; +import gregtech.api.util.GT_OreDictUnificator; +import ic2.core.Ic2Items; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraftforge.oredict.OreDictionary; +import org.apache.commons.lang3.reflect.FieldUtils; + +import java.lang.reflect.Field; + +import static com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler.newStuff; + +public class BeforeGTPreload implements Runnable { + @Override + public void run() { + Field fieldModController = FieldUtils.getDeclaredField(Loader.class,"modController",true); + LoadController modController = null; + try { + modController = (LoadController) fieldModController.get(Loader.instance()); + } catch (IllegalAccessException e) { + e.printStackTrace(); + FMLCommonHandler.instance().exitJava(-1,true); + } + ModContainer bartworks = null; + ModContainer gregtech = null; + assert modController != null; + for (ModContainer mod : modController.getActiveModList()){ + if (mod.getModId().equals(MainMod.MOD_ID)) { + bartworks = mod; + } + if (mod.getModId().equals("gregtech")) + gregtech=mod; + if (bartworks!= null && gregtech != null) + break; + } + if (bartworks == null || gregtech == null) + FMLCommonHandler.instance().exitJava(-1,true); + Field activeContainer = FieldUtils.getDeclaredField(LoadController.class,"activeContainer",true); + + try { + activeContainer.set(modController,bartworks); + } catch (IllegalAccessException e) { + e.printStackTrace(); + FMLCommonHandler.instance().exitJava(-1,true); + } + + if (newStuff) { + GameRegistry.registerBlock(ItemRegistry.bw_glasses[0], BW_ItemBlocks.class, "BW_GlasBlocks"); + GameRegistry.registerBlock(ItemRegistry.bw_fake_glasses, "BW_FakeGlasBlock"); + GameRegistry.registerBlock(ItemRegistry.BW_BLOCKS[2], BW_ItemBlocks.class, "BW_Machinery_Casings"); + GameRegistry.registerItem(ItemRegistry.LEATHER_ROTOR, "BW_LeatherRotor"); + GameRegistry.registerItem(ItemRegistry.WOOL_ROTOR, "BW_WoolRotor"); + GameRegistry.registerItem(ItemRegistry.PAPER_ROTOR, "BW_PaperRotor"); + GameRegistry.registerItem(ItemRegistry.COMBINED_ROTOR, "BW_CombinedRotor"); + GameRegistry.registerItem(ItemRegistry.CRAFTING_PARTS, "craftingParts"); + GameRegistry.registerTileEntity(BW_RotorBlock.class, "BWRotorBlockTE"); + GameRegistry.registerBlock(ItemRegistry.ROTORBLOCK, BW_ItemBlocks.class, "BWRotorBlock"); + GameRegistry.registerTileEntity(BW_TileEntity_HeatedWaterPump.class, "BWHeatedWaterPumpTE"); + GameRegistry.registerBlock(ItemRegistry.PUMPBLOCK, BW_ItemBlocks.class, "BWHeatedWaterPumpBlock"); + GameRegistry.registerItem(ItemRegistry.PUMPPARTS, "BWPumpParts"); + GameRegistry.registerItem(ItemRegistry.WINDMETER, "BW_SimpleWindMeter"); + GameRegistry.registerTileEntity(BW_TileEntity_ExperimentalFloodGate.class, "BWExpReversePump"); + GameRegistry.registerBlock(ItemRegistry.EXPPUMP, BW_ItemBlocks.class, "BWExpReversePumpBlock"); + } + + //GT2 stuff + GameRegistry.registerBlock(ItemRegistry.BW_BLOCKS[0], BW_ItemBlocks.class, "BW_ItemBlocks"); + GameRegistry.registerBlock(ItemRegistry.BW_BLOCKS[1], BW_ItemBlocks.class, "GT_LESU_CASING"); + if (ConfigHandler.teslastaff) + GameRegistry.registerItem(ItemRegistry.TESLASTAFF, ItemRegistry.TESLASTAFF.getUnlocalizedName()); + + GameRegistry.registerItem(ItemRegistry.ROCKCUTTER_LV, ItemRegistry.ROCKCUTTER_LV.getUnlocalizedName()); + GameRegistry.registerItem(ItemRegistry.ROCKCUTTER_MV, ItemRegistry.ROCKCUTTER_MV.getUnlocalizedName()); + GameRegistry.registerItem(ItemRegistry.ROCKCUTTER_HV, ItemRegistry.ROCKCUTTER_HV.getUnlocalizedName()); + GameRegistry.registerItem(ItemRegistry.TAB, "tabIconGT2"); + + OreDictionary.registerOre("blockGlassHV",new ItemStack(Blocks.glass,1,Short.MAX_VALUE)); + OreDictionary.registerOre("blockGlassHV",new ItemStack(ItemRegistry.bw_glasses[0],1,0)); + OreDictionary.registerOre("blockGlassEV", Ic2Items.reinforcedGlass); + OreDictionary.registerOre("blockGlassEV",new ItemStack(ItemRegistry.bw_glasses[0],1,1)); + OreDictionary.registerOre("blockGlassIV",new ItemStack(ItemRegistry.bw_glasses[0],1,2)); + OreDictionary.registerOre("blockGlassIV",new ItemStack(ItemRegistry.bw_glasses[0],1,12)); + OreDictionary.registerOre("blockGlassLuV",new ItemStack(ItemRegistry.bw_glasses[0],1,3)); + OreDictionary.registerOre("blockGlassZPM",new ItemStack(ItemRegistry.bw_glasses[0],1,4)); + OreDictionary.registerOre("blockGlassUV",new ItemStack(ItemRegistry.bw_glasses[0],1,5)); + + try { + activeContainer.set(modController,gregtech); + } catch (IllegalAccessException e) { + e.printStackTrace(); + FMLCommonHandler.instance().exitJava(-1,true); + } + } +} 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 dd20bd3a85..f14e5f8051 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 @@ -40,6 +40,9 @@ import com.github.bartimaeusnek.bartworks.common.tileentities.multis.mega.GT_Til import com.github.bartimaeusnek.bartworks.common.tileentities.multis.mega.GT_TileEntity_MegaVacuumFreezer; import com.github.bartimaeusnek.bartworks.common.tileentities.tiered.*; import com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader; +import cpw.mods.fml.common.LoadController; +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.ModContainer; import cpw.mods.fml.common.registry.GameRegistry; import gregtech.api.enums.GT_Values; import gregtech.api.enums.Materials; @@ -52,6 +55,9 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; +import org.apache.commons.lang3.reflect.FieldUtils; + +import java.lang.reflect.Field; import static com.github.bartimaeusnek.bartworks.MainMod.BWT; import static com.github.bartimaeusnek.bartworks.MainMod.GT2; @@ -139,31 +145,14 @@ public class ItemRegistry { public static ItemStack giantOutputHatch; public static void run() { - if (newStuff) { if (ConfigHandler.creativeScannerID != 0) new CreativeScanner(ConfigHandler.creativeScannerID,"Creative Debug Scanner","Creative Debug Scanner",20); ItemRegistry.eic = new GT_TileEntity_ElectricImplosionCompressor(ConfigHandler.IDOffset + GT_Values.VN.length * 8 + 6, "ElectricImplosionCompressor", "Electric Implosion Compressor").getStackForm(1L); ItemRegistry.thtr = new GT_TileEntity_THTR(ConfigHandler.IDOffset + GT_Values.VN.length * 8 + 5, "THTR", "Thorium High Temperature Reactor").getStackForm(1L); GT_TileEntity_THTR.THTRMaterials.registeraTHR_Materials(); - GameRegistry.registerBlock(ItemRegistry.bw_glasses[0], BW_ItemBlocks.class, "BW_GlasBlocks"); - GameRegistry.registerBlock(ItemRegistry.bw_fake_glasses, "BW_FakeGlasBlock"); GT_OreDictUnificator.add(OrePrefixes.block, Materials.BorosilicateGlass, new ItemStack(ItemRegistry.bw_glasses[0], 1, 0)); - GameRegistry.registerBlock(ItemRegistry.BW_BLOCKS[2], BW_ItemBlocks.class, "BW_Machinery_Casings"); GT_OreDictUnificator.registerOre(OrePrefixes.block, Materials.NickelZincFerrite, new ItemStack(ItemRegistry.BW_BLOCKS[2])); - GameRegistry.registerItem(ItemRegistry.LEATHER_ROTOR, "BW_LeatherRotor"); - GameRegistry.registerItem(ItemRegistry.WOOL_ROTOR, "BW_WoolRotor"); - GameRegistry.registerItem(ItemRegistry.PAPER_ROTOR, "BW_PaperRotor"); - GameRegistry.registerItem(ItemRegistry.COMBINED_ROTOR, "BW_CombinedRotor"); - GameRegistry.registerItem(ItemRegistry.CRAFTING_PARTS, "craftingParts"); - GameRegistry.registerTileEntity(BW_RotorBlock.class, "BWRotorBlockTE"); - GameRegistry.registerBlock(ItemRegistry.ROTORBLOCK, BW_ItemBlocks.class, "BWRotorBlock"); - GameRegistry.registerTileEntity(BW_TileEntity_HeatedWaterPump.class, "BWHeatedWaterPumpTE"); - GameRegistry.registerBlock(ItemRegistry.PUMPBLOCK, BW_ItemBlocks.class, "BWHeatedWaterPumpBlock"); - GameRegistry.registerItem(ItemRegistry.PUMPPARTS, "BWPumpParts"); - GameRegistry.registerItem(ItemRegistry.WINDMETER, "BW_SimpleWindMeter"); - GameRegistry.registerTileEntity(BW_TileEntity_ExperimentalFloodGate.class, "BWExpReversePump"); - GameRegistry.registerBlock(ItemRegistry.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); @@ -171,7 +160,6 @@ public class ItemRegistry { ItemRegistry.diode12A[i] = new GT_MetaTileEntity_Diode(ConfigHandler.IDOffset + GT_Values.VN.length * 4 + 1 + i, "diode" + "12A" + GT_Values.VN[i], StatCollector.translateToLocal("tile.diode.name") + " 12A " + GT_Values.VN[i], i).getStackForm(1L); ItemRegistry.diode16A[i] = new GT_MetaTileEntity_Diode(ConfigHandler.IDOffset + GT_Values.VN.length * 5 + 1 + i, "diode" + "16A" + GT_Values.VN[i], StatCollector.translateToLocal("tile.diode.name") + " 16A " + GT_Values.VN[i], i).getStackForm(1L); ItemRegistry.energyDistributor[i] = new GT_MetaTileEntity_EnergyDistributor(ConfigHandler.IDOffset + 1 + i, "energydistributor" + GT_Values.VN[i], StatCollector.translateToLocal("tile.energydistributor.name") + " " + GT_Values.VN[i], i).getStackForm(1L); - } for (int i = 0; i < 3; i++) { ItemRegistry.acidGens[i] = new GT_MetaTileEntity_AcidGenerator(ConfigHandler.IDOffset + GT_Values.VN.length * 8 - 2 + i, "acidgenerator" + GT_Values.VN[i + 2], StatCollector.translateToLocal("tile.acidgenerator.name") + " " + GT_Values.VN[i + 2], i + 2).getStackForm(1); @@ -183,17 +171,5 @@ public class ItemRegistry { ItemRegistry.compressedHatch = new GT_MetaTileEntity_CompressedFluidHatch(ConfigHandler.IDOffset + GT_Values.VN.length * 8 + 8, "CompressedFluidHatch", "Liquid Air Fluid Hatch").getStackForm(1L); ItemRegistry.giantOutputHatch = new GT_MetaTileEntity_GiantOutputHatch(ConfigHandler.IDOffset + GT_Values.VN.length * 8 + 9, "GiantOutputHatch", "Giant Output Hatch").getStackForm(1L); } - - - //GT2 stuff - GameRegistry.registerBlock(ItemRegistry.BW_BLOCKS[0], BW_ItemBlocks.class, "BW_ItemBlocks"); - GameRegistry.registerBlock(ItemRegistry.BW_BLOCKS[1], BW_ItemBlocks.class, "GT_LESU_CASING"); - if (ConfigHandler.teslastaff) - GameRegistry.registerItem(ItemRegistry.TESLASTAFF, ItemRegistry.TESLASTAFF.getUnlocalizedName()); - - GameRegistry.registerItem(ItemRegistry.ROCKCUTTER_LV, ItemRegistry.ROCKCUTTER_LV.getUnlocalizedName()); - GameRegistry.registerItem(ItemRegistry.ROCKCUTTER_MV, ItemRegistry.ROCKCUTTER_MV.getUnlocalizedName()); - GameRegistry.registerItem(ItemRegistry.ROCKCUTTER_HV, ItemRegistry.ROCKCUTTER_HV.getUnlocalizedName()); - GameRegistry.registerItem(ItemRegistry.TAB, "tabIconGT2"); } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/BWRecipes.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/BWRecipes.java index 3b4784beca..16d306d05f 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/util/BWRecipes.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/BWRecipes.java @@ -580,9 +580,9 @@ public class BWRecipes { } } - private static class SpecialObjectSensitiveMap extends GT_Recipe.GT_Recipe_Map{ + public static class SpecialObjectSensitiveMap extends GT_Recipe.GT_Recipe_Map{ - private SpecialObjectSensitiveMap(Collection<GT_Recipe> aRecipeList, String aUnlocalizedName, String aLocalName, String aNEIName, String aNEIGUIPath, int aUsualInputCount, int aUsualOutputCount, int aMinimalInputItems, int aMinimalInputFluids, int aAmperage, String aNEISpecialValuePre, int aNEISpecialValueMultiplier, String aNEISpecialValuePost, boolean aShowVoltageAmperageInNEI, boolean aNEIAllowed) { + public SpecialObjectSensitiveMap(Collection<GT_Recipe> aRecipeList, String aUnlocalizedName, String aLocalName, String aNEIName, String aNEIGUIPath, int aUsualInputCount, int aUsualOutputCount, int aMinimalInputItems, int aMinimalInputFluids, int aAmperage, String aNEISpecialValuePre, int aNEISpecialValueMultiplier, String aNEISpecialValuePost, boolean aShowVoltageAmperageInNEI, boolean aNEIAllowed) { super(aRecipeList, aUnlocalizedName, aLocalName, aNEIName, aNEIGUIPath, aUsualInputCount, aUsualOutputCount, aMinimalInputItems, aMinimalInputFluids, aAmperage, aNEISpecialValuePre, aNEISpecialValueMultiplier, aNEISpecialValuePost, aShowVoltageAmperageInNEI, aNEIAllowed); } diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/BartWorksCrossmod.java b/src/main/java/com/github/bartimaeusnek/crossmod/BartWorksCrossmod.java index d0a13b9af0..9bbd454325 100644 --- a/src/main/java/com/github/bartimaeusnek/crossmod/BartWorksCrossmod.java +++ b/src/main/java/com/github/bartimaeusnek/crossmod/BartWorksCrossmod.java @@ -22,23 +22,24 @@ package com.github.bartimaeusnek.crossmod; +import com.github.bartimaeusnek.bartworks.MainMod; import com.github.bartimaeusnek.bartworks.common.commands.ChangeConfig; import com.github.bartimaeusnek.bartworks.common.commands.SummonRuin; +import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; import com.github.bartimaeusnek.crossmod.GTpp.loader.RadioHatchCompat; +import com.github.bartimaeusnek.crossmod.emt.recipe.TCRecipeHandler; import com.github.bartimaeusnek.crossmod.galacticraft.GalacticraftProxy; import com.github.bartimaeusnek.crossmod.thaumcraft.CustomAspects; import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.Mod; -import cpw.mods.fml.common.event.FMLInitializationEvent; -import cpw.mods.fml.common.event.FMLPostInitializationEvent; -import cpw.mods.fml.common.event.FMLPreInitializationEvent; -import cpw.mods.fml.common.event.FMLServerStartingEvent; +import cpw.mods.fml.common.event.*; import net.minecraft.util.StringTranslate; import org.apache.commons.io.input.ReaderInputStream; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import java.io.StringReader; +import java.lang.reflect.InvocationTargetException; @Mod( modid = BartWorksCrossmod.MOD_ID, name = BartWorksCrossmod.NAME, version = BartWorksCrossmod.VERSION, @@ -49,6 +50,7 @@ import java.io.StringReader; + "after:GalacticraftCore; " + "after:Micdoodlecore; " + "after:miscutils;" + + "after:EMT;" ) public class BartWorksCrossmod { public static final String NAME = "BartWorks Mod Additions"; @@ -88,6 +90,19 @@ public class BartWorksCrossmod { // } // } + +// @Mod.EventHandler +// public void onServerStarted(FMLServerStartedEvent event) { +// if (Loader.isModLoaded("EMT")){ +// try { +// TCRecipeHandler.init(); +// } catch (IllegalAccessException | InvocationTargetException e) { +// e.printStackTrace(); +// } +// +// } +// } + @Mod.EventHandler public void onFMLServerStart(FMLServerStartingEvent event) { event.registerServerCommand(new SummonRuin()); diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/emt/recipe/TCRecipeHandler.java b/src/main/java/com/github/bartimaeusnek/crossmod/emt/recipe/TCRecipeHandler.java new file mode 100644 index 0000000000..c36f63cd00 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/crossmod/emt/recipe/TCRecipeHandler.java @@ -0,0 +1,286 @@ +/* + * 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.emt.recipe; + +import com.github.bartimaeusnek.bartworks.util.BWRecipes; +import com.github.bartimaeusnek.bartworks.util.BW_Util; +import com.github.bartimaeusnek.crossmod.thaumcraft.util.ThaumcraftHandler; +import com.google.common.collect.ArrayListMultimap; +import com.google.common.collect.HashBiMap; +import gregtech.api.GregTech_API; +import gregtech.api.enums.GT_Values; +import gregtech.api.interfaces.tileentity.IHasWorldObjectAndCoords; +import gregtech.api.objects.GT_ItemStack; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.oredict.OreDictionary; + +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; + +import static com.github.bartimaeusnek.crossmod.thaumcraft.util.ThaumcraftHandler.AspectAdder; + +public class TCRecipeHandler { + public static final GT_Recipe.GT_Recipe_Map alchemicalConstructHandler = new TCRecipeHandler.TCRecipeMap(new HashSet<>(), + "bwcm.recipe.alchemicalConstruct", + "Industrical Alchemical Construct", + null, + "gregtech:textures/gui/basicmachines/Default", + 2, 1, 2, 0, 1, + "", 1, "", true, true + ); + static Class aCrucibleRecipeClass; + static Class aThaumcraftAPI; + static Field craftingRecipes; + static Field aCrucibleRecipeField; + static Field aCrucibleRecipeCatalyst; + static Field aspects; + static Field key; + + static { + try { + aCrucibleRecipeClass = Class.forName("thaumcraft.api.crafting.CrucibleRecipe"); + aThaumcraftAPI = Class.forName("thaumcraft.api.ThaumcraftApi"); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } + try { + aspects = aCrucibleRecipeClass.getField("aspects"); + + key = aCrucibleRecipeClass.getField("key"); + + aCrucibleRecipeField = aCrucibleRecipeClass.getDeclaredField("recipeOutput"); + aCrucibleRecipeField.setAccessible(true); + + aCrucibleRecipeCatalyst = aCrucibleRecipeClass.getField("catalyst"); + + craftingRecipes = aThaumcraftAPI.getDeclaredField("craftingRecipes"); + craftingRecipes.setAccessible(true); + } catch (NoSuchFieldException e) { + e.printStackTrace(); + } + } + + public static void init() throws IllegalAccessException, InvocationTargetException { + ArrayList tcCraftingList = (ArrayList) craftingRecipes.get(null); + HashSet crucibleRecipes = new HashSet(); + for (Object o : tcCraftingList) { + if (TCRecipeHandler.aCrucibleRecipeClass.isInstance(o)) + crucibleRecipes.add(o); + } + TCRecipeHandler.convertCrucibleRecipesToGTRecipes(crucibleRecipes); + } + + public static void convertCrucibleRecipesToGTRecipes(HashSet crucibleRecipes) throws IllegalAccessException, InvocationTargetException { + HashSet<GT_Recipe> ret = new HashSet<>(); + ArrayListMultimap<ItemStack,Integer> itemToCircuitConfigMap = ArrayListMultimap.create(); + ArrayListMultimap<ItemStack,Object> itemToAspectsMap = ArrayListMultimap.create(); + ArrayListMultimap<ItemStack,ItemStack> itemToOutputMap = ArrayListMultimap.create(); + ArrayListMultimap<ItemStack,String> itemToResearchMap = ArrayListMultimap.create(); + + for (Object o : crucibleRecipes) { + + String key = (String) TCRecipeHandler.key.get(o); + ItemStack out = (ItemStack) TCRecipeHandler.aCrucibleRecipeField.get(o); + Object aspects = TCRecipeHandler.aspects.get(o); + Object cat = TCRecipeHandler.aCrucibleRecipeCatalyst.get(o); + + if (cat instanceof ItemStack) { + itemToAspectsMap.put((ItemStack)cat,aspects); + itemToOutputMap.put((ItemStack)cat,out); + itemToResearchMap.put((ItemStack)cat,key); + } else if (cat instanceof String) { + for (ItemStack stack : OreDictionary.getOres((String) cat)) { + itemToAspectsMap.put(stack,aspects); + itemToOutputMap.put(stack,out); + itemToResearchMap.put(stack,key); + } + } else if (cat instanceof ArrayList && ((ArrayList) cat).size() > 0) { + for (ItemStack stack : ((ArrayList<ItemStack>) cat)) { + itemToAspectsMap.put(stack,aspects); + itemToOutputMap.put(stack,out); + itemToResearchMap.put(stack,key); + + } + } + } + for (ItemStack o : itemToAspectsMap.keySet()){ + for (int j = 1; j <= itemToAspectsMap.get(o).size() ; j++) { + itemToCircuitConfigMap.put(o,j); + } + + for (int j = 0; j < itemToAspectsMap.get(o).size() ; j++) { + ret.add(addRecipes(itemToResearchMap.get(o).get(j),itemToOutputMap.get(o).get(j),itemToAspectsMap.get(o).get(j),o,itemToCircuitConfigMap.get(o).get(j))); + } + } + + for (GT_Recipe recipe : ret){ + TCRecipeHandler.alchemicalConstructHandler.add(recipe); + } + + } + + public static GT_Recipe addRecipes(String key, ItemStack out, Object aspects, ItemStack cat, int config) throws InvocationTargetException, IllegalAccessException { + + NBTTagCompound toWrite = new NBTTagCompound(); + ThaumcraftHandler.AspectAdder.writeAspectListToNBT.invoke(aspects, toWrite); + ItemStack fake = new ItemStack(Items.feather); + fake.setTagCompound(toWrite); + fake.setStackDisplayName(key); + GT_Recipe recipe = new BWRecipes.DynamicGTRecipe( + false, + new ItemStack[]{cat, GT_Utility.getIntegratedCircuit(config)}, + new ItemStack[]{out}, + fake, + null, + null, + null, + 60, + 480, + 0 + ); + return recipe; + } + + static class TCRecipeMap extends GT_Recipe.GT_Recipe_Map { + public TCRecipeMap(Collection<GT_Recipe> aRecipeList, String aUnlocalizedName, String aLocalName, String aNEIName, String aNEIGUIPath, int aUsualInputCount, int aUsualOutputCount, int aMinimalInputItems, int aMinimalInputFluids, int aAmperage, String aNEISpecialValuePre, int aNEISpecialValueMultiplier, String aNEISpecialValuePost, boolean aShowVoltageAmperageInNEI, boolean aNEIAllowed) { + super(aRecipeList, aUnlocalizedName, aLocalName, aNEIName, aNEIGUIPath, aUsualInputCount, aUsualOutputCount, aMinimalInputItems, aMinimalInputFluids, aAmperage, aNEISpecialValuePre, aNEISpecialValueMultiplier, aNEISpecialValuePost, aShowVoltageAmperageInNEI, aNEIAllowed); + } + + @Override + public GT_Recipe findRecipe(IHasWorldObjectAndCoords aTileEntity, GT_Recipe aRecipe, boolean aNotUnificated, boolean aDontCheckStackSizes, long aVoltage, FluidStack[] aFluids, ItemStack aSpecialSlot, ItemStack... aInputs) { + // No Recipes? Well, nothing to be found then. + if (mRecipeList.isEmpty()) return null; + + // Some Recipe Classes require a certain amount of Inputs of certain kinds. Like "at least 1 Fluid + 1 Stack" or "at least 2 Stacks" before they start searching for Recipes. + // This improves Performance massively, especially if people leave things like Circuits, Molds or Shapes in their Machines to select Sub Recipes. + if (GregTech_API.sPostloadFinished) { + if (this.mMinimalInputItems > 0) { + if (aInputs == null) + return null; + int tAmount = 0; + for (ItemStack aInput : aInputs) + if (aInput != null) + tAmount++; + if (tAmount < this.mMinimalInputItems) + return null; + } + } + + // Unification happens here in case the Input isn't already unificated. + if (aNotUnificated) + aInputs = GT_OreDictUnificator.getStackArray(true, (Object[]) aInputs); + +// // Check the Recipe which has been used last time in order to not have to search for it again, if possible. +// if (aRecipe != null) +// if (!aRecipe.mFakeRecipe && aRecipe.mCanBeBuffered && aRecipe.isRecipeInputEqual(false, aDontCheckStackSizes, aFluids, aInputs)) { +// NBTTagCompound toCheckNBT = aSpecialSlot.getTagCompound(); +// NBTTagCompound givenNBT = ((ItemStack)aRecipe.mSpecialItems).getTagCompound(); +// Object aAspectListToCheck = null; +// Object aGivenAspectList = null; +// try { +// aAspectListToCheck = AspectAdder.mAspectListClass.newInstance(); +// aGivenAspectList = AspectAdder.mAspectListClass.newInstance(); +// AspectAdder.readAspectListFromNBT.invoke(aAspectListToCheck,toCheckNBT); +// AspectAdder.readAspectListFromNBT.invoke(aGivenAspectList,givenNBT); +// if (!TCRecipeHandler.TCRecipeMap.containsAspects(aAspectListToCheck,aGivenAspectList)) +// return null; +// } catch (InstantiationException | IllegalAccessException | InvocationTargetException e) { +// e.printStackTrace(); +// return null; +// } +// return aRecipe.mEnabled && aVoltage * mAmperage >= aRecipe.mEUt ? aRecipe : null; +// } + + + // Now look for the Recipes inside the Item HashMaps, but only when the Recipes usually have Items. + if (this.mUsualInputCount > 0 && aInputs != null) + for (ItemStack tStack : aInputs) + if (tStack != null) { + Collection<GT_Recipe> tRecipes = mRecipeItemMap.get(new GT_ItemStack(tStack)); + if (tRecipes != null) + for (GT_Recipe tRecipe : tRecipes) + if (!tRecipe.mFakeRecipe && tRecipe.isRecipeInputEqual(false, aDontCheckStackSizes, aFluids, aInputs)) { + NBTTagCompound toCheckNBT = aSpecialSlot.getTagCompound(); + NBTTagCompound givenNBT = ((ItemStack)aRecipe.mSpecialItems).getTagCompound(); + Object aAspectListToCheck = null; + Object aGivenAspectList = null; + try { + aAspectListToCheck = AspectAdder.mAspectListClass.newInstance(); + aGivenAspectList = AspectAdder.mAspectListClass.newInstance(); + AspectAdder.readAspectListFromNBT.invoke(aAspectListToCheck,toCheckNBT); + AspectAdder.readAspectListFromNBT.invoke(aGivenAspectList,givenNBT); + if (!TCRecipeHandler.TCRecipeMap.containsAspects(aAspectListToCheck,aGivenAspectList)) + continue; + } catch (InstantiationException | IllegalAccessException | InvocationTargetException e) { + e.printStackTrace(); + return null; + } + return tRecipe.mEnabled && aVoltage * mAmperage >= tRecipe.mEUt ? tRecipe : null; + } + tRecipes = mRecipeItemMap.get(new GT_ItemStack(GT_Utility.copyMetaData(GT_Values.W, tStack))); + if (tRecipes != null) + for (GT_Recipe tRecipe : tRecipes) + if (!tRecipe.mFakeRecipe && tRecipe.isRecipeInputEqual(false, aDontCheckStackSizes, aFluids, aInputs) && BW_Util.areStacksEqualOrNull((ItemStack) tRecipe.mSpecialItems, aSpecialSlot)) { + NBTTagCompound toCheckNBT = aSpecialSlot.getTagCompound(); + NBTTagCompound givenNBT = ((ItemStack)aRecipe.mSpecialItems).getTagCompound(); + Object aAspectListToCheck = null; + Object aGivenAspectList = null; + try { + aAspectListToCheck = AspectAdder.mAspectListClass.newInstance(); + aGivenAspectList = AspectAdder.mAspectListClass.newInstance(); + AspectAdder.readAspectListFromNBT.invoke(aAspectListToCheck,toCheckNBT); + AspectAdder.readAspectListFromNBT.invoke(aGivenAspectList,givenNBT); + if (!TCRecipeHandler.TCRecipeMap.containsAspects(aAspectListToCheck,aGivenAspectList)) + continue; + } catch (InstantiationException | IllegalAccessException | InvocationTargetException e) { + e.printStackTrace(); + return null; + } + return tRecipe.mEnabled && aVoltage * mAmperage >= tRecipe.mEUt ? tRecipe : null; + } + } + // And nothing has been found. + return null; + } + + + private static boolean containsAspects(Object aAspectListToCheck, Object aGivenAspectList) throws InvocationTargetException, IllegalAccessException { + Object[] aspects = (Object[]) ThaumcraftHandler.AspectAdder.getAspects.invoke(aGivenAspectList); + for (int i = 0; i < aspects.length; i++) { + if ((int) ThaumcraftHandler.AspectAdder.getAmount.invoke(aAspectListToCheck,aspects[i]) < (int) ThaumcraftHandler.AspectAdder.getAmount.invoke(aGivenAspectList,aspects[i])) + return false; + } + return true; + } + + } +}
\ No newline at end of file diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/emt/tileentities/multi/GT_Industrial_Alchemic_Furnace.java b/src/main/java/com/github/bartimaeusnek/crossmod/emt/tileentities/multi/GT_Industrial_Alchemic_Furnace.java new file mode 100644 index 0000000000..fa9bf7cd37 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/crossmod/emt/tileentities/multi/GT_Industrial_Alchemic_Furnace.java @@ -0,0 +1,150 @@ +/* + * Copyright (c) 2019 bartimaeusnek + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.bartimaeusnek.crossmod.emt.tileentities.multi; + +import com.github.bartimaeusnek.crossmod.emt.recipe.TCRecipeHandler; +import com.github.bartimaeusnek.crossmod.emt.util.EMTHandler; +import com.github.bartimaeusnek.crossmod.thaumcraft.util.ThaumcraftHandler; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.interfaces.tileentity.IHasWorldObjectAndCoords; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.List; + +import static gregtech.api.enums.GT_Values.V; + +public class GT_Industrial_Alchemic_Furnace extends GT_MetaTileEntity_MultiBlockBase { + + List<Object> mEssentiaHatches = new ArrayList<>(); + + public boolean addInputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity.getClass().isInstance(EMTHandler.aEssentiaInputHatch)) + return this.addEssetiaHatchToList(aTileEntity, aBaseCasingIndex); + return super.addInputToMachineList(aTileEntity, aBaseCasingIndex); + } + + private boolean addEssetiaHatchToList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } else if (aTileEntity.getClass().isInstance(EMTHandler.aEssentiaInputHatch)) { + ((GT_MetaTileEntity_Hatch)aMetaTileEntity).updateTexture(aBaseCasingIndex); + return this.mEssentiaHatches.add(aMetaTileEntity); + } else { + return false; + } + } + } + + public GT_Industrial_Alchemic_Furnace(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GT_Industrial_Alchemic_Furnace(String aName) { + super(aName); + } + + @Override + public boolean isCorrectMachinePart(ItemStack itemStack) { + return true; + } + + @Override + public boolean checkRecipe(ItemStack itemStack) { + ItemStack stack = new ItemStack(Items.feather); + try { + String owner = this.getBaseMetaTileEntity().getOwnerName(); + Object allAspects = ThaumcraftHandler.AspectAdder.mAspectListClass.newInstance(); + for (Object o : this.mEssentiaHatches) { + Object aspectList = EMTHandler.aAspectField.get(o); + ThaumcraftHandler.AspectAdder.add.invoke(allAspects,aspectList); + } + NBTTagCompound toWrite = (NBTTagCompound)ThaumcraftHandler.AspectAdder.writeAspectListToNBT.invoke(allAspects,new NBTTagCompound()); + stack.setTagCompound(toWrite); + } catch (IllegalAccessException | InstantiationException | InvocationTargetException e) { + e.printStackTrace(); + return false; + } + ItemStack[] tInputs = this.getStoredInputs().toArray(new ItemStack[0]); + ArrayList<ItemStack> outputItems = new ArrayList<ItemStack>(); + + long tVoltage = this.getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + GT_Recipe tRecipe = TCRecipeHandler.alchemicalConstructHandler.findRecipe(this.getBaseMetaTileEntity(),null,false, false, V[tTier], null, stack,tInputs); + + return false; + } + + @Override + public boolean checkMachine(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { + return false; + } + + @Override + public int getMaxEfficiency(ItemStack itemStack) { + return 0; + } + + @Override + public int getPollutionPerTick(ItemStack itemStack) { + return 0; + } + + @Override + public int getDamageToComponent(ItemStack itemStack) { + return 0; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack itemStack) { + return false; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { + return new GT_Industrial_Alchemic_Furnace(mName); + } + + @Override + public String[] getDescription() { + return new String[0]; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity iGregTechTileEntity, byte b, byte b1, byte b2, boolean b3, boolean b4) { + return new ITexture[0]; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/emt/util/EMTHandler.java b/src/main/java/com/github/bartimaeusnek/crossmod/emt/util/EMTHandler.java new file mode 100644 index 0000000000..c720de1f07 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/crossmod/emt/util/EMTHandler.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2019 bartimaeusnek + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.bartimaeusnek.crossmod.emt.util; + +import java.lang.reflect.Field; + +public class EMTHandler { + public static Class aEssentiaInputHatch; + public static Field aAspectField; + static { + try { + aEssentiaInputHatch = Class.forName("emt.gthandler.common.implementations.EssentiaHatch"); + aAspectField = aEssentiaInputHatch.getDeclaredField("current"); + aAspectField.setAccessible(true); + } catch (ClassNotFoundException | NoSuchFieldException e) { + e.printStackTrace(); + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/PlanetsHelperClass.java b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/PlanetsHelperClass.java new file mode 100644 index 0000000000..8eddf5eb04 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/PlanetsHelperClass.java @@ -0,0 +1,49 @@ +/* + * 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.bartworks.common.configs.ConfigHandler; +import micdoodle8.mods.galacticraft.core.entities.EntityLander; +import micdoodle8.mods.galacticraft.core.entities.EntityLanderBase; +import micdoodle8.mods.galacticraft.planets.asteroids.entities.EntityEntryPod; +import micdoodle8.mods.galacticraft.planets.mars.entities.EntityLandingBalloons; +import net.minecraft.entity.player.EntityPlayerMP; + +public class PlanetsHelperClass { + + public static EntityLanderBase getLanderType(EntityPlayerMP player){ + EntityLanderBase elb; + switch (ConfigHandler.landerType){ + case 1: + elb = new EntityLander(player); + break; + case 2: + elb = new EntityLandingBalloons(player); + break; + default: + elb = new EntityEntryPod(player); + break; + } + return elb; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/UniversalTeleportType.java b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/UniversalTeleportType.java index c1e7e7a6c8..ddae0648b2 100644 --- a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/UniversalTeleportType.java +++ b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/UniversalTeleportType.java @@ -22,14 +22,12 @@ package com.github.bartimaeusnek.crossmod.galacticraft; -import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; +import cpw.mods.fml.common.Loader; import micdoodle8.mods.galacticraft.api.vector.Vector3; import micdoodle8.mods.galacticraft.api.world.ITeleportType; import micdoodle8.mods.galacticraft.core.entities.EntityLander; import micdoodle8.mods.galacticraft.core.entities.EntityLanderBase; import micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats; -import micdoodle8.mods.galacticraft.planets.asteroids.entities.EntityEntryPod; -import micdoodle8.mods.galacticraft.planets.mars.entities.EntityLandingBalloons; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.world.World; @@ -71,18 +69,10 @@ public class UniversalTeleportType implements ITeleportType { } EntityLanderBase elb; - - switch (ConfigHandler.landerType){ - case 1: - elb = new EntityLander(player); - break; - case 2: - elb = new EntityLandingBalloons(player); - break; - default: - elb = new EntityEntryPod(player); - break; - } + if (Loader.isModLoaded("GalacticraftMars")) + elb=PlanetsHelperClass.getLanderType(player); + else + elb = new EntityLander(player); if (!newWorld.isRemote) { newWorld.spawnEntityInWorld(elb); diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/thaumcraft/util/ThaumcraftHandler.java b/src/main/java/com/github/bartimaeusnek/crossmod/thaumcraft/util/ThaumcraftHandler.java index ef6dcde7f0..b753f61a4c 100644 --- a/src/main/java/com/github/bartimaeusnek/crossmod/thaumcraft/util/ThaumcraftHandler.java +++ b/src/main/java/com/github/bartimaeusnek/crossmod/thaumcraft/util/ThaumcraftHandler.java @@ -29,6 +29,7 @@ import com.github.bartimaeusnek.bartworks.util.Pair; import gregtech.api.enums.OrePrefixes; import gregtech.api.enums.TC_Aspects; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.biome.BiomeGenBase; import java.lang.reflect.InvocationTargetException; @@ -84,11 +85,16 @@ public class ThaumcraftHandler { } public static class AspectAdder { - private static Class mAspectListClass; + public static Class mAspectListClass; public static Class mAspectClass; - private static Method registerObjectTag; - private static Method addToList; - private static Method getName; + public static Method registerObjectTag; + public static Method addToList; + public static Method getName; + public static Method writeAspectListToNBT; + public static Method readAspectListFromNBT; + public static Method add; + public static Method getAmount; + public static Method getAspects; static { try { @@ -96,7 +102,12 @@ public class ThaumcraftHandler { ThaumcraftHandler.AspectAdder.mAspectClass = Class.forName("thaumcraft.api.aspects.Aspect"); ThaumcraftHandler.AspectAdder.addToList = ThaumcraftHandler.AspectAdder.mAspectListClass.getMethod("add", ThaumcraftHandler.AspectAdder.mAspectClass,int.class); ThaumcraftHandler.AspectAdder.registerObjectTag = Class.forName("thaumcraft.api.ThaumcraftApi").getMethod("registerObjectTag",ItemStack.class, ThaumcraftHandler.AspectAdder.mAspectListClass); - ThaumcraftHandler.AspectAdder.getName = AspectAdder.mAspectClass.getMethod("getName"); + ThaumcraftHandler.AspectAdder.getName = ThaumcraftHandler.AspectAdder.mAspectClass.getMethod("getName"); + ThaumcraftHandler.AspectAdder.writeAspectListToNBT = ThaumcraftHandler.AspectAdder.mAspectListClass.getMethod("writeToNBT", NBTTagCompound.class); + ThaumcraftHandler.AspectAdder.add = ThaumcraftHandler.AspectAdder.mAspectListClass.getMethod("add", ThaumcraftHandler.AspectAdder.mAspectListClass); + ThaumcraftHandler.AspectAdder.getAmount = ThaumcraftHandler.AspectAdder.mAspectListClass.getMethod("getAmount", ThaumcraftHandler.AspectAdder.mAspectClass); + ThaumcraftHandler.AspectAdder.getAspects = ThaumcraftHandler.AspectAdder.mAspectListClass.getMethod("getAspects"); + ThaumcraftHandler.AspectAdder.readAspectListFromNBT = ThaumcraftHandler.AspectAdder.mAspectListClass.getMethod("readFromNBT", NBTTagCompound.class); } catch (ClassNotFoundException | NoSuchMethodException e) { e.printStackTrace(); } @@ -109,7 +120,7 @@ public class ThaumcraftHandler { Object aspectList = ThaumcraftHandler.AspectAdder.mAspectListClass.newInstance(); for (Pair a : aspectPair) { if (ConfigHandler.debugLog) - DebugLog.log("Stack:"+ stack.getDisplayName() + " Damage:" +stack.getItemDamage() + " aspectPair: " + AspectAdder.getName.invoke(a.getKey()) + " / " + a.getValue()); + DebugLog.log("Stack:"+ stack.getDisplayName() + " Damage:" +stack.getItemDamage() + " aspectPair: " + ThaumcraftHandler.AspectAdder.getName.invoke(a.getKey()) + " / " + a.getValue()); ThaumcraftHandler.AspectAdder.addToList.invoke(aspectList, a.getKey(), a.getValue()); } ThaumcraftHandler.AspectAdder.registerObjectTag.invoke(null, stack, aspectList); diff --git a/src/main/java/com/github/bartimaeusnek/preloader/PreLoaderMod.java b/src/main/java/com/github/bartimaeusnek/preloader/PreLoaderMod.java new file mode 100644 index 0000000000..b46a133df5 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/preloader/PreLoaderMod.java @@ -0,0 +1,55 @@ +/* + * 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.preloader; + +import com.github.bartimaeusnek.bartworks.common.loaders.BeforeGTPreload; +import com.github.bartimaeusnek.crossmod.BartWorksCrossmod; +import cpw.mods.fml.common.Mod; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import gregtech.api.GregTech_API; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +@Mod( + modid = com.github.bartimaeusnek.preloader.PreLoaderMod.MOD_ID, name = com.github.bartimaeusnek.preloader.PreLoaderMod.NAME, version = com.github.bartimaeusnek.preloader.PreLoaderMod.VERSION, + dependencies = "required-before:IC2; " + + "required-before:gregtech; " + + "required-before:bartworks;" + + "before:GalacticraftMars; " + + "before:GalacticraftCore; " + + "before:miscutils;" + + "before:dreamcraft;" + + "before:EMT;" +) +public class PreLoaderMod { + public static final String NAME = "BartWorks Preloader Mod"; + public static final String VERSION = "0.0.1"; + public static final String MOD_ID = "bartworkspreloader"; + public static final Logger LOGGER = LogManager.getLogger(BartWorksCrossmod.NAME); + + + @Mod.EventHandler + public void preInit(FMLPreInitializationEvent preinit) { + GregTech_API.sBeforeGTPreload.add(new BeforeGTPreload()); + } +} |