diff options
Diffstat (limited to 'src/Java/gtPlusPlus/xmod/gregtech/common')
27 files changed, 2557 insertions, 274 deletions
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java b/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java index 629c584f70..430ae44d64 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java @@ -13,10 +13,12 @@ import java.util.Timer; import java.util.TimerTask; import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.common.registry.LanguageRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.GregTech_API; import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; import gregtech.api.enums.Materials; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.BaseMetaTileEntity; @@ -32,13 +34,17 @@ import gtPlusPlus.api.objects.minecraft.FormattedTooltipString; import gtPlusPlus.core.handler.AchievementHandler; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.material.ELEMENT; -import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.minecraft.FluidUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.minecraft.LangUtils; import gtPlusPlus.core.util.minecraft.MaterialUtils; +import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils; import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.BaseCustomTileEntity; import gtPlusPlus.xmod.gregtech.api.metatileentity.custom.power.BaseCustomPower_MTE; import gtPlusPlus.xmod.gregtech.common.covers.CoverManager; +import ic2.core.init.BlocksItems; +import ic2.core.init.InternalName; import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; @@ -46,84 +52,172 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; public class Meta_GT_Proxy { static { - instance = new Meta_GT_Proxy(); Logger.INFO("GT_PROXY - initialized."); } - - public static final Meta_GT_Proxy instance; - + public static List<Runnable> GT_BlockIconload = new ArrayList<>(); public static List<Runnable> GT_ItemIconload = new ArrayList<>(); - + public static AutoMap<Integer> GT_ValidHeatingCoilMetas = new AutoMap<Integer>(); - private static Class sBaseMetaTileEntityClass; - private static Class sBaseMetaTileEntityClass2; - + private static Class<BaseCustomTileEntity> sBaseMetaTileEntityClass; + private static Class<BaseCustomPower_MTE> sBaseMetaTileEntityClass2; + public static AchievementHandler mAssemblyAchievements; - + public static final Map<String, FormattedTooltipString> mCustomGregtechMetaTooltips = new LinkedHashMap<String, FormattedTooltipString>(); - + @SideOnly(Side.CLIENT) public static IIconRegister sBlockIcons, sItemIcons; public Meta_GT_Proxy() { - + } - + public static Block sBlockMachines; - - public void preInit() { - + + public static void preInit() { + //New GT++ Block, yay! (Progress) //sBlockMachines = new GTPP_Block_Machines(); - - GT_Log.out.println("GT++ Mod: Register TileEntities."); - BaseMetaTileEntity tBaseMetaTileEntity = constructBaseMetaTileEntity(); - BaseMetaTileEntity tBaseMetaTileEntity2 = constructBaseMetaTileEntityCustomPower(); - - GT_Log.out.println("GT++ Mod: Testing BaseMetaTileEntity."); - if (tBaseMetaTileEntity == null || tBaseMetaTileEntity2 == null) { - GT_Log.out.println("GT++ Mod: Fatal Error ocurred while initializing TileEntities, crashing Minecraft."); - throw new RuntimeException(""); - } - - //Gotta set it here so that we don't try call gregtech too early. - //Must set on the correct side - - if (ReflectionUtils.doesFieldExist(GT_Proxy.class, "gt6Pipe")) { - StaticFields59.mGT6StylePipes = (boolean) StaticFields59.getFieldFromGregtechProxy("gt6Pipe"); - } - else { - StaticFields59.mGT6StylePipes = false; - } - - GT_Log.out.println("GT++ Mod: Registering the BaseMetaTileEntity."); - GameRegistry.registerTileEntity(tBaseMetaTileEntity.getClass(), "BaseMetaTileEntity_GTPP"); - GameRegistry.registerTileEntity(tBaseMetaTileEntity2.getClass(), "BaseMetaTileEntity_GTPP2"); - CoverManager.generateCustomCovers(); + fixIC2FluidNames(); + + GT_Log.out.println("GT++ Mod: Register TileEntities."); + BaseMetaTileEntity tBaseMetaTileEntity = constructBaseMetaTileEntity(); + BaseMetaTileEntity tBaseMetaTileEntity2 = constructBaseMetaTileEntityCustomPower(); + + GT_Log.out.println("GT++ Mod: Testing BaseMetaTileEntity."); + if (tBaseMetaTileEntity == null || tBaseMetaTileEntity2 == null) { + GT_Log.out.println("GT++ Mod: Fatal Error ocurred while initializing TileEntities, crashing Minecraft."); + throw new RuntimeException(""); + } + + //Gotta set it here so that we don't try call gregtech too early. + //Must set on the correct side + + if (ReflectionUtils.doesFieldExist(GT_Proxy.class, "gt6Pipe")) { + StaticFields59.mGT6StylePipes = (boolean) StaticFields59.getFieldFromGregtechProxy("gt6Pipe"); + } + else { + StaticFields59.mGT6StylePipes = false; + } + + GT_Log.out.println("GT++ Mod: Registering the BaseMetaTileEntity."); + GameRegistry.registerTileEntity(tBaseMetaTileEntity.getClass(), "BaseMetaTileEntity_GTPP"); + GameRegistry.registerTileEntity(tBaseMetaTileEntity2.getClass(), "BaseMetaTileEntity_GTPP2"); + CoverManager.generateCustomCovers(); } - - public void init() { + + public static void init() { scheduleCoverMapCleaner(); setValidHeatingCoilMetas(); + PollutionUtils.setPollutionFluids(); + fixIC2FluidNames(); + } + + public static void postInit() { + mAssemblyAchievements = new AchievementHandler(); + fixIC2FluidNames(); } - - public void postInit() { - mAssemblyAchievements = new AchievementHandler(); + + @SuppressWarnings("deprecation") + public static void fixIC2FluidNames() { + //Fix IC2 Hot Water name + try { + String aNewHeatedWaterName = "Heated Water"; + Logger.INFO("Renaming [IC2 Hotspring Water] --> ["+aNewHeatedWaterName+"].");LanguageRegistry.instance().addStringLocalization("fluidHotWater", "Heated Water"); + LanguageRegistry.instance().addStringLocalization("fluidHotWater", aNewHeatedWaterName); + LanguageRegistry.instance().addStringLocalization("ic2.fluidHotWater", aNewHeatedWaterName); + GT_LanguageManager.addStringLocalization("fluidHotWater", aNewHeatedWaterName); + GT_LanguageManager.addStringLocalization("ic2.fluidHotWater", aNewHeatedWaterName); + + Block b = BlocksItems.getFluidBlock(InternalName.fluidHotWater); + if (b != null) { + LanguageRegistry.addName(ItemUtils.getSimpleStack(b), aNewHeatedWaterName); + LanguageRegistry.instance().addStringLocalization(b.getUnlocalizedName(), aNewHeatedWaterName); + GT_LanguageManager.addStringLocalization(b.getUnlocalizedName(), aNewHeatedWaterName); + } + Fluid f = BlocksItems.getFluid(InternalName.fluidHotWater); + if (f != null) { + LanguageRegistry.instance().addStringLocalization(f.getUnlocalizedName(), aNewHeatedWaterName); + GT_LanguageManager.addStringLocalization(f.getUnlocalizedName(), aNewHeatedWaterName); + int aDam = FluidRegistry.getFluidID(f); + ItemStack s = ItemList.Display_Fluid.getWithDamage(1, aDam); + if (s != null) { + LanguageRegistry.addName(s, aNewHeatedWaterName); + } + } + + String[] aLangs = new String[] { + "de_DE", + "en_US", + "en_GB", + "en_IC", + "es_AR", + "es_ES", + "es_MX", + "es_UY", + "es_VE", + "fr_CA", + "fr_FR", + "it_IT", + "ko_KR", + "pt_BR", + "pt_PT", + "ru_RU", + "sv_SE", + "tr_TR", + "zh_CN", + "zh_TW", + }; + String[] aLangValues = new String[] { + "Erhitztes Wasser", + "Heated Water", + "Heated Water", + "Heated Water", + "Agua caliente", + "Agua caliente", + "Agua caliente", + "Agua caliente", + "Agua caliente", + "Eau chauffée", + "Eau chauffée", + "Acqua riscaldata", + "온수", + "Água aquecida", + "Água aquecida", + "Вода с подогревом", + "Uppvärmt vatten", + "Isıtılmış Su", + "热水", + "热水", + + }; + for (int i=0;i<aLangs.length;i++) { + Logger.REFLECTION("Trying to inject new lang data for "+aLangs[i]+", using value: "+aLangValues[i]); + LangUtils.rewriteEntryForLanguageRegistry(aLangs[i], "fluidHotWater", aLangValues[i]); + LangUtils.rewriteEntryForLanguageRegistry(aLangs[i], "ic2.fluidHotWater", aLangValues[i]); + } + } + + catch (Throwable t) { + + } } - + public static boolean generatePlasmaRecipesForAdvVacFreezer() { - + AutoMap<Recipe_GT> aFreezerMapRebaked = new AutoMap<Recipe_GT>(); AutoMap<Recipe_GT> aRemovedRecipes = new AutoMap<Recipe_GT>(); - + //Find recipes containing Plasma and map them for (Recipe_GT y : Recipe_GT.Gregtech_Recipe_Map.sAdvFreezerRecipes.mRecipeList) { if (y.mFluidInputs.length > 0) { @@ -136,20 +230,20 @@ public class Meta_GT_Proxy { aFreezerMapRebaked.put(y); } } - + AutoMap<Recipe_GT> aNewRecipes = new AutoMap<Recipe_GT>(); int aAtomicMass = 0; int aAtomicTier = 0; - + final FluidStack NULL_PLASMA = Materials._NULL.getPlasma(1); - + for (String s : ELEMENT.NAMES) { - + aAtomicMass++; aAtomicTier = (aAtomicMass/30)+1; FluidStack aMoltenFluid = null; FluidStack aPlasma = null; - + //Try Get Material via Gregtech Materials aGregMaterial = MaterialUtils.getMaterial(s); if (aGregMaterial != null) { @@ -165,7 +259,7 @@ public class Meta_GT_Proxy { } aPlasma = aGregMaterial.getPlasma(100); } - + //Just wildcard values if (aMoltenFluid == null || aPlasma == null) { if (aMoltenFluid == null) { @@ -175,7 +269,7 @@ public class Meta_GT_Proxy { aPlasma = FluidUtils.getFluidStack("plasma."+s.toLowerCase(), 1); } } - + //Skip this material if (aMoltenFluid == null || aPlasma == null || aPlasma.isFluidEqual(NULL_PLASMA)) { Logger.INFO("Could not generate Advanced Vacuum Freezer recipe. Cooling "+s+" plasma. Molten Form Exists? "+(aMoltenFluid != null)+" | Plasma Exists? "+(aPlasma != null)); @@ -190,49 +284,49 @@ public class Meta_GT_Proxy { null, new int[] {10000}, new FluidStack[] { - aPlasma, - FluidUtils.getFluidStack("cryotheum", aTotalTickTime) - }, + aPlasma, + FluidUtils.getFluidStack("cryotheum", aTotalTickTime) + }, new FluidStack[] { - aMoltenFluid - }, + aMoltenFluid + }, aTotalTickTime, (int) GT_Values.V[4+aAtomicTier], aAtomicMass); - + //Add it to the map if it's valid if (aTempRecipe != null) { aNewRecipes.put(aTempRecipe); } } - + } - + //Add the new recipes to the map we will rebake over the original for (Recipe_GT w : aNewRecipes) { aFreezerMapRebaked.put(w); } - + //Best not touch the original map if we don't have a valid map to override it with. if (aFreezerMapRebaked.size() > 0) { - + int aOriginalCount = Recipe_GT.Gregtech_Recipe_Map.sAdvFreezerRecipes.mRecipeList.size(); - + //Empty the original map Recipe_GT.Gregtech_Recipe_Map.sAdvFreezerRecipes.mRecipeList.clear(); - + //Rebake the real map for (Recipe_GT w : aFreezerMapRebaked) { Recipe_GT.Gregtech_Recipe_Map.sAdvFreezerRecipes.mRecipeList.add(w); } - + return Recipe_GT.Gregtech_Recipe_Map.sAdvFreezerRecipes.mRecipeList.size() >= aOriginalCount; } - + return false; } - + public static TileEntity constructCustomGregtechMetaTileEntityByMeta(int aMeta) { if (aMeta == 12) { return Meta_GT_Proxy.constructBaseMetaTileEntityCustomPower(); @@ -241,7 +335,7 @@ public class Meta_GT_Proxy { return Meta_GT_Proxy.constructBaseMetaTileEntity(); } } - + public static BaseCustomTileEntity constructBaseMetaTileEntity() { if (sBaseMetaTileEntityClass == null) { try { @@ -268,7 +362,7 @@ public class Meta_GT_Proxy { } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | SecurityException e) { GT_Log.err - .println("GT++ Mod: Fatal Error ocurred while initializing TileEntities, crashing Minecraft."); + .println("GT++ Mod: Fatal Error ocurred while initializing TileEntities, crashing Minecraft."); e.printStackTrace(GT_Log.err); throw new RuntimeException(e); } @@ -303,21 +397,21 @@ public class Meta_GT_Proxy { } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | SecurityException e) { GT_Log.err - .println("GT++ Mod: Fatal Error ocurred while initializing TileEntities, crashing Minecraft."); + .println("GT++ Mod: Fatal Error ocurred while initializing TileEntities, crashing Minecraft."); e.printStackTrace(GT_Log.err); throw new RuntimeException(e); } } } - - - - - - - - - public void setValidHeatingCoilMetas() { + + + + + + + + + public static void setValidHeatingCoilMetas() { for (int i = 0; i <= 6; i++ ) { GT_ValidHeatingCoilMetas.put(i); } @@ -340,26 +434,27 @@ public class Meta_GT_Proxy { return false; } } - - - public void scheduleCoverMapCleaner(){ - TimerTask repeatedTask = new TimerTask() { - public void run() { - cleanupOverFlowCoverCache(); - } - }; - Timer timer = new Timer("CoverCleanupManager"); - long delay = 120000L; - long period = 300000L; - timer.scheduleAtFixedRate(repeatedTask, delay, period); + + + public static void scheduleCoverMapCleaner(){ + TimerTask repeatedTask = new TimerTask() { + public void run() { + cleanupOverFlowCoverCache(); + } + }; + Timer timer = new Timer("CoverCleanupManager"); + long delay = 120000L; + long period = 300000L; + timer.scheduleAtFixedRate(repeatedTask, delay, period); } - + public static int cleanupOverFlowCoverCache() { ObjMap<String, ?> cache = mOverflowCache; int aRemoved = 0; long aCurrentTime = System.currentTimeMillis()/1000; for (Object o : cache.values()) { if (o != null && o instanceof HashMap) { + @SuppressWarnings("unchecked") HashMap<String, Object> m = (HashMap<String, Object>) o; if (m != null) { String s = (String) m.get("aCoverKey"); @@ -379,57 +474,57 @@ public class Meta_GT_Proxy { } return aRemoved; } - - + + static GT_Proxy[] mProxies = new GT_Proxy[2]; /** * @deprecated Use {@link StaticFields59#getFieldFromGregtechProxy(boolean,String)} instead */ public static Object getFieldFromGregtechProxy(boolean client, String fieldName) { - return StaticFields59.getFieldFromGregtechProxy(fieldName); + return StaticFields59.getFieldFromGregtechProxy(client, fieldName); } - - public void setCustomGregtechTooltip(String aNbtTagName, FormattedTooltipString aData) { + + public static void setCustomGregtechTooltip(String aNbtTagName, FormattedTooltipString aData) { mCustomGregtechMetaTooltips.put(aNbtTagName, aData); } - - public static void conStructGtTileBlockTooltip(ItemStack aStack, EntityPlayer aPlayer, List<Object> aList, boolean par4) { - try { - int tDamage = aStack.getItemDamage(); - if ((tDamage <= 0) || (tDamage >= GregTech_API.METATILEENTITIES.length)) { - return; - } - - if (GregTech_API.METATILEENTITIES[tDamage] != null) { - IGregTechTileEntity tTileEntity = GregTech_API.METATILEENTITIES[tDamage].getBaseMetaTileEntity(); - if (tTileEntity.getDescription() != null) { - int i = 0; - for (String tDescription : tTileEntity.getDescription()) { - if (GT_Utility.isStringValid(tDescription)) { - if(tDescription.contains("%%%")){ - String[] tString = tDescription.split("%%%"); - if(tString.length>=2){ - StringBuffer tBuffer = new StringBuffer(); - Object tRep[] = new String[tString.length / 2]; - for (int j = 0; j < tString.length; j++) - if (j % 2 == 0) tBuffer.append(tString[j]); - else {tBuffer.append(" %s"); tRep[j / 2] = tString[j];} - aList.add(String.format(GT_LanguageManager.addStringLocalization("TileEntity_DESCRIPTION_" + tDamage + "_Index_" + i++, tBuffer.toString(), !GregTech_API.sPostloadFinished), tRep)); - } - }else{String tTranslated = GT_LanguageManager.addStringLocalization("TileEntity_DESCRIPTION_" + tDamage + "_Index_" + i++, tDescription, !GregTech_API.sPostloadFinished ); - aList.add(tTranslated.equals("") ? tDescription : tTranslated);} - }else i++; - } - } - + + public static void conStructGtTileBlockTooltip(ItemStack aStack, EntityPlayer aPlayer, List<Object> aList, boolean par4) { + try { + int tDamage = aStack.getItemDamage(); + if ((tDamage <= 0) || (tDamage >= GregTech_API.METATILEENTITIES.length)) { + return; + } + + if (GregTech_API.METATILEENTITIES[tDamage] != null) { + IGregTechTileEntity tTileEntity = GregTech_API.METATILEENTITIES[tDamage].getBaseMetaTileEntity(); + if (tTileEntity.getDescription() != null) { + int i = 0; + for (String tDescription : tTileEntity.getDescription()) { + if (GT_Utility.isStringValid(tDescription)) { + if(tDescription.contains("%%%")){ + String[] tString = tDescription.split("%%%"); + if(tString.length>=2){ + StringBuffer tBuffer = new StringBuffer(); + Object tRep[] = new String[tString.length / 2]; + for (int j = 0; j < tString.length; j++) + if (j % 2 == 0) tBuffer.append(tString[j]); + else {tBuffer.append(" %s"); tRep[j / 2] = tString[j];} + aList.add(String.format(GT_LanguageManager.addStringLocalization("TileEntity_DESCRIPTION_" + tDamage + "_Index_" + i++, tBuffer.toString(), !GregTech_API.sPostloadFinished), tRep)); + } + }else{String tTranslated = GT_LanguageManager.addStringLocalization("TileEntity_DESCRIPTION_" + tDamage + "_Index_" + i++, tDescription, !GregTech_API.sPostloadFinished ); + aList.add(tTranslated.equals("") ? tDescription : tTranslated);} + }else i++; + } + } + if (tTileEntity.getEUCapacity() > 0L) { final long tVoltage = tTileEntity.getInputVoltage(); byte tTier = (byte) ((byte) Math.max(1, GT_Utility.getTier(tVoltage))); - + //Custom handling if (tDamage < 30500 && tDamage >= 30400) { int aOffset = tDamage - 30400; @@ -442,13 +537,13 @@ public class Meta_GT_Proxy { aList.add(GT_LanguageManager.addStringLocalization("TileEntity_Breaker_Loss", "Breaker Loss: "+EnumChatFormatting.RED+""+(GT_Values.V[Math.max(tTier-1, 0)]/10)+EnumChatFormatting.GRAY+" EU/t", !GregTech_API.sPostloadFinished) + EnumChatFormatting.GRAY); } - + aList.add(GT_LanguageManager.addStringLocalization("TileEntity_Special_Power_1", EnumChatFormatting.RED+"Special Power Handling, please read manual", !GregTech_API.sPostloadFinished) + EnumChatFormatting.GRAY); //aList.add(GT_LanguageManager.addStringLocalization("TileEntity_BreakerBox_2", EnumChatFormatting.RED+"Special Power Handling, please read manual", !GregTech_API.sPostloadFinished) + EnumChatFormatting.GRAY); //aList.add(GT_LanguageManager.addStringLocalization("TileEntity_BreakerBox_3", EnumChatFormatting.RED+"Special Power Handling, please read manual", !GregTech_API.sPostloadFinished) + EnumChatFormatting.GRAY); } - - + + if (tTileEntity.getInputVoltage() > 0L) { String inA = "0"; if (tTileEntity.getInputAmperage() >= 1L) { @@ -476,20 +571,20 @@ public class Meta_GT_Proxy { + EnumChatFormatting.GRAY + outA; aList.add(a1); } - + if (tTileEntity.getOutputVoltage() > 0L) { aList.add(GT_LanguageManager.addStringLocalization("TileEntity_Lossess_EU", "Transmission Loss: "+EnumChatFormatting.DARK_BLUE+""+(tDamage < 30500 && tDamage >= 30400 ? 0 : 1), !GregTech_API.sPostloadFinished) + EnumChatFormatting.GRAY); } - + if (tTileEntity.getEUCapacity() > 0) { aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_STORE2", "Internal Capacity: ", !GregTech_API.sPostloadFinished) + EnumChatFormatting.BLUE + tTileEntity.getEUCapacity() + EnumChatFormatting.GRAY + " EU"); } } - - /*if (tTileEntity.getEUCapacity() > 0L) { + + /*if (tTileEntity.getEUCapacity() > 0L) { if (tTileEntity.getInputVoltage() > 0L) { aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_IN", "Voltage IN: ", !GregTech_API.sPostloadFinished ) + EnumChatFormatting.GREEN + tTileEntity.getInputVoltage() + " (" + GT_Values.VN[GT_Utility.getTier(tTileEntity.getInputVoltage())] + ")" + EnumChatFormatting.GRAY); } @@ -501,42 +596,42 @@ public class Meta_GT_Proxy { } aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_STORE", "Capacity: ", !GregTech_API.sPostloadFinished ) + EnumChatFormatting.BLUE + tTileEntity.getEUCapacity() + EnumChatFormatting.GRAY); }*/ - - } - NBTTagCompound aNBT = aStack.getTagCompound(); - if (aNBT != null) { - if (aNBT.getBoolean("mMuffler")) { - aList.add(GT_LanguageManager.addStringLocalization("GT_TileEntity_MUFFLER", "has Muffler Upgrade", !GregTech_API.sPostloadFinished )); - } - if (aNBT.getBoolean("mSteamConverter")) { - aList.add(GT_LanguageManager.addStringLocalization("GT_TileEntity_STEAMCONVERTER", "has Steam Upgrade", !GregTech_API.sPostloadFinished )); - } - int tAmount = 0; - if ((tAmount = aNBT.getByte("mSteamTanks")) > 0) { - aList.add(tAmount + " " + GT_LanguageManager.addStringLocalization("GT_TileEntity_STEAMTANKS", "Steam Tank Upgrades", !GregTech_API.sPostloadFinished )); - } - - FluidStack afluid = net.minecraftforge.fluids.FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mFluid")); - if (afluid != null) { - int tFluidAmount = afluid.amount; - if (tFluidAmount > 0) { - aList.add(GT_LanguageManager.addStringLocalization("GT_TileEntity_FLUIDTANK", "Tank Fluid: "+tFluidAmount+"L "+afluid.getLocalizedName()+"", !GregTech_API.sPostloadFinished )); - } - } - - } - - //Add Custom Here - - //Add Custom Tooltips - for (String s : mCustomGregtechMetaTooltips.keySet()) { - if (aNBT.hasKey(s)) { - String aTip = mCustomGregtechMetaTooltips.get(s).getTooltip(aNBT.getString(s)); - aList.add(aTip); - } - } - - //Add GT++ Stuff + + } + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + if (aNBT.getBoolean("mMuffler")) { + aList.add(GT_LanguageManager.addStringLocalization("GT_TileEntity_MUFFLER", "has Muffler Upgrade", !GregTech_API.sPostloadFinished )); + } + if (aNBT.getBoolean("mSteamConverter")) { + aList.add(GT_LanguageManager.addStringLocalization("GT_TileEntity_STEAMCONVERTER", "has Steam Upgrade", !GregTech_API.sPostloadFinished )); + } + int tAmount = 0; + if ((tAmount = aNBT.getByte("mSteamTanks")) > 0) { + aList.add(tAmount + " " + GT_LanguageManager.addStringLocalization("GT_TileEntity_STEAMTANKS", "Steam Tank Upgrades", !GregTech_API.sPostloadFinished )); + } + + FluidStack afluid = net.minecraftforge.fluids.FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mFluid")); + if (afluid != null) { + int tFluidAmount = afluid.amount; + if (tFluidAmount > 0) { + aList.add(GT_LanguageManager.addStringLocalization("GT_TileEntity_FLUIDTANK", "Tank Fluid: "+tFluidAmount+"L "+afluid.getLocalizedName()+"", !GregTech_API.sPostloadFinished )); + } + } + + } + + //Add Custom Here + + //Add Custom Tooltips + for (String s : mCustomGregtechMetaTooltips.keySet()) { + if (aNBT.hasKey(s)) { + String aTip = mCustomGregtechMetaTooltips.get(s).getTooltip(aNBT.getString(s)); + aList.add(aTip); + } + } + + //Add GT++ Stuff if (tDamage >= 30400 && tDamage < 30500) { aList.add(EnumChatFormatting.UNDERLINE+"Special GT++ Machine"); @@ -544,11 +639,11 @@ public class Meta_GT_Proxy { if ((tDamage >= 750 && tDamage < 1000) || (tDamage >= 30000 && tDamage < 31000)) { aList.add(CORE.GT_Tooltip); } - - - } catch (Throwable e) { - e.printStackTrace(GT_Log.err); - } - } + + + } catch (Throwable e) { + e.printStackTrace(GT_Log.err); + } + } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/StaticFields59.java b/src/Java/gtPlusPlus/xmod/gregtech/common/StaticFields59.java index 9c552db3ad..814ed589f0 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/StaticFields59.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/StaticFields59.java @@ -18,6 +18,7 @@ import gregtech.api.interfaces.ITexture; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Muffler; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_TieredMachineBlock; import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gregtech.common.GT_Proxy; import gtPlusPlus.api.objects.Logger; @@ -37,6 +38,7 @@ public class StaticFields59 { public static final Field mPreventableComponents; public static final Field mDisabledItems; public static final Field mMultiblockChemicalRecipes; + public static final Field mPyrolyseRecipes; public static final Field mDescriptionArray; public static final Field mCasingTexturePages; public static final Field mAssLineVisualMapNEI; @@ -79,8 +81,16 @@ public class StaticFields59 { } sAssemblylineVisualRecipes = aTemp; + mMultiblockChemicalRecipes = getField(GT_Recipe_Map.class, "sMultiblockChemicalRecipes"); - Logger.INFO("[SH] Got Field: sMultiblockChemicalRecipes"); + Logger.INFO("[SH] Got Field: sMultiblockChemicalRecipes"); + if (ReflectionUtils.doesFieldExist(GT_Recipe.GT_Recipe_Map.class, "sPyrolyseRecipes")) { + mPyrolyseRecipes = getField(GT_Recipe_Map.class, "sPyrolyseRecipes"); + Logger.INFO("[SH] Got Field: sPyrolyseRecipes"); + } + else { + mPyrolyseRecipes = null; + } mCalculatePollutionReduction = getMethod(GT_MetaTileEntity_Hatch_Muffler.class, "calculatePollutionReduction", int.class); @@ -148,6 +158,14 @@ public class StaticFields59 { } } + public static synchronized final GT_Recipe_Map getPyrolyseRecipeMap() { + try { + return mPyrolyseRecipes != null ? (GT_Recipe_Map) mPyrolyseRecipes.get(null) : null; + } catch (IllegalArgumentException | IllegalAccessException e) { + return null; + } + } + public static Materials getMaterial(String aMaterialName) { Materials m = mMaterialCache.get(aMaterialName); if (m != null) { diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GTPP_Block_Machines.java b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GTPP_Block_Machines.java index c62d47e904..01f655c355 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GTPP_Block_Machines.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GTPP_Block_Machines.java @@ -15,13 +15,13 @@ import gregtech.api.items.GT_Generic_Block; import gregtech.api.metatileentity.BaseMetaPipeEntity; import gregtech.api.metatileentity.BaseMetaTileEntity; import gregtech.api.metatileentity.BaseTileEntity; -import gregtech.api.objects.XSTR; import gregtech.api.util.GT_Log; import gregtech.api.util.GT_Utility; import gregtech.common.blocks.GT_Item_Machines; import gregtech.common.blocks.GT_Material_Machines; import gregtech.common.render.GT_Renderer_Block; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.random.XSTR; import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy; import gtPlusPlus.xmod.gregtech.common.render.GTPP_Render_MachineBlock; import net.minecraft.block.Block; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks3.java b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks3.java index 4c534eb7bb..8e6a55c9c5 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks3.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks3.java @@ -66,6 +66,7 @@ extends GregtechMetaCasingBlocksAbstract { GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".11.name", "Volcanus Casing"); GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".12.name", "Fusion Machine Casing MK III"); GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".13.name", "Advanced Fusion Coil"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".14.name", "Unnamed"); GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".15.name", "Containment Casing"); GregtechItemList.Casing_FishPond.set(new ItemStack(this, 1, 0)); GregtechItemList.Casing_Extruder.set(new ItemStack(this, 1, 1)); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks4.java b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks4.java index 321ab43134..b624649789 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks4.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks4.java @@ -138,7 +138,7 @@ extends GregtechMetaCasingBlocksAbstract { return TexturesGtBlock.Casing_Material_RedSteel.getIcon(); case 15: default: - return TexturesGtBlock.Overlay_UU_Matter.getIcon(); + return TexturesGtBlock.Casing_Material_MaragingSteel.getIcon(); } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java index 09f3f2d1f5..6cac1fddea 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java @@ -350,8 +350,13 @@ public class TexturesGtBlock { private static final CustomIcon Internal_Overlay_Machine_Controller_Advanced_Active = new CustomIcon("iconsets/OVERLAY_FRONT_ADVANCED_MULTIBLOCK_ANIMATED_ACTIVE"); public static final CustomIcon Overlay_Machine_Controller_Advanced_Active = Internal_Overlay_Machine_Controller_Advanced_Active; - - + //Fluid Reactor Overlays + public static final CustomIcon Overlay_FluidReactor_Front = new CustomIcon("TileEntities/FluidReactor/OVERLAY_FRONT"); + public static final CustomIcon Overlay_FluidReactor_Side = new CustomIcon("TileEntities/FluidReactor/OVERLAY_SIDE"); + public static final CustomIcon Overlay_FluidReactor_Top = new CustomIcon("TileEntities/FluidReactor/OVERLAY_TOP"); + public static final CustomIcon Overlay_FluidReactor_Front_Active = new CustomIcon("TileEntities/FluidReactor/OVERLAY_FRONT_ACTIVE"); + public static final CustomIcon Overlay_FluidReactor_Side_Active = new CustomIcon("TileEntities/FluidReactor/OVERLAY_SIDE_ACTIVE"); + public static final CustomIcon Overlay_FluidReactor_Top_Active = new CustomIcon("TileEntities/FluidReactor/OVERLAY_TOP_ACTIVE"); //Crafting Overlays private static final CustomIcon Internal_Overlay_Crafting_Bronze = new CustomIcon("TileEntities/bronze_top_crafting"); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_ToggleVisual.java b/src/Java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_ToggleVisual.java index 561da54ceb..65b59ce151 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_ToggleVisual.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_ToggleVisual.java @@ -9,6 +9,7 @@ import gregtech.api.util.GT_CoverBehavior; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.minecraft.BlockPos; import gtPlusPlus.api.objects.random.XSTR; +import gtPlusPlus.core.util.minecraft.LangUtils; import gtPlusPlus.core.util.minecraft.PlayerUtils; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -37,7 +38,7 @@ public class GTPP_Cover_ToggleVisual extends GT_CoverBehavior { public boolean onCoverRightclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { - PlayerUtils.messagePlayer(aPlayer, this.trans("756", "Connectable: ") + getConnectionState(aCoverVariable)); + PlayerUtils.messagePlayer(aPlayer, LangUtils.trans("756", "Connectable: ") + getConnectionState(aCoverVariable)); return super.onCoverRightclick(aSide, aCoverID, aCoverVariable, aTileEntity, aPlayer, aX, aY, aZ); } @@ -71,7 +72,7 @@ public class GTPP_Cover_ToggleVisual extends GT_CoverBehavior { } public String getDescription(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { - return this.trans("756", "Connectable: ") + getConnectionState(aCoverVariable); + return LangUtils.trans("756", "Connectable: ") + getConnectionState(aCoverVariable); } public int getTickRate(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/GT_MethodHelper.java b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/GT_MethodHelper.java new file mode 100644 index 0000000000..d51107bbf0 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/GT_MethodHelper.java @@ -0,0 +1,80 @@ +package gtPlusPlus.xmod.gregtech.common.helpers; + +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +import gregtech.api.enums.Textures.BlockIcons; +import gregtech.api.interfaces.ITexture; +import gregtech.api.metatileentity.BaseMetaTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import net.minecraft.block.Block; +import net.minecraft.tileentity.TileEntity; + +public class GT_MethodHelper { + + private static final Method mGetTexture; + private static final Class mITexturedTileEntity; + + static { + Class clazz = null; + Method aMeth = null; + if (ReflectionUtils.doesClassExist("gregtech.api.interfaces.tileentity.ITexturedTileEntity")) { + clazz = ReflectionUtils.getClass("gregtech.api.interfaces.tileentity.ITexturedTileEntity"); + aMeth = ReflectionUtils.getMethod(clazz, "getTexture", Block.class, byte.class); + } + mITexturedTileEntity = clazz; + mGetTexture = aMeth; + } + + + public static ITexture[] getTexture(TileEntity tTileEntity, Block aBlock, byte aSide) { + + if (mITexturedTileEntity.isInstance(tTileEntity)) { + + if (mGetTexture != null) { + try { + mGetTexture.invoke(tTileEntity, aBlock, aSide); + } + catch (IllegalAccessException | IllegalArgumentException + | InvocationTargetException e) { + e.printStackTrace(); + } + } + else { + if (tTileEntity instanceof BaseMetaTileEntity) { + try { + BaseMetaTileEntity aTile = (BaseMetaTileEntity) tTileEntity; + ITexture rIcon = aTile.getCoverTexture(aSide); + Field aFacing = ReflectionUtils.getField(BaseMetaTileEntity.class, "mFacing"); + Field aColor = ReflectionUtils.getField(BaseMetaTileEntity.class, "mColor"); + Field aActive = ReflectionUtils.getField(BaseMetaTileEntity.class, "mActive"); + Field aMetaTile = ReflectionUtils.getField(BaseMetaTileEntity.class, "mMetaTileEntity"); + Method aHasValidTile = ReflectionUtils.getMethod(BaseMetaTileEntity.class, "hasValidMetaTileEntity", new Class[] {}); + + boolean hasValidTileObj = (boolean) aHasValidTile.invoke(aTile, new Object[] {}); + boolean aActiveObj = aActive.getBoolean(aTile); + byte aFacingObj = aFacing.getByte(aTile); + byte aColorObj = aColor.getByte(aTile);; + MetaTileEntity aMetaTileObj = (MetaTileEntity) aMetaTile.get(aTile); + + if (rIcon != null) { + return new ITexture[]{rIcon}; + } else { + return hasValidTileObj + ? aMetaTileObj.getTexture(aTile, aSide, aFacingObj, (byte) (aColorObj - 1), aActiveObj, + aTile.getOutputRedstoneSignal(aSide) > 0) + : BlockIcons.ERROR_RENDERING; + } + } + catch (Throwable t) { + t.printStackTrace(); + } + } + } + } + return BlockIcons.ERROR_RENDERING; + } + +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/TreeFarmHelper.java b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/TreeFarmHelper.java index 4038d5bdf4..8b3fb9a42f 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/TreeFarmHelper.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/TreeFarmHelper.java @@ -297,7 +297,7 @@ public class TreeFarmHelper { return true; } else if (aStack.getUnlocalizedName().toLowerCase().contains("mu-metaitem")) { - String[] aData = aStack.getUnlocalizedName().toLowerCase().split("."); + String[] aData = aStack.getUnlocalizedName().toLowerCase().split("//."); if (aData != null && aData.length > 0) { for (String s : aData) { if (s.contains("32120")) { diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechTools.java b/src/Java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechTools.java index 8add5d5a6e..bc11cb6a11 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechTools.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechTools.java @@ -1,10 +1,14 @@ package gtPlusPlus.xmod.gregtech.common.items; +import java.lang.reflect.Field; + import gregtech.api.GregTech_API; import gregtech.api.enums.TC_Aspects; import gregtech.api.enums.ToolDictNames; import gregtech.api.items.GT_MetaGenerated_Tool; -import gregtech.common.tools.GT_Tool_WireCutter; +import gregtech.api.objects.GT_HashSet; +import gregtech.api.objects.GT_ItemStack; +import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.gregtech.api.enums.GregtechToolDictNames; import gtPlusPlus.xmod.gregtech.common.tools.TOOL_Gregtech_AngelGrinder; import gtPlusPlus.xmod.gregtech.common.tools.TOOL_Gregtech_Choocher; @@ -20,10 +24,18 @@ public class MetaGeneratedGregtechTools extends GT_MetaGenerated_Tool { public static final short ANGLE_GRINDER = 7834; public static final short ELECTRIC_SNIPS = 7934; public static GT_MetaGenerated_Tool INSTANCE; + + static { + INSTANCE = new MetaGeneratedGregtechTools(); + } + + public static GT_MetaGenerated_Tool getInstance() { + return INSTANCE; + } + - public MetaGeneratedGregtechTools() { + private MetaGeneratedGregtechTools() { super("plusplus.metatool.01"); - INSTANCE = this; // Skookum Choocher GregTech_API.registerTool(this.addTool(SKOOKUM_CHOOCHER, "Skookum Choocher", "Can Really Chooch. Does a Skookum job at Hammering and Wrenching stuff.", new TOOL_Gregtech_Choocher(), @@ -41,6 +53,23 @@ public class MetaGeneratedGregtechTools extends GT_MetaGenerated_Tool { new TC_Aspects.TC_AspectStack(TC_Aspects.FABRICO, 2L), new TC_Aspects.TC_AspectStack(TC_Aspects.ORDO, 2L) }); + GT_HashSet<GT_ItemStack> aWireCutterList = new GT_HashSet<GT_ItemStack>(); + //Does not exist prior to 5.09.32, use an empty field if we can't find the existing one. + if (ReflectionUtils.doesFieldExist(GregTech_API.class, "sWireCutterList")) { + Field sWireCutterList = ReflectionUtils.getField(GregTech_API.class, "sWireCutterList"); + try { + if (sWireCutterList != null) { + Object val = sWireCutterList.get(null); + if (val != null && val instanceof GT_HashSet) { + aWireCutterList = (GT_HashSet<GT_ItemStack>) val; + } + } + + } + catch (IllegalArgumentException | IllegalAccessException e) { + // Not found, so it's GT 5.09.31 or earlier. + } + } // Electric Wire Cutter GregTech_API.registerTool( @@ -49,7 +78,7 @@ public class MetaGeneratedGregtechTools extends GT_MetaGenerated_Tool { new Object[] { GregtechToolDictNames.craftingToolElectricSnips, ToolDictNames.craftingToolWireCutter, new TC_Aspects.TC_AspectStack(TC_Aspects.INSTRUMENTUM, 4L), new TC_Aspects.TC_AspectStack(TC_Aspects.FABRICO, 4L), - new TC_Aspects.TC_AspectStack(TC_Aspects.ORDO, 4L) }), GregTech_API.sWireCutterList); + new TC_Aspects.TC_AspectStack(TC_Aspects.ORDO, 4L) }), aWireCutterList); // Electric Lighter diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/render/GTPP_CapeRenderer.java b/src/Java/gtPlusPlus/xmod/gregtech/common/render/GTPP_CapeRenderer.java index 763a4a129d..6201a782de 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/render/GTPP_CapeRenderer.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/render/GTPP_CapeRenderer.java @@ -63,7 +63,6 @@ public class GTPP_CapeRenderer extends RenderPlayer { private final ArrayList<String> mData; public GTPP_CapeRenderer() { - setRenderManager(RenderManager.instance); downloadCapeList(); ArrayList<String> aTemp = new ArrayList<String>(); try { @@ -76,10 +75,19 @@ public class GTPP_CapeRenderer extends RenderPlayer { } private static boolean hasResourceChecked = false; + private static boolean hasSetRenderer = false; private boolean hasCape = false; private ResourceLocation tResource = null; public synchronized void receiveRenderSpecialsEvent(RenderPlayerEvent.Specials.Pre aEvent) { + if (this.renderManager == null) { + hasSetRenderer = false; + } + if (!hasSetRenderer) { + if (RenderManager.instance != null) { + setRenderManager(RenderManager.instance); + } + } AbstractClientPlayer aPlayer = (AbstractClientPlayer) aEvent.entityPlayer; if (!ConfigSwitches.enableCustomCapes) { aEvent.setCanceled(true); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/render/GTPP_Render_MachineBlock.java b/src/Java/gtPlusPlus/xmod/gregtech/common/render/GTPP_Render_MachineBlock.java index c884114b79..35d78008c5 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/render/GTPP_Render_MachineBlock.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/render/GTPP_Render_MachineBlock.java @@ -10,10 +10,9 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.interfaces.tileentity.IPipeRenderedTileEntity; import gregtech.api.interfaces.tileentity.ITexturedTileEntity; import gregtech.common.blocks.GT_Block_Machines; -import gregtech.common.blocks.GT_Block_Ores_Abstract; -import gregtech.common.blocks.GT_TileEntity_Ores; import gregtech.common.render.GT_Renderer_Block; import gtPlusPlus.xmod.gregtech.common.blocks.GTPP_Block_Machines; +import gtPlusPlus.xmod.gregtech.common.helpers.GT_MethodHelper; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.Tessellator; @@ -134,14 +133,15 @@ public class GTPP_Render_MachineBlock extends GT_Renderer_Block { public static boolean renderStandardBlock(IBlockAccess aWorld, int aX, int aY, int aZ, Block aBlock, RenderBlocks aRenderer) { TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + return tTileEntity instanceof ITexturedTileEntity ? renderStandardBlock(aWorld, aX, aY, aZ, aBlock, aRenderer, - new ITexture[][]{((ITexturedTileEntity) tTileEntity).getTexture(aBlock, (byte) 0), - ((ITexturedTileEntity) tTileEntity).getTexture(aBlock, (byte) 1), - ((ITexturedTileEntity) tTileEntity).getTexture(aBlock, (byte) 2), - ((ITexturedTileEntity) tTileEntity).getTexture(aBlock, (byte) 3), - ((ITexturedTileEntity) tTileEntity).getTexture(aBlock, (byte) 4), - ((ITexturedTileEntity) tTileEntity).getTexture(aBlock, (byte) 5)}) + new ITexture[][]{GT_MethodHelper.getTexture(tTileEntity, aBlock, (byte) 0), + GT_MethodHelper.getTexture(tTileEntity, aBlock, (byte) 1), + GT_MethodHelper.getTexture(tTileEntity, aBlock, (byte) 2), + GT_MethodHelper.getTexture(tTileEntity, aBlock, (byte) 3), + GT_MethodHelper.getTexture(tTileEntity, aBlock, (byte) 4), + GT_MethodHelper.getTexture(tTileEntity, aBlock, (byte) 5)}) : false; } @@ -190,7 +190,7 @@ public class GTPP_Render_MachineBlock extends GT_Renderer_Block { ITexture[][] tCovers = new ITexture[6][]; for (byte i = 0; i < 6; ++i) { - tCovers[i] = aTileEntity.getTexture(aBlock, i); + tCovers[i] = GT_MethodHelper.getTexture((TileEntity) aTileEntity, aBlock, i); arg15[i] = aTileEntity.getTextureUncovered(i); } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/creative/GregtechMetaCreativeEnergyBuffer.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/creative/GregtechMetaCreativeEnergyBuffer.java index 1ee27afbf0..2f00600af6 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/creative/GregtechMetaCreativeEnergyBuffer.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/creative/GregtechMetaCreativeEnergyBuffer.java @@ -22,6 +22,7 @@ import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.PlayerUtils; import gtPlusPlus.core.util.reflect.ReflectionUtils; +import gtPlusPlus.core.util.sys.KeyboardUtils; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock.CustomIcon; import gtPlusPlus.xmod.gregtech.common.tileentities.storage.GregtechMetaEnergyBuffer; @@ -48,7 +49,7 @@ public class GregtechMetaCreativeEnergyBuffer extends GregtechMetaEnergyBuffer { @Override public String[] getDescription() { - return new String[] {this.mDescription, "Use Screwdriver to change voltage", EnumChatFormatting.GREEN+"CREATIVE MACHINE"}; + return new String[] {this.mDescription, "Use Screwdriver to change voltage", "Hold Shift while using Screwdriver to change amperage", EnumChatFormatting.GREEN+"CREATIVE MACHINE"}; } /* @@ -177,43 +178,48 @@ public class GregtechMetaCreativeEnergyBuffer extends GregtechMetaEnergyBuffer { } @Override - public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - if (this.mTier < 9) { - this.mTier++; + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (KeyboardUtils.isShiftKeyDown()) { + super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); } else { - this.mTier = 0; - } - this.markDirty(); - try { - Field field = ReflectionUtils.getField(this.getClass(), "mTextures"); - field.setAccessible(true); - Field modifiersField = Field.class.getDeclaredField("modifiers"); - modifiersField.setAccessible(true); - modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL); - ITexture[][][] V = getTextureSet(null); - if (V != null) { - Logger.REFLECTION("Got Valid Textures."); - if (this.getBaseMetaTileEntity().isClientSide()) { - Logger.REFLECTION("Clientside Call."); - Logger.REFLECTION("Refreshing Textures on buffer."); - field.set(this, V); - Logger.REFLECTION("Refreshed Textures on buffer."); + if (this.mTier < (CORE.GTNH ? GT_Values.V.length : 9)) { + this.mTier++; + } + else { + this.mTier = 0; + } + this.markDirty(); + try { + Field field = ReflectionUtils.getField(this.getClass(), "mTextures"); + field.setAccessible(true); + Field modifiersField = Field.class.getDeclaredField("modifiers"); + modifiersField.setAccessible(true); + modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL); + ITexture[][][] V = getTextureSet(null); + if (V != null) { + Logger.REFLECTION("Got Valid Textures."); + if (this.getBaseMetaTileEntity().isClientSide()) { + Logger.REFLECTION("Clientside Call."); + Logger.REFLECTION("Refreshing Textures on buffer."); + field.set(this, V); + Logger.REFLECTION("Refreshed Textures on buffer."); + } + else { + Logger.REFLECTION("Serverside Call."); + } } else { - Logger.REFLECTION("Serverside Call."); - } + Logger.REFLECTION("Bad mTextures setter."); + } } - else { - Logger.REFLECTION("Bad mTextures setter."); - } - } - catch (Throwable t) { - //Bad refresh. - t.printStackTrace(); - Logger.REFLECTION("Bad mTextures setter."); - } - PlayerUtils.messagePlayer(aPlayer, "Now running at "+GT_Values.VOLTAGE_NAMES[this.mTier]+". ["+MathUtils.isNumberEven(this.mTier)+"]"); - super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); + catch (Throwable t) { + //Bad refresh. + t.printStackTrace(); + Logger.REFLECTION("Bad mTextures setter."); + } + PlayerUtils.messagePlayer(aPlayer, "Now running at "+GT_Values.VOLTAGE_NAMES[this.mTier]+"."); + } + } }
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaAtmosphericReconditioner.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaAtmosphericReconditioner.java index 4795b0d0b9..10a1f96be7 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaAtmosphericReconditioner.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaAtmosphericReconditioner.java @@ -710,8 +710,17 @@ public class GregtechMetaAtmosphericReconditioner extends GT_MetaTileEntity_Basi catch (Throwable t) { aTooltipSuper.put("Maximum pollution removed per second: "+mPollutionReduction); } - aTooltipSuper.put("Air Sides: "+mAirSides); - return aTooltipSuper.toArray(); + aTooltipSuper.put("Air Sides: "+mAirSides); + + String[] mBuiltOutput = new String[aTooltipSuper.size()]; + int aIndex = 0; + for (String i : aTooltipSuper) { + mBuiltOutput[aIndex++] = i; + } + + + + return mBuiltOutput; } @Override diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_ChemicalReactor.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_ChemicalReactor.java new file mode 100644 index 0000000000..b7e4618e07 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_ChemicalReactor.java @@ -0,0 +1,688 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic; + +import static gregtech.api.enums.GT_Values.E; + +import java.util.HashSet; +import java.util.List; + +import cpw.mods.fml.common.registry.LanguageRegistry; +import gregtech.GT_Mod; +import gregtech.api.GregTech_API; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gregtech.api.util.GT_Utility; +import gregtech.api.util.Recipe_GT; +import gtPlusPlus.api.objects.random.XSTR; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.slots.SlotChemicalPlantInput; +import gtPlusPlus.xmod.gregtech.api.gui.fluidreactor.Container_FluidReactor; +import gtPlusPlus.xmod.gregtech.api.gui.fluidreactor.GUI_FluidReactor; +import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidHandler; + +public class GregtechMetaTileEntity_ChemicalReactor extends GT_MetaTileEntity_BasicMachine { + + public boolean mFluidTransfer_1 = false; + public boolean mFluidTransfer_2 = false; + + public FluidStack[] mInputFluids = new FluidStack[4]; + public FluidStack[] mOutputFluids = new FluidStack[2]; + + private static final GT_Recipe_Map mFluidChemicalReactorRecipes = new GT_Recipe_Map( + new HashSet<GT_Recipe>(100), + "gt.recipe.fluidchemicaleactor", + "Chemical Plant", + null, + CORE.MODID+":textures/gui/FluidReactor", + 0, + 0, + 0, + 2, + 1, + "Tier: ", + 1, + E, + true, + false); + + public GregtechMetaTileEntity_ChemicalReactor(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, 1, + "For mixing fluids", 4, 4, "ChemicalReactor.png", "", + new ITexture[]{ + new GT_RenderedTexture(TexturesGtBlock.Overlay_FluidReactor_Side_Active), + new GT_RenderedTexture(TexturesGtBlock.Overlay_FluidReactor_Side), + new GT_RenderedTexture(TexturesGtBlock.Overlay_FluidReactor_Front_Active), + new GT_RenderedTexture(TexturesGtBlock.Overlay_FluidReactor_Front), + new GT_RenderedTexture(TexturesGtBlock.Overlay_FluidReactor_Top_Active), + new GT_RenderedTexture(TexturesGtBlock.Overlay_FluidReactor_Top), + new GT_RenderedTexture(TexturesGtBlock.Overlay_FluidReactor_Top_Active), + new GT_RenderedTexture(TexturesGtBlock.Overlay_FluidReactor_Top) + } + ); + } + + public GregtechMetaTileEntity_ChemicalReactor(String aName, int aTier, String aDescription, ITexture[][][] aTextures, String aGUIName, String aNEIName) { + super(aName, aTier, 1, aDescription, aTextures, 1, 1, aGUIName, aNEIName); + } + + /*public GregtechMetaTileEntity_BasicWasher(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures, String aGUIName, String aNEIName) { + super(aName, aTier, 1, aDescription, aTextures, 1, 1, aGUIName, aNEIName); + }*/ + + @Override + public String[] getDescription() { + return new String[]{this.mDescription, "Because why not?", }; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + try { + GregtechMetaTileEntity_ChemicalReactor y = new GregtechMetaTileEntity_ChemicalReactor(this.mName, this.mTier, this.mDescription, this.mTextures, this.mGUIName, this.mNEIName); + return y; + } + catch(Throwable t) { + t.printStackTrace(); + } + return null; + } + + @Override + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + try { + Container_FluidReactor y = new Container_FluidReactor(aPlayerInventory, aBaseMetaTileEntity); + return y; + } + catch(Throwable t) { + t.printStackTrace(); + } + return null; + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_FluidReactor(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), + this.mGUIName, + GT_Utility.isStringValid(this.mNEIName) + ? this.mNEIName + : (this.getRecipeList() != null ? this.getRecipeList().mUnlocalizedName : "")); + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeList() { + if (mFluidChemicalReactorRecipes.mRecipeList.isEmpty()) { + for (Recipe_GT i :Recipe_GT.Gregtech_Recipe_Map.sFluidChemicalReactorRecipes.mRecipeList) { + mFluidChemicalReactorRecipes.add(i); + } + } + return mFluidChemicalReactorRecipes; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return (super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack)) && (getRecipeList().containsInput(aStack)); + } + + @Override + public boolean isFluidInputAllowed(FluidStack aFluid) { + return (super.isFluidInputAllowed(aFluid)); + } + + @Override + public int getCapacity() { + return 32000 * Math.max(1, this.mTier) / 4; + } + + @Override + public int getInputSlot() { + return 3; + } + + @Override + public boolean isLiquidInput(byte aSide) { + return aSide > 1; + } + + @Override + public boolean isLiquidOutput(byte aSide) { + return aSide < 2; + } + + @Override + public int getOutputSlot() { + return super.getOutputSlot(); + } + + @Override + public int getStackDisplaySlot() { + return super.getStackDisplaySlot(); + } + + @Override + public boolean doesEmptyContainers() { + return true; + } + + @Override + public boolean canTankBeFilled() { + return super.canTankBeFilled(); + } + + @Override + public boolean canTankBeEmptied() { + return super.canTankBeEmptied(); + } + + @Override + public FluidStack getDisplayedFluid() { + return super.getDisplayedFluid(); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setBoolean("mFluidTransfer_1", mFluidTransfer_1); + aNBT.setBoolean("mFluidTransfer_2", mFluidTransfer_2); + for (int i=0;i<4;i++) { + if (this.mInputFluids[i] != null) { + aNBT.setTag("mInputFluid"+i, this.mInputFluids[i].writeToNBT(new NBTTagCompound())); + } + } + for (int i=0;i<2;i++) { + if (this.mOutputFluids[i] != null) { + aNBT.setTag("mOutputFluid"+i, this.mOutputFluids[i].writeToNBT(new NBTTagCompound())); + } + } + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + mFluidTransfer_1 = aNBT.getBoolean("mFluidTransfer_1"); + mFluidTransfer_2 = aNBT.getBoolean("mFluidTransfer_2"); + for (int i=0;i<4;i++) { + if (this.mInputFluids[i] == null) { + this.mInputFluids[i] = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mInputFluid"+i)); + } + } + for (int i=0;i<2;i++) { + if (this.mOutputFluids[i] == null) { + this.mOutputFluids[i] = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mOutputFluid"+i)); + } + } + } + + /* + * Custom Fluid Handling - TODO + */ + + public FluidStack getFillableStack() { + return this.mFluid; + } + + public FluidStack setFillableStack(FluidStack aFluid) { + this.mFluid = aFluid; + return this.mFluid; + } + + public FluidStack getDrainableStack() { + return this.mFluid; + } + + public FluidStack setDrainableStack(FluidStack aFluid) { + this.mFluid = aFluid; + return this.mFluid; + } + + + + + + + + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + // Re-implement basic machine logic from the ground up.= + + if (aBaseMetaTileEntity.isServerSide()) { + this.mCharge = aBaseMetaTileEntity.getStoredEU() / 2L > aBaseMetaTileEntity.getEUCapacity() / 3L; + this.mDecharge = aBaseMetaTileEntity.getStoredEU() < aBaseMetaTileEntity.getEUCapacity() / 3L; + this.doDisplayThings(); + boolean tSucceeded = false; + int i; + if (this.mMaxProgresstime > 0 && (this.mProgresstime >= 0 || aBaseMetaTileEntity.isAllowedToWork())) { + aBaseMetaTileEntity.setActive(true); + if (this.mProgresstime >= 0 && !this.drainEnergyForProcess((long) this.mEUt)) { + if (!this.mStuttering) { + this.stutterProcess(); + if (this.canHaveInsufficientEnergy()) { + this.mProgresstime = -100; + } + + this.mStuttering = true; + } + } else { + if (++this.mProgresstime >= this.mMaxProgresstime) { + for (i = 0; i < this.mOutputItems.length; ++i) { + for (i = 0; i < this.mOutputItems.length && !aBaseMetaTileEntity.addStackToSlot( + this.getOutputSlot() + (i + i) % this.mOutputItems.length, + this.mOutputItems[i]); ++i) { + ; + } + } + + if (this.mOutputFluid != null) { + if (this.getDrainableStack() == null) { + this.setDrainableStack(this.mOutputFluid.copy()); + } else if (this.mOutputFluid.isFluidEqual(this.getDrainableStack())) { + FluidStack var10000 = this.getDrainableStack(); + var10000.amount += this.mOutputFluid.amount; + } + } + + for (i = 0; i < this.mOutputItems.length; ++i) { + this.mOutputItems[i] = null; + } + + this.mOutputFluid = null; + this.mEUt = 0; + this.mProgresstime = 0; + this.mMaxProgresstime = 0; + this.mStuttering = false; + tSucceeded = true; + this.endProcess(); + } + + if (this.mProgresstime > 5) { + this.mStuttering = false; + } + } + } else { + aBaseMetaTileEntity.setActive(false); + } + + boolean tRemovedOutputFluid = false; + if (this.doesAutoOutputFluids() && this.getDrainableStack() != null + && aBaseMetaTileEntity.getFrontFacing() != this.mMainFacing && (tSucceeded || aTick % 20L == 0L)) { + IFluidHandler tTank = aBaseMetaTileEntity.getITankContainerAtSide(aBaseMetaTileEntity.getFrontFacing()); + if (tTank != null) { + FluidStack tDrained = this.drain(1000, false); + if (tDrained != null) { + int tFilledAmount = tTank.fill( + ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()), tDrained, false); + if (tFilledAmount > 0) { + tTank.fill(ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()), + this.drain(tFilledAmount, true), true); + } + } + } + + if (this.getDrainableStack() == null) { + tRemovedOutputFluid = true; + } + } + + int j; + if (this.doesAutoOutput() && !this.isOutputEmpty() + && aBaseMetaTileEntity.getFrontFacing() != this.mMainFacing + && (tSucceeded || this.mOutputBlocked % 300 == 1 || aBaseMetaTileEntity.hasInventoryBeenModified() + || aTick % 600L == 0L)) { + TileEntity tTileEntity2 = aBaseMetaTileEntity.getTileEntityAtSide(aBaseMetaTileEntity.getFrontFacing()); + j = 0; + + for (byte tCosts = 1; j < this.mOutputItems.length && tCosts > 0 + && aBaseMetaTileEntity.isUniversalEnergyStored(128L); ++j) { + tCosts = GT_Utility.moveOneItemStack(aBaseMetaTileEntity, tTileEntity2, + aBaseMetaTileEntity.getFrontFacing(), aBaseMetaTileEntity.getBackFacing(), (List) null, + false, (byte) 64, (byte) 1, (byte) 64, (byte) 1); + if (tCosts > 0) { + aBaseMetaTileEntity.decreaseStoredEnergyUnits((long) tCosts, true); + } + } + } + + if (this.mOutputBlocked != 0) { + if (this.isOutputEmpty()) { + this.mOutputBlocked = 0; + } else { + ++this.mOutputBlocked; + } + } + + if (this.allowToCheckRecipe()) { + if (this.mMaxProgresstime <= 0 && aBaseMetaTileEntity.isAllowedToWork() + && (tRemovedOutputFluid || tSucceeded || aBaseMetaTileEntity.hasInventoryBeenModified() + || aTick % 600L == 0L || aBaseMetaTileEntity.hasWorkJustBeenEnabled()) + && this.hasEnoughEnergyToCheckRecipe()) { + if (this.checkRecipe() == 2) { + if (this.mInventory[3] != null && this.mInventory[3].stackSize <= 0) { + this.mInventory[3] = null; + } + + i = this.getInputSlot(); + + for (j = i + this.mInputSlotCount; i < j; ++i) { + if (this.mInventory[i] != null && this.mInventory[i].stackSize <= 0) { + this.mInventory[i] = null; + } + } + + for (i = 0; i < this.mOutputItems.length; ++i) { + this.mOutputItems[i] = GT_Utility.copy(new Object[]{this.mOutputItems[i]}); + if (this.mOutputItems[i] != null && this.mOutputItems[i].stackSize > 64) { + this.mOutputItems[i].stackSize = 64; + } + + this.mOutputItems[i] = GT_OreDictUnificator.get(true, this.mOutputItems[i]); + } + + if (this.mFluid != null && this.mFluid.amount <= 0) { + this.mFluid = null; + } + + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + if (GT_Utility.isDebugItem(this.mInventory[this.dechargerSlotStartIndex()])) { + this.mEUt = this.mMaxProgresstime = 1; + } + + this.startProcess(); + } else { + this.mMaxProgresstime = 0; + + for (i = 0; i < this.mOutputItems.length; ++i) { + this.mOutputItems[i] = null; + } + + this.mOutputFluid = null; + } + } + } else if (!this.mStuttering) { + this.stutterProcess(); + this.mStuttering = true; + } + } + + + + } + + @Override + protected void doDisplayThings() { + // TODO Auto-generated method stub + super.doDisplayThings(); + } + + @Override + protected ItemStack getSpecialSlot() { + // TODO Auto-generated method stub + return super.getSpecialSlot(); + } + + @Override + protected ItemStack getOutputAt(int aIndex) { + // TODO Auto-generated method stub + return super.getOutputAt(aIndex); + } + + @Override + protected ItemStack[] getAllOutputs() { + // TODO Auto-generated method stub + return super.getAllOutputs(); + } + + @Override + protected ItemStack getInputAt(int aIndex) { + // TODO Auto-generated method stub + return super.getInputAt(aIndex); + } + + @Override + protected ItemStack[] getAllInputs() { + // TODO Auto-generated method stub + return super.getAllInputs(); + } + + @Override + protected boolean displaysInputFluid() { + return true; + } + + @Override + protected boolean displaysOutputFluid() { + return true; + } + + @Override + public boolean doesAutoOutput() { + return super.doesAutoOutput(); + } + + @Override + public boolean doesAutoOutputFluids() { + return this.mFluidTransfer_1 && this.mFluidTransfer_2; + } + + @Override + public void startProcess() { + super.startProcess(); + } + + @Override + public void endProcess() { + super.endProcess(); + } + + @Override + public String[] getInfoData() { + return super.getInfoData(); + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return super.allowPullStack(aBaseMetaTileEntity, aIndex, aSide, aStack); + } + + @Override + public int checkRecipe() { + return super.checkRecipe(); + } + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPreTick(aBaseMetaTileEntity, aTick); + + /* if (aBaseMetaTileEntity != null) { + if (!aBaseMetaTileEntity.getWorld().isRemote) { + itemslots : for (int i=3;i<7;i++) { + ItemStack aStack = aBaseMetaTileEntity.getStackInSlot(i); + if (aStack != null) { + if (FluidContainerRegistry.isContainer(aStack)) { + if (this.isItemValidForSlot(i, aStack)) { + // Add Fluid + FluidStack aContainerFluid = FluidContainerRegistry.getFluidForFilledItem(aStack); + if (aContainerFluid != null) { + fluidslots : for (FluidStack u : mInputFluids) { + if (u != null && u.isFluidEqual(aContainerFluid)) { + if (u.amount <= (this.getCapacity() - aContainerFluid.amount)) { + + // Matching, not full, let's fill, then continue + u.amount += aContainerFluid.amount; + + // Update stack size + if (aStack.stackSize > 1) { + aStack.stackSize--; + } + else { + aStack = null; + } + + // Add Output container + // TODO + + continue itemslots; + } + else { + // Too full + break fluidslots; + } + } + else { + if (u == null ) { + + // Empty, let's fill, then continue + u = aContainerFluid.copy(); + + // Update stack size + if (aStack.stackSize > 1) { + aStack.stackSize--; + } + else { + aStack = null; + } + + // Add Output container + // TODO + + continue itemslots; + + } + else { + // Not empty, doesn't match, check next slot. + continue fluidslots; + } + } + } + + + + } + // Eat Input + + // Add Container to Output + } + } + } + } + } + }*/ + + } + + @Override + public FluidStack getFluid() { + return super.getFluid(); + } + + @Override + public int getFluidAmount() { + return super.getFluidAmount(); + } + + @Override + public int fill(FluidStack aFluid, boolean doFill) { + return super.fill(aFluid, doFill); + } + + @Override + public FluidStack drain(int maxDrain, boolean doDrain) { + return super.drain(maxDrain, doDrain); + } + + @Override + public void setItemNBT(NBTTagCompound aNBT) { + super.setItemNBT(aNBT); + } + + @Override + public boolean isItemValidForSlot(int aIndex, ItemStack aStack) { + if (aIndex >= 3 && aIndex <= 6) { + return SlotChemicalPlantInput.isItemValidForChemicalPlantSlot(aStack); + } + return false; + } + + @Override + public int[] getAccessibleSlotsFromSide(int aSide) { + return super.getAccessibleSlotsFromSide(aSide); + } + + @Override + public boolean canInsertItem(int aIndex, ItemStack aStack, int aSide) { + if (aIndex >= 3 && aIndex <= 6) { + return super.canInsertItem(aIndex, aStack, aSide); + } + return false; + } + + @Override + public boolean canExtractItem(int aIndex, ItemStack aStack, int aSide) { + if (aIndex >= 7 && aIndex <= 11) { + return super.canExtractItem(aIndex, aStack, aSide); + } + return false; + } + + @Override + public boolean canFill(ForgeDirection aSide, Fluid aFluid) { + // TODO Auto-generated method stub + return super.canFill(aSide, aFluid); + } + + @Override + public boolean canDrain(ForgeDirection aSide, Fluid aFluid) { + // TODO Auto-generated method stub + return super.canDrain(aSide, aFluid); + } + + @Override + public FluidTankInfo[] getTankInfo(ForgeDirection aSide) { + // TODO Auto-generated method stub + return super.getTankInfo(aSide); + } + + @Override + public int fill_default( + ForgeDirection aSide, FluidStack aFluid, boolean doFill + ) { + // TODO Auto-generated method stub + return super.fill_default(aSide, aFluid, doFill); + } + + @Override + public int fill(ForgeDirection aSide, FluidStack aFluid, boolean doFill) { + // TODO Auto-generated method stub + return super.fill(aSide, aFluid, doFill); + } + + @Override + public FluidStack drain( + ForgeDirection aSide, FluidStack aFluid, boolean doDrain + ) { + // TODO Auto-generated method stub + return super.drain(aSide, aFluid, doDrain); + } + + @Override + public FluidStack drain( + ForgeDirection aSide, int maxDrain, boolean doDrain + ) { + // TODO Auto-generated method stub + return super.drain(aSide, maxDrain, doDrain); + } + +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCokeOven.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCokeOven.java index 611cb4da71..b8517533e6 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCokeOven.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCokeOven.java @@ -55,7 +55,7 @@ extends GregtechMeta_MultiBlockBase { "1x Input Bus", "1x Output Bus", "1x Energy Hatch" - }; + }; } @Override @@ -101,7 +101,7 @@ extends GregtechMeta_MultiBlockBase { public boolean checkRecipe(final ItemStack aStack) { return checkRecipeGeneric(getMaxParallelRecipes(), getEuDiscountForParallelism(), 0); } - + @Override public int getMaxParallelRecipes() { return this.mLevel * 12; @@ -118,19 +118,21 @@ extends GregtechMeta_MultiBlockBase { final int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; this.mLevel = 0; if (!aBaseMetaTileEntity.getAirOffset(xDir, 1, zDir)) { + Logger.INFO("No air? "+xDir+", 1, "+zDir); return false; } final byte tUsedMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + 1, 1, zDir); switch (tUsedMeta) { - case 2: - this.mLevel = 1; - break; - case 3: - this.mLevel = 2; - break; - default: - return false; + case 2: + this.mLevel = 1; + break; + case 3: + this.mLevel = 2; + break; + default: + Logger.INFO("Bad Heating Coils."); + return false; } for (int i = -1; i < 2; i++) { for (int j = -1; j < 2; j++) { @@ -140,7 +142,7 @@ extends GregtechMeta_MultiBlockBase { Logger.INFO("Heating Coils missing."); return false; } - + if (!isValidBlockForStructure(tTileEntity2, TAE.GTPP_INDEX(1), true, aBaseMetaTileEntity.getBlockOffset(xDir + i, 2, zDir + j), (int) aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 2, zDir + j), ModBlocks.blockCasingsMisc, 1)) { Logger.INFO("Casings missing from top layer of coke oven."); return false; @@ -158,7 +160,7 @@ extends GregtechMeta_MultiBlockBase { } } } - } + } return true; } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMultiMachine.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMultiMachine.java index 2e0eeea844..8b07117596 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMultiMachine.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMultiMachine.java @@ -609,8 +609,13 @@ extends GregtechMeta_MultiBlockBase { } // -- Try not to fail after this point - inputs have already been consumed! -- - ItemStack[] mBuiltOutput = this.mReplicatorOutputMap.toArray(); - + ItemStack[] mBuiltOutput = new ItemStack[this.mReplicatorOutputMap.size()]; + int aIndex = 0; + for (ItemStack i : this.mReplicatorOutputMap) { + mBuiltOutput[aIndex++] = i; + } + + // Convert speed bonus to duration multiplier // e.g. 100% speed bonus = 200% speed = 100%/200% = 50% recipe duration. aSpeedBonusPercent = Math.max(-99, aSpeedBonusPercent); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_EBF.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_EBF.java index cce1d5b530..a2087c0891 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_EBF.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_EBF.java @@ -188,6 +188,8 @@ public class GregtechMetaTileEntity_Adv_EBF extends GregtechMeta_MultiBlockBase } } } + + // TODO - Fix Casing Count return true; } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GT4Entity_ThermalBoiler.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GT4Entity_ThermalBoiler.java index c55fe10829..6e7039f8ca 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GT4Entity_ThermalBoiler.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GT4Entity_ThermalBoiler.java @@ -292,7 +292,19 @@ extends GregtechMeta_MultiBlockBase @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { if (aBaseMetaTileEntity.isServerSide()){ - //Utils.LOG_INFO("tick: "+aTick); + // Reload Lava Filter + if (this.getGUIItemStack() == null) { + if (this.mInputBusses.size() > 0) { + for (GT_MetaTileEntity_Hatch_InputBus aBus : this.mInputBusses) { + for (ItemStack aStack : aBus.mInventory) { + if (aStack.getItem() instanceof ItemLavaFilter) { + this.setGUIItemStack(aStack); + } + } + } + } + } + if (this.mEUt > 0){ if (aTick % 600L == 0L){ damageFilter(); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_MiniFusionPlant.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_MiniFusionPlant.java index 8925caf480..cb8b7590ee 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_MiniFusionPlant.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_MiniFusionPlant.java @@ -207,7 +207,7 @@ public class GregtechMTE_MiniFusionPlant extends GregtechMeta_MultiBlockBase { FluidStack[] arg5 = (FluidStack[]) tFluidList.toArray(new FluidStack[tFluidList.size()]); GT_Recipe arg6 = getRecipeMap().findRecipe(this.getBaseMetaTileEntity(), this.mLastRecipe, false, this.getMaxInputVoltage(), arg5, new ItemStack[0]); - if (arg6 == null && !this.mRunningOnLoad || this.maxEUStore() < (long) arg6.mSpecialValue) { + if (arg6 == null && !this.mRunningOnLoad || (arg6 != null && this.maxEUStore() < (long) arg6.mSpecialValue)) { //Logger.INFO("Bad Step "+aStep++); //this.turnCasingActive(false); this.mLastRecipe = null; @@ -215,7 +215,7 @@ public class GregtechMTE_MiniFusionPlant extends GregtechMeta_MultiBlockBase { } //Logger.INFO("Step "+aStep++); - if (this.mRunningOnLoad || arg6.isRecipeInputEqual(true, arg5, new ItemStack[0])) { + if (this.mRunningOnLoad || (arg6 != null && arg6.isRecipeInputEqual(true, arg5, new ItemStack[0]))) { //Logger.INFO("Step "+aStep++); this.mLastRecipe = arg6; this.mEUt = this.mLastRecipe.mEUt * 1; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityGeneratorArray.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityGeneratorArray.java index 23ca94e54d..6f9080673f 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityGeneratorArray.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityGeneratorArray.java @@ -17,16 +17,11 @@ import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; import gregtech.api.util.Recipe_GT; -import gregtech.api.util.GT_Recipe.GT_Recipe_Map; -import gregtech.api.util.Recipe_GT.Gregtech_Recipe_Map; -import gregtech.common.GT_Pollution; import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.util.minecraft.FluidUtils; import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import net.minecraft.block.Block; -import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java index 33555c8f51..f3fefdf789 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java @@ -34,6 +34,10 @@ public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase public static int CASING_TEXTURE_ID; public static String mCasingName = "Advanced Cryogenic Casing"; public static TreeGenerator mTreeData; + + static { + mTreeData = new TreeGenerator(); + } public GregtechMetaTileEntityTreeFarm(final int aID, final String aName, final String aNameRegional) { super(aID, aName, aNameRegional); @@ -76,10 +80,6 @@ public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase } }*/ - if (mTreeData == null) { - mTreeData = new TreeGenerator(); - } - diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Refinery.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Refinery.java index 07c8a4a7ac..24db72fbe0 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Refinery.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Refinery.java @@ -22,8 +22,6 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection; public class GregtechMetaTileEntity_Refinery extends GregtechMeta_MultiBlockBase { - - public GT_Recipe mLastRecipe; public GregtechMetaTileEntity_Refinery(final int aID, final String aName, final String aNameRegional) { super(aID, aName, aNameRegional); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/algae/GregtechMTE_AlgaePondBase.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/algae/GregtechMTE_AlgaePondBase.java new file mode 100644 index 0000000000..fda79876f6 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/algae/GregtechMTE_AlgaePondBase.java @@ -0,0 +1,502 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.algae; + +import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.commons.lang3.ArrayUtils; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.GregTech_API; +import gregtech.api.enums.TAE; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.item.chemistry.AgriculturalChem; +import gtPlusPlus.core.util.minecraft.FluidUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import gtPlusPlus.xmod.gregtech.loaders.recipe.RecipeLoader_AlgaeFarm; +import ic2.core.init.BlocksItems; +import ic2.core.init.InternalName; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; + +public class GregtechMTE_AlgaePondBase extends GregtechMeta_MultiBlockBase { + + private int mLevel = -1; + + public GregtechMTE_AlgaePondBase(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMTE_AlgaePondBase(final String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMTE_AlgaePondBase(this.mName); + } + + @Override + public String getMachineType() { + return "Algae Pond"; + } + + @Override + public String[] getTooltip() { + return new String[] { + "Grows Algae!", + "Controller Block for the Algae Farm", + "Size: 9x3x9 [WxHxL] (open)", + "X X", + "X X", + "XXXXXXXXX", + "Machine Hulls (all bottom layer)", + "Sterile Farm Casings (rest)", + "Controller (front centered)", + "All hatches must be on the bottom layer", + "All hulls must be the same tier, this dictates machine speed", + "Does not require power or maintenance", + "1x Output Bus", + "1x Input Bus (optional)", + "1x Input Hatch (fill with water)", + }; + } + + @Override + public String getSound() { + return GregTech_API.sSoundList.get(Integer.valueOf(207)); + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + + int aID = TAE.getIndexFromPage(1, 15); + if (mLevel > -1) { + aID = mLevel; + } + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[aID], new GT_RenderedTexture(aActive ? TexturesGtBlock.Overlay_Machine_Controller_Default_Active : TexturesGtBlock.Overlay_Machine_Controller_Default)}; + } + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[aID]}; + } + + @Override + public boolean hasSlotInGUI() { + return true; + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return null; + } + + @Override + public boolean isFacingValid(final byte aFacing) { + return aFacing > 1; + } + + @Override + public int getMaxParallelRecipes() { + return 2; + } + + @Override + public int getEuDiscountForParallelism() { + return 0; + } + + @Override + public boolean checkMultiblock(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack) { + + this.mLevel = 0; + + + // Get Facing direction + int mCurrentDirectionX; + int mCurrentDirectionZ; + + int mOffsetX_Lower = 0; + int mOffsetX_Upper = 0; + int mOffsetZ_Lower = 0; + int mOffsetZ_Upper = 0; + + mCurrentDirectionX = 4; + mCurrentDirectionZ = 4; + + mOffsetX_Lower = -4; + mOffsetX_Upper = 4; + mOffsetZ_Lower = -4; + mOffsetZ_Upper = 4; + + final int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX + * mCurrentDirectionX; + final int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ + * mCurrentDirectionZ; + + // Get Expected Tier + Block aCasingBlock = aBaseMetaTileEntity.getBlockAtSide((byte) 0); + int aCasingMeta = aBaseMetaTileEntity.getMetaIDAtSide((byte) 0); + + // Bad Casings + if ((aCasingBlock != GregTech_API.sBlockCasings1) || aCasingMeta > 9) { + return false; + } + else { + mLevel = this.getCasingTierOnClientSide(); + } + int aID = TAE.getIndexFromPage(1, 15); + int tAmount = 0; + check : for (int i = mOffsetX_Lower; i <= mOffsetX_Upper; ++i) { + for (int j = mOffsetZ_Lower; j <= mOffsetZ_Upper; ++j) { + for (int h = -1; h < 2; ++h) { + if ((h != 0) || ((((xDir + i != 0) || (zDir + j != 0))) && (((i != 0) || (j != 0))))) { + IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j); + + Logger.INFO("X: " + i + " | Z: " + j+" | Tier: "+aID); + if (h == -1 && tTileEntity != null && addToMachineList(tTileEntity, aID)) { + continue; + } + else if (h != -1 && tTileEntity != null) { + Logger.INFO("Found hatch in wrong place, expected casing."); + return false; + } + + Block tBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j); + byte tMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j); + + if ((tBlock == ModBlocks.blockCasings2Misc) && (tMeta == 15) && (h >= 0)) { + ++tAmount; + } + else if ((tBlock == GregTech_API.sBlockCasings1) && (tMeta == mLevel) && (h == -1)) { + ++tAmount; + } + else if ((tBlock == GregTech_API.sBlockCasings1) && (tMeta != mLevel) && (h == -1)) { + Logger.INFO("Found wrong tiered casing."); + return false; + } + else { + if ((i != mOffsetX_Lower && j != mOffsetZ_Lower && i != mOffsetX_Upper + && j != mOffsetZ_Upper) && (h == 0 || h == 1)) { + continue; + } else { + if (tBlock.getLocalizedName().contains("gt.blockmachines") || tBlock == Blocks.water + || tBlock == Blocks.flowing_water + || tBlock == BlocksItems.getFluidBlock(InternalName.fluidDistilledWater)) { + continue; + + } else { + Logger.INFO("[x] Did not form - Found: " + tBlock.getLocalizedName() + " | " + + tBlock.getDamageValue(aBaseMetaTileEntity.getWorld(), + aBaseMetaTileEntity.getXCoord() + i, + aBaseMetaTileEntity.getYCoord(), + aBaseMetaTileEntity.getZCoord() + j) + + " | Special Meta: " + + (tTileEntity == null ? "0" : tTileEntity.getMetaTileID())); + Logger.INFO("[x] Did not form - Found: " + + (aBaseMetaTileEntity.getXCoord() + xDir + i) + " | " + + aBaseMetaTileEntity.getYCoord() + " | " + + (aBaseMetaTileEntity.getZCoord() + zDir + j)); + break check; + } + } + + } + + } + } + } + } + if ((tAmount >= 64)) { + Logger.INFO("Made structure."); + this.getBaseMetaTileEntity().getWorld().markBlockForUpdate(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord()); + } else { + Logger.INFO("Did not make structure."); + } + return (tAmount >= 64); + } + + public boolean checkForWater() { + + // Get Facing direction + IGregTechTileEntity aBaseMetaTileEntity = this.getBaseMetaTileEntity(); + int mDirectionX = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; + int mCurrentDirectionX; + int mCurrentDirectionZ; + int mOffsetX_Lower = 0; + int mOffsetX_Upper = 0; + int mOffsetZ_Lower = 0; + int mOffsetZ_Upper = 0; + + mCurrentDirectionX = 4; + mCurrentDirectionZ = 4; + + mOffsetX_Lower = -4; + mOffsetX_Upper = 4; + mOffsetZ_Lower = -4; + mOffsetZ_Upper = 4; + + // if (aBaseMetaTileEntity.fac) + + final int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX + * mCurrentDirectionX; + final int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ + * mCurrentDirectionZ; + + int tAmount = 0; + for (int i = mOffsetX_Lower + 1; i <= mOffsetX_Upper - 1; ++i) { + for (int j = mOffsetZ_Lower + 1; j <= mOffsetZ_Upper - 1; ++j) { + for (int h = 0; h < 2; h++) { + Block tBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j); + // byte tMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j); + if (tBlock == Blocks.air || tBlock == Blocks.flowing_water || tBlock == BlocksItems.getFluidBlock(InternalName.fluidDistilledWater)) { + if (this.getStoredFluids() != null) { + for (FluidStack stored : this.getStoredFluids()) { + if (stored.isFluidEqual(FluidUtils.getFluidStack("water", 1))) { + if (stored.amount >= 1000) { + // Utils.LOG_WARNING("Going to try swap an air block for water from inut bus."); + stored.amount -= 1000; + Block fluidUsed = Blocks.water; + aBaseMetaTileEntity.getWorld().setBlock( + aBaseMetaTileEntity.getXCoord() + xDir + i, + aBaseMetaTileEntity.getYCoord() + h, + aBaseMetaTileEntity.getZCoord() + zDir + j, fluidUsed); + + } + } + } + } + } + tBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j); + if (tBlock == Blocks.water || tBlock == Blocks.flowing_water) { + ++tAmount; + // Logger.INFO("Found Water"); + } + } + } + } + + boolean isValidWater = tAmount >= 60; + + if (isValidWater) { + Logger.INFO("Filled structure."); + return true; + } + else { + return false; + } + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(final ItemStack aStack) { + return 0; + } + + @Override + public int getAmountOfOutputs() { + return 1; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + @Override + public String getCustomGUIResourceName() { + return null; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + } + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPreTick(aBaseMetaTileEntity, aTick); + this.fixAllMaintenanceIssue(); + // Silly Client Syncing + if (aBaseMetaTileEntity.isClientSide()) { + this.mLevel = getCasingTierOnClientSide(); + } + + } + + @Override + public boolean checkRecipe(final ItemStack aStack) { + return checkRecipeGeneric(getMaxParallelRecipes(), getEuDiscountForParallelism(), 0); + } + + public boolean checkRecipeGeneric( + ItemStack[] aItemInputs, FluidStack[] aFluidInputs, + int aMaxParallelRecipes, int aEUPercent, + int aSpeedBonusPercent, int aOutputChanceRoll, GT_Recipe aRecipe) { + + if (this.mLevel < 0) { + Logger.INFO("Bad Tier."); + return false; + } + + if (!checkForWater()) { + Logger.INFO("Not enough Water."); + return false; + } + + // Reset outputs and progress stats + this.mEUt = 0; + this.mMaxProgresstime = 0; + this.mOutputItems = new ItemStack[]{}; + this.mOutputFluids = new FluidStack[]{}; + + Logger.INFO("Running checkRecipeGeneric(0)"); + + GT_Recipe tRecipe = RecipeLoader_AlgaeFarm.getTieredRecipeFromCache(this.mLevel, isUsingCompost(aItemInputs)); + + this.mLastRecipe = tRecipe; + + if (tRecipe == null) { + return false; + } + + if (!this.canBufferOutputs(tRecipe, aMaxParallelRecipes, false)) { + return false; + } + + + // -- Try not to fail after this point - inputs have already been consumed! -- + + + this.mMaxProgresstime = (int)(tRecipe.mDuration); + this.mEUt = 0; + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + Logger.INFO("Recipe time: "+this.mMaxProgresstime); + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + + // Collect fluid outputs + FluidStack[] tOutputFluids = new FluidStack[tRecipe.mFluidOutputs.length]; + for (int h = 0; h < tRecipe.mFluidOutputs.length; h++) { + if (tRecipe.getFluidOutput(h) != null) { + tOutputFluids[h] = tRecipe.getFluidOutput(h).copy(); + tOutputFluids[h].amount *= aMaxParallelRecipes; + } + } + + // Collect output item types + ItemStack[] tOutputItems = new ItemStack[tRecipe.mOutputs.length]; + for (int h = 0; h < tRecipe.mOutputs.length; h++) { + if (tRecipe.getOutput(h) != null) { + tOutputItems[h] = tRecipe.getOutput(h).copy(); + tOutputItems[h].stackSize = 0; + } + } + + // Set output item stack sizes (taking output chance into account) + for (int f = 0; f < tOutputItems.length; f++) { + if (tRecipe.mOutputs[f] != null && tOutputItems[f] != null) { + for (int g = 0; g < aMaxParallelRecipes; g++) { + if (getBaseMetaTileEntity().getRandomNumber(aOutputChanceRoll) < tRecipe.getOutputChance(f)) + tOutputItems[f].stackSize += tRecipe.mOutputs[f].stackSize; + } + } + } + + tOutputItems = removeNulls(tOutputItems); + + // Sanitize item stack size, splitting any stacks greater than max stack size + List<ItemStack> splitStacks = new ArrayList<ItemStack>(); + for (ItemStack tItem : tOutputItems) { + while (tItem.getMaxStackSize() < tItem.stackSize) { + ItemStack tmp = tItem.copy(); + tmp.stackSize = tmp.getMaxStackSize(); + tItem.stackSize = tItem.stackSize - tItem.getMaxStackSize(); + splitStacks.add(tmp); + } + } + + if (splitStacks.size() > 0) { + ItemStack[] tmp = new ItemStack[splitStacks.size()]; + tmp = splitStacks.toArray(tmp); + tOutputItems = ArrayUtils.addAll(tOutputItems, tmp); + } + + // Strip empty stacks + List<ItemStack> tSList = new ArrayList<ItemStack>(); + for (ItemStack tS : tOutputItems) { + if (tS.stackSize > 0) tSList.add(tS); + } + tOutputItems = tSList.toArray(new ItemStack[tSList.size()]); + + // Commit outputs + this.mOutputItems = tOutputItems; + this.mOutputFluids = tOutputFluids; + updateSlots(); + + // Play sounds (GT++ addition - GT multiblocks play no sounds) + startProcess(); + + Logger.INFO("GOOD RETURN - 1"); + return true; + + } + + private boolean isUsingCompost(ItemStack[] aItemInputs) { + ItemStack aCompost = ItemUtils.getSimpleStack(AgriculturalChem.mCompost, 1); + for (ItemStack i : aItemInputs) { + if (GT_Utility.areStacksEqual(aCompost, i)) { + if (i.stackSize >= 8) { + return true; + } + else { + continue; + } + } + } + return false; + } + + @SideOnly(Side.CLIENT) + private final int getCasingTierOnClientSide() { + if (this == null || this.getBaseMetaTileEntity().getWorld() == null) { + return 0; + } + try { + Block aInitStructureCheck; + int aInitStructureCheckMeta; + IGregTechTileEntity aBaseMetaTileEntity = this.getBaseMetaTileEntity(); + aInitStructureCheck = aBaseMetaTileEntity.getBlockOffset(0, -1, 0); + aInitStructureCheckMeta = aBaseMetaTileEntity.getMetaIDOffset(0, -1, 0); + if (aInitStructureCheck == GregTech_API.sBlockCasings1) { + return aInitStructureCheckMeta; + } + return 0; + } + catch (Throwable t) { + t.printStackTrace(); + return 0; + } + } + + + +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/bedrock/GregtechMetaTileEntity_BedrockMiningPlatformBase.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/bedrock/GregtechMetaTileEntity_BedrockMiningPlatformBase.java index 736d0bc389..c499de0fa5 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/bedrock/GregtechMetaTileEntity_BedrockMiningPlatformBase.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/bedrock/GregtechMetaTileEntity_BedrockMiningPlatformBase.java @@ -23,6 +23,7 @@ import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.FluidUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.minecraft.MiningUtils; +import gtPlusPlus.core.util.minecraft.OreDictUtils; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import net.minecraft.block.Block; @@ -509,23 +510,23 @@ public abstract class GregtechMetaTileEntity_BedrockMiningPlatformBase extends G mMixedOreData.put(new Pair<String, Integer>("oreLapis", 40)); mMixedOreData.put(new Pair<String, Integer>("oreRedstone", 40)); - if (LoadedMods.Thaumcraft || (OreDictionary.doesOreNameExist("oreAmber") && OreDictionary.doesOreNameExist("oreCinnabar"))) { + if (LoadedMods.Thaumcraft || (OreDictUtils.containsValidEntries("oreAmber") && OreDictUtils.containsValidEntries("oreCinnabar"))) { mMixedOreData.put(new Pair<String, Integer>("oreAmber", 20)); mMixedOreData.put(new Pair<String, Integer>("oreCinnabar", 20)); } - if (LoadedMods.Railcraft || OreDictionary.doesOreNameExist("oreSaltpeter")) { + if (LoadedMods.Railcraft || OreDictUtils.containsValidEntries("oreSaltpeter")) { mMixedOreData.put(new Pair<String, Integer>("oreSaltpeter", 10)); } - if (LoadedMods.IndustrialCraft2 || OreDictionary.doesOreNameExist("oreUranium")) { + if (LoadedMods.IndustrialCraft2 || OreDictUtils.containsValidEntries("oreUranium")) { mMixedOreData.put(new Pair<String, Integer>("oreUranium", 10)); } - if (OreDictionary.doesOreNameExist("oreSulfur")) { + if (OreDictUtils.containsValidEntries("oreSulfur")) { mMixedOreData.put(new Pair<String, Integer>("oreSulfur", 15)); } - if (OreDictionary.doesOreNameExist("oreSilicon")) { + if (OreDictUtils.containsValidEntries("oreSilicon")) { mMixedOreData.put(new Pair<String, Integer>("oreSilicon", 15)); } - if (OreDictionary.doesOreNameExist("oreApatite")) { + if (OreDictUtils.containsValidEntries("oreApatite")) { mMixedOreData.put(new Pair<String, Integer>("oreApatite", 25)); } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/GregtechMTE_ChemicalPlant.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/GregtechMTE_ChemicalPlant.java new file mode 100644 index 0000000000..654d036bf8 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/GregtechMTE_ChemicalPlant.java @@ -0,0 +1,823 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.chemplant; + +import static gregtech.api.enums.GT_Values.E; + +import java.util.HashSet; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.GregTech_API; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_TieredMachineBlock; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gregtech.api.util.Recipe_GT; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; +import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy; +import gtPlusPlus.xmod.gregtech.common.StaticFields59; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; + +public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { + + private int mSolidCasingTier = 0; + private int mMachineCasingTier = 0; + private int mPipeCasingTier = 0; + private int mCoilTier = 0; + + /** + * Internal Recipe Map which holds the actual recipes, backed by the real map, shown by NEI. + */ + private static final GT_Recipe_Map mFluidChemicalReactorRecipes = new GT_Recipe_Map( + new HashSet<GT_Recipe>(100), + "gt.recipe.fluidchemicaleactor", + "Chemical Plant", + null, + CORE.MODID+":textures/gui/FluidReactor", + 0, + 0, + 0, + 2, + 1, + "Tier: ", + 1, + E, + true, + false); + + + public GregtechMTE_ChemicalPlant(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMTE_ChemicalPlant(final String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMTE_ChemicalPlant(this.mName); + } + + @Override + public String getMachineType() { + return "Chemical Plant"; + } + + @Override + public String[] getTooltip() { + return new String[] { + "Heavy Industry, now right at your doorstep!", + "Controller Block for the Chemical Plant", + "27 Coils", + "18 Pipe Casings", + "57 Tiered Machine Casings", + "80+ Solid Casings", + "Hatch tier is limited to Machine Casing tier", + }; + } + + @Override + public String getSound() { + return GregTech_API.sSoundList.get(Integer.valueOf(207)); + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + + ITexture aOriginalTexture; + + // Check things exist client side (The worst code ever) + if (aBaseMetaTileEntity.getWorld() != null) { + + } + // Check the Tier Client Side + int aTier = mSolidCasingTier; + + if (aTier == 1) { + aOriginalTexture = Textures.BlockIcons.CASING_BLOCKS[16]; + } + else if (aTier == 2) { + aOriginalTexture = Textures.BlockIcons.CASING_BLOCKS[49]; + } + else if (aTier == 3) { + aOriginalTexture = Textures.BlockIcons.CASING_BLOCKS[50]; + } + else if (aTier == 4) { + aOriginalTexture = Textures.BlockIcons.CASING_BLOCKS[48]; + } + else { + aOriginalTexture = Textures.BlockIcons.CASING_BLOCKS[11]; + } + + + if (aSide == aFacing) { + return new ITexture[]{aOriginalTexture, new GT_RenderedTexture(aActive ? TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active : TexturesGtBlock.Overlay_Machine_Controller_Advanced)}; + } + return new ITexture[]{aOriginalTexture}; + } + + @Override + public boolean hasSlotInGUI() { + return false; + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + if (mFluidChemicalReactorRecipes.mRecipeList.isEmpty() || mFluidChemicalReactorRecipes.mRecipeList.size() != Recipe_GT.Gregtech_Recipe_Map.sFluidChemicalReactorRecipes.mRecipeList.size()) { + if (!mFluidChemicalReactorRecipes.mRecipeList.isEmpty()) { + mFluidChemicalReactorRecipes.mRecipeList.clear(); + } + for (Recipe_GT i : Recipe_GT.Gregtech_Recipe_Map.sFluidChemicalReactorRecipes.mRecipeList) { + mFluidChemicalReactorRecipes.add(i); + } + } + return mFluidChemicalReactorRecipes; + } + + @Override + public boolean isFacingValid(final byte aFacing) { + return aFacing > 1; + } + + @Override + public int getMaxParallelRecipes() { + return 2 * getPipeCasingTier(); + } + + @Override + public int getEuDiscountForParallelism() { + return 0; + } + + private int getSolidCasingTier() { + return mSolidCasingTier; + } + + private int getMachineCasingTier() { + return mMachineCasingTier; + } + private int getPipeCasingTier() { + return mPipeCasingTier; + } + private int getCoilTier() { + return mCoilTier; + } + + private int getCasingTextureID() { + // Check the Tier Client Side + int aTier = mSolidCasingTier; + + if (aTier == 1) { + return 16; + } + else if (aTier == 2) { + return 49; + } + else if (aTier == 3) { + return 50; + } + else if (aTier == 4) { + return 48; + } + else { + return 11; + } + } + + public boolean addToMachineList(IGregTechTileEntity aTileEntity) { + int aMaxTier = getMachineCasingTier(); + final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof GT_MetaTileEntity_TieredMachineBlock) { + GT_MetaTileEntity_TieredMachineBlock aMachineBlock = (GT_MetaTileEntity_TieredMachineBlock) aMetaTileEntity; + int aTileTier = aMachineBlock.mTier; + if (aTileTier > aMaxTier) { + Logger.INFO("Hatch tier too high."); + return false; + } + else { + return addToMachineList(aTileEntity, getCasingTextureID()); + } + } + else { + Logger.INFO("Bad Tile Entity being added to hatch map."); // Shouldn't ever happen, but.. ya know.. + return false; + } + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setInteger("mSolidCasingTier", this.mSolidCasingTier); + aNBT.setInteger("mMachineCasingTier", this.mMachineCasingTier); + aNBT.setInteger("mPipeCasingTier", this.mPipeCasingTier); + aNBT.setInteger("mCoilTier", this.mCoilTier); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + mSolidCasingTier = aNBT.getInteger("mSolidCasingTier"); + mMachineCasingTier = aNBT.getInteger("mMachineCasingTier"); + mPipeCasingTier = aNBT.getInteger("mPipeCasingTier"); + mCoilTier = aNBT.getInteger("mCoilTier"); + } + + private static boolean isBlockSolidCasing(Block aBlock, int aMeta) { + if (aBlock == null) { + return false; + } + if (aBlock == GregTech_API.sBlockCasings2 && aMeta == 0) { + return true; + } + if (aBlock == GregTech_API.sBlockCasings4) { + int aMetaStainlessCasing = 1; + int aMetaTitaniumCasing = 2; + int aMetaTungstenCasing = 0; + if (aMeta == aMetaStainlessCasing || aMeta == aMetaTitaniumCasing || aMeta == aMetaTungstenCasing) { + return true; + } + } + return false; + } + private static boolean isBlockMachineCasing(Block aBlock, int aMeta) { + Block aCasingBlock1 = GregTech_API.sBlockCasings1; + if (aBlock == aCasingBlock1) { + if (aMeta > 9 || aMeta < 0) { + return false; + } + else { + return true; + } + } + else { + return false; + } + } + private static boolean isBlockPipeCasing(Block aBlock, int aMeta) { + Block aCasingBlock2 = GregTech_API.sBlockCasings2; + if (aBlock == aCasingBlock2) { + int aMetaBronzePipeCasing = 12; + int aMetaSteelPipeCasing = 13; + int aMetaTitaniumPipeCasing = 14; + int aMetaTungstenPipeCasing = 15; + if (aMeta > aMetaTungstenPipeCasing || aMeta < aMetaBronzePipeCasing) { + return false; + } + else { + return true; + } + } + else { + return false; + } + } + + private static AutoMap<Integer> mValidCoilMetaCache; + + private static boolean isBlockCoil(Block aBlock, int aMeta) { + Block aCasingBlock; + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { + aCasingBlock = StaticFields59.getBlockCasings5(); + } + else { + aCasingBlock = GregTech_API.sBlockCasings1; + } + // Cache the meta values for later + if (mValidCoilMetaCache == null || mValidCoilMetaCache.isEmpty()) { + AutoMap<Integer> aValidCoilMeta = new AutoMap<Integer>(); + // Only use the right meta values available. + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { + aValidCoilMeta = Meta_GT_Proxy.GT_ValidHeatingCoilMetas; + } + else { + aValidCoilMeta.put(12); + aValidCoilMeta.put(13); + aValidCoilMeta.put(14); + } + mValidCoilMetaCache = aValidCoilMeta; + } + if (aBlock == aCasingBlock) { + for (int i: mValidCoilMetaCache.values()) { + if (i == aMeta) { + return true; + } + } + } + return false; + } + + + @Override + public boolean checkMultiblock(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack) { + + int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX * 3; + int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ * 3; + + int tAmount = 0; + Logger.INFO("Checking ChemPlant Structure"); + + // Require Air above controller + boolean aAirCheck = aBaseMetaTileEntity.getAirOffset(0, 1, 0); + + if (!aAirCheck) { + Logger.INFO("No Air Above Controller"); + return false; + } else { + + //String aName = aInitStructureCheck != null ? ItemUtils.getLocalizedNameOfBlock(aInitStructureCheck, aInitStructureCheckMeta) : "Air"; + + mSolidCasingTier = getSolidCasingTierCheck(aBaseMetaTileEntity, xDir, zDir); + mMachineCasingTier = getMachineCasingTierCheck(aBaseMetaTileEntity, xDir, zDir); + + Logger.INFO("Initial Casing Check Complete, Solid Casing Tier: "+mSolidCasingTier+", Machine Casing Tier: "+mMachineCasingTier); + + int aSolidCasingCount = 0; + int aMachineCasingCount = 0; + int aPipeCount = 0; + int aCoilCount = 0; + + aSolidCasingCount = checkSolidCasings(aBaseMetaTileEntity, aStack, xDir, zDir); + aMachineCasingCount = checkMachineCasings(aBaseMetaTileEntity, aStack, xDir, zDir); + aPipeCount = checkPipes(aBaseMetaTileEntity, aStack, xDir, zDir); + aCoilCount = checkCoils(aBaseMetaTileEntity, aStack, xDir, zDir); + + Logger.INFO("Casing Counts: "); + Logger.INFO("Solid: "+aSolidCasingCount+", Machine: "+aMachineCasingCount); + Logger.INFO("Pipe: "+aPipeCount+", Coil: "+aCoilCount); + + + Logger.INFO("Casing Tiers: "); + Logger.INFO("Solid: "+getSolidCasingTier()+", Machine: "+getMachineCasingTier()); + Logger.INFO("Pipe: "+getPipeCasingTier()+", Coil: "+getCoilTier()); + + // Attempt to sync fields here, so that it updates client side values. + aBaseMetaTileEntity.getWorld().markBlockForUpdate(aBaseMetaTileEntity.getXCoord(), aBaseMetaTileEntity.getYCoord(), aBaseMetaTileEntity.getZCoord()); + + + + // Minimum 80/93 Solid Casings + if (aSolidCasingCount < 80) { + Logger.INFO("Not enough solid casings. Found "+aSolidCasingCount+", require: 80."); + return false; + } + if (aMachineCasingCount != 57) { + Logger.INFO("Not enough machine casings. Found "+aMachineCasingCount+", require: 57."); + return false; + } + if (aPipeCount != 18) { + Logger.INFO("Not enough pipe casings. Found "+aPipeCount+", require: 18."); + return false; + } + if (aCoilCount != 27) { + Logger.INFO("Not enough coils. Found "+aCoilCount+", require: 27."); + return false; + } + + Logger.INFO("Structure Check Complete!"); + + return true; + } + } + + + public int checkCoils(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack, int aOffsetX, int aOffsetZ) { + int tAmount = 0; + int aCurrentCoilMeta = -1; + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + for (int h = 0; h < 8; h++) { + if (h == 1 || h == 3 || h == 5) { + Block aBlock = aBaseMetaTileEntity.getBlockOffset(aOffsetX + i, h, aOffsetZ + j); + int aMeta = aBaseMetaTileEntity.getMetaIDOffset(aOffsetX + i, h, aOffsetZ + j); + if (isBlockCoil(aBlock, aMeta)) { + if (aCurrentCoilMeta < 0) { + aCurrentCoilMeta = aMeta; + } + if (aCurrentCoilMeta != aMeta) { + return tAmount; + } + else { + tAmount++; + } + } + } + } + } + } + + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { + this.mCoilTier = (aCurrentCoilMeta+1); + } + else { + if (aCurrentCoilMeta == 12) { + this.mCoilTier = 1; + } + else if (aCurrentCoilMeta == 13) { + this.mCoilTier = 2; + } + else if (aCurrentCoilMeta == 14) { + this.mCoilTier = 3; + } + else { + this.mCoilTier = 0; + } + } + + return tAmount; + } + + + public int checkPipes(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack, int aOffsetX, int aOffsetZ) { + int tAmount = 0; + int aCurrentPipeMeta = -1; + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + for (int h = 0; h < 8; h++) { + if (h == 2 || h == 4) { + Block aBlock = aBaseMetaTileEntity.getBlockOffset(aOffsetX + i, h, aOffsetZ + j); + int aMeta = aBaseMetaTileEntity.getMetaIDOffset(aOffsetX + i, h, aOffsetZ + j); + if (isBlockPipeCasing(aBlock, aMeta)) { + if (aCurrentPipeMeta < 0) { + aCurrentPipeMeta = aMeta; + } + if (aCurrentPipeMeta != aMeta) { + return tAmount; + } + else { + tAmount++; + } + } + } + } + } + } + + if (aCurrentPipeMeta == 12) { + this.mPipeCasingTier = 1; + } + else if (aCurrentPipeMeta == 13) { + this.mPipeCasingTier = 2; + } + else if (aCurrentPipeMeta == 14) { + this.mPipeCasingTier = 3; + } + else if (aCurrentPipeMeta == 15) { + this.mPipeCasingTier = 4; + } + else { + this.mPipeCasingTier = 0; + } + + return tAmount; + } + + + public int checkSolidCasings(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack, int aOffsetX, int aOffsetZ) { + + int tAmount = 0; + + // Only check a 7x7 ring + for (int i = -3; i < 4; i++) { + for (int j = -3; j < 4; j++) { + // If we are on the 7x7 ring, proceed + if (i == -3 || i == 3 || j == -3 || j == 3) { + IGregTechTileEntity aTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(aOffsetX + i, 0, aOffsetZ + j); + Block aBlock = aBaseMetaTileEntity.getBlockOffset(aOffsetX + i, 0, aOffsetZ + j); + int aMeta = aBaseMetaTileEntity.getMetaIDOffset(aOffsetX + i, 0, aOffsetZ + j); + + if (aTileEntity != null) { + + if (this.addToMachineList(aTileEntity)) { + tAmount++; + } + else { + final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + Logger.INFO("Error counting Bottom Layer Casing Ring. Bad Tile Entity. Found "+aTileEntity.getInventoryName()); + return tAmount; + } + //Handle controller + if (aMetaTileEntity instanceof GregtechMTE_ChemicalPlant) { + continue; + } + else { + Logger.INFO("Error counting Bottom Layer Casing Ring. Bad Tile Entity. Found "+aMetaTileEntity.getInventoryName()); + return tAmount; + } + } + } + else { + if (isBlockSolidCasing(aBlock, aMeta)) { + tAmount++; + } + else { + Logger.INFO("Error counting Bottom Layer Casing Ring. Found "+aBlock.getLocalizedName()+":"+aMeta); + return tAmount; + } + } + } + } + } + + // Check 5 layers Pillars + for (int r=1;r<6;r++) { + // Check Each Pillar/Corner + for (int aPillar=0;aPillar<4;aPillar++) { + int i = 0; + int j = 0; + if (aPillar == 0) { + i = -3; + j = -3; + } + else if (aPillar == 1) { + i = 3; + j = 3; + } + else if (aPillar == 2) { + i = -3; + j = 3; + } + else if (aPillar == 3) { + i = 3; + j = -3; + } + Block aBlock = aBaseMetaTileEntity.getBlockOffset(aOffsetX + i, r, aOffsetZ + j); + int aMeta = aBaseMetaTileEntity.getMetaIDOffset(aOffsetX + i, r, aOffsetZ + j); + if (isBlockSolidCasing(aBlock, aMeta)) { + tAmount++; + } + else { + Logger.INFO("Error counting Pillars. Found "+ItemUtils.getLocalizedNameOfBlock(aBlock, aMeta)); + return tAmount; + } + } + } + + + // Check top layer 7x7 + for (int i = -3; i < 4; i++) { + for (int j = -3; j < 4; j++) { + Block aBlock = aBaseMetaTileEntity.getBlockOffset(aOffsetX + i, 6, aOffsetZ + j); + int aMeta = aBaseMetaTileEntity.getMetaIDOffset(aOffsetX + i, 6, aOffsetZ + j); + if (isBlockSolidCasing(aBlock, aMeta)) { + tAmount++; + } + else { + Logger.INFO("Error counting Top Layer casings. Found "+ItemUtils.getLocalizedNameOfBlock(aBlock, aMeta)); + return tAmount; + } + } + } + + return tAmount; + } + + + public int checkMachineCasings(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack, int aOffsetX, int aOffsetZ) { + int tAmount = 0; + int aHeight = 0; + // Iterate once for each layer + for (int aIteration=0;aIteration<3;aIteration++) { + // Dynamically set height + aHeight = (aIteration == 0 ? 0 : aIteration == 1 ? 1 : 5); + // Only check a 5x5 area + for (int i = -2; i < 3; i++) { + for (int j = -2; j < 3; j++) { + // If we are on the 5x5 ring, proceed + if (i == -2 || i == 2 || j == -2 || j == 2) { + // If the second axis is on the outer ring, continue + if (i < -2 || i > 2 || j < -2 || j > 2) { + continue; + } + Block aBlock = aBaseMetaTileEntity.getBlockOffset(aOffsetX + i, aHeight, aOffsetZ + j); + int aMeta = aBaseMetaTileEntity.getMetaIDOffset(aOffsetX + i, aHeight, aOffsetZ + j); + if (isBlockMachineCasing(aBlock, aMeta)) { + tAmount++; + } + else { + return tAmount; + } + } + } + } + } + + // Check bottom layer inner 3x3 + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + Block aBlock = aBaseMetaTileEntity.getBlockOffset(aOffsetX + i, 0, aOffsetZ + j); + int aMeta = aBaseMetaTileEntity.getMetaIDOffset(aOffsetX + i, 0, aOffsetZ + j); + if (isBlockMachineCasing(aBlock, aMeta)) { + tAmount++; + } + else { + return tAmount; + } + } + } + + return tAmount; + } + + public int getSolidCasingTierCheck(IGregTechTileEntity aBaseMetaTileEntity, int xDir, int zDir) { + Block aInitStructureCheck; + int aInitStructureCheckMeta; + if (xDir == 0) { + aInitStructureCheck = aBaseMetaTileEntity.getBlockOffset(zDir, 1, 0); + aInitStructureCheckMeta = aBaseMetaTileEntity.getMetaIDOffset(zDir, 1, 0); + } + else { + aInitStructureCheck = aBaseMetaTileEntity.getBlockOffset(0, 1, xDir); + aInitStructureCheckMeta = aBaseMetaTileEntity.getMetaIDOffset(0, 1, xDir); + } + if (aInitStructureCheck == GregTech_API.sBlockCasings2) { + int aMetaSteelCasing = 0; + if (aInitStructureCheckMeta == aMetaSteelCasing) { + return 1; + } + } + else if (aInitStructureCheck == GregTech_API.sBlockCasings4) { + int aMetaStainlessCasing = 1; + int aMetaTitaniumCasing = 2; + int aMetaTungstenCasing = 0; + if (aInitStructureCheckMeta == aMetaStainlessCasing) { + return 2; + } + else if (aInitStructureCheckMeta == aMetaTitaniumCasing) { + return 3; + } + else if (aInitStructureCheckMeta == aMetaTungstenCasing) { + return 4; + } + } + return 0; + } + + public int getMachineCasingTierCheck(IGregTechTileEntity aBaseMetaTileEntity, int xDir, int zDir) { + Block aInitStructureCheck; + int aInitStructureCheckMeta; + Logger.INFO(""+xDir+", "+zDir); + if (xDir == 0) { + if (zDir > 0) { + aInitStructureCheck = aBaseMetaTileEntity.getBlockOffset(0, 0, 1); + aInitStructureCheckMeta = aBaseMetaTileEntity.getMetaIDOffset(0, 0, 1); + } + else { + aInitStructureCheck = aBaseMetaTileEntity.getBlockOffset(0, 0, -1); + aInitStructureCheckMeta = aBaseMetaTileEntity.getMetaIDOffset(0, 0, -1); + } + + } + else { + if (xDir > 0) { + aInitStructureCheck = aBaseMetaTileEntity.getBlockOffset(1, 0, 0); + aInitStructureCheckMeta = aBaseMetaTileEntity.getMetaIDOffset(1, 0, 0); + } + else { + aInitStructureCheck = aBaseMetaTileEntity.getBlockOffset(-1, 0, 0); + aInitStructureCheckMeta = aBaseMetaTileEntity.getMetaIDOffset(-1, 0, 0); + } + } + + if (isBlockMachineCasing(aInitStructureCheck, aInitStructureCheckMeta)) { + Logger.INFO("Using Meta "+aInitStructureCheckMeta); + return aInitStructureCheckMeta; + } + return 0; + } + + + + + + + + + + + + + + + + + + + + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(final ItemStack aStack) { + return 0; + } + + @Override + public int getAmountOfOutputs() { + return 1; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + @Override + public String getCustomGUIResourceName() { + return null; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + // Silly Client Syncing + if (aBaseMetaTileEntity.isClientSide()) { + this.mSolidCasingTier = getCasingTierOnClientSide(); + } + + } + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPreTick(aBaseMetaTileEntity, aTick); + } + + @Override + public boolean checkRecipe(final ItemStack aStack) { + return checkRecipeGeneric(getMaxParallelRecipes(), getEuDiscountForParallelism(), 0); + } + + + + @SideOnly(Side.CLIENT) + private final int getCasingTierOnClientSide() { + + if (this == null || this.getBaseMetaTileEntity().getWorld() == null) { + return 0; + } + try { + Block aInitStructureCheck; + int aInitStructureCheckMeta; + IGregTechTileEntity aBaseMetaTileEntity = this.getBaseMetaTileEntity(); + int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX * 3; + int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ * 3; + if (xDir == 0) { + aInitStructureCheck = aBaseMetaTileEntity.getBlockOffset(zDir, 1, 0); + aInitStructureCheckMeta = aBaseMetaTileEntity.getMetaIDOffset(zDir, 1, 0); + } + else { + aInitStructureCheck = aBaseMetaTileEntity.getBlockOffset(0, 1, xDir); + aInitStructureCheckMeta = aBaseMetaTileEntity.getMetaIDOffset(0, 1, xDir); + } + if (aInitStructureCheck == GregTech_API.sBlockCasings2) { + int aMetaSteelCasing = 0; + if (aInitStructureCheckMeta == aMetaSteelCasing) { + return 1; + } + } + else if (aInitStructureCheck == GregTech_API.sBlockCasings4) { + int aMetaStainlessCasing = 1; + int aMetaTitaniumCasing = 2; + int aMetaTungstenCasing = 0; + if (aInitStructureCheckMeta == aMetaStainlessCasing) { + return 2; + } + else if (aInitStructureCheckMeta == aMetaTitaniumCasing) { + return 3; + } + else if (aInitStructureCheckMeta == aMetaTungstenCasing) { + return 4; + } + } + return 0; + } + catch (Throwable t) { + t.printStackTrace(); + return 0; + } + + } + + + + + + + + +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/storage/GregtechMetaTileEntity_PowerSubStationController.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/storage/GregtechMetaTileEntity_PowerSubStationController.java index dda1a6b0c0..7300b3507b 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/storage/GregtechMetaTileEntity_PowerSubStationController.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/storage/GregtechMetaTileEntity_PowerSubStationController.java @@ -21,6 +21,7 @@ import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.preloader.asm.AsmConfig; import gtPlusPlus.xmod.gregtech.api.gui.CONTAINER_PowerSubStation; import gtPlusPlus.xmod.gregtech.api.gui.GUI_PowerSubStation; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBattery; @@ -120,7 +121,9 @@ public class GregtechMetaTileEntity_PowerSubStationController extends GregtechMe checkMachineProblem(problem); } private void checkMachineProblem(String msg) { - Logger.INFO("Power Sub-Station problem: " + msg); + if (!AsmConfig.disableAllLogging) { + Logger.INFO("Power Sub-Station problem: " + msg); + } } public static int getCellTier(Block aBlock, int aMeta) { |