diff options
Diffstat (limited to 'src/Java/gtPlusPlus')
4 files changed, 202 insertions, 222 deletions
diff --git a/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java index 2ed4532d18..d7d611a1e4 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java @@ -912,46 +912,10 @@ public class ItemUtils { return CORE.burnables.add(new Pair<Integer, ItemStack>(burn, aBurnable)); } - /** - * Quick Block Name Lookup that is friendly to servers and locale. - */ - private static volatile Map<String, String> mLocaleCache = new HashMap<String, String>(); - public static String getLocalizedNameOfBlock(BlockPos pos) { Block block = pos.world.getBlock(pos.xPos, pos.yPos, pos.zPos); int metaData = pos.world.getBlockMetadata(pos.xPos, pos.yPos, pos.zPos); - return getLocalizedNameOfBlock(block, metaData); - } - - public synchronized static String getLocalizedNameOfBlock(Block block, int meta) { - if (block == null || meta < 0) { - return "Bad Block"; - } - String mCacheKey = block.getUnlocalizedName() + ":" + meta; - if (mLocaleCache.containsKey(mCacheKey)) { - // Recache the key if it's invalid. - if (mLocaleCache.get(mCacheKey).toLowerCase().contains(".name")) { - mLocaleCache.remove(mCacheKey); - String mNew = ItemUtils.simpleMetaStack(block, meta, 1).getDisplayName(); - //Logger.INFO("Re-caching "+mNew+" into locale cache."); - mLocaleCache.put(mCacheKey, mNew); - } - //Logger.INFO("Returning Cached Value."); - return mLocaleCache.get(mCacheKey); - } else { - Item item = Item.getItemFromBlock(block); - if (item == null) { - return "Bad Item"; - } - String unlocalizedName = item.getUnlocalizedName(new ItemStack(block, 1, meta)); - String blockName = StatCollector.translateToLocal(unlocalizedName + ".name"); - if (blockName.toLowerCase().contains(".name")) { - blockName = ItemUtils.simpleMetaStack(block, meta, 1).getDisplayName(); - } - mLocaleCache.put(mCacheKey, blockName); - //Logger.INFO("Cached New Value."); - return blockName; - } + return LangUtils.getLocalizedNameOfBlock(block, metaData); } public static boolean checkForInvalidItems(ItemStack mInput) { @@ -1346,4 +1310,8 @@ public class ItemUtils { return false; } + public static String getLocalizedNameOfBlock(Block aBlock, int aMeta) { + return LangUtils.getLocalizedNameOfBlock(aBlock, aMeta); + } + } diff --git a/src/Java/gtPlusPlus/core/util/minecraft/LangUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/LangUtils.java index 01d0efac54..0b24e962af 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/LangUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/LangUtils.java @@ -7,7 +7,13 @@ import java.util.Properties; import cpw.mods.fml.common.registry.LanguageRegistry; import gregtech.api.util.GT_LanguageManager; +import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.util.reflect.ReflectionUtils; +import net.minecraft.block.Block; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.StatCollector; public class LangUtils { @@ -15,7 +21,7 @@ public class LangUtils { public static boolean rewriteEntryForLanguageRegistry(String aKey, String aNewValue){ return rewriteEntryForLanguageRegistry("en_US", aKey, aNewValue); } - + @SuppressWarnings("unchecked") public static boolean rewriteEntryForLanguageRegistry(String aLang, String aKey, String aNewValue){ LanguageRegistry aInstance = LanguageRegistry.instance(); @@ -43,7 +49,7 @@ public class LangUtils { } } catch (IllegalArgumentException | IllegalAccessException e) { - + } } return false; @@ -52,5 +58,93 @@ public class LangUtils { public static String trans(String aNr, String aEnglish) { return GT_LanguageManager.addStringLocalization("Interaction_DESCRIPTION_Index_GTPP_" + aNr, aEnglish, false); } - + + + + /** + * Quick Block Name Lookup that is friendly to servers and locale. + */ + private static final Map<String, String> mLocaleCache = new HashMap<String, String>(); + + public static String getLocalizedNameOfBlock(Block aBlock, int aMeta) { + if (aBlock != null) { + return getLocalizedNameOfItemStack(ItemUtils.simpleMetaStack(aBlock, aMeta, 1)); + } + return "Bad Block Name"; + } + + public static String getLocalizedNameOfItem(Item aItem, int aMeta) { + if (aItem != null) { + return getLocalizedNameOfItemStack(ItemUtils.simpleMetaStack(aItem, aMeta, 1)); + } + return "Bad Item Name"; + } + + public static String getLocalizedNameOfItemStack(ItemStack aStack) { + String aUnlocalized; + if (aStack != null) { + aUnlocalized = ItemUtils.getUnlocalizedItemName(aStack)+"."+aStack.getItemDamage()+".name"; + if (aUnlocalized == null || aUnlocalized.length() <= 0) { + return "Bad Locale Data"; + } + String mCacheKey = aUnlocalized; + if (mLocaleCache.containsKey(mCacheKey)) { + // Recache the key if it's invalid. + if (mLocaleCache.get(mCacheKey).toLowerCase().contains(".name") || mLocaleCache.get(mCacheKey).toLowerCase().contains("|")) { + mLocaleCache.remove(mCacheKey); + String mNew; + try { + mNew = ("" + StatCollector + .translateToLocal(aStack.getItem().getUnlocalizedNameInefficiently(aStack) + ".name")) + .trim(); + if (aStack.hasTagCompound()) { + if (aStack.stackTagCompound != null && aStack.stackTagCompound.hasKey("display", 10)) { + NBTTagCompound nbttagcompound = aStack.stackTagCompound.getCompoundTag("display"); + + if (nbttagcompound.hasKey("Name", 8)) { + mNew = nbttagcompound.getString("Name"); + } + } + } + } catch (Throwable t) { + mNew = "ERROR - Empty Stack"; + } + Logger.INFO("Re-caching "+mNew+" into locale cache. Key: "+mCacheKey); + mLocaleCache.put(mCacheKey, mNew); + } + Logger.INFO("Returning Cached Value. Key: "+mCacheKey); + return mLocaleCache.get(mCacheKey); + } + else { + String unlocalizedName = aStack.getItem().getUnlocalizedName(aStack); + Logger.INFO("Cached New Value. UnlocalName: "+unlocalizedName); + String blockName = StatCollector.translateToLocal(unlocalizedName + ".name"); + Logger.INFO("Cached New Value. TranslatedName: "+unlocalizedName); + if (blockName.toLowerCase().contains(".name") || blockName.toLowerCase().contains("|")) { + try { + blockName = ("" + StatCollector + .translateToLocal(aStack.getItem().getUnlocalizedNameInefficiently(aStack) + ".name")) + .trim(); + if (aStack.hasTagCompound()) { + if (aStack.stackTagCompound != null && aStack.stackTagCompound.hasKey("display", 10)) { + NBTTagCompound nbttagcompound = aStack.stackTagCompound.getCompoundTag("display"); + if (nbttagcompound.hasKey("Name", 8)) { + blockName = nbttagcompound.getString("Name"); + } + } + } + } catch (Throwable t) { + blockName = "ERROR - Empty Stack"; + } + } + mLocaleCache.put(mCacheKey, blockName); + Logger.INFO("Cached New Value. Key: "+mCacheKey); + return blockName; + } + + } + return "Bad ItemStack Name"; + } + + } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java index e1849985d0..a115b223d8 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java @@ -415,7 +415,8 @@ public abstract class GregtechMeta_MultiBlockBase extends GT_MetaTileEntity_Mult aToolTip = ArrayUtils.addAll(aToolTip, x); aToolTip = ArrayUtils.addAll(aToolTip, z); - if (aCachedToolTip == null || aCachedToolTip.length <= 0) { + //Valid Cached Tooltip during Run-Time + if (aCachedToolTip == null || aCachedToolTip.length <= 0 || aCachedToolTip.length != aToolTip.length) { aCachedToolTip = aToolTip; } return aCachedToolTip; @@ -2581,7 +2582,7 @@ public abstract class GregtechMeta_MultiBlockBase extends GT_MetaTileEntity_Mult else if (aFoundBlock != aExpectedBlock) { if (GTplusplus.CURRENT_LOAD_PHASE == INIT_PHASE.STARTED) { log("A1 - Found: "+aFoundBlock.getLocalizedName()+":"+aFoundMeta+", Expected: "+aExpectedBlock.getLocalizedName()+":"+aExpectedMeta); - log("Loc: "+(new BlockPos(aBaseMetaTileEntity).getLocationString())); + //log("Loc: "+(new BlockPos(aBaseMetaTileEntity).getLocationString())); } return false; } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_LargeNaqReactor.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_LargeNaqReactor.java index 89bb00f64d..e8e7a6fd2f 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_LargeNaqReactor.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_LargeNaqReactor.java @@ -1,6 +1,5 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; -import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import gregtech.api.GregTech_API; @@ -10,18 +9,18 @@ import gregtech.api.gui.GT_GUIContainer_MultiMachine; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.minecraft.LangUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Naquadah; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; -import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.advanced.GregtechMetaTileEntity_Adv_Fusion_MK4; import net.minecraft.block.Block; import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection; @@ -29,16 +28,24 @@ public class GregtechMTE_LargeNaqReactor extends GregtechMeta_MultiBlockBase { public ArrayList<GT_MetaTileEntity_Hatch_Naquadah> mNaqHatches = new ArrayList<GT_MetaTileEntity_Hatch_Naquadah>(); public static String[] mCasingName = new String[5]; - public static String mHatchName = "Naquadah Fuel Hatch"; + public static String mHatchName = "Naquadah Fuel Hatch"; + + private final int CASING_TEXTURE_ID = TAE.getIndexFromPage(0, 13); + private final int META_BaseCasing = 0; //4 + private final int META_ContainmentCasing = 15; //3 + private final int META_Shielding = 13; //1 + private final int META_PipeCasing = 1; //4 + private final int META_IntegralCasing = 6; //0 + private final int META_ContainmentChamberCasing = 2; //4 public GregtechMTE_LargeNaqReactor(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); - mCasingName[0] = ItemUtils.getLocalizedNameOfBlock(getCasing(4), 0); - mCasingName[1] = ItemUtils.getLocalizedNameOfBlock(getCasing(4), 1); - mCasingName[2] = ItemUtils.getLocalizedNameOfBlock(getCasing(4), 2); - mCasingName[3] = ItemUtils.getLocalizedNameOfBlock(getCasing(3), 15); - mCasingName[4] = ItemUtils.getLocalizedNameOfBlock(getCasing(3), 3); - mHatchName = ItemUtils.getLocalizedNameOfBlock(GregTech_API.sBlockMachines, 969); + mCasingName[0] = LangUtils.getLocalizedNameOfBlock(getCasing(4), 0); + mCasingName[1] = LangUtils.getLocalizedNameOfBlock(getCasing(4), 1); + mCasingName[2] = LangUtils.getLocalizedNameOfBlock(getCasing(4), 2); + mCasingName[3] = LangUtils.getLocalizedNameOfBlock(getCasing(3), 15); + mCasingName[4] = LangUtils.getLocalizedNameOfBlock(getCasing(3), 3); + mHatchName = LangUtils.getLocalizedNameOfBlock(GregTech_API.sBlockMachines, 969); } public GregtechMTE_LargeNaqReactor(String aName) { @@ -51,22 +58,22 @@ public class GregtechMTE_LargeNaqReactor extends GregtechMeta_MultiBlockBase { public String[] getTooltip() { if (mCasingName[0].toLowerCase().contains(".name")) { - mCasingName[0] = ItemUtils.getLocalizedNameOfBlock(getCasing(4), 0); + mCasingName[0] = LangUtils.getLocalizedNameOfBlock(getCasing(4), 0); } if (mCasingName[1].toLowerCase().contains(".name")) { - mCasingName[1] = ItemUtils.getLocalizedNameOfBlock(getCasing(4), 1); + mCasingName[1] = LangUtils.getLocalizedNameOfBlock(getCasing(4), 1); } if (mCasingName[2].toLowerCase().contains(".name")) { - mCasingName[2] = ItemUtils.getLocalizedNameOfBlock(getCasing(4), 2); + mCasingName[2] = LangUtils.getLocalizedNameOfBlock(getCasing(4), 2); } if (mCasingName[3].toLowerCase().contains(".name")) { - mCasingName[3] = ItemUtils.getLocalizedNameOfBlock(getCasing(3), 15); + mCasingName[3] = LangUtils.getLocalizedNameOfBlock(getCasing(3), 15); } if (mCasingName[4].toLowerCase().contains(".name")) { - mCasingName[4] = ItemUtils.getLocalizedNameOfBlock(getCasing(3), 3); + mCasingName[4] = LangUtils.getLocalizedNameOfBlock(getCasing(3), 3); } if (mHatchName.toLowerCase().contains(".name")) { - mHatchName = ItemUtils.getLocalizedNameOfBlock(GregTech_API.sBlockMachines, 969); + mHatchName = LangUtils.getLocalizedNameOfBlock(GregTech_API.sBlockMachines, 969); } return new String[]{ "Naquadah reacts violently with potassium, ", @@ -111,7 +118,7 @@ public class GregtechMTE_LargeNaqReactor extends GregtechMeta_MultiBlockBase { } public boolean isFacingValid(byte aFacing) { - return aFacing > 1; + return aFacing == 1; } public boolean checkRecipe(ItemStack aStack) { @@ -155,7 +162,7 @@ public class GregtechMTE_LargeNaqReactor extends GregtechMeta_MultiBlockBase { return ModBlocks.blockCasings4Misc; } else { - return ModBlocks.blockCasingsMisc; + return ModBlocks.blockCasingsTieredGTPP; } } @@ -168,160 +175,36 @@ public class GregtechMTE_LargeNaqReactor extends GregtechMeta_MultiBlockBase { //Magic Glass - blockAlloyGlass public boolean checkMultiblock(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; - int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; - int r; - int i; - IGregTechTileEntity tTileEntity; - if (xDir != 0) { - for (r = 0; r <= 16; ++r) { - i = r * xDir; - tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(0, 0, i); - if (i != 0 - && (aBaseMetaTileEntity.getBlockOffset(0, 0, i) != getCasing(3) - || aBaseMetaTileEntity.getMetaIDOffset(0, 0, i) != 3) - && r == 1 && !this.addNaquadahHatchToMachineInput(tTileEntity, TAE.getIndexFromPage(2, 3))) { - return false; - } - - if (aBaseMetaTileEntity.getBlockOffset(0, -1, i) != getCasing(3) || aBaseMetaTileEntity.getMetaIDOffset(0, -1, i) != 15) { - return false; - } - - tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(0, -2, i); - if (!this.addMaintenanceToMachineList(tTileEntity, TAE.getIndexFromPage(3, 0)) - && !this.addInputToMachineList(tTileEntity, TAE.getIndexFromPage(3, 0))) { - if (aBaseMetaTileEntity.getBlockOffset(0, -2, i) != getCasing(4)) { - return false; - } - - if (aBaseMetaTileEntity.getMetaIDOffset(0, -2, i) != 0) { - return false; - } - } - - tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir, 1, i); - if (!this.addDynamoToMachineList(tTileEntity, TAE.getIndexFromPage(3, 0))) { - if (aBaseMetaTileEntity.getBlockOffset(xDir, 1, i) != getCasing(4)) { - return false; - } - - if (aBaseMetaTileEntity.getMetaIDOffset(xDir, 1, i) != 0) { - return false; - } - } - - if (i != 0 && (aBaseMetaTileEntity.getBlockOffset(xDir, 0, i) != getCasing(4) - || aBaseMetaTileEntity.getMetaIDOffset(xDir, 0, i) != 1)) { - return false; - } - - if (i != 0 && (aBaseMetaTileEntity.getBlockOffset(xDir, -1, i) != getCasing(4) - || aBaseMetaTileEntity.getMetaIDOffset(xDir, -1, i) != 2)) { - return false; - } - - if (aBaseMetaTileEntity.getBlockOffset(xDir * 2, 0, i) != getCasing(3) - || aBaseMetaTileEntity.getMetaIDOffset(xDir * 2, 0, i) != 3) { - return false; - } - - if (aBaseMetaTileEntity.getBlockOffset(xDir * 2, -1, i) != getCasing(3) || aBaseMetaTileEntity.getMetaIDOffset(xDir * 2, -1, i) != 15) { - return false; - } - - tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir * 2, -2, i); - if (!this.addMaintenanceToMachineList(tTileEntity, TAE.getIndexFromPage(3, 0)) - && !this.addInputToMachineList(tTileEntity, TAE.getIndexFromPage(3, 0))) { - if (aBaseMetaTileEntity.getBlockOffset(xDir * 2, -2, i) != getCasing(4)) { - return false; - } - - if (aBaseMetaTileEntity.getMetaIDOffset(xDir * 2, -2, i) != 0) { - return false; - } - } - - tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir, -2, i); - if (!this.addInputToMachineList(tTileEntity, TAE.getIndexFromPage(3, 0)) && this.addOutputToMachineList(tTileEntity, TAE.getIndexFromPage(3, 0))) { - return r > 0 && this.mEnergyHatches.size() > 0; - } - } - } else { - for (r = 0; r <= 16; ++r) { - i = r * -zDir; - tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(i, 0, 0); - if (i != 0 - && (aBaseMetaTileEntity.getBlockOffset(i, 0, 0) != getCasing(3) - || aBaseMetaTileEntity.getMetaIDOffset(i, 0, 0) != 3) - && r == 1 && !this.addNaquadahHatchToMachineInput(tTileEntity, TAE.getIndexFromPage(2, 3))) { - return false; - } - - if (aBaseMetaTileEntity.getBlockOffset(i, -1, 0) != getCasing(3) || aBaseMetaTileEntity.getMetaIDOffset(i, -1, 0) != 15) { - return false; - } - - tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(i, -2, 0); - if (!this.addMaintenanceToMachineList(tTileEntity, TAE.getIndexFromPage(3, 0)) - && !this.addInputToMachineList(tTileEntity, TAE.getIndexFromPage(3, 0))) { - if (aBaseMetaTileEntity.getBlockOffset(i, -2, 0) != getCasing(4)) { - return false; - } - - if (aBaseMetaTileEntity.getMetaIDOffset(i, -2, 0) != 0) { - return false; - } - } - - tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(i, 1, zDir); - if (!this.addDynamoToMachineList(tTileEntity, TAE.getIndexFromPage(3, 0))) { - if (aBaseMetaTileEntity.getBlockOffset(i, 1, zDir) != getCasing(4)) { - return false; - } - - if (aBaseMetaTileEntity.getMetaIDOffset(i, 1, zDir) != 0) { - return false; - } - } - - if (i != 0 && (aBaseMetaTileEntity.getBlockOffset(i, 0, zDir) != getCasing(4) - || aBaseMetaTileEntity.getMetaIDOffset(i, 0, zDir) != 1)) { - return false; - } - - if (i != 0 && (aBaseMetaTileEntity.getBlockOffset(i, -1, zDir) != getCasing(4) - || aBaseMetaTileEntity.getMetaIDOffset(i, -1, zDir) != 2)) { - return false; - } - - if (aBaseMetaTileEntity.getBlockOffset(i, 0, zDir * 2) != getCasing(3) - || aBaseMetaTileEntity.getMetaIDOffset(i, 0, zDir * 2) != 3) { - return false; - } - - if (aBaseMetaTileEntity.getBlockOffset(i, -1, zDir * 2) != getCasing(3) || aBaseMetaTileEntity.getMetaIDOffset(i, -1, zDir * 2) != 15) { - return false; - } - - tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(i, -2, zDir * 2); - if (!this.addMaintenanceToMachineList(tTileEntity, TAE.getIndexFromPage(3, 0)) - && !this.addInputToMachineList(tTileEntity, TAE.getIndexFromPage(3, 0))) { - if (aBaseMetaTileEntity.getBlockOffset(i, -2, zDir * 2) != getCasing(4)) { - return false; - } - - if (aBaseMetaTileEntity.getMetaIDOffset(i, -2, zDir * 2) != 0) { - return false; - } - } - - tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(i, -2, zDir); - if (!this.addInputToMachineList(tTileEntity, TAE.getIndexFromPage(3, 0)) && this.addOutputToMachineList(tTileEntity, TAE.getIndexFromPage(3, 0))) { - return r > 0 && this.mEnergyHatches.size() > 0; - } - } - } + int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX * 4; + int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ * 4; + + // Counts for all Casing Types + int aBaseCasingCount = 0; + int aContainmentCasingCount = 0; + int aShieldingCount = 0; + int aPipeCount = 0; + int aIntegralCasingCount = 0; + int aContainmentChamberCount = 0; + + // Bottom Layer + aBaseCasingCount += checkEntireLayer(aBaseMetaTileEntity, getCasing(4), META_BaseCasing, -7, xDir, zDir); + Logger.INFO("Bottom Layer is Valid. Moving to Layer 1."); + // Layer 1 + + // Layer 2 + + // Layer 3 + + // Layer 4 + + // Layer 5 + + // Layer 6 + + // Top Layer + aBaseCasingCount += checkEntireLayer(aBaseMetaTileEntity, getCasing(4), META_BaseCasing, 0, xDir, zDir); + + return false; } @@ -334,19 +217,53 @@ public class GregtechMTE_LargeNaqReactor extends GregtechMeta_MultiBlockBase { if (aMetaTileEntity == null) { return false; } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Naquadah) { - - try { - GregtechMetaTileEntity_Adv_Fusion_MK4.mUpdateHatchTexture.invoke((GT_MetaTileEntity_Hatch) aMetaTileEntity, aBaseCasingIndex); - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - } - - //((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + this.updateTexture(aMetaTileEntity, aBaseCasingIndex); return this.mNaqHatches.add((GT_MetaTileEntity_Hatch_Naquadah) aMetaTileEntity); } else { return false; } } } + + public int checkEntireLayer(IGregTechTileEntity aBaseMetaTileEntity, Block aBlock, int aMeta, int aY, int xDir, int zDir) { + int aCasingCount = 0; + for (int x = -4; x < 5; x++) { + for (int z = -4; z < 5; z++) { + int aOffsetX = this.getBaseMetaTileEntity().getXCoord() + x; + int aOffsetY = this.getBaseMetaTileEntity().getYCoord() + aY; + int aOffsetZ = this.getBaseMetaTileEntity().getZCoord() + z; + //Skip the corners + if ((x == 4 && z == 4) || (x == -4 && z == -4) || (x == 4 && z == -4) || (x == -4 && z == 4)) { + continue; + } + Block aCurrentBlock = aBaseMetaTileEntity.getBlockOffset(xDir + x, aY, zDir + z); + int aCurrentMeta = (int) aBaseMetaTileEntity.getMetaIDOffset(xDir + x, aY, zDir + z); + if (aCurrentBlock == aBlock && aCurrentMeta == aMeta) { + aCasingCount++; + } + final IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + x, aY, zDir + z); + if (!isValidBlockForStructure(tTileEntity, CASING_TEXTURE_ID, true, aCurrentBlock, aCurrentMeta, aBlock, aMeta)) { + Logger.INFO("Layer has error. Height: "+aY); + this.getBaseMetaTileEntity().getWorld().setBlock(aOffsetX, aOffsetY, aOffsetZ, Blocks.pumpkin); + return 0; + } + } + } + return aCasingCount; + } + + public int checkOuterRing(Block aBlock, int aMeta, int aY) { + return 0; + } + public int checkIntegralRing(Block aBlock, int aMeta, int aY) { + return 0; + } + public int checkPipes(Block aBlock, int aMeta, int aY) { + return 0; + } + public int checkContainmentRing(Block aBlock, int aMeta, int aY) { + return 0; + } public int getMaxEfficiency(ItemStack aStack) { return 10000; |