From 9fe3f693f1d6d015f45898818b7958b3a57a9f4a Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Fri, 26 Jul 2019 04:23:36 +0100 Subject: + Added config option to adjust ingame BGM delays. (Should be working) + Added a Pest Killer for quick removal of Butterflies and Bats. + Added Hydrogen Cyanide. % Replaced existing assets for the Bat King. % Replaced Bat King Logic, it's now an offensive mob. $ Fixed Bat King model scaling. --- src/Java/gtPlusPlus/api/objects/Logger.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Java/gtPlusPlus/api/objects') diff --git a/src/Java/gtPlusPlus/api/objects/Logger.java b/src/Java/gtPlusPlus/api/objects/Logger.java index f994c40b52..616a241d89 100644 --- a/src/Java/gtPlusPlus/api/objects/Logger.java +++ b/src/Java/gtPlusPlus/api/objects/Logger.java @@ -112,7 +112,7 @@ public class Logger { * Special Logger for Materials related content */ public static void MATERIALS(final String s) { - if (CORE.DEVENV || CORE.DEBUG) + if (/* CORE.DEVENV || */CORE.DEBUG) modLogger.info("[Materials] "+s); } /** -- cgit From e7ef217244340fe6984b79815d56d9d5b72582fc Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Thu, 15 Aug 2019 07:55:35 +0100 Subject: + Attempted to add a buggy NEI page for decayable dusts. + Added a way to disable ALL GT++ logging in the ASM config file. + Added recipes for Ztones covers. % Adjusted recipes for Tiered machine covers. % Updated GT++ debug command to toggle logging if desired. (Useful in-game). $ Fixed bug where smart covers would lose their state. --- src/Java/gtPlusPlus/api/objects/Logger.java | 156 +++++---- .../api/objects/minecraft/ShapedRecipe.java | 12 +- .../commands/CommandEnableDebugWhileRunning.java | 46 ++- src/Java/gtPlusPlus/core/common/CommonProxy.java | 6 + .../core/handler/Recipes/DecayableRecipe.java | 39 +++ .../core/item/materials/DustDecayable.java | 4 + .../gtPlusPlus/core/recipe/RECIPES_General.java | 13 +- .../gtPlusPlus/core/recipe/RECIPES_Machines.java | 364 +++++++++++++-------- src/Java/gtPlusPlus/core/recipe/common/CI.java | 5 +- .../gtPlusPlus/core/util/minecraft/ItemUtils.java | 145 ++++---- .../gtPlusPlus/nei/DecayableRecipeHandler.java | 113 +++++++ src/Java/gtPlusPlus/nei/NEI_GT_Config.java | 6 +- src/Java/gtPlusPlus/preloader/asm/AsmConfig.java | 10 +- .../common/covers/GTPP_Cover_ToggleVisual.java | 84 +++-- src/resources/assets/miscutils/lang/en_US.lang | 12 +- 15 files changed, 686 insertions(+), 329 deletions(-) create mode 100644 src/Java/gtPlusPlus/core/handler/Recipes/DecayableRecipe.java create mode 100644 src/Java/gtPlusPlus/nei/DecayableRecipeHandler.java (limited to 'src/Java/gtPlusPlus/api/objects') diff --git a/src/Java/gtPlusPlus/api/objects/Logger.java b/src/Java/gtPlusPlus/api/objects/Logger.java index 616a241d89..9c1e3d4338 100644 --- a/src/Java/gtPlusPlus/api/objects/Logger.java +++ b/src/Java/gtPlusPlus/api/objects/Logger.java @@ -6,11 +6,12 @@ import cpw.mods.fml.common.FMLLog; import cpw.mods.fml.relauncher.FMLRelaunchLog; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.proxy.ClientProxy; +import gtPlusPlus.preloader.asm.AsmConfig; public class Logger { - + public Logger(String string) { - + } // Logging Functions @@ -22,133 +23,170 @@ public class Logger { return gtPlusPlusLogger; } + private static final boolean enabled = !AsmConfig.disableAllLogging; + public static final org.apache.logging.log4j.Logger getLogger(){ return modLogger; } // Non-Dev Comments public static void INFO(final String s) { - modLogger.info(s); + if (enabled) { + modLogger.info(s); + } } // Non-Dev Comments public static void MACHINE_INFO(final String s) { - - boolean localPlayer = false; - try { - if (ClientProxy.playerName != null){ - if (ClientProxy.playerName.toLowerCase().contains("draknyte1")){ - localPlayer = true; + if (enabled) { + + boolean localPlayer = false; + try { + if (ClientProxy.playerName != null){ + if (ClientProxy.playerName.toLowerCase().contains("draknyte1")){ + localPlayer = true; + } } } - } - catch (final Throwable t){ - - } - - if (CORE.ConfigSwitches.MACHINE_INFO || localPlayer) { - final String name1 = gtPlusPlus.core.util.reflect.ReflectionUtils.getMethodName(2); - modLogger.info("Machine Info: " + s + " | " + name1); + catch (final Throwable t){ + + } + + if (CORE.ConfigSwitches.MACHINE_INFO || localPlayer) { + final String name1 = gtPlusPlus.core.util.reflect.ReflectionUtils.getMethodName(2); + modLogger.info("Machine Info: " + s + " | " + name1); + } } } // Developer Comments public static void WARNING(final String s) { - if (CORE.DEBUG) { - modLogger.warn(s); + if (enabled) { + if (CORE.DEBUG) { + modLogger.warn(s); + } } } // Errors public static void ERROR(final String s) { - if (CORE.DEBUG) { - modLogger.fatal(s); + if (enabled) { + if (CORE.DEBUG) { + modLogger.fatal(s); + } } } // Developer Logger public static void SPECIFIC_WARNING(final String whatToLog, final String msg, final int line) { - // if (!CORE.DEBUG){ - FMLLog.warning("GT++ |" + line + "| " + whatToLog + " | " + msg); - // } + if (enabled) { + // if (!CORE.DEBUG){ + FMLLog.warning("GT++ |" + line + "| " + whatToLog + " | " + msg); + // } + } } // ASM Comments public static void LOG_ASM(final String s) { - FMLRelaunchLog.info("[Special ASM Logging] ", s); - } - - - - - - - - - - + if (enabled) { + FMLRelaunchLog.info("[Special ASM Logging] ", s); + } + } + + + + + + + + + + /** * Special Loggers */ - + /** * Special Logger for Bee related content */ public static void BEES(final String s) { - if (CORE.DEVENV || CORE.DEBUG) - modLogger.info("[Bees] "+s); + if (enabled) { + if (CORE.DEVENV || CORE.DEBUG) { + modLogger.info("[Bees] "+s); + } + } } /** * Special Logger for Debugging Bee related content */ public static void DEBUG_BEES(final String s) { - if (CORE.DEVENV || CORE.DEBUG) - modLogger.info("[Debug][Bees] "+s); + if (enabled) { + if (CORE.DEVENV || CORE.DEBUG) { + modLogger.info("[Debug][Bees] "+s); + } + } } - - - + + + /** * Special Logger for Materials related content */ public static void MATERIALS(final String s) { - if (/* CORE.DEVENV || */CORE.DEBUG) - modLogger.info("[Materials] "+s); + if (enabled) { + if (/* CORE.DEVENV || */CORE.DEBUG) { + modLogger.info("[Materials] "+s); + } + } } /** * Special Logger for Debugging Materials related content */ public static void DEBUG_MATERIALS(final String s) { - if (CORE.DEVENV || CORE.DEBUG) - modLogger.info("[Debug][Materials] "+s); + if (enabled) { + if (CORE.DEVENV || CORE.DEBUG) { + modLogger.info("[Debug][Materials] "+s); + } + } } - + /** * Special Logger for Reflection related content */ public static void REFLECTION(final String s) { - if (CORE.DEVENV || CORE.DEBUG) - modLogger.info("[Reflection] "+s); + if (enabled) { + if (CORE.DEVENV || CORE.DEBUG) { + modLogger.info("[Reflection] "+s); + } + } } - + /** * Special Logger for Darkworld related content */ public static void WORLD(final String s) { - if (CORE.DEVENV || CORE.DEBUG) - modLogger.info("[WorldGen] "+s); + if (enabled) { + if (CORE.DEVENV || CORE.DEBUG) { + modLogger.info("[WorldGen] "+s); + } + } } public static void RECIPE(String string) { - if (/*CORE.DEVENV || */CORE.DEBUG) - modLogger.info("[Recipe] "+string); + if (enabled) { + if (/*CORE.DEVENV || */CORE.DEBUG) { + modLogger.info("[Recipe] "+string); + } + } } public static void SPACE(final String s) { - modLogger.info("[Space] "+s); + if (enabled) { + modLogger.info("[Space] "+s); + } } - - + + } diff --git a/src/Java/gtPlusPlus/api/objects/minecraft/ShapedRecipe.java b/src/Java/gtPlusPlus/api/objects/minecraft/ShapedRecipe.java index 1073e63914..c0e9b20c54 100644 --- a/src/Java/gtPlusPlus/api/objects/minecraft/ShapedRecipe.java +++ b/src/Java/gtPlusPlus/api/objects/minecraft/ShapedRecipe.java @@ -3,11 +3,7 @@ package gtPlusPlus.api.objects.minecraft; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.api.objects.data.Pair; -import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.util.minecraft.ItemUtils; -import gtPlusPlus.everglades.dimension.Dimension_Everglades; -import gtPlusPlus.xmod.forestry.bees.items.FR_ItemRegistry; -import gtPlusPlus.xmod.ic2.item.IC2_Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.oredict.ShapedOreRecipe; @@ -36,13 +32,7 @@ public class ShapedRecipe { String[] aLoggingInfo = new String[9]; if (mBlackList == null) { - mBlackList = new ItemStack[] { - ItemUtils.getSimpleStack(ModBlocks.blockNet), - ItemUtils.getSimpleStack(ModBlocks.blockXpConverter), - ItemUtils.getSimpleStack(ModBlocks.blockWitherGuard), - ItemUtils.getSimpleStack(ModBlocks.blockMiningExplosive), - ItemUtils.getSimpleStack(Dimension_Everglades.blockPortalFrame), - }; + mBlackList = new ItemStack[] {}; } //Just to be safe diff --git a/src/Java/gtPlusPlus/core/commands/CommandEnableDebugWhileRunning.java b/src/Java/gtPlusPlus/core/commands/CommandEnableDebugWhileRunning.java index 3a7d4461f4..5b9c17bacf 100644 --- a/src/Java/gtPlusPlus/core/commands/CommandEnableDebugWhileRunning.java +++ b/src/Java/gtPlusPlus/core/commands/CommandEnableDebugWhileRunning.java @@ -7,6 +7,7 @@ import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.preloader.asm.AsmConfig; import net.minecraft.command.ICommand; import net.minecraft.command.ICommandSender; import net.minecraft.entity.player.EntityPlayer; @@ -33,6 +34,9 @@ public class CommandEnableDebugWhileRunning implements ICommand } + + // Use '/debugmodegtpp' along with 'logging' or 'debug' to toggle Debug mode and Logging. + // Using nothing after the command toggles both to their opposite states respectively. @Override public String getCommandUsage(final ICommandSender var1){ return "/debugmodegtpp"; @@ -47,16 +51,44 @@ public class CommandEnableDebugWhileRunning implements ICommand @Override public void processCommand(final ICommandSender S, final String[] argString){ - Logger.INFO("Toggling Debug Mode"); - final World W = S.getEntityWorld(); - final EntityPlayer P = CommandUtils.getPlayer(S); - - if (PlayerUtils.isPlayerOP(P)) { - CORE.DEBUG = Utils.invertBoolean(CORE.DEBUG); - PlayerUtils.messagePlayer(P, "Toggled GT++ Debug Mode - Enabled: "+CORE.DEBUG); + if (argString == null || argString.length == 0 || argString.length > 1) { + Logger.INFO("Toggling Debug Mode & Logging."); + final EntityPlayer P = CommandUtils.getPlayer(S); + if (PlayerUtils.isPlayerOP(P)) { + CORE.DEBUG = Utils.invertBoolean(CORE.DEBUG); + PlayerUtils.messagePlayer(P, "Toggled GT++ Debug Mode - Enabled: "+CORE.DEBUG); + AsmConfig.disableAllLogging = Utils.invertBoolean(AsmConfig.disableAllLogging); + PlayerUtils.messagePlayer(P, "Toggled GT++ Logging - Enabled: "+(!AsmConfig.disableAllLogging)); + } + } + else { + if (argString[0].toLowerCase().equals("debug")) { + Logger.INFO("Toggling Debug Mode."); + final EntityPlayer P = CommandUtils.getPlayer(S); + if (PlayerUtils.isPlayerOP(P)) { + CORE.DEBUG = Utils.invertBoolean(CORE.DEBUG); + PlayerUtils.messagePlayer(P, "Toggled GT++ Debug Mode - Enabled: "+CORE.DEBUG); + } + } + else if (argString[0].toLowerCase().equals("logging")) { + Logger.INFO("Toggling Logging."); + final EntityPlayer P = CommandUtils.getPlayer(S); + if (PlayerUtils.isPlayerOP(P)) { + AsmConfig.disableAllLogging = Utils.invertBoolean(AsmConfig.disableAllLogging); + PlayerUtils.messagePlayer(P, "Toggled GT++ Logging - Enabled: "+(!AsmConfig.disableAllLogging)); + } + } + else { + final EntityPlayer P = CommandUtils.getPlayer(S); + if (PlayerUtils.isPlayerOP(P)) { + PlayerUtils.messagePlayer(P, "Invalid command, use 'debug' or 'logging'"); + } + } } + + } @Override diff --git a/src/Java/gtPlusPlus/core/common/CommonProxy.java b/src/Java/gtPlusPlus/core/common/CommonProxy.java index 23bd46d5b0..ea106a2c2f 100644 --- a/src/Java/gtPlusPlus/core/common/CommonProxy.java +++ b/src/Java/gtPlusPlus/core/common/CommonProxy.java @@ -190,11 +190,17 @@ public class CommonProxy { } // Compat Handling + Logger.INFO("Removing recipes from other mods."); COMPAT_HANDLER.RemoveRecipesFromOtherMods(); + Logger.INFO("Initialising Handler, Then Adding Recipes"); COMPAT_HANDLER.InitialiseHandlerThenAddRecipes(); + Logger.INFO("Loading Gregtech API recipes."); COMPAT_HANDLER.startLoadingGregAPIBasedRecipes(); + Logger.INFO("Loading Intermod staging."); COMPAT_IntermodStaging.postInit(e); + Logger.INFO("Loading queued recipes."); COMPAT_HANDLER.runQueuedRecipes(); + Logger.INFO("Registering custom mob drops."); registerCustomMobDrops(); } diff --git a/src/Java/gtPlusPlus/core/handler/Recipes/DecayableRecipe.java b/src/Java/gtPlusPlus/core/handler/Recipes/DecayableRecipe.java new file mode 100644 index 0000000000..360b0440a2 --- /dev/null +++ b/src/Java/gtPlusPlus/core/handler/Recipes/DecayableRecipe.java @@ -0,0 +1,39 @@ +package gtPlusPlus.core.handler.Recipes; + +import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import net.minecraft.item.ItemStack; + +public class DecayableRecipe { + + public static final AutoMap mRecipes = new AutoMap(); + + + public final int mTime; + public final ItemStack mInput; + public final ItemStack mOutput; + + public DecayableRecipe(int time, ItemStack input, ItemStack output) { + mTime = time; + mInput = input; + mOutput = output; + mRecipes.put(this); + } + + @Override + public boolean equals(Object o) { + if (o instanceof DecayableRecipe) { + DecayableRecipe i = (DecayableRecipe) o; + if (i.mTime == this.mTime && GT_Utility.areStacksEqual(mInput, i.mInput) && GT_Utility.areStacksEqual(mOutput, i.mOutput)) { + return true; + } + } + return false; + } + + public boolean isValid() { + return (mTime > 0 && ItemUtils.checkForInvalidItems(mInput) && ItemUtils.checkForInvalidItems(mOutput)); + } + +} diff --git a/src/Java/gtPlusPlus/core/item/materials/DustDecayable.java b/src/Java/gtPlusPlus/core/item/materials/DustDecayable.java index aa6fdabacc..9994c7d362 100644 --- a/src/Java/gtPlusPlus/core/item/materials/DustDecayable.java +++ b/src/Java/gtPlusPlus/core/item/materials/DustDecayable.java @@ -1,5 +1,7 @@ package gtPlusPlus.core.item.materials; +import static gtPlusPlus.core.util.minecraft.ItemUtils.getSimpleStack; + import java.util.List; import net.minecraft.client.renderer.texture.IIconRegister; @@ -10,6 +12,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.world.World; import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.core.handler.Recipes.DecayableRecipe; import gtPlusPlus.core.item.base.BaseItemTickable; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.minecraft.EntityUtils; @@ -25,6 +28,7 @@ public class DustDecayable extends BaseItemTickable { this.turnsIntoItem = turnsInto; this.radLevel = radLevel; GT_OreDictUnificator.registerOre(unlocal, ItemUtils.getSimpleStack(this)); + new DecayableRecipe(maxTicks, getSimpleStack(this), getSimpleStack(turnsInto)); } @Override diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_General.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_General.java index 14807f7f3e..02b282b1b3 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_General.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_General.java @@ -6,7 +6,9 @@ import static gtPlusPlus.core.util.minecraft.ItemUtils.getSimpleStack; import static gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechConduits.generatePipeRecipes; import static gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechConduits.generateWireRecipes; -import gregtech.api.enums.*; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; import gregtech.api.util.GT_ModHandler; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.block.ModBlocks; @@ -15,16 +17,13 @@ import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.material.ALLOY; import gtPlusPlus.core.material.ELEMENT; -import gtPlusPlus.core.material.nuclear.FLUORIDES; import gtPlusPlus.core.recipe.common.CI; -import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.minecraft.FluidUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.minecraft.RecipeUtils; import gtPlusPlus.xmod.bop.blocks.BOP_Block_Registrator; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes.GT_Materials; -import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechConduits; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; @@ -119,12 +118,6 @@ public class RECIPES_General { Logger.INFO("Added a recipe for Rainforest oak Saplings."); } - - // Try fix this ore - if (ModBlocks.blockOreFluorite != null){ - RecipeUtils.addShapelessGregtechRecipe(new ItemStack[]{ItemUtils.getSimpleStack(ModBlocks.blockOreFluorite)}, FLUORIDES.FLUORITE.getOre(1)); - } - //Iron bars final ItemStack ironBars; if (CORE.GTNH) { diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java index 52a6c4889e..0bd5c0cf76 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java @@ -2,6 +2,7 @@ package gtPlusPlus.core.recipe; import static gtPlusPlus.core.lib.CORE.GTNH; +import cpw.mods.fml.common.Loader; import gregtech.api.enums.*; import gregtech.api.util.GT_ModHandler; import gtPlusPlus.api.objects.Logger; @@ -15,8 +16,12 @@ import gtPlusPlus.core.material.Material; import gtPlusPlus.core.recipe.common.CI; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.minecraft.*; +import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.everglades.dimension.Dimension_Everglades; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.covers.CoverManager; +import gtPlusPlus.xmod.gregtech.common.items.MetaCustomCoverItem; +import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; @@ -207,7 +212,7 @@ public class RECIPES_Machines { } private static void run(){ - + //Determines Casing Recipe Output if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK && !GTNH){ Casing_Amount=2; @@ -215,7 +220,7 @@ public class RECIPES_Machines { else { Casing_Amount=1; } - + initModItems(); controlCores(); energyCores(); @@ -223,6 +228,7 @@ public class RECIPES_Machines { largeArcFurnace(); industrialVacuumFurnace(); fakeMachineCasingCovers(); + ztonesCoverRecipes(); superBuses(); } @@ -289,7 +295,7 @@ public class RECIPES_Machines { private static void runModRecipes(){ if (LoadedMods.Gregtech){ - + //Computer Cube CORE.RA.addSixSlotAssemblingRecipe( new ItemStack[] { @@ -357,7 +363,7 @@ public class RECIPES_Machines { ItemUtils.getSimpleStack(ModBlocks.blockCustomJukebox), 20 * 30, 30); - + //Poo Collector CORE.RA.addSixSlotAssemblingRecipe( new ItemStack[] { @@ -708,7 +714,7 @@ public class RECIPES_Machines { //Semi-Fluid Generators ItemStack mSemiFluidgen = ItemUtils.getItemStackFromFQRN("IC2:blockGenerator:7", 1); mSemiFluidgen.setItemDamage(7); - //ItemUtils.simpleMetaStack("IC2:blockGenerator:7", 7, 1); + //ItemUtils.simpleMetaStack("IC2:blockGenerator:7", 7, 1); ItemStack[] aSemifluids = new ItemStack[] {mSemiFluidgen, GregtechItemList.Generator_SemiFluid_LV.get(1), GregtechItemList.Generator_SemiFluid_MV.get(1), GregtechItemList.Generator_SemiFluid_HV.get(1)}; for (int o=1;o<4;o++) { CORE.RA.addSixSlotAssemblingRecipe( @@ -829,7 +835,7 @@ public class RECIPES_Machines { "plankWood", "frameGtTumbaga", "plankWood", "plankWood", "plankWood", "plankWood", RECIPE_TreeFarmFrame); - } + } if (CORE.ConfigSwitches.enableMachine_Tesseracts){ //Tesseracts @@ -852,8 +858,8 @@ public class RECIPES_Machines { if (CORE.ConfigSwitches.enableMachine_SimpleWasher){ ItemStack plateWrought = ItemUtils.getItemStackOfAmountFromOreDict("plateWroughtIron", 1); ItemStack washerPipe; - - + + if (CORE.ConfigSwitches.enableCustom_Pipes){ washerPipe = ItemUtils.getItemStackOfAmountFromOreDict("pipeLargeClay", 1); RecipeUtils.addShapedGregtechRecipe( @@ -869,7 +875,7 @@ public class RECIPES_Machines { plateWrought, washerPipe, plateWrought, plateWrought, CI.machineCasing_ULV, plateWrought, GregtechItemList.SimpleDustWasher_ULV.get(1)); - + int aSimpleWasherTier = 2; int aSlot = 0; ItemStack[][] aInputsForSimpleWashers = new ItemStack[4][6]; @@ -880,7 +886,7 @@ public class RECIPES_Machines { CI.getTieredComponent(OrePrefixes.plate, 1, GTNH ? 8 : 4), CI.getTieredComponent(OrePrefixes.rod, 2, GTNH ? 4 : 2), CI.getTieredComponent(OrePrefixes.circuit, 2, GTNH ? 3 : 1), - + }; aInputsForSimpleWashers[1] = new ItemStack[] { CI.getTieredMachineHull(4), @@ -888,7 +894,7 @@ public class RECIPES_Machines { CI.getTieredComponent(OrePrefixes.plate, 3, GTNH ? 12 : 6), CI.getTieredComponent(OrePrefixes.rod, 4, GTNH ? 6 : 3), CI.getTieredComponent(OrePrefixes.circuit, 4, GTNH ? 4 : 2), - + }; aInputsForSimpleWashers[2] = new ItemStack[] { CI.getTieredMachineHull(6), @@ -896,7 +902,7 @@ public class RECIPES_Machines { CI.getTieredComponent(OrePrefixes.plate, 5, GTNH ? 16 : 8), CI.getTieredComponent(OrePrefixes.rod, 6, GTNH ? 8 : 4), CI.getTieredComponent(OrePrefixes.circuit, 6, GTNH ? 6 : 3), - + }; aInputsForSimpleWashers[3] = new ItemStack[] { CI.getTieredMachineHull(8), @@ -904,37 +910,37 @@ public class RECIPES_Machines { CI.getTieredComponent(OrePrefixes.plate, 7, GTNH ? 32 : 16), CI.getTieredComponent(OrePrefixes.rod, 8, GTNH ? 10 : 5), CI.getTieredComponent(OrePrefixes.circuit, 8, GTNH ? 8 : 4), - + }; - - - - - - + + + + + + ItemStack[] aSimpleWashers = new ItemStack[] {GregtechItemList.SimpleDustWasher_MV.get(1), GregtechItemList.SimpleDustWasher_EV.get(1), GregtechItemList.SimpleDustWasher_LuV.get(1), GregtechItemList.SimpleDustWasher_UV.get(1)}; for (int i=0;i<4;i++) { - + CORE.RA.addSixSlotAssemblingRecipe( aInputsForSimpleWashers[aSlot], CI.getTieredFluid(aSimpleWasherTier, 144 * aSimpleWasherTier), aSimpleWashers[aSlot], 20 * 15 * aSimpleWasherTier, (int) GT_Values.V[aSimpleWasherTier]); - + aSimpleWasherTier += 2; aSlot++; } - - - - - - + + + + + + } if (CORE.ConfigSwitches.enableMachine_Pollution && CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK){ - + RecipeUtils.addShapedGregtechRecipe( "plateCarbon", "plateCarbon", "plateCarbon", "dustCarbon", "dustCarbon", "dustCarbon", @@ -1164,7 +1170,7 @@ public class RECIPES_Machines { RECIPE_CyclotronController = GregtechItemList.COMET_Cyclotron.get(1); RECIPE_CyclotronOuterCasing = GregtechItemList.Casing_Cyclotron_External.get(Casing_Amount); RECIPE_CyclotronInnerCoil = GregtechItemList.Casing_Cyclotron_Coil.get(1); - + //Outer Casing CORE.RA.addSixSlotAssemblingRecipe( new ItemStack[] { @@ -1179,8 +1185,8 @@ public class RECIPES_Machines { RECIPE_CyclotronOuterCasing, 30 * 20 * 2, MaterialUtils.getVoltageForTier(4)); - - + + //Inner Coil CORE.RA.addSixSlotAssemblingRecipe( new ItemStack[] { @@ -1995,7 +2001,7 @@ public class RECIPES_Machines { } } - + private static void largeArcFurnace() { int aCostMultiplier = GTNH ? 2 : 1; CORE.RA.addSixSlotAssemblingRecipe( @@ -2025,10 +2031,10 @@ public class RECIPES_Machines { 60 * 20 * 8, MaterialUtils.getVoltageForTier(6)); } - + private static void industrialVacuumFurnace() { int aCostMultiplier = GTNH ? 2 : 1; - + CORE.RA.addSixSlotAssemblingRecipe( new ItemStack[] { CI.getTieredMachineHull(-1, 1 * aCostMultiplier), @@ -2041,9 +2047,9 @@ public class RECIPES_Machines { GregtechItemList.Casing_Vacuum_Furnace.get(Casing_Amount), 20 * 10 * 6, MaterialUtils.getVoltageForTier(6)); - + ; - + CORE.RA.addSixSlotAssemblingRecipe( new ItemStack[] { GregtechItemList.Casing_Vacuum_Furnace.get(Casing_Amount), @@ -2058,113 +2064,191 @@ public class RECIPES_Machines { 60 * 20 * 12, MaterialUtils.getVoltageForTier(7)); } - + private static void fakeMachineCasingCovers() { - GregtechItemList[] mMachineCasingCovers = new GregtechItemList[] { - GregtechItemList.FakeMachineCasingPlate_ULV, - GregtechItemList.FakeMachineCasingPlate_LV, - GregtechItemList.FakeMachineCasingPlate_MV, - GregtechItemList.FakeMachineCasingPlate_HV, - GregtechItemList.FakeMachineCasingPlate_EV, - GregtechItemList.FakeMachineCasingPlate_IV, - GregtechItemList.FakeMachineCasingPlate_LuV, - GregtechItemList.FakeMachineCasingPlate_ZPM, - GregtechItemList.FakeMachineCasingPlate_UV, - GregtechItemList.FakeMachineCasingPlate_MAX, - }; - for (int i = 0;i<10;i++) { - GT_Values.RA.addCutterRecipe( - CI.getTieredMachineCasing(i), - mMachineCasingCovers[i].get(5), - null, - 20 * 5 * i, - (int) GT_Values.V[i]); - } + GregtechItemList[] mMachineCasingCovers = new GregtechItemList[] { + GregtechItemList.FakeMachineCasingPlate_ULV, + GregtechItemList.FakeMachineCasingPlate_LV, + GregtechItemList.FakeMachineCasingPlate_MV, + GregtechItemList.FakeMachineCasingPlate_HV, + GregtechItemList.FakeMachineCasingPlate_EV, + GregtechItemList.FakeMachineCasingPlate_IV, + GregtechItemList.FakeMachineCasingPlate_LuV, + GregtechItemList.FakeMachineCasingPlate_ZPM, + GregtechItemList.FakeMachineCasingPlate_UV, + GregtechItemList.FakeMachineCasingPlate_MAX, + }; + int aMaxTier = GT_Values.VOLTAGE_NAMES.length; + if (!GTNH) { + aMaxTier = 10; + } + ItemStack aTier[] = new ItemStack[aMaxTier]; + for (int i=0;i Short.MAX_VALUE) { + meta = 0; + } + if (size < 0 || size > 64) { + size = 1; + } + Logger.INFO("Found Metastack: " + item.getUnlocalizedName() + ":" + meta); + final ItemStack metaStack = new ItemStack(item, size, meta); + return metaStack; } public static ItemStack simpleMetaStack(final Block block, final int meta, final int size) { @@ -305,9 +298,9 @@ public class ItemUtils { else { mTemp = Utils.sanitizeString(mTemp); } - - - + + + if (oredictName.contains("rod")) { String s = "stick"+oredictName.substring(3); oredictName = s; @@ -374,7 +367,7 @@ public class ItemUtils { return returnValue.copy(); } } - + Logger.RECIPE(oredictName + " was not valid."); return null; } catch (final Throwable t) { @@ -405,7 +398,7 @@ public class ItemUtils { new BaseItemDustUnique("itemDust" + unlocalizedName, materialName, mChemForm, Colour, "Dust"), new BaseItemDustUnique("itemDustSmall" + unlocalizedName, materialName, mChemForm, Colour, "Small"), new BaseItemDustUnique("itemDustTiny" + unlocalizedName, materialName, mChemForm, Colour, "Tiny") }; - + //Generate Shaped/Shapeless Recipes final ItemStack normalDust = ItemUtils.getSimpleStack(output[0]); @@ -459,7 +452,7 @@ public class ItemUtils { Logger.WARNING("4 Small dust from 1 Dust Recipe: "+materialName+" - Failed"); } } - + return output; } @@ -489,7 +482,7 @@ public class ItemUtils { public static Item[] generateSpecialUseDusts(final Material material, final boolean onlyLargeDust) { return generateSpecialUseDusts(material, onlyLargeDust, false); } - + public static Item[] generateSpecialUseDusts(final Material material, final boolean onlyLargeDust, final boolean disableExtraRecipes) { final String materialName = material.getLocalizedName(); final String unlocalizedName = Utils.sanitizeString(materialName); @@ -697,19 +690,19 @@ public class ItemUtils { public static String[] getArrayStackNamesAsArray(final ItemStack[] aStack) { final String[] itemNames = aStack == null ? new String[] {} : new String[aStack.length]; Logger.INFO(""+aStack.length); - + if (aStack == null || aStack.length < 1) { return itemNames; } - + int arpos = 0; for (final ItemStack alph : aStack) { if (alph == null) { continue; } try { - itemNames[arpos] = alph.getDisplayName(); - arpos++; + itemNames[arpos] = alph.getDisplayName(); + arpos++; } catch (Throwable t) { t.printStackTrace(); @@ -1001,15 +994,15 @@ public class ItemUtils { return true; } - - + + public static IInventory organiseInventory(IInventory aInputInventory) { ItemStack[] p = new ItemStack[aInputInventory.getSizeInventory()]; for (int o = 0; o < aInputInventory.getSizeInventory(); o++) { p[o] = aInputInventory.getStackInSlot(o); } //ItemStack[] g = organiseInventory(p); - + IInventory aTemp = aInputInventory; for (int i = 0; i < p.length; ++i) { for (int j = i + 1; j < p.length; ++j) { @@ -1019,22 +1012,22 @@ public class ItemUtils { } } } - + /* for (int o = 0; o < aInputInventory.getSizeInventory(); o++) { aTemp.setInventorySlotContents(o, g[o]); }*/ return aTemp; } - - + + public static ItemStack[] organiseInventory(ItemStack[] aInputs) { //Update Slots int aInvSize = aInputs.length; ItemStack[] newArray = new ItemStack[aInvSize]; - - + + //Try merge stacks for (int i = 0; i < aInvSize; i++) { for (int i2 = 0; i2 < aInvSize; i2++) { @@ -1048,29 +1041,29 @@ public class ItemUtils { } //Try Merge else { - + if (GT_Utility.areStacksEqual(t1[0], t1[1])) { - while ((t1[0].stackSize < 64 && t1[1].stackSize > 0)) { - t1[0].stackSize++; - t1[1].stackSize--; - if (t1[1].stackSize <= 0) { - t1[1] = null; - break; - } - if (t1[0].stackSize == 64) { - break; - } - } - newArray[i] = t1[1]; - newArray[i2] = t1[0]; + while ((t1[0].stackSize < 64 && t1[1].stackSize > 0)) { + t1[0].stackSize++; + t1[1].stackSize--; + if (t1[1].stackSize <= 0) { + t1[1] = null; + break; + } + if (t1[0].stackSize == 64) { + break; + } + } + newArray[i] = t1[1]; + newArray[i2] = t1[0]; } } } } } - + ItemStack[] newArray2 = new ItemStack[aInvSize]; - + //Move nulls to end int count2 = 0; for (int i = 0; i < aInvSize; i++) @@ -1078,10 +1071,10 @@ public class ItemUtils { newArray2[count2++] = newArray[i]; while (count2 < aInvSize) newArray2[count2++] = null; - + return newArray2; - + } public static String getItemName(ItemStack aStack) { @@ -1092,7 +1085,7 @@ public class ItemUtils { try { aDisplay = ("" + StatCollector .translateToLocal(aStack.getItem().getUnlocalizedNameInefficiently(aStack) + ".name")) - .trim(); + .trim(); if (aStack.hasTagCompound()) { if (aStack.stackTagCompound != null && aStack.stackTagCompound.hasKey("display", 10)) { NBTTagCompound nbttagcompound = aStack.stackTagCompound.getCompoundTag("display"); @@ -1120,7 +1113,7 @@ public class ItemUtils { String aDisplay = null; try { aDisplay = (aStack.getUnlocalizedName()).trim(); - + } catch (Throwable t) { aDisplay = aStack.getItem().getUnlocalizedName(); } @@ -1129,7 +1122,7 @@ public class ItemUtils { } return aDisplay; } - + public static boolean isItemGregtechTool(ItemStack aStack) { if (aStack == null) { return false; @@ -1142,49 +1135,49 @@ public class ItemUtils { } return false; } - + public static boolean isToolWrench(ItemStack aWrench) { if (isItemGregtechTool(aWrench) && (aWrench.getItemDamage() == 16 || aWrench.getItemDamage() == 120 || aWrench.getItemDamage() == 122 || aWrench.getItemDamage() == 124 || aWrench.getItemDamage() == 7734)) { return true; } return false; } - + public static boolean isToolMallet(ItemStack aMallet) { if (isItemGregtechTool(aMallet) && (aMallet.getItemDamage() == 14)) { return true; } return false; } - + public static boolean isToolScrewdriver(ItemStack aScrewdriver) { if (isItemGregtechTool(aScrewdriver) && (aScrewdriver.getItemDamage() == 22 || aScrewdriver.getItemDamage() == 150)) { return true; } return false; } - + public static boolean isToolCrowbar(ItemStack aCrowbar) { if (isItemGregtechTool(aCrowbar) && (aCrowbar.getItemDamage() == 20)) { return true; } return false; } - + public static boolean isToolWirecutters(ItemStack aWirecutters) { if (isItemGregtechTool(aWirecutters) && (aWirecutters.getItemDamage() == 26)) { return true; } return false; } - + public static boolean isToolHammer(ItemStack aHammer) { if (isItemGregtechTool(aHammer) && (aHammer.getItemDamage() == 12 || aHammer.getItemDamage() == 7734)) { return true; } return false; } - + public static boolean isToolSolderingIron(ItemStack aSoldering) { if (isItemGregtechTool(aSoldering) && (aSoldering.getItemDamage() == 160)) { return true; @@ -1213,7 +1206,7 @@ public class ItemUtils { public static ItemStack getEnchantedBook(Enchantment aEnch, int aLevel) { return enchantItem(new ItemStack(Items.enchanted_book), aEnch, aLevel); } - + public static ItemStack enchantItem(ItemStack aStack, Enchantment aEnch, int aLevel) { Items.enchanted_book.addEnchantment(aStack, new EnchantmentData(aEnch, aLevel)); return aStack; @@ -1226,16 +1219,16 @@ public class ItemUtils { public static void hideItemFromNEI(ItemStack aItemToHide) { codechicken.nei.api.API.hideItem(aItemToHide); } - + public static ItemStack getNullStack() { return GT_Values.NI; } - + public static ItemStack depleteStack(ItemStack aStack) { return depleteStack(aStack, 1); } - + public static ItemStack depleteStack(ItemStack aStack, int aAmount) { final int cap = aStack.stackSize; if (cap > 1 && cap > aAmount) { diff --git a/src/Java/gtPlusPlus/nei/DecayableRecipeHandler.java b/src/Java/gtPlusPlus/nei/DecayableRecipeHandler.java new file mode 100644 index 0000000000..6b7f24ed37 --- /dev/null +++ b/src/Java/gtPlusPlus/nei/DecayableRecipeHandler.java @@ -0,0 +1,113 @@ +package gtPlusPlus.nei; + +import java.awt.Rectangle; +import java.util.Collection; +import java.util.List; + +import codechicken.nei.PositionedStack; +import codechicken.nei.recipe.TemplateRecipeHandler; +import crazypants.enderio.gui.IconEIO; +import crazypants.enderio.machine.enchanter.GuiEnchanter; +import gtPlusPlus.core.handler.Recipes.DecayableRecipe; +import gtPlusPlus.core.item.materials.DustDecayable; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.StatCollector; + +public class DecayableRecipeHandler extends TemplateRecipeHandler { + + public String getRecipeName() { + return StatCollector.translateToLocal("gtpp.nei.decayables"); + } + + public String getGuiTexture() { + return "enderio:textures/gui/enchanter.png"; + } + + public Class getGuiClass() { + return GuiEnchanter.class; + } + + public String getOverlayIdentifier() { + return "GTPP_Decayables"; + } + + public void loadTransferRects() { + this.transferRects.add(new RecipeTransferRect(new Rectangle(149, -3, 16, 16), "GTPP_Decayables", new Object[0])); + } + + public void loadCraftingRecipes(ItemStack result) { + if (result == null || !DustDecayable.class.isInstance(result.getItem())) { + return; + } + final List recipes = DecayableRecipe.mRecipes; + for (final DecayableRecipe recipe : recipes) { + if (recipe.isValid()) { + final ItemStack input = recipe.mInput.copy(); + final ItemStack output = recipe.mOutput.copy(); + final DecayableRecipeNEI rec = new DecayableRecipeNEI(input, output, recipe.mTime); + this.arecipes.add(rec); + } + } + } + + public void loadCraftingRecipes(String outputId, Object... results) { + if (outputId.equals(getOverlayIdentifier()) && this.getClass() == DecayableRecipeHandler.class) { + final List recipes = DecayableRecipe.mRecipes; + for (final DecayableRecipe recipe : recipes) { + if (recipe.isValid()) { + final ItemStack input = recipe.mInput.copy(); + final ItemStack output = recipe.mOutput.copy(); + final DecayableRecipeNEI rec = new DecayableRecipeNEI(input, output, recipe.mTime); + this.arecipes.add(rec); + } + } + } + else { + super.loadCraftingRecipes(outputId, results); + } + } + + public void loadUsageRecipes(ItemStack ingredient) { + final List recipes = DecayableRecipe.mRecipes; + for (final DecayableRecipe recipe : recipes) { + if (recipe.isValid()) { + final ItemStack input = recipe.mInput.copy(); + final ItemStack output = recipe.mOutput.copy(); + final DecayableRecipeNEI rec = new DecayableRecipeNEI(input, output, recipe.mTime); + if (!rec.contains((Collection)rec.input, ingredient)) { + continue; + } + rec.setIngredientPermutation((Collection) rec.input, ingredient); + this.arecipes.add(rec); + } + }} + + public void drawExtras(int recipeIndex) { + DecayableRecipeNEI recipe = (DecayableRecipeNEI) this.arecipes.get(recipeIndex); + //GuiDraw.drawStringC(recipe.getEnchantName(), 83, 10, 8421504, false); + /* + * int cost = TileEnchanter.getEnchantmentCost(recipe.recipe, 1); if (cost > 0) + * { String s = I18n.format("container.repair.cost", new Object[]{cost}); + * GuiDraw.drawStringC(s, 83, 46, 8453920); } + */ + + IconEIO.RECIPE_BUTTON.renderIcon(149.0D, -3.0D, 16.0D, 16.0D, 0.0D, true); + } + + public class DecayableRecipeNEI extends TemplateRecipeHandler.CachedRecipe + { + private PositionedStack input; + private PositionedStack output; + + public PositionedStack getResult() { + return this.output; + } + + public DecayableRecipeNEI(final ItemStack input, final ItemStack result, final int time) { + super(); + this.input = new PositionedStack(input, 22, 24); + this.output = new PositionedStack(result, 129, 24); + } + } +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/nei/NEI_GT_Config.java b/src/Java/gtPlusPlus/nei/NEI_GT_Config.java index aca6dd5662..ab949bd517 100644 --- a/src/Java/gtPlusPlus/nei/NEI_GT_Config.java +++ b/src/Java/gtPlusPlus/nei/NEI_GT_Config.java @@ -1,10 +1,10 @@ package gtPlusPlus.nei; +import codechicken.nei.api.API; +import codechicken.nei.api.IConfigureNEI; import gregtech.api.util.CustomRecipeMap; import gregtech.api.util.Recipe_GT.Gregtech_Recipe_Map; -import codechicken.nei.api.IConfigureNEI; - public class NEI_GT_Config implements IConfigureNEI { public static boolean sIsAdded = true; @@ -23,6 +23,8 @@ implements IConfigureNEI { } } sIsAdded = true; + API.registerRecipeHandler(new DecayableRecipeHandler()); + API.registerUsageHandler(new DecayableRecipeHandler()); } @Override diff --git a/src/Java/gtPlusPlus/preloader/asm/AsmConfig.java b/src/Java/gtPlusPlus/preloader/asm/AsmConfig.java index c29d8423d8..baf62bf64d 100644 --- a/src/Java/gtPlusPlus/preloader/asm/AsmConfig.java +++ b/src/Java/gtPlusPlus/preloader/asm/AsmConfig.java @@ -20,6 +20,8 @@ public class AsmConfig { public static boolean enableGcFuelChanges; public static boolean enableRcFlowFix; public static boolean enableTcAspectSafety; + + public static boolean disableAllLogging; public AsmConfig(File file) { if (!loaded) { @@ -40,7 +42,13 @@ public class AsmConfig { Property prop; - //Debug + //Debug + prop = config.get("debug", "disableAllLogging", false); + prop.comment = "Disables ALL logging from GT++."; + prop.setLanguageKey("gtpp.disableAllLogging").setRequiresMcRestart(false); + disableAllLogging = prop.getBoolean(false); + propOrderDebug.add(prop.getName()); + prop = config.get("debug", "enableChunkDebugging", false); prop.comment = "Enable/Disable Chunk Debugging Features, Must Be enabled on Client and Server."; prop.setLanguageKey("gtpp.enableChunkDebugging").setRequiresMcRestart(true); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_ToggleVisual.java b/src/Java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_ToggleVisual.java index 7e5b07916e..561da54ceb 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_ToggleVisual.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_ToggleVisual.java @@ -4,11 +4,12 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import gregtech.api.interfaces.tileentity.ICoverable; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.util.GT_CoverBehavior; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.minecraft.BlockPos; import gtPlusPlus.api.objects.random.XSTR; -import gtPlusPlus.xmod.gregtech.common.items.MetaCustomCoverItem; +import gtPlusPlus.core.util.minecraft.PlayerUtils; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -17,9 +18,11 @@ import net.minecraftforge.fluids.Fluid; public class GTPP_Cover_ToggleVisual extends GT_CoverBehavior { - private static final Map sConnectionStateForEntityMap = new ConcurrentHashMap(); + private static final Map sConnectionStateForEntityMap = new ConcurrentHashMap(); private static final Map sPrefixMap = new ConcurrentHashMap(); - + private static final int VALUE_OFF = 0; + private static final int VALUE_ON = 1; + public static String generateUniqueKey(byte aSide, ICoverable aEntity) { try { BlockPos aPos = new BlockPos(aEntity.getIGregTechTileEntity(aEntity.getXCoord(), aEntity.getYCoord(), aEntity.getZCoord())); @@ -33,7 +36,8 @@ public class GTPP_Cover_ToggleVisual extends GT_CoverBehavior { } public boolean onCoverRightclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, - EntityPlayer aPlayer, float aX, float aY, float aZ) { + EntityPlayer aPlayer, float aX, float aY, float aZ) { + PlayerUtils.messagePlayer(aPlayer, this.trans("756", "Connectable: ") + getConnectionState(aCoverVariable)); return super.onCoverRightclick(aSide, aCoverID, aCoverVariable, aTileEntity, aPlayer, aX, aY, aZ); } @@ -43,31 +47,31 @@ public class GTPP_Cover_ToggleVisual extends GT_CoverBehavior { } public boolean letsEnergyIn(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { - return getConnectionState(aSide, aTileEntity); + return getConnectionState(aCoverVariable); } public boolean letsEnergyOut(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { - return getConnectionState(aSide, aTileEntity); + return getConnectionState(aCoverVariable); } public boolean letsFluidIn(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { - return getConnectionState(aSide, aTileEntity); + return getConnectionState(aCoverVariable); } public boolean letsFluidOut(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { - return getConnectionState(aSide, aTileEntity); + return getConnectionState(aCoverVariable); } public boolean letsItemsIn(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) { - return getConnectionState(aSide, aTileEntity); + return getConnectionState(aCoverVariable); } public boolean letsItemsOut(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) { - return getConnectionState(aSide, aTileEntity); + return getConnectionState(aCoverVariable); } public String getDescription(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { - return this.trans("756", "Connectable: ") + getConnectionState(aSide, aTileEntity); + return this.trans("756", "Connectable: ") + getConnectionState(aCoverVariable); } public int getTickRate(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { @@ -76,18 +80,34 @@ public class GTPP_Cover_ToggleVisual extends GT_CoverBehavior { @Override public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, - long aTimer) { + long aTimer) { + try { + String aKey = generateUniqueKey(aSide, aTileEntity); + Integer b = sConnectionStateForEntityMap.get(aKey); + //Logger.INFO("Val: "+aCoverVariable); + if (b != null && aCoverVariable != b) { + aCoverVariable = b; + } + if (b == null) { + b = aCoverVariable; + sConnectionStateForEntityMap.put(aKey, b); + trySetState(aSide, b == VALUE_ON ? VALUE_ON : VALUE_OFF, aTileEntity); + } + } + catch (Throwable t) { + + } return aCoverVariable; } @Override public boolean letsRedstoneGoIn(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { - return getConnectionState(aSide, aTileEntity); + return getConnectionState(aCoverVariable); } @Override public boolean letsRedstoneGoOut(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { - return getConnectionState(aSide, aTileEntity); + return getConnectionState(aCoverVariable); } @Override @@ -98,7 +118,7 @@ public class GTPP_Cover_ToggleVisual extends GT_CoverBehavior { @Override public byte getRedstoneInput(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { - if (!getConnectionState(aSide, aTileEntity)) { + if (!getConnectionState(aCoverVariable)) { return 0; } return super.getRedstoneInput(aSide, aInputRedstone, aCoverID, aCoverVariable, aTileEntity); @@ -109,8 +129,11 @@ public class GTPP_Cover_ToggleVisual extends GT_CoverBehavior { String aKey = generateUniqueKey(aSide, aTileEntity); boolean state = getCoverConnections(aCover); sPrefixMap.put(aKey, aCover.getUnlocalizedName()); - //Logger.INFO("Mapping key "+aKey+" to "+state); - sConnectionStateForEntityMap.put(aKey, state); + Logger.INFO("Mapping key "+aKey+" to "+state); + sConnectionStateForEntityMap.put(aKey, state ? VALUE_ON : VALUE_OFF); + Logger.INFO("Key Value: "+(state ? VALUE_ON : VALUE_OFF)); + //Try set cover state directly + //trySetState(aSide, state ? VALUE_ON : VALUE_OFF, aTileEntity); super.placeCover(aSide, aCover, aTileEntity); } @@ -122,14 +145,33 @@ public class GTPP_Cover_ToggleVisual extends GT_CoverBehavior { //Logger.INFO("Unmapping key "+aKey+"."); return true; } - + + public static boolean getConnectionState(int aCoverVar) { + return aCoverVar == VALUE_ON; + } + + private static final void trySetState(byte aSide, int aState, ICoverable aTile) { + //Try set cover state directly + if (aTile instanceof IGregTechTileEntity) { + IGregTechTileEntity gTileEntity = (IGregTechTileEntity) aTile; + if (gTileEntity != null) { + gTileEntity.setCoverDataAtSide(aSide, aState); + } + } + } + + public static boolean getConnectionState(byte aSide, ICoverable aTile) { String aKey = generateUniqueKey(aSide, aTile); - boolean b = sConnectionStateForEntityMap.get(aKey); - //Logger.INFO("Get State: "+b+" | "+aKey); - return b; + return getConnectionState(aKey); } + public static boolean getConnectionState(String aKey) { + Integer b = sConnectionStateForEntityMap.get(aKey); + //Logger.INFO("Get State: "+b+" | "+aKey); + return b != null ? b == VALUE_ON : false; + } + public static final boolean getCoverConnections(final ItemStack aStack) { NBTTagCompound aNBT = aStack.getTagCompound(); if (aNBT != null) { diff --git a/src/resources/assets/miscutils/lang/en_US.lang b/src/resources/assets/miscutils/lang/en_US.lang index cf25dad8a9..3aefd6dee2 100644 --- a/src/resources/assets/miscutils/lang/en_US.lang +++ b/src/resources/assets/miscutils/lang/en_US.lang @@ -2957,5 +2957,15 @@ item.GTPP.bauble.fireprotection.0.name=Supreme Pizza Gloves item.itemCellSeleniumDioxide.name=Selenium Dioxide Cell item.itemCellSeleniousAcid.name=Selenious Acid Cell -//Added 25/8/19 +//Added 25/7/19 container.pestkiller=Pest Killer + +//Added 15/8/19 +gtpp.nei.decayables=Decayables Chest +entity.batKing.name=Bat King +item.itemCellCarbyne.name=Carbyne Cell +item.itemCellHydrogenCyanide.name=Cell of Hydrogen Cyanide +item.itemCactusCharcoal.name=Cactus Charcoal +item.itemCactusCoke.name=Cactus Coke +item.itemSugarCharcoal.name=Sugar Charcoal +item.itemSugarCoke.name=Sugar Coke \ No newline at end of file -- cgit From 4a2fa070a2ae91173cf15785c63b4090016323d4 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Fri, 11 Oct 2019 18:14:07 +0100 Subject: $ Fixed many tiny bugs, found by static code analysis. $ Fixed Canning handling further. $ Adjusted the Charcoal Pit fix. --- src/Java/gtPlusPlus/GTplusplus.java | 8 +- .../minecraft/ThreadFakeWorldGenerator.java | 2 +- .../api/objects/minecraft/ThreadPooCollector.java | 2 +- src/Java/gtPlusPlus/api/objects/random/XSTR.java | 2 +- .../biome/type/Biome_AustralianPlains.java | 1 - .../australia/chunk/ChunkProviderAustralia.java | 27 ++--- .../australia/gen/map/component/ComponentHut.java | 4 +- .../core/block/base/BlockBaseModular.java | 2 +- .../core/container/Container_SuperJukebox.java | 4 +- .../core/gui/machine/GUI_PestKiller.java | 4 +- src/Java/gtPlusPlus/core/item/ModItems.java | 8 +- .../core/item/base/dusts/BaseItemDust.java | 121 --------------------- .../core/item/general/ItemControlCore.java | 3 + .../core/item/general/ItemHealingDevice.java | 29 +++-- .../core/item/general/ItemSlowBuildingRing.java | 7 +- .../core/item/tool/misc/DebugScanner.java | 22 ++-- .../core/item/tool/misc/GregtechPump.java | 2 +- src/Java/gtPlusPlus/core/material/Material.java | 17 +-- .../core/material/MaterialGenerator.java | 28 ++++- .../gtPlusPlus/core/recipe/RECIPES_GREGTECH.java | 10 +- .../general/TileEntityCircuitProgrammer.java | 2 +- .../gtPlusPlus/core/util/minecraft/FluidUtils.java | 6 +- .../core/util/minecraft/HazmatUtils.java | 9 +- .../gtPlusPlus/core/util/minecraft/ItemUtils.java | 4 +- .../core/util/minecraft/MaterialUtils.java | 5 +- .../util/minecraft/gregtech/PollutionUtils.java | 2 +- .../everglades/biome/BiomeGenerator_Custom.java | 4 - .../villagers/entity/EntityBaseVillager.java | 5 +- .../villagers/entity/EntityNativeAustralian.java | 7 +- .../ClassTransformer_GT_CharcoalPit.java | 17 ++- .../ClassTransformer_TC_ItemWispEssence.java | 61 ++++++----- .../transformers/Preloader_ClassTransformer2.java | 2 - .../xmod/forestry/bees/custom/GTPP_Bees.java | 1 - .../galacticraft/handler/HandlerTooltip_GC.java | 14 ++- src/Java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java | 3 +- .../interfaces/internal/IGregtech_RecipeAdder.java | 6 +- .../power/GTPP_MTE_BasicLosslessGenerator.java | 4 +- .../GT_MetaTileEntity_SuperBus_Input.java | 2 - .../GT_MetaTileEntity_Hatch_CustomFluidBase.java | 2 +- .../base/GregtechMeta_MultiBlockBase.java | 61 +++++++---- .../gregtech/api/world/GTPP_Worldgen_Boulder.java | 3 +- .../api/world/GTPP_Worldgen_Ore_Normal.java | 3 +- .../xmod/gregtech/common/Meta_GT_Proxy.java | 21 ++-- .../gregtech/common/helpers/TreeFarmHelper.java | 2 +- .../common/items/MetaGeneratedGregtechTools.java | 13 ++- .../GregtechMetaAtmosphericReconditioner.java | 13 ++- ...gtechMetaTileEntity_IndustrialMultiMachine.java | 9 +- .../production/GregtechMTE_MiniFusionPlant.java | 4 +- .../production/GregtechMetaTileEntityTreeFarm.java | 8 +- .../GregtechMetaTileEntity_Refinery.java | 2 - .../gregtech/loaders/RecipeGen_DustGeneration.java | 2 +- .../gregtech/loaders/RecipeGen_FluidCanning.java | 109 +++++++++---------- .../xmod/gregtech/loaders/RecipeGen_Fluids.java | 5 - .../xmod/gregtech/loaders/RecipeGen_Ore.java | 5 +- .../xmod/gregtech/loaders/RecipeGen_Recycling.java | 10 +- .../xmod/gregtech/recipes/GregtechRecipeAdder.java | 20 +++- .../xmod/growthcraft/fishtrap/FishTrapHandler.java | 4 +- .../xmod/thaumcraft/util/ThaumcraftUtils.java | 29 +++-- .../recipe/TF_Gregtech_Recipes.java | 6 +- 59 files changed, 363 insertions(+), 425 deletions(-) (limited to 'src/Java/gtPlusPlus/api/objects') diff --git a/src/Java/gtPlusPlus/GTplusplus.java b/src/Java/gtPlusPlus/GTplusplus.java index 8c8b973dc9..ee2bf6c940 100644 --- a/src/Java/gtPlusPlus/GTplusplus.java +++ b/src/Java/gtPlusPlus/GTplusplus.java @@ -105,7 +105,6 @@ public class GTplusplus implements ActionListener { //Mod Instance @Mod.Instance(CORE.MODID) public static GTplusplus instance; - public static Meta_GT_Proxy instanceGtProxy; //Material Loader public static GT_Material_Loader mGregMatLoader; @@ -181,8 +180,7 @@ public class GTplusplus implements ActionListener { mChunkLoading.preInit(event); proxy.preInit(event); Logger.INFO("Setting up our own GT_Proxy."); - instanceGtProxy = Meta_GT_Proxy.instance; - instanceGtProxy.preInit(); + Meta_GT_Proxy.preInit(); Core_Manager.preInit(); } @@ -194,7 +192,7 @@ public class GTplusplus implements ActionListener { proxy.init(event); HazmatUtils.init(); proxy.registerNetworkStuff(); - instanceGtProxy.init(); + Meta_GT_Proxy.init(); Core_Manager.init(); //Used by foreign players to generate .lang files for translation. @@ -211,7 +209,7 @@ public class GTplusplus implements ActionListener { mChunkLoading.postInit(event); proxy.postInit(event); BookHandler.runLater(); - instanceGtProxy.postInit(); + Meta_GT_Proxy.postInit(); Core_Manager.postInit(); //SprinklerHandler.registerModFerts(); diff --git a/src/Java/gtPlusPlus/api/objects/minecraft/ThreadFakeWorldGenerator.java b/src/Java/gtPlusPlus/api/objects/minecraft/ThreadFakeWorldGenerator.java index 393d3260b5..b7462250b1 100644 --- a/src/Java/gtPlusPlus/api/objects/minecraft/ThreadFakeWorldGenerator.java +++ b/src/Java/gtPlusPlus/api/objects/minecraft/ThreadFakeWorldGenerator.java @@ -21,7 +21,7 @@ public class ThreadFakeWorldGenerator extends Thread { public ThreadFakeWorldGenerator() { setName("gtpp.handler.fakeworldtrees"); - run(); + start(); } public static ThreadFakeWorldGenerator getInstance() { diff --git a/src/Java/gtPlusPlus/api/objects/minecraft/ThreadPooCollector.java b/src/Java/gtPlusPlus/api/objects/minecraft/ThreadPooCollector.java index a5f466b19f..0ff6e112ac 100644 --- a/src/Java/gtPlusPlus/api/objects/minecraft/ThreadPooCollector.java +++ b/src/Java/gtPlusPlus/api/objects/minecraft/ThreadPooCollector.java @@ -33,7 +33,7 @@ public class ThreadPooCollector extends Thread { public ThreadPooCollector() { setName("gtpp.handler.poop"); - run(); + start(); } public static ThreadPooCollector getInstance() { diff --git a/src/Java/gtPlusPlus/api/objects/random/XSTR.java b/src/Java/gtPlusPlus/api/objects/random/XSTR.java index 4b5b1298b6..6357e9895c 100644 --- a/src/Java/gtPlusPlus/api/objects/random/XSTR.java +++ b/src/Java/gtPlusPlus/api/objects/random/XSTR.java @@ -33,7 +33,7 @@ import java.util.concurrent.atomic.AtomicLong; * 03.06.2016 * version 0.0.4 */ -public class XSTR extends Random { +public class XSTR extends Random implements Cloneable { private static final long serialVersionUID = 6208727693524452904L; private long seed; diff --git a/src/Java/gtPlusPlus/australia/biome/type/Biome_AustralianPlains.java b/src/Java/gtPlusPlus/australia/biome/type/Biome_AustralianPlains.java index 4ee24aaca5..c04f211fd3 100644 --- a/src/Java/gtPlusPlus/australia/biome/type/Biome_AustralianPlains.java +++ b/src/Java/gtPlusPlus/australia/biome/type/Biome_AustralianPlains.java @@ -16,7 +16,6 @@ import net.minecraftforge.common.BiomeManager; public class Biome_AustralianPlains extends BiomeGenPlains { - protected boolean field_150628_aC; public Biome_AustralianPlains(int p_i1986_1_) { diff --git a/src/Java/gtPlusPlus/australia/chunk/ChunkProviderAustralia.java b/src/Java/gtPlusPlus/australia/chunk/ChunkProviderAustralia.java index 82da02db45..07f5f969e2 100644 --- a/src/Java/gtPlusPlus/australia/chunk/ChunkProviderAustralia.java +++ b/src/Java/gtPlusPlus/australia/chunk/ChunkProviderAustralia.java @@ -9,26 +9,29 @@ import java.util.Map; import java.util.Random; import cpw.mods.fml.common.eventhandler.Event.Result; -import cpw.mods.fml.common.registry.VillagerRegistry; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.australia.gen.map.MapGenLargeRavine; import net.minecraft.block.Block; -import net.minecraft.block.BlockFalling; import net.minecraft.entity.EnumCreatureType; import net.minecraft.init.Blocks; import net.minecraft.util.IProgressUpdate; import net.minecraft.util.MathHelper; -import net.minecraft.world.*; +import net.minecraft.world.ChunkPosition; +import net.minecraft.world.SpawnerAnimals; +import net.minecraft.world.World; +import net.minecraft.world.WorldType; import net.minecraft.world.biome.BiomeGenBase; import net.minecraft.world.chunk.Chunk; import net.minecraft.world.chunk.IChunkProvider; -import net.minecraft.world.gen.*; +import net.minecraft.world.gen.ChunkProviderGenerate; +import net.minecraft.world.gen.MapGenBase; +import net.minecraft.world.gen.MapGenCaves; +import net.minecraft.world.gen.NoiseGenerator; +import net.minecraft.world.gen.NoiseGeneratorOctaves; +import net.minecraft.world.gen.NoiseGeneratorPerlin; import net.minecraft.world.gen.feature.WorldGenDungeons; -import net.minecraft.world.gen.feature.WorldGenLakes; import net.minecraft.world.gen.structure.MapGenMineshaft; import net.minecraft.world.gen.structure.MapGenScatteredFeature; -import net.minecraft.world.gen.structure.MapGenVillage; - import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.terraingen.ChunkProviderEvent; import net.minecraftforge.event.terraingen.PopulateChunkEvent; @@ -40,16 +43,6 @@ public class ChunkProviderAustralia extends ChunkProviderGenerate implements ICh private NoiseGeneratorOctaves noiseGen2; private NoiseGeneratorOctaves noiseGen3; private NoiseGeneratorPerlin noiseGen4; - - /** - * A NoiseGeneratorOctaves used in generating terrain - */ - public NoiseGeneratorOctaves noiseGen5; - /** - * A NoiseGeneratorOctaves used in generating terrain - */ - public NoiseGeneratorOctaves noiseGen6; - public NoiseGeneratorOctaves mobSpawnerNoise; /** * Reference to the World object. */ diff --git a/src/Java/gtPlusPlus/australia/gen/map/component/ComponentHut.java b/src/Java/gtPlusPlus/australia/gen/map/component/ComponentHut.java index 4af5aa09ab..1f5dd59667 100644 --- a/src/Java/gtPlusPlus/australia/gen/map/component/ComponentHut.java +++ b/src/Java/gtPlusPlus/australia/gen/map/component/ComponentHut.java @@ -79,11 +79,11 @@ public class ComponentHut extends AustraliaComponent { placeDoorAtCurrentPosition( world, this.boundingBox, random, 0, 1, 3, getMetadataWithOffset(Blocks.wooden_door, 1)); } - else if (dir == 0) { + else if (dir == 1) { placeDoorAtCurrentPosition( world, this.boundingBox, random, 3, 1, 6, getMetadataWithOffset(Blocks.wooden_door, 1)); } - else if (dir == 0) { + else if (dir == 2) { placeDoorAtCurrentPosition( world, this.boundingBox, random, 6, 1, 3, getMetadataWithOffset(Blocks.wooden_door, 1)); } diff --git a/src/Java/gtPlusPlus/core/block/base/BlockBaseModular.java b/src/Java/gtPlusPlus/core/block/base/BlockBaseModular.java index 8310fa3c23..c0113e869b 100644 --- a/src/Java/gtPlusPlus/core/block/base/BlockBaseModular.java +++ b/src/Java/gtPlusPlus/core/block/base/BlockBaseModular.java @@ -175,7 +175,7 @@ public class BlockBaseModular extends BasicBlock { } } metType = (metType.equals("9j4852jyo3rjmh3owlhw9oe") ? "METALLIC" : metType); - int tier = this.blockMaterial.vTier; + int tier = blockMaterial != null ? this.blockMaterial.vTier : 0; String aType = (this.thisBlock == BlockTypes.FRAME) ? "frameGt" : (tier <= 4 ? "block1" : "block5"); this.blockIcon = iIcon.registerIcon("gregtech" + ":" + "materialicons/"+ metType +"/" + aType); } diff --git a/src/Java/gtPlusPlus/core/container/Container_SuperJukebox.java b/src/Java/gtPlusPlus/core/container/Container_SuperJukebox.java index 34a4e9fa97..f9bf617e1b 100644 --- a/src/Java/gtPlusPlus/core/container/Container_SuperJukebox.java +++ b/src/Java/gtPlusPlus/core/container/Container_SuperJukebox.java @@ -191,7 +191,7 @@ public class Container_SuperJukebox extends Container { @Override public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { - if (tile_entity.getWorldObj().isRemote || tile_entity == null) return null; + if (tile_entity == null || tile_entity.getWorldObj().isRemote) return null; switch (aSlotIndex) { case SLOT_HOLO_PLAY: if (tile_entity == null) return null; @@ -217,7 +217,7 @@ public class Container_SuperJukebox extends Container { @Override public void detectAndSendChanges() { super.detectAndSendChanges(); - if (tile_entity.getWorldObj().isRemote || tile_entity == null) return; + if (tile_entity == null || tile_entity.getWorldObj().isRemote) return; isPlaying = tile_entity.mIsPlaying; isLooping = tile_entity.mIsLooping; diff --git a/src/Java/gtPlusPlus/core/gui/machine/GUI_PestKiller.java b/src/Java/gtPlusPlus/core/gui/machine/GUI_PestKiller.java index 889b19443e..881c6c82a1 100644 --- a/src/Java/gtPlusPlus/core/gui/machine/GUI_PestKiller.java +++ b/src/Java/gtPlusPlus/core/gui/machine/GUI_PestKiller.java @@ -57,12 +57,10 @@ public class GUI_PestKiller extends GuiContainer { Color startGrad = new Color(50, 50, 50); Color endGrad = new Color(20, 20, 20); Container_PestKiller aCont = (Container_PestKiller) this.inventorySlots; - TileEntityPestKiller aTileKiller = aCont.tile_entity; double aPercentage = 0; double aDivisor = (100/16); - int aFrameHeight = 16; - + int aFrameHeight = 16; boolean didRender = false; if (aCont != null) { diff --git a/src/Java/gtPlusPlus/core/item/ModItems.java b/src/Java/gtPlusPlus/core/item/ModItems.java index 007079b9c8..96fe5694cc 100644 --- a/src/Java/gtPlusPlus/core/item/ModItems.java +++ b/src/Java/gtPlusPlus/core/item/ModItems.java @@ -1055,10 +1055,10 @@ public final class ModItems { GT_OreDictUnificator.registerOre("platePhasedIron", ItemUtils.getSimpleStack(itemPlatePulsatingIron)); GT_OreDictUnificator.registerOre("blockVibrantAlloy", ItemUtils.getItemStackOfAmountFromOreDict("blockPhasedGold", 1)); - CORE.RA.addFluidExtractionRecipe(MaterialEIO.REDSTONE_ALLOY.getPlate(1), null, MaterialEIO.REDSTONE_ALLOY.getFluid(144), 10000, 16, 4*9); - CORE.RA.addFluidExtractionRecipe(MaterialEIO.REDSTONE_ALLOY.getIngot(1), null, MaterialEIO.REDSTONE_ALLOY.getFluid(144), 10000, 16, 4*9); - CORE.RA.addFluidExtractionRecipe(MaterialEIO.REDSTONE_ALLOY.getNugget(1), null, MaterialEIO.REDSTONE_ALLOY.getFluid(16), 10000, 16, 4); - CORE.RA.addFluidExtractionRecipe(MaterialEIO.REDSTONE_ALLOY.getBlock(1), null, MaterialEIO.REDSTONE_ALLOY.getFluid(1294), 10000, 16, 4*9*9); + CORE.RA.addFluidExtractionRecipe(MaterialEIO.REDSTONE_ALLOY.getPlate(1), null, MaterialEIO.REDSTONE_ALLOY.getFluid(144), 16, 4*9); + CORE.RA.addFluidExtractionRecipe(MaterialEIO.REDSTONE_ALLOY.getIngot(1), null, MaterialEIO.REDSTONE_ALLOY.getFluid(144), 16, 4*9); + CORE.RA.addFluidExtractionRecipe(MaterialEIO.REDSTONE_ALLOY.getNugget(1), null, MaterialEIO.REDSTONE_ALLOY.getFluid(16), 16, 4); + CORE.RA.addFluidExtractionRecipe(MaterialEIO.REDSTONE_ALLOY.getBlock(1), null, MaterialEIO.REDSTONE_ALLOY.getFluid(1294), 16, 4*9*9); } else { diff --git a/src/Java/gtPlusPlus/core/item/base/dusts/BaseItemDust.java b/src/Java/gtPlusPlus/core/item/base/dusts/BaseItemDust.java index afc4b17354..1b13d34495 100644 --- a/src/Java/gtPlusPlus/core/item/base/dusts/BaseItemDust.java +++ b/src/Java/gtPlusPlus/core/item/base/dusts/BaseItemDust.java @@ -1,14 +1,10 @@ package gtPlusPlus.core.item.base.dusts; import gtPlusPlus.core.item.base.BaseItemComponent; -import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.material.Material; public class BaseItemDust extends BaseItemComponent { - - - private Material dustInfo; private BaseItemComponent[] mSizedDusts = new BaseItemComponent[2]; public BaseItemDust(Material aMat) { @@ -33,127 +29,10 @@ public class BaseItemDust extends BaseItemComponent { } } - private BaseItemDust(final String unlocalizedName, final String materialName, final Material matInfo, final int colour, final String pileSize, final int tier){ - this(unlocalizedName, materialName, matInfo, colour, pileSize, tier, true); - } - private BaseItemDust(String unlocalizedName, String materialName, Material matInfo, int colour, String pileSize, int tier, boolean addRecipes) { super(matInfo, ComponentTypes.DUST); - - try {/* - this.setUnlocalizedName(unlocalizedName); - this.setMaxStackSize(64); - - this.setCreativeTab(tabMisc); - this.colour = colour; - this.mTier = tier; - this.materialName = materialName; - this.dustInfo = matInfo; - this.setTextureName(this.getCorrectTexture(pileSize)); - GameRegistry.registerItem(this, unlocalizedName); - - String temp = ""; - Logger.WARNING("Unlocalized name for OreDict nameGen: "+this.getUnlocalizedName()); - if (this.getUnlocalizedName().contains("item.")){ - temp = this.getUnlocalizedName().replace("item.", ""); - Logger.WARNING("Generating OreDict Name: "+temp); - } - else { - temp = this.getUnlocalizedName(); - } - if (temp.contains("DustTiny")){ - temp = temp.replace("itemD", "d"); - Logger.WARNING("Generating OreDict Name: "+temp); - } - else if (temp.contains("DustSmall")){ - temp = temp.replace("itemD", "d"); - Logger.WARNING("Generating OreDict Name: "+temp); - } - else { - temp = temp.replace("itemD", "d"); - Logger.WARNING("Generating OreDict Name: "+temp); - } - if ((temp != null) && !temp.equals("")){ - GT_OreDictUnificator.registerOre(temp, ItemUtils.getSimpleStack(this)); - } - if (addRecipes){ - this.addFurnaceRecipe(); - this.addMacerationRecipe(); - } - */} - catch (Throwable t) { - t.printStackTrace(); - } - } - - private String getCorrectTexture(final String pileSize){ - - if (!CORE.ConfigSwitches.useGregtechTextures || this.dustInfo.getTextureSet() == null){ - if ((pileSize == "dust") || (pileSize == "Dust")){ - this.setTextureName(CORE.MODID + ":" + "dust");} - else{ - this.setTextureName(CORE.MODID + ":" + "dust"+pileSize); - } - } - - - if (pileSize.toLowerCase().contains("small")){ - return "gregtech" + ":" + "materialicons/"+this.dustInfo.getTextureSet().mSetName+"/dustSmall"; - } - else if (pileSize.toLowerCase().contains("tiny")){ - return "gregtech" + ":" + "materialicons/"+this.dustInfo.getTextureSet().mSetName+"/dustTiny"; - } - return "gregtech" + ":" + "materialicons/"+this.dustInfo.getTextureSet().mSetName+"/dust"; } - /* @Override - public String getItemStackDisplayName(final ItemStack iStack) { - - String unlocal = super.getItemStackDisplayName(iStack); - if (!unlocal.toLowerCase().contains(".name")) { - return unlocal; - } - else { - return unlocal; - } - - }*/ - - /* @Override - public void onUpdate(final ItemStack iStack, final World world, final Entity entityHolding, final int p_77663_4_, final boolean p_77663_5_) { - try { - if (this.dustInfo != null){ - if (entityHolding instanceof EntityPlayer){ - if (!((EntityPlayer) entityHolding).capabilities.isCreativeMode){ - EntityUtils.applyRadiationDamageToEntity(iStack.stackSize, this.dustInfo.vRadiationLevel, world, entityHolding); - } - } - } - } - catch (Throwable t) { - t.printStackTrace(); - } - }*/ - - /*@SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { - - if (stack.getDisplayName().toLowerCase().contains("fluorite")){ - list.add("Mined from Sandstone and Limestone."); - } - if (this.dustInfo != null){ - list.add(this.dustInfo.vChemicalFormula); - } - if (this.dustInfo.vRadiationLevel > 0){ - list.add(CORE.GT_Tooltip_Radioactive); - } - - - //} - super.addInformation(stack, aPlayer, list, bool); - }*/ - public static class DustState { static final int NORMAL = (1); static final int SMALL = (10); diff --git a/src/Java/gtPlusPlus/core/item/general/ItemControlCore.java b/src/Java/gtPlusPlus/core/item/general/ItemControlCore.java index 5ef72b6f17..b74b7972be 100644 --- a/src/Java/gtPlusPlus/core/item/general/ItemControlCore.java +++ b/src/Java/gtPlusPlus/core/item/general/ItemControlCore.java @@ -71,6 +71,9 @@ public class ItemControlCore extends Item { @Override public String getItemStackDisplayName(final ItemStack tItem) { + if (tItem == null) { + return "Control Core"; + } String aReturnValue = super.getItemStackDisplayName(tItem); if (tItem != null) { try { diff --git a/src/Java/gtPlusPlus/core/item/general/ItemHealingDevice.java b/src/Java/gtPlusPlus/core/item/general/ItemHealingDevice.java index c8acdc2152..82bb29b5bf 100644 --- a/src/Java/gtPlusPlus/core/item/general/ItemHealingDevice.java +++ b/src/Java/gtPlusPlus/core/item/general/ItemHealingDevice.java @@ -2,23 +2,10 @@ package gtPlusPlus.core.item.general; import java.util.List; -import cpw.mods.fml.common.Optional; -import cpw.mods.fml.common.registry.GameRegistry; - -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.util.StatCollector; -import net.minecraft.world.World; - import baubles.api.BaubleType; import baubles.api.IBauble; +import cpw.mods.fml.common.Optional; +import cpw.mods.fml.common.registry.GameRegistry; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.lib.CORE; @@ -31,6 +18,16 @@ import gtPlusPlus.xmod.gregtech.common.helpers.ChargingHelper; import ic2.api.item.ElectricItem; import ic2.api.item.IElectricItem; import ic2.api.item.IElectricItemManager; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; @Optional.InterfaceList(value = {@Optional.Interface(iface = "baubles.api.IBauble", modid = "Baubles"), @Optional.Interface(iface = "baubles.api.BaubleType", modid = "Baubles")}) public class ItemHealingDevice extends Item implements IElectricItem, IElectricItemManager, IBauble{ @@ -232,7 +229,7 @@ public class ItemHealingDevice extends Item implements IElectricItem, IElectricI @Override //TODO public void onWornTick(final ItemStack aBaubleStack, final EntityLivingBase arg1) { - if (!arg1.worldObj.isRemote){ + if (arg1 != null && arg1.worldObj != null && !arg1.worldObj.isRemote){ //Try Charge First diff --git a/src/Java/gtPlusPlus/core/item/general/ItemSlowBuildingRing.java b/src/Java/gtPlusPlus/core/item/general/ItemSlowBuildingRing.java index 09c23d3551..c151a16f09 100644 --- a/src/Java/gtPlusPlus/core/item/general/ItemSlowBuildingRing.java +++ b/src/Java/gtPlusPlus/core/item/general/ItemSlowBuildingRing.java @@ -111,11 +111,8 @@ public class ItemSlowBuildingRing extends Item implements IBauble{ private static void doEffect(final EntityLivingBase arg1){ try { // Get World - World aWorld = arg1.worldObj; - if (arg1.worldObj.isRemote){ - return; - } - if (aWorld != null) { + World aWorld = arg1.worldObj; + if (aWorld != null && !aWorld.isRemote) { EntityPlayer aPlayer; if (arg1 instanceof EntityPlayer) { aPlayer = (EntityPlayer) arg1; diff --git a/src/Java/gtPlusPlus/core/item/tool/misc/DebugScanner.java b/src/Java/gtPlusPlus/core/item/tool/misc/DebugScanner.java index d0f3005d00..0170df0dc7 100644 --- a/src/Java/gtPlusPlus/core/item/tool/misc/DebugScanner.java +++ b/src/Java/gtPlusPlus/core/item/tool/misc/DebugScanner.java @@ -7,6 +7,7 @@ import gtPlusPlus.core.util.minecraft.PlayerUtils; import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; @@ -62,19 +63,22 @@ public class DebugScanner extends CoreItem { PlayerUtils.messagePlayer(player, "Invisible? "+entity.isInvisible()); PlayerUtils.messagePlayer(player, "Age: "+entity.ticksExisted); - if (entity instanceof EntityLiving) { - EntityLiving g = (EntityLiving) entity; + if (entity instanceof EntityLivingBase) { + EntityLivingBase g = (EntityLivingBase) entity; PlayerUtils.messagePlayer(player, "Health: "+g.getHealth()+"/"+g.getMaxHealth()); PlayerUtils.messagePlayer(player, "On ground? "+g.onGround); - PlayerUtils.messagePlayer(player, "Can Loot? "+g.canPickUpLoot()); - PlayerUtils.messagePlayer(player, "Child? "+g.isChild()); - if (entity instanceof EntityPlayer) { - EntityPlayer y = (EntityPlayer) entity; - PlayerUtils.messagePlayer(player, "Experience: "+y.experience); - PlayerUtils.messagePlayer(player, "Name: "+y.getCommandSenderName()); - } + PlayerUtils.messagePlayer(player, "Child? "+g.isChild()); + } + if (entity instanceof EntityLiving) { + EntityLiving g = (EntityLiving) entity; + PlayerUtils.messagePlayer(player, "Can Loot? "+g.canPickUpLoot()); } + if (entity instanceof EntityPlayer) { + EntityPlayer y = (EntityPlayer) entity; + PlayerUtils.messagePlayer(player, "Experience: "+y.experience); + PlayerUtils.messagePlayer(player, "Name: "+y.getCommandSenderName()); + } } return true; diff --git a/src/Java/gtPlusPlus/core/item/tool/misc/GregtechPump.java b/src/Java/gtPlusPlus/core/item/tool/misc/GregtechPump.java index 0c31b999cd..a48573888e 100644 --- a/src/Java/gtPlusPlus/core/item/tool/misc/GregtechPump.java +++ b/src/Java/gtPlusPlus/core/item/tool/misc/GregtechPump.java @@ -1127,7 +1127,7 @@ public class GregtechPump extends Item implements ISpecialElectricItem, IElectri else if ((aTileEntity instanceof IFluidTank || aTileEntity instanceof IFluidHandler)) { if (aTileEntity instanceof IFluidTank) { Logger.INFO("Tile Was instanceof IFluidTank."); - FluidStack f = ((IFluidTank) aTileEntity).getFluid(); + FluidStack f = ((IFluidTank) aTileEntity).getFluid(); if (aSetFluid == null) { aSetFluid = f; aSetFluid.amount = f.amount; diff --git a/src/Java/gtPlusPlus/core/material/Material.java b/src/Java/gtPlusPlus/core/material/Material.java index dbcbeac32a..d95b17e75c 100644 --- a/src/Java/gtPlusPlus/core/material/Material.java +++ b/src/Java/gtPlusPlus/core/material/Material.java @@ -237,7 +237,7 @@ public class Material { int hashSize = MathUtils.howManyPlaces(aValueForGen); String a = String.valueOf(aValueForGen); - String b = null; + String b = ""; if (hashSize < 9) { int aSecondHash = this.materialState.hashCode(); @@ -379,9 +379,6 @@ public class Material { aDataSet.put(m.getStackMaterial().vRadiationLevel); } byte aAverage = MathUtils.getByteAverage(aDataSet); - if (aAverage > Byte.MAX_VALUE || aAverage < Byte.MIN_VALUE) { - aAverage = 0; - } if (aAverage > 0) { Logger.MATERIALS(this.getLocalizedName()+" is radioactive due to trace elements. Level: "+aAverage+"."); this.isRadioactive = true; @@ -531,11 +528,6 @@ public class Material { } } - public Material(String string, MaterialState solid, TextureSet setShiny, int i, short[] s, int j, int k, int l, - int m, boolean b, String string2, int n) { - // TODO Auto-generated constructor stub - } - public final TextureSet getTextureSet() { synchronized(this) { return textureSet; @@ -868,10 +860,9 @@ public class Material { ItemStack a1 = getOre(1); Item a2 = a1.getItem(); Block a3 = Block.getBlockFromItem(a2); - - //Logger.DEBUG_MATERIALS("[Invalid Ore] Is a1 valid? "+(a1 != null)); - //Logger.DEBUG_MATERIALS("[Invalid Ore] Is a2 valid? "+(a2 != null)); - //Logger.DEBUG_MATERIALS("[Invalid Ore] Is a3 valid? "+(a3 != null)); + if (a3 != null) { + return a3; + } Block x = Block.getBlockFromItem(ItemUtils.getItemStackOfAmountFromOreDictNoBroken("ore"+Utils.sanitizeString(this.unlocalizedName), stacksize).getItem()); if (x != null){ diff --git a/src/Java/gtPlusPlus/core/material/MaterialGenerator.java b/src/Java/gtPlusPlus/core/material/MaterialGenerator.java index 1757b461ee..797a033dcc 100644 --- a/src/Java/gtPlusPlus/core/material/MaterialGenerator.java +++ b/src/Java/gtPlusPlus/core/material/MaterialGenerator.java @@ -59,10 +59,17 @@ public class MaterialGenerator { @SuppressWarnings("unused") private static volatile Block tempBlock; + + public static boolean addFluidExtractionRecipe(ItemStack aEmpty, ItemStack aRemains, FluidStack aFluid) { + return addFluidExtractionRecipe(aEmpty, aRemains, aFluid, null, null); + } + /** * Called Reflectively from CORE.RA.addFluidExtractionRecipe + * @param aSpecial + * @return */ - private static void addFluidExtractionRecipe(ItemStack aEmpty, ItemStack aRemains, FluidStack aFluid, int aDuration, int aEU) { + public static boolean addFluidExtractionRecipe(ItemStack aEmpty, ItemStack aRemains, FluidStack aFluid, Integer aDuration, Integer aEU) { /*GT_Recipe r = new Recipe_GT( true, new ItemStack[] {aEmpty, aRemains != null ? aRemains : null}, @@ -73,13 +80,22 @@ public class MaterialGenerator { new FluidStack[] {c}, a2, a3, a1);*/ //new RecipeGen_FluidCanning(r, true); - new RecipeGen_FluidCanning(true, aEmpty, aRemains, aFluid, aDuration, aEU); + RecipeGen_FluidCanning g = new RecipeGen_FluidCanning(true, aEmpty, aRemains, aFluid, aDuration, aEU); + if (g != null && g.valid()) { + return true; + } + return false; } + + public static boolean addFluidCannerRecipe(ItemStack aEmpty, ItemStack aFullContainer, FluidStack aFluidIn, FluidStack rFluidOut) { + return addFluidCannerRecipe(aEmpty, aFullContainer, aFluidIn, rFluidOut, null, null); + } /** * Called Reflectively from CORE.RA.addFluidCannerRecipe + * @return */ - private static void addFluidCannerRecipe(ItemStack aFullContainer, ItemStack aEmpty, FluidStack aFluid) { + public static boolean addFluidCannerRecipe(ItemStack aEmpty, ItemStack aFullContainer, FluidStack aFluidIn, FluidStack rFluidOut, Integer aTime, Integer aEu) { /*GT_Recipe r = new Recipe_GT( true, new ItemStack[] {aEmpty}, @@ -90,7 +106,11 @@ public class MaterialGenerator { new FluidStack[] {rFluidOut}, 0, 0, 0);*/ //new RecipeGen_FluidCanning(r, false); - new RecipeGen_FluidCanning(false, aEmpty, aFullContainer, aFluid, null, null); + RecipeGen_FluidCanning g = new RecipeGen_FluidCanning(false, aEmpty, aFullContainer, aFluidIn, null, null, 0); + if (g != null && g.valid()) { + return true; + } + return false; } public static void generate(final Material matInfo){ diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java index c3c8da7761..f237eb9f37 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java @@ -1589,18 +1589,18 @@ public class RECIPES_GREGTECH { private static void fluidExtractorRecipes() { //FLiBe fuel CORE.RA.addFluidExtractionRecipe(ItemUtils.getItemStackOfAmountFromOreDict("dustLi2BeF4", 1), null, - FluidUtils.getFluidStack("li2bef4", 144), 10000, 100, 500); + FluidUtils.getFluidStack("li2bef4", 144), 100, 500); //LFTR Fuel 1 CORE.RA.addFluidExtractionRecipe(NUCLIDE.LiFBeF2ZrF4U235.getDust(1), null, - NUCLIDE.LiFBeF2ZrF4U235.getFluid(144), 10000, 250, 1000); + NUCLIDE.LiFBeF2ZrF4U235.getFluid(144), 250, 1000); CORE.RA.addFluidExtractionRecipe(NUCLIDE.LiFBeF2ZrF4UF4.getDust(1), null, - NUCLIDE.LiFBeF2ZrF4UF4.getFluid(144), 10000, 150, 2000); + NUCLIDE.LiFBeF2ZrF4UF4.getFluid(144), 150, 2000); CORE.RA.addFluidExtractionRecipe(NUCLIDE.LiFBeF2ThF4UF4.getDust(1), null, - NUCLIDE.LiFBeF2ThF4UF4.getFluid(144), 10000, 200, 1500); + NUCLIDE.LiFBeF2ThF4UF4.getFluid(144), 200, 1500); //ZIRCONIUM_TETRAFLUORIDE CORE.RA.addFluidExtractionRecipe(FLUORIDES.ZIRCONIUM_TETRAFLUORIDE.getDust(1), null, - FluidUtils.getFluidStack(ModItems.fluidZrF4, 144), 10000, 200, 512+256); + FluidUtils.getFluidStack(ModItems.fluidZrF4, 144), 200, 512+256); diff --git a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityCircuitProgrammer.java b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityCircuitProgrammer.java index 0cda40c616..0157384cd0 100644 --- a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityCircuitProgrammer.java +++ b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityCircuitProgrammer.java @@ -101,8 +101,8 @@ public class TileEntityCircuitProgrammer extends TileEntity implements ISidedInv } if (doAdd) { ItemStack aOutput = CI.getNumberedCircuit(e); - aOutput.stackSize = aSize; if (aOutput != null) { + aOutput.stackSize = aSize; this.setInventorySlotContents(e, aInputStack); this.setInventorySlotContents(25, aOutput); return true; diff --git a/src/Java/gtPlusPlus/core/util/minecraft/FluidUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/FluidUtils.java index ff60d8c416..8902947c0d 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/FluidUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/FluidUtils.java @@ -149,7 +149,7 @@ public class FluidUtils { public static Fluid addGtFluid(final String aName, final String aLocalized, final GT_Materials aMaterial, final int aState, final long aTemperatureK, final ItemStack aFullContainer, final ItemStack aEmptyContainer, final int aFluidAmount, final boolean aGenerateCell) { - Fluid g = addGTFluid(aName, "fluid.autogenerated", aLocalized, aMaterial.mRGBa, aState, aTemperatureK, aFullContainer, aEmptyContainer, aFluidAmount, aGenerateCell); + Fluid g = addGTFluid(aName, "fluid.autogenerated", aLocalized, aMaterial != null ? aMaterial.mRGBa : new short[]{255, 255, 255, 0}, aState, aTemperatureK, aFullContainer, aEmptyContainer, aFluidAmount, aGenerateCell); if (g != null) { if (aMaterial != null) { switch (aState) { @@ -310,7 +310,7 @@ public class FluidUtils { rFluid.setTemperature((int) (aTemperatureK)); } if ((aFullContainer != null) && (aEmptyContainer != null) && !FluidContainerRegistry.registerFluidContainer(new FluidStack(rFluid, aFluidAmount), aFullContainer, aEmptyContainer)) { - CORE.RA.addFluidCannerRecipe(CI.emptyCells(1), aFullContainer, null, new FluidStack(rFluid, aFluidAmount)); + CORE.RA.addFluidCannerRecipe(CI.emptyCells(1), aFullContainer, new FluidStack(rFluid, aFluidAmount)); } else { //Utils.LOG_INFO("Failed creating recipes to fill/empty cells of "+aName+"."); @@ -466,7 +466,6 @@ public class FluidUtils { dustStack, //Input null, //Input 2 FluidUtils.getFluidStack(gtFluid, amountPerItem), //Fluid Output - 0, //Chance 1*20, //Duration 16 //Eu Tick ); @@ -476,7 +475,6 @@ public class FluidUtils { dustStack2, //Input null, //Input 2 FluidUtils.getFluidStack(gtFluid, amountPerItem), //Fluid Output - 0, //Chance 1*20, //Duration 16 //Eu Tick ); diff --git a/src/Java/gtPlusPlus/core/util/minecraft/HazmatUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/HazmatUtils.java index c529f60ba1..d69dd5d66e 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/HazmatUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/HazmatUtils.java @@ -306,7 +306,14 @@ public class HazmatUtils { //Logger.INFO("[Hazmat] Item was mapped for TTs"); Collections.sort(aTempTooltipData); //Logger.INFO("[Hazmat] Sorted TTs"); - return aTempTooltipData.toArray(); + + String[] mBuiltOutput = new String[aTempTooltipData.size()]; + int aIndex = 0; + for (String i : aTempTooltipData) { + mBuiltOutput[aIndex++] = i; + } + + return mBuiltOutput; } } diff --git a/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java index 25d1eb2793..a8cef939be 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java @@ -694,7 +694,9 @@ public class ItemUtils { public static String[] getArrayStackNamesAsArray(final ItemStack[] aStack) { final String[] itemNames = aStack == null ? new String[] {} : new String[aStack.length]; - Logger.INFO(""+aStack.length); + if (aStack != null){ + Logger.INFO(""+aStack.length); + } if (aStack == null || aStack.length < 1) { return itemNames; diff --git a/src/Java/gtPlusPlus/core/util/minecraft/MaterialUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/MaterialUtils.java index 364430b07d..9c623bb9be 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/MaterialUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/MaterialUtils.java @@ -25,6 +25,7 @@ import gtPlusPlus.core.material.state.MaterialState; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.data.EnumUtils; import gtPlusPlus.core.util.data.StringUtils; +import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.reflect.ReflectionUtils; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -207,9 +208,9 @@ public class MaterialUtils { return true; } - public static int getTierOfMaterial(final int aMeltingPoint){ + public static int getTierOfMaterial(final double aMeltingPoint){ - return aMeltingPoint < 1000 ? 0 : (Math.round(aMeltingPoint/1000)); + return aMeltingPoint < 1000 ? 0 : (MathUtils.roundToClosestInt(aMeltingPoint/1000f)); /*if ((aMeltingPoint >= 0) && (aMeltingPoint <= 1000)){ diff --git a/src/Java/gtPlusPlus/core/util/minecraft/gregtech/PollutionUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/gregtech/PollutionUtils.java index 6a41e54ec3..2f42e36bec 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/gregtech/PollutionUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/gregtech/PollutionUtils.java @@ -138,7 +138,7 @@ public class PollutionUtils { if (te == null) { return false; } - return nullifyPollution(te); + return nullifyPollution((IHasWorldObjectAndCoords) te); } public static boolean nullifyPollution(IHasWorldObjectAndCoords aTileOfSomeSort) { diff --git a/src/Java/gtPlusPlus/everglades/biome/BiomeGenerator_Custom.java b/src/Java/gtPlusPlus/everglades/biome/BiomeGenerator_Custom.java index 83dedc376a..0f8acd75b4 100644 --- a/src/Java/gtPlusPlus/everglades/biome/BiomeGenerator_Custom.java +++ b/src/Java/gtPlusPlus/everglades/biome/BiomeGenerator_Custom.java @@ -21,10 +21,6 @@ import net.minecraftforge.event.terraingen.OreGenEvent; import net.minecraftforge.event.terraingen.TerrainGen; public class BiomeGenerator_Custom extends BiomeDecorator { - /** The world the BiomeDecorator is currently decorating */ - public World currentWorld; - /** The Biome Decorator's random number generator. */ - public Random randomGenerator; public WorldGenerator fluoriteGen; diff --git a/src/Java/gtPlusPlus/plugin/villagers/entity/EntityBaseVillager.java b/src/Java/gtPlusPlus/plugin/villagers/entity/EntityBaseVillager.java index 4dc5a15b4b..c29aadb16b 100644 --- a/src/Java/gtPlusPlus/plugin/villagers/entity/EntityBaseVillager.java +++ b/src/Java/gtPlusPlus/plugin/villagers/entity/EntityBaseVillager.java @@ -70,7 +70,7 @@ public class EntityBaseVillager extends EntityVillager { @Override public void readEntityFromNBT(NBTTagCompound aNBT) { if (aNBT.hasKey("aCustomName")) { - if (this.getCustomNameTag() != aNBT.getString("aCustomName")) { + if (!this.getCustomNameTag().equals(aNBT.getString("aCustomName"))) { this.setCustomNameTag(aNBT.getString("aCustomName")); } } @@ -202,9 +202,10 @@ public class EntityBaseVillager extends EntityVillager { protected MerchantRecipeList getBuyingList() { Field v82191; - MerchantRecipeList o; + MerchantRecipeList o = null; v82191 = ReflectionUtils.getField(getClass(), "buyingList"); try { + if (v82191 != null) o = (MerchantRecipeList) v82191.get(this); Logger.WARNING("Is BuyingList Valid? " + (v82191 != null)); return v82191 != null ? o : null; diff --git a/src/Java/gtPlusPlus/plugin/villagers/entity/EntityNativeAustralian.java b/src/Java/gtPlusPlus/plugin/villagers/entity/EntityNativeAustralian.java index 967647cff6..4f9e2954a4 100644 --- a/src/Java/gtPlusPlus/plugin/villagers/entity/EntityNativeAustralian.java +++ b/src/Java/gtPlusPlus/plugin/villagers/entity/EntityNativeAustralian.java @@ -79,7 +79,7 @@ public class EntityNativeAustralian extends EntityVillager { @Override public void readEntityFromNBT(NBTTagCompound aNBT) { if (aNBT.hasKey("aCustomName")) { - if (this.getCustomNameTag() != aNBT.getString("aCustomName")) { + if (!this.getCustomNameTag().equals(aNBT.getString("aCustomName"))) { this.setCustomNameTag(aNBT.getString("aCustomName")); } } @@ -105,7 +105,7 @@ public class EntityNativeAustralian extends EntityVillager { @Override public void setProfession(int p_70938_1_) { - super.setProfession(mRoleID); + super.setProfession(7738); } @Override @@ -190,9 +190,10 @@ public class EntityNativeAustralian extends EntityVillager { protected MerchantRecipeList getBuyingList() { Field v82191; - MerchantRecipeList o; + MerchantRecipeList o = null; v82191 = ReflectionUtils.getField(getClass(), "buyingList"); try { + if (v82191 != null) o = (MerchantRecipeList) v82191.get(this); Logger.WARNING("Is BuyingList Valid? " + (v82191 != null)); return v82191 != null ? o : null; diff --git a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_CharcoalPit.java b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_CharcoalPit.java index 8299ea3cb5..9c79db265d 100644 --- a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_CharcoalPit.java +++ b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_CharcoalPit.java @@ -17,6 +17,7 @@ import org.objectweb.asm.MethodVisitor; import cpw.mods.fml.relauncher.FMLRelaunchLog; import gregtech.api.enums.OrePrefixes; +import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.util.minecraft.ItemUtils; import net.minecraft.block.Block; import net.minecraft.block.material.Material; @@ -30,13 +31,19 @@ public class ClassTransformer_GT_CharcoalPit { private final ClassWriter writer; public static boolean isWoodLog(Block log) { - String tTool = log.getHarvestTool(0); - boolean isLog1 = OrePrefixes.log.contains(new ItemStack(log, 1)) && tTool != null && tTool.equals("axe") && log.getMaterial() == Material.wood; + //Logger.INFO("checking for log"); + boolean isLog1 = OrePrefixes.log.contains(new ItemStack(log, 1)); + if (isLog1) { + //Logger.INFO("Found 1"); + return true; + } ArrayList oredict = OreDictionary.getOres("logWood"); if (oredict.contains(ItemUtils.getSimpleStack(log))) { + //Logger.INFO("found 2"); return true; - } - return isLog1; + } + //Logger.INFO("Did not find. "+(log != null ? ""+log.getLocalizedName() : "Null or invalid block?")); + return false; } public ClassTransformer_GT_CharcoalPit(byte[] basicClass, boolean obfuscated) { @@ -79,7 +86,7 @@ public class ClassTransformer_GT_CharcoalPit { aBlockClassName = "aji"; } if (aMethodName.equals("isWoodLog")) { - mv = cw.visitMethod(ACC_PUBLIC, "woodLog", "(L"+aBlockClassName+";)Z", null, null); + mv = cw.visitMethod(ACC_PUBLIC, "isWoodLog", "(L"+aBlockClassName+";)Z", null, null); mv.visitCode(); Label l0 = new Label(); mv.visitLabel(l0); diff --git a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_TC_ItemWispEssence.java b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_TC_ItemWispEssence.java index 06759429b9..8f65709478 100644 --- a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_TC_ItemWispEssence.java +++ b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_TC_ItemWispEssence.java @@ -1,6 +1,36 @@ package gtPlusPlus.preloader.asm.transformers; -import static org.objectweb.asm.Opcodes.*; +import static org.objectweb.asm.Opcodes.AALOAD; +import static org.objectweb.asm.Opcodes.ACC_PUBLIC; +import static org.objectweb.asm.Opcodes.ACONST_NULL; +import static org.objectweb.asm.Opcodes.ALOAD; +import static org.objectweb.asm.Opcodes.ARETURN; +import static org.objectweb.asm.Opcodes.ARRAYLENGTH; +import static org.objectweb.asm.Opcodes.ASM5; +import static org.objectweb.asm.Opcodes.ASTORE; +import static org.objectweb.asm.Opcodes.DUP; +import static org.objectweb.asm.Opcodes.F_APPEND; +import static org.objectweb.asm.Opcodes.F_CHOP; +import static org.objectweb.asm.Opcodes.F_SAME; +import static org.objectweb.asm.Opcodes.F_SAME1; +import static org.objectweb.asm.Opcodes.GETSTATIC; +import static org.objectweb.asm.Opcodes.GOTO; +import static org.objectweb.asm.Opcodes.I2L; +import static org.objectweb.asm.Opcodes.ICONST_0; +import static org.objectweb.asm.Opcodes.IFEQ; +import static org.objectweb.asm.Opcodes.IFLE; +import static org.objectweb.asm.Opcodes.IFNONNULL; +import static org.objectweb.asm.Opcodes.IFNULL; +import static org.objectweb.asm.Opcodes.ILOAD; +import static org.objectweb.asm.Opcodes.INVOKESPECIAL; +import static org.objectweb.asm.Opcodes.INVOKESTATIC; +import static org.objectweb.asm.Opcodes.INVOKEVIRTUAL; +import static org.objectweb.asm.Opcodes.IRETURN; +import static org.objectweb.asm.Opcodes.ISTORE; +import static org.objectweb.asm.Opcodes.L2I; +import static org.objectweb.asm.Opcodes.LDIV; +import static org.objectweb.asm.Opcodes.LREM; +import static org.objectweb.asm.Opcodes.NEW; import org.apache.logging.log4j.Level; import org.objectweb.asm.AnnotationVisitor; @@ -11,12 +41,7 @@ import org.objectweb.asm.Label; import org.objectweb.asm.MethodVisitor; import cpw.mods.fml.relauncher.FMLRelaunchLog; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import gtPlusPlus.preloader.DevHelper; -import net.minecraft.item.ItemStack; -import thaumcraft.api.aspects.Aspect; -import thaumcraft.api.aspects.AspectList; public class ClassTransformer_TC_ItemWispEssence { @@ -246,30 +271,6 @@ public class ClassTransformer_TC_ItemWispEssence { } } - static Aspect[] displayAspects; - - @SideOnly(Side.CLIENT) - public int getColorFromItemStack(ItemStack stack, int par2) { - if (stack == null) { - return 0; - } - if (this.getAspects(stack) != null) { - return this.getAspects(stack).getAspects()[0].getColor(); - } else { - int idx = (int) (System.currentTimeMillis() / 500L % (long) displayAspects.length); - return displayAspects[idx].getColor(); - } - } - - public AspectList getAspects(ItemStack itemstack) { - if (itemstack.hasTagCompound()) { - AspectList aspects = new AspectList(); - aspects.readFromNBT(itemstack.getTagCompound()); - return aspects.size() > 0 ? aspects : null; - } else { - return null; - } - } diff --git a/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_ClassTransformer2.java b/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_ClassTransformer2.java index 390289d162..507e2cf974 100644 --- a/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_ClassTransformer2.java +++ b/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_ClassTransformer2.java @@ -329,8 +329,6 @@ public class Preloader_ClassTransformer2 { Logger.REFLECTION("mItemStorageNBT: "+(mItemStorageNBT != null)); //mItemStorageNBT - - ItemStack rStack = new ItemStack(GregTech_API.sBlockMachines, 1, tID); NBTTagCompound tNBT = new NBTTagCompound(); if (tRecipeStuff != null && !tRecipeStuff.hasNoTags()) tNBT.setTag("GT.CraftingComponents", tRecipeStuff); diff --git a/src/Java/gtPlusPlus/xmod/forestry/bees/custom/GTPP_Bees.java b/src/Java/gtPlusPlus/xmod/forestry/bees/custom/GTPP_Bees.java index fd83cc707d..7d45899911 100644 --- a/src/Java/gtPlusPlus/xmod/forestry/bees/custom/GTPP_Bees.java +++ b/src/Java/gtPlusPlus/xmod/forestry/bees/custom/GTPP_Bees.java @@ -111,7 +111,6 @@ public class GTPP_Bees { input, null, output, - 0, 30, 8); } diff --git a/src/Java/gtPlusPlus/xmod/galacticraft/handler/HandlerTooltip_GC.java b/src/Java/gtPlusPlus/xmod/galacticraft/handler/HandlerTooltip_GC.java index 64f1cfbe23..3b59b58cab 100644 --- a/src/Java/gtPlusPlus/xmod/galacticraft/handler/HandlerTooltip_GC.java +++ b/src/Java/gtPlusPlus/xmod/galacticraft/handler/HandlerTooltip_GC.java @@ -21,6 +21,10 @@ public class HandlerTooltip_GC { private static Class oMainClass; private static Class oFuelLoaderClass; private static HashMap mFuelNames; + + static { + mFuelNames = new LinkedHashMap(); + } @SubscribeEvent public void onItemTooltip(ItemTooltipEvent event) { @@ -38,7 +42,7 @@ public class HandlerTooltip_GC { oFuelLoaderClass = GCFuelLoader; } - Field aField = ReflectionUtils.getField(GCBlocks, "fuelLoader"); + Field aField = ReflectionUtils.getField(oMainClass, "fuelLoader"); if (aField != null) { Block aBlock = (Block) aField.get(null); if (aBlock != null) { @@ -49,10 +53,12 @@ public class HandlerTooltip_GC { } } catch (Throwable t) { } - } + } + if (mFuelNames == null) { + mFuelNames = new LinkedHashMap(); + } - if (mFuelNames == null || mFuelNames.isEmpty()) { - mFuelNames = new LinkedHashMap(); + if (mFuelNames.isEmpty()) { for (int aMapKey : RocketFuels.mValidRocketFuels.keySet()) { Fluid aFuel = RocketFuels.mValidRocketFuels.get(aMapKey); if (aFuel != null) { diff --git a/src/Java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java b/src/Java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java index 0143c9096f..f85d432b0c 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java @@ -59,6 +59,7 @@ public class HANDLER_GT { public static final List sWorldgenListEverglades = new ArrayList(); public static final List sWorldgenListAustralia = new ArrayList(); public static final List sCustomWorldgenList = new ArrayList(); + public static GT_MetaGenerated_Tool sMetaGeneratedToolInstance; public static void preInit(){ @@ -88,7 +89,7 @@ public class HANDLER_GT { //Only loads if the config option is true (default: true) if (CORE.ConfigSwitches.enableSkookumChoochers){ - new MetaGeneratedGregtechTools(); + sMetaGeneratedToolInstance= MetaGeneratedGregtechTools.getInstance(); } if (ConfigSwitches.enableOldGTcircuits && !CORE.GTNH){ diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/IGregtech_RecipeAdder.java b/src/Java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/IGregtech_RecipeAdder.java index 94adb5a92c..2726b140ca 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/IGregtech_RecipeAdder.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/IGregtech_RecipeAdder.java @@ -216,10 +216,14 @@ public interface IGregtech_RecipeAdder { public boolean addSmeltingAndAlloySmeltingRecipe(ItemStack aDust, ItemStack aOutput); - public boolean addFluidExtractionRecipe(ItemStack input, ItemStack input2, FluidStack output, int aTime, int aEu, int aSpecial); + public boolean addFluidExtractionRecipe(ItemStack aContainer, ItemStack aFullContainer, FluidStack rFluidOut, int aTime, int aEu); + + public boolean addFluidCannerRecipe(ItemStack aContainer, ItemStack aFullContainer, FluidStack rFluidIn); public boolean addFluidCannerRecipe(ItemStack aContainer, ItemStack aFullContainer, FluidStack rFluidIn, FluidStack rFluidOut); + public boolean addFluidCannerRecipe(ItemStack aContainer, ItemStack aFullContainer, FluidStack rFluidIn, FluidStack rFluidOut, int aTime, int aEu); + /** * Adds a Fusion reactor Recipe * diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_BasicLosslessGenerator.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_BasicLosslessGenerator.java index 1ce7fc49d3..e1b329c07f 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_BasicLosslessGenerator.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_BasicLosslessGenerator.java @@ -247,9 +247,9 @@ public abstract class GTPP_MTE_BasicLosslessGenerator extends GTPP_MTE_BasicTank public int getFuelValue(FluidStack aLiquid) { if (aLiquid != null && this.getRecipes() != null) { Collection tRecipeList = this.getRecipes().mRecipeList; - Logger.WARNING("Fuels: "+tRecipeList.size()); if (tRecipeList != null) { - Iterator var4 = tRecipeList.iterator(); + Logger.WARNING("Fuels: "+tRecipeList.size()); + Iterator var4 = tRecipeList.iterator(); while (var4.hasNext()) { GT_Recipe tFuel = (GT_Recipe) var4.next(); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Input.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Input.java index e0844bb071..4c60d9a932 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Input.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Input.java @@ -9,7 +9,6 @@ import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Utility; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.minecraft.PlayerUtils; -import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.IInventory; @@ -17,7 +16,6 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; public class GT_MetaTileEntity_SuperBus_Input extends GT_MetaTileEntity_Hatch_InputBus { - public GT_Recipe_Map mRecipeMap = null; public GT_MetaTileEntity_SuperBus_Input(int aID, String aName, String aNameRegional, int aTier) { super(aID, aName, aNameRegional, aTier); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GT_MetaTileEntity_Hatch_CustomFluidBase.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GT_MetaTileEntity_Hatch_CustomFluidBase.java index 839fb3a14a..c9b98a6a64 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GT_MetaTileEntity_Hatch_CustomFluidBase.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GT_MetaTileEntity_Hatch_CustomFluidBase.java @@ -102,7 +102,7 @@ public class GT_MetaTileEntity_Hatch_CustomFluidBase extends GT_MetaTileEntity_H String[] s2 = new String[]{ "Fluid Input for Multiblocks", "Capacity: " + getCapacity()+"L", - "Accepted Fluid: " + mTempMod + mLockedStack.getLocalizedName() + "Accepted Fluid: " + mTempMod + mLockedStack != null ? mLockedStack.getLocalizedName() : "Empty" }; return s2; } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java index 3b8597c5eb..68b81182fc 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java @@ -86,6 +86,18 @@ GT_MetaTileEntity_MultiBlockBase { Logger.MACHINE_INFO("Found .08 findRecipe method? "+(a08 != null)); Logger.MACHINE_INFO("Found .09 findRecipe method? "+(a09 != null)); + if (CORE.DEBUG) { + aLogger = ReflectionUtils.getMethod(Logger.class, "INFO", String.class); + } + else { + aLogger = ReflectionUtils.getMethod(Logger.class, "MACHINE_INFO", String.class); + } + + try { + calculatePollutionReduction = GT_MetaTileEntity_Hatch_Muffler.class.getDeclaredMethod("calculatePollutionReduction", int.class); + } catch (NoSuchMethodException | SecurityException e) {} + + //gregtech.api.util.GT_Recipe.GT_Recipe_Map.findRecipe(IHasWorldObjectAndCoords, GT_Recipe, boolean, long, FluidStack[], ItemStack, ItemStack...) } @@ -523,20 +535,27 @@ GT_MetaTileEntity_MultiBlockBase { public void log(String s) { - boolean isDebugLogging = CORE.DEBUG; - boolean reset = true; + boolean isDebugLogging = CORE.DEBUG; + boolean reset = false; - if (aLogger == null || reset) { + if (reset) { if (isDebugLogging) { - aLogger = ReflectionUtils.getMethod(Logger.class, "INFO", String.class); + aLogger = ReflectionUtils.getMethod( + Logger.class, "INFO", String.class + ); } else { - aLogger = ReflectionUtils.getMethod(Logger.class, "MACHINE_INFO", String.class); + aLogger = ReflectionUtils.getMethod( + Logger.class, "MACHINE_INFO", String.class + ); } } try { aLogger.invoke(null, s); - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {} + } + catch (IllegalAccessException | IllegalArgumentException + | InvocationTargetException e) { + } } @@ -1435,13 +1454,15 @@ GT_MetaTileEntity_MultiBlockBase { boolean aExists = false; for (E m : aList) { IGregTechTileEntity b = ((IMetaTileEntity) m).getBaseMetaTileEntity(); - BlockPos aPos = new BlockPos(b); - if (b != null && aPos != null) { - if (aCurPos.equals(aPos)) { - if (GTplusplus.CURRENT_LOAD_PHASE == INIT_PHASE.STARTED) { - log("Found Duplicate "+b.getInventoryName()+" at " + aPos.getLocationString()); + if (b != null) { + BlockPos aPos = new BlockPos(b); + if (aPos != null) { + if (aCurPos.equals(aPos)) { + if (GTplusplus.CURRENT_LOAD_PHASE == INIT_PHASE.STARTED) { + log("Found Duplicate "+b.getInventoryName()+" at " + aPos.getLocationString()); + } + return false; } - return false; } } } @@ -1867,20 +1888,16 @@ GT_MetaTileEntity_MultiBlockBase { } } - private static Method calculatePollutionReduction; + private static Method calculatePollutionReduction = null; public int calculatePollutionReductionForHatch(GT_MetaTileEntity_Hatch_Muffler i , int g) { - if (calculatePollutionReduction == null) { + if (calculatePollutionReduction != null) { try { - calculatePollutionReduction = i.getClass().getDeclaredMethod("calculatePollutionReduction", int.class); - } catch (NoSuchMethodException | SecurityException e) { - calculatePollutionReduction = null; + return (int) calculatePollutionReduction.invoke(i, g); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + } - } - try { - return (int) calculatePollutionReduction.invoke(i, g); - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - return 0; } + return 0; } @Override diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen_Boulder.java b/src/Java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen_Boulder.java index c8a7b5119d..ca78a72e04 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen_Boulder.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen_Boulder.java @@ -3,6 +3,7 @@ package gtPlusPlus.xmod.gregtech.api.world; import java.util.Collection; import java.util.Random; +import gtPlusPlus.core.lib.CORE; import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.util.MathHelper; @@ -21,7 +22,7 @@ public class GTPP_Worldgen_Boulder extends GTPP_Worldgen_Ore { int tX = aChunkX + aRandom.nextInt(16), tY = mMinY + aRandom.nextInt(mMaxY - mMinY), tZ = aChunkZ + aRandom.nextInt(16); Block tBlock = aWorld.getBlock(tX, tY - 7, tZ); if (tBlock != null && tBlock.isOpaqueCube() && aWorld.getBlock(tX, tY - 6, tZ).isAir(aWorld, tX, tY - 6, tZ)) { - float math_pi = 3.141593F; + float math_pi = CORE.PI; float var6 = aRandom.nextFloat() * math_pi; float var1b = mSize / 8.0F; float var3b = MathHelper.sin(var6) * var1b; float var4b = MathHelper.cos(var6) * var1b; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen_Ore_Normal.java b/src/Java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen_Ore_Normal.java index 9d7eb5a020..e66106ad4a 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen_Ore_Normal.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen_Ore_Normal.java @@ -3,6 +3,7 @@ package gtPlusPlus.xmod.gregtech.api.world; import java.util.Collection; import java.util.Random; +import gtPlusPlus.core.lib.CORE; import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.util.MathHelper; @@ -20,7 +21,7 @@ public class GTPP_Worldgen_Ore_Normal extends GTPP_Worldgen_Ore { for (int i = 0; i < mAmount; i++) { int tX = aChunkX + aRandom.nextInt(16), tY = mMinY + aRandom.nextInt(mMaxY - mMinY), tZ = aChunkZ + aRandom.nextInt(16); if (mAllowToGenerateinVoid || aWorld.getBlock(tX, tY, tZ).isAir(aWorld, tX, tY, tZ)) { - float math_pi = 3.141593F;float var1b = mSize / 8.0F; + float math_pi = CORE.PI;float var1b = mSize / 8.0F; float var6 = aRandom.nextFloat() * math_pi; float var3b = MathHelper.sin(var6) * var1b; float var4b = MathHelper.cos(var6) * var1b; float var8b = -2*var3b;float var9b = -2*var4b; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java b/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java index 629c584f70..2d7151bf45 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java @@ -32,7 +32,6 @@ import gtPlusPlus.api.objects.minecraft.FormattedTooltipString; import gtPlusPlus.core.handler.AchievementHandler; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.material.ELEMENT; -import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.minecraft.FluidUtils; import gtPlusPlus.core.util.minecraft.MaterialUtils; import gtPlusPlus.core.util.reflect.ReflectionUtils; @@ -51,19 +50,16 @@ import net.minecraftforge.fluids.FluidStack; public class Meta_GT_Proxy { static { - instance = new Meta_GT_Proxy(); Logger.INFO("GT_PROXY - initialized."); } - public static final Meta_GT_Proxy instance; - public static List GT_BlockIconload = new ArrayList<>(); public static List GT_ItemIconload = new ArrayList<>(); public static AutoMap GT_ValidHeatingCoilMetas = new AutoMap(); - private static Class sBaseMetaTileEntityClass; - private static Class sBaseMetaTileEntityClass2; + private static Class sBaseMetaTileEntityClass; + private static Class sBaseMetaTileEntityClass2; public static AchievementHandler mAssemblyAchievements; @@ -79,7 +75,7 @@ public class Meta_GT_Proxy { public static Block sBlockMachines; - public void preInit() { + public static void preInit() { //New GT++ Block, yay! (Progress) //sBlockMachines = new GTPP_Block_Machines(); @@ -110,12 +106,12 @@ public class Meta_GT_Proxy { CoverManager.generateCustomCovers(); } - public void init() { + public static void init() { scheduleCoverMapCleaner(); setValidHeatingCoilMetas(); } - public void postInit() { + public static void postInit() { mAssemblyAchievements = new AchievementHandler(); } @@ -317,7 +313,7 @@ public class Meta_GT_Proxy { - public void setValidHeatingCoilMetas() { + public static void setValidHeatingCoilMetas() { for (int i = 0; i <= 6; i++ ) { GT_ValidHeatingCoilMetas.put(i); } @@ -342,7 +338,7 @@ public class Meta_GT_Proxy { } - public void scheduleCoverMapCleaner(){ + public static void scheduleCoverMapCleaner(){ TimerTask repeatedTask = new TimerTask() { public void run() { cleanupOverFlowCoverCache(); @@ -360,6 +356,7 @@ public class Meta_GT_Proxy { long aCurrentTime = System.currentTimeMillis()/1000; for (Object o : cache.values()) { if (o != null && o instanceof HashMap) { + @SuppressWarnings("unchecked") HashMap m = (HashMap) o; if (m != null) { String s = (String) m.get("aCoverKey"); @@ -390,7 +387,7 @@ public class Meta_GT_Proxy { return StaticFields59.getFieldFromGregtechProxy(fieldName); } - public void setCustomGregtechTooltip(String aNbtTagName, FormattedTooltipString aData) { + public static void setCustomGregtechTooltip(String aNbtTagName, FormattedTooltipString aData) { mCustomGregtechMetaTooltips.put(aNbtTagName, aData); } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/TreeFarmHelper.java b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/TreeFarmHelper.java index 4038d5bdf4..8b3fb9a42f 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/TreeFarmHelper.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/TreeFarmHelper.java @@ -297,7 +297,7 @@ public class TreeFarmHelper { return true; } else if (aStack.getUnlocalizedName().toLowerCase().contains("mu-metaitem")) { - String[] aData = aStack.getUnlocalizedName().toLowerCase().split("."); + String[] aData = aStack.getUnlocalizedName().toLowerCase().split("//."); if (aData != null && aData.length > 0) { for (String s : aData) { if (s.contains("32120")) { diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechTools.java b/src/Java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechTools.java index 236ae65edb..bc11cb6a11 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechTools.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechTools.java @@ -8,7 +8,6 @@ import gregtech.api.enums.ToolDictNames; import gregtech.api.items.GT_MetaGenerated_Tool; import gregtech.api.objects.GT_HashSet; import gregtech.api.objects.GT_ItemStack; -import gregtech.common.tools.GT_Tool_WireCutter; import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.gregtech.api.enums.GregtechToolDictNames; import gtPlusPlus.xmod.gregtech.common.tools.TOOL_Gregtech_AngelGrinder; @@ -25,10 +24,18 @@ public class MetaGeneratedGregtechTools extends GT_MetaGenerated_Tool { public static final short ANGLE_GRINDER = 7834; public static final short ELECTRIC_SNIPS = 7934; public static GT_MetaGenerated_Tool INSTANCE; + + static { + INSTANCE = new MetaGeneratedGregtechTools(); + } + + public static GT_MetaGenerated_Tool getInstance() { + return INSTANCE; + } + - public MetaGeneratedGregtechTools() { + private MetaGeneratedGregtechTools() { super("plusplus.metatool.01"); - INSTANCE = this; // Skookum Choocher GregTech_API.registerTool(this.addTool(SKOOKUM_CHOOCHER, "Skookum Choocher", "Can Really Chooch. Does a Skookum job at Hammering and Wrenching stuff.", new TOOL_Gregtech_Choocher(), diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaAtmosphericReconditioner.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaAtmosphericReconditioner.java index 4795b0d0b9..10a1f96be7 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaAtmosphericReconditioner.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaAtmosphericReconditioner.java @@ -710,8 +710,17 @@ public class GregtechMetaAtmosphericReconditioner extends GT_MetaTileEntity_Basi catch (Throwable t) { aTooltipSuper.put("Maximum pollution removed per second: "+mPollutionReduction); } - aTooltipSuper.put("Air Sides: "+mAirSides); - return aTooltipSuper.toArray(); + aTooltipSuper.put("Air Sides: "+mAirSides); + + String[] mBuiltOutput = new String[aTooltipSuper.size()]; + int aIndex = 0; + for (String i : aTooltipSuper) { + mBuiltOutput[aIndex++] = i; + } + + + + return mBuiltOutput; } @Override diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMultiMachine.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMultiMachine.java index 2e0eeea844..8b07117596 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMultiMachine.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMultiMachine.java @@ -609,8 +609,13 @@ extends GregtechMeta_MultiBlockBase { } // -- Try not to fail after this point - inputs have already been consumed! -- - ItemStack[] mBuiltOutput = this.mReplicatorOutputMap.toArray(); - + ItemStack[] mBuiltOutput = new ItemStack[this.mReplicatorOutputMap.size()]; + int aIndex = 0; + for (ItemStack i : this.mReplicatorOutputMap) { + mBuiltOutput[aIndex++] = i; + } + + // Convert speed bonus to duration multiplier // e.g. 100% speed bonus = 200% speed = 100%/200% = 50% recipe duration. aSpeedBonusPercent = Math.max(-99, aSpeedBonusPercent); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_MiniFusionPlant.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_MiniFusionPlant.java index 8925caf480..cb8b7590ee 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_MiniFusionPlant.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_MiniFusionPlant.java @@ -207,7 +207,7 @@ public class GregtechMTE_MiniFusionPlant extends GregtechMeta_MultiBlockBase { FluidStack[] arg5 = (FluidStack[]) tFluidList.toArray(new FluidStack[tFluidList.size()]); GT_Recipe arg6 = getRecipeMap().findRecipe(this.getBaseMetaTileEntity(), this.mLastRecipe, false, this.getMaxInputVoltage(), arg5, new ItemStack[0]); - if (arg6 == null && !this.mRunningOnLoad || this.maxEUStore() < (long) arg6.mSpecialValue) { + if (arg6 == null && !this.mRunningOnLoad || (arg6 != null && this.maxEUStore() < (long) arg6.mSpecialValue)) { //Logger.INFO("Bad Step "+aStep++); //this.turnCasingActive(false); this.mLastRecipe = null; @@ -215,7 +215,7 @@ public class GregtechMTE_MiniFusionPlant extends GregtechMeta_MultiBlockBase { } //Logger.INFO("Step "+aStep++); - if (this.mRunningOnLoad || arg6.isRecipeInputEqual(true, arg5, new ItemStack[0])) { + if (this.mRunningOnLoad || (arg6 != null && arg6.isRecipeInputEqual(true, arg5, new ItemStack[0]))) { //Logger.INFO("Step "+aStep++); this.mLastRecipe = arg6; this.mEUt = this.mLastRecipe.mEUt * 1; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java index 33555c8f51..f3fefdf789 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java @@ -34,6 +34,10 @@ public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase public static int CASING_TEXTURE_ID; public static String mCasingName = "Advanced Cryogenic Casing"; public static TreeGenerator mTreeData; + + static { + mTreeData = new TreeGenerator(); + } public GregtechMetaTileEntityTreeFarm(final int aID, final String aName, final String aNameRegional) { super(aID, aName, aNameRegional); @@ -76,10 +80,6 @@ public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase } }*/ - if (mTreeData == null) { - mTreeData = new TreeGenerator(); - } - diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Refinery.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Refinery.java index 07c8a4a7ac..24db72fbe0 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Refinery.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Refinery.java @@ -22,8 +22,6 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection; public class GregtechMetaTileEntity_Refinery extends GregtechMeta_MultiBlockBase { - - public GT_Recipe mLastRecipe; public GregtechMetaTileEntity_Refinery(final int aID, final String aName, final String aNameRegional) { super(aID, aName, aNameRegional); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_DustGeneration.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_DustGeneration.java index d8a5617b2e..d4a25e03dd 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_DustGeneration.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_DustGeneration.java @@ -266,7 +266,7 @@ public class RecipeGen_DustGeneration extends RecipeGen_Base { //Get us four ItemStacks to input into the mixer ItemStack input1, input2, input3, input4; - input1 = (inputStacks.length >= 1) ? (input1 = (inputStacks[0] == null) ? null : inputStacks[0]) : null; + input1 = inputStacks[0]; input2 = (inputStacks.length >= 2) ? (input2 = (inputStacks[1] == null) ? null : inputStacks[1]) : null; input3 = (inputStacks.length >= 3) ? (input3 = (inputStacks[2] == null) ? null : inputStacks[2]) : null; input4 = (inputStacks.length >= 4) ? (input4 = (inputStacks[3] == null) ? null : inputStacks[3]) : null; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_FluidCanning.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_FluidCanning.java index 0a20d9357c..ce4a6c629a 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_FluidCanning.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_FluidCanning.java @@ -3,6 +3,7 @@ package gtPlusPlus.xmod.gregtech.loaders; import java.util.HashSet; import java.util.Set; +import gregtech.api.GregTech_API; import gregtech.api.enums.GT_Values; import gregtech.api.enums.Materials; import gregtech.api.util.GT_Recipe; @@ -26,8 +27,23 @@ public class RecipeGen_FluidCanning extends RecipeGen_Base { private final GT_Recipe recipe; private final boolean isValid; - // Alternative Constructor + public boolean valid() { + return isValid; + } + public RecipeGen_FluidCanning(boolean aExtracting, ItemStack aEmpty, ItemStack aFull, FluidStack aFluid) { + this(aExtracting, aEmpty, aFull, aFluid, null, null, null); + } + + public RecipeGen_FluidCanning(boolean aExtracting, ItemStack aEmpty, ItemStack aFull, FluidStack aFluidIn, FluidStack aFluidOut) { + this(aExtracting, aEmpty, aFull, aFluidIn, aFluidOut, null, null); + } + public RecipeGen_FluidCanning(boolean aExtracting, ItemStack aEmpty, ItemStack aFull, FluidStack aFluid, Integer aDuration, Integer aEUt) { + this(aExtracting, aEmpty, aFull, aFluid, null, aDuration, aEUt); + } + + // Alternative Constructor + public RecipeGen_FluidCanning(boolean aExtracting, ItemStack aEmpty, ItemStack aFull, FluidStack aFluidIn, FluidStack aFluidOut, Integer aDuration, Integer aEUt) { ItemStack aInput; ItemStack aOutput; FluidStack aFluidInput; @@ -35,7 +51,7 @@ public class RecipeGen_FluidCanning extends RecipeGen_Base { // Safety check on the duration if (aDuration == null || aDuration <= 0) { - aDuration = (aFluid != null) ? (aFluid.amount / 62) : (1000 / 62); + aDuration = (aFluidIn != null) ? (aFluidIn.amount / 62) : ((aFluidOut != null) ? (aFluidOut.amount / 62) : 10); } // Safety check on the EU @@ -53,13 +69,13 @@ public class RecipeGen_FluidCanning extends RecipeGen_Base { aInput = aFull; aOutput = aEmpty; aFluidInput = null; - aFluidOutput = aFluid; + aFluidOutput = aFluidIn; } else { aInput = aEmpty; - aOutput = aFull; - aFluidInput = aFluid; - aFluidOutput = null; + aOutput = aFull; + aFluidInput = aFluidIn; + aFluidOutput = aFluidOut != null ? aFluidOut : GT_Values.NF; } //Check validity @@ -69,16 +85,16 @@ public class RecipeGen_FluidCanning extends RecipeGen_Base { new ItemStack[] { aInput }, new ItemStack[] { aOutput }, null, - new int[] {}, + new int[] {10000}, new FluidStack[] { aFluidInput }, new FluidStack[] { aFluidOutput }, aDuration, - 1, + aEUt, 0); // Not Valid - if ((aExtracting && (aInput == null || aOutput == null ||aFluidOutput == null)) || (!aExtracting && (aInput == null || aOutput == null || aFluidInput == null))) { + if ((aExtracting && (aInput == null || aOutput == null ||(aFluidInput == null && aFluidOutput == null))) || (!aExtracting && (aInput == null || aOutput == null || (aFluidInput == null && aFluidOutput == null)))) { isValid = false; disableOptional = aExtracting; recipe = null; @@ -102,77 +118,54 @@ public class RecipeGen_FluidCanning extends RecipeGen_Base { } private void generateRecipes() { - if (isValid && recipe != null) { - //Used to store Fluid extraction state + if (isValid && recipe != null) { if (this.disableOptional) { - addFluidExtractionRecipe( - recipe.mInputs.length >= 1 ? recipe.mInputs[0] : null, //Input - recipe.mInputs.length == 2 ? recipe.mInputs[1] : null, //Input 2 - recipe.mFluidOutputs.length == 1 ? recipe.mFluidOutputs[0] : null, //Fluid Output - recipe.mDuration, //Duration - recipe.mEUt //Eu Tick - ); + addFluidExtractionRecipe(recipe); } else { - addFluidCannerRecipe( - recipe.mInputs.length == 1 ? recipe.mInputs[0] : null, //Input - recipe.mOutputs.length == 1 ? recipe.mOutputs[0] : null, //Input 2 - recipe.mFluidInputs.length == 1 ? recipe.mFluidInputs[0] : null //Fluid Input - ); - + addFluidCannerRecipe(recipe); } - } } - private final boolean addFluidExtractionRecipe(final ItemStack aInput, final ItemStack aRemains, FluidStack aOutput, int aDuration, final int aEUt) { - if (aInput == null || aOutput == null) { - return false; - } - if (aOutput.isFluidEqual(Materials.PhasedGold.getMolten(1L))) { - aOutput = Materials.VibrantAlloy.getMolten(aOutput.amount); - } - if (aOutput.isFluidEqual(Materials.PhasedIron.getMolten(1L))) { - aOutput = Materials.PulsatingIron.getMolten(aOutput.amount); + private final boolean addFluidExtractionRecipe(GT_Recipe aRecipe) { + if (aRecipe != null) { + if ((aRecipe.mDuration = GregTech_API.sRecipeFile.get("fluidextractor", aRecipe.mInputs[0], aRecipe.mDuration)) <= 0) { + return false; + } else { + GT_Recipe_Map.sFluidExtractionRecipes.addRecipe(aRecipe); + return true; + } } - //Logger.INFO(buildLogString()); - boolean result = GT_Values.RA.addFluidExtractionRecipe(aInput, aRemains, aOutput, 10000, aDuration, aEUt); - //Logger.INFO(buildLogString()); - //dumpStack(); - return result; + return false; } - public final boolean addFluidCannerRecipe(final ItemStack aInput, final ItemStack aOutput, FluidStack aFluidInput) { - if (aInput == null || aOutput == null || aFluidInput == null) { - return false; - } - if (aFluidInput.isFluidEqual(Materials.PhasedGold.getMolten(1L))) { - aFluidInput = Materials.VibrantAlloy.getMolten(aFluidInput.amount); - } - if (aFluidInput.isFluidEqual(Materials.PhasedIron.getMolten(1L))) { - aFluidInput = Materials.PulsatingIron.getMolten(aFluidInput.amount); + private final boolean addFluidCannerRecipe(GT_Recipe recipe2) { + if (recipe2 != null) { + if ((recipe2.mDuration = GregTech_API.sRecipeFile.get("fluidcanner", recipe2.mOutputs[0], recipe2.mDuration)) <= 0) { + return false; + } else { + GT_Recipe_Map.sFluidCannerRecipes.addRecipe(recipe2); + return true; + } } - //Logger.INFO(buildLogString()); - boolean result = GT_Values.RA.addFluidCannerRecipe(aInput, aOutput, aFluidInput, GT_Values.NF); - //Logger.INFO(buildLogString()); - //dumpStack(); - return result; - } - + return false; + } + private void dumpStack() { int parents = 2; for (int i=0;i<6;i++) { Logger.INFO((disableOptional ? "EXTRACTING" : "CANNING")+" DEBUG | "+(i == 0 ? "Called from: " : "Parent: ")+ReflectionUtils.getMethodName(i+parents)); } - + } - + private String buildLogString() { int solidSize = getMapSize(GT_Recipe_Map.sCannerRecipes); int fluidSize = getMapSize(GT_Recipe_Map.sFluidCannerRecipes); return (disableOptional ? "EXTRACTING" : "CANNING")+" DEBUG | Solids: "+solidSize+" | Liquids: "+fluidSize+" | "; } - + private final int getMapSize(GT_Recipe_Map aMap) { return aMap.mRecipeList.size(); } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Fluids.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Fluids.java index b3b71c7587..799c6cd63b 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Fluids.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Fluids.java @@ -51,7 +51,6 @@ public class RecipeGen_Fluids extends RecipeGen_Base { if (CORE.RA.addFluidExtractionRecipe(material.getIngot(1), // Input null, // Input 2 material.getFluid(144), // Fluid Output - 0, // Chance 1 * 20, // Duration material.vVoltageMultiplier // Eu Tick )) { @@ -67,7 +66,6 @@ public class RecipeGen_Fluids extends RecipeGen_Base { if (CORE.RA.addFluidExtractionRecipe(material.getPlate(1), // Input null, // Input 2 material.getFluid(144), // Fluid Output - 0, // Chance 1 * 20, // Duration material.vVoltageMultiplier // Eu Tick )) { @@ -83,7 +81,6 @@ public class RecipeGen_Fluids extends RecipeGen_Base { if (CORE.RA.addFluidExtractionRecipe(material.getPlateDouble(1), // Input null, // Input 2 material.getFluid(288), // Fluid Output - 0, // Chance 1 * 20, // Duration material.vVoltageMultiplier // Eu Tick )) { @@ -99,7 +96,6 @@ public class RecipeGen_Fluids extends RecipeGen_Base { if (CORE.RA.addFluidExtractionRecipe(material.getNugget(1), // Input null, // Input 2 material.getFluid(16), // Fluid Output - 0, // Chance 16, // Duration material.vVoltageMultiplier // Eu Tick )) { @@ -115,7 +111,6 @@ public class RecipeGen_Fluids extends RecipeGen_Base { if (CORE.RA.addFluidExtractionRecipe(material.getBlock(1), // Input null, // Input 2 material.getFluid(144 * 9), // Fluid Output - 0, // Chance 288, // Duration material.vVoltageMultiplier // Eu Tick )) { diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Ore.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Ore.java index 52f7ab24f3..9b7e1d708d 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Ore.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Ore.java @@ -219,9 +219,10 @@ public class RecipeGen_Ore extends RecipeGen_Base { Logger.MATERIALS("material.getCrushed(1): "+(material.getCrushed(1) != null)); Logger.MATERIALS("material.getCrushedPurified(1): "+(material.getCrushedPurified(1) != null)); - Logger.MATERIALS("bonusA.getTinyDust(1): "+(tinyDustA != null)+" | Material: "+(bonusA != null) + " | Material name: "+(bonusA != null ? bonusA.getLocalizedName() : "invalid material")); - Logger.MATERIALS("bonusB.getTinyDust(1): "+(tinyDustB != null)+" | Material: "+(bonusB != null) + " | Material name: "+(bonusB != null ? bonusB.getLocalizedName() : "invalid material")); + Logger.MATERIALS("material.getTinyDust(1): "+(ItemUtils.getItemName(bonusA.getCrushed(1)))); + Logger.MATERIALS("material.getTinyDust(1): "+(ItemUtils.getItemName(bonusB.getCrushed(1)))); + try { //.08 compat if (GT_ModHandler.addThermalCentrifugeRecipe(material.getCrushed(1), 200, material.getCrushedCentrifuged(1), tinyDustB, dustStone)){ diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Recycling.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Recycling.java index 3328b0894f..58db8a473f 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Recycling.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Recycling.java @@ -7,16 +7,11 @@ import java.util.Map; import org.apache.commons.lang3.reflect.FieldUtils; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; - -import gregtech.api.enums.GT_Values; import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_OreDictUnificator; import gregtech.api.util.GT_Utility; - import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.api.objects.data.Pair; @@ -26,6 +21,8 @@ import gtPlusPlus.core.material.state.MaterialState; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.reflect.ReflectionUtils; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; import net.minecraftforge.oredict.OreDictionary; public class RecipeGen_Recycling implements Runnable { @@ -60,6 +57,7 @@ public class RecipeGen_Recycling implements Runnable { public static void generateRecipes(final Material material) { + if (material != null) Logger.WARNING("Generating Recycling recipes for " + material.getLocalizedName()); final OrePrefixes[] mValidPrefixesAsString = { OrePrefixes.ingot, OrePrefixes.ingotHot, OrePrefixes.nugget, @@ -139,7 +137,7 @@ public class RecipeGen_Recycling implements Runnable { //Fluid Extractor if (ItemUtils.checkForInvalidItems(tempStack)) { // mValidItems[mSlotIndex++] = tempStack; - if ((mDust != null) && CORE.RA.addFluidExtractionRecipe(tempStack, null, material.getFluid(mFluidAmount), 0, 30, material.vVoltageMultiplier)) { + if ((mDust != null) && CORE.RA.addFluidExtractionRecipe(tempStack, null, material.getFluid(mFluidAmount), 30, material.vVoltageMultiplier)) { Logger.WARNING("Fluid Recycle Recipe: " + material.getLocalizedName() + " - Success - Recycle " + tempStack.getDisplayName() + " and obtain " + mFluidAmount+"mb of "+material.getFluid(1).getLocalizedName()+"."); } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java b/src/Java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java index 3c996ef64f..fa6f2ad790 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java @@ -19,7 +19,6 @@ import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.lib.LoadedMods; -import gtPlusPlus.core.material.ELEMENT; import gtPlusPlus.core.material.MaterialGenerator; import gtPlusPlus.core.recipe.common.CI; import gtPlusPlus.core.util.data.ArrayUtils; @@ -991,15 +990,24 @@ public class GregtechRecipeAdder implements IGregtech_RecipeAdder { } @Override - public boolean addFluidExtractionRecipe(ItemStack input, ItemStack input2, FluidStack output, int aTime, int aEu, int aSpecial) { - Method aExtractionMethod = ReflectionUtils.getMethod(MaterialGenerator.class, "addFluidExtractionRecipe", new Class[] {ItemStack.class, ItemStack.class, FluidStack.class, int.class, int.class}); - return ReflectionUtils.invoke(null, aExtractionMethod, new Object[] {input, input2, output, aSpecial, aTime, aEu}); + public boolean addFluidExtractionRecipe(ItemStack input, ItemStack input2, FluidStack output, int aTime, int aEu) { + return MaterialGenerator.addFluidExtractionRecipe(input, input2, output, aTime, aEu); + } + + @Override + public boolean addFluidCannerRecipe(ItemStack aFullContainer, ItemStack container, FluidStack rFluidIn) { + return MaterialGenerator.addFluidCannerRecipe(container, aFullContainer, rFluidIn, null); } @Override public boolean addFluidCannerRecipe(ItemStack aFullContainer, ItemStack container, FluidStack rFluidIn, FluidStack rFluidOut) { - Method aExtractionMethod = ReflectionUtils.getMethod(MaterialGenerator.class, "addFluidCannerRecipe", new Class[] {ItemStack.class, ItemStack.class, FluidStack.class}); - return ReflectionUtils.invoke(null, aExtractionMethod, new Object[] {aFullContainer, container, rFluidIn, rFluidOut}); + return MaterialGenerator.addFluidCannerRecipe(container, aFullContainer, rFluidIn, rFluidOut); + } + + + @Override + public boolean addFluidCannerRecipe(ItemStack aFullContainer, ItemStack container, FluidStack rFluidIn, FluidStack rFluidOut, int aTime, int aEu) { + return MaterialGenerator.addFluidCannerRecipe(container, aFullContainer, rFluidIn, rFluidOut, aTime, aEu); } /** diff --git a/src/Java/gtPlusPlus/xmod/growthcraft/fishtrap/FishTrapHandler.java b/src/Java/gtPlusPlus/xmod/growthcraft/fishtrap/FishTrapHandler.java index e394a8b8c0..6933987593 100644 --- a/src/Java/gtPlusPlus/xmod/growthcraft/fishtrap/FishTrapHandler.java +++ b/src/Java/gtPlusPlus/xmod/growthcraft/fishtrap/FishTrapHandler.java @@ -221,10 +221,10 @@ public class FishTrapHandler { private static void addGregtechFluidRecipe(final ItemStack input){ if (LoadedMods.Gregtech){ if (CORE.GTNH) { - CORE.RA.addFluidExtractionRecipe(input, null, FluidUtils.getFluidStack("fishoil", 50), 10000, 16, 4); + CORE.RA.addFluidExtractionRecipe(input, null, FluidUtils.getFluidStack("fishoil", 50), 16, 4); } else { - CORE.RA.addFluidExtractionRecipe(input, null, FluidUtils.getFluidStack("fishoil", 4), 0, 16, 4); //4eu/t total eu used = 64 so time = 64/4 + CORE.RA.addFluidExtractionRecipe(input, null, FluidUtils.getFluidStack("fishoil", 4), 16, 4); //4eu/t total eu used = 64 so time = 64/4 } } } diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/util/ThaumcraftUtils.java b/src/Java/gtPlusPlus/xmod/thaumcraft/util/ThaumcraftUtils.java index 8beaa8df5e..f23a5db6fe 100644 --- a/src/Java/gtPlusPlus/xmod/thaumcraft/util/ThaumcraftUtils.java +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/util/ThaumcraftUtils.java @@ -38,8 +38,18 @@ import net.minecraft.world.World; public class ThaumcraftUtils { - private static Class mClass_Aspect; + private static Class mClass_Aspect; private static Field mField_Aspects; + + static { + mClass_Aspect = ReflectionUtils.getClass("thaumcraft.api.aspects.Aspect"); + if (mClass_Aspect != null) { + Field aTagF = ReflectionUtils.getField(mClass_Aspect, "tag"); + if (aTagF != null) { + mField_Aspects = aTagF; + } + } + } public static boolean addAspectToItem(ItemStack item, TC_Aspect_Wrapper aspect, int amount) { return addAspectToItem(item, new TC_Aspect_Wrapper[] {aspect}, new Integer[] {amount}); @@ -212,10 +222,10 @@ public class ThaumcraftUtils { } - private static final Class mClass_ThaumcraftApi; - private static final Class mClass_ThaumcraftApiHelper; - private static final Class mClass_AspectList; - private static final Class mClass_ResearchManager; + private static final Class mClass_ThaumcraftApi; + private static final Class mClass_ThaumcraftApiHelper; + private static final Class mClass_AspectList; + private static final Class mClass_ResearchManager; private static final Method mMethod_registerObjectTag1; private static final Method mMethod_registerObjectTag2; private static final Method mMethod_registerComplexObjectTag; @@ -336,12 +346,11 @@ public class ThaumcraftUtils { public static String getTagFromAspectObject(Object aAspect) { - try { - Field aTagF = ReflectionUtils.getField(mClass_Aspect, "tag"); - if (aTagF == null) { + try { + if (mClass_Aspect == null || mField_Aspects == null) { return null; - } - String aTafB = (String) aTagF.get(aAspect); + } + String aTafB = (String) mField_Aspects.get(aAspect); if (aTafB == null) { return null; } diff --git a/src/Java/gtPlusPlus/xmod/thermalfoundation/recipe/TF_Gregtech_Recipes.java b/src/Java/gtPlusPlus/xmod/thermalfoundation/recipe/TF_Gregtech_Recipes.java index 1b2541ff3a..56e577fb7d 100644 --- a/src/Java/gtPlusPlus/xmod/thermalfoundation/recipe/TF_Gregtech_Recipes.java +++ b/src/Java/gtPlusPlus/xmod/thermalfoundation/recipe/TF_Gregtech_Recipes.java @@ -34,7 +34,7 @@ public class TF_Gregtech_Recipes { //Gelid Cryotheum Logger.INFO("Adding Recipes for Gelid Cryotheum"); - CORE.RA.addFluidExtractionRecipe(dust_Cryotheum, GT_Values.NI, getFluidStack("cryotheum", 250), 10000, 200, 240); + CORE.RA.addFluidExtractionRecipe(dust_Cryotheum, GT_Values.NI, getFluidStack("cryotheum", 250), 200, 240); GT_Values.RA.addChemicalBathRecipe((GT_OreDictUnificator.get(OrePrefixes.ore, Materials.Cinnabar, 1L)), getFluidStack("cryotheum", 144), GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Cinnabar, 3L), GT_Values.NI, GT_Values.NI, null, 400, 30); //Blizz Powder @@ -48,10 +48,10 @@ public class TF_Gregtech_Recipes { //Blazing Pyrotheum Logger.INFO("Adding Recipes for Blazing Pyrotheum"); - CORE.RA.addFluidExtractionRecipe(dust_Pyrotheum, GT_Values.NI, getFluidStack("pyrotheum", 250), 10000, 200, 240); + CORE.RA.addFluidExtractionRecipe(dust_Pyrotheum, GT_Values.NI, getFluidStack("pyrotheum", 250), 200, 240); //Ender Fluid - CORE.RA.addFluidExtractionRecipe(ItemUtils.getSimpleStack(Items.ender_pearl), GT_Values.NI, getFluidStack("ender", 250), 10000, 100, 30); + CORE.RA.addFluidExtractionRecipe(ItemUtils.getSimpleStack(Items.ender_pearl), GT_Values.NI, getFluidStack("ender", 250), 100, 30); ItemStack dustCoal = ItemUtils.getItemStackOfAmountFromOreDict("dustCoal", 1); -- cgit From 82f4a138efb59d8fdc4a492a190d3c8d7c53fbff Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Sun, 13 Oct 2019 21:54:43 +0100 Subject: + Added Round-Robinator recipes. % Adjusted Zirconium Carbide tier, and changed the materials used for LV tiered recipes. % Finished work on the Round-Robinator logic. $ Removed PSS log spam. $ Many minor bug fixes. --- src/Java/gtPlusPlus/api/objects/data/AutoMap.java | 7 +- .../gtPlusPlus/api/objects/minecraft/BlockPos.java | 2 +- .../api/objects/minecraft/FakeBlockPos.java | 2 +- src/Java/gtPlusPlus/api/objects/random/XSTR.java | 7 + .../core/block/machine/Machine_RoundRobinator.java | 78 ++- .../core/container/Container_RoundRobinator.java | 247 +++++--- .../core/gui/machine/GUI_RoundRobinator.java | 86 ++- src/Java/gtPlusPlus/core/handler/GuiHandler.java | 46 +- .../core/inventories/Inventory_RoundRobinator.java | 7 +- .../core/item/base/dusts/BaseItemDust.java | 3 +- .../core/item/base/dusts/BaseItemDustUnique.java | 2 +- .../item/base/itemblock/ItemBlockBasicTile.java | 6 +- .../base/itemblock/ItemBlockRoundRobinator.java | 111 ++++ .../core/item/bauble/FireProtectionBauble.java | 2 +- .../gtPlusPlus/core/recipe/RECIPES_Machines.java | 43 ++ src/Java/gtPlusPlus/core/recipe/common/CI.java | 6 +- .../machines/TileEntityRoundRobinator.java | 695 +++++++++++++++++---- .../gtPlusPlus/nei/DecayableRecipeHandler.java | 28 +- .../gtPlusPlus/nei/GT_NEI_MultiBlockHandler.java | 2 +- .../plugin/fixes/vanilla/VanillaBedHeightFix.java | 2 +- src/Java/gtPlusPlus/preloader/DevHelper.java | 2 +- ...chMetaTileEntity_PowerSubStationController.java | 5 +- src/resources/assets/miscutils/lang/en_US.lang | 11 +- .../RoundRobinator/RoundRobinator_Side_0.png | Bin 0 -> 1448 bytes .../RoundRobinator/RoundRobinator_Side_1.png | Bin 0 -> 1444 bytes .../RoundRobinator/RoundRobinator_Side_2.png | Bin 0 -> 1446 bytes .../RoundRobinator/RoundRobinator_Side_3.png | Bin 0 -> 1446 bytes .../RoundRobinator/RoundRobinator_Side_4.png | Bin 0 -> 1443 bytes .../RoundRobinator/RoundRobinator_Top_0.png | Bin 0 -> 1405 bytes .../RoundRobinator/RoundRobinator_Top_1.png | Bin 0 -> 1403 bytes .../RoundRobinator/RoundRobinator_Top_2.png | Bin 0 -> 1403 bytes .../RoundRobinator/RoundRobinator_Top_3.png | Bin 0 -> 1402 bytes .../RoundRobinator/RoundRobinator_Top_4.png | Bin 0 -> 1400 bytes .../miscutils/textures/gui/RoundRobinator.png | Bin 0 -> 1648 bytes 34 files changed, 1113 insertions(+), 287 deletions(-) create mode 100644 src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockRoundRobinator.java create mode 100644 src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Side_0.png create mode 100644 src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Side_1.png create mode 100644 src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Side_2.png create mode 100644 src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Side_3.png create mode 100644 src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Side_4.png create mode 100644 src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Top_0.png create mode 100644 src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Top_1.png create mode 100644 src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Top_2.png create mode 100644 src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Top_3.png create mode 100644 src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Top_4.png create mode 100644 src/resources/assets/miscutils/textures/gui/RoundRobinator.png (limited to 'src/Java/gtPlusPlus/api/objects') diff --git a/src/Java/gtPlusPlus/api/objects/data/AutoMap.java b/src/Java/gtPlusPlus/api/objects/data/AutoMap.java index 3583a04a74..9e7f702200 100644 --- a/src/Java/gtPlusPlus/api/objects/data/AutoMap.java +++ b/src/Java/gtPlusPlus/api/objects/data/AutoMap.java @@ -212,11 +212,12 @@ public class AutoMap implements Iterable, Cloneable, Serializable, Collect @Override public boolean retainAll(Collection c) { - AutoMap aTempAllocation = new AutoMap(); + AutoMap aTempAllocation = new AutoMap(); boolean aTrue = false; aTempAllocation = this; - aTempAllocation.removeAll(c); - aTrue = this.removeAll(aTempAllocation); + aTempAllocation.removeAll(c); + aTempAllocation.clear(); + aTrue = aTempAllocation.isEmpty(); aTempAllocation.clear(); return aTrue; } diff --git a/src/Java/gtPlusPlus/api/objects/minecraft/BlockPos.java b/src/Java/gtPlusPlus/api/objects/minecraft/BlockPos.java index 7c11e7232b..ab359c3853 100644 --- a/src/Java/gtPlusPlus/api/objects/minecraft/BlockPos.java +++ b/src/Java/gtPlusPlus/api/objects/minecraft/BlockPos.java @@ -19,7 +19,7 @@ public class BlockPos implements Serializable{ public final int yPos; public final int zPos; public final int dim; - public final World world; + public final transient World world; public static BlockPos generateBlockPos(String sUUID) { String[] s2 = sUUID.split("@"); diff --git a/src/Java/gtPlusPlus/api/objects/minecraft/FakeBlockPos.java b/src/Java/gtPlusPlus/api/objects/minecraft/FakeBlockPos.java index d0c1f3f040..d5db8081dc 100644 --- a/src/Java/gtPlusPlus/api/objects/minecraft/FakeBlockPos.java +++ b/src/Java/gtPlusPlus/api/objects/minecraft/FakeBlockPos.java @@ -12,7 +12,7 @@ import net.minecraftforge.common.DimensionManager; public class FakeBlockPos extends BlockPos { private static final long serialVersionUID = -6442245826092414593L; - private Block aBlockAtPos; + private transient Block aBlockAtPos; private int aBlockMetaAtPos = 0; public static FakeBlockPos generateBlockPos(String sUUID) { diff --git a/src/Java/gtPlusPlus/api/objects/random/XSTR.java b/src/Java/gtPlusPlus/api/objects/random/XSTR.java index 6357e9895c..6ce1cbeb6c 100644 --- a/src/Java/gtPlusPlus/api/objects/random/XSTR.java +++ b/src/Java/gtPlusPlus/api/objects/random/XSTR.java @@ -115,6 +115,13 @@ public class XSTR extends Random implements Cloneable { */ @Override public XSTR clone() { + try { + super.clone(); + } + catch (CloneNotSupportedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } return new XSTR(this.getSeed()); } diff --git a/src/Java/gtPlusPlus/core/block/machine/Machine_RoundRobinator.java b/src/Java/gtPlusPlus/core/block/machine/Machine_RoundRobinator.java index 71814cb868..8ba7c2533b 100644 --- a/src/Java/gtPlusPlus/core/block/machine/Machine_RoundRobinator.java +++ b/src/Java/gtPlusPlus/core/block/machine/Machine_RoundRobinator.java @@ -1,14 +1,25 @@ package gtPlusPlus.core.block.machine; +import java.util.List; + import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.common.items.GT_MetaGenerated_Tool_01; +import gtPlusPlus.api.interfaces.ITileTooltip; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.item.base.itemblock.ItemBlockRoundRobinator; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.tileentities.machines.TileEntityRoundRobinator; +import gtPlusPlus.core.util.minecraft.InventoryUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.minecraft.PlayerUtils; import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EnumCreatureType; import net.minecraft.entity.player.EntityPlayer; @@ -19,24 +30,12 @@ import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import gtPlusPlus.GTplusplus; -import gtPlusPlus.api.interfaces.ITileTooltip; -import gtPlusPlus.core.creative.AddToCreativeTab; -import gtPlusPlus.core.handler.GuiHandler; -import gtPlusPlus.core.item.base.itemblock.ItemBlockBasicTile; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.tileentities.machines.TileEntityRoundRobinator; -import gtPlusPlus.core.util.minecraft.InventoryUtils; -import gtPlusPlus.core.util.minecraft.PlayerUtils; - public class Machine_RoundRobinator extends BlockContainer implements ITileTooltip { @SideOnly(Side.CLIENT) - private IIcon textureTop; - @SideOnly(Side.CLIENT) - private IIcon textureBottom; + private IIcon[] textureTop = new IIcon[5]; @SideOnly(Side.CLIENT) - private IIcon textureFront; + private IIcon[] textureFront = new IIcon[5]; /** * Determines which tooltip is displayed within the itemblock. @@ -55,8 +54,8 @@ public class Machine_RoundRobinator extends BlockContainer implements ITileToolt this.setResistance(1f); this.setBlockName("blockRoundRobinator"); this.setCreativeTab(AddToCreativeTab.tabMachines); - GameRegistry.registerBlock(this, ItemBlockBasicTile.class, "blockRoundRobinator"); - LanguageRegistry.addName(this, "Round-Robinator"); + GameRegistry.registerBlock(this, ItemBlockRoundRobinator.class, "blockRoundRobinator"); + //LanguageRegistry.addName(this, "Round-Robinator"); } @@ -65,19 +64,23 @@ public class Machine_RoundRobinator extends BlockContainer implements ITileToolt */ @Override @SideOnly(Side.CLIENT) - public IIcon getIcon(final int p_149691_1_, final int p_149691_2_) - { - return p_149691_1_ == 1 ? this.textureTop : (p_149691_1_ == 0 ? this.textureBottom : (this.textureFront)); + public IIcon getIcon(final int aSide, final int aMeta) { + if (aSide < 2) { + return this.textureTop[aMeta]; + } + else { + return this.textureFront[aMeta]; + } } @Override @SideOnly(Side.CLIENT) - public void registerBlockIcons(final IIconRegister p_149651_1_) - { - this.blockIcon = p_149651_1_.registerIcon(CORE.MODID + ":" + "metro/" + "TEXTURE_TECH_PANEL_B"); - this.textureTop = p_149651_1_.registerIcon(CORE.MODID + ":" + "metro/" + "TEXTURE_TECH_PANEL_B"); - this.textureBottom = p_149651_1_.registerIcon(CORE.MODID + ":" + "metro/" + "TEXTURE_METAL_PANEL_G"); - this.textureFront = p_149651_1_.registerIcon(CORE.MODID + ":" + "metro/" + "TEXTURE_METAL_PANEL_I"); + public void registerBlockIcons(final IIconRegister p_149651_1_){ + this.blockIcon = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "RoundRobinator_Side"); + for (int i=0;i<5;i++) { + this.textureTop[i] = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/RoundRobinator/" + "RoundRobinator_Top_"+i); + this.textureFront[i] = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/RoundRobinator/" + "RoundRobinator_Side_"+i); + } } /** @@ -109,16 +112,14 @@ public class Machine_RoundRobinator extends BlockContainer implements ITileToolt if (!mDidScrewDriver) { final TileEntity te = world.getTileEntity(x, y, z); if ((te != null) && (te instanceof TileEntityRoundRobinator)){ - player.openGui(GTplusplus.instance, GuiHandler.GUI16, world, x, y, z); - return true; + return ((TileEntityRoundRobinator) te).onRightClick((byte) side, player, x, y, z); } + return false; } else { return true; - } - + } } - return false; } @Override @@ -149,9 +150,7 @@ public class Machine_RoundRobinator extends BlockContainer implements ITileToolt @Override public void onBlockPlacedBy(final World world, final int x, final int y, final int z, final EntityLivingBase entity, final ItemStack stack) { - if (stack.hasDisplayName()) { - ((TileEntityRoundRobinator) world.getTileEntity(x,y,z)).setCustomName(stack.getDisplayName()); - } + super.onBlockPlacedBy(world, x, y, z, entity, stack); } @Override @@ -159,4 +158,17 @@ public class Machine_RoundRobinator extends BlockContainer implements ITileToolt return false; } + @Override + public void getSubBlocks(Item aItem, CreativeTabs p_149666_2_, List aList) { + //super.getSubBlocks(aItem, p_149666_2_, aList); + for (int i=0;i<5;i++) { + aList.add(ItemUtils.simpleMetaStack(aItem, i, 1)); + } + } + + @Override + public IIcon getIcon(IBlockAccess aBlockAccess, int x, int y, int z, int aSide) { + return super.getIcon(aBlockAccess, x, y, z, aSide); + } + } \ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/container/Container_RoundRobinator.java b/src/Java/gtPlusPlus/core/container/Container_RoundRobinator.java index ad2aef02f8..0da2933dfa 100644 --- a/src/Java/gtPlusPlus/core/container/Container_RoundRobinator.java +++ b/src/Java/gtPlusPlus/core/container/Container_RoundRobinator.java @@ -1,39 +1,52 @@ package gtPlusPlus.core.container; +import java.util.Iterator; + +import org.apache.commons.lang3.ArrayUtils; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.GT_Values; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.inventories.Inventory_RoundRobinator; +import gtPlusPlus.core.slots.SlotNoInput; +import gtPlusPlus.core.tileentities.machines.TileEntityRoundRobinator; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; +import net.minecraft.inventory.ICrafting; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import net.minecraft.world.World; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.inventories.Inventory_RoundRobinator; -import gtPlusPlus.core.slots.SlotIntegratedCircuit; -import gtPlusPlus.core.slots.SlotNoInput; -import gtPlusPlus.core.tileentities.machines.TileEntityRoundRobinator; public class Container_RoundRobinator extends Container { - protected TileEntityRoundRobinator tile_entity; + public TileEntityRoundRobinator tile_entity; public final Inventory_RoundRobinator inventoryChest; private final World worldObj; private final int posX; private final int posY; private final int posZ; + + private final boolean[] mActiveData = new boolean[] {false, false, false, false}; - public static final int SLOT_OUTPUT = 25; - - public static int StorageSlotNumber = 26; // Number of slots in storage area - public static int InventorySlotNumber = 36; // Inventory Slots (Inventory + public static int mStorageSlotNumber = 4; // Number of slots in storage area + public static int mInventorySlotNumber = 36; // Inventory Slots (Inventory // and Hotbar) - public static int FullSlotNumber = InventorySlotNumber + StorageSlotNumber; // All + public static int mFullSlotNumber = mInventorySlotNumber + mStorageSlotNumber; // All // slots public Container_RoundRobinator(final InventoryPlayer inventory, final TileEntityRoundRobinator te) { this.tile_entity = te; this.inventoryChest = te.getInventory(); + boolean [] aTemp = te.getActiveSides(); + if (aTemp != null && aTemp.length == 4) { + for (int i=0;i<4;i++) { + mActiveData[i] = aTemp[i]; + } + } int var6; int var7; @@ -54,44 +67,20 @@ public class Container_RoundRobinator extends Container { }*/ - int xStart = 8; - int yStart = 5; + int xStart = 134; + int yStart = 32; try { //0 - this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart, yStart)); - //1-10 - this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart+18, yStart)); - this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart+36, yStart)); - this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart+54, yStart)); - this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart+72, yStart)); - this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart+90, yStart)); - this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart+108, yStart)); - this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart+18, yStart+18)); - this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart+36, yStart+18)); - this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart+54, yStart+18)); - this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart+72, yStart+18)); - //11-20 - this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart+90, yStart+18)); - this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart+108, yStart+18)); - this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart+18, yStart+36)); - this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart+36, yStart+36)); - this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart+54, yStart+36)); - this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart+72, yStart+36)); - this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart+90, yStart+36)); - this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart+108, yStart+36)); - this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart+18, yStart+54)); - this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart+36, yStart+54)); - //21-24 - this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart+54, yStart+54)); - this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart+72, yStart+54)); - this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart+90, yStart+54)); - this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart+108, yStart+54)); + this.addSlotToContainer(new SlotNoInput(this.inventoryChest, o++, xStart, yStart)); + this.addSlotToContainer(new SlotNoInput(this.inventoryChest, o++, xStart+18, yStart)); + this.addSlotToContainer(new SlotNoInput(this.inventoryChest, o++, xStart, yStart+17)); + this.addSlotToContainer(new SlotNoInput(this.inventoryChest, o++, xStart+18, yStart+17)); Logger.INFO("2"); //Add Output - this.addSlotToContainer(new SlotNoInput(this.inventoryChest, SLOT_OUTPUT, xStart+(8*18), yStart+54)); - o++; + //this.addSlotToContainer(new SlotNoInput(this.inventoryChest, SLOT_OUTPUT, xStart+(8*18), yStart+54)); + //o++; Logger.INFO("3"); @@ -112,6 +101,7 @@ public class Container_RoundRobinator extends Container { Logger.INFO("4"); } catch (Throwable t) {} + this.detectAndSendChanges(); } @@ -121,10 +111,14 @@ public class Container_RoundRobinator extends Container { if (!aPlayer.worldObj.isRemote) { if ((aSlotIndex == 999) || (aSlotIndex == -999)) { - // Utils.LOG_WARNING("??? - "+aSlotIndex); + } + else if (aSlotIndex < 4) { + this.tile_entity.toggleSide(aSlotIndex+2); + Logger.INFO("Toggling side: "+(aSlotIndex+2)+" | Active: "+this.tile_entity.getSideActive(aSlotIndex+2)+" | Data:"+this.tile_entity.getDataString()); } } - return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + return GT_Values.NI; + //return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); } @Override @@ -140,51 +134,136 @@ public class Container_RoundRobinator extends Container { return par1EntityPlayer.getDistanceSq(this.posX + 0.5D, this.posY + 0.5D, this.posZ + 0.5D) <= 64D; } + - @Override - public ItemStack transferStackInSlot(final EntityPlayer par1EntityPlayer, final int par2) { - ItemStack var3 = null; - final Slot var4 = (Slot) this.inventorySlots.get(par2); - - if ((var4 != null) && var4.getHasStack()) { - final ItemStack var5 = var4.getStack(); - var3 = var5.copy(); - - /* - * if (par2 == 0) { if (!this.mergeItemStack(var5, - * InOutputSlotNumber, FullSlotNumber, true)) { return null; } - * - * var4.onSlotChange(var5, var3); } else if (par2 >= - * InOutputSlotNumber && par2 < InventoryOutSlotNumber) { if - * (!this.mergeItemStack(var5, InventoryOutSlotNumber, - * FullSlotNumber, false)) { return null; } } else if (par2 >= - * InventoryOutSlotNumber && par2 < FullSlotNumber) { if - * (!this.mergeItemStack(var5, InOutputSlotNumber, - * InventoryOutSlotNumber, false)) { return null; } } else if - * (!this.mergeItemStack(var5, InOutputSlotNumber, FullSlotNumber, - * false)) { return null; } - */ - - if (var5.stackSize == 0) { - var4.putStack((ItemStack) null); - } else { - var4.onSlotChanged(); - } - if (var5.stackSize == var3.stackSize) { - return null; - } + public final void addCraftingToCrafters(ICrafting par1ICrafting) { + try { + super.addCraftingToCrafters(par1ICrafting); + } catch (Throwable var3) { + + } + } + + public final void removeCraftingFromCrafters(ICrafting par1ICrafting) { + try { + super.removeCraftingFromCrafters(par1ICrafting); + } catch (Throwable var3) { + } + } - var4.onPickupFromSlot(par1EntityPlayer, var5); + public final void detectAndSendChanges() { + try { + super.detectAndSendChanges(); + detectAndSendChangesEx(); + } catch (Throwable var2) { } + } - return var3; + public final void updateProgressBar(int par1, int par2) { + try { + super.updateProgressBar(par1, par2); + updateProgressBarEx(par1, par2); + } catch (Throwable var4) { + } } + + + public int mSide_1 = 0; + public int mSide_2 = 0; + public int mSide_3 = 0; + public int mSide_4 = 0; + public int mTier = 1; + public int mTickRate = 50; + + private int oSide_1 = 0; + private int oSide_2 = 0; + private int oSide_3 = 0; + private int oSide_4 = 0; + private int oTier = 1; + private int oTickRate = 50; + + private int mTimer = 0; + + + + public void detectAndSendChangesEx() { + super.detectAndSendChanges(); + if (!this.tile_entity.getWorldObj().isRemote) { + boolean [] aTemp = tile_entity.getActiveSides(); + for (int i=0;i<4;i++) { + mActiveData[i] = aTemp[i]; + } + this.mSide_1 = aTemp[0] ? 1 : 0; + this.mSide_2 = aTemp[1] ? 1 : 0; + this.mSide_3 = aTemp[2] ? 1 : 0; + this.mSide_4 = aTemp[3] ? 1 : 0; + this.mTier = this.tile_entity.getTier(); + this.mTickRate = this.tile_entity.getTickRate(); + + String InventoryContents = ArrayUtils.toString(aTemp, "null"); + //Logger.INFO("Test: "+InventoryContents); + ++this.mTimer; + Iterator var2 = this.crafters.iterator(); + + while (true) { + ICrafting var1; + do { + if (!var2.hasNext()) { + this.oSide_1 = this.mSide_1; + this.oSide_2 = this.mSide_2; + this.oSide_3 = this.mSide_3; + this.oSide_4 = this.mSide_4; + this.oTier = this.mTier; + this.oTickRate = this.mTickRate; + return; + } + var1 = (ICrafting) var2.next(); + if (this.mTimer % 500 == 10 || this.oSide_1 != this.mSide_1) { + var1.sendProgressBarUpdate(this, 2, this.mSide_1); + } + if (this.mTimer % 500 == 10 || this.oSide_2 != this.mSide_2) { + var1.sendProgressBarUpdate(this, 4, this.mSide_2); + } + if (this.mTimer % 500 == 10 || this.oSide_3 != this.mSide_3) { + var1.sendProgressBarUpdate(this, 6, this.mSide_3); + } + if (this.mTimer % 500 == 10 || this.oSide_4 != this.mSide_4) { + var1.sendProgressBarUpdate(this, 8, this.mSide_4); + } + if (this.mTimer % 500 == 10 || this.oTier != this.mTier) { + var1.sendProgressBarUpdate(this, 10, this.mTier); + } + if (this.mTimer % 500 == 10 || this.oTickRate != this.mTickRate) { + var1.sendProgressBarUpdate(this, 12, this.mTickRate); + } + } while (this.mTimer % 500 != 10); + + } + } + } + + @SideOnly(Side.CLIENT) + public void updateProgressBarEx(int par1, int par2) { + super.updateProgressBar(par1, par2); + switch (par1) { + case 2 : + this.mSide_1 = par2; + break; + case 4 : + this.mSide_2 = par2; + break; + case 6 : + this.mSide_3 = par2; + case 8 : + this.mSide_4 = par2; + case 10 : + this.mTier = par2; + case 12 : + this.mTickRate = par2; + break; + } - // Can merge Slot - @Override - public boolean func_94530_a(final ItemStack p_94530_1_, final Slot p_94530_2_) { - return super.func_94530_a(p_94530_1_, p_94530_2_); } } \ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/gui/machine/GUI_RoundRobinator.java b/src/Java/gtPlusPlus/core/gui/machine/GUI_RoundRobinator.java index 7a9417c806..c5a8341d8a 100644 --- a/src/Java/gtPlusPlus/core/gui/machine/GUI_RoundRobinator.java +++ b/src/Java/gtPlusPlus/core/gui/machine/GUI_RoundRobinator.java @@ -1,29 +1,75 @@ package gtPlusPlus.core.gui.machine; +import java.lang.reflect.Field; +import java.lang.reflect.Method; + import org.lwjgl.opengl.GL11; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - -import net.minecraft.client.gui.inventory.GuiContainer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.util.ResourceLocation; import gtPlusPlus.core.container.Container_RoundRobinator; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.tileentities.machines.TileEntityRoundRobinator; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; @SideOnly(Side.CLIENT) public class GUI_RoundRobinator extends GuiContainer { private static final ResourceLocation craftingTableGuiTextures = new ResourceLocation(CORE.MODID, "textures/gui/RoundRobinator.png"); + private TileEntityRoundRobinator mTile; + private Container_RoundRobinator mContainer; + private static final Method mDrawItemStack; + + static { + mDrawItemStack = ReflectionUtils.getMethod(GuiContainer.class, "drawItemStack", new Class[] {ItemStack.class, int.class, int.class, String.class}); + } public GUI_RoundRobinator(final InventoryPlayer player_inventory, final TileEntityRoundRobinator te){ - super(new Container_RoundRobinator(player_inventory, te)); + this(new Container_RoundRobinator(player_inventory, te)); + mTile = te; + } + + private GUI_RoundRobinator(final Container_RoundRobinator aContainer){ + super(aContainer); + mContainer = aContainer; } @Override protected void drawGuiContainerForegroundLayer(final int i, final int j){ - super.drawGuiContainerForegroundLayer(i, j); + super.drawGuiContainerForegroundLayer(i, j); + + int xStart = 134; + int yStart = 31; + mTile = this.mContainer.tile_entity; + + int tier = mContainer.mTier; + int aTickRate = mContainer.mTickRate; + + fontRendererObj.drawString("Round Robinator", 85, 4, Utils.rgbtoHexValue(50, 150, 50)); + fontRendererObj.drawString("Tier: "+tier, 85, 12, Utils.rgbtoHexValue(50, 150, 50)); + fontRendererObj.drawString("Rate: 1 Item/"+aTickRate+"t", 85, 20, Utils.rgbtoHexValue(50, 150, 50)); + + boolean[] aStates = new boolean[] {mContainer.mSide_1 == 0 ? false : true, mContainer.mSide_2 == 0 ? false : true, mContainer.mSide_3 == 0 ? false : true,mContainer.mSide_4 == 0 ? false : true}; + + fontRendererObj.drawString("West: "+(aStates[0] ? "Active" : "Disabled"), 5, 5, Utils.rgbtoHexValue(50, 50, 50)); + fontRendererObj.drawString("North: "+(aStates[1] ? "Active" : "Disabled"), 5, 15, Utils.rgbtoHexValue(50, 50, 50)); + fontRendererObj.drawString("South: "+(aStates[2] ? "Active" : "Disabled"), 5, 25, Utils.rgbtoHexValue(50, 50, 50)); + fontRendererObj.drawString("East: "+(aStates[3] ? "Active" : "Disabled"), 5, 35, Utils.rgbtoHexValue(50, 50, 50)); + fontRendererObj.drawString("Toggling South will visually", 5, 65, Utils.rgbtoHexValue(150, 50, 50)); + fontRendererObj.drawString("toggle East, This is a visual bug.", 5, 74, Utils.rgbtoHexValue(150, 50, 50)); + drawStatus(aStates[0], xStart, yStart); + drawStatus(aStates[1], xStart+18, yStart); + drawStatus(aStates[2], xStart, yStart+18); + drawStatus(aStates[3], xStart+18, yStart+18); + } @Override @@ -33,6 +79,34 @@ public class GUI_RoundRobinator extends GuiContainer { final int x = (this.width - this.xSize) / 2; final int y = (this.height - this.ySize) / 2; this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); + + + + } + + private static ItemStack aGreenGlass; + private static ItemStack aRedGlass; + + private void drawStatus(boolean aStateActive, int x, int y) { + if (aGreenGlass == null) { + Item pane = ItemUtils.getSimpleStack(Blocks.stained_glass_pane).getItem(); + aGreenGlass = ItemUtils.simpleMetaStack(pane, 5, 1); + } + if (aRedGlass == null) { + Item pane = ItemUtils.getSimpleStack(Blocks.stained_glass_pane).getItem(); + aRedGlass = ItemUtils.simpleMetaStack(pane, 14, 1); + } + if (mDrawItemStack != null) { + try { + if (aStateActive) { + mDrawItemStack.invoke(this, new Object[]{aGreenGlass, x, y, ""}); + } + else { + mDrawItemStack.invoke(this, new Object[]{aRedGlass, x, y, ""}); + } + } + catch (Throwable t) {} + } } //This method is called when the Gui is first called! diff --git a/src/Java/gtPlusPlus/core/handler/GuiHandler.java b/src/Java/gtPlusPlus/core/handler/GuiHandler.java index 2141210650..e44c9a8f20 100644 --- a/src/Java/gtPlusPlus/core/handler/GuiHandler.java +++ b/src/Java/gtPlusPlus/core/handler/GuiHandler.java @@ -2,16 +2,22 @@ package gtPlusPlus.core.handler; import cpw.mods.fml.common.network.IGuiHandler; import cpw.mods.fml.common.network.NetworkRegistry; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ChunkCoordinates; -import net.minecraft.world.World; - import gtPlusPlus.GTplusplus; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.block.machine.Machine_SuperJukebox.TileEntitySuperJukebox; -import gtPlusPlus.core.container.*; +import gtPlusPlus.core.container.Container_BackpackBase; +import gtPlusPlus.core.container.Container_CircuitProgrammer; +import gtPlusPlus.core.container.Container_DecayablesChest; +import gtPlusPlus.core.container.Container_FishTrap; +import gtPlusPlus.core.container.Container_Grindle; +import gtPlusPlus.core.container.Container_ModularityTable; +import gtPlusPlus.core.container.Container_PestKiller; +import gtPlusPlus.core.container.Container_ProjectTable; +import gtPlusPlus.core.container.Container_RoundRobinator; +import gtPlusPlus.core.container.Container_SuperJukebox; +import gtPlusPlus.core.container.Container_TradeTable; +import gtPlusPlus.core.container.Container_Workbench; +import gtPlusPlus.core.container.Container_WorkbenchAdvanced; import gtPlusPlus.core.container.box.LunchBoxContainer; import gtPlusPlus.core.container.box.MagicBagContainer; import gtPlusPlus.core.container.box.ToolBoxContainer; @@ -22,20 +28,38 @@ import gtPlusPlus.core.gui.item.GuiBaseGrindle; import gtPlusPlus.core.gui.item.box.LunchBoxGui; import gtPlusPlus.core.gui.item.box.MagicBagGui; import gtPlusPlus.core.gui.item.box.ToolBoxGui; -import gtPlusPlus.core.gui.machine.*; +import gtPlusPlus.core.gui.machine.GUI_CircuitProgrammer; +import gtPlusPlus.core.gui.machine.GUI_DecayablesChest; +import gtPlusPlus.core.gui.machine.GUI_FishTrap; +import gtPlusPlus.core.gui.machine.GUI_ModularityTable; +import gtPlusPlus.core.gui.machine.GUI_PestKiller; +import gtPlusPlus.core.gui.machine.GUI_ProjectTable; +import gtPlusPlus.core.gui.machine.GUI_RoundRobinator; +import gtPlusPlus.core.gui.machine.GUI_SuperJukebox; +import gtPlusPlus.core.gui.machine.GUI_TradeTable; +import gtPlusPlus.core.gui.machine.GUI_Workbench; +import gtPlusPlus.core.gui.machine.GUI_WorkbenchAdvanced; import gtPlusPlus.core.interfaces.IGuiManager; import gtPlusPlus.core.inventories.BaseInventoryBackpack; import gtPlusPlus.core.inventories.BaseInventoryGrindle; import gtPlusPlus.core.inventories.box.LunchBoxInventory; import gtPlusPlus.core.inventories.box.MagicBagInventory; import gtPlusPlus.core.inventories.box.ToolBoxInventory; -import gtPlusPlus.core.item.tool.misc.box.ContainerBoxBase; -import gtPlusPlus.core.item.tool.misc.box.CustomBoxInventory; import gtPlusPlus.core.tileentities.base.TileEntityBase; import gtPlusPlus.core.tileentities.general.TileEntityCircuitProgrammer; import gtPlusPlus.core.tileentities.general.TileEntityDecayablesChest; import gtPlusPlus.core.tileentities.general.TileEntityFishTrap; -import gtPlusPlus.core.tileentities.machines.*; +import gtPlusPlus.core.tileentities.machines.TileEntityModularityTable; +import gtPlusPlus.core.tileentities.machines.TileEntityPestKiller; +import gtPlusPlus.core.tileentities.machines.TileEntityProjectTable; +import gtPlusPlus.core.tileentities.machines.TileEntityRoundRobinator; +import gtPlusPlus.core.tileentities.machines.TileEntityTradeTable; +import gtPlusPlus.core.tileentities.machines.TileEntityWorkbench; +import gtPlusPlus.core.tileentities.machines.TileEntityWorkbenchAdvanced; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.world.World; public class GuiHandler implements IGuiHandler { diff --git a/src/Java/gtPlusPlus/core/inventories/Inventory_RoundRobinator.java b/src/Java/gtPlusPlus/core/inventories/Inventory_RoundRobinator.java index 58d60b595f..a47f250c39 100644 --- a/src/Java/gtPlusPlus/core/inventories/Inventory_RoundRobinator.java +++ b/src/Java/gtPlusPlus/core/inventories/Inventory_RoundRobinator.java @@ -1,6 +1,5 @@ package gtPlusPlus.core.inventories; -import gtPlusPlus.core.recipe.common.CI; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; @@ -9,10 +8,10 @@ import net.minecraft.nbt.NBTTagList; public class Inventory_RoundRobinator implements IInventory{ - private final String name = "Circuit Programmer"; + private final String name = "Round Robinator"; /** Defining your inventory size this way is handy */ - public static final int INV_SIZE = 26; + public static final int INV_SIZE = 4; /** Inventory's size must be same as number of slots you add to the Container class */ private ItemStack[] inventory = new ItemStack[INV_SIZE]; @@ -167,7 +166,7 @@ public class Inventory_RoundRobinator implements IInventory{ */ @Override public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) { - return (itemstack.getItem() == CI.getNumberedCircuit(0).getItem()); + return true; } } \ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/item/base/dusts/BaseItemDust.java b/src/Java/gtPlusPlus/core/item/base/dusts/BaseItemDust.java index 1b13d34495..9022f864cb 100644 --- a/src/Java/gtPlusPlus/core/item/base/dusts/BaseItemDust.java +++ b/src/Java/gtPlusPlus/core/item/base/dusts/BaseItemDust.java @@ -87,8 +87,7 @@ public class BaseItemDust extends BaseItemComponent { else if (amount == 10) { doesThings[0] = false; doesThings[1] = true; - doesThings[2] = false; - + doesThings[2] = false; } else if (amount == 100) { doesThings[0] = false; diff --git a/src/Java/gtPlusPlus/core/item/base/dusts/BaseItemDustUnique.java b/src/Java/gtPlusPlus/core/item/base/dusts/BaseItemDustUnique.java index e1c3e179ee..e4fa06c58e 100644 --- a/src/Java/gtPlusPlus/core/item/base/dusts/BaseItemDustUnique.java +++ b/src/Java/gtPlusPlus/core/item/base/dusts/BaseItemDustUnique.java @@ -118,7 +118,7 @@ public class BaseItemDustUnique extends Item{ private String getCorrectTexture(final String pileSize){ if (!CORE.ConfigSwitches.useGregtechTextures){ - if ((pileSize == "dust") || (pileSize == "Dust")){ + if ((pileSize.equals("dust")) || (pileSize.equals("Dust"))){ this.setTextureName(CORE.MODID + ":" + "dust");} else{ this.setTextureName(CORE.MODID + ":" + "dust"+pileSize); diff --git a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockBasicTile.java b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockBasicTile.java index c52eb0d222..42890ddfa6 100644 --- a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockBasicTile.java +++ b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockBasicTile.java @@ -44,11 +44,7 @@ public class ItemBlockBasicTile extends ItemBlock { list.add("Kills Forestry Butterflies, Bats and other pests"); list.add("Use either Formaldehyde or Hydrogen cyanide"); list.add("Be weary of your neighbours"); - } else if (this.mID == 7) { // Round-Robinator - list.add("Attempts to output items evenly on all four horizontal planes"); - list.add("Each tier operates at a factor of one operation every (20/tier)ticks"); - list.add("Top and bottom do not pull, so you must push item in"); - list.add("Sides can be disabled with a screwdriver"); + } else if (this.mID == 7) { } else { list.add("Bad Tooltip ID - " + mID); diff --git a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockRoundRobinator.java b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockRoundRobinator.java new file mode 100644 index 0000000000..fa18d745fb --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockRoundRobinator.java @@ -0,0 +1,111 @@ +package gtPlusPlus.core.item.base.itemblock; +import java.util.List; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemBlockWithMetadata; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; + +public class ItemBlockRoundRobinator extends ItemBlockWithMetadata +{ + private final Block mBlock; + + public ItemBlockRoundRobinator(final Block aBlock){ + super(aBlock, aBlock); + this.mBlock = aBlock; + this.setMaxDamage(0); + this.setHasSubtypes(true); + } + + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + list.add("Attempts to output items evenly on all four horizontal planes"); + if (stack.getItemDamage() == 0) { + list.add("1 Item per enabled side every 400 ticks"); + } + else if (stack.getItemDamage() == 1) { + list.add("1 Item per enabled side every 100 ticks"); + } + else if (stack.getItemDamage() == 2) { + list.add("1 Item per enabled side every 20 ticks"); + } + else if (stack.getItemDamage() == 3) { + list.add("1 Item per enabled side every 10 ticks"); + } + else if (stack.getItemDamage() == 4) { + list.add("1 Item per enabled side every 1 ticks"); + } + list.add("Top and bottom do not pull, so you must push item in"); + list.add("Sides can also be disabled with a screwdriver"); + super.addInformation(stack, aPlayer, list, bool); + } + + /** + * Gets an icon index based on an item's damage value + */ + @Override + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamage(final int p_77617_1_) + { + return this.mBlock.getIcon(2, p_77617_1_); + } + + /** + * Returns the metadata of the block which this Item (ItemBlock) can place + */ + @Override + public int getMetadata(final int p_77647_1_) + { + return p_77647_1_; + } + + @Override + public String getUnlocalizedName(final ItemStack stack) { + return this.getUnlocalizedName() + "." + stack.getItemDamage(); + } + + @Override + public boolean isDamageable() { + return false; + } + + @Override + public int getItemEnchantability() { + return 0; + } + + @Override + public boolean getIsRepairable(ItemStack p_82789_1_, ItemStack p_82789_2_) { + return false; + } + + @Override + public boolean isBookEnchantable(ItemStack stack, ItemStack book) { + return false; + } + + @Override + public int getDisplayDamage(ItemStack stack) { + return 0; + } + + @Override + public boolean showDurabilityBar(ItemStack stack) { + return false; + } + + @Override + public double getDurabilityForDisplay(ItemStack stack) { + return 0; + } + + @Override + public int getItemEnchantability(ItemStack stack) { + return 0; + } +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/item/bauble/FireProtectionBauble.java b/src/Java/gtPlusPlus/core/item/bauble/FireProtectionBauble.java index 93a5a969f7..6a8751b682 100644 --- a/src/Java/gtPlusPlus/core/item/bauble/FireProtectionBauble.java +++ b/src/Java/gtPlusPlus/core/item/bauble/FireProtectionBauble.java @@ -29,7 +29,7 @@ public class FireProtectionBauble extends BaseBauble { private static Field isImmuneToFire; static { - isImmuneToFire = ReflectionUtils.getField(Entity.class, DevHelper.IsObfuscatedEnvironment() ? "func_70045_F" : "isImmuneToFire"); + isImmuneToFire = ReflectionUtils.getField(Entity.class, DevHelper.isObfuscatedEnvironment() ? "func_70045_F" : "isImmuneToFire"); } public static boolean fireImmune(Entity aEntity) { diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java index 0bd5c0cf76..bc1c7fc398 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java @@ -230,6 +230,7 @@ public class RECIPES_Machines { fakeMachineCasingCovers(); ztonesCoverRecipes(); superBuses(); + roundRobinators(); } private static void initModItems(){ @@ -2251,4 +2252,46 @@ public class RECIPES_Machines { } + private static void roundRobinators() { + + RecipeUtils.addShapedGregtechRecipe( + ItemUtils.getSimpleStack(Blocks.hopper), "circuitPrimitive", ItemUtils.getSimpleStack(Blocks.hopper), + CI.craftingToolWrench, CI.machineCasing_ULV, CI.craftingToolScrewdriver, + ItemUtils.getSimpleStack(Blocks.hopper), "circuitPrimitive", ItemUtils.getSimpleStack(Blocks.hopper), + ItemUtils.simpleMetaStack(ModBlocks.blockRoundRobinator, 0, 1)); + + ItemStack[] aRobinators = new ItemStack[] { + ItemUtils.simpleMetaStack(ModBlocks.blockRoundRobinator, 0, 1), + ItemUtils.simpleMetaStack(ModBlocks.blockRoundRobinator, 1, 1), + ItemUtils.simpleMetaStack(ModBlocks.blockRoundRobinator, 2, 1), + ItemUtils.simpleMetaStack(ModBlocks.blockRoundRobinator, 3, 1), + ItemUtils.simpleMetaStack(ModBlocks.blockRoundRobinator, 4, 1), + }; + + int aCostMultiplier = GTNH ? 2 : 1; + + for (int i = 0; i < 5; i++) { + if (i == 0) { + continue; + } + int aTier = i+1; + ItemStack[] aInputs = new ItemStack[] { + aRobinators[i-1], + CI.getTieredMachineHull(aTier, 1 * aCostMultiplier), + CI.getConveyor(aTier, 2 * aCostMultiplier), + CI.getElectricMotor(aTier, 2 * aCostMultiplier), + CI.getTieredComponent(OrePrefixes.plate, aTier, 4 * aCostMultiplier), + CI.getTieredComponent(OrePrefixes.circuit, i, 2 * aCostMultiplier), + }; + + CORE.RA.addSixSlotAssemblingRecipe( + aInputs, + CI.getAlternativeTieredFluid(aTier, (144 * 2 * i)), //Input Fluid + aRobinators[i], + 45 * 10 * 1 * (i+1), + MaterialUtils.getVoltageForTier(i)); + + } + } + } diff --git a/src/Java/gtPlusPlus/core/recipe/common/CI.java b/src/Java/gtPlusPlus/core/recipe/common/CI.java index 15589ada84..63477cda19 100644 --- a/src/Java/gtPlusPlus/core/recipe/common/CI.java +++ b/src/Java/gtPlusPlus/core/recipe/common/CI.java @@ -547,7 +547,7 @@ public class CI { private static final Material[] aMaterial_Main = new Material[] { ALLOY.POTIN, - ALLOY.ZIRCONIUM_CARBIDE, + ALLOY.TUMBAGA, ALLOY.EGLIN_STEEL, ALLOY.INCONEL_792, ALLOY.TUNGSTEN_TITANIUM_CARBIDE, @@ -561,7 +561,7 @@ public class CI { }; private static final Material[] aMaterial_Secondary = new Material[] { - ALLOY.TUMBAGA, + ALLOY.STEEL, ALLOY.SILICON_CARBIDE, ALLOY.TUNGSTEN_CARBIDE, ALLOY.INCONEL_690, @@ -576,7 +576,7 @@ public class CI { }; private static final Material[] aMaterial_Tertiary = new Material[] { - ALLOY.STEEL, + ELEMENT.getInstance().LEAD, ELEMENT.getInstance().ALUMINIUM, ALLOY.STAINLESS_STEEL, ELEMENT.getInstance().TUNGSTEN, diff --git a/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityRoundRobinator.java b/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityRoundRobinator.java index 13ba5ca44d..4950718f4a 100644 --- a/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityRoundRobinator.java +++ b/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityRoundRobinator.java @@ -1,19 +1,36 @@ package gtPlusPlus.core.tileentities.machines; +import java.util.List; + +import gtPlusPlus.GTplusplus; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.handler.GuiHandler; +import gtPlusPlus.core.inventories.Inventory_RoundRobinator; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.core.util.sys.KeyboardUtils; +import net.minecraft.block.Block; +import net.minecraft.block.BlockChest; +import net.minecraft.command.IEntitySelector; +import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; import net.minecraft.network.NetworkManager; import net.minecraft.network.Packet; import net.minecraft.network.play.server.S35PacketUpdateTileEntity; +import net.minecraft.tileentity.IHopper; import net.minecraft.tileentity.TileEntity; -import gtPlusPlus.api.objects.data.AutoMap; -import gtPlusPlus.core.inventories.Inventory_RoundRobinator; -import gtPlusPlus.core.recipe.common.CI; -import gtPlusPlus.core.util.minecraft.PlayerUtils; +import net.minecraft.tileentity.TileEntityChest; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.Facing; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; -public class TileEntityRoundRobinator extends TileEntity implements ISidedInventory { +public class TileEntityRoundRobinator extends TileEntity implements ISidedInventory, IHopper { private int tickCount = 0; private final Inventory_RoundRobinator inventoryContents; @@ -21,7 +38,9 @@ public class TileEntityRoundRobinator extends TileEntity implements ISidedInvent public int locationX; public int locationY; public int locationZ; - private int aCurrentMode = 0; + private int aData = 1111; + private int aTier = 1; + private int aTickRate = 100; public TileEntityRoundRobinator() { this.inventoryContents = new Inventory_RoundRobinator(); @@ -34,6 +53,7 @@ public class TileEntityRoundRobinator extends TileEntity implements ISidedInvent this.locationX = this.xCoord; this.locationY = this.yCoord; this.locationZ = this.zCoord; + this.aTier = this.getWorldObj().getBlockMetadata(locationX, locationY, locationZ) + 1; return true; } } @@ -41,8 +61,8 @@ public class TileEntityRoundRobinator extends TileEntity implements ISidedInvent } //Rename to hasCircuitToConfigure - public final boolean hasCircuitToConfigure() { - for (ItemStack i : this.getInventory().getInventory()) { + public final boolean hasInventoryContents() { + for (ItemStack i : this.aHopperInventory) { if (i == null) { continue; } @@ -56,76 +76,54 @@ public class TileEntityRoundRobinator extends TileEntity implements ISidedInvent public Inventory_RoundRobinator getInventory() { return this.inventoryContents; } - - public boolean addOutput() { - ItemStack[] aInputs = this.getInventory().getInventory().clone(); - //Check if there is output in slot. - Boolean hasOutput = false; - if (aInputs[25] != null) { - hasOutput = true; - } - AutoMap aValidSlots = new AutoMap(); - int aSlotCount = 0; - for (ItemStack i : aInputs) { - if (i != null) { - aValidSlots.put(aSlotCount); - } - aSlotCount++; - } - for (int e : aValidSlots) { - boolean doAdd = false; - ItemStack g = this.getStackInSlot(e); - int aSize = 0; - ItemStack aInputStack = null; - if (g != null) { - if (!hasOutput) { - aSize = g.stackSize; - doAdd = true; - } - else { - ItemStack f = this.getStackInSlot(25); - if (f != null) { - if (f.getItemDamage() == e) { - aSize = f.stackSize + g.stackSize; - if (aSize > 64) { - aInputStack = g.copy(); - aInputStack.stackSize = (aSize-64); - } - doAdd = true; - } - } - else { - doAdd = true; - aSize = g.stackSize; - } - } - if (doAdd) { - ItemStack aOutput = CI.getNumberedCircuit(e); - if (aOutput != null) { - aOutput.stackSize = aSize; - this.setInventorySlotContents(e, aInputStack); - this.setInventorySlotContents(25, aOutput); - return true; - } - } - } - continue; - } - return false; + + public int getTier() { + return this.aTier; + } + + public int getTickRate() { + return this.aTickRate; } @Override public void updateEntity() { try{ - if (!this.worldObj.isRemote) { - if (tickCount % 10 == 0) { - if (hasCircuitToConfigure()) { - this.addOutput(); - this.markDirty(); + // TODO + if (this.worldObj != null && !this.worldObj.isRemote){ + setTileLocation(); + aTickRate = (60-(aTier*10)); + if (this.getTier() == 1) { + // 20 s + aTickRate = 400; + } + else if (this.getTier() == 2) { + // 5 + aTickRate = 100; + } + else if (this.getTier() == 3) { + // 1 + aTickRate = 20; + } + else if (this.getTier() == 4) { + // 1/5 + aTickRate = 10; + } + else if (this.getTier() == 5) { + // 1/20 + aTickRate = 1; + } + else { + aTickRate = 999999; + } + + if (tickCount % getTickRate() == 0) { + if (hasInventoryContents()) { + Logger.INFO("Trying to move items. "+aTickRate); + this.tryProcessItems(); } } - this.tickCount++; - } + this.tickCount++; + } } catch (final Throwable t){} } @@ -144,55 +142,26 @@ public class TileEntityRoundRobinator extends TileEntity implements ISidedInvent @Override public void writeToNBT(final NBTTagCompound nbt) { super.writeToNBT(nbt); - // Utils.LOG_WARNING("Trying to write NBT data to TE."); - final NBTTagCompound chestData = new NBTTagCompound(); - this.inventoryContents.writeToNBT(chestData); - nbt.setTag("ContentsChest", chestData); if (this.hasCustomInventoryName()) { nbt.setString("CustomName", this.getCustomName()); } - nbt.setInteger("aCurrentMode", aCurrentMode); + nbt.setInteger("aCurrentMode", aData); + this.writeToNBT2(nbt); } @Override public void readFromNBT(final NBTTagCompound nbt) { super.readFromNBT(nbt); - // Utils.LOG_WARNING("Trying to read NBT data from TE."); - this.inventoryContents.readFromNBT(nbt.getCompoundTag("ContentsChest")); if (nbt.hasKey("CustomName", 8)) { this.setCustomName(nbt.getString("CustomName")); } - aCurrentMode = nbt.getInteger("aCurrentMode"); - } - - @Override - public int getSizeInventory() { - return this.getInventory().getSizeInventory(); - } - - @Override - public ItemStack getStackInSlot(final int slot) { - return this.getInventory().getStackInSlot(slot); - } - - @Override - public ItemStack decrStackSize(final int slot, final int count) { - return this.getInventory().decrStackSize(slot, count); - } - - @Override - public ItemStack getStackInSlotOnClosing(final int slot) { - return this.getInventory().getStackInSlotOnClosing(slot); - } - - @Override - public void setInventorySlotContents(final int slot, final ItemStack stack) { - this.getInventory().setInventorySlotContents(slot, stack); + aData = nbt.getInteger("aCurrentMode"); + this.readFromNBT2(nbt); } @Override public int getInventoryStackLimit() { - return this.getInventory().getInventoryStackLimit(); + return 64; } @Override @@ -205,7 +174,7 @@ public class TileEntityRoundRobinator extends TileEntity implements ISidedInvent this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, 1); this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType()); this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord - 1, this.zCoord, this.getBlockType()); - this.getInventory().openInventory(); + //this.getInventory().openInventory(); } @Override @@ -213,32 +182,27 @@ public class TileEntityRoundRobinator extends TileEntity implements ISidedInvent this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, 1); this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType()); this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord - 1, this.zCoord, this.getBlockType()); - this.getInventory().closeInventory(); + //this.getInventory().closeInventory(); } @Override public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) { - return this.getInventory().isItemValidForSlot(slot, itemstack); + return true; } @Override - public int[] getAccessibleSlotsFromSide(final int p_94128_1_) { - final int[] accessibleSides = new int[this.getSizeInventory()]; - for (int r=0; r= 0 && p_102007_1_ <= 24; + public boolean canInsertItem(final int aSlot, final ItemStack aStack, final int aSide) { + return aSide < 2; } @Override - public boolean canExtractItem(final int p_102008_1_, final ItemStack p_102008_2_, final int p_102008_3_) { - return p_102008_1_ == 25; + public boolean canExtractItem(final int aSlot, final ItemStack aStack, final int aSide) { + return false; } public String getCustomName() { @@ -251,7 +215,7 @@ public class TileEntityRoundRobinator extends TileEntity implements ISidedInvent @Override public String getInventoryName() { - return this.hasCustomInventoryName() ? this.customName : "container.circuitprogrammer"; + return this.hasCustomInventoryName() ? this.customName : "container.roundrobinator"; } @Override @@ -272,15 +236,37 @@ public class TileEntityRoundRobinator extends TileEntity implements ISidedInvent this.readFromNBT(tag); } - public boolean onScrewdriverRightClick(byte side, EntityPlayer player, int x, int y, int z) { - try { - if (aCurrentMode == 24) { - aCurrentMode = 0; + + public boolean onRightClick(byte side, EntityPlayer player, int x, int y, int z) { + if (player != null && player.getHeldItem() == null) { + if (!player.isSneaking() && !KeyboardUtils.isShiftKeyDown()) { + player.openGui(GTplusplus.instance, GuiHandler.GUI16, player.getEntityWorld(), x, y, z); } else { - aCurrentMode++; + String InventoryContents = ItemUtils.getArrayStackNames(this.aHopperInventory); + PlayerUtils.messagePlayer(player, "Contents: "+InventoryContents+" | "+getDataString()); + } + return true; + } + else { + return false; + } + } + + public boolean onScrewdriverRightClick(byte side, EntityPlayer player, int x, int y, int z) { + try { + if (side < 2) { + // Top/Bottom } - PlayerUtils.messagePlayer(player, "Now configuring units for type "+aCurrentMode+"."); + else { + if (toggleSide(side)) { + PlayerUtils.messagePlayer(player, "Enabling side "+side+"."); + } + else { + PlayerUtils.messagePlayer(player, "Disabling side "+side+"."); + } + PlayerUtils.messagePlayer(player, "Mode String: "+aData+""); + } return true; } catch (Throwable t) { @@ -288,4 +274,461 @@ public class TileEntityRoundRobinator extends TileEntity implements ISidedInvent } } + public int getDataString() { + return aData; + } + + public boolean[] getActiveSides() { + this.markDirty(); + String s = String.valueOf(aData); + if (s == null || s.length() != 4) { + s = "1111"; + } + boolean[] aActiveSides = new boolean[4]; + for (int i=0;i<4;i++) { + char ch = s.charAt(i); + if (ch == '1') { + aActiveSides[i] = true; + } + else { + aActiveSides[i] = false; + } + } + return aActiveSides; + } + + /** + * Toggle active state of side + * @param aSide - Forge Direction / Side + * @return - True if the side is now Active, false if now disabled. + */ + public boolean toggleSide(int aSide) { + setSideActive(!getSideActive(aSide), aSide); + return getSideActive(aSide); + } + + + public void setSideActive(boolean aActive, int aSide) { + try { + if (aSide < 2) { + } + else { + if (aData < 1111) { + aData = 1111; + } + else if (aData > 2222) { + aData = 2222; + } + String s = String.valueOf(aData); + StringBuilder aDataString = new StringBuilder(s); + int aIndex = aSide - 2; + if (aActive) { + aDataString.setCharAt(aIndex, '1'); + } + else { + aDataString.setCharAt(aIndex, '2'); + } + aData = Integer.valueOf(aDataString.toString()); + this.markDirty(); + } + } + catch (Throwable t) { + } + } + + public boolean getSideActive(int aSide) { + this.markDirty(); + try { + if (aSide < 2) { + return false; + } + else { + if (aData < 1111) { + aData = 1111; + } + else if (aData > 2222) { + aData = 2222; + } + String s = String.valueOf(aData); + int aIndex = aSide - 2; + char ch = s.charAt(aIndex); + if (ch == '1') { + return true; + } + else { + return false; + } + + } + } + catch (Throwable t) { + return false; + } + } + + @Override + public double getXPos() { + return this.locationX; + } + + @Override + public double getYPos() { + return this.locationY; + } + + @Override + public double getZPos() { + return this.locationZ; + } + + + + + + + + + // TODO + + + + /* + * Hopper Code + */ + + + private ItemStack[] aHopperInventory = new ItemStack[5]; + + public int getSizeInventory() { + return this.aHopperInventory.length; + } + + public ItemStack getStackInSlot(int aSlot) { + return this.aHopperInventory[aSlot]; + } + + /** + * Removes from an inventory slot (first arg) up to a specified number (second arg) of items and returns them in a + * new stack. + */ + public ItemStack decrStackSize(int aSlot, int aMinimumSizeOfExistingStack) + { + if (this.aHopperInventory[aSlot] != null) + { + ItemStack itemstack; + + if (this.aHopperInventory[aSlot].stackSize <= aMinimumSizeOfExistingStack) + { + itemstack = this.aHopperInventory[aSlot]; + this.aHopperInventory[aSlot] = null; + return itemstack; + } + else + { + itemstack = this.aHopperInventory[aSlot].splitStack(aMinimumSizeOfExistingStack); + + if (this.aHopperInventory[aSlot].stackSize == 0) + { + this.aHopperInventory[aSlot] = null; + } + + return itemstack; + } + } + else + { + return null; + } + } + + /** + * When some containers are closed they call this on each slot, then drop whatever it returns as an EntityItem - + * like when you close a workbench GUI. + */ + public ItemStack getStackInSlotOnClosing(int aSlot) + { + if (this.aHopperInventory[aSlot] != null) + { + ItemStack itemstack = this.aHopperInventory[aSlot]; + this.aHopperInventory[aSlot] = null; + return itemstack; + } + else + { + return null; + } + } + + /** + * Sets the given item stack to the specified slot in the inventory (can be crafting or armor sections). + */ + public void setInventorySlotContents(int aSlot, ItemStack aStack) + { + this.aHopperInventory[aSlot] = aStack; + + if (aStack != null && aStack.stackSize > this.getInventoryStackLimit()) + { + aStack.stackSize = this.getInventoryStackLimit(); + } + } + + public boolean tryProcessItems() { + if (this.worldObj != null && !this.worldObj.isRemote) { + boolean didSomething = false; + if (!this.isEmpty()) { + Logger.INFO("Has Items, Trying to push to all active directions."); + didSomething = this.tryPushItemsIntoNeighbours(); + } + if (didSomething) { + this.markDirty(); + return true; + } + } + return false; + } + + /** + * Is Empty + * @return + */ + private boolean isEmpty() { + ItemStack[] aitemstack = this.aHopperInventory; + int i = aitemstack.length; + + for (int j = 0; j < i; ++j) { + ItemStack itemstack = aitemstack[j]; + + if (itemstack != null) { + return false; + } + } + + return true; + } + + private boolean tryPushItemsIntoNeighbours() { + + boolean aDidPush = false; + + for (int u = 2; u < 6; u++) { + if (!this.getSideActive(u)) { + Logger.INFO("Not pushing on side "+u); + continue; + } + + Logger.INFO("Pushing on side "+u); + IInventory iinventory = this.getInventoryFromFacing(u); + + if (iinventory == null) { + Logger.INFO("No inventory found."); + continue; + } + else { + + int i = Facing.oppositeSide[u]; + Logger.INFO("Using Opposite direction: "+i); + + if (this.isInventoryFull(iinventory, i)) { + Logger.INFO("Target is full, skipping."); + continue; + } + else { + Logger.INFO("Target has space, let's move a single item."); + for (int j = 0; j < this.getSizeInventory(); ++j) { + if (this.getStackInSlot(j) != null) { + ItemStack itemstack = this.getStackInSlot(j).copy(); + ItemStack itemstack1 = setStackInNeighbour(iinventory, this.decrStackSize(j, 1), i); + if (itemstack1 == null || itemstack1.stackSize == 0) { + iinventory.markDirty(); + aDidPush = true; + continue; + } + this.setInventorySlotContents(j, itemstack); + } + } + } + } + } + + return aDidPush; + } + + private boolean isInventoryFull(IInventory aInv, int aSide) { + if (aInv instanceof ISidedInventory && aSide > -1) { + ISidedInventory isidedinventory = (ISidedInventory)aInv; + int[] aint = isidedinventory.getAccessibleSlotsFromSide(aSide); + + for (int l = 0; l < aint.length; ++l) + { + ItemStack itemstack1 = isidedinventory.getStackInSlot(aint[l]); + + if (itemstack1 == null || itemstack1.stackSize != itemstack1.getMaxStackSize()) + { + return false; + } + } + } + else { + int j = aInv.getSizeInventory(); + + for (int k = 0; k < j; ++k) + { + ItemStack itemstack = aInv.getStackInSlot(k); + + if (itemstack == null || itemstack.stackSize != itemstack.getMaxStackSize()) + { + return false; + } + } + } + return true; + } + + public static ItemStack setStackInNeighbour(IInventory aNeighbour, ItemStack aStack, int aSide) { + if (aNeighbour instanceof ISidedInventory && aSide > -1) + { + ISidedInventory isidedinventory = (ISidedInventory)aNeighbour; + int[] aint = isidedinventory.getAccessibleSlotsFromSide(aSide); + + for (int l = 0; l < aint.length && aStack != null && aStack.stackSize > 0; ++l) + { + aStack = tryMoveStack(aNeighbour, aStack, aint[l], aSide); + } + } + else + { + int j = aNeighbour.getSizeInventory(); + + for (int k = 0; k < j && aStack != null && aStack.stackSize > 0; ++k) + { + aStack = tryMoveStack(aNeighbour, aStack, k, aSide); + } + } + + if (aStack != null && aStack.stackSize == 0) + { + aStack = null; + } + + return aStack; + } + + private static boolean canInsertItemIntoNeighbour(IInventory aNeighbour, ItemStack aStack, int aSlot, int aSide) { + return !aNeighbour.isItemValidForSlot(aSlot, aStack) ? false : !(aNeighbour instanceof ISidedInventory) || ((ISidedInventory)aNeighbour).canInsertItem(aSlot, aStack, aSide); + } + + private static ItemStack tryMoveStack(IInventory aNeighbour, ItemStack aStack, int aSlot, int aSide) { + ItemStack itemstack1 = aNeighbour.getStackInSlot(aSlot); + if (canInsertItemIntoNeighbour(aNeighbour, aStack, aSlot, aSide)) { + boolean aDidSomething = false; + if (itemstack1 == null) { + //Forge: BUGFIX: Again, make things respect max stack sizes. + int max = Math.min(aStack.getMaxStackSize(), aNeighbour.getInventoryStackLimit()); + if (max >= aStack.stackSize) { + aNeighbour.setInventorySlotContents(aSlot, aStack); + aStack = null; + } + else { + aNeighbour.setInventorySlotContents(aSlot, aStack.splitStack(max)); + } + aDidSomething = true; + } + else if (areItemStacksEqual(itemstack1, aStack)) { + //Forge: BUGFIX: Again, make things respect max stack sizes. + int max = Math.min(aStack.getMaxStackSize(), aNeighbour.getInventoryStackLimit()); + if (max > itemstack1.stackSize) { + int l = Math.min(aStack.stackSize, max - itemstack1.stackSize); + aStack.stackSize -= l; + itemstack1.stackSize += l; + aDidSomething = l > 0; + } + } + if (aDidSomething){ + aNeighbour.markDirty(); + } + } + return aStack; + } + + private IInventory getInventoryFromFacing(int aSide) + { + int i = aSide; + return tryFindInvetoryAtXYZ(this.getWorldObj(), (double)(this.xCoord + Facing.offsetsXForSide[i]), (double)(this.yCoord + Facing.offsetsYForSide[i]), (double)(this.zCoord + Facing.offsetsZForSide[i])); + } + + public static IInventory tryFindInvetoryAtXYZ(World aWorld, double aX, double aY, double aZ) + { + IInventory iinventory = null; + int sX = MathHelper.floor_double(aX); + int sY = MathHelper.floor_double(aY); + int sZ = MathHelper.floor_double(aZ); + TileEntity tileentity = aWorld.getTileEntity(sX, sY, sZ); + + if (tileentity != null && tileentity instanceof IInventory) + { + iinventory = (IInventory)tileentity; + + if (iinventory instanceof TileEntityChest) + { + Block block = aWorld.getBlock(sX, sY, sZ); + + if (block instanceof BlockChest) + { + iinventory = ((BlockChest)block).func_149951_m(aWorld, sX, sY, sZ); + } + } + } + + if (iinventory == null) + { + List list = aWorld.getEntitiesWithinAABBExcludingEntity((Entity)null, AxisAlignedBB.getBoundingBox(aX, aY, aZ, aX + 1.0D, aY + 1.0D, aZ + 1.0D), IEntitySelector.selectInventories); + + if (list != null && list.size() > 0) + { + iinventory = (IInventory)list.get(aWorld.rand.nextInt(list.size())); + } + } + + return iinventory; + } + + private static boolean areItemStacksEqual(ItemStack aStack, ItemStack aStack2) { + return aStack.getItem() != aStack2.getItem() ? false : (aStack.getItemDamage() != aStack2.getItemDamage() ? false : (aStack.stackSize > aStack.getMaxStackSize() ? false : ItemStack.areItemStackTagsEqual(aStack, aStack2))); + } + + public void readFromNBT2(NBTTagCompound p_145839_1_) { + super.readFromNBT(p_145839_1_); + NBTTagList nbttaglist = p_145839_1_.getTagList("Items", 10); + this.aHopperInventory = new ItemStack[this.getSizeInventory()]; + for (int i = 0; i < nbttaglist.tagCount(); ++i) { + NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); + byte b0 = nbttagcompound1.getByte("Slot"); + if (b0 >= 0 && b0 < this.aHopperInventory.length) { + this.aHopperInventory[b0] = ItemStack.loadItemStackFromNBT( + nbttagcompound1 + ); + } + } + } + + public void writeToNBT2(NBTTagCompound aNBT) { + super.writeToNBT(aNBT); + NBTTagList nbttaglist = new NBTTagList(); + for (int i = 0; i < this.aHopperInventory.length; ++i) { + if (this.aHopperInventory[i] != null) { + NBTTagCompound nbttagcompound1 = new NBTTagCompound(); + nbttagcompound1.setByte("Slot", (byte) i); + this.aHopperInventory[i].writeToNBT(nbttagcompound1); + nbttaglist.appendTag(nbttagcompound1); + } + } + aNBT.setTag("Items", nbttaglist); + } + + + + + + + } diff --git a/src/Java/gtPlusPlus/nei/DecayableRecipeHandler.java b/src/Java/gtPlusPlus/nei/DecayableRecipeHandler.java index b5f5fa7989..dae1a663d7 100644 --- a/src/Java/gtPlusPlus/nei/DecayableRecipeHandler.java +++ b/src/Java/gtPlusPlus/nei/DecayableRecipeHandler.java @@ -220,7 +220,8 @@ public class DecayableRecipeHandler extends TemplateRecipeHandler { @Override public int compareTo(CachedRecipe o) { - if (o instanceof DecayableRecipeNEI) { + boolean b = DecayableRecipeNEI.class.isInstance(o); + if (b) { DecayableRecipeNEI p = (DecayableRecipeNEI) o; if (p.time > this.time) { return 1; @@ -232,5 +233,30 @@ public class DecayableRecipeHandler extends TemplateRecipeHandler { } return 0; } + + @Override + public boolean equals(Object obj) { + if (obj != null) { + if (DecayableRecipeNEI.class.isInstance(obj)) { + DecayableRecipeNEI p = (DecayableRecipeNEI) obj; + if (p != null) { + // Time check first to keep it simple and not unbox the Recipes. + if (p.time == this.time) { + ItemStack aInput = p.input.item; + ItemStack aOutput = p.output.item; + if (GT_Utility.areStacksEqual(aInput, this.input.item, true)) { + if (GT_Utility.areStacksEqual(aOutput, this.output.item, true)) { + return true; + } + } + } + } + + } + } + return false; + } + + } } \ No newline at end of file diff --git a/src/Java/gtPlusPlus/nei/GT_NEI_MultiBlockHandler.java b/src/Java/gtPlusPlus/nei/GT_NEI_MultiBlockHandler.java index 6612ab703f..e3c980e6a4 100644 --- a/src/Java/gtPlusPlus/nei/GT_NEI_MultiBlockHandler.java +++ b/src/Java/gtPlusPlus/nei/GT_NEI_MultiBlockHandler.java @@ -928,7 +928,7 @@ extends TemplateRecipeHandler { } - public class recipeCompare implements Comparator { + public class RecipeCompare implements Comparator { public int compare(GT_Recipe a, GT_Recipe b) { if (a.mEUt != b.mEUt) { return a.mEUt - b.mEUt; diff --git a/src/Java/gtPlusPlus/plugin/fixes/vanilla/VanillaBedHeightFix.java b/src/Java/gtPlusPlus/plugin/fixes/vanilla/VanillaBedHeightFix.java index 5f3b1d8abd..f33cc71fc6 100644 --- a/src/Java/gtPlusPlus/plugin/fixes/vanilla/VanillaBedHeightFix.java +++ b/src/Java/gtPlusPlus/plugin/fixes/vanilla/VanillaBedHeightFix.java @@ -23,7 +23,7 @@ public class VanillaBedHeightFix implements IBugFix { mParent = minstance; if (DevHelper.isValidHelperObject()) { Method m; - if (DevHelper.IsObfuscatedEnvironment()) { + if (DevHelper.isObfuscatedEnvironment()) { m = ReflectionUtils.getMethod(EntityPlayer.class, "func_71018_a", int.class, int.class, int.class); } else { diff --git a/src/Java/gtPlusPlus/preloader/DevHelper.java b/src/Java/gtPlusPlus/preloader/DevHelper.java index d942de503a..81d36d591b 100644 --- a/src/Java/gtPlusPlus/preloader/DevHelper.java +++ b/src/Java/gtPlusPlus/preloader/DevHelper.java @@ -32,7 +32,7 @@ public class DevHelper { - public static boolean IsObfuscatedEnvironment() { + public static boolean isObfuscatedEnvironment() { // Are we in a 'decompiled' environment? boolean deobfuscatedEnvironment = false; byte[] bs; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/storage/GregtechMetaTileEntity_PowerSubStationController.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/storage/GregtechMetaTileEntity_PowerSubStationController.java index dda1a6b0c0..7300b3507b 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/storage/GregtechMetaTileEntity_PowerSubStationController.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/storage/GregtechMetaTileEntity_PowerSubStationController.java @@ -21,6 +21,7 @@ import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.preloader.asm.AsmConfig; import gtPlusPlus.xmod.gregtech.api.gui.CONTAINER_PowerSubStation; import gtPlusPlus.xmod.gregtech.api.gui.GUI_PowerSubStation; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBattery; @@ -120,7 +121,9 @@ public class GregtechMetaTileEntity_PowerSubStationController extends GregtechMe checkMachineProblem(problem); } private void checkMachineProblem(String msg) { - Logger.INFO("Power Sub-Station problem: " + msg); + if (!AsmConfig.disableAllLogging) { + Logger.INFO("Power Sub-Station problem: " + msg); + } } public static int getCellTier(Block aBlock, int aMeta) { diff --git a/src/resources/assets/miscutils/lang/en_US.lang b/src/resources/assets/miscutils/lang/en_US.lang index 193df880f0..a66ac39435 100644 --- a/src/resources/assets/miscutils/lang/en_US.lang +++ b/src/resources/assets/miscutils/lang/en_US.lang @@ -3025,4 +3025,13 @@ item.dustImpureRareEarthIII.name=Impure Rare Earth (III) Dust item.dustPureRareEarthIII.name=Purified Rare Earth (III) Dust item.itemDustRareEarthIII.name=Rare Earth (III) Dust item.itemDustTinyRareEarthIII.name=Tiny Pile of Rare Earth (III) Dust -item.itemDustSmallRareEarthIII.name=Small Pile of Rare Earth (III) Dust \ No newline at end of file +item.itemDustSmallRareEarthIII.name=Small Pile of Rare Earth (III) Dust + + + +//Added 13/10/19 +tile.blockRoundRobinator.0.name=Round Robinator I +tile.blockRoundRobinator.1.name=Round Robinator II +tile.blockRoundRobinator.2.name=Round Robinator III +tile.blockRoundRobinator.3.name=Round Robinator IV +tile.blockRoundRobinator.4.name=Round Robinator V \ No newline at end of file diff --git a/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Side_0.png b/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Side_0.png new file mode 100644 index 0000000000..cbf604f2b3 Binary files /dev/null and b/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Side_0.png differ diff --git a/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Side_1.png b/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Side_1.png new file mode 100644 index 0000000000..3b7ac3d50e Binary files /dev/null and b/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Side_1.png differ diff --git a/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Side_2.png b/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Side_2.png new file mode 100644 index 0000000000..a5a5e2c559 Binary files /dev/null and b/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Side_2.png differ diff --git a/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Side_3.png b/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Side_3.png new file mode 100644 index 0000000000..b68c900ddd Binary files /dev/null and b/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Side_3.png differ diff --git a/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Side_4.png b/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Side_4.png new file mode 100644 index 0000000000..df182aeaa5 Binary files /dev/null and b/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Side_4.png differ diff --git a/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Top_0.png b/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Top_0.png new file mode 100644 index 0000000000..85bc3f16cd Binary files /dev/null and b/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Top_0.png differ diff --git a/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Top_1.png b/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Top_1.png new file mode 100644 index 0000000000..f82185ebdb Binary files /dev/null and b/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Top_1.png differ diff --git a/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Top_2.png b/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Top_2.png new file mode 100644 index 0000000000..345476e03c Binary files /dev/null and b/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Top_2.png differ diff --git a/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Top_3.png b/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Top_3.png new file mode 100644 index 0000000000..971164eb3e Binary files /dev/null and b/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Top_3.png differ diff --git a/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Top_4.png b/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Top_4.png new file mode 100644 index 0000000000..5b5bac3ad2 Binary files /dev/null and b/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Top_4.png differ diff --git a/src/resources/assets/miscutils/textures/gui/RoundRobinator.png b/src/resources/assets/miscutils/textures/gui/RoundRobinator.png new file mode 100644 index 0000000000..54c06f22ae Binary files /dev/null and b/src/resources/assets/miscutils/textures/gui/RoundRobinator.png differ -- cgit From f3a698a3af1826ef6f5ac719d31334b930e0005e Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Sun, 24 Nov 2019 16:14:12 +0000 Subject: + Added Concurrent Set objects to the API. + Added Flexible Pair objects to the API. + Added logging to ICO formation code. % Adjusted position of GUI elements in NEI for Chemical Plant recipes. % Adjusted the recipe for the Lava Filter. % Adjusted which fluids are returned when requesting tiered fluids from CI. This will inevitably adjust many recipes as a result. % Adjusted handling of the creative energy buffer. % Adjusted Achievement handler for Dev Mode. % Adjusted Tank Capacity on my Chemical Plants. $ Fixed Output buffer checks on multiblocks, Closes #574. $ Fixed LuV Super Bus recipes, Closes #575. (ULV super bus recipe is still broken for the time being) $ Attempted once more to fix Hot Water localization. --- src/Java/gtPlusPlus/api/objects/data/AutoMap.java | 14 + .../api/objects/data/ConcurrentHashSet.java | 18 + .../gtPlusPlus/api/objects/data/ConcurrentSet.java | 53 +++ .../gtPlusPlus/api/objects/data/FlexiblePair.java | 39 ++ .../handler/StopAnnoyingFuckingAchievements.java | 13 +- .../gtPlusPlus/core/recipe/RECIPES_Machines.java | 77 +++- src/Java/gtPlusPlus/core/recipe/common/CI.java | 16 +- .../gtPlusPlus/core/util/minecraft/ItemUtils.java | 9 + .../gtPlusPlus/core/util/minecraft/LangUtils.java | 51 +++ src/Java/gtPlusPlus/nei/GT_NEI_FluidReactor.java | 22 +- .../gregtech/api/gui/CONTAINER_MultiMachine.java | 16 +- .../base/GregtechMeta_MultiBlockBase.java | 464 ++++++++++++++++----- .../xmod/gregtech/common/Meta_GT_Proxy.java | 101 +++-- .../creative/GregtechMetaCreativeEnergyBuffer.java | 74 ++-- .../GregtechMetaTileEntity_ChemicalReactor.java | 6 +- .../GregtechMetaTileEntity_IndustrialCokeOven.java | 26 +- 16 files changed, 789 insertions(+), 210 deletions(-) create mode 100644 src/Java/gtPlusPlus/api/objects/data/ConcurrentHashSet.java create mode 100644 src/Java/gtPlusPlus/api/objects/data/ConcurrentSet.java create mode 100644 src/Java/gtPlusPlus/api/objects/data/FlexiblePair.java create mode 100644 src/Java/gtPlusPlus/core/util/minecraft/LangUtils.java (limited to 'src/Java/gtPlusPlus/api/objects') diff --git a/src/Java/gtPlusPlus/api/objects/data/AutoMap.java b/src/Java/gtPlusPlus/api/objects/data/AutoMap.java index 9e7f702200..02517097cf 100644 --- a/src/Java/gtPlusPlus/api/objects/data/AutoMap.java +++ b/src/Java/gtPlusPlus/api/objects/data/AutoMap.java @@ -70,6 +70,20 @@ public class AutoMap implements Iterable, Cloneable, Serializable, Collect } } } + + /** + * Generates an AutoMap from a Array. + * @param aArray - Data to be inserted into the AutoMap. + */ + public AutoMap(V[] aArray) { + mInternalMap = new LinkedHashMap(); + mInternalNameMap = new LinkedHashMap(); + if (aArray != null && aArray.length > 0) { + for (V obj : aArray) { + add(obj); + } + } + } @Override public Iterator iterator() { diff --git a/src/Java/gtPlusPlus/api/objects/data/ConcurrentHashSet.java b/src/Java/gtPlusPlus/api/objects/data/ConcurrentHashSet.java new file mode 100644 index 0000000000..991908e402 --- /dev/null +++ b/src/Java/gtPlusPlus/api/objects/data/ConcurrentHashSet.java @@ -0,0 +1,18 @@ +package gtPlusPlus.api.objects.data; + +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; + +public class ConcurrentHashSet extends ConcurrentSet { + + private static final long serialVersionUID = -1293478938482781728L; + + public ConcurrentHashSet() { + this(new ConcurrentHashMap()); + } + + public ConcurrentHashSet(ConcurrentMap defaultMapType) { + super(defaultMapType); + } + +} diff --git a/src/Java/gtPlusPlus/api/objects/data/ConcurrentSet.java b/src/Java/gtPlusPlus/api/objects/data/ConcurrentSet.java new file mode 100644 index 0000000000..1d3ffc1c01 --- /dev/null +++ b/src/Java/gtPlusPlus/api/objects/data/ConcurrentSet.java @@ -0,0 +1,53 @@ +package gtPlusPlus.api.objects.data; + +import java.io.Serializable; +import java.util.AbstractSet; +import java.util.Iterator; +import java.util.concurrent.ConcurrentMap; + +public abstract class ConcurrentSet extends AbstractSet implements Serializable { + + private static final long serialVersionUID = -6761513279741915432L; + + private final ConcurrentMap mInternalMap; + + private int mInternalID = 0; + + /** + * Creates a new instance which wraps the specified {@code map}. + */ + public ConcurrentSet(ConcurrentMap aMap) { + mInternalMap = aMap; + } + + @Override + public int size() { + return mInternalMap.size(); + } + + @Override + public boolean contains(Object o) { + return mInternalMap.containsKey(o); + } + + @Override + public boolean add(E o) { + return mInternalMap.putIfAbsent(mInternalID++, o) == null; + } + + @Override + public boolean remove(Object o) { + return mInternalMap.remove(o) != null; + } + + @Override + public void clear() { + this.mInternalID = 0; + mInternalMap.clear(); + } + + @Override + public Iterator iterator() { + return mInternalMap.values().iterator(); + } +} diff --git a/src/Java/gtPlusPlus/api/objects/data/FlexiblePair.java b/src/Java/gtPlusPlus/api/objects/data/FlexiblePair.java new file mode 100644 index 0000000000..64f57b4e5a --- /dev/null +++ b/src/Java/gtPlusPlus/api/objects/data/FlexiblePair.java @@ -0,0 +1,39 @@ +package gtPlusPlus.api.objects.data; + +import java.io.Serializable; + +import com.google.common.base.Objects; + +public class FlexiblePair implements Serializable { + + /** + * SVUID + */ + private static final long serialVersionUID = 1250550491092812443L; + private final K key; + private V value; + + public FlexiblePair(final K key, final V value){ + this.key = key; + this.value = value; + } + + final public K getKey(){ + return this.key; + } + + final public V getValue(){ + return this.value; + } + + final public void setValue(V aObj) { + value = aObj; + } + + @Override + public int hashCode() { + Integer aCode = Objects.hashCode(getKey(), getValue()); + return aCode != null ? aCode : super.hashCode(); + } + +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/handler/StopAnnoyingFuckingAchievements.java b/src/Java/gtPlusPlus/core/handler/StopAnnoyingFuckingAchievements.java index b10e67aeaf..8853acd4b7 100644 --- a/src/Java/gtPlusPlus/core/handler/StopAnnoyingFuckingAchievements.java +++ b/src/Java/gtPlusPlus/core/handler/StopAnnoyingFuckingAchievements.java @@ -1,8 +1,8 @@ package gtPlusPlus.core.handler; +import cpw.mods.fml.common.eventhandler.EventPriority; import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import gtPlusPlus.core.util.math.MathUtils; -import gtPlusPlus.core.util.minecraft.PlayerUtils; +import net.minecraft.client.Minecraft; import net.minecraft.stats.AchievementList; import net.minecraftforge.event.entity.player.AchievementEvent; @@ -12,12 +12,15 @@ public class StopAnnoyingFuckingAchievements { * Stops me getting fireworks every fucking time I open my inventory upon first loading a dev client. * @param event */ - @SubscribeEvent + @SubscribeEvent(priority=EventPriority.HIGHEST) public void FUCK_OFF(AchievementEvent event) { if (event.achievement.equals(AchievementList.openInventory)) { - if (MathUtils.randInt(0, 10) >= 9) - PlayerUtils.messagePlayer(event.entityPlayer, "Bang! Nah, Just joking, there's no fireworks. :)"); event.setCanceled(true); + if (Minecraft.getMinecraft() != null) { + if (Minecraft.getMinecraft().gameSettings != null) { + Minecraft.getMinecraft().gameSettings.showInventoryAchievementHint = false; + } + } } } diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java index bc1c7fc398..c0a4a998e8 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java @@ -1063,7 +1063,20 @@ public class RECIPES_Machines { RECIPE_ThermalBoilerCasing); //Lava Filter Recipe - GT_Values.RA.addAssemblerRecipe(ItemUtils.getItemStackWithMeta(LoadedMods.IndustrialCraft2, "IC2:itemPartCarbonMesh", "RawCarbonMesh", 0, 16), CI.getNumberedCircuit(18), ItemUtils.getSimpleStack(ModItems.itemLavaFilter), 80*20, 16); + CORE.RA.addSixSlotAssemblingRecipe(new ItemStack[] { + CI.getNumberedCircuit(18), + ItemUtils.getItemStackOfAmountFromOreDict("dustCarbon", GTNH ? 64 : 32), + ItemUtils.getItemStackOfAmountFromOreDict("wireFineSteel", GTNH ? 64 : 32), + ItemUtils.getItemStackOfAmountFromOreDict("ringTumbaga", GTNH ? 32 : 16), + ItemUtils.getItemStackOfAmountFromOreDict("foilCopper", GTNH ? 8 : 4), + ItemUtils.getItemStackWithMeta(LoadedMods.IndustrialCraft2, "IC2:itemPartCarbonMesh", "RawCarbonMesh", 0, 64), + + }, + CI.getTieredFluid(3, 144), + ItemUtils.getSimpleStack(ModItems.itemLavaFilter, GTNH ? 8 : 16), + 1600, + 240 + ); } if (CORE.ConfigSwitches.enableMultiblock_LiquidFluorideThoriumReactor){ @@ -2201,10 +2214,10 @@ public class RECIPES_Machines { ItemList.Hatch_Input_Bus_ZPM.get(1), ItemList.Hatch_Input_Bus_UV.get(1), ItemList.Hatch_Input_Bus_MAX.get(1), - GregtechItemList.Hatch_SuperBus_Input_ULV.get(1), GregtechItemList.Hatch_SuperBus_Input_LV.get(1), GregtechItemList.Hatch_SuperBus_Input_MV.get(1), GregtechItemList.Hatch_SuperBus_Input_HV.get(1), + GregtechItemList.Hatch_SuperBus_Input_EV.get(1), }; ItemStack[] mOutputHatch = new ItemStack[] { @@ -2214,20 +2227,66 @@ public class RECIPES_Machines { ItemList.Hatch_Output_Bus_ZPM.get(1), ItemList.Hatch_Output_Bus_UV.get(1), ItemList.Hatch_Output_Bus_MAX.get(1), - GregtechItemList.Hatch_SuperBus_Output_ULV.get(1), GregtechItemList.Hatch_SuperBus_Output_LV.get(1), GregtechItemList.Hatch_SuperBus_Output_MV.get(1), GregtechItemList.Hatch_SuperBus_Output_HV.get(1), + GregtechItemList.Hatch_SuperBus_Output_EV.get(1), }; + // Special Case recipes for ULV buses + { + + int i = 0; + ItemStack[] aInputs1 = new ItemStack[] { + CI.getNumberedCircuit(17), + mInputHatch[i], + CI.getElectricMotor(i, GTNH ? 8 : 2), + CI.getConveyor(i, GTNH ? 10 : 5), + CI.getBolt(i, GTNH ? 32 : 16), + CI.getTieredComponent(OrePrefixes.circuit, i, GTNH ? 4 : 2) + }; + Logger.INFO("[FIND] "+ItemUtils.getArrayStackNames(aInputs1)); + ItemStack[] aOutputs1 = new ItemStack[] { + CI.getNumberedCircuit(18), + mOutputHatch[i], + CI.getElectricPiston(i, GTNH ? 8 : 2), + CI.getConveyor(i, GTNH ? 10 : 5), + CI.getGear(i, GTNH ? 6 : 3), + CI.getTieredComponent(OrePrefixes.circuit, i, GTNH ? 4 : 2) + }; + Logger.INFO("[FIND] "+ItemUtils.getArrayStackNames(aOutputs1)); + + FluidStack a1 = CI.getAlternativeTieredFluid(i, 144 * 8); + FluidStack a2 = CI.getTertiaryTieredFluid(i, 144 * 8); + + + Logger.INFO("[FIND] Input Bus Fluid: "+ItemUtils.getFluidName(a1)); + Logger.INFO("[FIND] Output Bus Fluid: "+ItemUtils.getFluidName(a2)); + + + CORE.RA.addSixSlotAssemblingRecipe(aInputs1, + a1, + mSuperBusesInput[i].get(1), + 20 * 30 * 2 * i, + (int) GT_Values.V[i]); + + CORE.RA.addSixSlotAssemblingRecipe(aOutputs1, + a2, + mSuperBusesOutput[i].get(1), + 20 * 30 * 2 * i, + (int) GT_Values.V[i]); + + + } + //Input Buses - for (int i = 0; i < 10; i++) { + for (int i = 1; i < 10; i++) { CORE.RA.addSixSlotAssemblingRecipe(new ItemStack[] { - CI.getNumberedCircuit(16), + CI.getNumberedCircuit(17), mInputHatch[i], CI.getElectricMotor(i, GTNH ? 8 : 2), CI.getConveyor(i, GTNH ? 10 : 5), - CI.getGear(i, GTNH ? 6 : 3), + CI.getBolt(i, GTNH ? 32 : 16), CI.getTieredComponent(OrePrefixes.circuit, i, GTNH ? 4 : 2) }, CI.getAlternativeTieredFluid(i, 144 * 8), @@ -2235,7 +2294,7 @@ public class RECIPES_Machines { (int) GT_Values.V[i]); } //Output Buses - for (int i = 0; i < 10; i++) { + for (int i = 1; i < 10; i++) { CORE.RA.addSixSlotAssemblingRecipe(new ItemStack[] { CI.getNumberedCircuit(18), mOutputHatch[i], @@ -2259,7 +2318,7 @@ public class RECIPES_Machines { CI.craftingToolWrench, CI.machineCasing_ULV, CI.craftingToolScrewdriver, ItemUtils.getSimpleStack(Blocks.hopper), "circuitPrimitive", ItemUtils.getSimpleStack(Blocks.hopper), ItemUtils.simpleMetaStack(ModBlocks.blockRoundRobinator, 0, 1)); - + ItemStack[] aRobinators = new ItemStack[] { ItemUtils.simpleMetaStack(ModBlocks.blockRoundRobinator, 0, 1), ItemUtils.simpleMetaStack(ModBlocks.blockRoundRobinator, 1, 1), @@ -2283,7 +2342,7 @@ public class RECIPES_Machines { CI.getTieredComponent(OrePrefixes.plate, aTier, 4 * aCostMultiplier), CI.getTieredComponent(OrePrefixes.circuit, i, 2 * aCostMultiplier), }; - + CORE.RA.addSixSlotAssemblingRecipe( aInputs, CI.getAlternativeTieredFluid(aTier, (144 * 2 * i)), //Input Fluid diff --git a/src/Java/gtPlusPlus/core/recipe/common/CI.java b/src/Java/gtPlusPlus/core/recipe/common/CI.java index 63477cda19..968a96135e 100644 --- a/src/Java/gtPlusPlus/core/recipe/common/CI.java +++ b/src/Java/gtPlusPlus/core/recipe/common/CI.java @@ -634,12 +634,22 @@ public class CI { } public static FluidStack getTieredFluid(int aTier, int aAmount, int aType) { - ItemStack aCell = getTieredComponent(OrePrefixes.liquid, aTier, 1); + // Weird Legacy handling + /*ItemStack aCell = getTieredComponent(OrePrefixes.liquid, aTier, 1); FluidStack a = GT_Utility.getFluidForFilledItem(aCell, true); if (a == null) { a = aMaster[aType][aTier].getFluid(aAmount); - } - a.amount = aAmount; + }*/ + + // Modern Handling + FluidStack a = aMaster[aType][aTier].getFluid(aAmount); + if (a == null) { + ItemStack aCell = getTieredComponent(OrePrefixes.liquid, aTier, 1); + if (aCell != null) { + a = GT_Utility.getFluidForFilledItem(aCell, true); + a.amount = aAmount; + } + } return a; } diff --git a/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java index 88fdda555c..cb490203df 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java @@ -47,6 +47,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; +import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.oredict.OreDictionary; @@ -1083,6 +1084,14 @@ public class ItemUtils { } + + public static String getFluidName(FluidStack aFluid) { + return aFluid != null ? aFluid.getFluid().getLocalizedName(aFluid) : "NULL"; + } + + public static String getFluidName(Fluid aFluid) { + return aFluid != null ? aFluid.getLocalizedName() : "NULL"; + } public static String getItemName(ItemStack aStack) { if (aStack == null) { diff --git a/src/Java/gtPlusPlus/core/util/minecraft/LangUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/LangUtils.java new file mode 100644 index 0000000000..1de4209bf9 --- /dev/null +++ b/src/Java/gtPlusPlus/core/util/minecraft/LangUtils.java @@ -0,0 +1,51 @@ +package gtPlusPlus.core.util.minecraft; + +import java.lang.reflect.Field; +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; + +import cpw.mods.fml.common.registry.LanguageRegistry; +import gtPlusPlus.core.util.reflect.ReflectionUtils; + +public class LangUtils { + + + public static boolean rewriteEntryForLanguageRegistry(String aKey, String aNewValue){ + return rewriteEntryForLanguageRegistry("en_US", aKey, aNewValue); + } + + @SuppressWarnings("unchecked") + public static boolean rewriteEntryForLanguageRegistry(String aLang, String aKey, String aNewValue){ + LanguageRegistry aInstance = LanguageRegistry.instance(); + Field aModLanguageData = ReflectionUtils.getField(LanguageRegistry.class, "modLanguageData"); + if (aModLanguageData != null){ + Map aProps = new HashMap(); + Object aInstanceProps; + try { + aInstanceProps = aModLanguageData.get(aInstance); + if (aInstanceProps != null){ + aProps = (Map) aInstanceProps; + Properties aLangProps = aProps.get(aLang); + if (aLangProps != null){ + if (aLangProps.containsKey(aKey)) { + aLangProps.remove(aKey); + aLangProps.put(aKey, aNewValue); + } + else { + aLangProps.put(aKey, aNewValue); + } + aProps.remove(aLang); + aProps.put(aLang, aLangProps); + ReflectionUtils.setField(aInstance, aModLanguageData, aProps); + } + } + } + catch (IllegalArgumentException | IllegalAccessException e) { + + } + } + return false; + } + +} diff --git a/src/Java/gtPlusPlus/nei/GT_NEI_FluidReactor.java b/src/Java/gtPlusPlus/nei/GT_NEI_FluidReactor.java index 5c5d1169aa..e4279cf489 100644 --- a/src/Java/gtPlusPlus/nei/GT_NEI_FluidReactor.java +++ b/src/Java/gtPlusPlus/nei/GT_NEI_FluidReactor.java @@ -65,7 +65,7 @@ extends TemplateRecipeHandler { @Override public void loadCraftingRecipes(final String outputId, final Object... results) { - if (outputId.equals(this.getOverlayIdentifier())) { + if (outputId.equals(this.mRecipeMap.mNEIName)) { for (final GT_Recipe tRecipe : this.mRecipeMap.mRecipeList) { if (!tRecipe.mHidden) { this.arecipes.add(new CachedDefaultRecipe(tRecipe)); @@ -146,7 +146,8 @@ extends TemplateRecipeHandler { @Override public String getOverlayIdentifier() { - return this.mRecipeMap.mNEIName; + //return this.mRecipeMap.mNEIName; + return "Penis"; } @Override @@ -163,7 +164,8 @@ extends TemplateRecipeHandler { @Override public String getRecipeName() { - return GT_LanguageManager.getTranslation(this.mRecipeMap.mUnlocalizedName); + //return GT_LanguageManager.getTranslation(this.mRecipeMap.mUnlocalizedName); + return " Chem Plant"; } @Override @@ -201,24 +203,24 @@ extends TemplateRecipeHandler { @Override public void drawExtras(final int aRecipeIndex) { - final int tEUt = ((CachedDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.mEUt; + final long tEUt = ((CachedDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.mEUt; final int tDuration = ((CachedDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.mDuration; if (tEUt != 0) { - drawText(10, 73, "Total: " + (tDuration * tEUt) + " EU", -16777216); - drawText(10, 83, "Usage: " + tEUt + " EU/t", -16777216); + drawText(10, 73, "Total: " + (long) (tDuration * tEUt) + " EU", -16777216); + //drawText(10, 83, "Usage: " + tEUt + " EU/t", -16777216); if (this.mRecipeMap.mShowVoltageAmperageInNEI) { - drawText(10, 93, "Voltage: " + (tEUt / this.mRecipeMap.mAmperage) + " EU", -16777216); - drawText(10, 103, "Amperage: " + this.mRecipeMap.mAmperage, -16777216); + drawText(10, 83, "Voltage: " + (tEUt / this.mRecipeMap.mAmperage) + " EU/t", -16777216); + drawText(10, 93, "Amperage: " + this.mRecipeMap.mAmperage, -16777216); } else { drawText(10, 93, "Voltage: unspecified", -16777216); drawText(10, 103, "Amperage: unspecified", -16777216); } } if (tDuration > 0) { - drawText(10, 113, "Time: " + (tDuration < 20 ? "< 1" : Integer.valueOf(tDuration / 20)) + " secs", -16777216); + drawText(10, 103, "Time: " + (tDuration < 20 ? "< 1" : Integer.valueOf(tDuration / 20)) + " secs", -16777216); } if ((GT_Utility.isStringValid(this.mRecipeMap.mNEISpecialValuePre)) || (GT_Utility.isStringValid(this.mRecipeMap.mNEISpecialValuePost))) { - drawText(10, 123, this.mRecipeMap.mNEISpecialValuePre + (((CachedDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.mSpecialValue * this.mRecipeMap.mNEISpecialValueMultiplier) + this.mRecipeMap.mNEISpecialValuePost, -16777216); + drawText(10, 113, this.mRecipeMap.mNEISpecialValuePre + (((CachedDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.mSpecialValue * this.mRecipeMap.mNEISpecialValueMultiplier) + this.mRecipeMap.mNEISpecialValuePost, -16777216); } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_MultiMachine.java b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_MultiMachine.java index d3e22875ae..88b9661c95 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_MultiMachine.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_MultiMachine.java @@ -101,32 +101,32 @@ public class CONTAINER_MultiMachine extends GT_ContainerMetaTile_Machine { //crafters = ReflectionUtils.getField(getClass(), "crafters"); } if (timer != null && crafters != null && mControllerSet) { - Logger.INFO("Trying to update clientside GUI data"); + //Logger.INFO("Trying to update clientside GUI data"); try { - Logger.INFO("0"); + //Logger.INFO("0"); int aTimer = (int) ReflectionUtils.getFieldValue(timer, this); //List crafters1List = (List) crafters1; List crafters2 = new ArrayList(); - Logger.INFO("1"); + //Logger.INFO("1"); for (Object o : crafters) { if (o instanceof ICrafting) { crafters2.add((ICrafting) o); } } - Logger.INFO("2"); + //Logger.INFO("2"); if (!crafters2.isEmpty()) { - Logger.INFO("3"); + //Logger.INFO("3"); handleInitialFieldSetting(); try { - Logger.INFO("4"); + //Logger.INFO("4"); for (final ICrafting var3 : crafters2) { handleCraftingEvent(aTimer, var3); } - Logger.INFO("5"); + //Logger.INFO("5"); handleInternalFieldSetting(); - Logger.INFO("6"); + //Logger.INFO("6"); } catch (Throwable t) { } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java index 68b81182fc..2e50d12aca 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java @@ -42,6 +42,11 @@ import gtPlusPlus.GTplusplus; import gtPlusPlus.GTplusplus.INIT_PHASE; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.api.objects.data.ConcurrentHashSet; +import gtPlusPlus.api.objects.data.ConcurrentSet; +import gtPlusPlus.api.objects.data.FlexiblePair; +import gtPlusPlus.api.objects.data.Pair; +import gtPlusPlus.api.objects.data.Triplet; import gtPlusPlus.api.objects.minecraft.BlockPos; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.lib.LoadedMods; @@ -49,6 +54,7 @@ import gtPlusPlus.core.recipe.common.CI; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.reflect.ReflectionUtils; +import gtPlusPlus.preloader.asm.AsmConfig; import gtPlusPlus.xmod.gregtech.api.gui.CONTAINER_MultiMachine; import gtPlusPlus.xmod.gregtech.api.gui.CONTAINER_MultiMachine_NoPlayerInventory; import gtPlusPlus.xmod.gregtech.api.gui.GUI_MultiMachine; @@ -59,6 +65,7 @@ import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEn import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBattery; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_OutputBattery; import gtPlusPlus.xmod.gregtech.api.objects.MultiblockRequirements; + import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; @@ -92,12 +99,12 @@ GT_MetaTileEntity_MultiBlockBase { else { aLogger = ReflectionUtils.getMethod(Logger.class, "MACHINE_INFO", String.class); } - + try { calculatePollutionReduction = GT_MetaTileEntity_Hatch_Muffler.class.getDeclaredMethod("calculatePollutionReduction", int.class); } catch (NoSuchMethodException | SecurityException e) {} - - + + //gregtech.api.util.GT_Recipe.GT_Recipe_Map.findRecipe(IHasWorldObjectAndCoords, GT_Recipe, boolean, long, FluidStack[], ItemStack, ItemStack...) } @@ -135,7 +142,7 @@ GT_MetaTileEntity_MultiBlockBase { } public abstract boolean hasSlotInGUI(); - + public long getTotalRuntimeInTicks() { return this.mTotalRunTime; } @@ -276,7 +283,7 @@ GT_MetaTileEntity_MultiBlockBase { } - + public int getPollutionReductionForAllMufflers() { int mPollutionReduction=0; for (GT_MetaTileEntity_Hatch_Muffler tHatch : mMufflerHatches) { @@ -286,7 +293,7 @@ GT_MetaTileEntity_MultiBlockBase { } return mPollutionReduction; } - + public long getStoredEnergyInAllEnergyHatches() { long storedEnergy=0; for(GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches) { @@ -296,7 +303,7 @@ GT_MetaTileEntity_MultiBlockBase { } return storedEnergy; } - + public long getMaxEnergyStorageOfAllEnergyHatches() { long maxEnergy=0; for(GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches) { @@ -408,7 +415,7 @@ GT_MetaTileEntity_MultiBlockBase { String[] aToolTip = new String[(a2 + a3)]; aToolTip = ArrayUtils.addAll(aToolTip, x); aToolTip = ArrayUtils.addAll(aToolTip, z); - + if (aCachedToolTip == null || aCachedToolTip.length <= 0) { aCachedToolTip = aToolTip; } @@ -465,66 +472,300 @@ GT_MetaTileEntity_MultiBlockBase { public String getSound() { return ""; } public boolean canBufferOutputs(final GT_Recipe aRecipe, int aParallelRecipes) { - if (aRecipe.mOutputs.length > 16) { - // Gendustry custom comb with a billion centrifuge outputs? Do it anyway. - return true; - } - // Count slots available in output buses - ArrayList tBusStacks = new ArrayList<>(); + Logger.INFO("Determining if we have space to buffer outputs."); + + // Null recipe or a recipe with lots of outputs? + // E.G. Gendustry custom comb with a billion centrifuge outputs? + // Do it anyway. + if (aRecipe == null || aRecipe.mOutputs.length > 16) { + return aRecipe == null ? false : true; + } - int tEmptySlots = 0; - for (final GT_MetaTileEntity_Hatch_OutputBus tBus : this.mOutputBusses) { - if (!isValidMetaTileEntity(tBus)) { - continue; + // Do we even need to check for item outputs? + boolean aDoesOutputItems = aRecipe.mOutputs.length > 0; + // Do we even need to check for fluid outputs? + boolean aDoesOutputFluids = aRecipe.mFluidOutputs.length > 0; + + + + /* ======================================== + * Item Management + * ======================================== + */ + + if (aDoesOutputItems) { + Logger.INFO("We have items to output."); + + // How many slots are free across all the output buses? + int aInputBusSlotsFree = 0; + + /* + * Create Variables for Item Output + */ + + AutoMap> aItemMap = new AutoMap>(); + AutoMap aOutputs = new AutoMap(aRecipe.mOutputs); + + for (final GT_MetaTileEntity_Hatch_OutputBus tBus : this.mOutputBusses) { + if (!isValidMetaTileEntity(tBus)) { + continue; + } + final IInventory tBusInv = tBus.getBaseMetaTileEntity(); + for (int i = 0; i < tBusInv.getSizeInventory(); i++) { + if (tBus.getStackInSlot(i) == null) { + aInputBusSlotsFree++; + } + else { + ItemStack aT = tBus.getStackInSlot(i); + int aSize = aT.stackSize; + aT = aT.copy(); + aT.stackSize = 0; + aItemMap.put(new FlexiblePair(aT, aSize)); + } + } } - final IInventory tBusInv = tBus.getBaseMetaTileEntity(); - for (int i = 0; i < tBusInv.getSizeInventory(); i++) { - if (tBus.getStackInSlot(i) == null) { - tEmptySlots++; + + // Count the slots we need, later we can check if any are able to merge with existing stacks + int aRecipeSlotsRequired = 0; + + // A map to hold the items we will be 'inputting' into the output buses. These itemstacks are actually the recipe outputs. + ConcurrentSet> aInputMap = new ConcurrentHashSet>(); + + // Iterate over the outputs, calculating require stack spacing they will require. + for (int i=0;i 64) { + int aSlotsNeedsForThisStack = (int) Math.ceil((double) ((float) aStackSize / 64f)); + // Sould round up and add as many stacks as required nicely. + aRecipeSlotsRequired += aSlotsNeedsForThisStack; + for (int o=0;o 64 ? 64 : aStackSize; + aY = aY.copy(); + aY.stackSize = 0; + aInputMap.add(new FlexiblePair(aY, aStackToRemove)); + } + } + else { + // Only requires one slot + aRecipeSlotsRequired++; + aY = aY.copy(); + aY.stackSize = 0; + aInputMap.add(new FlexiblePair(aY, aStackSize)); + } + } + } + + // We have items to add to the output buses. See if any are not full stacks and see if we can make them full. + if (aInputMap.size() > 0) { + // Iterate over the current stored items in the Output busses, if any match and are not full, we can try account for merging. + busItems: for (FlexiblePair y : aItemMap) { + // Iterate over the 'inputs', we can safely remove these as we go. + outputItems: for (FlexiblePair u : aInputMap) { + // Create local vars for readability. + ItemStack aOutputBusStack = y.getKey(); + ItemStack aOutputStack = u.getKey(); + // Stacks match, including NBT. + if (GT_Utility.areStacksEqual(aOutputBusStack, aOutputStack, false)) { + // Stack Matches, but it's full, continue. + if (aOutputBusStack.stackSize >= 64) { + // This stack is full, no point checking it. + continue busItems; + } + else { + // We can merge these two stacks without any hassle. + if ((aOutputBusStack.stackSize + aOutputStack.stackSize) <= 64) { + // Update the stack size in the bus storage map. + y.setValue(aOutputBusStack.stackSize + aOutputStack.stackSize); + // Remove the 'input' stack from the recipe outputs, so we don't try count it again. + aInputMap.remove(u); + continue outputItems; + } + // Stack merging is too much, so we fill this stack, leave the remainder. + else { + int aRemainder = (aOutputBusStack.stackSize + aOutputStack.stackSize) - 64; + // Update the stack size in the bus storage map. + y.setValue(64); + // Create a new object to iterate over later, with the remainder data; + FlexiblePair t = new FlexiblePair(u.getKey(), aRemainder); + // Remove the 'input' stack from the recipe outputs, so we don't try count it again. + aInputMap.remove(u); + // Add the remainder stack. + aInputMap.add(t); + continue outputItems; + } + } + } + else { + continue outputItems; + } + } + } } + + // We have stacks that did not merge, do we have space for them? + if (aInputMap.size() > 0) { + if (aInputMap.size() > aInputBusSlotsFree) { + // We do not have enough free slots in total to accommodate the remaining managed stacks. + Logger.INFO("Failed to find enough space for all item outputs."); + return false; + } + } + + /* + * End Item Management + */ + } - int slotsNeeded = aRecipe.mOutputs.length; - for (final ItemStack tRecipeOutput: aRecipe.mOutputs) { - if (tRecipeOutput == null) continue; - int amount = tRecipeOutput.stackSize * aParallelRecipes; - for (final ItemStack tBusStack : tBusStacks) { - if (GT_Utility.areStacksEqual(tBusStack, tRecipeOutput)) { - if (tBusStack.stackSize + amount <= tBusStack.getMaxStackSize()) { - slotsNeeded--; - break; - } + + + + + /* ======================================== + * Fluid Management + * ======================================== + */ + + + + if (aDoesOutputFluids) { + Logger.INFO("We have Fluids to output."); + // How many slots are free across all the output buses? + int aFluidHatches = 0; + int aEmptyFluidHatches = 0; + int aFullFluidHatches = 0; + // Create Map for Fluid Output + ConcurrentHashSet> aOutputHatches = new ConcurrentHashSet>(); + for (final GT_MetaTileEntity_Hatch_Output tBus : this.mOutputHatches) { + if (!isValidMetaTileEntity(tBus)) { + continue; + } + aFluidHatches++; + // Map the Hatch with the space left for easy checking later. + if (tBus.getFluid() == null) { + aOutputHatches.add(new Triplet(tBus, null, tBus.getCapacity())); + } + else { + int aSpaceLeft = tBus.getCapacity() - tBus.getFluidAmount(); + aOutputHatches.add(new Triplet(tBus, tBus.getFluid(), aSpaceLeft)); } } - } - // Enough open slots? - if (tEmptySlots < slotsNeeded) return false; - - // For each output fluid, make sure an output hatch can accept it. - for (FluidStack tRecipeFluid: aRecipe.mFluidOutputs) { - if (tRecipeFluid == null) continue; - boolean tCanBufferFluid = false; - int tRecipeAmount = tRecipeFluid.amount; - for (final GT_MetaTileEntity_Hatch_Output tHatch : this.mOutputHatches) { - FluidStack tHatchFluid = tHatch.getFluid(); - if (tHatchFluid == null) { - if(tHatch.getCapacity() > tRecipeAmount) { - tCanBufferFluid = true; - break; - } + // Create a map of all the fluids we would like to output, we can iterate over this and see how many we can merge into existing hatch stacks. + ConcurrentHashSet aOutputFluids = new ConcurrentHashSet(); + // Ugly ass boxing + aOutputFluids.addAll(new AutoMap(aRecipe.mFluidOutputs)); + // Iterate the Hatches, updating their 'stored' data. + aHatchIterator: for (Triplet aHatchData : aOutputHatches) { + // The Hatch Itself + GT_MetaTileEntity_Hatch_Output aHatch = aHatchData.getValue_1(); + // Fluid in the Hatch + FluidStack aHatchStack = aHatchData.getValue_2(); + // Space left in Hatch + int aSpaceLeftInHatch = aHatch.getCapacity() - aHatch.getFluidAmount(); + // Hatch is full, + if (aSpaceLeftInHatch <= 0) { + aFullFluidHatches++; + aOutputHatches.remove(aHatchData); + continue aHatchIterator; } - else if (tHatchFluid.isFluidEqual(tRecipeFluid) && tHatch.getCapacity() - tHatchFluid.amount > tRecipeAmount) { - tCanBufferFluid = true; - break; + // Hatch has space + else { + // Check if any fluids match + aFluidMatch: for (FluidStack aOutputStack : aOutputFluids) { + if (GT_Utility.areFluidsEqual(aHatchStack, aOutputStack)) { + int aFluidToPutIntoHatch = aOutputStack.amount; + // Not Enough space to insert all of the fluid. + // We fill this hatch and add a smaller Fluidstack back to the iterator. + if (aSpaceLeftInHatch < aFluidToPutIntoHatch) { + // Copy existing Hatch Stack + FluidStack aNewHatchStack = aHatchStack.copy(); + aNewHatchStack.amount = 0; + // Copy existing Hatch Stack again + FluidStack aNewOutputStack = aHatchStack.copy(); + aNewOutputStack.amount = 0; + // How much fluid do we have left after we fill the hatch? + int aFluidLeftAfterInsert = aFluidToPutIntoHatch - aSpaceLeftInHatch; + // Set new stacks to appropriate values + aNewHatchStack.amount = aHatch.getCapacity(); + aNewOutputStack.amount = aFluidLeftAfterInsert; + // Remove fluid from output list, merge success + aOutputFluids.remove(aOutputStack); + // Remove hatch from hatch list, data is now invalid. + aOutputHatches.remove(aHatchData); + // Add remaining Fluid to Output list + aOutputFluids.add(aNewOutputStack); + // Re-add hatch to hatch list, with new data. + Triplet aNewHatchData = new Triplet(aHatch, aNewHatchStack, aNewHatchStack.amount); + aOutputHatches.add(aNewHatchData); + continue aHatchIterator; + } + // We can fill this hatch perfectly (rare case), may as well add it directly to the full list. + else if (aSpaceLeftInHatch == aFluidToPutIntoHatch) { + // Copy Old Stack + FluidStack aNewHatchStack = aHatchStack.copy(); + // Add in amount from output stack + aNewHatchStack.amount += aOutputStack.amount; + // Remove fluid from output list, merge success + aOutputFluids.remove(aOutputStack); + // Remove hatch from hatch list, data is now invalid. + aOutputHatches.remove(aHatchData); + // Re-add hatch to hatch list, with new data. + Triplet aNewHatchData = new Triplet(aHatch, aNewHatchStack, aNewHatchStack.amount); + aOutputHatches.add(aNewHatchData); + continue aHatchIterator; + } + // We have more space than we need to merge, so we remove the stack from the output list and update the hatch list. + else { + // Copy Old Stack + FluidStack aNewHatchStack = aHatchStack.copy(); + // Add in amount from output stack + aNewHatchStack.amount += aOutputStack.amount; + // Remove fluid from output list, merge success + aOutputFluids.remove(aOutputStack); + // Remove hatch from hatch list, data is now invalid. + aOutputHatches.remove(aHatchData); + // Re-add hatch to hatch list, with new data. + Triplet aNewHatchData = new Triplet(aHatch, aNewHatchStack, aNewHatchStack.amount); + aOutputHatches.add(aNewHatchData); + // Check next fluid + continue aFluidMatch; + } + + } + else { + continue aFluidMatch; + } + } + } + } + + for (Triplet aFreeHatchCheck : aOutputHatches) { + // Free Hatch + if (aFreeHatchCheck.getValue_2() == null || aFreeHatchCheck.getValue_3() == 0 || aFreeHatchCheck.getValue_1().getFluid() == null) { + aEmptyFluidHatches++; } } - if (!tCanBufferFluid) return false; + + // We have Fluid Stacks we did not merge. Do we have space? + if (aOutputFluids.size() > 0) { + // Not enough space to add fluids. + if (aOutputFluids.size() < aEmptyFluidHatches) { + Logger.INFO("Failed to find enough space for all fluid outputs."); + return false; + } + } + + /* + * End Fluid Management + */ } + return true; } @@ -534,20 +775,17 @@ GT_MetaTileEntity_MultiBlockBase { public static Method aLogger = null; public void log(String s) { - - boolean isDebugLogging = CORE.DEBUG; - boolean reset = false; - - if (reset) { - if (isDebugLogging) { + boolean reset = true; + if (reset || aLogger == null) { + if (!AsmConfig.disableAllLogging) { aLogger = ReflectionUtils.getMethod( Logger.class, "INFO", String.class - ); + ); } else { aLogger = ReflectionUtils.getMethod( Logger.class, "MACHINE_INFO", String.class - ); + ); } } try { @@ -555,6 +793,7 @@ GT_MetaTileEntity_MultiBlockBase { } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + e.printStackTrace(); } } @@ -741,21 +980,39 @@ GT_MetaTileEntity_MultiBlockBase { int aSpeedBonusPercent, int aOutputChanceRoll, GT_Recipe aRecipe) { // Based on the Processing Array. A bit overkill, but very flexible. + // Reset outputs and progress stats this.mEUt = 0; this.mMaxProgresstime = 0; this.mOutputItems = new ItemStack[]{}; this.mOutputFluids = new FluidStack[]{}; - + + + + // Get input Voltage long tVoltage = getMaxInputVoltage(); - byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + + // Get total Amps available to this multiblock + long tAmpsIn = 0; + for (GT_MetaTileEntity_Hatch_Energy aHatch : this.mEnergyHatches) { + tAmpsIn += aHatch.maxAmperesIn(); + } + + // How much voltage can actually go in + long tEffectiveVoltage = tVoltage * tAmpsIn; + + byte tTierInputVoltage = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tEffectiveVoltage)); log("Running checkRecipeGeneric(0)"); + log("Amps: "+tAmpsIn); + log("Input Voltage: "+tVoltage+", Tier: "+tTierInputVoltage); + log("Effective Voltage: "+tEffectiveVoltage+", Effective Tier: "+tTier); GT_Recipe tRecipe = findRecipe( getBaseMetaTileEntity(), mLastRecipe, false, - gregtech.api.enums.GT_Values.V[tTier], aFluidInputs, aItemInputs); + gregtech.api.enums.GT_Values.V[tTierInputVoltage], aFluidInputs, aItemInputs); log("Running checkRecipeGeneric(1)"); // Remember last recipe - an optimization for findRecipe() @@ -767,7 +1024,8 @@ GT_MetaTileEntity_MultiBlockBase { } if (!this.canBufferOutputs(tRecipe, aMaxParallelRecipes)) { - log("BAD RETURN - 2"); + log("BAD RETURN - 2"); // TODO + Logger.INFO("No Output Space."); return false; } @@ -783,12 +1041,12 @@ GT_MetaTileEntity_MultiBlockBase { log("tVoltage: "+tVoltage); log("tRecipeEUt: "+tRecipeEUt); // Count recipes to do in parallel, consuming input items and fluids and considering input voltage limits - for (; parallelRecipes < aMaxParallelRecipes && tTotalEUt < (tVoltage - tRecipeEUt); parallelRecipes++) { + for (; parallelRecipes < aMaxParallelRecipes && tTotalEUt < (tEffectiveVoltage - tRecipeEUt); parallelRecipes++) { if (!tRecipe.isRecipeInputEqual(true, aFluidInputs, aItemInputs)) { log("Broke at "+parallelRecipes+"."); break; } - log("Bumped EU from "+tTotalEUt+" to "+(tTotalEUt+tRecipeEUt)+"."); + log("Bumped EU from "+tTotalEUt+" to "+(tTotalEUt+tRecipeEUt)+". Can use "+tEffectiveVoltage); tTotalEUt += tRecipeEUt; } @@ -813,10 +1071,10 @@ GT_MetaTileEntity_MultiBlockBase { // Overclock if (this.mEUt <= 16) { - this.mEUt = (this.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); - this.mMaxProgresstime = (this.mMaxProgresstime / (1 << tTier - 1)); + this.mEUt = (this.mEUt * (1 << tTierInputVoltage - 1) * (1 << tTierInputVoltage - 1)); + this.mMaxProgresstime = (this.mMaxProgresstime / (1 << tTierInputVoltage - 1)); } else { - while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { + while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTierInputVoltage - 1)]) { this.mEUt *= 4; this.mMaxProgresstime /= 2; } @@ -1383,36 +1641,36 @@ GT_MetaTileEntity_MultiBlockBase { public boolean causeMaintenanceIssue() { boolean b = false; switch (this.getBaseMetaTileEntity().getRandomNumber(6)) { - case 0 : { - this.mWrench = false; - b = true; - break; - } - case 1 : { - this.mScrewdriver = false; - b = true; - break; - } - case 2 : { - this.mSoftHammer = false; - b = true; - break; - } - case 3 : { - this.mHardHammer = false; - b = true; - break; - } - case 4 : { - this.mSolderingTool = false; - b = true; - break; - } - case 5 : { - this.mCrowbar = false; - b = true; - break; - } + case 0 : { + this.mWrench = false; + b = true; + break; + } + case 1 : { + this.mScrewdriver = false; + b = true; + break; + } + case 2 : { + this.mSoftHammer = false; + b = true; + break; + } + case 3 : { + this.mHardHammer = false; + b = true; + break; + } + case 4 : { + this.mSolderingTool = false; + b = true; + break; + } + case 5 : { + this.mCrowbar = false; + b = true; + break; + } } return b; } @@ -1849,7 +2107,7 @@ GT_MetaTileEntity_MultiBlockBase { @SuppressWarnings("rawtypes") public boolean isThisHatchMultiDynamo(Object aMetaTileEntity){ - Class mDynamoClass; + Class mDynamoClass; mDynamoClass = ReflectionUtils.getClass("com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_DynamoMulti"); if (mDynamoClass != null){ if (mDynamoClass.isInstance(aMetaTileEntity)){ @@ -1894,7 +2152,7 @@ GT_MetaTileEntity_MultiBlockBase { try { return (int) calculatePollutionReduction.invoke(i, g); } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - + } } return 0; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java b/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java index d507b3c814..aad05f1730 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java @@ -36,6 +36,7 @@ import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.material.ELEMENT; import gtPlusPlus.core.util.minecraft.FluidUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.minecraft.LangUtils; import gtPlusPlus.core.util.minecraft.MaterialUtils; import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils; import gtPlusPlus.core.util.reflect.ReflectionUtils; @@ -131,32 +132,84 @@ public class Meta_GT_Proxy { public static void fixIC2FluidNames() { //Fix IC2 Hot Water name try { - String aNewHeatedWaterName = "Heated Water"; - Logger.INFO("Renaming [IC2 Hotspring Water] --> ["+aNewHeatedWaterName+"].");LanguageRegistry.instance().addStringLocalization("fluidHotWater", "Heated Water"); - LanguageRegistry.instance().addStringLocalization("fluidHotWater", aNewHeatedWaterName); - LanguageRegistry.instance().addStringLocalization("ic2.fluidHotWater", aNewHeatedWaterName); - GT_LanguageManager.addStringLocalization("fluidHotWater", aNewHeatedWaterName); - GT_LanguageManager.addStringLocalization("ic2.fluidHotWater", aNewHeatedWaterName); - - Block b = BlocksItems.getFluidBlock(InternalName.fluidHotWater); - if (b != null) { - LanguageRegistry.addName(ItemUtils.getSimpleStack(b), aNewHeatedWaterName); - LanguageRegistry.instance().addStringLocalization(b.getUnlocalizedName(), aNewHeatedWaterName); - GT_LanguageManager.addStringLocalization(b.getUnlocalizedName(), aNewHeatedWaterName); - } - Fluid f = BlocksItems.getFluid(InternalName.fluidHotWater); - if (f != null) { - LanguageRegistry.instance().addStringLocalization(f.getUnlocalizedName(), aNewHeatedWaterName); - GT_LanguageManager.addStringLocalization(f.getUnlocalizedName(), aNewHeatedWaterName); - int aDam = FluidRegistry.getFluidID(f); - ItemStack s = ItemList.Display_Fluid.getWithDamage(1, aDam); - if (s != null) { - LanguageRegistry.addName(s, aNewHeatedWaterName); - } - } + String aNewHeatedWaterName = "Heated Water"; + Logger.INFO("Renaming [IC2 Hotspring Water] --> ["+aNewHeatedWaterName+"].");LanguageRegistry.instance().addStringLocalization("fluidHotWater", "Heated Water"); + LanguageRegistry.instance().addStringLocalization("fluidHotWater", aNewHeatedWaterName); + LanguageRegistry.instance().addStringLocalization("ic2.fluidHotWater", aNewHeatedWaterName); + GT_LanguageManager.addStringLocalization("fluidHotWater", aNewHeatedWaterName); + GT_LanguageManager.addStringLocalization("ic2.fluidHotWater", aNewHeatedWaterName); + + Block b = BlocksItems.getFluidBlock(InternalName.fluidHotWater); + if (b != null) { + LanguageRegistry.addName(ItemUtils.getSimpleStack(b), aNewHeatedWaterName); + LanguageRegistry.instance().addStringLocalization(b.getUnlocalizedName(), aNewHeatedWaterName); + GT_LanguageManager.addStringLocalization(b.getUnlocalizedName(), aNewHeatedWaterName); + } + Fluid f = BlocksItems.getFluid(InternalName.fluidHotWater); + if (f != null) { + LanguageRegistry.instance().addStringLocalization(f.getUnlocalizedName(), aNewHeatedWaterName); + GT_LanguageManager.addStringLocalization(f.getUnlocalizedName(), aNewHeatedWaterName); + int aDam = FluidRegistry.getFluidID(f); + ItemStack s = ItemList.Display_Fluid.getWithDamage(1, aDam); + if (s != null) { + LanguageRegistry.addName(s, aNewHeatedWaterName); + } + } + + String[] aLangs = new String[] { + "de_DE", + "en_US", + "en_GB", + "en_IC", + "es_AR", + "es_ES", + "es_MX", + "es_UY", + "es_VE", + "fr_CA", + "fr_FR", + "it_IT", + "ko_KR", + "pt_BR", + "pt_PT", + "ru_RU", + "sv_SE", + "tr_TR", + "zh_CN", + "zh_TW", + }; + String[] aLangValues = new String[] { + "Erhitztes Wasser", + "Heated Water", + "Heated Water", + "Heated Water", + "Agua caliente", + "Agua caliente", + "Agua caliente", + "Agua caliente", + "Agua caliente", + "Eau chauffée", + "Eau chauffée", + "Acqua riscaldata", + "온수", + "Água aquecida", + "Água aquecida", + "Вода с подогревом", + "Uppvärmt vatten", + "Isıtılmış Su", + "热水", + "热水", + + }; + for (int i=0;i aBaseMetaTileEntity.getEUCapacity() / 3L; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCokeOven.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCokeOven.java index 611cb4da71..b8517533e6 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCokeOven.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCokeOven.java @@ -55,7 +55,7 @@ extends GregtechMeta_MultiBlockBase { "1x Input Bus", "1x Output Bus", "1x Energy Hatch" - }; + }; } @Override @@ -101,7 +101,7 @@ extends GregtechMeta_MultiBlockBase { public boolean checkRecipe(final ItemStack aStack) { return checkRecipeGeneric(getMaxParallelRecipes(), getEuDiscountForParallelism(), 0); } - + @Override public int getMaxParallelRecipes() { return this.mLevel * 12; @@ -118,19 +118,21 @@ extends GregtechMeta_MultiBlockBase { final int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; this.mLevel = 0; if (!aBaseMetaTileEntity.getAirOffset(xDir, 1, zDir)) { + Logger.INFO("No air? "+xDir+", 1, "+zDir); return false; } final byte tUsedMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + 1, 1, zDir); switch (tUsedMeta) { - case 2: - this.mLevel = 1; - break; - case 3: - this.mLevel = 2; - break; - default: - return false; + case 2: + this.mLevel = 1; + break; + case 3: + this.mLevel = 2; + break; + default: + Logger.INFO("Bad Heating Coils."); + return false; } for (int i = -1; i < 2; i++) { for (int j = -1; j < 2; j++) { @@ -140,7 +142,7 @@ extends GregtechMeta_MultiBlockBase { Logger.INFO("Heating Coils missing."); return false; } - + if (!isValidBlockForStructure(tTileEntity2, TAE.GTPP_INDEX(1), true, aBaseMetaTileEntity.getBlockOffset(xDir + i, 2, zDir + j), (int) aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 2, zDir + j), ModBlocks.blockCasingsMisc, 1)) { Logger.INFO("Casings missing from top layer of coke oven."); return false; @@ -158,7 +160,7 @@ extends GregtechMeta_MultiBlockBase { } } } - } + } return true; } -- cgit From 10d4c7d4b4fd651d64f17936a916785b36a43f92 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Sun, 8 Dec 2019 02:00:35 +0000 Subject: + Added an assembly recipe for tier 1 Round Robinators. + Added localization for Rotor Housing achievement. + Added the Algae Farm (WIP). - Removed Durability bar on Iridium Rotors. - Reverted 2A hatch fix on Multiblocks. % Adjusted all Robinator recipes, removing the fluid requirements. $ Fixed Robinators Crashing on Servers. $ Implemented new backend for all future non-GT tile entities. --- .../api/objects/minecraft/CubicObject.java | 62 +++++ .../api/objects/minecraft/SafeTexture.java | 64 +++++ .../core/block/base/BasicTileBlockWithTooltip.java | 309 +++++++++++++++++++++ .../core/block/machine/CircuitProgrammer.java | 111 ++++---- .../core/block/machine/Machine_RoundRobinator.java | 138 ++++----- .../gtPlusPlus/core/handler/COMPAT_HANDLER.java | 1 + .../item/base/itemblock/ItemBlockBasicTile.java | 33 ++- .../item/base/itemblock/ItemBlockBasicTooltip.java | 34 --- .../base/itemblock/ItemBlockRoundRobinator.java | 6 +- src/Java/gtPlusPlus/core/lib/CORE.java | 23 +- .../gtPlusPlus/core/recipe/RECIPES_GREGTECH.java | 6 +- .../gtPlusPlus/core/recipe/RECIPES_Machines.java | 13 +- .../core/util/minecraft/ClientUtils.java | 18 ++ .../xmod/gregtech/api/enums/GregtechItemList.java | 3 + .../base/GregtechMeta_MultiBlockBase.java | 51 ++-- .../algae/GregtechMTE_AlgaePondBase.java | 128 +++++++++ .../gregtech/GregtechAlgaeContent.java | 24 ++ .../xmod/ic2/item/CustomKineticRotor.java | 274 ++++++++++++++++++ src/Java/gtPlusPlus/xmod/ic2/item/IC2_Items.java | 68 ++--- .../gtPlusPlus/xmod/ic2/item/RotorIridium.java | 5 + src/resources/assets/gregtech/lang/en_US.lang | 4 +- .../RoundRobinator/RoundRobinator_Side_0.png | Bin 1448 -> 0 bytes .../RoundRobinator/RoundRobinator_Side_1.png | Bin 1444 -> 0 bytes .../RoundRobinator/RoundRobinator_Side_2.png | Bin 1446 -> 0 bytes .../RoundRobinator/RoundRobinator_Side_3.png | Bin 1446 -> 0 bytes .../RoundRobinator/RoundRobinator_Side_4.png | Bin 1443 -> 0 bytes .../RoundRobinator/RoundRobinator_Top_0.png | Bin 1405 -> 0 bytes .../RoundRobinator/RoundRobinator_Top_1.png | Bin 1403 -> 0 bytes .../RoundRobinator/RoundRobinator_Top_2.png | Bin 1403 -> 0 bytes .../RoundRobinator/RoundRobinator_Top_3.png | Bin 1402 -> 0 bytes .../RoundRobinator/RoundRobinator_Top_4.png | Bin 1400 -> 0 bytes .../blocks/TileEntities/RoundRobinator/Side_0.png | Bin 0 -> 1448 bytes .../blocks/TileEntities/RoundRobinator/Side_1.png | Bin 0 -> 1444 bytes .../blocks/TileEntities/RoundRobinator/Side_2.png | Bin 0 -> 1446 bytes .../blocks/TileEntities/RoundRobinator/Side_3.png | Bin 0 -> 1446 bytes .../blocks/TileEntities/RoundRobinator/Side_4.png | Bin 0 -> 1443 bytes .../blocks/TileEntities/RoundRobinator/Top_0.png | Bin 0 -> 1405 bytes .../blocks/TileEntities/RoundRobinator/Top_1.png | Bin 0 -> 1403 bytes .../blocks/TileEntities/RoundRobinator/Top_2.png | Bin 0 -> 1403 bytes .../blocks/TileEntities/RoundRobinator/Top_3.png | Bin 0 -> 1402 bytes .../blocks/TileEntities/RoundRobinator/Top_4.png | Bin 0 -> 1400 bytes 41 files changed, 1096 insertions(+), 279 deletions(-) create mode 100644 src/Java/gtPlusPlus/api/objects/minecraft/CubicObject.java create mode 100644 src/Java/gtPlusPlus/api/objects/minecraft/SafeTexture.java create mode 100644 src/Java/gtPlusPlus/core/block/base/BasicTileBlockWithTooltip.java delete mode 100644 src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockBasicTooltip.java create mode 100644 src/Java/gtPlusPlus/core/util/minecraft/ClientUtils.java create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/algae/GregtechMTE_AlgaePondBase.java create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechAlgaeContent.java create mode 100644 src/Java/gtPlusPlus/xmod/ic2/item/CustomKineticRotor.java delete mode 100644 src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Side_0.png delete mode 100644 src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Side_1.png delete mode 100644 src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Side_2.png delete mode 100644 src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Side_3.png delete mode 100644 src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Side_4.png delete mode 100644 src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Top_0.png delete mode 100644 src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Top_1.png delete mode 100644 src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Top_2.png delete mode 100644 src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Top_3.png delete mode 100644 src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Top_4.png create mode 100644 src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/Side_0.png create mode 100644 src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/Side_1.png create mode 100644 src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/Side_2.png create mode 100644 src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/Side_3.png create mode 100644 src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/Side_4.png create mode 100644 src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/Top_0.png create mode 100644 src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/Top_1.png create mode 100644 src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/Top_2.png create mode 100644 src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/Top_3.png create mode 100644 src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/Top_4.png (limited to 'src/Java/gtPlusPlus/api/objects') diff --git a/src/Java/gtPlusPlus/api/objects/minecraft/CubicObject.java b/src/Java/gtPlusPlus/api/objects/minecraft/CubicObject.java new file mode 100644 index 0000000000..8c76513d09 --- /dev/null +++ b/src/Java/gtPlusPlus/api/objects/minecraft/CubicObject.java @@ -0,0 +1,62 @@ +package gtPlusPlus.api.objects.minecraft; + +import gtPlusPlus.api.objects.data.AutoMap; +import net.minecraftforge.common.util.ForgeDirection; + +public class CubicObject { + + public final T NORTH; + public final T SOUTH; + + public final T WEST; + public final T EAST; + + public final T UP; + public final T DOWN; + + public CubicObject(AutoMap aDataSet) { + this(aDataSet.get(0), aDataSet.get(1), aDataSet.get(2), aDataSet.get(3), aDataSet.get(4), aDataSet.get(5)); + } + + public CubicObject(T[] aDataSet) { + this(aDataSet[0], aDataSet[1], aDataSet[2], aDataSet[3], aDataSet[4], aDataSet[5]); + } + + public CubicObject(T aDOWN, T aUP, T aNORTH, T aSOUTH, T aWEST, T aEAST) { + DOWN = aDOWN; + UP = aUP; + NORTH = aNORTH; + SOUTH = aSOUTH; + WEST = aWEST; + EAST = aEAST; + } + + public T get(int aSide) { + return get(ForgeDirection.getOrientation(aSide)); + } + + public T get(ForgeDirection aSide) { + if (aSide == ForgeDirection.DOWN) { + return DOWN; + } + else if (aSide == ForgeDirection.UP) { + return UP; + } + else if (aSide == ForgeDirection.NORTH) { + return NORTH; + } + else if (aSide == ForgeDirection.SOUTH) { + return SOUTH; + } + else if (aSide == ForgeDirection.WEST) { + return WEST; + } + else if (aSide == ForgeDirection.EAST) { + return EAST; + } + else { + return null; + } + } + +} diff --git a/src/Java/gtPlusPlus/api/objects/minecraft/SafeTexture.java b/src/Java/gtPlusPlus/api/objects/minecraft/SafeTexture.java new file mode 100644 index 0000000000..7c418b5a77 --- /dev/null +++ b/src/Java/gtPlusPlus/api/objects/minecraft/SafeTexture.java @@ -0,0 +1,64 @@ +package gtPlusPlus.api.objects.minecraft; + +import java.util.HashMap; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.GregTech_API; +import gtPlusPlus.core.util.Utils; +import net.minecraft.util.IIcon; + +/** + * A Server Side safe object that can hold {@link IIcon}s. + * @author Alkalus + * + */ +public class SafeTexture implements Runnable { + + @SideOnly(Side.CLIENT) + private static final HashMap mHashToIconCache = new HashMap(); + + @SideOnly(Side.CLIENT) + private static final HashMap mPathToHashCash = new HashMap(); + + private static final HashMap mTextureObjectCache = new HashMap(); + + private final int mHash; + + private final String mTextureName; + + private final static String getKey(String aTexPath) { + String aNameKey = Utils.sanitizeString(aTexPath); + aNameKey = aNameKey.replace('/', ' '); + aNameKey = aNameKey.toLowerCase(); + return aNameKey; + } + + public static SafeTexture register(String aTexturePath) { + String aNameKey = getKey(aTexturePath); + SafeTexture g = mTextureObjectCache.get(aNameKey); + if (g == null) { + g = new SafeTexture(aTexturePath); + mTextureObjectCache.put(aNameKey, g); + mPathToHashCash.put(aTexturePath, aTexturePath.hashCode()); + } + return g; + } + + private SafeTexture(String aTexturePath) { + mTextureName = aTexturePath; + mHash = getKey(aTexturePath).hashCode(); + GregTech_API.sGTBlockIconload.add(this); + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon() { + return mHashToIconCache.get(mHash); + } + + @Override + public void run() { + mHashToIconCache.put(getKey(mTextureName).hashCode(), GregTech_API.sBlockIcons.registerIcon(mTextureName)); + } + +} diff --git a/src/Java/gtPlusPlus/core/block/base/BasicTileBlockWithTooltip.java b/src/Java/gtPlusPlus/core/block/base/BasicTileBlockWithTooltip.java new file mode 100644 index 0000000000..098b670509 --- /dev/null +++ b/src/Java/gtPlusPlus/core/block/base/BasicTileBlockWithTooltip.java @@ -0,0 +1,309 @@ +package gtPlusPlus.core.block.base; + +import java.util.List; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.api.interfaces.ITileTooltip; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.api.objects.minecraft.CubicObject; +import gtPlusPlus.api.objects.minecraft.SafeTexture; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.minecraft.InventoryUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import net.minecraft.block.Block; +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.item.Item; +import net.minecraft.item.ItemBlock; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public abstract class BasicTileBlockWithTooltip extends BlockContainer implements ITileTooltip { + + /** + * Each mapped object holds the data for the six sides. + */ + @SideOnly(Side.CLIENT) + private AutoMap> mSidedTextureArray = new AutoMap>(); + + /** + * Holds the data for the six sides, each side holds an array of data for each respective meta. + */ + @SideOnly(Side.CLIENT) + private AutoMap> mSidedTexturePathArray = new AutoMap>(); + + /** + * Does this block have any meta at all? + * @return + */ + public final boolean hasMeta() { + return getMetaCount() > 0; + } + + /** + * The amount of meta this block has. + * @return + */ + public abstract int getMetaCount(); + + /** + * Does this {@link Block} require special {@link ItemBlock} handling? + * @return The {@link Class} that will be used for this {@link Block}. + */ + public Class getItemBlockClass() { + return ItemBlock.class; + } + + /** + * A lazy way to declare the unlocal name for the block, makes boilerplating easy. + * @return The internal name for this block. + */ + public abstract String getUnlocalBlockName(); + + /** + * Does this Block have {@link ITileTooltip} support? + * @return {@link boolean} that represents if this block supports {@link ITileTooltip} or not. + */ + public final boolean hasTooltip() { + return getTooltipID() >= -1; + } + + /** + * Lazy Boilerplating. + * @return Block Hardness. + */ + protected abstract float initBlockHardness(); + + /** + * Lazy Boilerplating. + * @return Block Resistance. + */ + protected abstract float initBlockResistance(); + + /** + * Lazy Boilerplating. + * @return The {@link CreativeTab} this Block is shown on. + */ + protected abstract CreativeTabs initCreativeTab(); + + /** + * The ID used by the {@link ITileTooltip} handler. Return -1 if you are not providing a custom {@link ItemBlock} in {@link #getItemBlockClass}(). + * @return + */ + @Override + public abstract int getTooltipID(); + + public BasicTileBlockWithTooltip(Material aBlockMat){ + super(aBlockMat); + //Use Abstract method values + this.setHardness(initBlockHardness()); + this.setResistance(initBlockResistance()); + this.setBlockName(getUnlocalBlockName()); + this.setCreativeTab(initCreativeTab()); + // Register the block last. + GameRegistry.registerBlock(this, getItemBlockClass(), getUnlocalBlockName()); + Logger.INFO("Registered "+getTileEntityName()+"."); + if (Utils.isClient()) { + // Handle Textures + handleTextures(); + } + } + + /** + * The name of the Tile Entity. + * @return + */ + protected abstract String getTileEntityName(); + + /** + * The String used for texture pathing. + * @return Sanitized {@link String}, containing no spaces or illegal characters. + */ + private final String getTileEntityNameForTexturePathing() { + return Utils.sanitizeString(getTileEntityName().replace(" ", "")); + } + + /** + * An array of CubicObjects, one for each meta, else just a single cell array. + * Expected to be null regularly, as the default texture handling should suffice. + * Handy if re-using textures or using a non-standard structure for them. FULL texture path must be used, + * inclusive of the MODID and a colon. + * @return + */ + public CubicObject[] getCustomTextureDirectoryObject(){ + return null; + } + + @Override + @SideOnly(Side.CLIENT) + public final IIcon getIcon(final int aSide, final int aMeta) { + return mSidedTextureArray.get(aMeta).get(aSide).getIcon(); + } + + @Override + public IIcon getIcon(IBlockAccess aWorld, int aX, int aY, int aZ, int aSide) { + return super.getIcon(aWorld, aX, aY, aZ, aSide); + } + + @SideOnly(Side.CLIENT) + private final void handleTextures() { + + Logger.INFO("[TeTexture] Building Texture Maps for "+getTileEntityName()+"."); + //Store them in forge order + //DOWN, UP, NORTH, SOUTH, WEST, EAST + + // Default Path Name, this will make us look inside 'miscutils\textures\blocks' + final String aPrefixTexPath = CORE.MODID + ":"; + // Default Path Name, this will make us look in the sub-directory for this Tile Entity. + final String aTexPathMid = "TileEntities"+CORE.SEPERATOR+getTileEntityNameForTexturePathing()+CORE.SEPERATOR; + // Construct a full path + String aTexPathBuilt = aPrefixTexPath + aTexPathMid; + // File Name Suffixes, without meta tags + String aStringBot; + String aStringTop; + String aStringBack; + String aStringFront; + String aStringLeft; + String aStringRight; + // Do we provide a matrix of custom data to be used for texture processing instead? + if (getCustomTextureDirectoryObject() != null) { + // Get custom provided texture data. + CubicObject[] aDataMap = getCustomTextureDirectoryObject(); + Logger.INFO("[TeTexture] Found custom texture data, using this instead. Size: "+aDataMap.length); + // Map each meta string data to the main map. + for (int i=0;i aMetaBlob = new CubicObject(aStringBot, aStringTop, aStringBack, aStringFront, aStringLeft, aStringRight); + mSidedTexturePathArray.put(aMetaBlob); + Logger.INFO("[TeTexture] Added Texture Path data to map for meta "+i); + } + } + Logger.INFO("[TeTexture] Map size for pathing: "+mSidedTexturePathArray.size()); + + // Iteration Index + int aIndex = 0; + + // Iterate each CubicObject, holding the six texture paths for each meta. + for (CubicObject aMetaBlob : mSidedTexturePathArray) { + // Make a Safe Texture for each side + SafeTexture aBottom = SafeTexture.register(aMetaBlob.DOWN); + SafeTexture aTop = SafeTexture.register(aMetaBlob.UP); + SafeTexture aBack = SafeTexture.register(aMetaBlob.NORTH); + SafeTexture aFont = SafeTexture.register(aMetaBlob.SOUTH); + SafeTexture aWest = SafeTexture.register(aMetaBlob.WEST); + SafeTexture aEast = SafeTexture.register(aMetaBlob.EAST); + // Store them in an Array + SafeTexture[] aInjectBlob = new SafeTexture[] { + aBottom, + aTop, + aBack, + aFont, + aWest, + aEast + }; + // Convenience Blob + CubicObject aMetaBlob2 = new CubicObject(aInjectBlob); + // Store this Blob into + mSidedTextureArray.put(aMetaBlob2); + Logger.INFO("[TeTexture] Added SafeTexture data to map for meta "+(aIndex++)); + } + Logger.INFO("[TeTexture] Map size for registration: "+mSidedTextureArray.size()); + + + } + + @Override + @SideOnly(Side.CLIENT) + public final void registerBlockIcons(final IIconRegister aRegisterer){ + this.blockIcon = aRegisterer.registerIcon(CORE.MODID + ":" + "net"); + } + + @Override + public abstract TileEntity createNewTileEntity(final World world, final int p_149915_2_); + + /** + * Called when {@link #breakBlock}() is called, but before {@link InventoryUtils#dropInventoryItems} and the super call. + */ + public void onBlockBreak() { + + } + + @Override + public final void breakBlock(final World world, final int x, final int y, final int z, final Block block, final int number) { + onBlockBreak(); + InventoryUtils.dropInventoryItems(world, x, y, z, block); + super.breakBlock(world, x, y, z, block, number); + } + + @SuppressWarnings({"unchecked", "rawtypes"}) + @Override + public final void getSubBlocks(Item aItem, CreativeTabs p_149666_2_, List aList) { + if (hasMeta()) { + for (int i=0;i[] getCustomTextureDirectoryObject() { + String[] aTexData = new String[] { + CORE.MODID + ":" + "metro/" + "TEXTURE_METAL_PANEL_G", + CORE.MODID + ":" + "metro/" + "TEXTURE_TECH_PANEL_B", + CORE.MODID + ":" + "metro/" + "TEXTURE_METAL_PANEL_I", + CORE.MODID + ":" + "metro/" + "TEXTURE_METAL_PANEL_I", + CORE.MODID + ":" + "metro/" + "TEXTURE_METAL_PANEL_I", + CORE.MODID + ":" + "metro/" + "TEXTURE_METAL_PANEL_I" + }; + CubicObject[] aTextureData = new CubicObject[] {new CubicObject(aTexData)}; + return aTextureData; + } + } \ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/block/machine/Machine_RoundRobinator.java b/src/Java/gtPlusPlus/core/block/machine/Machine_RoundRobinator.java index cd480dcffe..dc87b885b9 100644 --- a/src/Java/gtPlusPlus/core/block/machine/Machine_RoundRobinator.java +++ b/src/Java/gtPlusPlus/core/block/machine/Machine_RoundRobinator.java @@ -1,85 +1,27 @@ package gtPlusPlus.core.block.machine; -import java.util.List; - -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import gregtech.common.items.GT_MetaGenerated_Tool_01; -import gtPlusPlus.api.interfaces.ITileTooltip; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.api.objects.minecraft.CubicObject; +import gtPlusPlus.core.block.base.BasicTileBlockWithTooltip; import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.item.base.itemblock.ItemBlockRoundRobinator; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.tileentities.machines.TileEntityRoundRobinator; -import gtPlusPlus.core.util.minecraft.InventoryUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.minecraft.PlayerUtils; -import net.minecraft.block.Block; -import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; -import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.EnumCreatureType; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; +import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.IIcon; -import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -public class Machine_RoundRobinator extends BlockContainer implements ITileTooltip -{ - @SideOnly(Side.CLIENT) - private IIcon[] textureTop = new IIcon[5]; - @SideOnly(Side.CLIENT) - private IIcon[] textureFront = new IIcon[5]; +public class Machine_RoundRobinator extends BasicTileBlockWithTooltip { + - /** - * Determines which tooltip is displayed within the itemblock. - */ - private final int mTooltipID = 7; - - @Override - public int getTooltipID() { - return this.mTooltipID; - } - - @SuppressWarnings("deprecation") public Machine_RoundRobinator(){ super(Material.iron); - this.setHardness(1f); - this.setResistance(1f); - this.setBlockName("blockRoundRobinator"); - this.setCreativeTab(AddToCreativeTab.tabMachines); - GameRegistry.registerBlock(this, ItemBlockRoundRobinator.class, "blockRoundRobinator"); - //LanguageRegistry.addName(this, "Round-Robinator"); - - } - - /** - * Gets the block's texture. Args: side, meta - */ - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(final int aSide, final int aMeta) { - if (aSide < 2) { - return this.textureTop[aMeta]; - } - else { - return this.textureFront[aMeta]; - } - } - - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(final IIconRegister p_149651_1_){ - this.blockIcon = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "RoundRobinator_Side"); - for (int i=0;i<5;i++) { - this.textureTop[i] = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/RoundRobinator/" + "RoundRobinator_Top_"+i); - this.textureFront[i] = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/RoundRobinator/" + "RoundRobinator_Side_"+i); - } } /** @@ -97,13 +39,11 @@ public class Machine_RoundRobinator extends BlockContainer implements ITileToolt // Check For Screwdriver try { final ItemStack mHandStack = PlayerUtils.getItemStackInPlayersHand(world, player.getDisplayName()); - final Item mHandItem = mHandStack.getItem(); - if (((mHandItem instanceof GT_MetaGenerated_Tool_01) - && ((mHandItem.getDamage(mHandStack) == 22) || (mHandItem.getDamage(mHandStack) == 150)))) { + if (ItemUtils.isToolScrewdriver(mHandStack)) { final TileEntityRoundRobinator tile = (TileEntityRoundRobinator) world.getTileEntity(x, y, z); if (tile != null) { mDidScrewDriver = tile.onScrewdriverRightClick((byte) side, player, x, y, z); - } + } } } catch (final Throwable t) {} @@ -122,52 +62,70 @@ public class Machine_RoundRobinator extends BlockContainer implements ITileToolt } @Override - public int getRenderBlockPass() { - return 0; + public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { + return new TileEntityRoundRobinator(); } @Override - public boolean isOpaqueCube() { - return false; + public int getMetaCount() { + return 5; } @Override - public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { - return new TileEntityRoundRobinator(); + public String getUnlocalBlockName() { + return "blockRoundRobinator"; } @Override - public void onBlockAdded(final World world, final int x, final int y, final int z) { - super.onBlockAdded(world, x, y, z); + protected float initBlockHardness() { + return 1; } @Override - public void breakBlock(final World world, final int x, final int y, final int z, final Block block, final int number) { - InventoryUtils.dropInventoryItems(world, x, y, z, block); - super.breakBlock(world, x, y, z, block, number); + protected float initBlockResistance() { + return 1; } @Override - public void onBlockPlacedBy(final World world, final int x, final int y, final int z, final EntityLivingBase entity, final ItemStack stack) { - super.onBlockPlacedBy(world, x, y, z, entity, stack); + protected CreativeTabs initCreativeTab() { + return AddToCreativeTab.tabMachines; } @Override - public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { - return false; + public int getTooltipID() { + return -1; } @Override - public void getSubBlocks(Item aItem, CreativeTabs p_149666_2_, List aList) { - //super.getSubBlocks(aItem, p_149666_2_, aList); - for (int i=0;i<5;i++) { - aList.add(ItemUtils.simpleMetaStack(aItem, i, 1)); - } + protected String getTileEntityName() { + return "Round Robinator"; + } + + @Override + public Class getItemBlockClass() { + return ItemBlockRoundRobinator.class; } @Override - public IIcon getIcon(IBlockAccess aBlockAccess, int x, int y, int z, int aSide) { - return super.getIcon(aBlockAccess, x, y, z, aSide); + public CubicObject[] getCustomTextureDirectoryObject() { + AutoMap aTemp = new AutoMap(); + for (int i=0;i<5;i++) { + String[] aTexData = new String[] { + CORE.MODID + ":" + "TileEntities/RoundRobinator/Top_"+i, + CORE.MODID + ":" + "TileEntities/RoundRobinator/Top_"+i, + CORE.MODID + ":" + "TileEntities/RoundRobinator/Side_"+i, + CORE.MODID + ":" + "TileEntities/RoundRobinator/Side_"+i, + CORE.MODID + ":" + "TileEntities/RoundRobinator/Side_"+i, + CORE.MODID + ":" + "TileEntities/RoundRobinator/Side_"+i, + }; + aTemp.put(aTexData); + } + AutoMap> aTemp2 = new AutoMap>(); + for (String[] y : aTemp) { + aTemp2.put(new CubicObject(y)); + } + CubicObject[] aTextureData = new CubicObject[] {aTemp2.get(0), aTemp2.get(1), aTemp2.get(2), aTemp2.get(3), aTemp2.get(4)}; + return aTextureData; } } \ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java b/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java index 0b1078366a..ca62a524c1 100644 --- a/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java +++ b/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java @@ -136,6 +136,7 @@ public class COMPAT_HANDLER { GregtechLargeTurbinesAndHeatExchanger.run(); GregtechPowerBreakers.run(); GregtechFluidReactor.run(); + GregtechAlgaeContent.run(); //New Horizons Content NewHorizonsAccelerator.run(); diff --git a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockBasicTile.java b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockBasicTile.java index 42890ddfa6..251230932c 100644 --- a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockBasicTile.java +++ b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockBasicTile.java @@ -26,28 +26,43 @@ public class ItemBlockBasicTile extends ItemBlock { list.add("Can also be placed beside upto 4 other fish traps"); list.add("Requires at least two faces touching water"); list.add("1/1000 chance to produce triple loot."); - } else if (this.mID == 1) { // Modularity + } + else if (this.mID == 1) { // Modularity list.add("Used to construct modular armour & bauble upgrades.."); - } else if (this.mID == 2) { // Trade + } + else if (this.mID == 2) { // Trade list.add("Allows for SMP trade-o-mat type trading."); - } else if (this.mID == 3) { // Project + } + else if (this.mID == 3) { // Project list.add("Scan any crafting recipe in this to mass fabricate them in the Autocrafter.."); - } else if (this.mID == 4) { // Circuit Table + } + else if (this.mID == 4) { // Circuit Table list.add("Easy Circuit Configuration"); list.add("Change default setting with a Screwdriver"); list.add("Default is used to select slot for auto-insertion"); - } else if (this.mID == 5) { // Decayables Chest + } + else if (this.mID == 5) { // Decayables Chest list.add("Chest which holds radioactive materials"); list.add("Items which decay will tick while inside"); list.add("Place with right click"); - } else if (this.mID == 6) { // Butterfly Killer + } + else if (this.mID == 6) { // Butterfly Killer list.add("Kills Forestry Butterflies, Bats and other pests"); list.add("Use either Formaldehyde or Hydrogen cyanide"); list.add("Be weary of your neighbours"); - } else if (this.mID == 7) { - } else { - list.add("Bad Tooltip ID - " + mID); + } + else if (this.mID == 7) { + } + else if (this.mID == 8){ + + } + else if (this.mID == 9){ + + } + + else { + list.add("Bad Tooltip ID - " + mID); } super.addInformation(stack, aPlayer, list, bool); } diff --git a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockBasicTooltip.java b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockBasicTooltip.java deleted file mode 100644 index 9badd384d8..0000000000 --- a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockBasicTooltip.java +++ /dev/null @@ -1,34 +0,0 @@ -package gtPlusPlus.core.item.base.itemblock; - -import java.util.List; - -import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; - -import gtPlusPlus.api.interfaces.ITileTooltip; - -public class ItemBlockBasicTooltip extends ItemBlock{ - - protected final int mID; - - public ItemBlockBasicTooltip(final Block block) { - super(block); - this.mID = ((ITileTooltip) block).getTooltipID(); - } - - - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { - if (this.mID == 0){ //blockDarkWorldPortalFrame - list.add("Assembled in the same shape as the Nether Portal."); - } - else if (this.mID == 1){ //Modularity - list.add("Used to construct modular armour & bauble upgrades.."); - } - } - - -} diff --git a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockRoundRobinator.java b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockRoundRobinator.java index f586695eb7..2d0fd00dd9 100644 --- a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockRoundRobinator.java +++ b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockRoundRobinator.java @@ -16,8 +16,6 @@ public class ItemBlockRoundRobinator extends ItemBlockWithMetadata public ItemBlockRoundRobinator(final Block aBlock){ super(aBlock, aBlock); this.mBlock = aBlock; - this.setMaxDamage(4); - this.setHasSubtypes(true); } @@ -40,7 +38,7 @@ public class ItemBlockRoundRobinator extends ItemBlockWithMetadata else if (stack.getItemDamage() == 4) { list.add("1 Item per enabled side every tick"); } - list.add("Top and bottom do not pull, so you must push item in"); + list.add("Top and bottom do not pull, so you must push items in"); list.add("Sides can also be disabled with a screwdriver"); list.add("Shift+RMB with empty hand to view inventory contents"); super.addInformation(stack, aPlayer, list, bool); @@ -62,7 +60,7 @@ public class ItemBlockRoundRobinator extends ItemBlockWithMetadata @Override public int getMetadata(final int p_77647_1_) { - return super.getMetadata(p_77647_1_); + return p_77647_1_; } @Override diff --git a/src/Java/gtPlusPlus/core/lib/CORE.java b/src/Java/gtPlusPlus/core/lib/CORE.java index 04f1861cfe..3330ad8c3f 100644 --- a/src/Java/gtPlusPlus/core/lib/CORE.java +++ b/src/Java/gtPlusPlus/core/lib/CORE.java @@ -5,10 +5,13 @@ import java.util.concurrent.ConcurrentHashMap; import com.mojang.authlib.GameProfile; +import cpw.mods.fml.common.FMLCommonHandler; import gregtech.api.GregTech_API; +import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.Pair; import gtPlusPlus.api.objects.random.XSTR; import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.core.util.sys.GeoUtils; import gtPlusPlus.core.util.sys.NetworkUtils; import gtPlusPlus.preloader.CORE_Preloader; @@ -52,7 +55,7 @@ public class CORE { public static final String name = "GT++"; public static final String MODID = "miscutils"; - public static final String VERSION = "1.7.03.01"; + public static final String VERSION = "1.7.03.45"; public static String MASTER_VERSION = NetworkUtils.getContentFromURL("https://raw.githubusercontent.com/draknyte1/GTplusplus/master/Recommended.txt").toLowerCase(); public static String USER_COUNTRY = GeoUtils.determineUsersCountry(); public static boolean isModUpToDate = Utils.isModUpToDate(); @@ -76,7 +79,7 @@ public class CORE { public static int turbineCutoffBase = 75000; //GT++ Fake Player Profile - public static GameProfile gameProfile = new GameProfile(UUID.nameUUIDFromBytes("gtplusplus.core".getBytes()), "[GT++]"); + public static final GameProfile gameProfile = new GameProfile(UUID.nameUUIDFromBytes("gtplusplus.core".getBytes()), "[GT++]"); public static final WeakHashMap fakePlayerCache = new WeakHashMap(); //Tooltips; public static final String GT_Tooltip = "Added by: " + EnumChatFormatting.DARK_GREEN+"Alkalus "+EnumChatFormatting.GRAY+"- "+EnumChatFormatting.RED+"[GT++]"; @@ -88,6 +91,7 @@ public class CORE { //Because I want to be lazy. Beyond Reality Classic Var. public static boolean BRC = false; + public static final String SEPERATOR = "/"; /** @@ -286,7 +290,20 @@ public class CORE { } public static final void crash() { - System.exit(0); + Logger.ERROR("=========================================================="); + Logger.ERROR("[GT++ CRASH]"); + Logger.ERROR("=========================================================="); + Logger.ERROR("Oooops..."); + Logger.ERROR("This should only happy in a development environment or when something really bad happens."); + Logger.ERROR("=========================================================="); + Logger.ERROR("Called from: "+ReflectionUtils.getMethodName(0)); + Logger.ERROR(ReflectionUtils.getMethodName(1)); + Logger.ERROR(ReflectionUtils.getMethodName(2)); + Logger.ERROR(ReflectionUtils.getMethodName(3)); + Logger.ERROR(ReflectionUtils.getMethodName(4)); + Logger.ERROR(ReflectionUtils.getMethodName(5)); + Logger.ERROR(ReflectionUtils.getMethodName(6)); + FMLCommonHandler.instance().exitJava(0, true); } public static final void gc() { diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java index ea7f5e4ef7..cac54cec4e 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java @@ -1584,10 +1584,10 @@ public class RECIPES_GREGTECH { // Supreme Pizza Gloves CORE.RA.addSixSlotAssemblingRecipe(new ItemStack[] { - ItemUtils.getGregtechCircuit(17), - ItemUtils.getSimpleStack(ModItems.itemRope, 16), + ItemUtils.getGregtechCircuit(19), + ItemUtils.getSimpleStack(ModItems.itemRope, GTNH ? 32 : 16), ItemUtils.getItemStackOfAmountFromOreDict("gearGtSmallWroughtIron", GTNH ? 8 : 4), - ItemUtils.getItemStackOfAmountFromOreDict("wireFineTin", GTNH ? 32 : 16), + ItemUtils.getItemStackOfAmountFromOreDict("wireFineCopper", GTNH ? 32 : 16), ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(1), GTNH ? 2 : 1) }, FluidUtils.getFluidStack("molten.rubber", 2000), diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java index c0a4a998e8..f5bd390aee 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java @@ -2331,6 +2331,17 @@ public class RECIPES_Machines { for (int i = 0; i < 5; i++) { if (i == 0) { + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + CI.getNumberedCircuit(17), + CI.getTieredMachineCasing(0), + ItemUtils.getSimpleStack(Blocks.hopper, 4), + CI.getTieredComponent(OrePrefixes.circuit, 0, 2) + }, + GT_Values.NF, //Input Fluid + aRobinators[i], + 45 * 10 * 1, + 8); continue; } int aTier = i+1; @@ -2345,7 +2356,7 @@ public class RECIPES_Machines { CORE.RA.addSixSlotAssemblingRecipe( aInputs, - CI.getAlternativeTieredFluid(aTier, (144 * 2 * i)), //Input Fluid + GT_Values.NF, //Input Fluid aRobinators[i], 45 * 10 * 1 * (i+1), MaterialUtils.getVoltageForTier(i)); diff --git a/src/Java/gtPlusPlus/core/util/minecraft/ClientUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/ClientUtils.java new file mode 100644 index 0000000000..806f83d830 --- /dev/null +++ b/src/Java/gtPlusPlus/core/util/minecraft/ClientUtils.java @@ -0,0 +1,18 @@ +package gtPlusPlus.core.util.minecraft; + +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.relauncher.Side; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; + +public class ClientUtils { + + static { + if (FMLCommonHandler.instance().getSide() == Side.SERVER) { + Logger.ERROR("Something tried to access the ClientUtils class from the Server Side."); + Logger.ERROR("Soft crashing to prevent data corruption."); + CORE.crash(); + } + } + +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java index 3ea2851a85..3fc6d9d667 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java @@ -228,6 +228,9 @@ public enum GregtechItemList implements GregtechItemContainer { //Fish Pond Industrial_FishingPond, Casing_FishPond, + + //Algae + AlgaeFarm_Controller, //GT4 autoCrafter diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java index e5d7f58dc6..ece8dfaa87 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java @@ -474,7 +474,7 @@ GT_MetaTileEntity_MultiBlockBase { public boolean canBufferOutputs(final GT_Recipe aRecipe, int aParallelRecipes) { Logger.INFO("Determining if we have space to buffer outputs."); - + // Null recipe or a recipe with lots of outputs? // E.G. Gendustry custom comb with a billion centrifuge outputs? // Do it anyway. @@ -736,7 +736,7 @@ GT_MetaTileEntity_MultiBlockBase { // Check next fluid continue aFluidMatch; } - + } else { continue aFluidMatch; @@ -744,14 +744,14 @@ GT_MetaTileEntity_MultiBlockBase { } } } - + for (Triplet aFreeHatchCheck : aOutputHatches) { // Free Hatch if (aFreeHatchCheck.getValue_2() == null || aFreeHatchCheck.getValue_3() == 0 || aFreeHatchCheck.getValue_1().getFluid() == null) { aEmptyFluidHatches++; } } - + // We have Fluid Stacks we did not merge. Do we have space? if (aOutputFluids.size() > 0) { // Not enough space to add fluids. @@ -760,7 +760,7 @@ GT_MetaTileEntity_MultiBlockBase { return false; } } - + /* * End Fluid Management */ @@ -978,41 +978,22 @@ GT_MetaTileEntity_MultiBlockBase { ItemStack[] aItemInputs, FluidStack[] aFluidInputs, int aMaxParallelRecipes, int aEUPercent, int aSpeedBonusPercent, int aOutputChanceRoll, GT_Recipe aRecipe) { - // Based on the Processing Array. A bit overkill, but very flexible. - - + // Based on the Processing Array. A bit overkill, but very flexible. // Reset outputs and progress stats this.mEUt = 0; this.mMaxProgresstime = 0; this.mOutputItems = new ItemStack[]{}; this.mOutputFluids = new FluidStack[]{}; - - - - // Get input Voltage + long tVoltage = getMaxInputVoltage(); - - // Get total Amps available to this multiblock - long tAmpsIn = 0; - for (GT_MetaTileEntity_Hatch_Energy aHatch : this.mEnergyHatches) { - tAmpsIn += aHatch.maxAmperesIn(); - } - - // How much voltage can actually go in - long tEffectiveVoltage = tVoltage * tAmpsIn; - - byte tTierInputVoltage = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - byte tTier = (byte) Math.max(1, GT_Utility.getTier(tEffectiveVoltage)); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); log("Running checkRecipeGeneric(0)"); - log("Amps: "+tAmpsIn); - log("Input Voltage: "+tVoltage+", Tier: "+tTierInputVoltage); - log("Effective Voltage: "+tEffectiveVoltage+", Effective Tier: "+tTier); GT_Recipe tRecipe = findRecipe( getBaseMetaTileEntity(), mLastRecipe, false, - gregtech.api.enums.GT_Values.V[tTierInputVoltage], aFluidInputs, aItemInputs); + gregtech.api.enums.GT_Values.V[tTier], aFluidInputs, aItemInputs); log("Running checkRecipeGeneric(1)"); // Remember last recipe - an optimization for findRecipe() @@ -1024,8 +1005,7 @@ GT_MetaTileEntity_MultiBlockBase { } if (!this.canBufferOutputs(tRecipe, aMaxParallelRecipes)) { - log("BAD RETURN - 2"); // TODO - Logger.INFO("No Output Space."); + log("BAD RETURN - 2"); return false; } @@ -1041,12 +1021,12 @@ GT_MetaTileEntity_MultiBlockBase { log("tVoltage: "+tVoltage); log("tRecipeEUt: "+tRecipeEUt); // Count recipes to do in parallel, consuming input items and fluids and considering input voltage limits - for (; parallelRecipes < aMaxParallelRecipes && tTotalEUt < (tEffectiveVoltage - tRecipeEUt); parallelRecipes++) { + for (; parallelRecipes < aMaxParallelRecipes && tTotalEUt < (tVoltage - tRecipeEUt); parallelRecipes++) { if (!tRecipe.isRecipeInputEqual(true, aFluidInputs, aItemInputs)) { log("Broke at "+parallelRecipes+"."); break; } - log("Bumped EU from "+tTotalEUt+" to "+(tTotalEUt+tRecipeEUt)+". Can use "+tEffectiveVoltage); + log("Bumped EU from "+tTotalEUt+" to "+(tTotalEUt+tRecipeEUt)+"."); tTotalEUt += tRecipeEUt; } @@ -1058,6 +1038,7 @@ GT_MetaTileEntity_MultiBlockBase { // -- Try not to fail after this point - inputs have already been consumed! -- + // Convert speed bonus to duration multiplier // e.g. 100% speed bonus = 200% speed = 100%/200% = 50% recipe duration. aSpeedBonusPercent = Math.max(-99, aSpeedBonusPercent); @@ -1071,10 +1052,10 @@ GT_MetaTileEntity_MultiBlockBase { // Overclock if (this.mEUt <= 16) { - this.mEUt = (this.mEUt * (1 << tTierInputVoltage - 1) * (1 << tTierInputVoltage - 1)); - this.mMaxProgresstime = (this.mMaxProgresstime / (1 << tTierInputVoltage - 1)); + this.mEUt = (this.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); + this.mMaxProgresstime = (this.mMaxProgresstime / (1 << tTier - 1)); } else { - while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTierInputVoltage - 1)]) { + while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { this.mEUt *= 4; this.mMaxProgresstime /= 2; } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/algae/GregtechMTE_AlgaePondBase.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/algae/GregtechMTE_AlgaePondBase.java new file mode 100644 index 0000000000..332c46dc3e --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/algae/GregtechMTE_AlgaePondBase.java @@ -0,0 +1,128 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.algae; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.TAE; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Recipe; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; + +public class GregtechMTE_AlgaePondBase extends GregtechMeta_MultiBlockBase { + + private int mLevel = 0; + + public GregtechMTE_AlgaePondBase(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMTE_AlgaePondBase(final String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMTE_AlgaePondBase(this.mName); + } + + @Override + public String getMachineType() { + return "Algae Pond"; + } + + @Override + public String[] getTooltip() { + return new String[]{ + "Grows Algae!", + "Controller Block for the Algae Farm", + "Size: 3x3x3 (Hollow)", + "Controller (front middle)", + "1x Input Hatch", + "1x Output Hatch", + "1x Input Bus", + "1x Output Bus" + }; + } + + @Override + public String getSound() { + return GregTech_API.sSoundList.get(Integer.valueOf(207)); + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[TAE.GTPP_INDEX(1)], new GT_RenderedTexture(aActive ? TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active : TexturesGtBlock.Overlay_Machine_Controller_Advanced)}; + } + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[TAE.GTPP_INDEX(1)]}; + } + + @Override + public boolean hasSlotInGUI() { + return true; + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return null; + } + + @Override + public boolean isFacingValid(final byte aFacing) { + return aFacing > 1; + } + + @Override + public boolean checkRecipe(final ItemStack aStack) { + return checkRecipeGeneric(getMaxParallelRecipes(), getEuDiscountForParallelism(), 0); + } + + @Override + public int getMaxParallelRecipes() { + return this.mLevel * 10; + } + + @Override + public int getEuDiscountForParallelism() { + return 0; + } + + @Override + public boolean checkMultiblock(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack) { + final int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; + final int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; + this.mLevel = 0; + return true; + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(final ItemStack aStack) { + return 0; + } + + @Override + public int getAmountOfOutputs() { + return 1; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + @Override + public String getCustomGUIResourceName() { + return null; + } + +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechAlgaeContent.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechAlgaeContent.java new file mode 100644 index 0000000000..57a726f7e8 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechAlgaeContent.java @@ -0,0 +1,24 @@ +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.algae.GregtechMTE_AlgaePondBase; + +public class GregtechAlgaeContent { + + public static void run() { + if (LoadedMods.Gregtech) { + Logger.INFO("Gregtech5u Content | Registering Algae Content."); + run1(); + } + } + + private static void run1() { + // Industrial Centrifuge Multiblock + GregtechItemList.AlgaeFarm_Controller.set( + new GregtechMTE_AlgaePondBase(997, "algaefarm.controller.tier.single", "Algae Farm").getStackForm(1L)); + + } + +} diff --git a/src/Java/gtPlusPlus/xmod/ic2/item/CustomKineticRotor.java b/src/Java/gtPlusPlus/xmod/ic2/item/CustomKineticRotor.java new file mode 100644 index 0000000000..e433396a1b --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/ic2/item/CustomKineticRotor.java @@ -0,0 +1,274 @@ +package gtPlusPlus.xmod.ic2.item; + +import java.util.List; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.core.lib.LoadedMods; +import ic2.api.item.IKineticRotor; +import ic2.core.IC2; +import ic2.core.block.kineticgenerator.gui.GuiWaterKineticGenerator; +import ic2.core.block.kineticgenerator.gui.GuiWindKineticGenerator; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; + +public class CustomKineticRotor extends Item implements IKineticRotor { + + private final int mTier; + + @SideOnly(Side.CLIENT) + private final IIcon[] mTextures = new IIcon[6]; + + private static final String[] mRegistrationNames = new String[] { + "itemwoodrotor", "itemironrotor", "itemsteelrotor", "itemwcarbonrotor" + }; + + private static final String[] mUnlocalNames = new String[] { + "itemEnergeticRotor", + "itemTungstenSteelRotor", + "itemVibrantRotor", + "itemIridiumRotor", + "itemMagnaliumRotor", + "itemUltimetRotor", + }; + private static final int[] mMaxDurability = new int[] { + 512000, 809600, 1600000, 3200000 + }; + private static final int[] mRadius = new int[] { + 9, 11, 13, 15 + }; + private static final float[] mEfficiency = new float[] { + 0.9f, 1.0f, 1.2f, 1.5f + }; + private static final int[] mMinWindStrength = new int[] { + 12, 14, 16, 18 + }; + private static final int[] mMaxWindStrength = new int[] { + 80, 120, 160, 320 + }; + + private static final ResourceLocation[] mResourceLocations = new ResourceLocation[] { + new ResourceLocation(IC2.textureDomain, "textures/items/rotors/rotorEnergeticModel.png"), + new ResourceLocation(IC2.textureDomain, "textures/items/rotors/rotorTungstenSteelModel.png"), + new ResourceLocation(IC2.textureDomain, "textures/items/rotors/rotorVibrantModel.png"), + new ResourceLocation(IC2.textureDomain, "textures/items/rotors/rotorIridiumModel.png"), + new ResourceLocation(IC2.textureDomain, "textures/items/rotors/rotorMagnaliumModel.png"), + new ResourceLocation(IC2.textureDomain, "textures/items/rotors/rotorUltimetModel.png"), + }; + + private final int maxWindStrength; + private final int minWindStrength; + private final int radius; + private final float efficiency; + private final ResourceLocation renderTexture; + + public CustomKineticRotor(int aTier) { + mTier = aTier; + this.setMaxStackSize(1); + // Handle Differences if EIO is not loaded + if (!LoadedMods.EnderIO && (aTier == 0 || aTier == 2)) { + this.renderTexture = mResourceLocations[(aTier == 0 ? 4 : 5)]; + this.setUnlocalizedName(mUnlocalNames[(aTier == 0 ? 4 : 5)]); + } + else { + this.renderTexture = mResourceLocations[aTier]; + this.setUnlocalizedName(mUnlocalNames[aTier]); + } + this.setMaxDamage(mMaxDurability[aTier]); + this.radius = mRadius[aTier]; + this.efficiency = mEfficiency[aTier]; + this.minWindStrength = mMinWindStrength[aTier]; + this.maxWindStrength = mMaxWindStrength[aTier]; + this.setNoRepair(); + this.setCreativeTab(IC2.tabIC2); + GameRegistry.registerItem(this, mRegistrationNames[aTier]); + } + + @Override + public void setDamage(final ItemStack stack, final int damage) { + if (mTier < 3) { + super.setDamage(stack, damage); + } + } + + @Override + public void addInformation(final ItemStack itemStack, final EntityPlayer player, final List info, final boolean b) { + + info.add(StatCollector.translateToLocalFormatted("ic2.itemrotor.wind.info", new Object[]{this.minWindStrength, this.maxWindStrength})); + + GearboxType type = null; + if (Minecraft.getMinecraft().currentScreen != null && Minecraft.getMinecraft().currentScreen instanceof GuiWaterKineticGenerator) { + type = GearboxType.WATER; + } + else if (Minecraft.getMinecraft().currentScreen != null && Minecraft.getMinecraft().currentScreen instanceof GuiWindKineticGenerator) { + type = GearboxType.WIND; + } + + if (type != null) { + info.add(StatCollector.translateToLocal("ic2.itemrotor.fitsin." + this.isAcceptedType(itemStack, type))); + } + + } + + @Override + public int getDiameter(final ItemStack stack) + { + return this.radius; + } + + @Override + public ResourceLocation getRotorRenderTexture(final ItemStack stack) + { + return this.renderTexture; + } + + @Override + public float getEfficiency(final ItemStack stack) + { + return this.efficiency; + } + + @Override + public int getMinWindStrength(final ItemStack stack) + { + return this.minWindStrength; + } + + @Override + public int getMaxWindStrength(final ItemStack stack) + { + return this.maxWindStrength; + } + + @Override + public boolean isAcceptedType(final ItemStack stack, final IKineticRotor.GearboxType type){ + return (type == IKineticRotor.GearboxType.WIND) || (type == IKineticRotor.GearboxType.WATER); + } + + public String getUnlocalizedName() { + return "ic2." + super.getUnlocalizedName().substring(5); + } + + public String getUnlocalizedName(ItemStack itemStack) { + return this.getUnlocalizedName(); + } + + public String getItemStackDisplayName(ItemStack itemStack) { + return StatCollector.translateToLocal(this.getUnlocalizedName(itemStack)); + } + + @Override + public boolean showDurabilityBar(ItemStack stack) { + return mTier < 3; + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamage(int meta) { + if (!LoadedMods.EnderIO && (mTier == 0 || mTier == 2)) { + if (mTier == 0) { + return mTextures[4]; + } + else { + return mTextures[5]; + } + } + else { + return mTextures[mTier]; + } + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIconIndex(ItemStack aIndex) { + if (!LoadedMods.EnderIO && (mTier == 0 || mTier == 2)) { + if (mTier == 0) { + return mTextures[4]; + } + else { + return mTextures[5]; + } + } + else { + return mTextures[mTier]; + } + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamageForRenderPass(int aDmg, int aPass) { + if (!LoadedMods.EnderIO && (mTier == 0 || mTier == 2)) { + if (mTier == 0) { + return mTextures[4]; + } + else { + return mTextures[5]; + } + } + else { + return mTextures[mTier]; + } + } + + @Override + protected String getIconString() { + return super.getIconString(); + } + + @Override + public int getDisplayDamage(ItemStack stack) { + return super.getDisplayDamage(stack); + } + + @Override + public double getDurabilityForDisplay(ItemStack stack) { + return super.getDurabilityForDisplay(stack); + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) { + if (!LoadedMods.EnderIO && (mTier == 0 || mTier == 2)) { + if (mTier == 0) { + return mTextures[4]; + } + else { + return mTextures[5]; + } + } + else { + return mTextures[mTier]; + } + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(ItemStack stack, int pass) { + if (!LoadedMods.EnderIO && (mTier == 0 || mTier == 2)) { + if (mTier == 0) { + return mTextures[4]; + } + else { + return mTextures[5]; + } + } + else { + return mTextures[mTier]; + } + } + + @Override + public void registerIcons(IIconRegister iconRegister) { + int aIndex = 0; + for (String y : mUnlocalNames) { + mTextures[aIndex++] = iconRegister.registerIcon(IC2.textureDomain + ":" + "rotors/" + y); + } + } +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/ic2/item/IC2_Items.java b/src/Java/gtPlusPlus/xmod/ic2/item/IC2_Items.java index 64aa7f99bf..862ba38748 100644 --- a/src/Java/gtPlusPlus/xmod/ic2/item/IC2_Items.java +++ b/src/Java/gtPlusPlus/xmod/ic2/item/IC2_Items.java @@ -1,13 +1,9 @@ package gtPlusPlus.xmod.ic2.item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; - import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.item.base.CoreItem; import gtPlusPlus.core.lib.LoadedMods; -import ic2.core.IC2; -import ic2.core.init.InternalName; +import net.minecraft.item.ItemStack; public class IC2_Items { @@ -29,45 +25,33 @@ public class IC2_Items { public static ItemStack blockRTG; public static ItemStack blockKineticGenerator; - public static void register(){ + private static final String[] mData1 = new String[] {"itemEnergeticRotorBlade", "itemMagnaliumRotorBlade"}; + private static final String[] mData2 = new String[] {"itemEnergeticShaft", "itemMagnaliumShaft"}; + private static final String[] mData3 = new String[] {"itemVibrantRotorBlade", "itemUltimetRotorBlade"}; + private static final String[] mData4 = new String[] {"itemVibrantShaft", "itemUltimetShaft"}; + - if(LoadedMods.EnderIO){ - //Tier 1 - rotor_Blade_Material_1 = new ItemStack (new CoreItem("itemEnergeticRotorBlade", AddToCreativeTab.tabMachines, 16, "A part for an advanced Kinetic Rotor")); - shaft_Material_1 = new ItemStack (new CoreItem("itemEnergeticShaft", AddToCreativeTab.tabMachines, 16, "A part for an advanced Kinetic Rotor")); - rotor_Material_1 = new ItemStack (new RotorBase(InternalName.itemwoodrotor, 9, 512000, 0.9F, 12, 80, new ResourceLocation(IC2.textureDomain, "textures/items/rotors/rotorEnergeticModel.png")).setCreativeTab(AddToCreativeTab.tabMachines).setUnlocalizedName("itemEnergeticRotor")); - //Tier 2 - rotor_Blade_Material_2 = new ItemStack (new CoreItem("itemTungstenSteelRotorBlade", AddToCreativeTab.tabMachines, 16, "A part for an advanced Kinetic Rotor")); - shaft_Material_2 = new ItemStack (new CoreItem("itemTungstenSteelShaft", AddToCreativeTab.tabMachines, 16, "A part for an advanced Kinetic Rotor")); - rotor_Material_2 = new ItemStack (new RotorBase(InternalName.itemironrotor, 11, 809600, 1.0F, 14, 120, new ResourceLocation(IC2.textureDomain, "textures/items/rotors/rotorTungstenSteelModel.png")).setCreativeTab(AddToCreativeTab.tabMachines).setUnlocalizedName("itemTungstenSteelRotor")); - //Tier 3 - rotor_Blade_Material_3 = new ItemStack (new CoreItem("itemVibrantRotorBlade", AddToCreativeTab.tabMachines, 16, "A part for an advanced Kinetic Rotor")); - shaft_Material_3 = new ItemStack (new CoreItem("itemVibrantShaft", AddToCreativeTab.tabMachines, 16, "A part for an advanced Kinetic Rotor")); - rotor_Material_3 = new ItemStack (new RotorBase(InternalName.itemsteelrotor, 13, 1600000, 1.2F, 16, 160, new ResourceLocation(IC2.textureDomain, "textures/items/rotors/rotorVibrantModel.png")).setCreativeTab(AddToCreativeTab.tabMachines).setUnlocalizedName("itemVibrantRotor")); - //Tier 4 - rotor_Blade_Material_4 = new ItemStack (new CoreItem("itemIridiumRotorBlade", AddToCreativeTab.tabMachines, 16, "A part for an advanced Kinetic Rotor")); - shaft_Material_4 = new ItemStack (new CoreItem("itemIridiumShaft", AddToCreativeTab.tabMachines, 16, "A part for an advanced Kinetic Rotor")); - rotor_Material_4 = new ItemStack (new RotorIridium(InternalName.itemwcarbonrotor, 15, 3200000, 1.5F, 18, 320, new ResourceLocation(IC2.textureDomain, "textures/items/rotors/rotorIridiumModel.png")).setCreativeTab(AddToCreativeTab.tabMachines).setUnlocalizedName("itemIridiumRotor")); + public static void register(){ - } - else { - //Tier 1 - Magnalium - rotor_Blade_Material_1 = new ItemStack (new CoreItem("itemMagnaliumRotorBlade", AddToCreativeTab.tabMachines, 16, "A part for an advanced Kinetic Rotor")); - shaft_Material_1 = new ItemStack (new CoreItem("itemMagnaliumShaft", AddToCreativeTab.tabMachines, 16, "A part for an advanced Kinetic Rotor")); - rotor_Material_1 = new ItemStack (new RotorBase(InternalName.itemwoodrotor, 9, 512000, 0.9F, 12, 80, new ResourceLocation(IC2.textureDomain, "textures/items/rotors/rotorMagnaliumModel.png")).setCreativeTab(AddToCreativeTab.tabMachines).setUnlocalizedName("itemMagnaliumRotor")); - //Tier 2 - rotor_Blade_Material_2 = new ItemStack (new CoreItem("itemTungstenSteelRotorBlade", AddToCreativeTab.tabMachines, 16, "A part for an advanced Kinetic Rotor")); - shaft_Material_2 = new ItemStack (new CoreItem("itemTungstenSteelShaft", AddToCreativeTab.tabMachines, 16, "A part for an advanced Kinetic Rotor")); - rotor_Material_2 = new ItemStack (new RotorBase(InternalName.itemironrotor, 11, 809600, 1.0F, 14, 120, new ResourceLocation(IC2.textureDomain, "textures/items/rotors/rotorTungstenSteelModel.png")).setCreativeTab(AddToCreativeTab.tabMachines).setUnlocalizedName("itemTungstenSteelRotor")); - //Tier 3 - Ultimet - rotor_Blade_Material_3 = new ItemStack (new CoreItem("itemUltimetRotorBlade", AddToCreativeTab.tabMachines, 16, "A part for an advanced Kinetic Rotor")); - shaft_Material_3 = new ItemStack (new CoreItem("itemUltimetShaft", AddToCreativeTab.tabMachines, 16, "A part for an advanced Kinetic Rotor")); - rotor_Material_3 = new ItemStack (new RotorBase(InternalName.itemsteelrotor, 13, 1600000, 1.2F, 16, 160, new ResourceLocation(IC2.textureDomain, "textures/items/rotors/rotorUltimetModel.png")).setCreativeTab(AddToCreativeTab.tabMachines).setUnlocalizedName("itemUltimetRotor")); - //Tier 4 - rotor_Blade_Material_4 = new ItemStack (new CoreItem("itemIridiumRotorBlade", AddToCreativeTab.tabMachines, 16, "A part for an advanced Kinetic Rotor")); - shaft_Material_4 = new ItemStack (new CoreItem("itemIridiumShaft", AddToCreativeTab.tabMachines, 16, "A part for an advanced Kinetic Rotor")); - rotor_Material_4 = new ItemStack (new RotorIridium(InternalName.itemwcarbonrotor, 15, 3200000, 1.5F, 18, 320, new ResourceLocation(IC2.textureDomain, "textures/items/rotors/rotorIridiumModel.png")).setCreativeTab(AddToCreativeTab.tabMachines).setUnlocalizedName("itemIridiumRotor")); - } + int aIndexEIO = (LoadedMods.EnderIO ? 0 : 1); + + // Rotor Blades + rotor_Blade_Material_1 = new ItemStack (new CoreItem(mData1[aIndexEIO], AddToCreativeTab.tabMachines, 16, "A part for an advanced Kinetic Rotor")); + rotor_Blade_Material_2 = new ItemStack (new CoreItem("itemTungstenSteelRotorBlade", AddToCreativeTab.tabMachines, 16, "A part for an advanced Kinetic Rotor")); + rotor_Blade_Material_3 = new ItemStack (new CoreItem(mData3[aIndexEIO], AddToCreativeTab.tabMachines, 16, "A part for an advanced Kinetic Rotor")); + rotor_Blade_Material_4 = new ItemStack (new CoreItem("itemIridiumRotorBlade", AddToCreativeTab.tabMachines, 16, "A part for an advanced Kinetic Rotor")); + + // Rotor Shafts + shaft_Material_1 = new ItemStack (new CoreItem(mData2[aIndexEIO], AddToCreativeTab.tabMachines, 16, "A part for an advanced Kinetic Rotor")); + shaft_Material_2 = new ItemStack (new CoreItem("itemTungstenSteelShaft", AddToCreativeTab.tabMachines, 16, "A part for an advanced Kinetic Rotor")); + shaft_Material_3 = new ItemStack (new CoreItem(mData4[aIndexEIO], AddToCreativeTab.tabMachines, 16, "A part for an advanced Kinetic Rotor")); + shaft_Material_4 = new ItemStack (new CoreItem("itemIridiumShaft", AddToCreativeTab.tabMachines, 16, "A part for an advanced Kinetic Rotor")); + + // Rotors + rotor_Material_1 = new ItemStack (new CustomKineticRotor(0)); + rotor_Material_2 = new ItemStack (new CustomKineticRotor(1)); + rotor_Material_3 = new ItemStack (new CustomKineticRotor(2)); + rotor_Material_4 = new ItemStack (new CustomKineticRotor(3)); } } diff --git a/src/Java/gtPlusPlus/xmod/ic2/item/RotorIridium.java b/src/Java/gtPlusPlus/xmod/ic2/item/RotorIridium.java index aca1c6a310..b9dffbd371 100644 --- a/src/Java/gtPlusPlus/xmod/ic2/item/RotorIridium.java +++ b/src/Java/gtPlusPlus/xmod/ic2/item/RotorIridium.java @@ -118,5 +118,10 @@ public class RotorIridium extends RotorBase{ this.setCustomDamage(stack, this.getCustomDamage(stack) + damage); return true; } + + @Override + public boolean showDurabilityBar(ItemStack stack) { + return false; + } } diff --git a/src/resources/assets/gregtech/lang/en_US.lang b/src/resources/assets/gregtech/lang/en_US.lang index 9989bffcf0..e2120fdf7b 100644 --- a/src/resources/assets/gregtech/lang/en_US.lang +++ b/src/resources/assets/gregtech/lang/en_US.lang @@ -212,7 +212,9 @@ achievement.decay.technetium99.desc=Cyclotron Product - +//24/11/19 +achievement.gt.blockmachines.hatch.turbine.input.tier.00=Turbine Housing +achievement.gt.blockmachines.hatch.turbine.input.tier.00.desc=[AL] Pickup this item to see the recipe in NEI diff --git a/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Side_0.png b/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Side_0.png deleted file mode 100644 index cbf604f2b3..0000000000 Binary files a/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Side_0.png and /dev/null differ diff --git a/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Side_1.png b/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Side_1.png deleted file mode 100644 index 3b7ac3d50e..0000000000 Binary files a/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Side_1.png and /dev/null differ diff --git a/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Side_2.png b/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Side_2.png deleted file mode 100644 index a5a5e2c559..0000000000 Binary files a/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Side_2.png and /dev/null differ diff --git a/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Side_3.png b/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Side_3.png deleted file mode 100644 index b68c900ddd..0000000000 Binary files a/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Side_3.png and /dev/null differ diff --git a/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Side_4.png b/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Side_4.png deleted file mode 100644 index df182aeaa5..0000000000 Binary files a/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Side_4.png and /dev/null differ diff --git a/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Top_0.png b/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Top_0.png deleted file mode 100644 index 85bc3f16cd..0000000000 Binary files a/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Top_0.png and /dev/null differ diff --git a/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Top_1.png b/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Top_1.png deleted file mode 100644 index f82185ebdb..0000000000 Binary files a/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Top_1.png and /dev/null differ diff --git a/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Top_2.png b/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Top_2.png deleted file mode 100644 index 345476e03c..0000000000 Binary files a/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Top_2.png and /dev/null differ diff --git a/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Top_3.png b/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Top_3.png deleted file mode 100644 index 971164eb3e..0000000000 Binary files a/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Top_3.png and /dev/null differ diff --git a/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Top_4.png b/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Top_4.png deleted file mode 100644 index 5b5bac3ad2..0000000000 Binary files a/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/RoundRobinator_Top_4.png and /dev/null differ diff --git a/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/Side_0.png b/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/Side_0.png new file mode 100644 index 0000000000..cbf604f2b3 Binary files /dev/null and b/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/Side_0.png differ diff --git a/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/Side_1.png b/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/Side_1.png new file mode 100644 index 0000000000..3b7ac3d50e Binary files /dev/null and b/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/Side_1.png differ diff --git a/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/Side_2.png b/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/Side_2.png new file mode 100644 index 0000000000..a5a5e2c559 Binary files /dev/null and b/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/Side_2.png differ diff --git a/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/Side_3.png b/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/Side_3.png new file mode 100644 index 0000000000..b68c900ddd Binary files /dev/null and b/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/Side_3.png differ diff --git a/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/Side_4.png b/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/Side_4.png new file mode 100644 index 0000000000..df182aeaa5 Binary files /dev/null and b/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/Side_4.png differ diff --git a/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/Top_0.png b/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/Top_0.png new file mode 100644 index 0000000000..85bc3f16cd Binary files /dev/null and b/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/Top_0.png differ diff --git a/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/Top_1.png b/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/Top_1.png new file mode 100644 index 0000000000..f82185ebdb Binary files /dev/null and b/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/Top_1.png differ diff --git a/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/Top_2.png b/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/Top_2.png new file mode 100644 index 0000000000..345476e03c Binary files /dev/null and b/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/Top_2.png differ diff --git a/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/Top_3.png b/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/Top_3.png new file mode 100644 index 0000000000..971164eb3e Binary files /dev/null and b/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/Top_3.png differ diff --git a/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/Top_4.png b/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/Top_4.png new file mode 100644 index 0000000000..5b5bac3ad2 Binary files /dev/null and b/src/resources/assets/miscutils/textures/blocks/TileEntities/RoundRobinator/Top_4.png differ -- cgit From 051c46ab36a749954cff3bae1fbd44cea6f1fc99 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Mon, 9 Dec 2019 21:03:31 +0000 Subject: + Added GT++ API class. + Added handler for Void Miner to API. + Added handler for special multiblock logic to API. + Added Initial work For Chemical Plant. % More work on the Algae Farm. --- .../api/helpers/GregtechPlusPlus_API.java | 194 +++++++++ .../api/objects/data/WeightedCollection.java | 102 +++++ .../multi/NoOutputBonusMultiBehaviour.java | 28 ++ .../minecraft/multi/SpecialMultiBehaviour.java | 44 ++ src/Java/gtPlusPlus/core/common/CommonProxy.java | 3 + src/Java/gtPlusPlus/core/recipe/common/CI.java | 4 + .../xmod/gregtech/api/enums/GregtechItemList.java | 4 +- .../base/GregtechMeta_MultiBlockBase.java | 71 ++- .../api/util/SpecialBehaviourTooltipHandler.java | 29 ++ .../algae/GregtechMTE_AlgaePondBase.java | 169 ++++--- .../chemplant/GregtechMTE_ChemicalPlant.java | 483 +++++++++++++++++++++ .../gregtech/GregtechAlgaeContent.java | 10 +- 12 files changed, 1039 insertions(+), 102 deletions(-) create mode 100644 src/Java/gtPlusPlus/api/helpers/GregtechPlusPlus_API.java create mode 100644 src/Java/gtPlusPlus/api/objects/data/WeightedCollection.java create mode 100644 src/Java/gtPlusPlus/api/objects/minecraft/multi/NoOutputBonusMultiBehaviour.java create mode 100644 src/Java/gtPlusPlus/api/objects/minecraft/multi/SpecialMultiBehaviour.java create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/api/util/SpecialBehaviourTooltipHandler.java create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/GregtechMTE_ChemicalPlant.java (limited to 'src/Java/gtPlusPlus/api/objects') diff --git a/src/Java/gtPlusPlus/api/helpers/GregtechPlusPlus_API.java b/src/Java/gtPlusPlus/api/helpers/GregtechPlusPlus_API.java new file mode 100644 index 0000000000..9816d45bbf --- /dev/null +++ b/src/Java/gtPlusPlus/api/helpers/GregtechPlusPlus_API.java @@ -0,0 +1,194 @@ +package gtPlusPlus.api.helpers; + +import java.util.HashMap; + +import gtPlusPlus.api.objects.data.WeightedCollection; +import gtPlusPlus.api.objects.minecraft.multi.SpecialMultiBehaviour; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.xmod.gregtech.api.util.SpecialBehaviourTooltipHandler; +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; + +public class GregtechPlusPlus_API { + + public static class Multiblock_API { + + private static final HashMap mSpecialBehaviourItemMap; + + static { + mSpecialBehaviourItemMap = new HashMap(); + } + + /** + * Register a special behaviour for GT++ Multis to listen use. + * @param aBehaviour - An Object which has extended {@link SpecialMultiBehaviour}'s base implementation. + * @return - Did this behaviour register properly? + */ + public static boolean registerSpecialMultiBehaviour(SpecialMultiBehaviour aBehaviour) { + if (aBehaviour.getTriggerItem() == null || aBehaviour.getTriggerItemTooltip() == null || aBehaviour.getTriggerItemTooltip().length() <= 0) { + return false; + } + mSpecialBehaviourItemMap.put("UniqueKey_"+aBehaviour.hashCode(), aBehaviour); + SpecialBehaviourTooltipHandler.addTooltipForItem(aBehaviour.getTriggerItem(), aBehaviour.getTriggerItemTooltip()); + return true; + } + + public static final HashMap getSpecialBehaviourItemMap() { + return mSpecialBehaviourItemMap; + } + + + } + + public static class VoidMiner_API { + + private static final HashMap>> mMinerLootCache; + + static { + mMinerLootCache = new HashMap>>(); + } + + + /** + * + * Registers an ore block for a dimension. Uses a default weight of 100. + * @param aDim - The Dimension ID + * @param aOredictName - The OreDict name of the Ore to be mined. + * @return - If there was a valid Block found in the OreDict for the provided name. + */ + public static boolean registerOreForVoidMiner(int aDim, String aOredictName) { + return registerOreForVoidMiner(aDim, aOredictName, 100); + } + + /** + * + * Registers an ore block for a dimension. Uses a default weight of 100. + * @param aDim - The Dimension ID + * @param aOredictName - The OreDict name of the Ore to be mined. + * @param aWeight - The weight of this ore Block. + * @return - If there was a valid Block found in the OreDict for the provided name. + */ + public static boolean registerOreForVoidMiner(int aDim, String aOredictName, int aWeight) { + Block b = null; + ItemStack[] aValidItems = ItemUtils.validItemsForOreDict(aOredictName); + for (ItemStack g : aValidItems) { + if (g != null) { + b = Block.getBlockFromItem(g.getItem()); + if (b != null) { + break; + } + } + } + if (b != null) { + registerOreForVoidMiner(aDim, b, aWeight); + return true; + } + return false; + } + + + /** + * Registers an ore block for a dimension. Uses a default weight of 100. + * @param aDim - The Dimension ID + * @param aOreBlock - The Ore Block to be mined. + */ + public static void registerOreForVoidMiner(int aDim, Block aOreBlock) { + registerOreForVoidMiner(aDim, aOreBlock, 100); + } + + /** + * Registers an ore block for a dimension. + * @param aDim - The Dimension ID + * @param aOreBlock - The Ore Block to be mined. + * @param aWeight - The weight of this ore Block. + */ + public static void registerOreForVoidMiner(int aDim, Block aOreBlock, int aWeight) { + GregtechPlusPlus_API_Internal.writeBlockToDimensionInCache(aDim, 0, aOreBlock, aWeight); + } + + /** + * Registers a surface block for a dimension. Uses a default weight of 100. + * @param aDim - The Dimension ID + * @param aDirtBlock - The Dirt/Grass Block to be mined. + */ + public static void registerEarthSurfaceForVoidMiner(int aDim, Block aDirtBlock) { + registerEarthSurfaceForVoidMiner(aDim, aDirtBlock, 100); + } + + /** + * Registers a surface block for a dimension. + * @param aDim - The Dimension ID + * @param aDirtBlock - The Dirt/Grass Block to be mined. + * @param aWeight - The weight of this Dirt/Grass Block. + */ + public static void registerEarthSurfaceForVoidMiner(int aDim, Block aDirtBlock, int aWeight) { + GregtechPlusPlus_API_Internal.writeBlockToDimensionInCache(aDim, 0, aDirtBlock, aWeight); + } + + /** + * Registers a stone block for a dimension. Uses a default weight of 100. + * @param aDim - The Dimension ID + * @param aStoneBlock - The Stone Block to be mined. + */ + public static void registerEarthStoneForVoidMiner(int aDim, Block aStoneBlock) { + registerEarthStoneForVoidMiner(aDim, aStoneBlock, 100); + } + + /** + * Registers a stone block for a dimension. + * @param aDim - The Dimension ID + * @param aStoneBlock - The Stone Block to be mined. + * @param aWeight - The weight of this Stone Block. + */ + public static void registerEarthStoneForVoidMiner(int aDim, Block aStoneBlock, int aWeight) { + GregtechPlusPlus_API_Internal.writeBlockToDimensionInCache(aDim, 0, aStoneBlock, aWeight); + } + + + + + public static WeightedCollection getAllRegisteredOresForDimension(int aDim) { + return mMinerLootCache.get(aDim).get("ore"); + } + + public static WeightedCollection getAllRegisteredDirtTypesForDimension(int aDim) { + return mMinerLootCache.get(aDim).get("dirt"); + } + + public static WeightedCollection getAllRegisteredStoneTypesForDimension(int aDim) { + return mMinerLootCache.get(aDim).get("stone"); + } + + public static final HashMap>> getVoidMinerLootCache() { + return mMinerLootCache; + } + + } + + + private static class GregtechPlusPlus_API_Internal { + + private static void writeBlockToDimensionInCache(int aDim, int aType, Block aBlock, int aWeight) { + HashMap> aDimMap = VoidMiner_API.mMinerLootCache.get(aDim); + if (aDimMap == null) { + aDimMap = new HashMap>(); + } + WeightedCollection aMappedBlocks = getBlockMap(aType, aDimMap); + aMappedBlocks.put(aWeight, aBlock); + + } + + private static WeightedCollection getBlockMap(int aType, HashMap> aDimMap){ + WeightedCollection aMappedBlocks; + String aTypeName = ((aType == 0) ? "ore" : (aType == 1) ? "dirt" : (aType == 2) ? "stone" : "error"); + aMappedBlocks = aDimMap.get(aTypeName); + if (aMappedBlocks == null) { + aMappedBlocks = new WeightedCollection(); + } + return aMappedBlocks; + } + + } + + +} diff --git a/src/Java/gtPlusPlus/api/objects/data/WeightedCollection.java b/src/Java/gtPlusPlus/api/objects/data/WeightedCollection.java new file mode 100644 index 0000000000..f9966474b0 --- /dev/null +++ b/src/Java/gtPlusPlus/api/objects/data/WeightedCollection.java @@ -0,0 +1,102 @@ +package gtPlusPlus.api.objects.data; + +import java.util.Collection; +import java.util.Map; +import java.util.NavigableMap; +import java.util.Random; +import java.util.Set; +import java.util.TreeMap; + +import gtPlusPlus.api.objects.random.XSTR; + +public class WeightedCollection implements Map { + + private NavigableMap map = new TreeMap(); + private Random random; + private int total = 0; + + public WeightedCollection() { + this(new XSTR()); + } + + public WeightedCollection(Random random) { + this.random = random; + } + + public E add(int weight, E object) { + if (weight <= 0) return null; + total += weight; + return map.put(total, object); + } + + private E next() { + int value = random.nextInt(total) + 1; // Can also use floating-point weights + return map.ceilingEntry(value).getValue(); + } + + @Override + public int size() { + return map.size(); + } + + @Override + public boolean isEmpty() { + return map.isEmpty(); + } + + @Override + public boolean containsKey(Object key) { + return map.containsKey(key); + } + + @Override + public boolean containsValue(Object value) { + return map.containsValue(value); + } + + public E get() { + return next(); + } + + @Override + public E get(Object key) { + return next(); + } + + @Override + public void putAll(Map m) { + map.putAll(m); + } + + @Override + public void clear() { + map.clear(); + this.total = 0; + } + + @Override + public Set keySet() { + return map.keySet(); + } + + @Override + public Collection values() { + return map.values(); + } + + @Override + public Set entrySet() { + return map.entrySet(); + } + + @Override + public E put(Integer key, E value) { + return add(key, value); + } + + @Override + public E remove(Object key) { + return map.remove(key); + } + +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/api/objects/minecraft/multi/NoOutputBonusMultiBehaviour.java b/src/Java/gtPlusPlus/api/objects/minecraft/multi/NoOutputBonusMultiBehaviour.java new file mode 100644 index 0000000000..871b42b901 --- /dev/null +++ b/src/Java/gtPlusPlus/api/objects/minecraft/multi/NoOutputBonusMultiBehaviour.java @@ -0,0 +1,28 @@ +package gtPlusPlus.api.objects.minecraft.multi; + +import gtPlusPlus.api.helpers.GregtechPlusPlus_API.Multiblock_API; +import gtPlusPlus.core.recipe.common.CI; +import net.minecraft.item.ItemStack; + +public class NoOutputBonusMultiBehaviour extends SpecialMultiBehaviour { + + public NoOutputBonusMultiBehaviour() { + Multiblock_API.registerSpecialMultiBehaviour(this); + } + + @Override + public ItemStack getTriggerItem() { + return CI.getNumberedBioCircuit(22); + } + + @Override + public String getTriggerItemTooltip() { + return "Prevents bonus output % on GT++ multiblocks when used"; + } + + @Override + public int getOutputChanceRoll() { + return 10000; + } + +} diff --git a/src/Java/gtPlusPlus/api/objects/minecraft/multi/SpecialMultiBehaviour.java b/src/Java/gtPlusPlus/api/objects/minecraft/multi/SpecialMultiBehaviour.java new file mode 100644 index 0000000000..e562ccc40b --- /dev/null +++ b/src/Java/gtPlusPlus/api/objects/minecraft/multi/SpecialMultiBehaviour.java @@ -0,0 +1,44 @@ +package gtPlusPlus.api.objects.minecraft.multi; + +import gregtech.api.util.GT_Utility; +import net.minecraft.item.ItemStack; + +/** + * Extend this class to implement custom behaviour for multiblocks. + * The Trigger item when in a special slot or input bus, will cause the multiblock to behave as specified. + * Not overriding a method here will cause the default values to be used. + * @author Alkalus + * + */ +public abstract class SpecialMultiBehaviour { + + private final int mMaxParallelRecipes = Short.MIN_VALUE; + private final int mEUPercent = Short.MIN_VALUE; + private final int mSpeedBonusPercent = Short.MIN_VALUE; + private final int mOutputChanceRoll = Short.MIN_VALUE; + + public abstract ItemStack getTriggerItem(); + + public abstract String getTriggerItemTooltip(); + + public int getMaxParallelRecipes() { + return this.mMaxParallelRecipes; + } + + public int getEUPercent() { + return this.mEUPercent; + } + + public int getSpeedBonusPercent() { + return this.mSpeedBonusPercent; + } + + public int getOutputChanceRoll() { + return this.mOutputChanceRoll; + } + + public final boolean isTriggerItem(ItemStack aToMatch) { + return GT_Utility.areStacksEqual(getTriggerItem(), aToMatch, false); + } + +} diff --git a/src/Java/gtPlusPlus/core/common/CommonProxy.java b/src/Java/gtPlusPlus/core/common/CommonProxy.java index 1920d9c903..f0d89b3016 100644 --- a/src/Java/gtPlusPlus/core/common/CommonProxy.java +++ b/src/Java/gtPlusPlus/core/common/CommonProxy.java @@ -53,6 +53,7 @@ import gtPlusPlus.plugin.villagers.block.BlockGenericSpawner; import gtPlusPlus.xmod.eio.handler.HandlerTooltip_EIO; import gtPlusPlus.xmod.galacticraft.handler.HandlerTooltip_GC; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.api.util.SpecialBehaviourTooltipHandler; import net.minecraft.enchantment.Enchantment; import net.minecraft.entity.Entity; import net.minecraft.entity.monster.EntityBlaze; @@ -147,6 +148,8 @@ public class CommonProxy { // Block Handler for all events. Utils.registerEvent(new BlockEventHandler()); Utils.registerEvent(new GeneralTooltipEventHandler()); + // Handles Tooltips for items giving custom multiblock behaviour + Utils.registerEvent(new SpecialBehaviourTooltipHandler()); // Handles Custom tooltips for EIO. Utils.registerEvent(new HandlerTooltip_EIO()); // Handles Custom Tooltips for GC diff --git a/src/Java/gtPlusPlus/core/recipe/common/CI.java b/src/Java/gtPlusPlus/core/recipe/common/CI.java index 968a96135e..ce5587ef33 100644 --- a/src/Java/gtPlusPlus/core/recipe/common/CI.java +++ b/src/Java/gtPlusPlus/core/recipe/common/CI.java @@ -1239,4 +1239,8 @@ public class CI { } + public static ItemStack getNumberedBioCircuit(int i) { + return GregtechItemList.Circuit_BioRecipeSelector.getWithDamage(i, 0L); + } + } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java index 3fc6d9d667..f61078437b 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java @@ -231,7 +231,9 @@ public enum GregtechItemList implements GregtechItemContainer { //Algae AlgaeFarm_Controller, - + + //Chemical Plant + ChemicalPlant_Controller, //GT4 autoCrafter GT4_Multi_Crafter, diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java index 3c3345d130..89c1112726 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java @@ -6,6 +6,7 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Collection; +import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.concurrent.TimeUnit; @@ -40,14 +41,16 @@ import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gregtech.api.util.GT_Utility; import gtPlusPlus.GTplusplus; import gtPlusPlus.GTplusplus.INIT_PHASE; +import gtPlusPlus.api.helpers.GregtechPlusPlus_API.Multiblock_API; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.api.objects.data.ConcurrentHashSet; import gtPlusPlus.api.objects.data.ConcurrentSet; import gtPlusPlus.api.objects.data.FlexiblePair; -import gtPlusPlus.api.objects.data.Pair; import gtPlusPlus.api.objects.data.Triplet; import gtPlusPlus.api.objects.minecraft.BlockPos; +import gtPlusPlus.api.objects.minecraft.multi.NoOutputBonusMultiBehaviour; +import gtPlusPlus.api.objects.minecraft.multi.SpecialMultiBehaviour; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.recipe.common.CI; @@ -65,7 +68,6 @@ import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEn import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBattery; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_OutputBattery; import gtPlusPlus.xmod.gregtech.api.objects.MultiblockRequirements; - import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; @@ -78,14 +80,10 @@ import net.minecraft.util.StatCollector; import net.minecraft.world.World; import net.minecraftforge.fluids.FluidStack; -public abstract class GregtechMeta_MultiBlockBase -extends -GT_MetaTileEntity_MultiBlockBase { - +public abstract class GregtechMeta_MultiBlockBase extends GT_MetaTileEntity_MultiBlockBase { public static final boolean DEBUG_DISABLE_CORES_TEMPORARILY = true; - static { Method a08 = findRecipe08 = ReflectionUtils.getMethod(GT_Recipe_Map.class, "findRecipe", IHasWorldObjectAndCoords.class, GT_Recipe.class, boolean.class, long.class, FluidStack[].class, ItemStack.class, ItemStack[].class); @@ -105,7 +103,9 @@ GT_MetaTileEntity_MultiBlockBase { } catch (NoSuchMethodException | SecurityException e) {} - //gregtech.api.util.GT_Recipe.GT_Recipe_Map.findRecipe(IHasWorldObjectAndCoords, GT_Recipe, boolean, long, FluidStack[], ItemStack, ItemStack...) + // Register the No-Bonus Special Behaviour. + new NoOutputBonusMultiBehaviour(); + } @@ -124,6 +124,10 @@ GT_MetaTileEntity_MultiBlockBase { public ArrayList mChargeHatches = new ArrayList(); public ArrayList mDischargeHatches = new ArrayList(); + // Custom Behaviour Map + HashMap mCustomBehviours; + + public GregtechMeta_MultiBlockBase(final int aID, final String aName, final String aNameRegional) { super(aID, aName, aNameRegional); @@ -989,12 +993,11 @@ GT_MetaTileEntity_MultiBlockBase { long tVoltage = getMaxInputVoltage(); byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); log("Running checkRecipeGeneric(0)"); - - + GT_Recipe tRecipe = findRecipe( getBaseMetaTileEntity(), mLastRecipe, false, - gregtech.api.enums.GT_Values.V[tTier], aFluidInputs, aItemInputs); - + gregtech.api.enums.GT_Values.V[tTier], aFluidInputs, aItemInputs); + log("Running checkRecipeGeneric(1)"); // Remember last recipe - an optimization for findRecipe() this.mLastRecipe = tRecipe; @@ -1003,6 +1006,50 @@ GT_MetaTileEntity_MultiBlockBase { log("BAD RETURN - 1"); return false; } + + + /* + * Check for Special Behaviours + */ + + // First populate the map if we need to. + if (mCustomBehviours.isEmpty()) { + mCustomBehviours = Multiblock_API.getSpecialBehaviourItemMap(); + } + + // We have a special slot object in the recipe + if (tRecipe.mSpecialItems != null) { + // The special slot is an item + if (tRecipe.mSpecialItems instanceof ItemStack) { + // Make an Itemstack instance of this. + ItemStack aSpecialStack = (ItemStack) tRecipe.mSpecialItems; + // Check if this item is in an input bus. + boolean aDidFindMatch = false; + for (ItemStack aInputItemsToCheck : aItemInputs) { + // If we find a matching stack, continue. + if (GT_Utility.areStacksEqual(aSpecialStack, aInputItemsToCheck, false)) { + // Iterate all special behaviour items, to see if we need to utilise one. + aDidFindMatch = true; + break; + } + } + // Try prevent needless iteration loops if we don't have the required inputs at all. + if (aDidFindMatch) { + // Iterate all special behaviour items, to see if we need to utilise one. + for (SpecialMultiBehaviour aBehaviours : mCustomBehviours.values()) { + // Found a match, let's adjust this recipe now. + if (aBehaviours.isTriggerItem(aSpecialStack)) { + // Adjust this recipe to suit special item + aMaxParallelRecipes = aBehaviours.getMaxParallelRecipes(); + aEUPercent = aBehaviours.getEUPercent(); + aSpeedBonusPercent = aBehaviours.getSpeedBonusPercent(); + aOutputChanceRoll = aBehaviours.getOutputChanceRoll(); + break; + } + } + } + } + } if (!this.canBufferOutputs(tRecipe, aMaxParallelRecipes)) { log("BAD RETURN - 2"); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/util/SpecialBehaviourTooltipHandler.java b/src/Java/gtPlusPlus/xmod/gregtech/api/util/SpecialBehaviourTooltipHandler.java new file mode 100644 index 0000000000..f345a67db6 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/util/SpecialBehaviourTooltipHandler.java @@ -0,0 +1,29 @@ +package gtPlusPlus.xmod.gregtech.api.util; + +import java.util.HashMap; + +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import net.minecraft.item.ItemStack; +import net.minecraftforge.event.entity.player.ItemTooltipEvent; + +public class SpecialBehaviourTooltipHandler { + + private static final HashMap mTooltipCache = new HashMap(); + + public static void addTooltipForItem(ItemStack aStack, String aTooltip) { + mTooltipCache.put(aStack, aTooltip); + } + + @SubscribeEvent + public void onItemTooltip(ItemTooltipEvent event){ + if (event != null) { + if (event.itemStack != null) { + String s = mTooltipCache.get(event.itemStack); + if (s != null && s.length() > 0) { + event.toolTip.add(s); + } + } + } + } + +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/algae/GregtechMTE_AlgaePondBase.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/algae/GregtechMTE_AlgaePondBase.java index 004fd8d94e..38c80ce8c4 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/algae/GregtechMTE_AlgaePondBase.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/algae/GregtechMTE_AlgaePondBase.java @@ -15,13 +15,13 @@ import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; import gregtech.api.util.Recipe_GT; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.api.objects.data.WeightedCollection; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.item.chemistry.AgriculturalChem; import gtPlusPlus.core.util.math.MathUtils; @@ -78,7 +78,7 @@ public class GregtechMTE_AlgaePondBase extends GregtechMeta_MultiBlockBase { "1x Output Bus", "1x Input Bus (optional)", "1x Input Hatch (fill with water)", - }; + }; } @Override @@ -116,7 +116,7 @@ public class GregtechMTE_AlgaePondBase extends GregtechMeta_MultiBlockBase { @Override public int getMaxParallelRecipes() { - return (this.mLevel+1) * 10; + return (this.mLevel+1) * 5; } @Override @@ -296,9 +296,9 @@ public class GregtechMTE_AlgaePondBase extends GregtechMeta_MultiBlockBase { } } } - + boolean isValidWater = tAmount >= 60; - + if (isValidWater) { Logger.INFO("Filled structure."); return true; @@ -358,12 +358,12 @@ public class GregtechMTE_AlgaePondBase extends GregtechMeta_MultiBlockBase { Logger.INFO("Bad Tier."); return false; } - + if (mRecipeCache.isEmpty()) { Logger.INFO("Generating Recipes."); generateRecipes(); } - + if (mRecipeCache.isEmpty() || !checkForWater()) { if (mRecipeCache.isEmpty()) { Logger.INFO("No Recipes."); @@ -382,7 +382,7 @@ public class GregtechMTE_AlgaePondBase extends GregtechMeta_MultiBlockBase { Logger.INFO("Running checkRecipeGeneric(0)"); - GT_Recipe tRecipe = getTieredRecipeFromCache(this.mLevel); + GT_Recipe tRecipe = getTieredRecipeFromCache(this.mLevel, isUsingCompost(aItemInputs)); this.mLastRecipe = tRecipe; @@ -398,33 +398,11 @@ public class GregtechMTE_AlgaePondBase extends GregtechMeta_MultiBlockBase { // -- Try not to fail after this point - inputs have already been consumed! -- - - // Convert speed bonus to duration multiplier - // e.g. 100% speed bonus = 200% speed = 100%/200% = 50% recipe duration. - aSpeedBonusPercent = Math.max(-99, aSpeedBonusPercent); - float tTimeFactor = 100.0f / (100.0f + aSpeedBonusPercent); - this.mMaxProgresstime = (int)(tRecipe.mDuration * tTimeFactor * 24); - + this.mMaxProgresstime = (int)(tRecipe.mDuration); this.mEUt = 0; - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - - // Overclock - if (this.mEUt <= 16) { - this.mEUt = (this.mEUt * (1 << mLevel - 1) * (1 << mLevel - 1)); - this.mMaxProgresstime = (this.mMaxProgresstime / (1 << mLevel - 1)); - } else { - while (this.mEUt <= gregtech.api.enums.GT_Values.V[(mLevel - 1)]) { - this.mEUt *= 4; - this.mMaxProgresstime /= 2; - } - } - - if (this.mEUt > 0) { - this.mEUt = (-this.mEUt); - } - + this.mEfficiencyIncrease = 10000; + Logger.INFO("Recipe time: "+this.mMaxProgresstime); this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); // Collect fluid outputs @@ -509,62 +487,65 @@ public class GregtechMTE_AlgaePondBase extends GregtechMeta_MultiBlockBase { return false; } - private GT_Recipe generateAlgaeOutput(boolean aUsingCompost) { + private GT_Recipe generateBaseRecipe(boolean aUsingCompost, int aTier) { // Type Safety - if (this.mLevel < 0) { + if (this.mLevel < 0 || aTier < 0 || this.mLevel != aTier) { return null; } - int[] aBrownChance = new int[] { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 2, 2, 2, 2, 2, 2, 2, - 3, 3, 3, 3, 3, 3, - 4, 4, 4, 4, - 5, 5, - 6, 7, 8, 9, 10 - }; - int[] aGoldChance = new int[] { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 1, 1, 1, 1, 1, 1, 1, 1, - 2, 2, 2, 2, 2, - 3, 3, 3, - 4, 4, - 5 + + final int[] aInvertedNumbers = new int[] { + 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 }; - int[] aRedChance = new int[] { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, - 2 + + WeightedCollection aOutputTimeMulti = new WeightedCollection(); + for (int i=100;i> 0;i--) { + float aValue = 0; + if (i < 10) { + aValue = 3f; + } + else if (i < 20) { + aValue = 2f; + } + else { + aValue = 1f; + } + aOutputTimeMulti.put(i, aValue); + } + + final int[] aDurations = new int[] { + 432000, + 378000, + 216000, + 162000, + 108000, + 81000, + 54000, + 40500, + 27000, + 20250, + 13500, + 6750, + 3375, + 1686, + 843, + 421 }; - ItemStack aAlgaeBasic = ItemUtils.getSimpleStack(AgriculturalChem.mAlgaeBiosmass, MathUtils.randInt(20, 60)); - ItemStack aAlgaeBasic2 = ItemUtils.getSimpleStack(AgriculturalChem.mAlgaeBiosmass, MathUtils.randInt(20, 60)); - ItemStack aAlgaeGreen = ItemUtils.getSimpleStack(AgriculturalChem.mGreenAlgaeBiosmass, MathUtils.randInt(10, 60)); - ItemStack aAlgaeBrown = ItemUtils.getSimpleStack(AgriculturalChem.mBrownAlgaeBiosmass, MathUtils.getRandomFromArray(aBrownChance)); - ItemStack aAlgaeGoldenBrown = ItemUtils.getSimpleStack(AgriculturalChem.mGoldenBrownAlgaeBiosmass, MathUtils.getRandomFromArray(aGoldChance)); - ItemStack aAlgaeRed = ItemUtils.getSimpleStack(AgriculturalChem.mRedAlgaeBiosmass, MathUtils.getRandomFromArray(aRedChance)); + ItemStack[] aInputs = new ItemStack[] {}; - // Make it use 8 compost if we have some available - ItemStack aCompost = ItemUtils.getSimpleStack(AgriculturalChem.mCompost, 8); - ItemStack[] aInputs = new ItemStack[] {}; if (aUsingCompost) { - aInputs = new ItemStack[] { - aCompost - }; + // Make it use 4 compost per tier if we have some available + ItemStack aCompost = ItemUtils.getSimpleStack(AgriculturalChem.mCompost, aTier * 4); + aInputs = new ItemStack[] {aCompost}; + // Boost Tier by one if using compost so it gets a speed boost + aTier++; } + // We set these elsewhere ItemStack[] aOutputs = new ItemStack[] { - aAlgaeBasic, aAlgaeBasic2, aAlgaeGreen, - aAlgaeBrown, aAlgaeGoldenBrown, - aAlgaeRed - }; - - // 20 ticks per second, 60 seconds per minute, 20 minutes per MC day, divide by 24 portions. - int aMinecraftHour = (20 * 60 * 20 / 24); + + }; GT_Recipe tRecipe = new Recipe_GT( false, @@ -574,38 +555,54 @@ public class GregtechMTE_AlgaePondBase extends GregtechMeta_MultiBlockBase { new int[] {}, new FluidStack[] {GT_Values.NF}, new FluidStack[] {GT_Values.NF}, - aMinecraftHour * MathUtils.randInt(24, 72), // Time + (int) (aDurations[aTier] * aOutputTimeMulti.get()), // Time 0, 0); - + + tRecipe.mSpecialValue = tRecipe.hashCode(); return tRecipe; } + private static WeightedCollection generateWeightedCollection(){ + WeightedCollection aCollection = new WeightedCollection(); + + return aCollection; + } + private static final HashMap> mRecipeCache = new HashMap>(); + private static final HashMap> mRecipeCompostCache = new HashMap>(); private final void generateRecipes() { for (int i=0;i<10;i++) { - getTieredRecipeFromCache(i); + getTieredRecipeFromCache(i, false); } - } - - public GT_Recipe getTieredRecipeFromCache(int aTier) { + for (int i=0;i<10;i++) { + getTieredRecipeFromCache(i, true); + } + } + + public GT_Recipe getTieredRecipeFromCache(int aTier, boolean aCompost) { + HashMap> aMap = aCompost ? mRecipeCompostCache : mRecipeCache; + String aComp = aCompost ? "(Compost)" : ""; - AutoMap aTemp = mRecipeCache.get(aTier); + AutoMap aTemp = aMap.get(aTier); if (aTemp == null || aTemp.isEmpty()) { aTemp = new AutoMap(); - mRecipeCache.put(aTier, aTemp); + aMap.put(aTier, aTemp); + Logger.INFO("Tier "+aTier+aComp+" had no recipes, initialising new map."); } if (aTemp.size() < 500) { + Logger.INFO("Tier "+aTier+aComp+" has less than 500 recipes, generating "+(500 - aTemp.size())+"."); for (int i=aTemp.size();i<500;i++) { - aTemp.put(generateAlgaeOutput(false)); + aTemp.put(generateBaseRecipe(aCompost, aTier)); } } int aIndex = MathUtils.randInt(0, aTemp.isEmpty() ? 1 : aTemp.size()); + Logger.INFO("Using recipe with index of "+aIndex+". "+aComp); return aTemp.get(aIndex); } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/GregtechMTE_ChemicalPlant.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/GregtechMTE_ChemicalPlant.java new file mode 100644 index 0000000000..251df46e45 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/GregtechMTE_ChemicalPlant.java @@ -0,0 +1,483 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.chemplant; + +import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.commons.lang3.ArrayUtils; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.TAE; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Recipe; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.util.minecraft.FluidUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import ic2.core.init.BlocksItems; +import ic2.core.init.InternalName; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; + +public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { + + private int mLevel = -1; + + public GregtechMTE_ChemicalPlant(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMTE_ChemicalPlant(final String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMTE_ChemicalPlant(this.mName); + } + + @Override + public String getMachineType() { + return "Chemical Plant"; + } + + @Override + public String[] getTooltip() { + return new String[] { + "Grows Algae!", + "Controller Block for the Algae Farm", + "Size: 9x3x9 [WxHxL] (open)", + "X X", + "X X", + "XXXXXXXXX", + "Can process (Tier * 10) recipes", + "Machine Hulls (all bottom layer)", + "Sterile Farm Casings (all non-hatches)", + "Controller (front centered)", + "All hatches must be on the bottom layer", + "All hulls must be the same tier, this dictates machine speed", + "Does not require power or maintenance", + "1x Output Bus", + "1x Input Bus (optional)", + "1x Input Hatch (fill with water)", + }; + } + + @Override + public String getSound() { + return GregTech_API.sSoundList.get(Integer.valueOf(207)); + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + + int aID = TAE.getIndexFromPage(1, 15); + if (mLevel > -1) { + aID = mLevel; + } + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[aID], new GT_RenderedTexture(aActive ? TexturesGtBlock.Overlay_Machine_Controller_Default_Active : TexturesGtBlock.Overlay_Machine_Controller_Default)}; + } + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[aID]}; + } + + @Override + public boolean hasSlotInGUI() { + return true; + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return null; + } + + @Override + public boolean isFacingValid(final byte aFacing) { + return aFacing > 1; + } + + @Override + public int getMaxParallelRecipes() { + return (this.mLevel+1) * 10; + } + + @Override + public int getEuDiscountForParallelism() { + return 0; + } + + @Override + public boolean checkMultiblock(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack) { + + this.mLevel = 0; + + + // Get Facing direction + int mCurrentDirectionX; + int mCurrentDirectionZ; + + int mOffsetX_Lower = 0; + int mOffsetX_Upper = 0; + int mOffsetZ_Lower = 0; + int mOffsetZ_Upper = 0; + + mCurrentDirectionX = 4; + mCurrentDirectionZ = 4; + + mOffsetX_Lower = -4; + mOffsetX_Upper = 4; + mOffsetZ_Lower = -4; + mOffsetZ_Upper = 4; + + final int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX + * mCurrentDirectionX; + final int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ + * mCurrentDirectionZ; + + // Get Expected Tier + Block aCasingBlock = aBaseMetaTileEntity.getBlockAtSide((byte) 0); + int aCasingMeta = aBaseMetaTileEntity.getMetaIDAtSide((byte) 0); + + // Bad Casings + if ((aCasingBlock != GregTech_API.sBlockCasings1) || aCasingMeta > 9) { + return false; + } + else { + mLevel = aCasingMeta; + } + + + /* + * if (!(aBaseMetaTileEntity.getAirOffset(xDir, 0, zDir))) { return false; } + */ + int tAmount = 0; + check : for (int i = mOffsetX_Lower; i <= mOffsetX_Upper; ++i) { + for (int j = mOffsetZ_Lower; j <= mOffsetZ_Upper; ++j) { + for (int h = -1; h < 2; ++h) { + if ((h != 0) || ((((xDir + i != 0) || (zDir + j != 0))) && (((i != 0) || (j != 0))))) { + IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j); + + Logger.INFO("X: " + i + " | Z: " + j+" | Tier: "+mLevel); + if (h == -1 && tTileEntity != null && addToMachineList(tTileEntity, mLevel)) { + continue; + } + else if (h != -1 && tTileEntity != null) { + Logger.INFO("Found hatch in wrong place, expected casing."); + return false; + } + + Block tBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j); + byte tMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j); + + if ((tBlock == ModBlocks.blockCasings2Misc) && (tMeta == 15) && (h >= 0)) { + ++tAmount; + } + else if ((tBlock == GregTech_API.sBlockCasings1) && (tMeta == mLevel) && (h == -1)) { + ++tAmount; + } + else if ((tBlock == GregTech_API.sBlockCasings1) && (tMeta != mLevel) && (h == -1)) { + Logger.INFO("Found wrong tiered casing."); + return false; + } + else { + if ((i != mOffsetX_Lower && j != mOffsetZ_Lower && i != mOffsetX_Upper + && j != mOffsetZ_Upper) && (h == 0 || h == 1)) { + continue; + } else { + if (tBlock.getLocalizedName().contains("gt.blockmachines") || tBlock == Blocks.water + || tBlock == Blocks.flowing_water + || tBlock == BlocksItems.getFluidBlock(InternalName.fluidDistilledWater)) { + continue; + + } else { + Logger.INFO("[x] Did not form - Found: " + tBlock.getLocalizedName() + " | " + + tBlock.getDamageValue(aBaseMetaTileEntity.getWorld(), + aBaseMetaTileEntity.getXCoord() + i, + aBaseMetaTileEntity.getYCoord(), + aBaseMetaTileEntity.getZCoord() + j) + + " | Special Meta: " + + (tTileEntity == null ? "0" : tTileEntity.getMetaTileID())); + Logger.INFO("[x] Did not form - Found: " + + (aBaseMetaTileEntity.getXCoord() + xDir + i) + " | " + + aBaseMetaTileEntity.getYCoord() + " | " + + (aBaseMetaTileEntity.getZCoord() + zDir + j)); + break check; + } + } + + } + + } + } + } + } + if ((tAmount >= 64)) { + Logger.INFO("Made structure."); + } else { + Logger.INFO("Did not make structure."); + } + return (tAmount >= 64); + } + + public boolean checkForWater() { + + // Get Facing direction + IGregTechTileEntity aBaseMetaTileEntity = this.getBaseMetaTileEntity(); + int mDirectionX = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; + int mCurrentDirectionX; + int mCurrentDirectionZ; + int mOffsetX_Lower = 0; + int mOffsetX_Upper = 0; + int mOffsetZ_Lower = 0; + int mOffsetZ_Upper = 0; + + mCurrentDirectionX = 4; + mCurrentDirectionZ = 4; + + mOffsetX_Lower = -4; + mOffsetX_Upper = 4; + mOffsetZ_Lower = -4; + mOffsetZ_Upper = 4; + + // if (aBaseMetaTileEntity.fac) + + final int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX + * mCurrentDirectionX; + final int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ + * mCurrentDirectionZ; + + int tAmount = 0; + for (int i = mOffsetX_Lower + 1; i <= mOffsetX_Upper - 1; ++i) { + for (int j = mOffsetZ_Lower + 1; j <= mOffsetZ_Upper - 1; ++j) { + for (int h = 0; h < 2; h++) { + Block tBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j); + // byte tMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j); + if (tBlock == Blocks.air || tBlock == Blocks.flowing_water || tBlock == BlocksItems.getFluidBlock(InternalName.fluidDistilledWater)) { + if (this.getStoredFluids() != null) { + for (FluidStack stored : this.getStoredFluids()) { + if (stored.isFluidEqual(FluidUtils.getFluidStack("water", 1))) { + if (stored.amount >= 1000) { + // Utils.LOG_WARNING("Going to try swap an air block for water from inut bus."); + stored.amount -= 1000; + Block fluidUsed = Blocks.water; + aBaseMetaTileEntity.getWorld().setBlock( + aBaseMetaTileEntity.getXCoord() + xDir + i, + aBaseMetaTileEntity.getYCoord() + h, + aBaseMetaTileEntity.getZCoord() + zDir + j, fluidUsed); + + } + } + } + } + } + tBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j); + if (tBlock == Blocks.water || tBlock == Blocks.flowing_water) { + ++tAmount; + // Logger.INFO("Found Water"); + } + } + } + } + + boolean isValidWater = tAmount >= 60; + + if (isValidWater) { + Logger.INFO("Filled structure."); + return true; + } + else { + return false; + } + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(final ItemStack aStack) { + return 0; + } + + @Override + public int getAmountOfOutputs() { + return 1; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + @Override + public String getCustomGUIResourceName() { + return null; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + } + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPreTick(aBaseMetaTileEntity, aTick); + this.fixAllMaintenanceIssue(); + } + + @Override + public boolean checkRecipe(final ItemStack aStack) { + return checkRecipeGeneric(getMaxParallelRecipes(), getEuDiscountForParallelism(), 0); + } + + public boolean checkRecipeGeneric( + ItemStack[] aItemInputs, FluidStack[] aFluidInputs, + int aMaxParallelRecipes, int aEUPercent, + int aSpeedBonusPercent, int aOutputChanceRoll, GT_Recipe aRecipe) { + + if (this.mLevel < 0) { + Logger.INFO("Bad Tier."); + return false; + } + + // Reset outputs and progress stats + this.mEUt = 0; + this.mMaxProgresstime = 0; + this.mOutputItems = new ItemStack[]{}; + this.mOutputFluids = new FluidStack[]{}; + + Logger.INFO("Running checkRecipeGeneric(0)"); + + GT_Recipe tRecipe = null; + + this.mLastRecipe = tRecipe; + + if (tRecipe == null) { + return false; + } + + if (!this.canBufferOutputs(tRecipe, aMaxParallelRecipes)) { + return false; + } + + + // -- Try not to fail after this point - inputs have already been consumed! -- + + + + // Convert speed bonus to duration multiplier + // e.g. 100% speed bonus = 200% speed = 100%/200% = 50% recipe duration. + aSpeedBonusPercent = Math.max(-99, aSpeedBonusPercent); + float tTimeFactor = 100.0f / (100.0f + aSpeedBonusPercent); + this.mMaxProgresstime = (int)(tRecipe.mDuration * tTimeFactor * 24); + + this.mEUt = 0; + + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + + // Overclock + if (this.mEUt <= 16) { + this.mEUt = (this.mEUt * (1 << mLevel - 1) * (1 << mLevel - 1)); + this.mMaxProgresstime = (this.mMaxProgresstime / (1 << mLevel - 1)); + } else { + while (this.mEUt <= gregtech.api.enums.GT_Values.V[(mLevel - 1)]) { + this.mEUt *= 4; + this.mMaxProgresstime /= 2; + } + } + + if (this.mEUt > 0) { + this.mEUt = (-this.mEUt); + } + + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + + // Collect fluid outputs + FluidStack[] tOutputFluids = new FluidStack[tRecipe.mFluidOutputs.length]; + for (int h = 0; h < tRecipe.mFluidOutputs.length; h++) { + if (tRecipe.getFluidOutput(h) != null) { + tOutputFluids[h] = tRecipe.getFluidOutput(h).copy(); + tOutputFluids[h].amount *= aMaxParallelRecipes; + } + } + + // Collect output item types + ItemStack[] tOutputItems = new ItemStack[tRecipe.mOutputs.length]; + for (int h = 0; h < tRecipe.mOutputs.length; h++) { + if (tRecipe.getOutput(h) != null) { + tOutputItems[h] = tRecipe.getOutput(h).copy(); + tOutputItems[h].stackSize = 0; + } + } + + // Set output item stack sizes (taking output chance into account) + for (int f = 0; f < tOutputItems.length; f++) { + if (tRecipe.mOutputs[f] != null && tOutputItems[f] != null) { + for (int g = 0; g < aMaxParallelRecipes; g++) { + if (getBaseMetaTileEntity().getRandomNumber(aOutputChanceRoll) < tRecipe.getOutputChance(f)) + tOutputItems[f].stackSize += tRecipe.mOutputs[f].stackSize; + } + } + } + + tOutputItems = removeNulls(tOutputItems); + + // Sanitize item stack size, splitting any stacks greater than max stack size + List splitStacks = new ArrayList(); + for (ItemStack tItem : tOutputItems) { + while (tItem.getMaxStackSize() < tItem.stackSize) { + ItemStack tmp = tItem.copy(); + tmp.stackSize = tmp.getMaxStackSize(); + tItem.stackSize = tItem.stackSize - tItem.getMaxStackSize(); + splitStacks.add(tmp); + } + } + + if (splitStacks.size() > 0) { + ItemStack[] tmp = new ItemStack[splitStacks.size()]; + tmp = splitStacks.toArray(tmp); + tOutputItems = ArrayUtils.addAll(tOutputItems, tmp); + } + + // Strip empty stacks + List tSList = new ArrayList(); + for (ItemStack tS : tOutputItems) { + if (tS.stackSize > 0) tSList.add(tS); + } + tOutputItems = tSList.toArray(new ItemStack[tSList.size()]); + + // Commit outputs + this.mOutputItems = tOutputItems; + this.mOutputFluids = tOutputFluids; + updateSlots(); + + // Play sounds (GT++ addition - GT multiblocks play no sounds) + startProcess(); + + Logger.INFO("GOOD RETURN - 1"); + return true; + + } + + + + + + + + + + + +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechAlgaeContent.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechAlgaeContent.java index 57a726f7e8..2c9f1d1943 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechAlgaeContent.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechAlgaeContent.java @@ -4,6 +4,7 @@ import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.algae.GregtechMTE_AlgaePondBase; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.chemplant.GregtechMTE_ChemicalPlant; public class GregtechAlgaeContent { @@ -15,10 +16,13 @@ public class GregtechAlgaeContent { } private static void run1() { - // Industrial Centrifuge Multiblock - GregtechItemList.AlgaeFarm_Controller.set( - new GregtechMTE_AlgaePondBase(997, "algaefarm.controller.tier.single", "Algae Farm").getStackForm(1L)); + + // Algae Pond + GregtechItemList.AlgaeFarm_Controller.set(new GregtechMTE_AlgaePondBase(997, "algaefarm.controller.tier.single", "Algae Farm").getStackForm(1L)); + // Chemical Plant + GregtechItemList.ChemicalPlant_Controller.set(new GregtechMTE_ChemicalPlant(998, "chemicalplant.controller.tier.single", "ExxonMobil Chemical Plant").getStackForm(1L)); + } } -- cgit From 2525ff075586759657e89b9f01969f0596bca2df Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Tue, 10 Dec 2019 11:01:32 +0000 Subject: % Changed name of custom GT++ Programmed Circuit to Programmed Bio Circuit. $ Fixed getNumberedBioCircuit() in CI. $ Fixed an issue where stripped fields were referenced in server side bytecode. $ Fixed Tooltips not working as intended for items giving custom GT++ Multi behaviour. $ Fixed 'No Bonus Output Chance' item not registering correctly. --- src/Java/gtPlusPlus/api/helpers/GregtechPlusPlus_API.java | 5 ++++- .../objects/minecraft/multi/NoOutputBonusMultiBehaviour.java | 3 +-- .../core/block/base/BasicTileBlockWithTooltip.java | 12 +++++++++--- src/Java/gtPlusPlus/core/recipe/common/CI.java | 3 ++- src/Java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java | 5 +++++ .../implementations/base/GregtechMeta_MultiBlockBase.java | 7 +------ .../gregtech/api/util/SpecialBehaviourTooltipHandler.java | 12 +++++++++--- .../multi/production/algae/GregtechMTE_AlgaePondBase.java | 9 +++++++-- src/resources/assets/miscutils/lang/en_US.lang | 2 +- 9 files changed, 39 insertions(+), 19 deletions(-) (limited to 'src/Java/gtPlusPlus/api/objects') diff --git a/src/Java/gtPlusPlus/api/helpers/GregtechPlusPlus_API.java b/src/Java/gtPlusPlus/api/helpers/GregtechPlusPlus_API.java index 9816d45bbf..3acca269d7 100644 --- a/src/Java/gtPlusPlus/api/helpers/GregtechPlusPlus_API.java +++ b/src/Java/gtPlusPlus/api/helpers/GregtechPlusPlus_API.java @@ -2,6 +2,7 @@ package gtPlusPlus.api.helpers; import java.util.HashMap; +import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.WeightedCollection; import gtPlusPlus.api.objects.minecraft.multi.SpecialMultiBehaviour; import gtPlusPlus.core.util.minecraft.ItemUtils; @@ -26,10 +27,12 @@ public class GregtechPlusPlus_API { */ public static boolean registerSpecialMultiBehaviour(SpecialMultiBehaviour aBehaviour) { if (aBehaviour.getTriggerItem() == null || aBehaviour.getTriggerItemTooltip() == null || aBehaviour.getTriggerItemTooltip().length() <= 0) { + Logger.INFO("Failed to attach custom multiblock logic to "+ItemUtils.getItemName(aBehaviour.getTriggerItem())); return false; } mSpecialBehaviourItemMap.put("UniqueKey_"+aBehaviour.hashCode(), aBehaviour); - SpecialBehaviourTooltipHandler.addTooltipForItem(aBehaviour.getTriggerItem(), aBehaviour.getTriggerItemTooltip()); + SpecialBehaviourTooltipHandler.addTooltipForItem(aBehaviour.getTriggerItem(), aBehaviour.getTriggerItemTooltip()); + Logger.INFO("Attached custom multiblock logic to "+ItemUtils.getItemName(aBehaviour.getTriggerItem())); return true; } diff --git a/src/Java/gtPlusPlus/api/objects/minecraft/multi/NoOutputBonusMultiBehaviour.java b/src/Java/gtPlusPlus/api/objects/minecraft/multi/NoOutputBonusMultiBehaviour.java index 871b42b901..0769d0a473 100644 --- a/src/Java/gtPlusPlus/api/objects/minecraft/multi/NoOutputBonusMultiBehaviour.java +++ b/src/Java/gtPlusPlus/api/objects/minecraft/multi/NoOutputBonusMultiBehaviour.java @@ -1,13 +1,12 @@ package gtPlusPlus.api.objects.minecraft.multi; -import gtPlusPlus.api.helpers.GregtechPlusPlus_API.Multiblock_API; import gtPlusPlus.core.recipe.common.CI; import net.minecraft.item.ItemStack; public class NoOutputBonusMultiBehaviour extends SpecialMultiBehaviour { public NoOutputBonusMultiBehaviour() { - Multiblock_API.registerSpecialMultiBehaviour(this); + } @Override diff --git a/src/Java/gtPlusPlus/core/block/base/BasicTileBlockWithTooltip.java b/src/Java/gtPlusPlus/core/block/base/BasicTileBlockWithTooltip.java index 098b670509..6166835f31 100644 --- a/src/Java/gtPlusPlus/core/block/base/BasicTileBlockWithTooltip.java +++ b/src/Java/gtPlusPlus/core/block/base/BasicTileBlockWithTooltip.java @@ -33,13 +33,13 @@ public abstract class BasicTileBlockWithTooltip extends BlockContainer implement * Each mapped object holds the data for the six sides. */ @SideOnly(Side.CLIENT) - private AutoMap> mSidedTextureArray = new AutoMap>(); + private AutoMap> mSidedTextureArray; /** * Holds the data for the six sides, each side holds an array of data for each respective meta. */ @SideOnly(Side.CLIENT) - private AutoMap> mSidedTexturePathArray = new AutoMap>(); + private AutoMap> mSidedTexturePathArray; /** * Does this block have any meta at all? @@ -157,7 +157,13 @@ public abstract class BasicTileBlockWithTooltip extends BlockContainer implement @SideOnly(Side.CLIENT) private final void handleTextures() { - Logger.INFO("[TeTexture] Building Texture Maps for "+getTileEntityName()+"."); + Logger.INFO("[TeTexture] Building Texture Maps for "+getTileEntityName()+"."); + + // Init on the Client side only, to prevent Field initialisers existing in the Server side bytecode. + mSidedTextureArray = new AutoMap>(); + mSidedTexturePathArray = new AutoMap>(); + + //Store them in forge order //DOWN, UP, NORTH, SOUTH, WEST, EAST diff --git a/src/Java/gtPlusPlus/core/recipe/common/CI.java b/src/Java/gtPlusPlus/core/recipe/common/CI.java index ce5587ef33..be1089a72a 100644 --- a/src/Java/gtPlusPlus/core/recipe/common/CI.java +++ b/src/Java/gtPlusPlus/core/recipe/common/CI.java @@ -6,6 +6,7 @@ import gregtech.api.enums.OrePrefixes; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Utility; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.item.chemistry.AgriculturalChem; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.material.ALLOY; @@ -1240,7 +1241,7 @@ public class CI { } public static ItemStack getNumberedBioCircuit(int i) { - return GregtechItemList.Circuit_BioRecipeSelector.getWithDamage(i, 0L); + return ItemUtils.simpleMetaStack(AgriculturalChem.mBioCircuit, i, 0); } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java b/src/Java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java index 42354e49e1..fd4659c543 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java @@ -19,9 +19,11 @@ import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gregtech.api.util.GT_Utility; import gregtech.common.items.GT_MetaGenerated_Tool_01; +import gtPlusPlus.api.helpers.GregtechPlusPlus_API.Multiblock_API; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.api.objects.data.Pair; +import gtPlusPlus.api.objects.minecraft.multi.NoOutputBonusMultiBehaviour; import gtPlusPlus.australia.gen.gt.WorldGen_GT_Australia; import gtPlusPlus.core.handler.COMPAT_HANDLER; import gtPlusPlus.core.handler.OldCircuitHandler; @@ -123,6 +125,9 @@ public class HANDLER_GT { } + // Register the No-Bonus Special Behaviour. + Multiblock_API.registerSpecialMultiBehaviour(new NoOutputBonusMultiBehaviour()); + //Register some custom recipe maps for any enabled multiblocks. //MultiblockRecipeMapHandler.run(); } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java index 89c1112726..55378113d9 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java @@ -100,12 +100,7 @@ public abstract class GregtechMeta_MultiBlockBase extends GT_MetaTileEntity_Mult try { calculatePollutionReduction = GT_MetaTileEntity_Hatch_Muffler.class.getDeclaredMethod("calculatePollutionReduction", int.class); - } catch (NoSuchMethodException | SecurityException e) {} - - - // Register the No-Bonus Special Behaviour. - new NoOutputBonusMultiBehaviour(); - + } catch (NoSuchMethodException | SecurityException e) {} } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/util/SpecialBehaviourTooltipHandler.java b/src/Java/gtPlusPlus/xmod/gregtech/api/util/SpecialBehaviourTooltipHandler.java index f345a67db6..74655fb744 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/util/SpecialBehaviourTooltipHandler.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/util/SpecialBehaviourTooltipHandler.java @@ -3,7 +3,9 @@ package gtPlusPlus.xmod.gregtech.api.util; import java.util.HashMap; import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import gregtech.api.util.GT_Utility; import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.event.entity.player.ItemTooltipEvent; public class SpecialBehaviourTooltipHandler { @@ -18,9 +20,13 @@ public class SpecialBehaviourTooltipHandler { public void onItemTooltip(ItemTooltipEvent event){ if (event != null) { if (event.itemStack != null) { - String s = mTooltipCache.get(event.itemStack); - if (s != null && s.length() > 0) { - event.toolTip.add(s); + for (ItemStack aKey : mTooltipCache.keySet()) { + if (GT_Utility.areStacksEqual(aKey, event.itemStack, false)) { + String s = mTooltipCache.get(aKey); + if (s != null && s.length() > 0) { + event.toolTip.add(EnumChatFormatting.RED+s); + } + } } } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/algae/GregtechMTE_AlgaePondBase.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/algae/GregtechMTE_AlgaePondBase.java index 38c80ce8c4..81afe2b147 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/algae/GregtechMTE_AlgaePondBase.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/algae/GregtechMTE_AlgaePondBase.java @@ -564,10 +564,15 @@ public class GregtechMTE_AlgaePondBase extends GregtechMeta_MultiBlockBase { return tRecipe; } - private static WeightedCollection generateWeightedCollection(){ + private static ItemStack[] getOutputForTier(int aTier){ + ItemStack[] aOutputs = new ItemStack[16]; + + + + WeightedCollection aCollection = new WeightedCollection(); - return aCollection; + return aOutputs; } diff --git a/src/resources/assets/miscutils/lang/en_US.lang b/src/resources/assets/miscutils/lang/en_US.lang index 394680edd8..ad10be2d8b 100644 --- a/src/resources/assets/miscutils/lang/en_US.lang +++ b/src/resources/assets/miscutils/lang/en_US.lang @@ -3039,7 +3039,7 @@ tile.blockRoundRobinator.4.name=Round Robinator V //Added 16/10/19 -item.BioRecipeSelector.name=Programmed Circuit +item.BioRecipeSelector.name=Programmed Bio Circuit item.FermentationBase.name=Cell of Fermentation Base item.ureamix.name=Cell of Urea Mix item.liquidresin.name=Cell of Liquid Resin -- cgit From 162a990fe4a1cb9cbc18e011e4d69fc4da0693b6 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Tue, 10 Dec 2019 11:18:44 +0000 Subject: + Added support for Bio Circuits to Circuit Slots and the Circuit Programmer. --- .../multi/NoOutputBonusMultiBehaviour.java | 2 +- .../inventories/InventoryCircuitProgrammer.java | 4 +- .../core/slots/SlotIntegratedCircuit.java | 49 +++++++++++++++++++--- .../general/TileEntityCircuitProgrammer.java | 33 ++++++++++----- .../base/GregtechMeta_MultiBlockBase.java | 1 - 5 files changed, 70 insertions(+), 19 deletions(-) (limited to 'src/Java/gtPlusPlus/api/objects') diff --git a/src/Java/gtPlusPlus/api/objects/minecraft/multi/NoOutputBonusMultiBehaviour.java b/src/Java/gtPlusPlus/api/objects/minecraft/multi/NoOutputBonusMultiBehaviour.java index 0769d0a473..4dc032d01f 100644 --- a/src/Java/gtPlusPlus/api/objects/minecraft/multi/NoOutputBonusMultiBehaviour.java +++ b/src/Java/gtPlusPlus/api/objects/minecraft/multi/NoOutputBonusMultiBehaviour.java @@ -6,7 +6,7 @@ import net.minecraft.item.ItemStack; public class NoOutputBonusMultiBehaviour extends SpecialMultiBehaviour { public NoOutputBonusMultiBehaviour() { - + // Used by other mods which may wish to not obtain bonus outputs on their Sifting or Maceration recipes. } @Override diff --git a/src/Java/gtPlusPlus/core/inventories/InventoryCircuitProgrammer.java b/src/Java/gtPlusPlus/core/inventories/InventoryCircuitProgrammer.java index 4cdbb72c6e..da45b5a988 100644 --- a/src/Java/gtPlusPlus/core/inventories/InventoryCircuitProgrammer.java +++ b/src/Java/gtPlusPlus/core/inventories/InventoryCircuitProgrammer.java @@ -1,6 +1,6 @@ package gtPlusPlus.core.inventories; -import gtPlusPlus.core.recipe.common.CI; +import gtPlusPlus.core.slots.SlotIntegratedCircuit; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; @@ -167,7 +167,7 @@ public class InventoryCircuitProgrammer implements IInventory{ */ @Override public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) { - return (itemstack.getItem() == CI.getNumberedCircuit(0).getItem()); + return SlotIntegratedCircuit.isItemValidForSlot(itemstack); } } \ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/slots/SlotIntegratedCircuit.java b/src/Java/gtPlusPlus/core/slots/SlotIntegratedCircuit.java index c41a385c4b..48b050d678 100644 --- a/src/Java/gtPlusPlus/core/slots/SlotIntegratedCircuit.java +++ b/src/Java/gtPlusPlus/core/slots/SlotIntegratedCircuit.java @@ -10,12 +10,13 @@ import gtPlusPlus.core.recipe.common.CI; public class SlotIntegratedCircuit extends Slot { public static Item mCircuitItem; + public static Item mCircuitItem2; private final short mCircuitLock; public SlotIntegratedCircuit(final IInventory inventory, final int slot, final int x, final int y) { this(Short.MAX_VALUE+1, inventory, slot, x, y); } - + public SlotIntegratedCircuit(int mTypeLock, final IInventory inventory, final int slot, final int x, final int y) { super(inventory, slot, x, y); if (mTypeLock > Short.MAX_VALUE || mTypeLock < Short.MIN_VALUE) { @@ -28,18 +29,29 @@ public class SlotIntegratedCircuit extends Slot { @Override public synchronized boolean isItemValid(final ItemStack itemstack) { + return isItemValidForSlot(mCircuitLock, itemstack); + } + + public static synchronized boolean isItemValidForSlot(final ItemStack itemstack) { + return isItemValidForSlot(-1, itemstack); + } + + public static synchronized boolean isItemValidForSlot(int aLockedCircuitNumber, final ItemStack itemstack) { boolean isValid = false; if (mCircuitItem == null) { mCircuitItem = CI.getNumberedCircuit(0).getItem(); } - if (mCircuitItem != null) { + if (mCircuitItem2 == null) { + mCircuitItem2 = CI.getNumberedBioCircuit(0).getItem(); + } + if (mCircuitItem != null && mCircuitItem2 != null) { if (itemstack != null) { - if (itemstack.getItem() == mCircuitItem) { - if (mCircuitLock == -1) { + if (itemstack.getItem() == mCircuitItem || itemstack.getItem() == mCircuitItem2) { + if (aLockedCircuitNumber == -1) { isValid = true; } else { - if (itemstack.getItemDamage() == mCircuitLock) { + if (itemstack.getItemDamage() == aLockedCircuitNumber) { isValid = true; } } @@ -49,6 +61,33 @@ public class SlotIntegratedCircuit extends Slot { return isValid; } + /** + * Returns the circuit type. -1 is invalid, 0 is standard, 1 is GT++ bio. + * @param itemstack - the Circuit Stack. + * @return + */ + public static synchronized int isRegularProgrammableCircuit(final ItemStack itemstack) { + if (mCircuitItem == null) { + mCircuitItem = CI.getNumberedCircuit(0).getItem(); + } + if (mCircuitItem2 == null) { + mCircuitItem2 = CI.getNumberedBioCircuit(0).getItem(); + } + if (mCircuitItem != null && mCircuitItem2 != null) { + if (itemstack != null) { + if (itemstack.getItem() == mCircuitItem || itemstack.getItem() == mCircuitItem2) { + if (itemstack.getItem() == mCircuitItem) { + return 0; + } + else if (itemstack.getItem() == mCircuitItem2) { + return 1; + } + } + } + } + return -1; + } + @Override public int getSlotStackLimit() { return 64; diff --git a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityCircuitProgrammer.java b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityCircuitProgrammer.java index 0157384cd0..23ad2a3233 100644 --- a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityCircuitProgrammer.java +++ b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityCircuitProgrammer.java @@ -11,6 +11,7 @@ import net.minecraft.tileentity.TileEntity; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.core.inventories.InventoryCircuitProgrammer; import gtPlusPlus.core.recipe.common.CI; +import gtPlusPlus.core.slots.SlotIntegratedCircuit; import gtPlusPlus.core.util.minecraft.PlayerUtils; public class TileEntityCircuitProgrammer extends TileEntity implements ISidedInventory { @@ -76,16 +77,21 @@ public class TileEntityCircuitProgrammer extends TileEntity implements ISidedInv boolean doAdd = false; ItemStack g = this.getStackInSlot(e); int aSize = 0; - ItemStack aInputStack = null; - if (g != null) { + ItemStack aInputStack = null; + int aTypeInSlot = SlotIntegratedCircuit.isRegularProgrammableCircuit(g); + if (aTypeInSlot >= 0 && g != null) { + // No Existing Output if (!hasOutput) { aSize = g.stackSize; doAdd = true; } + // Existing Output else { ItemStack f = this.getStackInSlot(25); - if (f != null) { - if (f.getItemDamage() == e) { + int aTypeInCheckedSlot = SlotIntegratedCircuit.isRegularProgrammableCircuit(f); + // Check that the Circuit in the Output slot is not null and the same type as the circuit input. + if (aTypeInCheckedSlot >= 0 && (aTypeInSlot == aTypeInCheckedSlot) && f != null) { + if (g.getItem() == f.getItem() && f.getItemDamage() == e) { aSize = f.stackSize + g.stackSize; if (aSize > 64) { aInputStack = g.copy(); @@ -93,14 +99,21 @@ public class TileEntityCircuitProgrammer extends TileEntity implements ISidedInv } doAdd = true; } - } - else { - doAdd = true; - aSize = g.stackSize; } } - if (doAdd) { - ItemStack aOutput = CI.getNumberedCircuit(e); + if (doAdd) { + // Check Circuit Type + ItemStack aOutput; + if (aTypeInSlot == 0) { + aOutput = CI.getNumberedCircuit(e); + } + else if (aTypeInSlot == 1) { + aOutput = CI.getNumberedBioCircuit(e); + } + else { + aOutput = null; + } + if (aOutput != null) { aOutput.stackSize = aSize; this.setInventorySlotContents(e, aInputStack); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java index 55378113d9..fe9e3ee9a0 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java @@ -49,7 +49,6 @@ import gtPlusPlus.api.objects.data.ConcurrentSet; import gtPlusPlus.api.objects.data.FlexiblePair; import gtPlusPlus.api.objects.data.Triplet; import gtPlusPlus.api.objects.minecraft.BlockPos; -import gtPlusPlus.api.objects.minecraft.multi.NoOutputBonusMultiBehaviour; import gtPlusPlus.api.objects.minecraft.multi.SpecialMultiBehaviour; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.lib.LoadedMods; -- cgit