diff options
author | Draknyte1 <Draknyte1@hotmail.com> | 2016-06-02 00:13:32 +1000 |
---|---|---|
committer | Draknyte1 <Draknyte1@hotmail.com> | 2016-06-02 00:13:32 +1000 |
commit | ecff67654aac93b33907a0784d9c0b88648cfd1a (patch) | |
tree | 728ab9131bacd866313c65c37e3f37a53e73520a /src | |
parent | e6d4747d4cb4e648f2b6f8f88ad0aceca59d3d8b (diff) | |
download | GT5-Unofficial-ecff67654aac93b33907a0784d9c0b88648cfd1a.tar.gz GT5-Unofficial-ecff67654aac93b33907a0784d9c0b88648cfd1a.tar.bz2 GT5-Unofficial-ecff67654aac93b33907a0784d9c0b88648cfd1a.zip |
~Changed Coke Oven Recipes
~Cleaned up a handful of classes (ModItems.java, RECIPES_Machines.java, Utils.java & UtilsItems.java)
+Added a handful of DEBUG classes (To resolve multiblock shaping issues)
+Added GregtechMetaTileEntityIndustrialPlatePress.java
+Added textures for itemStickyRubber, itemIngotBatteryAlloy & itemPlateBatteryAlloy.
+Added a basic wrapper for direct MineTweaker script usage (Ultra W.I.P.)
>This will probably be changed to preload .zs scripts, regex and handle appropriately, but undecided.
Diffstat (limited to 'src')
25 files changed, 1903 insertions, 197 deletions
diff --git a/src/Java/miscutil/MiscUtils.java b/src/Java/miscutil/MiscUtils.java index 2b286a28b3..2ddd6bf8cb 100644 --- a/src/Java/miscutil/MiscUtils.java +++ b/src/Java/miscutil/MiscUtils.java @@ -12,7 +12,7 @@ import miscutil.core.lib.CORE; import miscutil.core.lib.LoadedMods; import miscutil.core.util.PlayerCache; import miscutil.core.util.Utils; -import miscutil.core.util.debug.DEBUG_ScreenOverlay; +import miscutil.core.util.debug.DEBUG_INIT; import miscutil.gregtech.common.GregtechRecipeAdder; import net.minecraftforge.common.MinecraftForge; import cpw.mods.fml.common.FMLCommonHandler; @@ -29,7 +29,7 @@ import cpw.mods.fml.common.event.FMLServerStoppingEvent; public class MiscUtils implements ActionListener { - + @Mod.Instance(CORE.MODID) public static MiscUtils instance; @@ -43,15 +43,15 @@ implements ActionListener { LoadedMods.checkLoaded(); Utils.LOG_INFO("Doing some house cleaning."); - + if (LoadedMods.Gregtech){ try { CORE.sRecipeAdder = CORE.RA = new GregtechRecipeAdder(); } catch (NullPointerException e){ - + } } - + AddToCreativeTab.initialiseTabs(); proxy.registerTileEntities(); proxy.registerRenderThings(); @@ -65,8 +65,9 @@ implements ActionListener proxy.init(event); MinecraftForge.EVENT_BUS.register(this); MinecraftForge.EVENT_BUS.register(new PickaxeBlockBreakEventHandler()); + //Debug Loading if (CORE.DEBUG){ - MinecraftForge.EVENT_BUS.register(new DEBUG_ScreenOverlay()); + DEBUG_INIT.registerHandlers(); } FMLCommonHandler.instance().bus().register(this); proxy.registerNetworkStuff(); @@ -79,7 +80,7 @@ implements ActionListener COMPAT_HANDLER.ServerStartedEvent(); PlayerCache.initCache(); proxy.postInit(event); - + } @EventHandler diff --git a/src/Java/miscutil/core/handler/registration/RECIPES_GREGTECH.java b/src/Java/miscutil/core/handler/registration/RECIPES_GREGTECH.java index f433632163..75ea04e1e6 100644 --- a/src/Java/miscutil/core/handler/registration/RECIPES_GREGTECH.java +++ b/src/Java/miscutil/core/handler/registration/RECIPES_GREGTECH.java @@ -43,7 +43,7 @@ public class RECIPES_GREGTECH { CORE.RA.addCokeOvenRecipe( GT_OreDictUnificator.get(OrePrefixes.gem, Materials.Coal, 2L), //Input 1 GT_OreDictUnificator.get(OrePrefixes.gem, Materials.Coal, 1L), //Input 2 - Materials.SulfuricAcid.getFluid(80L), //Fluid Input + Materials.SulfuricAcid.getFluid(60L), //Fluid Input Materials.Creosote.getFluid(250L), //Fluid Output UtilsItems.getItemStack("Railcraft:fuel.coke", 2), //Item Output 600, //Time in ticks @@ -56,7 +56,7 @@ public class RECIPES_GREGTECH { CORE.RA.addCokeOvenRecipe( GT_OreDictUnificator.get(OrePrefixes.log, Materials.Wood, 2L), //Input 1 GT_OreDictUnificator.get(OrePrefixes.log, Materials.Wood, 1L), //Input 2 - Materials.Water.getFluid(160L), //Fluid Input + Materials.SaltWater.getFluid(85L), //Fluid Input Materials.Creosote.getFluid(145L), //Fluid Output GT_OreDictUnificator.get(OrePrefixes.gem, Materials.Charcoal, 2L), //Item Output 1200, //Time in ticks @@ -69,7 +69,7 @@ public class RECIPES_GREGTECH { CORE.RA.addCokeOvenRecipe( GT_OreDictUnificator.get(OrePrefixes.gem, Materials.Coal, 2L), //Input 1 GT_OreDictUnificator.get(OrePrefixes.gem, Materials.Coal, 1L), //Input 2 - null, //Fluid Input + Materials.SaltWater.getFluid(185L), //Fluid Input Materials.Creosote.getFluid(200L), //Fluid Output UtilsItems.getItemStack("Railcraft:fuel.coke", 2), //Item Output 900, //Time in ticks diff --git a/src/Java/miscutil/core/handler/registration/RECIPES_MTWRAPPER.java b/src/Java/miscutil/core/handler/registration/RECIPES_MTWRAPPER.java new file mode 100644 index 0000000000..16ba377b07 --- /dev/null +++ b/src/Java/miscutil/core/handler/registration/RECIPES_MTWRAPPER.java @@ -0,0 +1,113 @@ +package miscutil.core.handler.registration; + +import java.util.ArrayList; + +import miscutil.core.util.Utils; +import miscutil.core.util.UtilsItems; +import miscutil.core.util.wrapper.var; +import net.minecraft.item.ItemStack; + +public class RECIPES_MTWRAPPER { + + public static int MT_RECIPES_LOADED = 0; + public static int MT_RECIPES_FAILED = 0; + + static var chestWood = new var("minecraft:chest>"); + static var slabWood = new var("ore:slabWood>"); + static var gemNetherQuartz = new var("ore:gemNetherQuartz>"); + static var glass = new var("ore:blockGlass>"); + static var sensorDaylight = new var("minecraft:daylight_detector>"); + static var blazeRod = new var("minecraft:blaze_rod>"); + static var saw = new var("ore:craftingToolSaw>"); + static var logWood = new var("ore:logWood>"); + static var button = new var("minecraft:stone_button>"); + static var stoneBlock = new var("minecraft:stone>"); + + public static void run(){ + /*addShaped(button.getStack(2), + null, stoneBlock, null, + null, stoneBlock, null, + null, null, null);*/ + /*addShaped(stoneStick.getStack(1), + stoneBlock, null, null, + stoneBlock, null, null, + null, null, null);*/ + addShaped(chestWood.getStack(2), + logWood, logWood, logWood, + logWood, null, logWood, + logWood, logWood, logWood); + addShaped(chestWood.getStack(4), + logWood, logWood, logWood, + logWood, saw, logWood, + logWood, logWood, logWood); + //Recipe Fixes + //remove(sensorDaylight); + addShaped(sensorDaylight.getStack(1), + glass, glass, glass, + gemNetherQuartz, gemNetherQuartz, gemNetherQuartz, + slabWood, slabWood, slabWood); + /*addShaped(ironBars .getStack( 8), + null, "<ore:craftingToolWrench>", null, + "<ore:stickAnyIron>", "<ore:stickAnyIron>", "<ore:stickAnyIron>", + "<ore:stickAnyIron>", "<ore:stickAnyIron>", "<ore:stickAnyIron>");*/ + } + + + public static void addShaped(Object item_Output, + Object item_1, Object item_2, Object item_3, + Object item_4, Object item_5, Object item_6, + Object item_7, Object item_8, Object item_9){ + + + /* + * + * var item_1, var item_2, var item_3, + var item_4, var item_5, var item_6, + var item_7, var item_8, var item_9 + * + * + */ + + ItemStack outputItem = UtilsItems.getCorrectStacktype(item_Output, 1); + + ArrayList<Object> validSlots = new ArrayList<Object>(); + String a,b,c,d,e,f,g,h,i; + if (item_1 == null){ a = " ";} else { a = "1";validSlots.add('1');validSlots.add(item_1);} + if (item_2 == null){ b = " ";} else { b = "2";validSlots.add('2');validSlots.add(item_2);} + if (item_3 == null){ c = " ";} else { c = "3";validSlots.add('3');validSlots.add(item_3);} + if (item_4 == null){ d = " ";} else { d = "4";validSlots.add('4');validSlots.add(item_4);} + if (item_5 == null){ e = " ";} else { e = "5";validSlots.add('5');validSlots.add(item_5);} + if (item_6 == null){ f = " ";} else { f = "6";validSlots.add('6');validSlots.add(item_6);} + if (item_7 == null){ g = " ";} else { g = "7";validSlots.add('7');validSlots.add(item_7);} + if (item_8 == null){ h = " ";} else { h = "8";validSlots.add('8');validSlots.add(item_8);} + if (item_9 == null){ i = " ";} else { i = "9";validSlots.add('9');validSlots.add(item_9);} + + String lineOne = a+b+c; + String lineTwo = d+e+f; + String lineThree = g+h+i; + validSlots.add(0, lineOne); + validSlots.add(1, lineTwo); + validSlots.add(2, lineThree); + + try { + UtilsItems.recipeBuilder((Object[]) validSlots.toArray(), outputItem.copy()); + MT_RECIPES_LOADED++; + } + catch(NullPointerException | ClassCastException k){ + k.getMessage(); + k.getClass(); + k.printStackTrace(); + k.getLocalizedMessage(); + Utils.LOG_WARNING("@@@: Invalid Recipe detected for: "+((var) item_Output).getsanitizedName()); + MT_RECIPES_FAILED++; + } + } + + public static void addShapeless(){ + + } + + + +} + diff --git a/src/Java/miscutil/core/handler/registration/RECIPES_Machines.java b/src/Java/miscutil/core/handler/registration/RECIPES_Machines.java index 995a77f6c8..dc544be0fb 100644 --- a/src/Java/miscutil/core/handler/registration/RECIPES_Machines.java +++ b/src/Java/miscutil/core/handler/registration/RECIPES_Machines.java @@ -1,6 +1,7 @@ package miscutil.core.handler.registration; import gregtech.api.enums.ItemList; +import miscutil.core.lib.LoadedMods; import miscutil.core.util.Utils; import miscutil.core.util.UtilsItems; import miscutil.gregtech.api.enums.GregtechItemList; @@ -23,9 +24,14 @@ public class RECIPES_Machines { static ItemStack RECIPE_Buffer_ZPM = GregtechItemList.Energy_Buffer_1by1_ZPM.get(1); static ItemStack RECIPE_Buffer_UV = GregtechItemList.Energy_Buffer_1by1_UV.get(1); static ItemStack RECIPE_Buffer_MAX = GregtechItemList.Energy_Buffer_1by1_MAX.get(1); - static ItemStack RECIPE_IndustrialCentrifuge = GregtechItemList.Industrial_Centrifuge.get(1); + //Industrial Centrifuge + static ItemStack RECIPE_IndustrialCentrifugeController = GregtechItemList.Industrial_Centrifuge.get(1); static ItemStack RECIPE_IndustrialCentrifugeCasing = GregtechItemList.Casing_Centrifuge1.get(1); + //Industrial Coke Oven + static ItemStack RECIPE_IndustrialCokeOvenController = GregtechItemList.Industrial_CokeOven.get(1); static ItemStack RECIPE_IndustrialCokeOvenFrame = GregtechItemList.Casing_CokeOven.get(1); + static ItemStack RECIPE_IndustrialCokeOvenCasingA = GregtechItemList.Casing_CokeOven_Coil1.get(1); + static ItemStack RECIPE_IndustrialCokeOvenCasingB = GregtechItemList.Casing_CokeOven_Coil2.get(1); //Buffer Cores @@ -79,6 +85,19 @@ public class RECIPES_Machines { static String plateTier10 = "plateNaquadah"; static String plateTier11 = "plateNeutronium"; + //rods + static String rodTier1 = "stickLead"; + static String rodTier2 = "stickTin"; + static String rodTier3 = "stickCopper"; + static String rodTier4 = "stickGold"; + static String rodTier5 = "stickAluminium"; + static String rodTier6 = "stickThorium"; + static String rodTier7 = "stickTungsten"; + static String rodTier8 = "stickTungstenSteel"; + static String rodTier9 = "stickOsmium"; + static String rodTier10 = "stickNaquadah"; + static String rodTier11 = "stickNeutronium"; + //Machine Casings static ItemStack machineCasing_ULV = ItemList.Casing_ULV.get(1); @@ -91,6 +110,12 @@ public class RECIPES_Machines { static ItemStack machineCasing_ZPM = ItemList.Casing_ZPM.get(1); static ItemStack machineCasing_UV = ItemList.Casing_UV.get(1); static ItemStack machineCasing_MAX = ItemList.Casing_MAX.get(1); + + //Gearbox Casings + static ItemStack gearboxCasing_Tier_1 = ItemList.Casing_Gearbox_Bronze.get(1); + static ItemStack gearboxCasing_Tier_2 = ItemList.Casing_Gearbox_Steel.get(1); + static ItemStack gearboxCasing_Tier_3 = ItemList.Casing_Gearbox_Titanium.get(1); + static ItemStack gearboxCasing_Tier_4 = ItemList.Casing_Gearbox_TungstenSteel.get(1); //Cables static String cableGt02Electrum = "cableGt02Electrum"; @@ -99,6 +124,9 @@ public class RECIPES_Machines { //Plates static String plateElectricalSteel= "plateElectricalSteel"; static String plateEnergeticAlloy= "plateEnergeticAlloy"; + static String plateCobalt = "plateCobalt"; + static String plateBronze = "plateBronze"; + static String plateSteel = "plateSteel"; //Pipes static String pipeLargeCopper="pipeLargeCopper"; @@ -126,7 +154,7 @@ public class RECIPES_Machines { static String circuitElite = "circuitElite"; static String circuitMaster = "circuitMaster"; static String circuitUltimate = "circuitUltimate"; - + //Machine Components static ItemStack electricMotor_LV = ItemList.Electric_Motor_LV.get(1); static ItemStack electricMotor_MV = ItemList.Electric_Motor_MV.get(1); @@ -169,8 +197,11 @@ public class RECIPES_Machines { static ItemStack sensor_EV = ItemList.Sensor_EV.get(1); static ItemStack sensor_IV = ItemList.Sensor_IV.get(1); - - + //Misc + static ItemStack INPUT_RCCokeOvenBlock = UtilsItems.getItemStackWithMeta(LoadedMods.Railcraft, "Railcraft:machine.alpha", "Coke_Oven_RC", 7, 1); + + + //RobotArm, Conveyor, Emitter, Sensor, Field Generator @@ -328,23 +359,70 @@ public class RECIPES_Machines { "plateAnyIron", RECIPES_Tools.craftingToolWrench, "plateAnyIron", RECIPE_IronPlatedBricks); - - - + + + //Industrial Centrifuge UtilsItems.recipeBuilder( circuitElite, pipeHugeStainlessSteel, circuitElite, plateTier6, electricPump_EV, plateTier6, plateTier8, machineCasing_EV, plateTier8, - RECIPE_IndustrialCentrifuge); + RECIPE_IndustrialCentrifugeController); - //Steam Condenser + //Centrifuge Casing UtilsItems.recipeBuilder( plateTier6, "stickElectrum", plateTier6, plateTier8, "stickElectrum", plateTier8, plateTier6, "stickElectrum", plateTier6, RECIPE_IndustrialCentrifugeCasing); + //Industrial Coke Oven + UtilsItems.recipeBuilder( + plateCobalt, circuitAdvanced, plateCobalt, + machineCasing_HV, INPUT_RCCokeOvenBlock, machineCasing_HV, + plateCobalt, circuitAdvanced, plateCobalt, + RECIPE_IndustrialCokeOvenController); + + //Coke Oven Frame Casing + UtilsItems.recipeBuilder( + plateTier8, rodTier8, plateTier8, + rodTier8, "frameGtCobalt", rodTier8, + plateTier8, rodTier8, plateTier8, + RECIPE_IndustrialCokeOvenFrame); + + //Coke Oven Coil 1 + UtilsItems.recipeBuilder( + plateBronze, plateBronze, plateBronze, + "frameGtBronze", gearboxCasing_Tier_1, "frameGtBronze", + plateBronze, plateBronze, plateBronze, + RECIPE_IndustrialCokeOvenCasingA); + + //Coke Oven Coil 2 + UtilsItems.recipeBuilder( + plateSteel, plateSteel, plateSteel, + "frameGtSteel", gearboxCasing_Tier_2, "frameGtSteel", + plateSteel, plateSteel, plateSteel, + RECIPE_IndustrialCokeOvenCasingB); + + + + + + + + + + + + + + + + + + + + Utils.LOG_INFO("Done loading recipes for the Various machine blocks."); diff --git a/src/Java/miscutil/core/handler/registration/RECIPES_Shapeless.java b/src/Java/miscutil/core/handler/registration/RECIPES_Shapeless.java new file mode 100644 index 0000000000..c249bb9d77 --- /dev/null +++ b/src/Java/miscutil/core/handler/registration/RECIPES_Shapeless.java @@ -0,0 +1,41 @@ +package miscutil.core.handler.registration; + +import gregtech.api.enums.ItemList; +import miscutil.core.lib.LoadedMods; +import miscutil.core.util.Utils; +import miscutil.core.util.UtilsItems; +import net.minecraft.item.ItemStack; + +public class RECIPES_Shapeless { + + static ItemStack dustStaballoy = UtilsItems.getItemStackWithMeta(LoadedMods.Gregtech, "gregtech:gt.metaitem.01", "Staballoy Dust", 2319, 1); + + //Circuits + static String circuitPrimitive = "circuitPrimitive"; + static String circuitBasic = "circuitBasic"; + static String circuitGood = "circuitGood"; + static String circuitAdvanced = "circuitAdvanced"; + static String circuitData = "circuitData"; + static String circuitElite = "circuitElite"; + static String circuitMaster = "circuitMaster"; + static String circuitUltimate = "circuitUltimate"; + static ItemStack gearboxCasing_Tier_1 = ItemList.Casing_Gearbox_Bronze.get(1); + + public static final void RECIPES_LOAD(){ + run(); + Utils.LOG_INFO("Loading Shapeless Recipes."); + } + + private static void run(){ + UtilsItems.shapelessBuilder(dustStaballoy, + "dustTitanium", "dustUranium", "dustUranium", + "dustUranium", "dustUranium", "dustUranium", + "dustUranium", "dustUranium", "dustUranium"); + + UtilsItems.shapelessBuilder(gearboxCasing_Tier_1, + circuitPrimitive, circuitPrimitive, circuitPrimitive, + circuitPrimitive, circuitPrimitive, circuitPrimitive, + circuitPrimitive, circuitPrimitive, circuitPrimitive); + } + +} diff --git a/src/Java/miscutil/core/handler/registration/RegistrationHandler.java b/src/Java/miscutil/core/handler/registration/RegistrationHandler.java index 8c66bb1cc9..9f100117fc 100644 --- a/src/Java/miscutil/core/handler/registration/RegistrationHandler.java +++ b/src/Java/miscutil/core/handler/registration/RegistrationHandler.java @@ -14,12 +14,15 @@ public class RegistrationHandler { private final static void init(){ RECIPES_Tools.RECIPES_LOAD(); RECIPES_Machines.RECIPES_LOAD(); + RECIPES_Shapeless.RECIPES_LOAD(); + //RECIPES_MTWRAPPER.run(); try { Thread.sleep(10); } catch (InterruptedException e) { Utils.LOG_INFO(e.toString()); } Utils.LOG_INFO("Loaded: "+recipesSuccess+" Failed: "+recipesFailed); + Utils.LOG_INFO("MT Loaded: "+RECIPES_MTWRAPPER.MT_RECIPES_LOADED+" MT Failed: "+RECIPES_MTWRAPPER.MT_RECIPES_FAILED); } } diff --git a/src/Java/miscutil/core/item/ModItems.java b/src/Java/miscutil/core/item/ModItems.java index 49abc71cbc..e704ac0365 100644 --- a/src/Java/miscutil/core/item/ModItems.java +++ b/src/Java/miscutil/core/item/ModItems.java @@ -10,6 +10,7 @@ import miscutil.core.item.tool.staballoy.StaballoyPickaxe; import miscutil.core.lib.CORE; import miscutil.core.lib.LoadedMods; import miscutil.core.util.Utils; +import miscutil.core.util.debug.DEBUG_INIT; import net.minecraft.item.Item; import net.minecraft.item.Item.ToolMaterial; import net.minecraftforge.common.util.EnumHelper; @@ -54,6 +55,8 @@ Gold Tool: 22*/ //public static ToolMaterial TUTORIAL = EnumHelper.addToolMaterial("TUTORIAL", harvestLevel, durability, miningSpeed, damageVsEntities, enchantability); public static ToolMaterial STABALLOY = EnumHelper.addToolMaterial("Staballoy", 3, 2500, 7, 1.0F, 18); + public static Item itemDebugShapeSpawner; + //EnderIO public static Item itemPlateSoularium; public static Item itemPlateRedstoneAlloy; @@ -97,6 +100,11 @@ Gold Tool: 22*/ public static Item item_PLEASE_FACTOR_ME_4; //@SuppressWarnings("unused") public static final void init(){ + + //Debug Loading + if (CORE.DEBUG){ + DEBUG_INIT.registerItems(); + } //EnderIO Resources if (LoadedMods.EnderIO || LOAD_ALL_CONTENT){ @@ -231,16 +239,17 @@ Gold Tool: 22*/ System.out.println("Buffer Core registration count is: "+i); } //Dev Items - itemStickyRubber = new Item().setUnlocalizedName("itemStickyRubber").setCreativeTab(tabMisc).setTextureName(CORE.MODID + ":itemDefault"); + itemStickyRubber = new Item().setUnlocalizedName("itemStickyRubber").setCreativeTab(tabMisc).setTextureName(CORE.MODID + ":itemStickyRubber"); GameRegistry.registerItem(itemStickyRubber, "itemStickyRubber"); //Battery Alloy For cheap Niggers - itemIngotBatteryAlloy = new Item().setUnlocalizedName("itemIngotBatteryAlloy").setCreativeTab(tabMisc).setTextureName(CORE.MODID + ":itemDefault"); + itemIngotBatteryAlloy = new Item().setUnlocalizedName("itemIngotBatteryAlloy").setCreativeTab(tabMisc).setTextureName(CORE.MODID + ":itemIngotBatteryAlloy"); GameRegistry.registerItem(itemIngotBatteryAlloy, "itemIngotBatteryAlloy"); - itemPlateBatteryAlloy = new Item().setUnlocalizedName("itemPlateBatteryAlloy").setCreativeTab(tabMisc).setTextureName(CORE.MODID + ":itemDefault"); + itemPlateBatteryAlloy = new Item().setUnlocalizedName("itemPlateBatteryAlloy").setCreativeTab(tabMisc).setTextureName(CORE.MODID + ":itemPlateBatteryAlloy"); GameRegistry.registerItem(itemPlateBatteryAlloy, "itemPlateBatteryAlloy"); itemHeliumBlob = new Item().setUnlocalizedName("itemHeliumBlob").setCreativeTab(tabMisc).setTextureName(CORE.MODID + ":itemHeliumBlob"); GameRegistry.registerItem(itemHeliumBlob, "itemHeliumBlob"); + /* item_PLEASE_FACTOR_ME_4 = new Item().setUnlocalizedName("unlocalName4").setCreativeTab(tabMisc).setTextureName(CORE.MODID + ":itemDefault"); GameRegistry.registerItem(item_PLEASE_FACTOR_ME_4, "localName4");*/ diff --git a/src/Java/miscutil/core/item/base/BaseItemGeneric.java b/src/Java/miscutil/core/item/base/BaseItemGeneric.java index 55d98528ce..56b9c9d7fe 100644 --- a/src/Java/miscutil/core/item/base/BaseItemGeneric.java +++ b/src/Java/miscutil/core/item/base/BaseItemGeneric.java @@ -1,18 +1,29 @@ package miscutil.core.item.base; +import java.util.List; + import miscutil.core.lib.CORE; import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; -@Deprecated public class BaseItemGeneric extends Item { - public BaseItemGeneric(String s, CreativeTabs c, int stackSize, int maxDmg) + public BaseItemGeneric(String unlocalizedName, CreativeTabs c, int stackSize, int maxDmg) { - setUnlocalizedName(CORE.MODID + "_" + s); - setTextureName(CORE.MODID + ":" + s); + setUnlocalizedName(CORE.MODID + "_" + unlocalizedName); + setTextureName(CORE.MODID + ":" + unlocalizedName); setCreativeTab(c); setMaxStackSize(stackSize); setMaxDamage(maxDmg); } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + list.add(EnumChatFormatting.GOLD+""); + super.addInformation(stack, aPlayer, list, bool); + } }
\ No newline at end of file diff --git a/src/Java/miscutil/core/lib/CORE.java b/src/Java/miscutil/core/lib/CORE.java index 3f38cd9180..f2be1776bd 100644 --- a/src/Java/miscutil/core/lib/CORE.java +++ b/src/Java/miscutil/core/lib/CORE.java @@ -15,7 +15,7 @@ public class CORE { public static final String name = "Misc. Utils"; public static final String MODID = "miscutils"; public static final String VERSION = "1.0.4"; - public static final boolean DEBUG = false; + public static final boolean DEBUG = true; public static final boolean LOAD_ALL_CONTENT = false; public static final int GREG_FIRST_ID = 760; public static Map PlayerCache; diff --git a/src/Java/miscutil/core/lib/LoadedMods.java b/src/Java/miscutil/core/lib/LoadedMods.java index 394f96a6fc..896108052c 100644 --- a/src/Java/miscutil/core/lib/LoadedMods.java +++ b/src/Java/miscutil/core/lib/LoadedMods.java @@ -5,6 +5,7 @@ import cpw.mods.fml.common.Loader; public class LoadedMods { + //Initialize Variables public static boolean Gregtech = false; public static boolean EnderIO = false; @@ -18,6 +19,8 @@ public class LoadedMods { public static boolean MorePlanets = false; public static boolean ForbiddenMagic = false; public static boolean CompactWindmills = false; + public static boolean Railcraft = false; + public static boolean MiscUtils = true; //Dummy For MetaData Lookups in MT Wrapper private static int totalMods; @@ -71,6 +74,10 @@ public class LoadedMods { CompactWindmills = true; totalMods++; } + if (Loader.isModLoaded("Railcraft") == true){ + Railcraft = true; + totalMods++; + } Utils.LOG_INFO("Content found for "+totalMods+" mods"); diff --git a/src/Java/miscutil/core/util/Utils.java b/src/Java/miscutil/core/util/Utils.java index 4e303c8e39..37a4b5bb56 100644 --- a/src/Java/miscutil/core/util/Utils.java +++ b/src/Java/miscutil/core/util/Utils.java @@ -5,6 +5,8 @@ import static gregtech.api.enums.GT_Values.F; import java.awt.Color; import java.awt.Graphics; import java.util.Random; +import java.util.Timer; +import java.util.TimerTask; import miscutil.core.lib.CORE; import net.minecraft.block.Block; @@ -18,6 +20,13 @@ import cpw.mods.fml.common.FMLLog; public class Utils { public static final int WILDCARD_VALUE = Short.MAX_VALUE; + + static class ShortTimerTask extends TimerTask { + @Override + public void run() { + Utils.LOG_WARNING("Timer expired."); + } + } /** * Returns a psuedo-random number between min and max, inclusive. @@ -193,4 +202,15 @@ public class Utils { double f = i + 273.15F; return (int)decimalRoundingToWholes(f); } + + public static Timer ShortTimer(int seconds) { + Timer timer; + timer = new Timer(); + timer.schedule(new ShortTimerTask(), seconds * 1000); + return timer; + } + + } + + diff --git a/src/Java/miscutil/core/util/UtilsItems.java b/src/Java/miscutil/core/util/UtilsItems.java index c2bf2823fc..d939f2a9bc 100644 --- a/src/Java/miscutil/core/util/UtilsItems.java +++ b/src/Java/miscutil/core/util/UtilsItems.java @@ -7,12 +7,16 @@ import java.util.Iterator; import java.util.List; import miscutil.core.handler.registration.RegistrationHandler; +import miscutil.core.lib.CORE; +import miscutil.core.lib.LoadedMods; +import miscutil.core.util.wrapper.var; import net.minecraft.client.Minecraft; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.CraftingManager; import net.minecraft.item.crafting.IRecipe; import net.minecraftforge.oredict.ShapedOreRecipe; +import net.minecraftforge.oredict.ShapelessOreRecipe; import cpw.mods.fml.common.registry.GameRegistry; public class UtilsItems { @@ -44,16 +48,16 @@ public class UtilsItems { } return null; } - + public static ItemStack getSimpleStack(Item x){ try { - ItemStack r = new ItemStack(x, 1); - return r; + ItemStack r = new ItemStack(x, 1); + return r; } catch(Throwable e){ return null; } } - + public static void getItemForOreDict(String FQRN, String oreDictName, String itemName, int meta){ try { @@ -76,14 +80,64 @@ public class UtilsItems { } } + @SuppressWarnings("unused") + public static ItemStack getItemStackWithMeta(boolean MOD, String FQRN, String itemName, int meta, int itemstackSize){ + if (MOD){ + try { + Item em = null; + Item em1 = getItem(FQRN); + Utils.LOG_WARNING("Found: "+em1.getUnlocalizedName()+":"+meta); + if (em1 != null){ + if (null == em){ + em = em1; + } + if (em != null){ + ItemStack metaStack = new ItemStack(em,itemstackSize,meta); + return metaStack; + } + } + return null; + } catch (NullPointerException e) { + Utils.LOG_ERROR(itemName+" not found. [NULL]"); + return null; + } + } + return null; + } + + public static ItemStack getCorrectStacktype(String fqrn, int stackSize){ + String oreDict = "ore:"; + ItemStack temp; + if (fqrn.toLowerCase().contains(oreDict.toLowerCase())){ + String sanitizedName = fqrn.replace(oreDict, ""); + temp = UtilsItems.getItemStack(sanitizedName, stackSize); + return temp; + } + String[] fqrnSplit = fqrn.split(":"); + if(fqrnSplit[2] == null){fqrnSplit[2] = "0";} + temp = UtilsItems.getItemStackWithMeta(LoadedMods.MiscUtils, fqrn, fqrnSplit[1], Integer.parseInt(fqrnSplit[2]), stackSize); + return temp; + } + + public static ItemStack getCorrectStacktype(Object item_Input, int stackSize) { + if (item_Input instanceof String){ + return getCorrectStacktype(item_Input, stackSize); + } + else if (item_Input instanceof ItemStack){ + return (ItemStack) item_Input; + } + if (item_Input instanceof var){ + return ((var) item_Input).getStack(stackSize); + } + return null; + } + public static void recipeBuilder(Object slot_1, Object slot_2, Object slot_3, Object slot_4, Object slot_5, Object slot_6, Object slot_7, Object slot_8, Object slot_9, ItemStack resultItem){ ArrayList<Object> validSlots = new ArrayList<Object>(); - //, String lineFirst, String lineSecond, String lineThird Utils.LOG_INFO("Trying to add a recipe for "+resultItem.toString()); - String a,b,c,d,e,f,g,h,i; - //ItemStack empty = new ItemStack(Blocks.air); + String a,b,c,d,e,f,g,h,i; if (slot_1 == null){ a = " ";} else { a = "1";validSlots.add('1');validSlots.add(slot_1);} Utils.LOG_WARNING(a); if (slot_2 == null){ b = " ";} else { b = "2";validSlots.add('2');validSlots.add(slot_2);} @@ -118,8 +172,11 @@ public class UtilsItems { validSlots.add(0, lineOne); validSlots.add(1, lineTwo); validSlots.add(2, lineThree); - Boolean AadvancedLog = true; - if (AadvancedLog){ + boolean advancedLog = false; + if (CORE.DEBUG){ + advancedLog = true; + } + if (advancedLog){ int j = 0; int l = validSlots.size(); Utils.LOG_WARNING("l:"+l); @@ -152,40 +209,9 @@ public class UtilsItems { } try { - /*Utils.LOG_WARNING("validSlots to array: "+validSlots.toArray()); - Object[] validSlotsArray = (Object[]) validSlots.toArray(); - - for(int j = 0; j < validSlotsArray.length; j++) - { - Utils.LOG_ERROR(""+validSlotsArray[j]); - }*/ - GameRegistry.addRecipe(new ShapedOreRecipe(resultItem.copy(), (Object[]) validSlots.toArray())); Utils.LOG_INFO("Success! Added a recipe for "+resultItem.toString()); - RegistrationHandler.recipesSuccess++; - /*try { - try { - try { - //Code - } - catch (NullPointerException | ClassCastException r){ - Utils.LOG_WARNING("@@@: Invalid Recipe detected for: "+resultItem.getUnlocalizedName()); - RegistrationHandler.recipesFailed++; - r.printStackTrace(); - //System.exit(1); - } - } - catch (NullPointerException o){ - - Utils.LOG_WARNING("@@@: Invalid Recipe detected for: "+resultItem.getUnlocalizedName()); - o.printStackTrace(); - RegistrationHandler.recipesFailed++; - //System.exit(1); - } - } - catch (ClassCastException r){ - Utils.LOG_WARNING("@@@: Casting to ObjectArray Failed :("); - }*/ + RegistrationHandler.recipesSuccess++; } catch(NullPointerException | ClassCastException k){ k.getMessage(); @@ -194,10 +220,71 @@ public class UtilsItems { k.getLocalizedMessage(); Utils.LOG_WARNING("@@@: Invalid Recipe detected for: "+resultItem.getUnlocalizedName()); RegistrationHandler.recipesFailed++; - //System.exit(1); } } + public static void shapelessBuilder(ItemStack Output, Object slot_1, Object slot_2, Object slot_3, Object slot_4, Object slot_5, Object slot_6, Object slot_7, Object slot_8, Object slot_9){ + //Item output_ITEM = Output.getItem(); + + ArrayList<Object> validSlots = new ArrayList<Object>(); + + Utils.LOG_INFO("Trying to add a recipe for "+Output.toString()); + String a,b,c,d,e,f,g,h,i; + if (slot_1 == null){ a = " ";} else { a = "1";validSlots.add('1');validSlots.add(slot_1);} + Utils.LOG_WARNING(a); + if (slot_2 == null){ b = " ";} else { b = "2";validSlots.add('2');validSlots.add(slot_2);} + Utils.LOG_WARNING(b); + if (slot_3 == null){ c = " ";} else { c = "3";validSlots.add('3');validSlots.add(slot_3);} + Utils.LOG_WARNING(c); + if (slot_4 == null){ d = " ";} else { d = "4";validSlots.add('4');validSlots.add(slot_4);} + Utils.LOG_WARNING(d); + if (slot_5 == null){ e = " ";} else { e = "5";validSlots.add('5');validSlots.add(slot_5);} + Utils.LOG_WARNING(e); + if (slot_6 == null){ f = " ";} else { f = "6";validSlots.add('6');validSlots.add(slot_6);} + Utils.LOG_WARNING(f); + if (slot_7 == null){ g = " ";} else { g = "7";validSlots.add('7');validSlots.add(slot_7);} + Utils.LOG_WARNING(g); + if (slot_8 == null){ h = " ";} else { h = "8";validSlots.add('8');validSlots.add(slot_8);} + Utils.LOG_WARNING(h); + if (slot_9 == null){ i = " ";} else { i = "9";validSlots.add('9');validSlots.add(slot_9);} + Utils.LOG_WARNING(i); + + + Utils.LOG_ERROR("_______"); + String lineOne = a+b+c; + Utils.LOG_ERROR("|"+a+"|"+b+"|"+c+"|"); + Utils.LOG_ERROR("_______"); + String lineTwo = d+e+f; + Utils.LOG_ERROR("|"+d+"|"+e+"|"+f+"|"); + Utils.LOG_ERROR("_______"); + String lineThree = g+h+i; + Utils.LOG_ERROR("|"+g+"|"+h+"|"+i+"|"); + Utils.LOG_ERROR("_______"); + + validSlots.add(0, lineOne); + validSlots.add(1, lineTwo); + validSlots.add(2, lineThree); + + try { + //GameRegistry.addRecipe(new ShapelessOreRecipe(Output, outputAmount), (Object[]) validSlots.toArray()); + GameRegistry.addRecipe(new ShapelessOreRecipe(Output, (Object[]) validSlots.toArray())); + //GameRegistry.addShapelessRecipe(new ItemStack(output_ITEM, 1), new Object[] {slot_1, slot_2}); + Utils.LOG_INFO("Success! Added a recipe for "+Output.toString()); + RegistrationHandler.recipesSuccess++; + } + catch(RuntimeException k){ + k.getMessage(); + k.getClass(); + k.printStackTrace(); + k.getLocalizedMessage(); + Utils.LOG_WARNING("@@@: Invalid Recipe detected for: "+Output.getUnlocalizedName()); + RegistrationHandler.recipesFailed++; + } + + + //GameRegistry.addShapelessRecipe(new ItemStack(output_ITEM, 1), new Object[] {slot_1, slot_2}); + } + public static Item getItem(String fqrn) // fqrn = fully qualified resource name { String[] fqrnSplit = fqrn.split(":"); @@ -209,14 +296,14 @@ public class UtilsItems { String[] fqrnSplit = fqrn.split(":"); return GameRegistry.findItemStack(fqrnSplit[0], fqrnSplit[1], Size); } - + // TODO /*public static FluidStack getFluidStack(Materials m, int Size) // fqrn = fully qualified resource name { String[] fqrnSplit = fqrn.split(":"); - + FluidStack x = (FluidStack) "Materials."+m+".getFluid"(Size); - + return GameRegistry.findItemStack(fqrnSplit[0], fqrnSplit[1], Size); }*/ @@ -304,4 +391,53 @@ public class UtilsItems { Utils.LOG_INFO("Return false, because something went wrong."); return false; } + + public static void recipeBuilder(Object[] array, ItemStack outPut) { + Object a=null; + Object b=null; + Object c=null; + Object d=null; + Object e=null; + Object f=null; + Object g=null; + Object h=null; + Object i=null; + for(int z =0; z < array.length; z++){ + array[z].toString(); + switch(z) + { + case 0: + a = array[z]; + break; + case 1: + b = array[z]; + break; + case 2: + c = array[z]; + break; + case 3: + d = array[z]; + break; + case 4: + e = array[z]; + break; + case 5: + f = array[z]; + break; + case 6: + g = array[z]; + break; + case 7: + h = array[z]; + break; + case 8: + i = array[z]; + break; + default: + break; + } + recipeBuilder(a, b, c, d, e, f, g, h, i, outPut); + } + } + } diff --git a/src/Java/miscutil/core/util/debug/DEBUG_BLOCK_ShapeSpawner.java b/src/Java/miscutil/core/util/debug/DEBUG_BLOCK_ShapeSpawner.java new file mode 100644 index 0000000000..2c39fe0917 --- /dev/null +++ b/src/Java/miscutil/core/util/debug/DEBUG_BLOCK_ShapeSpawner.java @@ -0,0 +1,139 @@ +package miscutil.core.util.debug; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import miscutil.core.util.Utils; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; + +public class DEBUG_BLOCK_ShapeSpawner extends DEBUG_MULTIBLOCK_ShapeSpawner { + + private static boolean controller; + + public DEBUG_BLOCK_ShapeSpawner(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public DEBUG_BLOCK_ShapeSpawner(String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new DEBUG_BLOCK_ShapeSpawner(this.mName); + } + + + public String[] getDescription() { + return new String[]{ + "Controller Block for the Testing", + "Create the shapes for Multiblocks.",}; + } + + + @Override + public ITexture[] getTexture(IGregTechTileEntity arg0, byte arg1, + byte arg2, byte arg3, boolean arg4, boolean arg5) { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean isCorrectMachinePart(ItemStack aStack) { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean checkRecipe(ItemStack aStack) { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + + int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; + int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; + + if (!aBaseMetaTileEntity.getAirOffset(xDir, 0, zDir)) { + return false; + } + + int stepX = aBaseMetaTileEntity.getXCoord(); + int stepY = aBaseMetaTileEntity.getYCoord(); + int stepZ = aBaseMetaTileEntity.getZCoord(); + int temp = 0; + + Utils.LOG_INFO("Starting Block located @ "+"[X:"+stepX+"][Y:"+stepY+"][Z:"+stepZ+"]"); + + int tAmount = 0; + switch (xDir) { + case -1: + stepX++; + Utils.LOG_INFO("Modifying stepX + accomodate a "+xDir+" xDir - [X:"+stepX+"][Y:"+stepY+"][Z:"+stepZ+"]"); + break; + + case 1: + stepX--; + Utils.LOG_INFO("Modifying stepX - accomodate a "+xDir+" xDir - [X:"+stepX+"][Y:"+stepY+"][Z:"+stepZ+"]"); + break; + } + switch (zDir) { + case -1: + stepZ++; + Utils.LOG_INFO("Modifying stepZ + accomodate a "+zDir+" zDir - [X:"+stepX+"][Y:"+stepY+"][Z:"+stepZ+"]"); + break; + + case 1: + stepZ--; + Utils.LOG_INFO("Modifying stepZ - accomodate a "+zDir+" zDir - [X:"+stepX+"][Y:"+stepY+"][Z:"+stepZ+"]"); + break; + } + + for (int i = stepX-1; i <= stepX+1; i++){ + for (int j = stepZ-1; j <= stepZ+1; j++){ + for (int h = stepY-1; h <= stepY+1; h++){ + + + Utils.LOG_INFO("Block Facing - X:"+xDir+" Z:"+zDir); + Utils.LOG_INFO("(h != 0) || (((xDir + i != 0) || (zDir + j != 0)) && ((i != 0) || (j != 0)))"); + Utils.LOG_INFO(" "+(h != 0)+" || "+(((xDir + i != 0)+" || "+(zDir + j != 0))+" && "+((i != 0)+" || "+(j != 0)))); + } + } + } + return false; + } + + @Override + public int getMaxEfficiency(ItemStack aStack) { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getPollutionPerTick(ItemStack aStack) { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getDamageToComponent(ItemStack aStack) { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getAmountOfOutputs() { + // TODO Auto-generated method stub + return 0; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) { + // TODO Auto-generated method stub + return false; + } + +} diff --git a/src/Java/miscutil/core/util/debug/DEBUG_INIT.java b/src/Java/miscutil/core/util/debug/DEBUG_INIT.java new file mode 100644 index 0000000000..7b83137860 --- /dev/null +++ b/src/Java/miscutil/core/util/debug/DEBUG_INIT.java @@ -0,0 +1,37 @@ +package miscutil.core.util.debug; + +import miscutil.core.creative.AddToCreativeTab; +import miscutil.core.item.ModItems; +import miscutil.core.lib.CORE; +import net.minecraftforge.common.MinecraftForge; +import cpw.mods.fml.common.registry.GameRegistry; + +public class DEBUG_INIT { + + public static void registerBlocks(){ + //Debug Loading + if (CORE.DEBUG){ + + } + } + + public static void registerItems(){ + ModItems.itemDebugShapeSpawner = new DEBUG_ITEM_ShapeSpawner("itemDebugShapeSpawner", AddToCreativeTab.tabMisc, 1, 500); + GameRegistry.registerItem(ModItems.itemDebugShapeSpawner, "itemDebugShapeSpawner"); + } + + public static void registerTEs(){ + + } + + public static void registerMisc(){ + + + + } + + public static void registerHandlers(){ + MinecraftForge.EVENT_BUS.register(new DEBUG_ScreenOverlay()); + } + +} diff --git a/src/Java/miscutil/core/util/debug/DEBUG_ITEM_ShapeSpawner.java b/src/Java/miscutil/core/util/debug/DEBUG_ITEM_ShapeSpawner.java new file mode 100644 index 0000000000..47bf9977ff --- /dev/null +++ b/src/Java/miscutil/core/util/debug/DEBUG_ITEM_ShapeSpawner.java @@ -0,0 +1,55 @@ +package miscutil.core.util.debug; + +import static net.minecraftforge.event.entity.player.PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK; + +import java.util.List; + +import miscutil.core.creative.AddToCreativeTab; +import miscutil.core.item.base.BaseItemGeneric; +import miscutil.core.util.Utils; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; +import net.minecraftforge.event.entity.player.PlayerInteractEvent; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; + +public class DEBUG_ITEM_ShapeSpawner extends BaseItemGeneric{ + + public DEBUG_ITEM_ShapeSpawner(String s, CreativeTabs c, int stackSize, int maxDmg) { + super(s, c, stackSize, maxDmg); + s = "itemDebugShapeSpawner"; + c = AddToCreativeTab.tabMisc; + stackSize = 1; + maxDmg = 500; + } + + @Override + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player){ + + if (!world.isRemote){ + Utils.LOG_INFO("Constructing the shape for the "+"VACUUM FREEZER"); + Thread thread = new Thread(new DEBUG_TimerThread(world, player)); + thread.start(); + } + return stack; + } + + + + @SuppressWarnings("static-method") + @SubscribeEvent + public void playerInteractEventHandler(PlayerInteractEvent event) + { + if (event.isCanceled() || event.world.isRemote || event.action != RIGHT_CLICK_BLOCK) return; + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + list.add(EnumChatFormatting.GOLD+"For Testing Gregtech Shapes!"); + super.addInformation(stack, aPlayer, list, bool); + } + +} diff --git a/src/Java/miscutil/core/util/debug/DEBUG_MULTIBLOCK_ShapeSpawner.java b/src/Java/miscutil/core/util/debug/DEBUG_MULTIBLOCK_ShapeSpawner.java new file mode 100644 index 0000000000..b81a08ecf6 --- /dev/null +++ b/src/Java/miscutil/core/util/debug/DEBUG_MULTIBLOCK_ShapeSpawner.java @@ -0,0 +1,805 @@ +package miscutil.core.util.debug; + +import static gregtech.api.enums.GT_Values.V; +import gregtech.GT_Mod; +import gregtech.api.GregTech_API; +import gregtech.api.enums.ConfigCategories; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.gui.GT_Container_MultiMachine; +import gregtech.api.gui.GT_GUIContainer_MultiMachine; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.items.GT_MetaGenerated_Tool; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Dynamo; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Maintenance; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Muffler; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_OutputBus; +import gregtech.api.objects.GT_ItemStack; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gregtech.api.util.GT_Utility; +import gregtech.common.items.GT_MetaGenerated_Tool_01; + +import java.util.ArrayList; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.fluids.FluidStack; + +public abstract class DEBUG_MULTIBLOCK_ShapeSpawner extends MetaTileEntity { + + public static boolean disableMaintenance; + public boolean mMachine = false, mWrench = false, mScrewdriver = false, mSoftHammer = false, mHardHammer = false, mSolderingTool = false, mCrowbar = false, mRunningOnLoad = false; + public int mPollution = 0, mProgresstime = 0, mMaxProgresstime = 0, mEUt = 0, mEfficiencyIncrease = 0, mUpdate = 0, mStartUpCheck = 100, mRuntime = 0, mEfficiency = 0; + public ItemStack[] mOutputItems = null; + public FluidStack[] mOutputFluids = null; + public ArrayList<GT_MetaTileEntity_Hatch_Input> mInputHatches = new ArrayList<GT_MetaTileEntity_Hatch_Input>(); + public ArrayList<GT_MetaTileEntity_Hatch_Output> mOutputHatches = new ArrayList<GT_MetaTileEntity_Hatch_Output>(); + public ArrayList<GT_MetaTileEntity_Hatch_InputBus> mInputBusses = new ArrayList<GT_MetaTileEntity_Hatch_InputBus>(); + public ArrayList<GT_MetaTileEntity_Hatch_OutputBus> mOutputBusses = new ArrayList<GT_MetaTileEntity_Hatch_OutputBus>(); + public ArrayList<GT_MetaTileEntity_Hatch_Dynamo> mDynamoHatches = new ArrayList<GT_MetaTileEntity_Hatch_Dynamo>(); + public ArrayList<GT_MetaTileEntity_Hatch_Muffler> mMufflerHatches = new ArrayList<GT_MetaTileEntity_Hatch_Muffler>(); + public ArrayList<GT_MetaTileEntity_Hatch_Energy> mEnergyHatches = new ArrayList<GT_MetaTileEntity_Hatch_Energy>(); + public ArrayList<GT_MetaTileEntity_Hatch_Maintenance> mMaintenanceHatches = new ArrayList<GT_MetaTileEntity_Hatch_Maintenance>(); + + public DEBUG_MULTIBLOCK_ShapeSpawner(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional, 2); + this.disableMaintenance = GregTech_API.sMachineFile.get(ConfigCategories.machineconfig, "MultiBlockMachines.disableMaintenance", false); + } + + public DEBUG_MULTIBLOCK_ShapeSpawner(String aName) { + super(aName, 2); + this.disableMaintenance = GregTech_API.sMachineFile.get(ConfigCategories.machineconfig, "MultiBlockMachines.disableMaintenance", false); + } + + public static boolean isValidMetaTileEntity(MetaTileEntity aMetaTileEntity) { + return aMetaTileEntity.getBaseMetaTileEntity() != null && aMetaTileEntity.getBaseMetaTileEntity().getMetaTileEntity() == aMetaTileEntity && !aMetaTileEntity.getBaseMetaTileEntity().isDead(); + } + + @Override + public boolean allowCoverOnSide(byte aSide, GT_ItemStack aCoverID) { + return aSide != getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public boolean isSimpleMachine() { + return false; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return true; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean isValidSlot(int aIndex) { + return aIndex > 0; + } + + @Override + public int getProgresstime() { + return mProgresstime; + } + + @Override + public int maxProgresstime() { + return mMaxProgresstime; + } + + @Override + public int increaseProgress(int aProgress) { + return aProgress; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setInteger("mEUt", mEUt); + aNBT.setInteger("mProgresstime", mProgresstime); + aNBT.setInteger("mMaxProgresstime", mMaxProgresstime); + aNBT.setInteger("mEfficiencyIncrease", mEfficiencyIncrease); + aNBT.setInteger("mEfficiency", mEfficiency); + aNBT.setInteger("mPollution", mPollution); + aNBT.setInteger("mRuntime", mRuntime); + + if (mOutputItems != null) for (int i = 0; i < mOutputItems.length; i++) + if (mOutputItems[i] != null) { + NBTTagCompound tNBT = new NBTTagCompound(); + mOutputItems[i].writeToNBT(tNBT); + aNBT.setTag("mOutputItem" + i, tNBT); + } + if (mOutputFluids != null) for (int i = 0; i < mOutputFluids.length; i++) + if (mOutputFluids[i] != null) { + NBTTagCompound tNBT = new NBTTagCompound(); + mOutputFluids[i].writeToNBT(tNBT); + aNBT.setTag("mOutputFluids" + i, tNBT); + } + + aNBT.setBoolean("mWrench", mWrench); + aNBT.setBoolean("mScrewdriver", mScrewdriver); + aNBT.setBoolean("mSoftHammer", mSoftHammer); + aNBT.setBoolean("mHardHammer", mHardHammer); + aNBT.setBoolean("mSolderingTool", mSolderingTool); + aNBT.setBoolean("mCrowbar", mCrowbar); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + mEUt = aNBT.getInteger("mEUt"); + mProgresstime = aNBT.getInteger("mProgresstime"); + mMaxProgresstime = aNBT.getInteger("mMaxProgresstime"); + if (mMaxProgresstime > 0) mRunningOnLoad = true; + mEfficiencyIncrease = aNBT.getInteger("mEfficiencyIncrease"); + mEfficiency = aNBT.getInteger("mEfficiency"); + mPollution = aNBT.getInteger("mPollution"); + mRuntime = aNBT.getInteger("mRuntime"); + mOutputItems = new ItemStack[getAmountOfOutputs()]; + for (int i = 0; i < mOutputItems.length; i++) mOutputItems[i] = GT_Utility.loadItem(aNBT, "mOutputItem" + i); + mOutputFluids = new FluidStack[getAmountOfOutputs()]; + for (int i = 0; i < mOutputFluids.length; i++) + mOutputFluids[i] = GT_Utility.loadFluid(aNBT, "mOutputFluids" + i); + mWrench = aNBT.getBoolean("mWrench"); + mScrewdriver = aNBT.getBoolean("mScrewdriver"); + mSoftHammer = aNBT.getBoolean("mSoftHammer"); + mHardHammer = aNBT.getBoolean("mHardHammer"); + mSolderingTool = aNBT.getBoolean("mSolderingTool"); + mCrowbar = aNBT.getBoolean("mCrowbar"); + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) return true; + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + + @Override + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_Container_MultiMachine(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "MultiblockDisplay.png"); + } + + @Override + public byte getTileEntityBaseType() { + return 2; + } + + @Override + public void onMachineBlockUpdate() { + mUpdate = 50; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide()) { + if (mEfficiency < 0) mEfficiency = 0; + if (--mUpdate == 0 || --mStartUpCheck == 0) { + mInputHatches.clear(); + mInputBusses.clear(); + mOutputHatches.clear(); + mOutputBusses.clear(); + mDynamoHatches.clear(); + mEnergyHatches.clear(); + mMufflerHatches.clear(); + mMaintenanceHatches.clear(); + mMachine = checkMachine(aBaseMetaTileEntity, mInventory[1]); + } + if (mStartUpCheck < 0) { + if (mMachine) { + for (GT_MetaTileEntity_Hatch_Maintenance tHatch : mMaintenanceHatches) { + if (isValidMetaTileEntity(tHatch)) { + if (!this.disableMaintenance) { + if (tHatch.mWrench) mWrench = true; + if (tHatch.mScrewdriver) mScrewdriver = true; + if (tHatch.mSoftHammer) mSoftHammer = true; + if (tHatch.mHardHammer) mHardHammer = true; + if (tHatch.mSolderingTool) mSolderingTool = true; + if (tHatch.mCrowbar) mCrowbar = true; + } else { + mWrench = true; + mScrewdriver = true; + mSoftHammer = true; + mHardHammer = true; + mSolderingTool = true; + mCrowbar = true; + } + + tHatch.mWrench = false; + tHatch.mScrewdriver = false; + tHatch.mSoftHammer = false; + tHatch.mHardHammer = false; + tHatch.mSolderingTool = false; + tHatch.mCrowbar = false; + } + } + if (getRepairStatus() > 0) { + if (mMaxProgresstime > 0 && doRandomMaintenanceDamage()) { + if (onRunningTick(mInventory[1])) { + if (!polluteEnvironment(getPollutionPerTick(mInventory[1]))) { + stopMachine(); + } + if (mMaxProgresstime > 0 && ++mProgresstime >= mMaxProgresstime) { + if (mOutputItems != null) for (ItemStack tStack : mOutputItems) + if (tStack != null) { + try { + GT_Mod.instance.achievements.issueAchivementHatch(aBaseMetaTileEntity.getWorld().getPlayerEntityByName(aBaseMetaTileEntity.getOwnerName()), tStack); + } catch (Exception e) { + } + addOutput(tStack); + } + if (mOutputFluids != null && mOutputFluids.length == 1) { + for (FluidStack tStack : mOutputFluids) + if (tStack != null) { + addOutput(tStack); + } + } else if (mOutputFluids != null && mOutputFluids.length > 1) { + addFluidOutputs(mOutputFluids); + } + mEfficiency = Math.max(0, Math.min(mEfficiency + mEfficiencyIncrease, getMaxEfficiency(mInventory[1]) - ((getIdealStatus() - getRepairStatus()) * 1000))); + mOutputItems = null; + mProgresstime = 0; + mMaxProgresstime = 0; + mEfficiencyIncrease = 0; + if (aBaseMetaTileEntity.isAllowedToWork()) checkRecipe(mInventory[1]); + if (mOutputFluids != null && mOutputFluids.length > 0) { + if (mOutputFluids.length > 1) { + GT_Mod.instance.achievements.issueAchievement(aBaseMetaTileEntity.getWorld().getPlayerEntityByName(aBaseMetaTileEntity.getOwnerName()), "oilplant"); + } + } + } + } + } else { + if (aTick % 100 == 0 || aBaseMetaTileEntity.hasWorkJustBeenEnabled() || aBaseMetaTileEntity.hasInventoryBeenModified()) { + + if (aBaseMetaTileEntity.isAllowedToWork()) { + checkRecipe(mInventory[1]); + } + if (mMaxProgresstime <= 0) mEfficiency = Math.max(0, mEfficiency - 1000); + } + } + } else { + stopMachine(); + } + } else { + stopMachine(); + } + } + aBaseMetaTileEntity.setErrorDisplayID((aBaseMetaTileEntity.getErrorDisplayID() & ~127) | (mWrench ? 0 : 1) | (mScrewdriver ? 0 : 2) | (mSoftHammer ? 0 : 4) | (mHardHammer ? 0 : 8) | (mSolderingTool ? 0 : 16) | (mCrowbar ? 0 : 32) | (mMachine ? 0 : 64)); + aBaseMetaTileEntity.setActive(mMaxProgresstime > 0); + } + } + + public boolean polluteEnvironment(int aPollutionLevel) { + mPollution += aPollutionLevel; + for (GT_MetaTileEntity_Hatch_Muffler tHatch : mMufflerHatches) { + if (isValidMetaTileEntity(tHatch)) { + if (mPollution >= 10000) { + if (tHatch.polluteEnvironment()) { + mPollution -= 10000; + } + } else { + break; + } + } + } + return mPollution < 10000; + } + + /** + * Called every tick the Machine runs + */ + public boolean onRunningTick(ItemStack aStack) { + if (mEUt > 0) { + addEnergyOutput(((long) mEUt * mEfficiency) / 10000); + return true; + } + if (mEUt < 0) { + if (!drainEnergyInput(((long) -mEUt * 10000) / Math.max(1000, mEfficiency))) { + stopMachine(); + return false; + } + } + return true; + } + + /** + * Checks if this is a Correct Machine Part for this kind of Machine (Turbine Rotor for example) + */ + public abstract boolean isCorrectMachinePart(ItemStack aStack); + + /** + * Checks the Recipe + */ + public abstract boolean checkRecipe(ItemStack aStack); + + /** + * Checks the Machine. You have to assign the MetaTileEntities for the Hatches here. + */ + public abstract boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack); + + /** + * Gets the maximum Efficiency that spare Part can get (0 - 10000) + */ + public abstract int getMaxEfficiency(ItemStack aStack); + + /** + * Gets the pollution this Device outputs to a Muffler per tick (10000 = one Pullution Block) + */ + public abstract int getPollutionPerTick(ItemStack aStack); + + /** + * Gets the damage to the ItemStack, usually 0 or 1. + */ + public abstract int getDamageToComponent(ItemStack aStack); + + /** + * Gets the Amount of possibly outputted Items for loading the Output Stack Array from NBT. + * This should be the largest Amount that can ever happen legitimately. + */ + public abstract int getAmountOfOutputs(); + + /** + * If it explodes when the Component has to be replaced. + */ + public abstract boolean explodesOnComponentBreak(ItemStack aStack); + + public void stopMachine() { + mOutputItems = null; + mEUt = 0; + mEfficiency = 0; + mProgresstime = 0; + mMaxProgresstime = 0; + mEfficiencyIncrease = 0; + getBaseMetaTileEntity().disableWorking(); + } + + public int getRepairStatus() { + return (mWrench ? 1 : 0) + (mScrewdriver ? 1 : 0) + (mSoftHammer ? 1 : 0) + (mHardHammer ? 1 : 0) + (mSolderingTool ? 1 : 0) + (mCrowbar ? 1 : 0); + } + + public int getIdealStatus() { + return 6; + } + + public boolean doRandomMaintenanceDamage() { + if (!isCorrectMachinePart(mInventory[1]) || getRepairStatus() == 0) { + stopMachine(); + return false; + } + if (mRuntime++ > 1000) { + mRuntime = 0; + if (getBaseMetaTileEntity().getRandomNumber(6000) == 0) { + switch (getBaseMetaTileEntity().getRandomNumber(6)) { + case 0: + mWrench = false; + break; + case 1: + mScrewdriver = false; + break; + case 2: + mSoftHammer = false; + break; + case 3: + mHardHammer = false; + break; + case 4: + mSolderingTool = false; + break; + case 5: + mCrowbar = false; + break; + } + } + if (mInventory[1] != null && getBaseMetaTileEntity().getRandomNumber(2) == 0 && !mInventory[1].getUnlocalizedName().startsWith("gt.blockmachines.basicmachine.")) { + if (mInventory[1].getItem() instanceof GT_MetaGenerated_Tool_01) { + NBTTagCompound tNBT = mInventory[1].getTagCompound(); + if (tNBT != null) { + NBTTagCompound tNBT2 = tNBT.getCompoundTag("GT.CraftingComponents"); + if (!tNBT.getBoolean("mDis")) { + tNBT2 = new NBTTagCompound(); + Materials tMaterial = GT_MetaGenerated_Tool.getPrimaryMaterial(mInventory[1]); + ItemStack tTurbine = GT_OreDictUnificator.get(OrePrefixes.turbineBlade, tMaterial, 1); + int i = mInventory[1].getItemDamage(); + if (i == 170) { + ItemStack tStack = GT_Utility.copyAmount(1, tTurbine); + tNBT2.setTag("Ingredient.0", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.1", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.2", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.3", tStack.writeToNBT(new NBTTagCompound())); + tStack = GT_OreDictUnificator.get(OrePrefixes.stickLong, Materials.Magnalium, 1); + tNBT2.setTag("Ingredient.4", tStack.writeToNBT(new NBTTagCompound())); + } else if (i == 172) { + ItemStack tStack = GT_Utility.copyAmount(1, tTurbine); + tNBT2.setTag("Ingredient.0", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.1", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.2", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.3", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.5", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.6", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.7", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.8", tStack.writeToNBT(new NBTTagCompound())); + tStack = GT_OreDictUnificator.get(OrePrefixes.stickLong, Materials.Titanium, 1); + tNBT2.setTag("Ingredient.4", tStack.writeToNBT(new NBTTagCompound())); + } else if (i == 174) { + ItemStack tStack = GT_Utility.copyAmount(2, tTurbine); + tNBT2.setTag("Ingredient.0", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.1", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.2", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.3", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.5", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.6", tStack.writeToNBT(new NBTTagCompound())); + tStack = GT_OreDictUnificator.get(OrePrefixes.stickLong, Materials.TungstenSteel, 1); + tNBT2.setTag("Ingredient.4", tStack.writeToNBT(new NBTTagCompound())); + } else if (i == 176) { + ItemStack tStack = GT_Utility.copyAmount(2, tTurbine); + tNBT2.setTag("Ingredient.0", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.1", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.2", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.3", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.5", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.6", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.7", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.8", tStack.writeToNBT(new NBTTagCompound())); + tStack = GT_OreDictUnificator.get(OrePrefixes.stickLong, Materials.Americium, 1); + tNBT2.setTag("Ingredient.4", tStack.writeToNBT(new NBTTagCompound())); + } + tNBT.setTag("GT.CraftingComponents", tNBT2); + tNBT.setBoolean("mDis", true); + mInventory[1].setTagCompound(tNBT); + + } + } + + ((GT_MetaGenerated_Tool) mInventory[1].getItem()).doDamage(mInventory[1], (long) Math.min(mEUt / 5, Math.pow(mEUt, 0.7))); + if (mInventory[1].stackSize == 0) mInventory[1] = null; + } + } + } + return true; + } + + public void explodeMultiblock() { + mInventory[1] = null; + for (MetaTileEntity tTileEntity : mInputBusses) tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]); + for (MetaTileEntity tTileEntity : mOutputBusses) tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]); + for (MetaTileEntity tTileEntity : mInputHatches) tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]); + for (MetaTileEntity tTileEntity : mOutputHatches) tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]); + for (MetaTileEntity tTileEntity : mDynamoHatches) tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]); + for (MetaTileEntity tTileEntity : mMufflerHatches) tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]); + for (MetaTileEntity tTileEntity : mEnergyHatches) tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]); + for (MetaTileEntity tTileEntity : mMaintenanceHatches) tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]); + getBaseMetaTileEntity().doExplosion(V[8]); + } + + public boolean addEnergyOutput(long aEU) { + if (aEU <= 0) return true; + for (GT_MetaTileEntity_Hatch_Dynamo tHatch : mDynamoHatches) { + if (isValidMetaTileEntity(tHatch)) { + if (tHatch.getBaseMetaTileEntity().increaseStoredEnergyUnits(aEU, false)) { + return true; + } + } + } + return false; + } + + public long getMaxInputVoltage() { + long rVoltage = 0; + for (GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches) + if (isValidMetaTileEntity(tHatch)) rVoltage += tHatch.getBaseMetaTileEntity().getInputVoltage(); + return rVoltage; + } + + public boolean drainEnergyInput(long aEU) { + if (aEU <= 0) return true; + for (GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches) + if (isValidMetaTileEntity(tHatch)) { + if (tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(aEU, false)) return true; + } + return false; + } + + public boolean addOutput(FluidStack aLiquid) { + if (aLiquid == null) return false; + FluidStack tLiquid = aLiquid.copy(); + for (GT_MetaTileEntity_Hatch_Output tHatch : mOutputHatches) { + if (isValidMetaTileEntity(tHatch) && GT_ModHandler.isSteam(aLiquid) ? tHatch.outputsSteam() : tHatch.outputsLiquids()) { + int tAmount = tHatch.fill(tLiquid, false); + if (tAmount >= tLiquid.amount) { + return tHatch.fill(tLiquid, true) >= tLiquid.amount; + } else if (tAmount > 0) { + tLiquid.amount = tLiquid.amount - tHatch.fill(tLiquid, true); + } + } + } + return false; + } + + private void addFluidOutputs(FluidStack[] mOutputFluids2) { + for (int i = 0; i < mOutputFluids2.length; i++) { + if (mOutputHatches.size() > i && mOutputHatches.get(i) != null && mOutputFluids2[i] != null && isValidMetaTileEntity(mOutputHatches.get(i))) { + mOutputHatches.get(i).fill(mOutputFluids2[i], true); + } + } + + } + + public boolean depleteInput(FluidStack aLiquid) { + if (aLiquid == null) return false; + for (GT_MetaTileEntity_Hatch_Input tHatch : mInputHatches) { + tHatch.mRecipeMap = getRecipeMap(); + if (isValidMetaTileEntity(tHatch)) { + FluidStack tLiquid = tHatch.getFluid(); + if (tLiquid != null && tLiquid.isFluidEqual(aLiquid)) { + tLiquid = tHatch.drain(aLiquid.amount, false); + if (tLiquid != null && tLiquid.amount >= aLiquid.amount) { + tLiquid = tHatch.drain(aLiquid.amount, true); + return tLiquid != null && tLiquid.amount >= aLiquid.amount; + } + } + } + } + return false; + } + + public boolean addOutput(ItemStack aStack) { + if (GT_Utility.isStackInvalid(aStack)) return false; + aStack = GT_Utility.copy(aStack); +// FluidStack aLiquid = GT_Utility.getFluidForFilledItem(aStack, true); +// if (aLiquid == null) { + for (GT_MetaTileEntity_Hatch_OutputBus tHatch : mOutputBusses) { + if (isValidMetaTileEntity(tHatch)) { + for (int i = tHatch.getSizeInventory() - 1; i >= 0; i--) { + if (tHatch.getBaseMetaTileEntity().addStackToSlot(i, aStack)) return true; + } + } + } + for (GT_MetaTileEntity_Hatch_Output tHatch : mOutputHatches) { + if (isValidMetaTileEntity(tHatch) && tHatch.outputsItems()) { + if (tHatch.getBaseMetaTileEntity().addStackToSlot(1, aStack)) return true; + } + } +// }else { +// for (GT_MetaTileEntity_Hatch_Output tHatch : mOutputHatches) { +// if (isValidMetaTileEntity(tHatch) && GT_ModHandler.isSteam(aLiquid)?tHatch.outputsSteam():tHatch.outputsLiquids()) { +// int tAmount = tHatch.fill(aLiquid, false); +// if (tAmount >= aLiquid.amount) { +// return tHatch.fill(aLiquid, true) >= aLiquid.amount; +// } +// } +// } +// } + return false; + } + + public boolean depleteInput(ItemStack aStack) { + if (GT_Utility.isStackInvalid(aStack)) return false; + FluidStack aLiquid = GT_Utility.getFluidForFilledItem(aStack, true); + if (aLiquid != null) return depleteInput(aLiquid); + for (GT_MetaTileEntity_Hatch_Input tHatch : mInputHatches) { + tHatch.mRecipeMap = getRecipeMap(); + if (isValidMetaTileEntity(tHatch)) { + if (GT_Utility.areStacksEqual(aStack, tHatch.getBaseMetaTileEntity().getStackInSlot(0))) { + if (tHatch.getBaseMetaTileEntity().getStackInSlot(0).stackSize >= aStack.stackSize) { + tHatch.getBaseMetaTileEntity().decrStackSize(0, aStack.stackSize); + return true; + } + } + } + } + for (GT_MetaTileEntity_Hatch_InputBus tHatch : mInputBusses) { + tHatch.mRecipeMap = getRecipeMap(); + if (isValidMetaTileEntity(tHatch)) { + for (int i = tHatch.getBaseMetaTileEntity().getSizeInventory() - 1; i >= 0; i--) { + if (GT_Utility.areStacksEqual(aStack, tHatch.getBaseMetaTileEntity().getStackInSlot(i))) { + if (tHatch.getBaseMetaTileEntity().getStackInSlot(0).stackSize >= aStack.stackSize) { + tHatch.getBaseMetaTileEntity().decrStackSize(0, aStack.stackSize); + return true; + } + } + } + } + } + return false; + } + + public ArrayList<ItemStack> getStoredOutputs() { + ArrayList<ItemStack> rList = new ArrayList<ItemStack>(); + for (GT_MetaTileEntity_Hatch_Output tHatch : mOutputHatches) { + if (isValidMetaTileEntity(tHatch)) { + rList.add(tHatch.getBaseMetaTileEntity().getStackInSlot(1)); + } + } + for (GT_MetaTileEntity_Hatch_OutputBus tHatch : mOutputBusses) { + if (isValidMetaTileEntity(tHatch)) { + for (int i = tHatch.getBaseMetaTileEntity().getSizeInventory() - 1; i >= 0; i--) { + rList.add(tHatch.getBaseMetaTileEntity().getStackInSlot(i)); + } + } + } + return rList; + } + + public ArrayList<FluidStack> getStoredFluids() { + ArrayList<FluidStack> rList = new ArrayList<FluidStack>(); + for (GT_MetaTileEntity_Hatch_Input tHatch : mInputHatches) { + tHatch.mRecipeMap = getRecipeMap(); + if (isValidMetaTileEntity(tHatch) && tHatch.getFillableStack() != null) { + rList.add(tHatch.getFillableStack()); + } + } + return rList; + } + + public ArrayList<ItemStack> getStoredInputs() { + ArrayList<ItemStack> rList = new ArrayList<ItemStack>(); + for (GT_MetaTileEntity_Hatch_Input tHatch : mInputHatches) { + tHatch.mRecipeMap = getRecipeMap(); + if (isValidMetaTileEntity(tHatch) && tHatch.getBaseMetaTileEntity().getStackInSlot(0) != null) { + rList.add(tHatch.getBaseMetaTileEntity().getStackInSlot(0)); + } + } + for (GT_MetaTileEntity_Hatch_InputBus tHatch : mInputBusses) { + tHatch.mRecipeMap = getRecipeMap(); + if (isValidMetaTileEntity(tHatch)) { + for (int i = tHatch.getBaseMetaTileEntity().getSizeInventory() - 1; i >= 0; i--) { + if (tHatch.getBaseMetaTileEntity().getStackInSlot(i) != null) + rList.add(tHatch.getBaseMetaTileEntity().getStackInSlot(i)); + } + } + } + return rList; + } + + public GT_Recipe_Map getRecipeMap() { + return null; + } + + public void updateSlots() { + for (GT_MetaTileEntity_Hatch_Input tHatch : mInputHatches) + if (isValidMetaTileEntity(tHatch)) tHatch.updateSlots(); + for (GT_MetaTileEntity_Hatch_InputBus tHatch : mInputBusses) + if (isValidMetaTileEntity(tHatch)) tHatch.updateSlots(); + } + + public boolean addToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) return false; + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) return false; + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch) + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) + return mInputHatches.add((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus) + return mInputBusses.add((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) + return mOutputHatches.add((GT_MetaTileEntity_Hatch_Output) aMetaTileEntity); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) + return mOutputBusses.add((GT_MetaTileEntity_Hatch_OutputBus) aMetaTileEntity); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy) + return mEnergyHatches.add((GT_MetaTileEntity_Hatch_Energy) aMetaTileEntity); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Dynamo) + return mDynamoHatches.add((GT_MetaTileEntity_Hatch_Dynamo) aMetaTileEntity); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance) + return mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance) aMetaTileEntity); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) + return mMufflerHatches.add((GT_MetaTileEntity_Hatch_Muffler) aMetaTileEntity); + return false; + } + + public boolean addMaintenanceToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) return false; + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) return false; + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; + return mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance) aMetaTileEntity); + } + return false; + } + + public boolean addEnergyInputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) return false; + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; + return mEnergyHatches.add((GT_MetaTileEntity_Hatch_Energy) aMetaTileEntity); + } + return false; + } + + public boolean addDynamoToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) return false; + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) return false; + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Dynamo) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; + return mDynamoHatches.add((GT_MetaTileEntity_Hatch_Dynamo) aMetaTileEntity); + } + return false; + } + + public boolean addMufflerToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) return false; + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) return false; + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; + return mMufflerHatches.add((GT_MetaTileEntity_Hatch_Muffler) aMetaTileEntity); + } + return false; + } + + public boolean addInputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) return false; + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) return false; + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; + ((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity).mRecipeMap = getRecipeMap(); + return mInputHatches.add((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; + ((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity).mRecipeMap = getRecipeMap(); + return mInputBusses.add((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity); + } + return false; + } + + public boolean addOutputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) return false; + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) return false; + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; + return mOutputHatches.add((GT_MetaTileEntity_Hatch_Output) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; + return mOutputBusses.add((GT_MetaTileEntity_Hatch_OutputBus) aMetaTileEntity); + } + return false; + } + + @Override + public String[] getInfoData() { + return new String[]{"Progress:", (mProgresstime / 20) + "secs", (mMaxProgresstime / 20) + "secs", "Efficiency:", (mEfficiency / 100.0F) + "%", "Problems:", "" + (getIdealStatus() - getRepairStatus())}; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return false; + } +} diff --git a/src/Java/miscutil/core/util/debug/DEBUG_TimerThread.java b/src/Java/miscutil/core/util/debug/DEBUG_TimerThread.java new file mode 100644 index 0000000000..db960dbadf --- /dev/null +++ b/src/Java/miscutil/core/util/debug/DEBUG_TimerThread.java @@ -0,0 +1,63 @@ +package miscutil.core.util.debug; + +import java.util.concurrent.TimeUnit; + +import miscutil.core.util.Utils; +import net.minecraft.client.Minecraft; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +public class DEBUG_TimerThread implements Runnable { + + private World world; + private EntityPlayer player; + + + public DEBUG_TimerThread(World WORLD, EntityPlayer PLAYER) { + world = WORLD; + player = PLAYER; + } + + @Override + public void run(){ + int xDir = ForgeDirection.getOrientation(player.getPlayerCoordinates().posX).offsetX; + int zDir = ForgeDirection.getOrientation(player.getPlayerCoordinates().posZ).offsetZ; + + int stepX = Minecraft.getMinecraft().objectMouseOver.blockX; + int stepY = Minecraft.getMinecraft().objectMouseOver.blockY; + int stepZ = Minecraft.getMinecraft().objectMouseOver.blockZ; + Utils.LOG_INFO("Clicked on a Block @ "+"[X:"+stepX+"][Y:"+stepY+"][Z:"+stepZ+"]"+" with xDir:"+xDir+" zDir:"+zDir); + world.setBlock(stepX, stepY, stepZ, Blocks.bedrock,0,3); + Utils.LOG_INFO("Makng it Bedrock for future investment."); + //for (int i = -1; i <= 1; i++) { + //stepX = stepX+i; + for (int i = stepX-1; i <= stepX+1; i++){ + for (int j = stepZ-1; j <= stepZ+1; j++){ + for (int h = stepY-1; h <= stepY+1; h++){ + + xDir = ForgeDirection.getOrientation(player.getPlayerCoordinates().posX).offsetX; + zDir = ForgeDirection.getOrientation(player.getPlayerCoordinates().posZ).offsetZ; + + //for (int j = -1; j <= 1; j++) { + //stepZ = stepZ+j; + //for (int h = -1; h <= 1; h++) { + //stepY = stepY+h; + Utils.LOG_INFO("Placing Block @ "+"[X:"+i+"][Y:"+h+"][Z:"+j+"]"+" with xDir:"+xDir+" zDir:"+zDir); + if ((h != 0) || (((xDir + i != 0) || (zDir + j != 0)) && ((i != 0) || (j != 0)))) { + world.setBlock(i, h, j, Blocks.stone,0,3); + } + else { + Utils.LOG_INFO("Not even sure what this is for, but I got here."); + } + try { + TimeUnit.MILLISECONDS.sleep(500); + } catch (InterruptedException e1) { + e1.printStackTrace(); + } + } + } + } + } +}
\ No newline at end of file diff --git a/src/Java/miscutil/core/util/wrapper/var.java b/src/Java/miscutil/core/util/wrapper/var.java new file mode 100644 index 0000000000..bae0e020f4 --- /dev/null +++ b/src/Java/miscutil/core/util/wrapper/var.java @@ -0,0 +1,67 @@ +package miscutil.core.util.wrapper; + +import miscutil.core.lib.LoadedMods; +import miscutil.core.util.Utils; +import miscutil.core.util.UtilsItems; +import net.minecraft.item.ItemStack; + +public class var{ + + private ItemStack temp = null; + private String sanitizedName; + private String fqrn; + + public var(String o){ + String t = sanitize('<', o); + String t2 = sanitize('>', t); + sanitizedName = t2; + o = sanitize('"', t2); + fqrn = o; + } + + private String sanitize(char token, String input){ + for (int i=0;i<input.length();i++) { + if (input.charAt(i) == token) { + input = input.replace(input.charAt(i), ' '); + Utils.LOG_WARNING("MATCH FOUND"); + } + input = input.replaceAll(" ", ""); + } + String output = input; + return output; + } + + public String getFQRN(){ + String s = fqrn; + return s; + } + + public String getsanitizedName(){ + String s = sanitizedName; + return s; + } + + private ItemStack getOreDictStack(int stackSize){ + ItemStack v = UtilsItems.getItemStack(sanitizedName, stackSize); + return v; + } + + public ItemStack getStack(int stackSize){ + String oreDict = "ore:"; + if (fqrn.toLowerCase().contains(oreDict.toLowerCase())){ + ItemStack v = getOreDictStack(stackSize); + return v; + } + String[] fqrnSplit = fqrn.split(":"); + String meta = "0"; + try { + if(fqrnSplit[2] != null){meta = fqrnSplit[2];} + temp = UtilsItems.getItemStackWithMeta(LoadedMods.MiscUtils, fqrn, fqrnSplit[1], Integer.parseInt(meta), stackSize); + } + catch (ArrayIndexOutOfBoundsException a){ + temp = UtilsItems.getItemStackWithMeta(LoadedMods.MiscUtils, fqrn, fqrnSplit[1], Integer.parseInt(meta), stackSize); + } + return temp; + } + + }
\ No newline at end of file diff --git a/src/Java/miscutil/gregtech/api/init/machines/GregtechIndustrialPlatePress.java b/src/Java/miscutil/gregtech/api/init/machines/GregtechIndustrialPlatePress.java index 78f05b157c..266263380e 100644 --- a/src/Java/miscutil/gregtech/api/init/machines/GregtechIndustrialPlatePress.java +++ b/src/Java/miscutil/gregtech/api/init/machines/GregtechIndustrialPlatePress.java @@ -1,6 +1,5 @@ package miscutil.gregtech.api.init.machines; -import miscutil.core.util.Utils; import miscutil.gregtech.api.enums.GregtechItemList; import miscutil.gregtech.common.machines.multi.GregtechMetaTileEntityIndustrialPlatePress; @@ -11,10 +10,10 @@ public class GregtechIndustrialPlatePress public static void run() { - if (miscutil.core.lib.LoadedMods.Gregtech){ + /*if (miscutil.core.lib.LoadedMods.Gregtech){ Utils.LOG_INFO("MiscUtils: Gregtech5u Content | Registering Industrial Press Multiblock."); run1(); - } + }*/ } diff --git a/src/Java/miscutil/gregtech/common/machines/multi/GregtechMetaTileEntityIndustrialCokeOven.java b/src/Java/miscutil/gregtech/common/machines/multi/GregtechMetaTileEntityIndustrialCokeOven.java index 65c58b35db..7c96c7e913 100644 --- a/src/Java/miscutil/gregtech/common/machines/multi/GregtechMetaTileEntityIndustrialCokeOven.java +++ b/src/Java/miscutil/gregtech/common/machines/multi/GregtechMetaTileEntityIndustrialCokeOven.java @@ -13,6 +13,7 @@ import java.util.ArrayList; import java.util.Arrays; import miscutil.core.block.ModBlocks; +import miscutil.core.util.Utils; import miscutil.gregtech.api.gui.GUI_MultiMachine; import miscutil.gregtech.api.util.GregtechRecipe; import net.minecraft.entity.player.InventoryPlayer; @@ -171,6 +172,9 @@ public class GregtechMetaTileEntityIndustrialCokeOven public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; + int xr = aBaseMetaTileEntity.getXCoord(); + int yr = aBaseMetaTileEntity.getYCoord(); + int zr = aBaseMetaTileEntity.getZCoord(); this.mLevel = 0; if (!aBaseMetaTileEntity.getAirOffset(xDir, 1, zDir)) { return false; @@ -208,8 +212,20 @@ public class GregtechMetaTileEntityIndustrialCokeOven } } for (int i = -1; i < 2; i++) { + xr = aBaseMetaTileEntity.getXCoord(); + yr = aBaseMetaTileEntity.getYCoord(); + zr = aBaseMetaTileEntity.getZCoord(); + Utils.LOG_INFO("STEP 1 - x ["+xr+"] y ["+yr+"] z ["+zr+"]"); for (int j = -1; j < 2; j++) { + xr = aBaseMetaTileEntity.getXCoord(); + yr = aBaseMetaTileEntity.getYCoord(); + zr = aBaseMetaTileEntity.getZCoord(); + Utils.LOG_INFO("STEP 2 - x ["+xr+"] y ["+yr+"] z ["+zr+"]"); if ((xDir + i != 0) || (zDir + j != 0)) { + xr = aBaseMetaTileEntity.getXCoord(); + yr = aBaseMetaTileEntity.getYCoord(); + zr = aBaseMetaTileEntity.getZCoord(); + Utils.LOG_INFO("STEP 3 - x ["+xr+"] y ["+yr+"] z ["+zr+"]"); IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, 0, zDir + j); if ((!addMaintenanceToMachineList(tTileEntity, 1)) && (!addInputToMachineList(tTileEntity, 1)) && (!addOutputToMachineList(tTileEntity, 1)) && (!addEnergyInputToMachineList(tTileEntity, 1))) { if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 0, zDir + j) != ModBlocks.blockCasingsMisc) { diff --git a/src/Java/miscutil/gregtech/common/machines/multi/GregtechMetaTileEntityIndustrialPlatePress.java b/src/Java/miscutil/gregtech/common/machines/multi/GregtechMetaTileEntityIndustrialPlatePress.java index 0084deb2a2..8ed5a90731 100644 --- a/src/Java/miscutil/gregtech/common/machines/multi/GregtechMetaTileEntityIndustrialPlatePress.java +++ b/src/Java/miscutil/gregtech/common/machines/multi/GregtechMetaTileEntityIndustrialPlatePress.java @@ -13,131 +13,237 @@ import gregtech.api.util.GT_Utility; import java.util.ArrayList; +import miscutil.core.util.Utils; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection; public class GregtechMetaTileEntityIndustrialPlatePress - extends GT_MetaTileEntity_MultiBlockBase { - public GregtechMetaTileEntityIndustrialPlatePress(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntityIndustrialPlatePress(String aName) { - super(aName); - } - - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntityIndustrialPlatePress(this.mName); - } - - public String[] getDescription() { - return new String[]{"Controller Block for the Vacuum Freezer", "Size: 3x3x3 (Hollow)", "Controller (front centered)", "1x Input (anywhere)", "1x Output (anywhere)", "1x Energy Hatch (anywhere)", "1x Maintenance Hatch (anywhere)", "Frost Proof Casings for the rest (16 at least!)"}; - } - - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - if (aSide == aFacing) { - return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[17], new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER)}; - } - return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[17]}; - } - - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "VacuumFreezer.png"); - } - - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return GT_Recipe.GT_Recipe_Map.sBenderRecipes; - } - - public boolean isCorrectMachinePart(ItemStack aStack) { - return true; - } - - public boolean isFacingValid(byte aFacing) { - return aFacing > 1; - } - - public boolean checkRecipe(ItemStack aStack) { - ArrayList<ItemStack> tInputList = getStoredInputs(); - for (ItemStack tInput : tInputList) { - long tVoltage = getMaxInputVoltage(); - byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - - GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sVacuumRecipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], null, new ItemStack[]{tInput}); - if (tRecipe != null) { - if (tRecipe.isRecipeInputEqual(true, null, new ItemStack[]{tInput})) { - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - if (tRecipe.mEUt <= 16) { - this.mEUt = (tRecipe.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); - this.mMaxProgresstime = (tRecipe.mDuration / (1 << tTier - 1)); - } else { - this.mEUt = tRecipe.mEUt; - this.mMaxProgresstime = tRecipe.mDuration; - while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { - this.mEUt *= 4; - this.mMaxProgresstime /= 2; - } - } - if (this.mEUt > 0) { - this.mEUt = (-this.mEUt); - } - this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - this.mOutputItems = new ItemStack[]{tRecipe.getOutput(0)}; - updateSlots(); - return true; - } - } - } - return false; - } - - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; - int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; - if (!aBaseMetaTileEntity.getAirOffset(xDir, 0, zDir)) { - return false; - } - int tAmount = 0; - for (int i = -2; i < 3; i++) { - for (int j = -1; j < 2; 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); - if ((!addMaintenanceToMachineList(tTileEntity, 17)) && (!addInputToMachineList(tTileEntity, 17)) && (!addOutputToMachineList(tTileEntity, 17)) && (!addEnergyInputToMachineList(tTileEntity, 17))) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != GregTech_API.sBlockCasings2) { - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 1) { - return false; - } - tAmount++; - } - } - } - } - } - return tAmount >= 16; - } - - public int getMaxEfficiency(ItemStack aStack) { - return 10000; - } - - public int getPollutionPerTick(ItemStack aStack) { - return 0; - } - - public int getDamageToComponent(ItemStack aStack) { - return 0; - } - - public int getAmountOfOutputs() { - return 1; - } - - public boolean explodesOnComponentBreak(ItemStack aStack) { - return false; - } +extends GT_MetaTileEntity_MultiBlockBase { + public GregtechMetaTileEntityIndustrialPlatePress(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntityIndustrialPlatePress(String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntityIndustrialPlatePress(this.mName); + } + + @Override + public String[] getDescription() { + return new String[]{"Controller Block for the Vacuum Freezer", "Size: 3x3x3 (Hollow)", "Controller (front centered)", "1x Input (anywhere)", "1x Output (anywhere)", "1x Energy Hatch (anywhere)", "1x Maintenance Hatch (anywhere)", "Frost Proof Casings for the rest (16 at least!)"}; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[17], new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER)}; + } + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[17]}; + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "VacuumFreezer.png"); + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GT_Recipe.GT_Recipe_Map.sBenderRecipes; + } + + @Override + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return aFacing > 1; + } + + @Override + public boolean checkRecipe(ItemStack aStack) { + ArrayList<ItemStack> tInputList = getStoredInputs(); + for (ItemStack tInput : tInputList) { + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + + GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sVacuumRecipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], null, new ItemStack[]{tInput}); + if (tRecipe != null) { + if (tRecipe.isRecipeInputEqual(true, null, new ItemStack[]{tInput})) { + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + if (tRecipe.mEUt <= 16) { + this.mEUt = (tRecipe.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); + this.mMaxProgresstime = (tRecipe.mDuration / (1 << tTier - 1)); + } else { + this.mEUt = tRecipe.mEUt; + this.mMaxProgresstime = tRecipe.mDuration; + while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { + this.mEUt *= 4; + this.mMaxProgresstime /= 2; + } + } + if (this.mEUt > 0) { + this.mEUt = (-this.mEUt); + } + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + this.mOutputItems = new ItemStack[]{tRecipe.getOutput(0)}; + updateSlots(); + return true; + } + } + } + return false; + } + + /*public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; + int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; + if (!aBaseMetaTileEntity.getAirOffset(xDir, 0, zDir)) { + return false; + } + int stepX = 0; + int stepY = 0; + int stepZ = 0; + + int tAmount = 0; + for (int i = -1; i < 2; i++) { + stepX=+i; + for (int j = -1; j < 2; j++) { + stepZ=+j; + for (int h = -1; h < 2; h++) { + stepY=+h; + Utils.LOG_INFO("X:"+stepX); + Utils.LOG_INFO("Y:"+stepY); + Utils.LOG_INFO("Z:"+stepZ); + Utils.LOG_INFO("Block Facing - X:"+xDir+" Z:"+zDir); + Utils.LOG_INFO("(h != 0) || (((xDir + i != 0) || (zDir + j != 0)) && ((i != 0) || (j != 0)))"); + Utils.LOG_INFO(" "+(h != 0)+" || "+(((xDir + i != 0)+" || "+(zDir + j != 0))+" && "+((i != 0)+" || "+(j != 0)))); + try { + IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j); + Utils.LOG_INFO("IPP - RESULT - ? - ["+tTileEntity.getXCoord()+"] y ["+tTileEntity.getYCoord()+"] z ["+tTileEntity.getZCoord()+"] || i ["+i+"] j ["+j+"] h ["+h+"]"); + } catch(Throwable t){Utils.LOG_INFO("Bad move"); + } + if ((h != 0) || (((xDir + i != 0) || (zDir + j != 0)) && ((i != 0) || (j != 0)))) { + IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j); + if ((!addMaintenanceToMachineList(tTileEntity, 17)) && (!addInputToMachineList(tTileEntity, 17)) && (!addOutputToMachineList(tTileEntity, 17)) && (!addEnergyInputToMachineList(tTileEntity, 17))) { + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != GregTech_API.sBlockCasings2) { + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 1) { + return false; + } + tAmount++; + } + } + + } + } + } + return tAmount >= 16; + }*/ + + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; + int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; + if (!aBaseMetaTileEntity.getAirOffset(xDir, 0, zDir)) { + return false; + } + int stepX = aBaseMetaTileEntity.getXCoord(); + int stepY = aBaseMetaTileEntity.getYCoord(); + int stepZ = aBaseMetaTileEntity.getZCoord(); + int temp = 0; + + Utils.LOG_INFO("Starting Block located @ "+"[X:"+stepX+"][Y:"+stepY+"][Z:"+stepZ+"]"); + + int tAmount = 0; + switch (xDir) { + case -1: + stepX++; + Utils.LOG_INFO("Modifying stepX + accomodate a "+xDir+" xDir - [X:"+stepX+"][Y:"+stepY+"][Z:"+stepZ+"]"); + break; + + case 1: + stepX--; + Utils.LOG_INFO("Modifying stepX - accomodate a "+xDir+" xDir - [X:"+stepX+"][Y:"+stepY+"][Z:"+stepZ+"]"); + break; + } + switch (zDir) { + case -1: + stepZ++; + Utils.LOG_INFO("Modifying stepZ + accomodate a "+zDir+" zDir - [X:"+stepX+"][Y:"+stepY+"][Z:"+stepZ+"]"); + break; + + case 1: + stepZ--; + Utils.LOG_INFO("Modifying stepZ - accomodate a "+zDir+" zDir - [X:"+stepX+"][Y:"+stepY+"][Z:"+stepZ+"]"); + break; + } + + for (int i = stepX-1; i <= stepX+1; i++){ + for (int j = stepZ-1; j <= stepZ+1; j++){ + for (int h = stepY-1; h <= stepY+1; h++){ + + + Utils.LOG_INFO("Block Facing - X:"+xDir+" Z:"+zDir); + Utils.LOG_INFO("(h != 0) || (((xDir + i != 0) || (zDir + j != 0)) && ((i != 0) || (j != 0)))"); + Utils.LOG_INFO(" "+(h != 0)+" || "+(((xDir + i != 0)+" || "+(zDir + j != 0))+" && "+((i != 0)+" || "+(j != 0)))); + + try { + IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j); + Utils.LOG_INFO("IPP - RESULT - ? - ["+tTileEntity.getXCoord()+"] y ["+tTileEntity.getYCoord()+"] z ["+tTileEntity.getZCoord()+"] || i ["+i+"] j ["+j+"] h ["+h+"]"); + } catch(Throwable t){Utils.LOG_INFO("Checking Non-Hatch/Bus Block/Casing"); + } + if ((h != 0) || (((xDir + i != 0) || (zDir + j != 0)) && ((i != 0) || (j != 0)))) { + IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j); + if ((!addMaintenanceToMachineList(tTileEntity, 17)) && (!addInputToMachineList(tTileEntity, 17)) && (!addOutputToMachineList(tTileEntity, 17)) && (!addEnergyInputToMachineList(tTileEntity, 17))) { + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != GregTech_API.sBlockCasings2) { + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 1) { + return false; + } + tAmount++; + } + } + } + } + } + + + return tAmount >= 16; + } + + @Override + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(ItemStack aStack) { + return 0; + } + + @Override + public int getDamageToComponent(ItemStack aStack) { + return 0; + } + + @Override + public int getAmountOfOutputs() { + return 1; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } } diff --git a/src/resources/assets/miscutils/textures/items/itemDebugShapeSpawner.png b/src/resources/assets/miscutils/textures/items/itemDebugShapeSpawner.png Binary files differnew file mode 100644 index 0000000000..908d3121e9 --- /dev/null +++ b/src/resources/assets/miscutils/textures/items/itemDebugShapeSpawner.png diff --git a/src/resources/assets/miscutils/textures/items/itemIngotBatteryAlloy.png b/src/resources/assets/miscutils/textures/items/itemIngotBatteryAlloy.png Binary files differnew file mode 100644 index 0000000000..ab91ac2c85 --- /dev/null +++ b/src/resources/assets/miscutils/textures/items/itemIngotBatteryAlloy.png diff --git a/src/resources/assets/miscutils/textures/items/itemPlateBatteryAlloy.png b/src/resources/assets/miscutils/textures/items/itemPlateBatteryAlloy.png Binary files differnew file mode 100644 index 0000000000..c41f17392c --- /dev/null +++ b/src/resources/assets/miscutils/textures/items/itemPlateBatteryAlloy.png diff --git a/src/resources/assets/miscutils/textures/items/itemStickyRubber.png b/src/resources/assets/miscutils/textures/items/itemStickyRubber.png Binary files differnew file mode 100644 index 0000000000..d020c1b2b2 --- /dev/null +++ b/src/resources/assets/miscutils/textures/items/itemStickyRubber.png |