diff options
author | Jakub <53441451+kuba6000@users.noreply.github.com> | 2022-08-29 16:04:28 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-29 16:04:28 +0200 |
commit | 7d1f51a8937e0a86486267437d444696e81e8aa0 (patch) | |
tree | a5b145e7271998f7b4b968a2212ed487e54a92b5 /src/main/java/gtPlusPlus/xmod/gregtech/api | |
parent | 5267969156d30b4bb5f4cb2279ebb49db6bd40e2 (diff) | |
download | GT5-Unofficial-7d1f51a8937e0a86486267437d444696e81e8aa0.tar.gz GT5-Unofficial-7d1f51a8937e0a86486267437d444696e81e8aa0.tar.bz2 GT5-Unofficial-7d1f51a8937e0a86486267437d444696e81e8aa0.zip |
Buildscript + Spotless (#318)
* Convert AES.java to readable class
* Buildscript
* Spotless
Diffstat (limited to 'src/main/java/gtPlusPlus/xmod/gregtech/api')
167 files changed, 27172 insertions, 22286 deletions
diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/energy/IC2ElectricItem.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/energy/IC2ElectricItem.java index 4ec4589c03..d4a7f97051 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/energy/IC2ElectricItem.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/energy/IC2ElectricItem.java @@ -9,47 +9,46 @@ import net.minecraft.item.ItemStack; * The item should have a maximum damage of 13. */ public interface IC2ElectricItem { - /** - * Determine if the item can be used in a machine or as an armor part to supply energy. - * - * @return Whether the item can supply energy - */ - boolean canProvideEnergy(ItemStack itemStack); - - /** - * Get the item ID to use for a charge energy greater than 0. - * - * @return Item ID to use - */ - Item getChargedItem(ItemStack itemStack); - - /** - * Get the item ID to use for a charge energy of 0. - * - * @return Item ID to use - */ - Item getEmptyItem(ItemStack itemStack); - - /** - * Get the item's maximum charge energy in EU. - * - * @return Maximum charge energy - */ - double getMaxCharge(ItemStack itemStack); - - /** - * Get the item's tier, lower tiers can't send energy to higher ones. - * Batteries are Tier 1, Energy Crystals are Tier 2, Lapotron Crystals are Tier 3. - * - * @return Item's tier - */ - int getTier(ItemStack itemStack); - - /** - * Get the item's transfer limit in EU per transfer operation. - * - * @return Transfer limit - */ - double getTransferLimit(ItemStack itemStack); + /** + * Determine if the item can be used in a machine or as an armor part to supply energy. + * + * @return Whether the item can supply energy + */ + boolean canProvideEnergy(ItemStack itemStack); + + /** + * Get the item ID to use for a charge energy greater than 0. + * + * @return Item ID to use + */ + Item getChargedItem(ItemStack itemStack); + + /** + * Get the item ID to use for a charge energy of 0. + * + * @return Item ID to use + */ + Item getEmptyItem(ItemStack itemStack); + + /** + * Get the item's maximum charge energy in EU. + * + * @return Maximum charge energy + */ + double getMaxCharge(ItemStack itemStack); + + /** + * Get the item's tier, lower tiers can't send energy to higher ones. + * Batteries are Tier 1, Energy Crystals are Tier 2, Lapotron Crystals are Tier 3. + * + * @return Item's tier + */ + int getTier(ItemStack itemStack); + + /** + * Get the item's transfer limit in EU per transfer operation. + * + * @return Transfer limit + */ + double getTransferLimit(ItemStack itemStack); } - diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/energy/IC2ElectricItemManager.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/energy/IC2ElectricItemManager.java index 8bf42578cc..4ec01ce63c 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/energy/IC2ElectricItemManager.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/energy/IC2ElectricItemManager.java @@ -18,78 +18,84 @@ import net.minecraft.item.ItemStack; * more atomic features in the gateway manager. */ public interface IC2ElectricItemManager { - /** - * Charge an item with a specified amount of energy. - * - * @param itemStack electric item's stack - * @param amount amount of energy to charge in EU - * @param tier tier of the charging device, has to be at least as high as the item to charge - * @param ignoreTransferLimit ignore the transfer limit specified by getTransferLimit() - * @param simulate don't actually change the item, just determine the return value - * @return Energy transferred into the electric item - */ - double charge(ItemStack stack, double amount, int tier, boolean ignoreTransferLimit, boolean simulate); + /** + * Charge an item with a specified amount of energy. + * + * @param itemStack electric item's stack + * @param amount amount of energy to charge in EU + * @param tier tier of the charging device, has to be at least as high as the item to charge + * @param ignoreTransferLimit ignore the transfer limit specified by getTransferLimit() + * @param simulate don't actually change the item, just determine the return value + * @return Energy transferred into the electric item + */ + double charge(ItemStack stack, double amount, int tier, boolean ignoreTransferLimit, boolean simulate); - /** - * Discharge an item by a specified amount of energy - * - * @param itemStack electric item's stack - * @param amount amount of energy to discharge in EU - * @param tier tier of the discharging device, has to be at least as high as the item to discharge - * @param ignoreTransferLimit ignore the transfer limit specified by getTransferLimit() - * @param externally use the supplied item externally, i.e. to power something else as if it was a battery - * @param simulate don't actually discharge the item, just determine the return value - * @return Energy retrieved from the electric item - */ - double discharge(ItemStack stack, double amount, int tier, boolean ignoreTransferLimit, boolean externally, boolean simulate); + /** + * Discharge an item by a specified amount of energy + * + * @param itemStack electric item's stack + * @param amount amount of energy to discharge in EU + * @param tier tier of the discharging device, has to be at least as high as the item to discharge + * @param ignoreTransferLimit ignore the transfer limit specified by getTransferLimit() + * @param externally use the supplied item externally, i.e. to power something else as if it was a battery + * @param simulate don't actually discharge the item, just determine the return value + * @return Energy retrieved from the electric item + */ + double discharge( + ItemStack stack, + double amount, + int tier, + boolean ignoreTransferLimit, + boolean externally, + boolean simulate); - /** - * Determine the charge level for the specified item. - * - * @param itemStack ItemStack containing the electric item - * @return charge level in EU - */ - double getCharge(ItemStack stack); + /** + * Determine the charge level for the specified item. + * + * @param itemStack ItemStack containing the electric item + * @return charge level in EU + */ + double getCharge(ItemStack stack); - /** - * Determine if the specified electric item has at least a specific amount of EU. - * This is supposed to be used in the item code during operation, for example if you want to implement your own electric item. - * BatPacks are not taken into account. - * - * @param itemStack electric item's stack - * @param amount minimum amount of energy required - * @return true if there's enough energy - */ - boolean canUse(ItemStack stack, double amount); + /** + * Determine if the specified electric item has at least a specific amount of EU. + * This is supposed to be used in the item code during operation, for example if you want to implement your own electric item. + * BatPacks are not taken into account. + * + * @param itemStack electric item's stack + * @param amount minimum amount of energy required + * @return true if there's enough energy + */ + boolean canUse(ItemStack stack, double amount); - /** - * Try to retrieve a specific amount of energy from an Item, and if applicable, a BatPack. - * This is supposed to be used in the item code during operation, for example if you want to implement your own electric item. - * - * @param itemStack electric item's stack - * @param amount amount of energy to discharge in EU - * @param entity entity holding the item - * @return true if the operation succeeded - */ - boolean use(ItemStack stack, double amount, EntityLivingBase entity); + /** + * Try to retrieve a specific amount of energy from an Item, and if applicable, a BatPack. + * This is supposed to be used in the item code during operation, for example if you want to implement your own electric item. + * + * @param itemStack electric item's stack + * @param amount amount of energy to discharge in EU + * @param entity entity holding the item + * @return true if the operation succeeded + */ + boolean use(ItemStack stack, double amount, EntityLivingBase entity); - /** - * Charge an item from the BatPack a player is wearing. - * This is supposed to be used in the item code during operation, for example if you want to implement your own electric item. - * use() already contains this functionality. - * - * @param itemStack electric item's stack - * @param entity entity holding the item - */ - void chargeFromArmor(ItemStack stack, EntityLivingBase entity); + /** + * Charge an item from the BatPack a player is wearing. + * This is supposed to be used in the item code during operation, for example if you want to implement your own electric item. + * use() already contains this functionality. + * + * @param itemStack electric item's stack + * @param entity entity holding the item + */ + void chargeFromArmor(ItemStack stack, EntityLivingBase entity); - /** - * Get the tool tip to display for electric items. - * - * @param itemStack ItemStack to determine the tooltip for - * @return tool tip string or null for none - */ - String getToolTip(ItemStack stack); + /** + * Get the tool tip to display for electric items. + * + * @param itemStack ItemStack to determine the tooltip for + * @return tool tip string or null for none + */ + String getToolTip(ItemStack stack); - // TODO: add tier getter + // TODO: add tier getter } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/CustomGtTextures.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/CustomGtTextures.java index 554983c41c..a31e728e23 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/CustomGtTextures.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/CustomGtTextures.java @@ -1,81 +1,79 @@ package gtPlusPlus.xmod.gregtech.api.enums; -import net.minecraft.client.renderer.texture.TextureMap; -import net.minecraft.util.IIcon; -import net.minecraft.util.ResourceLocation; - import gregtech.api.GregTech_API; import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.ITexture; import gregtech.api.objects.GT_RenderedTexture; - import gtPlusPlus.core.lib.CORE; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; public class CustomGtTextures { - public enum ItemIcons implements IIconContainer, Runnable { - VOID, // The Empty Texture - RENDERING_ERROR, - PUMP, - SKOOKUMCHOOCHER; - - public static final ITexture[] ERROR_RENDERING = new ITexture[]{new GT_RenderedTexture(RENDERING_ERROR)}; - - protected IIcon mIcon, mOverlay; - - private ItemIcons() { - GregTech_API.sGTItemIconload.add(this); - } - - @Override - public IIcon getIcon() { - return this.mIcon; - } - - @Override - public IIcon getOverlayIcon() { - return this.mOverlay; - } - - @Override - public ResourceLocation getTextureFile() { - return TextureMap.locationItemsTexture; - } - - @Override - public void run() { - this.mIcon = GregTech_API.sItemIcons.registerIcon(CORE.RES_PATH_ITEM + "iconsets/" + this); - this.mOverlay = GregTech_API.sItemIcons.registerIcon(CORE.RES_PATH_ITEM + "iconsets/" + this + "_OVERLAY"); - } - - public static class CustomIcon implements IIconContainer, Runnable { - protected IIcon mIcon, mOverlay; - protected String mIconName; - - public CustomIcon(final String aIconName) { - this.mIconName = aIconName; - GregTech_API.sGTItemIconload.add(this); - } - - @Override - public IIcon getIcon() { - return this.mIcon; - } - - @Override - public IIcon getOverlayIcon() { - return this.mOverlay; - } - - @Override - public void run() { - this.mIcon = GregTech_API.sItemIcons.registerIcon(CORE.RES_PATH_ITEM + this.mIconName); - this.mOverlay = GregTech_API.sItemIcons.registerIcon(CORE.RES_PATH_ITEM + this.mIconName + "_OVERLAY"); - } - - @Override - public ResourceLocation getTextureFile() { - return TextureMap.locationItemsTexture; - } - } - } -}
\ No newline at end of file + public enum ItemIcons implements IIconContainer, Runnable { + VOID, // The Empty Texture + RENDERING_ERROR, + PUMP, + SKOOKUMCHOOCHER; + + public static final ITexture[] ERROR_RENDERING = new ITexture[] {new GT_RenderedTexture(RENDERING_ERROR)}; + + protected IIcon mIcon, mOverlay; + + private ItemIcons() { + GregTech_API.sGTItemIconload.add(this); + } + + @Override + public IIcon getIcon() { + return this.mIcon; + } + + @Override + public IIcon getOverlayIcon() { + return this.mOverlay; + } + + @Override + public ResourceLocation getTextureFile() { + return TextureMap.locationItemsTexture; + } + + @Override + public void run() { + this.mIcon = GregTech_API.sItemIcons.registerIcon(CORE.RES_PATH_ITEM + "iconsets/" + this); + this.mOverlay = GregTech_API.sItemIcons.registerIcon(CORE.RES_PATH_ITEM + "iconsets/" + this + "_OVERLAY"); + } + + public static class CustomIcon implements IIconContainer, Runnable { + protected IIcon mIcon, mOverlay; + protected String mIconName; + + public CustomIcon(final String aIconName) { + this.mIconName = aIconName; + GregTech_API.sGTItemIconload.add(this); + } + + @Override + public IIcon getIcon() { + return this.mIcon; + } + + @Override + public IIcon getOverlayIcon() { + return this.mOverlay; + } + + @Override + public void run() { + this.mIcon = GregTech_API.sItemIcons.registerIcon(CORE.RES_PATH_ITEM + this.mIconName); + this.mOverlay = GregTech_API.sItemIcons.registerIcon(CORE.RES_PATH_ITEM + this.mIconName + "_OVERLAY"); + } + + @Override + public ResourceLocation getTextureFile() { + return TextureMap.locationItemsTexture; + } + } + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/CustomOrePrefix.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/CustomOrePrefix.java index 9647b00578..c0c4e6a5c8 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/CustomOrePrefix.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/CustomOrePrefix.java @@ -6,107 +6,135 @@ import gregtech.api.enums.OrePrefixes; import net.minecraftforge.common.util.EnumHelper; public enum CustomOrePrefix { + milled( + "Milled Ores", + "Milled ", + " Ore", + true, + true, + false, + false, + false, + false, + false, + false, + false, + true, + B[3], + -1, + 64, + -1); - milled("Milled Ores", "Milled ", " Ore", true, true, false, false, false, false, false, false, false, true, B[3], -1, 64, -1); - - private final String mRegularLocalName; - private final String mLocalizedMaterialPre; - private final String mLocalizedMaterialPost; - private final boolean mIsUnificatable; - private final boolean mIsMaterialBased; - private final boolean mIsSelfReferencing; - private final boolean mIsContainer; - private final boolean mDontUnificateActively; - private final boolean mIsUsedForBlocks; - private final boolean mAllowNormalRecycling; - private final boolean mGenerateDefaultItem; - private final boolean mIsEnchantable; - private final boolean mIsUsedForOreProcessing; - private final int mMaterialGenerationBits; - private final long mMaterialAmount; - private final int mDefaultStackSize; - private final int mTextureindex; - - private OrePrefixes mSelfReference; - - private CustomOrePrefix( - String aRegularLocalName, - String aLocalizedMaterialPre, - String aLocalizedMaterialPost, - boolean aIsUnificatable, - boolean aIsMaterialBased, - boolean aIsSelfReferencing, - boolean aIsContainer, - boolean aDontUnificateActively, - boolean aIsUsedForBlocks, - boolean aAllowNormalRecycling, - boolean aGenerateDefaultItem, - boolean aIsEnchantable, - boolean aIsUsedForOreProcessing, - int aMaterialGenerationBits, - long aMaterialAmount, - int aDefaultStackSize, - int aTextureindex) { - - mRegularLocalName = aRegularLocalName; - mLocalizedMaterialPre = aLocalizedMaterialPre; - mLocalizedMaterialPost = aLocalizedMaterialPost; - mIsUnificatable = aIsUnificatable; - mIsMaterialBased = aIsMaterialBased; - mIsSelfReferencing = aIsSelfReferencing; - mIsContainer = aIsContainer; - mDontUnificateActively = aDontUnificateActively; - mIsUsedForBlocks = aIsUsedForBlocks; - mAllowNormalRecycling = aAllowNormalRecycling; - mGenerateDefaultItem = aGenerateDefaultItem; - mIsEnchantable = aIsEnchantable; - mIsUsedForOreProcessing = aIsUsedForOreProcessing; - mMaterialGenerationBits = aMaterialGenerationBits; - mMaterialAmount = aMaterialAmount; - mDefaultStackSize = aDefaultStackSize; - mTextureindex = aTextureindex; - - } - - public final boolean addToEnum() { - - mSelfReference = EnumHelper.addEnum(OrePrefixes.class, this.name(), - new Class[] { - String.class, - String.class, String.class, boolean.class, - boolean.class, boolean.class, boolean.class, - boolean.class, boolean.class, boolean.class, - boolean.class, boolean.class, boolean.class, - int.class, long.class, int.class, int.class - }, - new Object[] { - mRegularLocalName, - mLocalizedMaterialPre, - mLocalizedMaterialPost, - mIsUnificatable, - mIsMaterialBased, - mIsSelfReferencing, - mIsContainer, - mDontUnificateActively, - mIsUsedForBlocks, - mAllowNormalRecycling, - mGenerateDefaultItem, - mIsEnchantable, - mIsUsedForOreProcessing, - mMaterialGenerationBits, - mMaterialAmount, - mDefaultStackSize, - mTextureindex}); - - return mSelfReference != null; - } - - public static final boolean checkEntryWasAdded(CustomOrePrefix aCustomPrefixObject) { - return aCustomPrefixObject.mSelfReference != null; - } - - public OrePrefixes get() { - return mSelfReference; - } + private final String mRegularLocalName; + private final String mLocalizedMaterialPre; + private final String mLocalizedMaterialPost; + private final boolean mIsUnificatable; + private final boolean mIsMaterialBased; + private final boolean mIsSelfReferencing; + private final boolean mIsContainer; + private final boolean mDontUnificateActively; + private final boolean mIsUsedForBlocks; + private final boolean mAllowNormalRecycling; + private final boolean mGenerateDefaultItem; + private final boolean mIsEnchantable; + private final boolean mIsUsedForOreProcessing; + private final int mMaterialGenerationBits; + private final long mMaterialAmount; + private final int mDefaultStackSize; + private final int mTextureindex; + private OrePrefixes mSelfReference; + + private CustomOrePrefix( + String aRegularLocalName, + String aLocalizedMaterialPre, + String aLocalizedMaterialPost, + boolean aIsUnificatable, + boolean aIsMaterialBased, + boolean aIsSelfReferencing, + boolean aIsContainer, + boolean aDontUnificateActively, + boolean aIsUsedForBlocks, + boolean aAllowNormalRecycling, + boolean aGenerateDefaultItem, + boolean aIsEnchantable, + boolean aIsUsedForOreProcessing, + int aMaterialGenerationBits, + long aMaterialAmount, + int aDefaultStackSize, + int aTextureindex) { + + mRegularLocalName = aRegularLocalName; + mLocalizedMaterialPre = aLocalizedMaterialPre; + mLocalizedMaterialPost = aLocalizedMaterialPost; + mIsUnificatable = aIsUnificatable; + mIsMaterialBased = aIsMaterialBased; + mIsSelfReferencing = aIsSelfReferencing; + mIsContainer = aIsContainer; + mDontUnificateActively = aDontUnificateActively; + mIsUsedForBlocks = aIsUsedForBlocks; + mAllowNormalRecycling = aAllowNormalRecycling; + mGenerateDefaultItem = aGenerateDefaultItem; + mIsEnchantable = aIsEnchantable; + mIsUsedForOreProcessing = aIsUsedForOreProcessing; + mMaterialGenerationBits = aMaterialGenerationBits; + mMaterialAmount = aMaterialAmount; + mDefaultStackSize = aDefaultStackSize; + mTextureindex = aTextureindex; + } + + public final boolean addToEnum() { + + mSelfReference = EnumHelper.addEnum( + OrePrefixes.class, + this.name(), + new Class[] { + String.class, + String.class, + String.class, + boolean.class, + boolean.class, + boolean.class, + boolean.class, + boolean.class, + boolean.class, + boolean.class, + boolean.class, + boolean.class, + boolean.class, + int.class, + long.class, + int.class, + int.class + }, + new Object[] { + mRegularLocalName, + mLocalizedMaterialPre, + mLocalizedMaterialPost, + mIsUnificatable, + mIsMaterialBased, + mIsSelfReferencing, + mIsContainer, + mDontUnificateActively, + mIsUsedForBlocks, + mAllowNormalRecycling, + mGenerateDefaultItem, + mIsEnchantable, + mIsUsedForOreProcessing, + mMaterialGenerationBits, + mMaterialAmount, + mDefaultStackSize, + mTextureindex + }); + + return mSelfReference != null; + } + + public static final boolean checkEntryWasAdded(CustomOrePrefix aCustomPrefixObject) { + return aCustomPrefixObject.mSelfReference != null; + } + + public OrePrefixes get() { + return mSelfReference; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java index 32c3f9f271..cee5131f67 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java @@ -16,970 +16,1104 @@ import net.minecraft.item.ItemStack; */ public enum GregtechItemList implements GregtechItemContainer { - /** - * Items - */ - - // Advanced Hazmat Suit - Armour_Hazmat_Advanced_Helmet, - Armour_Hazmat_Advanced_Chest, - Armour_Hazmat_Advanced_Legs, - Armour_Hazmat_Advanced_Boots, - - //Gregtech Machine Parts - Electric_Motor_LuV, Electric_Motor_ZPM, Electric_Motor_UV, Electric_Motor_MAX, - Electric_Pump_LuV, Electric_Pump_ZPM, Electric_Pump_UV, Electric_Pump_MAX, - Conveyor_Module_LuV, Conveyor_Module_ZPM, Conveyor_Module_UV, Conveyor_Module_MAX, - Electric_Piston_LuV, Electric_Piston_ZPM, Electric_Piston_UV, Electric_Piston_MAX, - Robot_Arm_LuV, Robot_Arm_ZPM, Robot_Arm_UV, Robot_Arm_MAX, - Field_Generator_LuV, Field_Generator_ZPM, Field_Generator_UV, Field_Generator_MAX, - Emitter_LuV, Emitter_ZPM, Emitter_UV, Emitter_MAX, - Sensor_LuV, Sensor_ZPM, Sensor_UV, Sensor_MAX, - - //ULV Components - Electric_Motor_ULV, - Electric_Pump_ULV, - Conveyor_Module_ULV, - Electric_Piston_ULV, - Robot_Arm_ULV, - Field_Generator_ULV, - Emitter_ULV, - Sensor_ULV, - - // Mixed Components - TransmissionComponent_ULV, TransmissionComponent_LV, - TransmissionComponent_MV, TransmissionComponent_HV, - TransmissionComponent_EV, TransmissionComponent_IV, - TransmissionComponent_LuV, TransmissionComponent_ZPM, - TransmissionComponent_UV, TransmissionComponent_MAX, - - //Recipe Circuit - Circuit_BioRecipeSelector, - Circuit_T3RecipeSelector, - - //Circuits - Old_Circuit_Primitive, Old_Circuit_Basic, Old_Circuit_Good, - Old_Circuit_Advanced, Old_Circuit_Data, Old_Circuit_Elite, - Old_Circuit_Master, Old_Tool_DataOrb, Old_Circuit_Ultimate, Old_Tool_DataStick, - Circuit_IV, Circuit_LuV, Circuit_ZPM, - - //Circuit Parts - Circuit_Board_IV, Circuit_Board_LuV, Circuit_Board_ZPM, - Circuit_Parts_Crystal_Chip_IV, Circuit_Parts_Crystal_Chip_LuV, Circuit_Parts_Crystal_Chip_ZPM, - Circuit_Parts_IV, Circuit_Parts_LuV, Circuit_Parts_ZPM, - Circuit_Parts_Wiring_IV, Circuit_Parts_Wiring_LuV, Circuit_Parts_Wiring_ZPM, - - //Old Style Circuits - Old_Circuit_Board_Basic, Old_Circuit_Board_Advanced, Old_Circuit_Board_Elite, - Old_Circuit_Parts_Crystal_Chip_Elite, Old_Circuit_Parts_Crystal_Chip_Master, Old_Circuit_Parts_Advanced, - Old_Circuit_Parts_Wiring_Basic, Old_Circuit_Parts_Wiring_Advanced, Old_Circuit_Parts_Wiring_Elite, - Old_Empty_Board_Basic, Old_Empty_Board_Elite, - - //Batteries - Battery_RE_EV_Sodium, - Battery_RE_EV_Cadmium, - Battery_RE_EV_Lithium, - - //Shapes for Extruder - Shape_Extruder_WindmillShaft, - Shape_Extruder_SmallGear, - - //Cooked Raisin Toast for ImQ009 - Food_Baked_Raisin_Bread, - - - //Fluid Cells to regulate flows. - Fluid_Cell_1L, Fluid_Cell_16L, - Fluid_Cell_36L, Fluid_Cell_144L, - - //Debug - TESTITEM, - - // Larger Volumetric Flasks - VOLUMETRIC_FLASK_8k, - VOLUMETRIC_FLASK_32k, - - //RTG Fuels - Pellet_RTG_PU238, Pellet_RTG_SR90, - Pellet_RTG_PO210, Pellet_RTG_AM241, - - //Computer Cube - Gregtech_Computer_Cube, - Gregtech_Computer_Cube_Machine, - - //Casings for batteries - Battery_Casing_Gem_1, Battery_Casing_Gem_2, - Battery_Casing_Gem_3, Battery_Casing_Gem_4, - - //Custom Batteries - Battery_Gem_1, Battery_Gem_2, - Battery_Gem_3, Battery_Gem_4, - - //Compressed Fusion MK3 - Compressed_Fusion_Reactor, - - //Carbon Materials - NanoTube_Base_Substrate, - NanoTube_Finished, - Carbyne_Tube_Finished, - Carbyne_Sheet_Finished, - - //End Game Laser Engraver Lens - Laser_Lens_WoodsGlass, - Laser_Lens_Special, - - //Bombs - Bomb_Cast, Bomb_Cast_Molten, - Bomb_Cast_Set, Bomb_Cast_Broken, - Bomb_Cast_Mold, - - // Pellet Mold - Pellet_Mold, - - //Charged Items for Tree Farms - Farm_Processor_EV, - Farm_Processor_IV, - Farm_Processor_LuV, - Farm_Processor_ZPM, - Farm_Processor_UV, - - // Upgrade chip for Distillus - Distillus_Upgrade_Chip, - - - // Chips used to nerf my multis via custom behavioural attachments - Chip_MultiNerf_NoOutputBonus, - Chip_MultiNerf_NoSpeedBonus, - Chip_MultiNerf_NoEuBonus, - - // Milling Balls - Milling_Ball_Alumina, - Milling_Ball_Soapstone, - - - //---------------------------------------------------------------------------- - - - - /** - * MultiBlocks - */ - - - // Tier GT++ Casings - GTPP_Casing_ULV, GTPP_Casing_LV, - GTPP_Casing_MV, GTPP_Casing_HV, - GTPP_Casing_EV, GTPP_Casing_IV, - GTPP_Casing_LuV, GTPP_Casing_ZPM, - GTPP_Casing_UV, GTPP_Casing_MAX, - - //IronBlastFurnace Machine_Bronze_BlastFurnace - Machine_Iron_BlastFurnace, - Casing_IronPlatedBricks, - - //Large Centrifuge - Industrial_Centrifuge, - Casing_Centrifuge1, - - // Large Alloy Smelter - Industrial_AlloySmelter, - - //Coke Oven - Industrial_CokeOven, - Casing_CokeOven, - Casing_CokeOven_Coil1, - Casing_CokeOven_Coil2, - - //Bending Maching // Plate Press // Press - Industrial_PlatePress, - Casing_MaterialPress, - - //Matter Fab - Industrial_MassFab, - Casing_MatterGen, - Casing_MatterFab, - - //ABS - Industrial_AlloyBlastSmelter, - Casing_Coil_BlastSmelter, - Casing_BlastSmelter, - - //Industrial Electrolyzer - Industrial_Electrolyzer, - Casing_Electrolyzer, - - //Industrial Maceration Stack - Industrial_MacerationStack, - Casing_MacerationStack, - - //Industrial Wire Factory - Industrial_WireFactory, - Casing_WireFactory, - - //Power sub-station for mass storage. 3 hatches for input and output, whatever voltages you desire. - PowerSubStation, - Casing_Vanadium_Redox, - Casing_Vanadium_Redox_IV, - Casing_Vanadium_Redox_LuV, - Casing_Vanadium_Redox_ZPM, - Casing_Vanadium_Redox_UV, - Casing_Vanadium_Redox_MAX, - Casing_Power_SubStation, - - - //LFTR - ThoriumReactor, - Casing_Reactor_I, - Casing_Reactor_II, - - //Multitank - /*Industrial_MultiTank,*/ - Industrial_MultiTankDense, - Casing_MultitankExterior, - - - //Fission Fuel Refinery - Industrial_FuelRefinery, - Casing_Refinery_External, - Casing_Refinery_Structural, - Casing_Refinery_Internal, - - - //Industrial Sifter - Industrial_Sifter, - Casing_Sifter, - Casing_SifterGrate, - - - //Large Thermal Centrifuge - Industrial_ThermalCentrifuge, - Casing_ThermalCentrifuge, - - - //Cyclotron - COMET_Cyclotron, - Casing_Cyclotron_Coil, - Casing_Cyclotron_External, - - //Thermal Boiler - GT4_Thermal_Boiler, - Casing_ThermalContainment, - - - //Tree Farm - Industrial_TreeFarm, - TreeFarmer_Structural, - Casing_PLACEHOLDER_TreeFarmer, - - - //Fish Pond - Industrial_FishingPond, - Casing_FishPond, - - //Algae - AlgaeFarm_Controller, - - //Chemical Plant - ChemicalPlant_Controller, - - //GT4 autoCrafter - GT4_Multi_Crafter, - Casing_Autocrafter, - - - //industrial Ore-Washer - Industrial_WashPlant, - Casing_WashPlant, - - - //Generator Array - Generator_Array_Controller, - - - //Cutting Factory Controller - Industrial_CuttingFactoryController, - Casing_CuttingFactoryFrame, - - - //Tesla Tower - TelsaTower, - Casing_TeslaTower, - - - //Large Extruder - Industrial_Extruder, - Casing_Extruder, - - - //Multi-Machine - Industrial_MultiMachine, - Casing_Multi_Use, - - - //Bedrock Mining Platforms - /*BedrockMiner_MKI, */ - /*BedrockMiner_MKII, */ - /*BedrockMiner_MKIII, */ - Casing_BedrockMiner, - - - //Large Packager - Amazon_Warehouse_Controller, - Casing_AmazonWarehouse, - - - //Advanced GT vanilla Multis - Machine_Adv_BlastFurnace, - Casing_Adv_BlastFurnace, - Machine_Adv_ImplosionCompressor, - Machine_Adv_DistillationTower, - - //Advanced Assembly Line - Machine_Adv_AssemblyLine, - - //Advanced Vacuum Freezer - Industrial_Cryogenic_Freezer, - Casing_AdvancedVacuum, - - - //FusionTek MK IV - FusionComputer_UV2, - Casing_Fusion_External, - Casing_Fusion_Internal, - - - //large mixer - Industrial_Mixer, - - - //Naq Reactor - Casing_Naq_Reactor_A, - Casing_Naq_Reactor_B, - Casing_Naq_Reactor_C, - /*Controller_Naq_Reactor, */ - Casing_Containment, - - //Arc Furnace - Industrial_Arc_Furnace, - Casing_Industrial_Arc_Furnace, - - //Solar Tower - Industrial_Solar_Tower, - Casing_SolarTower_Structural, - Casing_SolarTower_SaltContainment, - Casing_SolarTower_HeatContainment, - - //Larger Turbines - Large_Steam_Turbine, Large_HPSteam_Turbine, - Large_Gas_Turbine, Large_Plasma_Turbine, - Casing_Turbine_Shaft, - Casing_Turbine_LP, Casing_Turbine_HP, - Casing_Turbine_Gas, Casing_Turbine_Plasma, - XL_HeatExchanger, Casing_XL_HeatExchanger, - - // Large Engine - Casing_Reinforced_Engine_Casing, - - //Large Vacuum Furnace - Casing_Vacuum_Furnace, - Controller_Vacuum_Furnace, - - // Large Rocket Engine - Casing_RocketEngine, - Controller_RocketEngine, - - // Large Semi-Fluid - Controller_LargeSemifluidGenerator, - - // IsaMill - Controller_IsaMill, - Casing_IsaMill_Casing, - Casing_IsaMill_Gearbox, - Casing_IsaMill_Pipe, - - // Flotation Cell - Controller_Flotation_Cell, - Casing_Flotation_Cell, - - // Sparge Tower - Controller_Sparge_Tower, - Casing_Sparge_Tower_Exterior, - Casing_Sparge_Tower_Interior, - - // Elemental Duplicator - Controller_ElementalDuplicator, - Casing_ElementalDuplicator, - - // Forge Hammer - Controller_IndustrialForgeHammer, - Casing_IndustrialForgeHammer, - - // Molecular Transformer - Controller_MolecularTransformer, - Casing_Molecular_Transformer_1, - Casing_Molecular_Transformer_2, - Casing_Molecular_Transformer_3, - - // Big Steam Macerator - Controller_SteamMaceratorMulti, - // Big Steam Compressor - Controller_SteamCompressorMulti, - - // Industrial Rock Breaker - Controller_IndustrialRockBreaker, - - // Industrial Chisel - Controller_IndustrialAutoChisel, - Casing_IndustrialAutoChisel, - - // Industrial Fluid Heater - Controller_IndustrialFluidHeater, - - // Custom Machine Casings - Casing_Machine_Custom_1, - Casing_Machine_Custom_2, - Casing_Machine_Custom_3, - Casing_Machine_Custom_4, - Casing_Machine_Custom_5, - Casing_Machine_Custom_6, - - - //---------------------------------------------------------------------------- - - /** - * Custom hatches/Busses - */ - - //Buffer Dynamos - Hatch_Buffer_Dynamo_ULV, Hatch_Buffer_Dynamo_LV, Hatch_Buffer_Dynamo_MV, Hatch_Buffer_Dynamo_HV, Hatch_Buffer_Dynamo_EV, - Hatch_Buffer_Dynamo_IV, Hatch_Buffer_Dynamo_LuV, Hatch_Buffer_Dynamo_ZPM, Hatch_Buffer_Dynamo_UV, Hatch_Buffer_Dynamo_MAX, - - //Air Intake hatch - Hatch_Air_Intake, - Hatch_Air_Intake_Extreme, - - //Reservoir Hatch - Hatch_Reservoir, - - //XL Turbine Rotor Hatch - Hatch_Turbine_Rotor, - - //Standard Turbine Rotor Hatch - Hatch_Input_TurbineHousing, - - //Control Core - Hatch_Control_Core, - - // Milling Ball Bus - Bus_Milling_Balls, - - // Catalyst Bus - Bus_Catalysts, - - //Custom Fluid Hatches - Hatch_Input_Cryotheum, - Hatch_Input_Pyrotheum, - Hatch_Input_Naquadah, - Hatch_Input_Steam, - - //Steam Multi Buses - Hatch_Input_Bus_Steam, - Hatch_Output_Bus_Steam, - - //Elemental Duplicator Data Orb Bus - Hatch_Input_Elemental_Duplicator, - - //RTG Hatch - Hatch_RTG_LV, - Hatch_RTG_MV, - Hatch_RTG_HV, - - //Battery hatches for PSS - Hatch_Input_Battery_MV, - Hatch_Input_Battery_EV, - Hatch_Output_Battery_MV, - Hatch_Output_Battery_EV, - - //Advanced Mufflers - Hatch_Muffler_Adv_LV, Hatch_Muffler_Adv_MV, Hatch_Muffler_Adv_HV, - Hatch_Muffler_Adv_EV, Hatch_Muffler_Adv_IV, Hatch_Muffler_Adv_LuV, - Hatch_Muffler_Adv_ZPM, Hatch_Muffler_Adv_UV, Hatch_Muffler_Adv_MAX, - - //Super Input Busses - Hatch_SuperBus_Input_ULV, Hatch_SuperBus_Input_LV, Hatch_SuperBus_Input_MV, - Hatch_SuperBus_Input_HV, Hatch_SuperBus_Input_EV, Hatch_SuperBus_Input_IV, - Hatch_SuperBus_Input_LuV, Hatch_SuperBus_Input_ZPM, Hatch_SuperBus_Input_UV, - Hatch_SuperBus_Input_MAX, - - //Super Output Busses - Hatch_SuperBus_Output_ULV, Hatch_SuperBus_Output_LV, Hatch_SuperBus_Output_MV, - Hatch_SuperBus_Output_HV, Hatch_SuperBus_Output_EV, Hatch_SuperBus_Output_IV, - Hatch_SuperBus_Output_LuV, Hatch_SuperBus_Output_ZPM, Hatch_SuperBus_Output_UV, - Hatch_SuperBus_Output_MAX, - - - //---------------------------------------------------------------------------- - - - /** - * Blocks - */ - - - ResonanceChamber_I, - ResonanceChamber_II, - ResonanceChamber_III, - ResonanceChamber_IV, - - Modulator_I, - Modulator_II, - Modulator_III, - Modulator_IV, - - //---------------------------------------------------------------------------- - - - /** - * Single Block Tile Entities - */ - - //ULV Generators - Generator_Diesel_ULV, Generator_Gas_Turbine_ULV, Generator_Steam_Turbine_ULV, - - //Crate Box - CrateStorage, - - //Auto TC Research Creator - Thaumcraft_Researcher, - - //Threaded Buffers - Automation_Threaded_SuperBuffer_ULV, Automation_Threaded_SuperBuffer_LV, Automation_Threaded_SuperBuffer_MV, Automation_Threaded_SuperBuffer_HV, Automation_Threaded_SuperBuffer_EV, - Automation_Threaded_SuperBuffer_IV, Automation_Threaded_SuperBuffer_LuV, Automation_Threaded_SuperBuffer_ZPM, Automation_Threaded_SuperBuffer_UV, Automation_Threaded_SuperBuffer_MAX, - - //infinite Items - Infinite_Item_Chest, - - //GT4 Redstone - GT4_Redstone_Lamp, - GT4_Redstone_Button_Panel, - GT4_Redstone_Scale, - GT4_Redstone_Display, - GT4_Redstone_Circuit, - - //Gt4 Workbenches - GT4_Workbench_Bronze, - GT4_Workbench_Advanced, - - //GT4 automation - GT4_Electric_Auto_Workbench_LV, - GT4_Electric_Auto_Workbench_MV, - GT4_Electric_Auto_Workbench_HV, - GT4_Electric_Auto_Workbench_EV, - GT4_Electric_Auto_Workbench_IV, - GT4_Electric_Auto_Workbench_LuV, - GT4_Electric_Auto_Workbench_ZPM, - GT4_Electric_Auto_Workbench_UV, - GT4_Electric_Inventory_Manager_LV, - GT4_Electric_Inventory_Manager_MV, - GT4_Electric_Inventory_Manager_HV, - GT4_Electric_Inventory_Manager_EV, - GT4_Electric_Inventory_Manager_IV, - GT4_Electric_Inventory_Manager_LuV, - GT4_Electric_Inventory_Manager_ZPM, - GT4_Electric_Inventory_Manager_UV, - - //GT4 Crop Harvester - GT4_Crop_Harvester_LV, - GT4_Crop_Harvester_MV, - GT4_Crop_Harvester_HV, - GT4_Crop_Harvester_EV, - GT4_Crop_Harvester_IV, - GT4_Crop_Harvester_LuV, - GT4_Crop_Harvester_ZPM, - GT4_Crop_Harvester_UV, - - - //Geothermal Engines - Geothermal_Engine_EV, - Geothermal_Engine_IV, - Geothermal_Engine_LuV, - - - //Tesseracts - GT4_Tesseract_Generator, - GT4_Tesseract_Terminal, - - - //Advanced Boilers - Boiler_Advanced_LV, - Boiler_Advanced_MV, - Boiler_Advanced_HV, - - - //Fancy Pollution Devices - Pollution_Detector, - Pollution_Cleaner_ULV, Pollution_Cleaner_LV, - Pollution_Cleaner_MV, Pollution_Cleaner_HV, - Pollution_Cleaner_EV, Pollution_Cleaner_IV, - Pollution_Cleaner_LuV, Pollution_Cleaner_ZPM, - Pollution_Cleaner_UV, Pollution_Cleaner_MAX, - - - //Debug machine - Pollution_Creator, - Garbage_Collector_Debug_Machine, - - - //Basically is an automatic Cauldron - SimpleDustWasher_ULV, - SimpleDustWasher_MV, - SimpleDustWasher_EV, - SimpleDustWasher_LuV, - SimpleDustWasher_UV, - - //Solar Tower Reflector - Solar_Tower_Reflector, - - //Super Tier Chests - Super_Chest_LV, Super_Chest_MV, Super_Chest_HV, Super_Chest_EV, Super_Chest_IV, - - //Chunkloader - GT_Chunkloader_HV, GT_Chunkloader_ZPM, GT_Chunkloader_IV, - - - //Wireless Chargers - Charger_LV, Charger_MV, Charger_HV, - Charger_EV, Charger_IV, Charger_LuV, - Charger_ZPM, Charger_UV, Charger_MAX, - - - //Tiny Fusion - /*Miniature_Fusion, */ - - - //Component Makers - Machine_LV_Component_Maker, - Machine_MV_Component_Maker, - Machine_HV_Component_Maker, - Machine_EV_Component_Maker, - Machine_IV_Component_Maker, - Machine_LuV_Component_Maker, - Machine_ZPM_Component_Maker, - Machine_UV_Component_Maker, - - // Reactor Processing Unit - ReactorProcessingUnit_IV, - ReactorProcessingUnit_ZPM, - - // Cold Trap - ColdTrap_IV, - ColdTrap_ZPM, - - //Breakers - BreakerBox_ULV, BreakerBox_LV, BreakerBox_MV, - BreakerBox_HV, BreakerBox_EV, BreakerBox_IV, - BreakerBox_LuV, BreakerBox_ZPM, BreakerBox_UV, - BreakerBox_MAX, - - - //Solar Generators - GT_Solar_ULV, GT_Solar_LV, GT_Solar_MV, - GT_Solar_HV, GT_Solar_EV, GT_Solar_IV, - GT_Solar_LuV, GT_Solar_ZPM, GT_Solar_UV, GT_Solar_MAX, - - - //512v Creative Buffer - Energy_Buffer_CREATIVE, - //Variable voltage RF convertor - Energy_Buffer_RF_Convertor, - //Energy Buffers - Energy_Buffer_1by1_ULV, Energy_Buffer_1by1_LV, - Energy_Buffer_1by1_MV, Energy_Buffer_1by1_HV, - Energy_Buffer_1by1_EV, Energy_Buffer_1by1_IV, - Energy_Buffer_1by1_LuV, Energy_Buffer_1by1_ZPM, - Energy_Buffer_1by1_UV, Energy_Buffer_1by1_MAX, - - - //Cobble Generators - Cobble_Generator_ULV, Cobble_Generator_LV, - Cobble_Generator_MV, Cobble_Generator_HV, - Cobble_Generator_EV, Cobble_Generator_IV, - Cobble_Generator_LuV, Cobble_Generator_ZPM, - Cobble_Generator_UV, Cobble_Generator_MAX, - - - //The max Steam condenser - Condensor_MAX, - - - //Player owned Safes - GT_Safe_ULV, GT_Safe_LV, - GT_Safe_MV, GT_Safe_HV, - GT_Safe_EV, GT_Safe_IV, - GT_Safe_LuV, GT_Safe_ZPM, - GT_Safe_UV, GT_Safe_MAX, - - - //Rocket Engines - Rocket_Engine_EV, - Rocket_Engine_IV, - Rocket_Engine_LuV, - - - //GT4 Shelves - GT4_Shelf, GT4_Shelf_Iron, - GT4_Shelf_FileCabinet, GT4_Shelf_Desk, - GT4_Shelf_Compartment, GT4_Shelf_Large, - - - //Hi Amp Transformers - Transformer_HA_LV_ULV, Transformer_HA_MV_LV, Transformer_HA_HV_MV, - Transformer_HA_EV_HV, Transformer_HA_IV_EV, Transformer_HA_LuV_IV, - Transformer_HA_ZPM_LuV, Transformer_HA_UV_ZPM, Transformer_HA_MAX_UV, - - - //Semi-Fluid generators - Generator_SemiFluid_LV, - Generator_SemiFluid_MV, - Generator_SemiFluid_HV, - - - //Advanced Mixer 4x4 - Machine_Advanced_LV_Mixer, Machine_Advanced_MV_Mixer, Machine_Advanced_HV_Mixer, - Machine_Advanced_EV_Mixer, Machine_Advanced_IV_Mixer, Machine_Advanced_LuV_Mixer, - Machine_Advanced_ZPM_Mixer, Machine_Advanced_UV_Mixer, - - - //Block that enables uplink to a superconductor network - SuperConductorInputNode, - - //Heat Pipes - HeatPipe_Tier_1, - HeatPipe_Tier_2, - HeatPipe_Tier_3, - - - //Chemical Dehydrators for nuclear fuels - GT_Dehydrator_MV, GT_Dehydrator_HV, - GT_Dehydrator_EV, GT_Dehydrator_IV, - GT_Dehydrator_LuV, GT_Dehydrator_ZPM, - - - //Fluid Storage Tanks - GT_FluidTank_ULV, GT_FluidTank_LV, - GT_FluidTank_MV, GT_FluidTank_HV, - GT_FluidTank_EV, GT_FluidTank_IV, - GT_FluidTank_LuV, GT_FluidTank_ZPM, - GT_FluidTank_UV, GT_FluidTank_MAX, - - //Tick Accelerators from GTNH - AcceleratorLV, AcceleratorMV, - AcceleratorHV, AcceleratorEV, - AcceleratorIV, AcceleratorLuV, - AcceleratorZPM, AcceleratorUV, - - //GT RTG - RTG, - - - // Chisel Machines - GT_Chisel_LV, - GT_Chisel_MV, - GT_Chisel_HV, - - //Plasma Tank - /*Plasma_Tank,*/ - - - //---------------------------------------------------------------------------- - - - /** - * Covers - */ - - //Fluid Void Covers - Cover_Overflow_ULV, Cover_Overflow_LV, Cover_Overflow_MV, Cover_Overflow_HV, Cover_Overflow_EV, Cover_Overflow_IV, - - //Item Void Covers - Cover_Overflow_Item_ULV, Cover_Overflow_Item_LV, Cover_Overflow_Item_MV, Cover_Overflow_Item_HV, Cover_Overflow_Item_EV, Cover_Overflow_Item_IV, - - //Fake Hull Covers - FakeMachineCasingPlate_ULV, FakeMachineCasingPlate_LV, - FakeMachineCasingPlate_MV, FakeMachineCasingPlate_HV, - FakeMachineCasingPlate_EV, FakeMachineCasingPlate_IV, - FakeMachineCasingPlate_LuV, FakeMachineCasingPlate_ZPM, - FakeMachineCasingPlate_UV, FakeMachineCasingPlate_MAX, - - - - - //---------------------------------------------------------------------------- - - ; - - public static final GregtechItemList[] - DYE_ONLY_ITEMS = { - Energy_Buffer_1by1_EV, Energy_Buffer_1by1_EV }; - private ItemStack mStack; - private boolean mHasNotBeenSet = true; - - - @Override - public GregtechItemList set(final Item aItem) { - this.mHasNotBeenSet = false; - if (aItem == null) { - return this; - } - final ItemStack aStack = new ItemStack(aItem, 1, 0); - this.mStack = GT_Utility.copyAmount(1, aStack); - return this; - } - - @Override - public GregtechItemList set(final ItemStack aStack) { - this.mHasNotBeenSet = false; - this.mStack = GT_Utility.copyAmount(1, aStack); - return this; - } - - @Override - public Item getItem() { - if (this.mHasNotBeenSet) { - throw new IllegalAccessError("The Enum '" + this.name() + "' has not been set to an Item at this time!"); - } - if (GT_Utility.isStackInvalid(this.mStack)) { - return null; - } - return this.mStack.getItem(); - } - - @Override - public Block getBlock() { - if (this.mHasNotBeenSet) { - throw new IllegalAccessError("The Enum '" + this.name() + "' has not been set to an Item at this time!"); - } - return getBlockFromStack(this.getItem()); - } - - @Override - public final boolean hasBeenSet() { - return !this.mHasNotBeenSet; - } - - @Override - public boolean isStackEqual(final Object aStack) { - return this.isStackEqual(aStack, false, false); - } - - @Override - public boolean isStackEqual(final Object aStack, final boolean aWildcard, final boolean aIgnoreNBT) { - if (GT_Utility.isStackInvalid(aStack)) { - return false; - } - return GT_Utility.areUnificationsEqual((ItemStack)aStack, aWildcard?this.getWildcard(1):this.get(1), aIgnoreNBT); - } - - public static Block getBlockFromStack(Object aStack) { - if (GT_Utility.isStackInvalid(aStack)) - return Blocks.air; - return Block.getBlockFromItem(((ItemStack) aStack).getItem()); - } - - @Override - public ItemStack get(final long aAmount, final Object... aReplacements) { - if (this.mHasNotBeenSet) { - throw new IllegalAccessError("The Enum '" + this.name() + "' has not been set to an Item at this time!"); - } - if (GT_Utility.isStackInvalid(this.mStack)) { - return GT_Utility.copyAmount(aAmount, aReplacements); - } - return GT_Utility.copyAmount(aAmount, GT_OreDictUnificator.get(this.mStack)); - } - - @Override - public ItemStack getWildcard(final long aAmount, final Object... aReplacements) { - if (this.mHasNotBeenSet) { - throw new IllegalAccessError("The Enum '" + this.name() + "' has not been set to an Item at this time!"); - } - if (GT_Utility.isStackInvalid(this.mStack)) { - return GT_Utility.copyAmount(aAmount, aReplacements); - } - return GT_Utility.copyAmountAndMetaData(aAmount, W, GT_OreDictUnificator.get(this.mStack)); - } - - @Override - public ItemStack getUndamaged(final long aAmount, final Object... aReplacements) { - if (this.mHasNotBeenSet) { - throw new IllegalAccessError("The Enum '" + this.name() + "' has not been set to an Item at this time!"); - } - if (GT_Utility.isStackInvalid(this.mStack)) { - return GT_Utility.copyAmount(aAmount, aReplacements); - } - return GT_Utility.copyAmountAndMetaData(aAmount, 0, GT_OreDictUnificator.get(this.mStack)); - } - - @Override - public ItemStack getAlmostBroken(final long aAmount, final Object... aReplacements) { - if (this.mHasNotBeenSet) { - throw new IllegalAccessError("The Enum '" + this.name() + "' has not been set to an Item at this time!"); - } - if (GT_Utility.isStackInvalid(this.mStack)) { - return GT_Utility.copyAmount(aAmount, aReplacements); - } - return GT_Utility.copyAmountAndMetaData(aAmount, this.mStack.getMaxDamage()-1, GT_OreDictUnificator.get(this.mStack)); - } - - @Override - public ItemStack getWithName(final long aAmount, final String aDisplayName, final Object... aReplacements) { - final ItemStack rStack = this.get(1, aReplacements); - if (GT_Utility.isStackInvalid(rStack)) { - return null; - } - rStack.setStackDisplayName(aDisplayName); - return GT_Utility.copyAmount(aAmount, rStack); - } - - @Override - public ItemStack getWithCharge(final long aAmount, final int aEnergy, final Object... aReplacements) { - final ItemStack rStack = this.get(1, aReplacements); - if (GT_Utility.isStackInvalid(rStack)) { - return null; - } - GT_ModHandler.chargeElectricItem(rStack, aEnergy, Integer.MAX_VALUE, true, false); - return GT_Utility.copyAmount(aAmount, rStack); - } - - @Override - public ItemStack getWithDamage(final long aAmount, final long aMetaValue, final Object... aReplacements) { - if (this.mHasNotBeenSet) { - throw new IllegalAccessError("The Enum '" + this.name() + "' has not been set to an Item at this time!"); - } - if (GT_Utility.isStackInvalid(this.mStack)) { - return GT_Utility.copyAmount(aAmount, aReplacements); - } - return GT_Utility.copyAmountAndMetaData(aAmount, aMetaValue, GT_OreDictUnificator.get(this.mStack)); - } - - @Override - public GregtechItemList registerOre(final Object... aOreNames) { - if (this.mHasNotBeenSet) { - throw new IllegalAccessError("The Enum '" + this.name() + "' has not been set to an Item at this time!"); - } - for (final Object tOreName : aOreNames) { - GT_OreDictUnificator.registerOre(tOreName, this.get(1)); - } - return this; - } - - @Override - public GregtechItemList registerWildcardAsOre(final Object... aOreNames) { - if (this.mHasNotBeenSet) { - throw new IllegalAccessError("The Enum '" + this.name() + "' has not been set to an Item at this time!"); - } - for (final Object tOreName : aOreNames) { - GT_OreDictUnificator.registerOre(tOreName, this.getWildcard(1)); - } - return this; - } -}
\ No newline at end of file + /** + * Items + */ + + // Advanced Hazmat Suit + Armour_Hazmat_Advanced_Helmet, + Armour_Hazmat_Advanced_Chest, + Armour_Hazmat_Advanced_Legs, + Armour_Hazmat_Advanced_Boots, + + // Gregtech Machine Parts + Electric_Motor_LuV, + Electric_Motor_ZPM, + Electric_Motor_UV, + Electric_Motor_MAX, + Electric_Pump_LuV, + Electric_Pump_ZPM, + Electric_Pump_UV, + Electric_Pump_MAX, + Conveyor_Module_LuV, + Conveyor_Module_ZPM, + Conveyor_Module_UV, + Conveyor_Module_MAX, + Electric_Piston_LuV, + Electric_Piston_ZPM, + Electric_Piston_UV, + Electric_Piston_MAX, + Robot_Arm_LuV, + Robot_Arm_ZPM, + Robot_Arm_UV, + Robot_Arm_MAX, + Field_Generator_LuV, + Field_Generator_ZPM, + Field_Generator_UV, + Field_Generator_MAX, + Emitter_LuV, + Emitter_ZPM, + Emitter_UV, + Emitter_MAX, + Sensor_LuV, + Sensor_ZPM, + Sensor_UV, + Sensor_MAX, + + // ULV Components + Electric_Motor_ULV, + Electric_Pump_ULV, + Conveyor_Module_ULV, + Electric_Piston_ULV, + Robot_Arm_ULV, + Field_Generator_ULV, + Emitter_ULV, + Sensor_ULV, + + // Mixed Components + TransmissionComponent_ULV, + TransmissionComponent_LV, + TransmissionComponent_MV, + TransmissionComponent_HV, + TransmissionComponent_EV, + TransmissionComponent_IV, + TransmissionComponent_LuV, + TransmissionComponent_ZPM, + TransmissionComponent_UV, + TransmissionComponent_MAX, + + // Recipe Circuit + Circuit_BioRecipeSelector, + Circuit_T3RecipeSelector, + + // Circuits + Old_Circuit_Primitive, + Old_Circuit_Basic, + Old_Circuit_Good, + Old_Circuit_Advanced, + Old_Circuit_Data, + Old_Circuit_Elite, + Old_Circuit_Master, + Old_Tool_DataOrb, + Old_Circuit_Ultimate, + Old_Tool_DataStick, + Circuit_IV, + Circuit_LuV, + Circuit_ZPM, + + // Circuit Parts + Circuit_Board_IV, + Circuit_Board_LuV, + Circuit_Board_ZPM, + Circuit_Parts_Crystal_Chip_IV, + Circuit_Parts_Crystal_Chip_LuV, + Circuit_Parts_Crystal_Chip_ZPM, + Circuit_Parts_IV, + Circuit_Parts_LuV, + Circuit_Parts_ZPM, + Circuit_Parts_Wiring_IV, + Circuit_Parts_Wiring_LuV, + Circuit_Parts_Wiring_ZPM, + + // Old Style Circuits + Old_Circuit_Board_Basic, + Old_Circuit_Board_Advanced, + Old_Circuit_Board_Elite, + Old_Circuit_Parts_Crystal_Chip_Elite, + Old_Circuit_Parts_Crystal_Chip_Master, + Old_Circuit_Parts_Advanced, + Old_Circuit_Parts_Wiring_Basic, + Old_Circuit_Parts_Wiring_Advanced, + Old_Circuit_Parts_Wiring_Elite, + Old_Empty_Board_Basic, + Old_Empty_Board_Elite, + + // Batteries + Battery_RE_EV_Sodium, + Battery_RE_EV_Cadmium, + Battery_RE_EV_Lithium, + + // Shapes for Extruder + Shape_Extruder_WindmillShaft, + Shape_Extruder_SmallGear, + + // Cooked Raisin Toast for ImQ009 + Food_Baked_Raisin_Bread, + + // Fluid Cells to regulate flows. + Fluid_Cell_1L, + Fluid_Cell_16L, + Fluid_Cell_36L, + Fluid_Cell_144L, + + // Debug + TESTITEM, + + // Larger Volumetric Flasks + VOLUMETRIC_FLASK_8k, + VOLUMETRIC_FLASK_32k, + + // RTG Fuels + Pellet_RTG_PU238, + Pellet_RTG_SR90, + Pellet_RTG_PO210, + Pellet_RTG_AM241, + + // Computer Cube + Gregtech_Computer_Cube, + Gregtech_Computer_Cube_Machine, + + // Casings for batteries + Battery_Casing_Gem_1, + Battery_Casing_Gem_2, + Battery_Casing_Gem_3, + Battery_Casing_Gem_4, + + // Custom Batteries + Battery_Gem_1, + Battery_Gem_2, + Battery_Gem_3, + Battery_Gem_4, + + // Compressed Fusion MK3 + Compressed_Fusion_Reactor, + + // Carbon Materials + NanoTube_Base_Substrate, + NanoTube_Finished, + Carbyne_Tube_Finished, + Carbyne_Sheet_Finished, + + // End Game Laser Engraver Lens + Laser_Lens_WoodsGlass, + Laser_Lens_Special, + + // Bombs + Bomb_Cast, + Bomb_Cast_Molten, + Bomb_Cast_Set, + Bomb_Cast_Broken, + Bomb_Cast_Mold, + + // Pellet Mold + Pellet_Mold, + + // Charged Items for Tree Farms + Farm_Processor_EV, + Farm_Processor_IV, + Farm_Processor_LuV, + Farm_Processor_ZPM, + Farm_Processor_UV, + + // Upgrade chip for Distillus + Distillus_Upgrade_Chip, + + // Chips used to nerf my multis via custom behavioural attachments + Chip_MultiNerf_NoOutputBonus, + Chip_MultiNerf_NoSpeedBonus, + Chip_MultiNerf_NoEuBonus, + + // Milling Balls + Milling_Ball_Alumina, + Milling_Ball_Soapstone, + + // ---------------------------------------------------------------------------- + + /** + * MultiBlocks + */ + + // Tier GT++ Casings + GTPP_Casing_ULV, + GTPP_Casing_LV, + GTPP_Casing_MV, + GTPP_Casing_HV, + GTPP_Casing_EV, + GTPP_Casing_IV, + GTPP_Casing_LuV, + GTPP_Casing_ZPM, + GTPP_Casing_UV, + GTPP_Casing_MAX, + + // IronBlastFurnace Machine_Bronze_BlastFurnace + Machine_Iron_BlastFurnace, + Casing_IronPlatedBricks, + + // Large Centrifuge + Industrial_Centrifuge, + Casing_Centrifuge1, + + // Large Alloy Smelter + Industrial_AlloySmelter, + + // Coke Oven + Industrial_CokeOven, + Casing_CokeOven, + Casing_CokeOven_Coil1, + Casing_CokeOven_Coil2, + + // Bending Maching // Plate Press // Press + Industrial_PlatePress, + Casing_MaterialPress, + + // Matter Fab + Industrial_MassFab, + Casing_MatterGen, + Casing_MatterFab, + + // ABS + Industrial_AlloyBlastSmelter, + Casing_Coil_BlastSmelter, + Casing_BlastSmelter, + + // Industrial Electrolyzer + Industrial_Electrolyzer, + Casing_Electrolyzer, + + // Industrial Maceration Stack + Industrial_MacerationStack, + Casing_MacerationStack, + + // Industrial Wire Factory + Industrial_WireFactory, + Casing_WireFactory, + + // Power sub-station for mass storage. 3 hatches for input and output, whatever voltages you desire. + PowerSubStation, + Casing_Vanadium_Redox, + Casing_Vanadium_Redox_IV, + Casing_Vanadium_Redox_LuV, + Casing_Vanadium_Redox_ZPM, + Casing_Vanadium_Redox_UV, + Casing_Vanadium_Redox_MAX, + Casing_Power_SubStation, + + // LFTR + ThoriumReactor, + Casing_Reactor_I, + Casing_Reactor_II, + + // Multitank + /*Industrial_MultiTank,*/ + Industrial_MultiTankDense, + Casing_MultitankExterior, + + // Fission Fuel Refinery + Industrial_FuelRefinery, + Casing_Refinery_External, + Casing_Refinery_Structural, + Casing_Refinery_Internal, + + // Industrial Sifter + Industrial_Sifter, + Casing_Sifter, + Casing_SifterGrate, + + // Large Thermal Centrifuge + Industrial_ThermalCentrifuge, + Casing_ThermalCentrifuge, + + // Cyclotron + COMET_Cyclotron, + Casing_Cyclotron_Coil, + Casing_Cyclotron_External, + + // Thermal Boiler + GT4_Thermal_Boiler, + Casing_ThermalContainment, + + // Tree Farm + Industrial_TreeFarm, + TreeFarmer_Structural, + Casing_PLACEHOLDER_TreeFarmer, + + // Fish Pond + Industrial_FishingPond, + Casing_FishPond, + + // Algae + AlgaeFarm_Controller, + + // Chemical Plant + ChemicalPlant_Controller, + + // GT4 autoCrafter + GT4_Multi_Crafter, + Casing_Autocrafter, + + // industrial Ore-Washer + Industrial_WashPlant, + Casing_WashPlant, + + // Generator Array + Generator_Array_Controller, + + // Cutting Factory Controller + Industrial_CuttingFactoryController, + Casing_CuttingFactoryFrame, + + // Tesla Tower + TelsaTower, + Casing_TeslaTower, + + // Large Extruder + Industrial_Extruder, + Casing_Extruder, + + // Multi-Machine + Industrial_MultiMachine, + Casing_Multi_Use, + + // Bedrock Mining Platforms + /*BedrockMiner_MKI, */ + /*BedrockMiner_MKII, */ + /*BedrockMiner_MKIII, */ + Casing_BedrockMiner, + + // Large Packager + Amazon_Warehouse_Controller, + Casing_AmazonWarehouse, + + // Advanced GT vanilla Multis + Machine_Adv_BlastFurnace, + Casing_Adv_BlastFurnace, + Machine_Adv_ImplosionCompressor, + Machine_Adv_DistillationTower, + + // Advanced Assembly Line + Machine_Adv_AssemblyLine, + + // Advanced Vacuum Freezer + Industrial_Cryogenic_Freezer, + Casing_AdvancedVacuum, + + // FusionTek MK IV + FusionComputer_UV2, + Casing_Fusion_External, + Casing_Fusion_Internal, + + // large mixer + Industrial_Mixer, + + // Naq Reactor + Casing_Naq_Reactor_A, + Casing_Naq_Reactor_B, + Casing_Naq_Reactor_C, + /*Controller_Naq_Reactor, */ + Casing_Containment, + + // Arc Furnace + Industrial_Arc_Furnace, + Casing_Industrial_Arc_Furnace, + + // Solar Tower + Industrial_Solar_Tower, + Casing_SolarTower_Structural, + Casing_SolarTower_SaltContainment, + Casing_SolarTower_HeatContainment, + + // Larger Turbines + Large_Steam_Turbine, + Large_HPSteam_Turbine, + Large_Gas_Turbine, + Large_Plasma_Turbine, + Casing_Turbine_Shaft, + Casing_Turbine_LP, + Casing_Turbine_HP, + Casing_Turbine_Gas, + Casing_Turbine_Plasma, + XL_HeatExchanger, + Casing_XL_HeatExchanger, + + // Large Engine + Casing_Reinforced_Engine_Casing, + + // Large Vacuum Furnace + Casing_Vacuum_Furnace, + Controller_Vacuum_Furnace, + + // Large Rocket Engine + Casing_RocketEngine, + Controller_RocketEngine, + + // Large Semi-Fluid + Controller_LargeSemifluidGenerator, + + // IsaMill + Controller_IsaMill, + Casing_IsaMill_Casing, + Casing_IsaMill_Gearbox, + Casing_IsaMill_Pipe, + + // Flotation Cell + Controller_Flotation_Cell, + Casing_Flotation_Cell, + + // Sparge Tower + Controller_Sparge_Tower, + Casing_Sparge_Tower_Exterior, + Casing_Sparge_Tower_Interior, + + // Elemental Duplicator + Controller_ElementalDuplicator, + Casing_ElementalDuplicator, + + // Forge Hammer + Controller_IndustrialForgeHammer, + Casing_IndustrialForgeHammer, + + // Molecular Transformer + Controller_MolecularTransformer, + Casing_Molecular_Transformer_1, + Casing_Molecular_Transformer_2, + Casing_Molecular_Transformer_3, + + // Big Steam Macerator + Controller_SteamMaceratorMulti, + // Big Steam Compressor + Controller_SteamCompressorMulti, + + // Industrial Rock Breaker + Controller_IndustrialRockBreaker, + + // Industrial Chisel + Controller_IndustrialAutoChisel, + Casing_IndustrialAutoChisel, + + // Industrial Fluid Heater + Controller_IndustrialFluidHeater, + + // Custom Machine Casings + Casing_Machine_Custom_1, + Casing_Machine_Custom_2, + Casing_Machine_Custom_3, + Casing_Machine_Custom_4, + Casing_Machine_Custom_5, + Casing_Machine_Custom_6, + + // ---------------------------------------------------------------------------- + + /** + * Custom hatches/Busses + */ + + // Buffer Dynamos + Hatch_Buffer_Dynamo_ULV, + Hatch_Buffer_Dynamo_LV, + Hatch_Buffer_Dynamo_MV, + Hatch_Buffer_Dynamo_HV, + Hatch_Buffer_Dynamo_EV, + Hatch_Buffer_Dynamo_IV, + Hatch_Buffer_Dynamo_LuV, + Hatch_Buffer_Dynamo_ZPM, + Hatch_Buffer_Dynamo_UV, + Hatch_Buffer_Dynamo_MAX, + + // Air Intake hatch + Hatch_Air_Intake, + Hatch_Air_Intake_Extreme, + + // Reservoir Hatch + Hatch_Reservoir, + + // XL Turbine Rotor Hatch + Hatch_Turbine_Rotor, + + // Standard Turbine Rotor Hatch + Hatch_Input_TurbineHousing, + + // Control Core + Hatch_Control_Core, + + // Milling Ball Bus + Bus_Milling_Balls, + + // Catalyst Bus + Bus_Catalysts, + + // Custom Fluid Hatches + Hatch_Input_Cryotheum, + Hatch_Input_Pyrotheum, + Hatch_Input_Naquadah, + Hatch_Input_Steam, + + // Steam Multi Buses + Hatch_Input_Bus_Steam, + Hatch_Output_Bus_Steam, + + // Elemental Duplicator Data Orb Bus + Hatch_Input_Elemental_Duplicator, + + // RTG Hatch + Hatch_RTG_LV, + Hatch_RTG_MV, + Hatch_RTG_HV, + + // Battery hatches for PSS + Hatch_Input_Battery_MV, + Hatch_Input_Battery_EV, + Hatch_Output_Battery_MV, + Hatch_Output_Battery_EV, + + // Advanced Mufflers + Hatch_Muffler_Adv_LV, + Hatch_Muffler_Adv_MV, + Hatch_Muffler_Adv_HV, + Hatch_Muffler_Adv_EV, + Hatch_Muffler_Adv_IV, + Hatch_Muffler_Adv_LuV, + Hatch_Muffler_Adv_ZPM, + Hatch_Muffler_Adv_UV, + Hatch_Muffler_Adv_MAX, + + // Super Input Busses + Hatch_SuperBus_Input_ULV, + Hatch_SuperBus_Input_LV, + Hatch_SuperBus_Input_MV, + Hatch_SuperBus_Input_HV, + Hatch_SuperBus_Input_EV, + Hatch_SuperBus_Input_IV, + Hatch_SuperBus_Input_LuV, + Hatch_SuperBus_Input_ZPM, + Hatch_SuperBus_Input_UV, + Hatch_SuperBus_Input_MAX, + + // Super Output Busses + Hatch_SuperBus_Output_ULV, + Hatch_SuperBus_Output_LV, + Hatch_SuperBus_Output_MV, + Hatch_SuperBus_Output_HV, + Hatch_SuperBus_Output_EV, + Hatch_SuperBus_Output_IV, + Hatch_SuperBus_Output_LuV, + Hatch_SuperBus_Output_ZPM, + Hatch_SuperBus_Output_UV, + Hatch_SuperBus_Output_MAX, + + // ---------------------------------------------------------------------------- + + /** + * Blocks + */ + ResonanceChamber_I, + ResonanceChamber_II, + ResonanceChamber_III, + ResonanceChamber_IV, + + Modulator_I, + Modulator_II, + Modulator_III, + Modulator_IV, + + // ---------------------------------------------------------------------------- + + /** + * Single Block Tile Entities + */ + + // ULV Generators + Generator_Diesel_ULV, + Generator_Gas_Turbine_ULV, + Generator_Steam_Turbine_ULV, + + // Crate Box + CrateStorage, + + // Auto TC Research Creator + Thaumcraft_Researcher, + + // Threaded Buffers + Automation_Threaded_SuperBuffer_ULV, + Automation_Threaded_SuperBuffer_LV, + Automation_Threaded_SuperBuffer_MV, + Automation_Threaded_SuperBuffer_HV, + Automation_Threaded_SuperBuffer_EV, + Automation_Threaded_SuperBuffer_IV, + Automation_Threaded_SuperBuffer_LuV, + Automation_Threaded_SuperBuffer_ZPM, + Automation_Threaded_SuperBuffer_UV, + Automation_Threaded_SuperBuffer_MAX, + + // infinite Items + Infinite_Item_Chest, + + // GT4 Redstone + GT4_Redstone_Lamp, + GT4_Redstone_Button_Panel, + GT4_Redstone_Scale, + GT4_Redstone_Display, + GT4_Redstone_Circuit, + + // Gt4 Workbenches + GT4_Workbench_Bronze, + GT4_Workbench_Advanced, + + // GT4 automation + GT4_Electric_Auto_Workbench_LV, + GT4_Electric_Auto_Workbench_MV, + GT4_Electric_Auto_Workbench_HV, + GT4_Electric_Auto_Workbench_EV, + GT4_Electric_Auto_Workbench_IV, + GT4_Electric_Auto_Workbench_LuV, + GT4_Electric_Auto_Workbench_ZPM, + GT4_Electric_Auto_Workbench_UV, + GT4_Electric_Inventory_Manager_LV, + GT4_Electric_Inventory_Manager_MV, + GT4_Electric_Inventory_Manager_HV, + GT4_Electric_Inventory_Manager_EV, + GT4_Electric_Inventory_Manager_IV, + GT4_Electric_Inventory_Manager_LuV, + GT4_Electric_Inventory_Manager_ZPM, + GT4_Electric_Inventory_Manager_UV, + + // GT4 Crop Harvester + GT4_Crop_Harvester_LV, + GT4_Crop_Harvester_MV, + GT4_Crop_Harvester_HV, + GT4_Crop_Harvester_EV, + GT4_Crop_Harvester_IV, + GT4_Crop_Harvester_LuV, + GT4_Crop_Harvester_ZPM, + GT4_Crop_Harvester_UV, + + // Geothermal Engines + Geothermal_Engine_EV, + Geothermal_Engine_IV, + Geothermal_Engine_LuV, + + // Tesseracts + GT4_Tesseract_Generator, + GT4_Tesseract_Terminal, + + // Advanced Boilers + Boiler_Advanced_LV, + Boiler_Advanced_MV, + Boiler_Advanced_HV, + + // Fancy Pollution Devices + Pollution_Detector, + Pollution_Cleaner_ULV, + Pollution_Cleaner_LV, + Pollution_Cleaner_MV, + Pollution_Cleaner_HV, + Pollution_Cleaner_EV, + Pollution_Cleaner_IV, + Pollution_Cleaner_LuV, + Pollution_Cleaner_ZPM, + Pollution_Cleaner_UV, + Pollution_Cleaner_MAX, + + // Debug machine + Pollution_Creator, + Garbage_Collector_Debug_Machine, + + // Basically is an automatic Cauldron + SimpleDustWasher_ULV, + SimpleDustWasher_MV, + SimpleDustWasher_EV, + SimpleDustWasher_LuV, + SimpleDustWasher_UV, + + // Solar Tower Reflector + Solar_Tower_Reflector, + + // Super Tier Chests + Super_Chest_LV, + Super_Chest_MV, + Super_Chest_HV, + Super_Chest_EV, + Super_Chest_IV, + + // Chunkloader + GT_Chunkloader_HV, + GT_Chunkloader_ZPM, + GT_Chunkloader_IV, + + // Wireless Chargers + Charger_LV, + Charger_MV, + Charger_HV, + Charger_EV, + Charger_IV, + Charger_LuV, + Charger_ZPM, + Charger_UV, + Charger_MAX, + + // Tiny Fusion + /*Miniature_Fusion, */ + + // Component Makers + Machine_LV_Component_Maker, + Machine_MV_Component_Maker, + Machine_HV_Component_Maker, + Machine_EV_Component_Maker, + Machine_IV_Component_Maker, + Machine_LuV_Component_Maker, + Machine_ZPM_Component_Maker, + Machine_UV_Component_Maker, + + // Reactor Processing Unit + ReactorProcessingUnit_IV, + ReactorProcessingUnit_ZPM, + + // Cold Trap + ColdTrap_IV, + ColdTrap_ZPM, + + // Breakers + BreakerBox_ULV, + BreakerBox_LV, + BreakerBox_MV, + BreakerBox_HV, + BreakerBox_EV, + BreakerBox_IV, + BreakerBox_LuV, + BreakerBox_ZPM, + BreakerBox_UV, + BreakerBox_MAX, + + // Solar Generators + GT_Solar_ULV, + GT_Solar_LV, + GT_Solar_MV, + GT_Solar_HV, + GT_Solar_EV, + GT_Solar_IV, + GT_Solar_LuV, + GT_Solar_ZPM, + GT_Solar_UV, + GT_Solar_MAX, + + // 512v Creative Buffer + Energy_Buffer_CREATIVE, + // Variable voltage RF convertor + Energy_Buffer_RF_Convertor, + // Energy Buffers + Energy_Buffer_1by1_ULV, + Energy_Buffer_1by1_LV, + Energy_Buffer_1by1_MV, + Energy_Buffer_1by1_HV, + Energy_Buffer_1by1_EV, + Energy_Buffer_1by1_IV, + Energy_Buffer_1by1_LuV, + Energy_Buffer_1by1_ZPM, + Energy_Buffer_1by1_UV, + Energy_Buffer_1by1_MAX, + + // Cobble Generators + Cobble_Generator_ULV, + Cobble_Generator_LV, + Cobble_Generator_MV, + Cobble_Generator_HV, + Cobble_Generator_EV, + Cobble_Generator_IV, + Cobble_Generator_LuV, + Cobble_Generator_ZPM, + Cobble_Generator_UV, + Cobble_Generator_MAX, + + // The max Steam condenser + Condensor_MAX, + + // Player owned Safes + GT_Safe_ULV, + GT_Safe_LV, + GT_Safe_MV, + GT_Safe_HV, + GT_Safe_EV, + GT_Safe_IV, + GT_Safe_LuV, + GT_Safe_ZPM, + GT_Safe_UV, + GT_Safe_MAX, + + // Rocket Engines + Rocket_Engine_EV, + Rocket_Engine_IV, + Rocket_Engine_LuV, + + // GT4 Shelves + GT4_Shelf, + GT4_Shelf_Iron, + GT4_Shelf_FileCabinet, + GT4_Shelf_Desk, + GT4_Shelf_Compartment, + GT4_Shelf_Large, + + // Hi Amp Transformers + Transformer_HA_LV_ULV, + Transformer_HA_MV_LV, + Transformer_HA_HV_MV, + Transformer_HA_EV_HV, + Transformer_HA_IV_EV, + Transformer_HA_LuV_IV, + Transformer_HA_ZPM_LuV, + Transformer_HA_UV_ZPM, + Transformer_HA_MAX_UV, + + // Semi-Fluid generators + Generator_SemiFluid_LV, + Generator_SemiFluid_MV, + Generator_SemiFluid_HV, + + // Advanced Mixer 4x4 + Machine_Advanced_LV_Mixer, + Machine_Advanced_MV_Mixer, + Machine_Advanced_HV_Mixer, + Machine_Advanced_EV_Mixer, + Machine_Advanced_IV_Mixer, + Machine_Advanced_LuV_Mixer, + Machine_Advanced_ZPM_Mixer, + Machine_Advanced_UV_Mixer, + + // Block that enables uplink to a superconductor network + SuperConductorInputNode, + + // Heat Pipes + HeatPipe_Tier_1, + HeatPipe_Tier_2, + HeatPipe_Tier_3, + + // Chemical Dehydrators for nuclear fuels + GT_Dehydrator_MV, + GT_Dehydrator_HV, + GT_Dehydrator_EV, + GT_Dehydrator_IV, + GT_Dehydrator_LuV, + GT_Dehydrator_ZPM, + + // Fluid Storage Tanks + GT_FluidTank_ULV, + GT_FluidTank_LV, + GT_FluidTank_MV, + GT_FluidTank_HV, + GT_FluidTank_EV, + GT_FluidTank_IV, + GT_FluidTank_LuV, + GT_FluidTank_ZPM, + GT_FluidTank_UV, + GT_FluidTank_MAX, + + // Tick Accelerators from GTNH + AcceleratorLV, + AcceleratorMV, + AcceleratorHV, + AcceleratorEV, + AcceleratorIV, + AcceleratorLuV, + AcceleratorZPM, + AcceleratorUV, + + // GT RTG + RTG, + + // Chisel Machines + GT_Chisel_LV, + GT_Chisel_MV, + GT_Chisel_HV, + + // Plasma Tank + /*Plasma_Tank,*/ + + // ---------------------------------------------------------------------------- + + /** + * Covers + */ + + // Fluid Void Covers + Cover_Overflow_ULV, + Cover_Overflow_LV, + Cover_Overflow_MV, + Cover_Overflow_HV, + Cover_Overflow_EV, + Cover_Overflow_IV, + + // Item Void Covers + Cover_Overflow_Item_ULV, + Cover_Overflow_Item_LV, + Cover_Overflow_Item_MV, + Cover_Overflow_Item_HV, + Cover_Overflow_Item_EV, + Cover_Overflow_Item_IV, + + // Fake Hull Covers + FakeMachineCasingPlate_ULV, + FakeMachineCasingPlate_LV, + FakeMachineCasingPlate_MV, + FakeMachineCasingPlate_HV, + FakeMachineCasingPlate_EV, + FakeMachineCasingPlate_IV, + FakeMachineCasingPlate_LuV, + FakeMachineCasingPlate_ZPM, + FakeMachineCasingPlate_UV, + FakeMachineCasingPlate_MAX, + +// ---------------------------------------------------------------------------- + +; + + public static final GregtechItemList[] DYE_ONLY_ITEMS = {Energy_Buffer_1by1_EV, Energy_Buffer_1by1_EV}; + private ItemStack mStack; + private boolean mHasNotBeenSet = true; + + @Override + public GregtechItemList set(final Item aItem) { + this.mHasNotBeenSet = false; + if (aItem == null) { + return this; + } + final ItemStack aStack = new ItemStack(aItem, 1, 0); + this.mStack = GT_Utility.copyAmount(1, aStack); + return this; + } + + @Override + public GregtechItemList set(final ItemStack aStack) { + this.mHasNotBeenSet = false; + this.mStack = GT_Utility.copyAmount(1, aStack); + return this; + } + + @Override + public Item getItem() { + if (this.mHasNotBeenSet) { + throw new IllegalAccessError("The Enum '" + this.name() + "' has not been set to an Item at this time!"); + } + if (GT_Utility.isStackInvalid(this.mStack)) { + return null; + } + return this.mStack.getItem(); + } + + @Override + public Block getBlock() { + if (this.mHasNotBeenSet) { + throw new IllegalAccessError("The Enum '" + this.name() + "' has not been set to an Item at this time!"); + } + return getBlockFromStack(this.getItem()); + } + + @Override + public final boolean hasBeenSet() { + return !this.mHasNotBeenSet; + } + + @Override + public boolean isStackEqual(final Object aStack) { + return this.isStackEqual(aStack, false, false); + } + + @Override + public boolean isStackEqual(final Object aStack, final boolean aWildcard, final boolean aIgnoreNBT) { + if (GT_Utility.isStackInvalid(aStack)) { + return false; + } + return GT_Utility.areUnificationsEqual( + (ItemStack) aStack, aWildcard ? this.getWildcard(1) : this.get(1), aIgnoreNBT); + } + + public static Block getBlockFromStack(Object aStack) { + if (GT_Utility.isStackInvalid(aStack)) return Blocks.air; + return Block.getBlockFromItem(((ItemStack) aStack).getItem()); + } + + @Override + public ItemStack get(final long aAmount, final Object... aReplacements) { + if (this.mHasNotBeenSet) { + throw new IllegalAccessError("The Enum '" + this.name() + "' has not been set to an Item at this time!"); + } + if (GT_Utility.isStackInvalid(this.mStack)) { + return GT_Utility.copyAmount(aAmount, aReplacements); + } + return GT_Utility.copyAmount(aAmount, GT_OreDictUnificator.get(this.mStack)); + } + + @Override + public ItemStack getWildcard(final long aAmount, final Object... aReplacements) { + if (this.mHasNotBeenSet) { + throw new IllegalAccessError("The Enum '" + this.name() + "' has not been set to an Item at this time!"); + } + if (GT_Utility.isStackInvalid(this.mStack)) { + return GT_Utility.copyAmount(aAmount, aReplacements); + } + return GT_Utility.copyAmountAndMetaData(aAmount, W, GT_OreDictUnificator.get(this.mStack)); + } + + @Override + public ItemStack getUndamaged(final long aAmount, final Object... aReplacements) { + if (this.mHasNotBeenSet) { + throw new IllegalAccessError("The Enum '" + this.name() + "' has not been set to an Item at this time!"); + } + if (GT_Utility.isStackInvalid(this.mStack)) { + return GT_Utility.copyAmount(aAmount, aReplacements); + } + return GT_Utility.copyAmountAndMetaData(aAmount, 0, GT_OreDictUnificator.get(this.mStack)); + } + + @Override + public ItemStack getAlmostBroken(final long aAmount, final Object... aReplacements) { + if (this.mHasNotBeenSet) { + throw new IllegalAccessError("The Enum '" + this.name() + "' has not been set to an Item at this time!"); + } + if (GT_Utility.isStackInvalid(this.mStack)) { + return GT_Utility.copyAmount(aAmount, aReplacements); + } + return GT_Utility.copyAmountAndMetaData( + aAmount, this.mStack.getMaxDamage() - 1, GT_OreDictUnificator.get(this.mStack)); + } + + @Override + public ItemStack getWithName(final long aAmount, final String aDisplayName, final Object... aReplacements) { + final ItemStack rStack = this.get(1, aReplacements); + if (GT_Utility.isStackInvalid(rStack)) { + return null; + } + rStack.setStackDisplayName(aDisplayName); + return GT_Utility.copyAmount(aAmount, rStack); + } + + @Override + public ItemStack getWithCharge(final long aAmount, final int aEnergy, final Object... aReplacements) { + final ItemStack rStack = this.get(1, aReplacements); + if (GT_Utility.isStackInvalid(rStack)) { + return null; + } + GT_ModHandler.chargeElectricItem(rStack, aEnergy, Integer.MAX_VALUE, true, false); + return GT_Utility.copyAmount(aAmount, rStack); + } + + @Override + public ItemStack getWithDamage(final long aAmount, final long aMetaValue, final Object... aReplacements) { + if (this.mHasNotBeenSet) { + throw new IllegalAccessError("The Enum '" + this.name() + "' has not been set to an Item at this time!"); + } + if (GT_Utility.isStackInvalid(this.mStack)) { + return GT_Utility.copyAmount(aAmount, aReplacements); + } + return GT_Utility.copyAmountAndMetaData(aAmount, aMetaValue, GT_OreDictUnificator.get(this.mStack)); + } + + @Override + public GregtechItemList registerOre(final Object... aOreNames) { + if (this.mHasNotBeenSet) { + throw new IllegalAccessError("The Enum '" + this.name() + "' has not been set to an Item at this time!"); + } + for (final Object tOreName : aOreNames) { + GT_OreDictUnificator.registerOre(tOreName, this.get(1)); + } + return this; + } + + @Override + public GregtechItemList registerWildcardAsOre(final Object... aOreNames) { + if (this.mHasNotBeenSet) { + throw new IllegalAccessError("The Enum '" + this.name() + "' has not been set to an Item at this time!"); + } + for (final Object tOreName : aOreNames) { + GT_OreDictUnificator.registerOre(tOreName, this.getWildcard(1)); + } + return this; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechOreDictNames.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechOreDictNames.java index 7ef6b5701e..b535236575 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechOreDictNames.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechOreDictNames.java @@ -24,16 +24,27 @@ Circuit Parts Circuit_Parts_Wiring_IV, Circuit_Parts_Wiring_LuV, Circuit_Parts_Wiring_ZPM; */ public enum GregtechOreDictNames { - buffer_core, itemGregConduit, Circuit_IV, Circuit_LuV, Circuit_ZPM, - Circuit_Board_IV, Circuit_Board_LuV, Circuit_Board_ZPM, - Circuit_Parts_Crystal_Chip_IV, Circuit_Parts_Crystal_Chip_LuV, Circuit_Parts_Crystal_Chip_ZPM, - Circuit_Parts_IV, Circuit_Parts_LuV, Circuit_Parts_ZPM, - Circuit_Parts_Wiring_IV, Circuit_Parts_Wiring_LuV, Circuit_Parts_Wiring_ZPM; - - public String unlocalisedName; + buffer_core, + itemGregConduit, + Circuit_IV, + Circuit_LuV, + Circuit_ZPM, + Circuit_Board_IV, + Circuit_Board_LuV, + Circuit_Board_ZPM, + Circuit_Parts_Crystal_Chip_IV, + Circuit_Parts_Crystal_Chip_LuV, + Circuit_Parts_Crystal_Chip_ZPM, + Circuit_Parts_IV, + Circuit_Parts_LuV, + Circuit_Parts_ZPM, + Circuit_Parts_Wiring_IV, + Circuit_Parts_Wiring_LuV, + Circuit_Parts_Wiring_ZPM; - private void ModObject() { - this.unlocalisedName = this.name(); - } + public String unlocalisedName; -}
\ No newline at end of file + private void ModObject() { + this.unlocalisedName = this.name(); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechOrePrefixes.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechOrePrefixes.java index b17b4a26ff..03d2741fe3 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechOrePrefixes.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechOrePrefixes.java @@ -3,8 +3,6 @@ package gtPlusPlus.xmod.gregtech.api.enums; import static gregtech.api.enums.GT_Values.*; import static gtPlusPlus.core.util.Utils.getTcAspectStack; -import java.util.*; - import gregtech.api.enums.*; import gregtech.api.enums.TC_Aspects.TC_AspectStack; import gregtech.api.interfaces.*; @@ -15,927 +13,2565 @@ import gtPlusPlus.core.lib.CORE; import gtPlusPlus.xmod.gregtech.api.interfaces.internal.Interface_OreRecipeRegistrator; import gtPlusPlus.xmod.gregtech.api.objects.GregtechItemData; import gtPlusPlus.xmod.gregtech.api.objects.GregtechMaterialStack; +import java.util.*; import net.minecraft.enchantment.Enchantment; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; public enum GregtechOrePrefixes { - /* Electric Components. - * - * usual Materials for this are: - * Primitive (Tier 1) - * Basic (Tier 2) as used by UE as well : IC2 Circuit and RE-Battery - * Good (Tier 3) - * Advanced (Tier 4) as used by UE as well : Advanced Circuit, Advanced Battery and Lithium Battery - * Data (Tier 5) : Data Storage Circuit - * Elite (Tier 6) as used by UE as well : Energy Crystal and Data Control Circuit - * Master (Tier 7) : Energy Flow Circuit and Lapotron Crystal - * Ultimate (Tier 8) : Data Orb and Lapotronic Energy Orb - * Infinite (Cheaty) - */ - ingotHot("Hot Ingots", "Hot ", " Ingot", true, true, false, false, false, false, false, true, false, false, B[1], M * 1, 16, 12), // A hot Ingot, which has to be cooled down by a Vacuum Freezer. - ingot("Ingots", "", " Ingot", true, true, false, false, false, false, false, true, false, false, B[1], M * 1, 64, 11), // A regular Ingot. Introduced by Eloraam - dustTiny("Tiny Dusts", "Tiny Pile of ", " Dust", true, true, false, false, false, false, false, true, false, false, B[0] | B[1] | B[2] | B[3], M / 9, 64, 0), // 1/9th of a Dust. - dustSmall("Small Dusts", "Small Pile of ", " Dust", true, true, false, false, false, false, false, true, false, false, B[0] | B[1] | B[2] | B[3], M / 4, 64, 1), // 1/4th of a Dust. - dustImpure("Impure Dusts", "Impure Pile of ", " Dust", true, true, false, false, false, false, false, true, false, true, B[3], M * 1, 64, 3), // Dust with impurities. 1 Unit of Main Material and 1/9 - 1/4 Unit of secondary Material - dustRefined("Refined Dusts", "Refined Pile of ", " Dust", true, true, false, false, false, false, false, true, false, true, B[3], M * 1, 64, 2), - dustPure("Purified Dusts", "Purified Pile of ", " Dust", true, true, false, false, false, false, false, true, false, true, B[3], M * 1, 64, 4), - dust("Dusts", "", " Dust", true, true, false, false, false, false, false, true, false, false, B[0] | B[1] | B[2] | B[3], M * 1, 64, 2), // Pure Dust worth of one Ingot or Gem. Introduced by Alblaka. - nugget("Nuggets", "", " Nugget", true, true, false, false, false, false, false, true, false, false, B[1], M / 9, 64, 9), // A Nugget. Introduced by Eloraam - plate("Plates", "", " Plate", true, true, false, false, false, false, true, true, false, false, B[1] | B[2], M * 1, 64, 17), // Regular Plate made of one Ingot/Dust. Introduced by Calclavia - block("Storage Blocks", "Block of ", "", true, true, false, false, false, true, true, false, false, false, 0, M * 9, 64, 71), // Storage Block consisting out of 9 Ingots/Gems/Dusts. Introduced by CovertJaguar - gem("Gemstones", "", "", true, true, true, false, false, false, true, true, false, false, B[2], M * 1, 64, 8), // A regular Gem worth one Dust. Introduced by Eloraam - gemChipped("Chipped Gemstones", "Chipped ", "", true, true, true, false, false, false, true, true, false, false, B[2], M / 4, 64, 59), // A regular Gem worth one small Dust. Introduced by TerraFirmaCraft - gemFlawed("Flawed Gemstones", "Flawed ", "", true, true, true, false, false, false, true, true, false, false, B[2], M / 2, 64, 60), // A regular Gem worth two small Dusts. Introduced by TerraFirmaCraft - gemFlawless("Flawless Gemstones", "Flawless ", "", true, true, true, false, false, false, true, true, false, false, B[2], M * 2, 32, 61), // A regular Gem worth two Dusts. Introduced by TerraFirmaCraft - gemExquisite("Exquisite Gemstones", "Exquisite ", "", true, true, true, false, false, false, true, true, false, false, B[2], M * 4, 16, 62), // A regular Gem worth four Dusts. Introduced by TerraFirmaCraft - stick("Sticks/Rods", "", " Rod", true, true, false, false, false, false, true, true, false, false, B[1] | B[2], M / 2, 64, 23), // Stick made of half an Ingot. Introduced by Eloraam - type2("16x Wires", "16x ", " Wire", true, true, false, false, false, false, true, false, false, false, 0, M * 8, 64, -1), - - toolSkookumChoocher("Skookum Choocher", "", " Skookum Choocher", true, true, false, false, false, false, true, true, false, false, B[6], M * 6, 16, 37), // consisting out of 6 Ingots. - toolAngleGrinder("Angle Grinder", "", "Angle Grinder", true, true, false, false, false, false, true, true, false, false, B[6], M * 6, 16, 37), // consisting out of 6 Ingots. - toolElectricSnips("Electric Snips", "", "Electric Snips", true, true, false, false, false, false, true, true, false, false, B[6], M * 6, 16, 37), // consisting out of 6 Ingots. - toolElectricLighter("Electric Lighter", "", "Electric Lighter", true, true, false, false, false, false, true, true, false, false, B[6], M * 6, 16, 37), // consisting out of 6 Ingots. - toolElectricButcherKnife("Electric Butcher Knife", "", "Electric Butcher Knife", true, true, false, false, false, false, true, true, false, false, B[6], M * 6, 16, 37), // consisting out of 6 Ingots. - - - - batterySingleuse("Single Use Batteries", "", "", false, true, false, false, false, false, false, false, false, false, 0, -1, 64, -1), - battery("Reusable Batteries", "", "", false, true, false, false, false, false, false, false, false, false, 0, -1, 64, -1), // Introduced by Calclavia - circuit("Circuits", "", "", true, true, false, false, false, false, false, false, false, false, 0, -1, 64, -1), // Introduced by Calclavia - chipset("Chipsets", "", "", true, true, false, false, false, false, false, false, false, false, 0, -1, 64, -1), // Introduced by Buildcraft - computer("Computers", "", "", true, true, false, false, true, false, false, false, false, false, 0, -1, 64, -1),; // A whole Computer. "computerMaster" = ComputerCube - - public static volatile int VERSION = 508; - - static { - - ingotHot.mHeatDamage = 3.0F; - - } - - public final ArrayList<ItemStack> mPrefixedItems = new ArrayList<>(); - public final short mTextureIndex; - public final String mRegularLocalName, mLocalizedMaterialPre, mLocalizedMaterialPost; - public final boolean mIsUsedForOreProcessing, mIsEnchantable, mIsUnificatable, mIsMaterialBased, mIsSelfReferencing, mIsContainer, mDontUnificateActively, mIsUsedForBlocks, mAllowNormalRecycling, mGenerateDefaultItem; - public final List<TC_AspectStack> mAspects = new ArrayList<>(); - public final Collection<GregtechOrePrefixes> mFamiliarPrefixes = new HashSet<>(); - /** - * Used to determine the amount of Material this Prefix contains. - * Multiply or Divide GregTech_API.MATERIAL_UNIT to get the Amounts in comparision to one Ingot. - * 0 = Null - * Negative = Undefined Amount - */ - public final long mMaterialAmount; - private final Collection<Materials> mNotGeneratedItems = new HashSet<>(), mIgnoredMaterials = new HashSet<>(), mGeneratedItems = new HashSet<>(); - private final ArrayList<Interface_OreRecipeRegistrator> mOreProcessing = new ArrayList<>(); - private final ArrayList<Interface_OreRecipeRegistrator> mOreProcessingFake = new ArrayList<>(); - public ItemStack mContainerItem = null; - public ICondition<ISubTagContainer> mCondition = null; - public byte mDefaultStackSize = 64; - public GregtechMaterialStack mSecondaryMaterial = null; - public GregtechOrePrefixes mPrefixInto = this; - public float mHeatDamage = 0.0F; // Negative for Frost Damage - /** - * Yes this Value can be changed to add Bits for the MetaGenerated-Item-Check. - */ - public int mMaterialGenerationBits = 0; - private GregtechOrePrefixes(final String aRegularLocalName, final String aLocalizedMaterialPre, final String aLocalizedMaterialPost, final boolean aIsUnificatable, final boolean aIsMaterialBased, final boolean aIsSelfReferencing, final boolean aIsContainer, final boolean aDontUnificateActively, final boolean aIsUsedForBlocks, final boolean aAllowNormalRecycling, final boolean aGenerateDefaultItem, final boolean aIsEnchantable, final boolean aIsUsedForOreProcessing, final int aMaterialGenerationBits, final long aMaterialAmount, final int aDefaultStackSize, final int aTextureindex) { - this.mIsUnificatable = aIsUnificatable; - this.mIsMaterialBased = aIsMaterialBased; - this.mIsSelfReferencing = aIsSelfReferencing; - this.mIsContainer = aIsContainer; - this.mDontUnificateActively = aDontUnificateActively; - this.mIsUsedForBlocks = aIsUsedForBlocks; - this.mAllowNormalRecycling = aAllowNormalRecycling; - this.mGenerateDefaultItem = aGenerateDefaultItem; - this.mIsEnchantable = aIsEnchantable; - this.mIsUsedForOreProcessing = aIsUsedForOreProcessing; - this.mMaterialGenerationBits = aMaterialGenerationBits; - this.mMaterialAmount = aMaterialAmount; - this.mRegularLocalName = aRegularLocalName; - this.mLocalizedMaterialPre = aLocalizedMaterialPre; - this.mLocalizedMaterialPost = aLocalizedMaterialPost; - this.mDefaultStackSize = (byte) aDefaultStackSize; - this.mTextureIndex = (short) aTextureindex; - - - //TODO - Utilise some form of way to check if it's gt 5.9 if so, use string switch. - if (this.name().startsWith("ore")) { - getTcAspectStack(TC_Aspects.TERRA.name(), 1).addToAspectList(this.mAspects); - } else if (this.name().startsWith("wire") || this.name().startsWith("cable")) { - getTcAspectStack(TC_Aspects.ELECTRUM.name(), 1).addToAspectList(this.mAspects); - } else if (this.name().startsWith("dust")) { - getTcAspectStack(TC_Aspects.PERDITIO.name(), 1).addToAspectList(this.mAspects); - } else if (this.name().startsWith("crushed")) { - getTcAspectStack(TC_Aspects.PERFODIO.name(), 1).addToAspectList(this.mAspects); - } else if (this.name().startsWith("ingot") || this.name().startsWith("nugget")) { - getTcAspectStack(TC_Aspects.METALLUM.name(), 1).addToAspectList(this.mAspects); - } else if (this.name().startsWith("armor")) { - getTcAspectStack(TC_Aspects.TUTAMEN.name(), 1).addToAspectList(this.mAspects); - } else if (this.name().startsWith("stone")) { - getTcAspectStack(TC_Aspects.TERRA.name(), 1).addToAspectList(this.mAspects); - } else if (this.name().startsWith("pipe")) { - getTcAspectStack(TC_Aspects.ITER.name(), 1).addToAspectList(this.mAspects); - } else if (this.name().startsWith("gear")) { - getTcAspectStack(TC_Aspects.MOTUS.name(), 1).addToAspectList(this.mAspects); - getTcAspectStack(TC_Aspects.MACHINA.name(), 1).addToAspectList(this.mAspects); - } else if (this.name().startsWith("frame") || this.name().startsWith("plate")) { - getTcAspectStack(TC_Aspects.FABRICO.name(), 1).addToAspectList(this.mAspects); - } else if (this.name().startsWith("tool")) { - getTcAspectStack(TC_Aspects.INSTRUMENTUM.name(), 2).addToAspectList(this.mAspects); - } else if (this.name().startsWith("gem") || this.name().startsWith("crystal") || this.name().startsWith("lens")) { - getTcAspectStack(TC_Aspects.VITREUS.name(), 1).addToAspectList(this.mAspects); - } else if (this.name().startsWith("crate")) { - getTcAspectStack(TC_Aspects.ITER.name(), 2).addToAspectList(this.mAspects); - } else if (this.name().startsWith("circuit")) { - getTcAspectStack("COGNITIO", 1); - } else if (this.name().startsWith("computer")) { - getTcAspectStack("COGNITIO", 4).addToAspectList(this.mAspects); - } else if (this.name().startsWith("battery")) { - getTcAspectStack(TC_Aspects.ELECTRUM.name(), 1).addToAspectList(this.mAspects); - } - } - - public static GregtechOrePrefixes getOrePrefix(final String aOre) { - for (final GregtechOrePrefixes tPrefix : values()) { - if (aOre.startsWith(tPrefix.toString())) { - return tPrefix; - } - } - return null; - } - - public static String stripPrefix(final String aOre) { - for (final GregtechOrePrefixes tPrefix : values()) { - if (aOre.startsWith(tPrefix.toString())) { - return aOre.replaceFirst(tPrefix.toString(), ""); - } - } - return aOre; - } - - public static String replacePrefix(final String aOre, final GregtechOrePrefixes aPrefix) { - for (final GregtechOrePrefixes tPrefix : values()) { - if (aOre.startsWith(tPrefix.toString())) { - return aOre.replaceFirst(tPrefix.toString(), aPrefix.toString()); - } - } - return ""; - } - - public static GregtechOrePrefixes getPrefix(final String aPrefixName) { - return getPrefix(aPrefixName, null); - } - - public static GregtechOrePrefixes getPrefix(final String aPrefixName, final GregtechOrePrefixes aReplacement) { - final Object tObject = GT_Utility.getFieldContent(GregtechOrePrefixes.class, aPrefixName, false, false); - if ((tObject != null) && (tObject instanceof GregtechOrePrefixes)) { - return (GregtechOrePrefixes) tObject; - } - return aReplacement; - } - - public static Materials getMaterial(final String aOre) { - return Materials.get(stripPrefix(aOre)); - } - - public static Materials getMaterial(final String aOre, final GregtechOrePrefixes aPrefix) { - return Materials.get(aOre.replaceFirst(aPrefix.toString(), "")); - } - - public static Materials getRealMaterial(final String aOre, final GregtechOrePrefixes aPrefix) { - return Materials.getRealMaterial(aOre.replaceFirst(aPrefix.toString(), "")); - } - - public static boolean isInstanceOf(final String aName, final GregtechOrePrefixes aPrefix) { - return aName == null ? false : aName.startsWith(aPrefix.toString()); - } - - public boolean add(final ItemStack aStack) { - if (aStack == null) { - return false; - } - if (!this.contains(aStack)) { - this.mPrefixedItems.add(aStack); - } - while (this.mPrefixedItems.contains(null)) { - this.mPrefixedItems.remove(null); - } - return true; - } - - - public boolean contains(final ItemStack aStack) { - if (aStack == null) { - return false; - } - for (final ItemStack tStack : this.mPrefixedItems) { - if (GT_Utility.areStacksEqual(aStack, tStack, !tStack.hasTagCompound())) { - return true; - } - } - return false; - } - - public boolean doGenerateItem(final Materials aMaterial) { - return (aMaterial != null) && (aMaterial != Materials._NULL) && (((aMaterial.mTypes & this.mMaterialGenerationBits) != 0) || this.mGeneratedItems.contains(aMaterial)) && !this.mNotGeneratedItems.contains(aMaterial) && ((this.mCondition == null) || this.mCondition.isTrue(aMaterial)); - } - - public boolean ignoreMaterials(final Materials... aMaterials) { - for (final Materials tMaterial : aMaterials) { - if (tMaterial != null) { - this.mIgnoredMaterials.add(tMaterial); - } - } - return true; - } - - public boolean addFamiliarPrefix(final GregtechOrePrefixes aPrefix) { - if ((aPrefix == null) || this.mFamiliarPrefixes.contains(aPrefix) || (aPrefix == this)) { - return false; - } - return this.mFamiliarPrefixes.add(aPrefix); - } - - public boolean add(final Interface_OreRecipeRegistrator aRegistrator) { - if (aRegistrator == null) { - return false; - } - return this.mOreProcessing.add(aRegistrator); - } - - public void processOre(final GT_Materials aMaterial, final String aOreDictName, final String aModName, final ItemStack aStack) { - if ((aMaterial != null) && ((aMaterial != GT_Materials._NULL) || this.mIsSelfReferencing || !this.mIsMaterialBased) && GT_Utility.isStackValid(aStack)) { - for (final Interface_OreRecipeRegistrator tRegistrator : this.mOreProcessing) { - if (D2) { - GT_Log.ore.println("Processing '" + aOreDictName + "' with the Prefix '" + this.name() + "' and the Material '" + aMaterial.name() + "' at " + GT_Utility.getClassName(tRegistrator)); - } - tRegistrator.registerOre(this, aMaterial, aOreDictName, aModName, GT_Utility.copyAmount(1, aStack)); - } - } - } - - //TODO - public void processOre(final Materials aMaterial, final String aOreDictName, final String aModName, final ItemStack aStack) { - if ((aMaterial != null) && ((aMaterial != Materials._NULL) || this.mIsSelfReferencing || !this.mIsMaterialBased) && GT_Utility.isStackValid(aStack)) { - for (final Interface_OreRecipeRegistrator tRegistrator : this.mOreProcessingFake) { - if (D2) { - GT_Log.ore.println("Processing '" + aOreDictName + "' with the Prefix '" + this.name() + "' and the Material '" + aMaterial.name() + "' at " + GT_Utility.getClassName(tRegistrator)); - } - tRegistrator.registerOre(this, aMaterial, aOreDictName, aModName, GT_Utility.copyAmount(1, aStack)); - } - } - } - - public Object get(final Object aMaterial) { - if (aMaterial instanceof GT_Materials) { - return new GregtechItemData(this, (GT_Materials) aMaterial); - } - return this.name() + aMaterial; - } - - public String getDefaultLocalNameForItem(final Materials aMaterial) { - - - // Use Standard Localization - return this.mLocalizedMaterialPre + aMaterial.mDefaultLocalName + this.mLocalizedMaterialPost; - } - - public enum GT_Materials implements IColorModulationContainer, ISubTagContainer { - - - - /** - * This is the Default Material returned in case no Material has been found or a NullPointer has been inserted at a location where it shouldn't happen. - * <p/> - * Mainly for preventing NullPointer Exceptions and providing Default Values. - * - * Unknown Material Components. Dead End Section. - * - * Alkalus Range 730-799 & 970-998 - * (aMetaItemSubID, TextureSet, aToolSpeed, aToolDurability, aToolQuality, aTypes, R, G, B, Alpha, aLocalName, - * aFuelType, aFuelPower, aMeltingPoint, aBlastFurnaceTemp, aBlastFurnaceRequired, aTransparent, aOreValue, aDensityMultiplier, aDensityDivider, aColor - * this(aMetaItemSubID, aIconSet, aToolSpeed, aToolDurability, aToolQuality, true); - * - */ - _NULL(-1, TextureSet.SET_NONE, 1.0F, 0, 0, 0, 255, 255, 255, 0, "NULL", 0, 0, 0, 0, false, false, 1, 1, 1, Dyes._NULL, Element._NULL, Arrays.asList(getTcAspectStack(TC_Aspects.VACUOS.name(), 1))), - - - //Lapis(526, TextureSet.SET_LAPIS, 1.0F, 0, 1, 1 | 4 | 8, 70, 70, 220, 0, "Lapis", 0, 0, -1, 0, false, false, 3, 1, 1, Dyes.dyeBlue, 2, Arrays.asList(new MaterialStack(Materials.Lazurite, 12), new MaterialStack(Materials.Sodalite, 2), new MaterialStack(Materials.Pyrite, 1), new MaterialStack(Materials.Calcite, 1)), Arrays.asList(getTcAspectStack(TC_Aspects.SENSUS, 1))), - Pyrotheum(20, TextureSet.SET_FLUID, 1.0F, 0, 1, 2 | 16 | 32, 255, 128, 0, 0, "Pyrotheum", 0, 0, -1, 0, false, false, 2, 3, 1, Dyes.dyeYellow, 2, Arrays.asList(new MaterialStack(Materials.Coal, 1), new MaterialStack(Materials.Redstone, 1), new MaterialStack(Materials.Blaze, 1), new MaterialStack(Materials.Sulfur, 1)), Arrays.asList(getTcAspectStack("PRAECANTATIO", 2), getTcAspectStack(TC_Aspects.IGNIS, 1))), - Cryotheum(21, TextureSet.SET_FLUID, 1.0F, 0, 1, 2 | 16 | 32, 102, 178, 255, 0, "Cryotheum", 0, 0, -1, 0, false, false, 2, 3, 1, Dyes.dyeLightBlue, 2, Arrays.asList(new MaterialStack(Materials.Blizz, 1), new MaterialStack(Materials.Redstone, 1), new MaterialStack(Materials.Snow, 1), new MaterialStack(Materials.Niter, 1)), Arrays.asList(getTcAspectStack("PRAECANTATIO", 2), getTcAspectStack(TC_Aspects.GELUM, 1))), - Ender(22, TextureSet.SET_FLUID, 1.0F, 0, 2, 1, 255, 255, 255, 0, "Ender", 0, 0, -1, 0, false, false, 3, 1, 1, Dyes.dyeGreen), - - /** - * Circuitry, Batteries and other Technical things - */ - Symbiotic(-1, TextureSet.SET_NONE, 1.0F, 0, 0, 0, 255, 255, 255, 0, "IV Tier", 0, 0, -1, 0, false, false, 1, 1, 1, Dyes.dyeLightGray, Arrays.asList(getTcAspectStack(TC_Aspects.ELECTRUM, 4), getTcAspectStack(TC_Aspects.MACHINA, 4))), - Neutronic(-1, TextureSet.SET_NONE, 1.0F, 0, 0, 0, 255, 255, 255, 0, "LuV Tier", 0, 0, -1, 0, false, false, 1, 1, 1, Dyes.dyeLightGray, Arrays.asList(getTcAspectStack(TC_Aspects.ELECTRUM, 6), getTcAspectStack(TC_Aspects.MACHINA, 6))), - Quantum(-1, TextureSet.SET_NONE, 1.0F, 0, 0, 0, 255, 255, 255, 0, "ZPM Tier", 0, 0, -1, 0, false, false, 1, 1, 1, Dyes.dyeLightGray, Arrays.asList(getTcAspectStack(TC_Aspects.ELECTRUM, 8), getTcAspectStack(TC_Aspects.MACHINA, 8))), - - Superconductor(-1, TextureSet.SET_NONE, 1.0F, 0, 0, 0, 190, 240, 190, 0, "Superconductor", 0, 0, -1, 0, false, false, 1, 1, 1, Dyes.dyeGreen, Arrays.asList(getTcAspectStack(TC_Aspects.ELECTRUM, 8))), - - Staballoy(30, TextureSet.SET_ROUGH, 10.0F, 5120, 4, 1 | 2 | 16 | 32 | 64 | 128, 68, 75, 66, 0, "Staballoy", 0, 0, 1500, 2800, true, false, 1, 3, 1, Dyes.dyeGreen, 2, Arrays.asList(new MaterialStack(Materials.Titanium, 1), new MaterialStack(Materials.Uranium, 9)), Arrays.asList(getTcAspectStack(TC_Aspects.METALLUM, 8), getTcAspectStack(TC_Aspects.STRONTIO, 3))), - Bedrockium(31, TextureSet.SET_FINE, 8.0F, 8196, 3, 1 | 2 | 16 | 32 | 64 | 128, 39, 39, 39, 0, "Bedrockium", 0, 0, -1, 0, false, false, 1, 5, 1, Dyes.dyeLightGray, 2, Arrays.asList(new MaterialStack(Materials.Carbon, 63), new MaterialStack(Materials.Carbon, 56)), Arrays.asList(getTcAspectStack(TC_Aspects.VACUOS, 8), getTcAspectStack(TC_Aspects.TUTAMEN, 3))), - BloodSteel(32, TextureSet.SET_METALLIC, 11.0F, 768, 4, 1 | 2 | 16 | 32 | 64 | 128, 142, 28, 0, 0, "Blood Steel", 0, 0, -1, 0, false, false, 1, 1, 1, Dyes.dyeRed, 2, Arrays.asList(new MaterialStack(Materials.Steel, 3)), Arrays.asList(getTcAspectStack(TC_Aspects.VICTUS, 8), getTcAspectStack(TC_Aspects.IGNIS, 3))), - Void(33, TextureSet.SET_METALLIC, 6.0F, 1280, 3, 1 | 2 | 16 | 32 | 64 | 128, 82, 17, 82, 0, "Void Metal", 0, 0, -1, 0, false, false, 3, 1, 1, Dyes.dyeBlack, Arrays.asList(getTcAspectStack("PRAECANTATIO", 5), getTcAspectStack(TC_Aspects.VACUOS, 7))), - ConductiveIron(34, TextureSet.SET_METALLIC, 5.0F, 256, 2, 1 | 2, 164, 109, 100, 0, "Conductive Iron", 0, 0, -1, 0, false, false, 3, 1, 1, Dyes.dyeRed, 2, Arrays.asList(new MaterialStack(Materials.Iron, 6), new MaterialStack(Materials.Redstone, 2)), Arrays.asList(getTcAspectStack(TC_Aspects.POTENTIA, 2), getTcAspectStack(TC_Aspects.METALLUM, 2))), - ElectricalSteel(35, TextureSet.SET_METALLIC, 7.0F, 768, 3, 1 | 2 | 64 | 128, 194, 194, 194, 0, "Electrical Steel", 0, 0, 1811, 1000, true, false, 3, 1, 1, Dyes.dyeLightGray, 2, Arrays.asList(new MaterialStack(Materials.Iron, 3), new MaterialStack(Materials.Coal, 2), new MaterialStack(Materials.Silicon, 2)), Arrays.asList(getTcAspectStack(TC_Aspects.MAGNETO, 2), getTcAspectStack(TC_Aspects.ELECTRUM, 5))), - EnergeticAlloy(36, TextureSet.SET_SHINY, 5.0F, 512, 3, 1 | 2 | 64 | 128, 252, 152, 45, 0, "Energetic Alloy", 0, 0, -1, 0, false, false, 3, 1, 1, Dyes.dyeOrange, 2, Arrays.asList(new MaterialStack(Materials.Gold, 3), new MaterialStack(Materials.Glowstone, 2), new MaterialStack(Materials.Redstone, 2)), Arrays.asList(getTcAspectStack(TC_Aspects.POTENTIA, 4), getTcAspectStack(TC_Aspects.LUX, 3))), - VibrantAlloy(37, TextureSet.SET_SHINY, 7.0F, 1280, 4, 1 | 2 | 64 | 128, 204, 242, 142, 0, "Vibrant Alloy", 0, 0, -1, 0, false, false, 3, 1, 1, Dyes.dyeLime, 2, Arrays.asList(new MaterialStack(Materials.EnergeticAlloy, 1), new MaterialStack(Materials.EnderPearl, 3)), Arrays.asList(getTcAspectStack(TC_Aspects.MACHINA, 5), getTcAspectStack(TC_Aspects.TELUM, 4))), - PulsatingIron(38, TextureSet.SET_SHINY, 5.0F, 256, 2, 1 | 2 | 64 | 128, 50, 91, 21, 0, "Pulsating Iron", 0, 0, -1, 0, false, false, 3, 1, 1, Dyes.dyeGreen, 2, Arrays.asList(new MaterialStack(Materials.Iron, 2), new MaterialStack(Materials.EnderPearl, 2)), Arrays.asList(getTcAspectStack(TC_Aspects.ALIENIS, 3), getTcAspectStack(TC_Aspects.METALLUM, 3))), - /* TODO*/ RedstoneAlloy(39, TextureSet.SET_METALLIC, 1.0F, 256, 2, 1|2|16|32|64, 178,34,34, 0, "Redstone Alloy", 0, 0, -1, 0, false, false, 3, 1, 1, Dyes.dyeRed, 2, Arrays.asList(new MaterialStack(Materials.Iron, 2), new MaterialStack(Materials.Redstone, 4))), - - //Needs more Use, I think. - Tantalloy60(40, TextureSet.SET_DULL, 8.0F, 5120, 3, 1 | 2 | 16 | 32 | 64 | 128, 68, 75, 166, 0, "Tantalloy-60", 0, 0, 3035, 2200, true, false, 1, 2, 1, Dyes.dyeLightBlue, 2, Arrays.asList(new MaterialStack(Materials.Tungsten, 1), new MaterialStack(Materials.Tantalum, 9)), Arrays.asList(getTcAspectStack(TC_Aspects.METALLUM, 8), getTcAspectStack(TC_Aspects.STRONTIO, 3))), - Tantalloy61(41, TextureSet.SET_DULL, 7.0F, 5120, 2, 1 | 2 | 16 | 32 | 64 | 128, 122, 135, 196, 0, "Tantalloy-61", 0, 0, 3015, 2150, true, false, 1, 2, 1, Dyes.dyeLightBlue, 2, Arrays.asList(new MaterialStack(Materials.Tungsten, 1), new MaterialStack(Materials.Tantalum, 9), new MaterialStack(Materials.Titanium, 1)), Arrays.asList(getTcAspectStack(TC_Aspects.METALLUM, 8), getTcAspectStack(TC_Aspects.STRONTIO, 3))), - - Potin(42, TextureSet.SET_METALLIC, 7.0F, 5120, 2, 1 | 2 | 16 | 32 | 64 | 128, 201,151,129, 0, "Potin", 0, 0, 3015, 2150, true, false, 1, 2, 1, Dyes.dyeLightBlue, 2, Arrays.asList(new MaterialStack(Materials.Tungsten, 1), new MaterialStack(Materials.Tantalum, 9), new MaterialStack(Materials.Titanium, 1)), Arrays.asList(getTcAspectStack(TC_Aspects.METALLUM, 8), getTcAspectStack(TC_Aspects.STRONTIO, 3))), - Inconel792(43, TextureSet.SET_METALLIC, 7.0F, 5120, 2, 1 | 2 | 16 | 32 | 64 | 128, 108, 240, 118, 0, "Inconel-792", 0, 0, 3015, 2150, true, false, 1, 2, 1, Dyes.dyeLightBlue, 2, Arrays.asList(new MaterialStack(Materials.Tungsten, 1), new MaterialStack(Materials.Tantalum, 9), new MaterialStack(Materials.Titanium, 1)), Arrays.asList(getTcAspectStack(TC_Aspects.METALLUM, 8), getTcAspectStack(TC_Aspects.STRONTIO, 3))), - Inconel690(44, TextureSet.SET_DULL, 7.0F, 5120, 2, 1 | 2 | 16 | 32 | 64 | 128, 118, 220, 138, 0, "Inconel-690", 0, 0, 3015, 2150, true, false, 1, 2, 1, Dyes.dyeLightBlue, 2, Arrays.asList(new MaterialStack(Materials.Tungsten, 1), new MaterialStack(Materials.Tantalum, 9), new MaterialStack(Materials.Titanium, 1)), Arrays.asList(getTcAspectStack(TC_Aspects.METALLUM, 8), getTcAspectStack(TC_Aspects.STRONTIO, 3))), - MaragingSteel300(45, TextureSet.SET_METALLIC, 7.0F, 5120, 2, 1 | 2 | 16 | 32 | 64 | 128, 150, 150, 150, 0, "Maraging Steel 300", 0, 0, 3015, 2150, true, false, 1, 2, 1, Dyes.dyeLightBlue, 2, Arrays.asList(new MaterialStack(Materials.Tungsten, 1), new MaterialStack(Materials.Tantalum, 9), new MaterialStack(Materials.Titanium, 1)), Arrays.asList(getTcAspectStack(TC_Aspects.METALLUM, 8), getTcAspectStack(TC_Aspects.STRONTIO, 3))), - MaragingSteel350(46, TextureSet.SET_METALLIC, 7.0F, 5120, 2, 1 | 2 | 16 | 32 | 64 | 128, 160, 160, 160, 0, "Maraging Steel 350", 0, 0, 3015, 2150, true, false, 1, 2, 1, Dyes.dyeLightBlue, 2, Arrays.asList(new MaterialStack(Materials.Tungsten, 1), new MaterialStack(Materials.Tantalum, 9), new MaterialStack(Materials.Titanium, 1)), Arrays.asList(getTcAspectStack(TC_Aspects.METALLUM, 8), getTcAspectStack(TC_Aspects.STRONTIO, 3))), - HastelloyX(47, TextureSet.SET_SHINY, 7.0F, 5120, 2, 1 | 2 | 16 | 32 | 64 | 128, 255, 193, 37, 0, "Hastelloy-X", 0, 0, 3015, 2150, true, false, 1, 2, 1, Dyes.dyeLightBlue, 2, Arrays.asList(new MaterialStack(Materials.Tungsten, 1), new MaterialStack(Materials.Tantalum, 9), new MaterialStack(Materials.Titanium, 1)), Arrays.asList(getTcAspectStack(TC_Aspects.METALLUM, 8), getTcAspectStack(TC_Aspects.STRONTIO, 3))), - - TriniumNaquadahCarbonite(48, TextureSet.SET_SHINY, 7.0F, 5120, 2, 1 | 2 | 16 | 32 | 64 | 128, 255, 233, 0, 0, "Trinium Naquadah Carbonite", 0, 0, 3015, 2150, true, false, 1, 2, 1, Dyes.dyeLightBlue, 2, Arrays.asList(new MaterialStack(Materials.Tungsten, 1), new MaterialStack(Materials.Tantalum, 9), new MaterialStack(Materials.Titanium, 1)), Arrays.asList(getTcAspectStack(TC_Aspects.METALLUM, 8), getTcAspectStack(TC_Aspects.STRONTIO, 3))), - - - //Radioactive Materials - HydrofluoricAcid(-1, TextureSet.SET_FLUID, 1.0F, 0, 1, 2 | 16 | 32, 200, 200, 200, 0, "Hydrofluoric Acid", 0, 0, -1, 0, false, false, 2, 3, 1, Dyes.dyeWhite, 2, Arrays.asList(new MaterialStack(Materials.Coal, 1), new MaterialStack(Materials.Redstone, 1), new MaterialStack(Materials.Blaze, 1), new MaterialStack(Materials.Sulfur, 1))), - UraniumHexaFluoride(-1, TextureSet.SET_FLUID, 1.0F, 0, 1, 2 | 16 | 32, 73, 220, 83, 0, "Uranium Hexafluoride", 0, 0, -1, 0, false, false, 2, 3, 1, Dyes.dyeLime, 2, Arrays.asList(new MaterialStack(Materials.Coal, 1), new MaterialStack(Materials.Redstone, 1), new MaterialStack(Materials.Blaze, 1), new MaterialStack(Materials.Sulfur, 1))), - UraniumTetraFluoride(-1, TextureSet.SET_FLUID, 1.0F, 0, 1, 2 | 16 | 32, 73, 220, 83, 0, "Uranium Tetrafluoride", 0, 0, -1, 0, false, false, 2, 3, 1, Dyes.dyeLime, 2, Arrays.asList(new MaterialStack(Materials.Coal, 1), new MaterialStack(Materials.Redstone, 1), new MaterialStack(Materials.Blaze, 1), new MaterialStack(Materials.Sulfur, 1))), - ThoriumTetraFluoride(-1, TextureSet.SET_FLUID, 1.0F, 0, 1, 2 | 16 | 32, 15, 120, 15, 0, "Thorium Tetrafluoride", 0, 0, -1, 0, false, false, 2, 3, 1, Dyes.dyeGreen, 2, Arrays.asList(new MaterialStack(Materials.Coal, 1), new MaterialStack(Materials.Redstone, 1), new MaterialStack(Materials.Blaze, 1), new MaterialStack(Materials.Sulfur, 1))), - - SulfurousAcid(-1, TextureSet.SET_FLUID, 1.0F, 0, 1, 2 | 16 | 32, 110, 220, 30, 0, "Sulfurous Acid", 0, 0, -1, 0, false, false, 2, 3, 1, Dyes.dyeWhite, 2, Arrays.asList(new MaterialStack(Materials.Coal, 1), new MaterialStack(Materials.Redstone, 1), new MaterialStack(Materials.Blaze, 1), new MaterialStack(Materials.Sulfur, 1))), - SulfurDioxide(-1, TextureSet.SET_FLUID, 1.0F, 0, 1, 2 | 16 | 32, 150, 200, 50, 0, "Sulfur Dioxide", 0, 0, -1, 0, false, false, 2, 3, 1, Dyes.dyeWhite, 2, Arrays.asList(new MaterialStack(Materials.Coal, 1), new MaterialStack(Materials.Redstone, 1), new MaterialStack(Materials.Blaze, 1), new MaterialStack(Materials.Sulfur, 1))), - HydrogenChloride(-1, TextureSet.SET_FLUID, 1.0F, 0, 1, 2 | 16 | 32, 150, 240, 90, 0, "Hydrogen Chloride", 0, 0, -1, 0, false, false, 2, 3, 1, Dyes.dyeWhite, 2, Arrays.asList(new MaterialStack(Materials.Coal, 1), new MaterialStack(Materials.Redstone, 1), new MaterialStack(Materials.Blaze, 1), new MaterialStack(Materials.Sulfur, 1))), - SulfuricApatite(-1, TextureSet.SET_FLUID, 1.0F, 0, 1, 2 | 16 | 32, 0, 105, 105, 0, "Sulfuric Apatite Solution", 0, 0, -1, 0, false, false, 2, 3, 1, Dyes.dyeWhite, 2, Arrays.asList(new MaterialStack(Materials.Coal, 1), new MaterialStack(Materials.Redstone, 1), new MaterialStack(Materials.Blaze, 1), new MaterialStack(Materials.Sulfur, 1))), - - SulfuricLithium(-1, TextureSet.SET_FLUID, 1.0F, 0, 1, 2 | 16 | 32, 0, 105, 105, 0, "Sulfuric Lithium Solution", 0, 0, -1, 0, false, false, 2, 3, 1, Dyes.dyeWhite, 2, Arrays.asList(new MaterialStack(Materials.Coal, 1), new MaterialStack(Materials.Redstone, 1), new MaterialStack(Materials.Blaze, 1), new MaterialStack(Materials.Sulfur, 1))), - LithiumHydroxide(-1, TextureSet.SET_FLUID, 1.0F, 0, 1, 2 | 16 | 32, 0, 105, 105, 0, "Lithium Hydroxide", 0, 0, -1, 0, false, false, 2, 3, 1, Dyes.dyeWhite, 2, Arrays.asList(new MaterialStack(Materials.Coal, 1), new MaterialStack(Materials.Redstone, 1), new MaterialStack(Materials.Blaze, 1), new MaterialStack(Materials.Sulfur, 1))), - - ; - - - - - /** - * List of all Materials. - */ - public static final Collection<GT_Materials> VALUES = new HashSet<>(Arrays.asList(values())); - - - static { - /*Primitive.add(SubTag.NO_SMASHING, SubTag.NO_SMELTING); - Basic.add(SubTag.NO_SMASHING, SubTag.NO_SMELTING); - Good.add(SubTag.NO_SMASHING, SubTag.NO_SMELTING); - Advanced.add(SubTag.NO_SMASHING, SubTag.NO_SMELTING); - Data.add(SubTag.NO_SMASHING, SubTag.NO_SMELTING); - Elite.add(SubTag.NO_SMASHING, SubTag.NO_SMELTING); - Master.add(SubTag.NO_SMASHING, SubTag.NO_SMELTING); - Ultimate.add(SubTag.NO_SMASHING, SubTag.NO_SMELTING); - Superconductor.add(SubTag.NO_SMASHING, SubTag.NO_SMELTING); - Infinite.add(SubTag.NO_SMASHING, SubTag.NO_SMELTING);*/ - Symbiotic.add(SubTag.NO_SMASHING, SubTag.NO_SMELTING); - Neutronic.add(SubTag.NO_SMASHING, SubTag.NO_SMELTING); - Quantum.add(SubTag.NO_SMASHING, SubTag.NO_SMELTING); - } - - - /** - * This Array can be changed dynamically by a Tick Handler in order to get a glowing Effect on all GT Meta Items out of this Material. - */ - public final short[] mRGBa = new short[]{255, 255, 255, 0}, mMoltenRGBa = new short[]{255, 255, 255, 0}; - public final TextureSet mIconSet; - public final int mMetaItemSubID; - public final boolean mUnificatable; - public final GT_Materials mMaterialInto; - public final List<MaterialStack> mMaterialList = new ArrayList<>(); - public final List<GT_Materials> mOreByProducts = new ArrayList<>(), mOreReRegistrations = new ArrayList<>(); - public final List<TC_AspectStack> mAspects = new ArrayList<>(); - private final ArrayList<ItemStack> mMaterialItems = new ArrayList<>(); - private final Collection<SubTag> mSubTags = new HashSet<>(); - public Enchantment mEnchantmentTools = null, mEnchantmentArmors = null; - public byte mEnchantmentToolsLevel = 0, mEnchantmentArmorsLevel = 0; - public boolean mBlastFurnaceRequired = false; - public float mToolSpeed = 1.0F, mHeatDamage = 0.0F; - public String mChemicalFormula = "?", mDefaultLocalName = "null"; - public Dyes mColor = Dyes._NULL; - public short mMeltingPoint = 0, mBlastFurnaceTemp = 0; - public int mTypes = 0, mDurability = 16, mFuelPower = 0, mFuelType = 0, mExtraData = 0, mOreValue = 0, mOreMultiplier = 1, mByProductMultiplier = 1, mSmeltingMultiplier = 1; - public long mDensity = M; - public Element mElement = null; - public GT_Materials mDirectSmelting = this, mOreReplacement = this, mMacerateInto = this, mSmeltInto = this, mArcSmeltInto = this, mHandleMaterial = this; - public byte mToolQuality = 0; - public Fluid mSolid = null, mFluid = null, mGas = null, mPlasma = null; - /** - * This Fluid is used as standard Unit for Molten Materials. 1296 is a Molten Block, what means 144 is one Material Unit worth - */ - public Fluid mStandardMoltenFluid = null; - - private GT_Materials(final int aMetaItemSubID, final TextureSet aIconSet, final float aToolSpeed, final int aToolDurability, final int aToolQuality, final boolean aUnificatable) { - this.mUnificatable = aUnificatable; - this.mMaterialInto = this; - this.mMetaItemSubID = aMetaItemSubID; - this.mToolQuality = (byte) aToolQuality; - this.mDurability = aToolDurability; - this.mToolSpeed = aToolSpeed; - this.mIconSet = aIconSet; - if (aMetaItemSubID >= 0) { - if (CORE.sMU_GeneratedMaterials[aMetaItemSubID] == null) { - CORE.sMU_GeneratedMaterials[aMetaItemSubID] = this; - } else { - throw new IllegalArgumentException("The Index " + aMetaItemSubID + " is already used!"); - } - } - } - - private GT_Materials(final GT_Materials aMaterialInto, final boolean aReRegisterIntoThis) { - this.mUnificatable = false; - this.mDefaultLocalName = aMaterialInto.mDefaultLocalName; - this.mMaterialInto = aMaterialInto.mMaterialInto; - if (aReRegisterIntoThis) { - this.mMaterialInto.mOreReRegistrations.add(this); - } - this.mChemicalFormula = aMaterialInto.mChemicalFormula; - this.mMetaItemSubID = -1; - this.mIconSet = TextureSet.SET_NONE; - } - - /** - * @param aMetaItemSubID the Sub-ID used in my own MetaItems. Range 0-1000. -1 for no Material - * @param aTypes which kind of Items should be generated. Bitmask as follows: - * 1 = Dusts of all kinds. - * 2 = Dusts, Ingots, Plates, Rods/Sticks, Machine Components and other Metal specific things. - * 4 = Dusts, Gems, Plates, Lenses (if transparent). - * 8 = Dusts, Impure Dusts, crushed Ores, purified Ores, centrifuged Ores etc. - * 16 = Cells - * 32 = Plasma Cells - * 64 = Tool Heads - * 128 = Gears - * @param aR, aG, aB Color of the Material 0-255 each. - * @param aA transparency of the Material Texture. 0 = fully visible, 255 = Invisible. - * @param aLocalName The Name used as Default for localization. - * @param aFuelType Type of Generator to get Energy from this Material. - * @param aFuelPower EU generated. Will be multiplied by 1000, also additionally multiplied by 2 for Gems. - * @param aAmplificationValue Amount of UUM amplifier gotten from this. - * @param aUUMEnergy Amount of EU needed to shape the UUM into this Material. - * @param aMeltingPoint Used to determine the smelting Costs in Furnii. - * @param aBlastFurnaceTemp Used to determine the needed Heat capactiy Costs in Blast Furnii. - * @param aBlastFurnaceRequired If this requires a Blast Furnace. - * @param aColor Vanilla MC Wool Color which comes the closest to this. - */ - private GT_Materials(final int aMetaItemSubID, final TextureSet aIconSet, final float aToolSpeed, final int aToolDurability, final int aToolQuality, final int aTypes, final int aR, final int aG, final int aB, final int aA, final String aLocalName, final int aFuelType, final int aFuelPower, final int aMeltingPoint, final int aBlastFurnaceTemp, final boolean aBlastFurnaceRequired, final boolean aTransparent, final int aOreValue, final int aDensityMultiplier, final int aDensityDivider, final Dyes aColor) { - this(aMetaItemSubID, aIconSet, aToolSpeed, aToolDurability, aToolQuality, true); - this.mDefaultLocalName = aLocalName; - this.mMeltingPoint = (short) aMeltingPoint; - this.mBlastFurnaceTemp = (short) aBlastFurnaceTemp; - this.mBlastFurnaceRequired = aBlastFurnaceRequired; - if (aTransparent) { - this.add(SubTag.TRANSPARENT); - } - this.mFuelPower = aFuelPower; - this.mFuelType = aFuelType; - this.mOreValue = aOreValue; - this.mDensity = (M * aDensityMultiplier) / aDensityDivider; - this.mColor = aColor == null ? Dyes._NULL : aColor; - if (this.mColor != null) { - this.add(SubTag.HAS_COLOR); - } - this.mRGBa[0] = this.mMoltenRGBa[0] = (short) aR; - this.mRGBa[1] = this.mMoltenRGBa[1] = (short) aG; - this.mRGBa[2] = this.mMoltenRGBa[2] = (short) aB; - this.mRGBa[3] = this.mMoltenRGBa[3] = (short) aA; - this.mTypes = aTypes; - if ((this.mTypes & 2) != 0) { - this.add(SubTag.SMELTING_TO_FLUID); - } - } - - private GT_Materials(final int aMetaItemSubID, final TextureSet aIconSet, final float aToolSpeed, final int aToolDurability, final int aToolQuality, final int aTypes, final int aR, final int aG, final int aB, final int aA, final String aLocalName, final int aFuelType, final int aFuelPower, final int aMeltingPoint, final int aBlastFurnaceTemp, final boolean aBlastFurnaceRequired, final boolean aTransparent, final int aOreValue, final int aDensityMultiplier, final int aDensityDivider, final Dyes aColor, final List<TC_AspectStack> aAspects) { - this(aMetaItemSubID, aIconSet, aToolSpeed, aToolDurability, aToolQuality, aTypes, aR, aG, aB, aA, aLocalName, aFuelType, aFuelPower, aMeltingPoint, aBlastFurnaceTemp, aBlastFurnaceRequired, aTransparent, aOreValue, aDensityMultiplier, aDensityDivider, aColor); - this.mAspects.addAll(aAspects); - } - - /** - * @param aElement The Element Enum represented by this Material - */ - private GT_Materials(final int aMetaItemSubID, final TextureSet aIconSet, final float aToolSpeed, final int aToolDurability, final int aToolQuality, final int aTypes, final int aR, final int aG, final int aB, final int aA, final String aLocalName, final int aFuelType, final int aFuelPower, final int aMeltingPoint, final int aBlastFurnaceTemp, final boolean aBlastFurnaceRequired, final boolean aTransparent, final int aOreValue, final int aDensityMultiplier, final int aDensityDivider, final Dyes aColor, final Element aElement, final List<TC_AspectStack> aAspects) { - this(aMetaItemSubID, aIconSet, aToolSpeed, aToolDurability, aToolQuality, aTypes, aR, aG, aB, aA, aLocalName, aFuelType, aFuelPower, aMeltingPoint, aBlastFurnaceTemp, aBlastFurnaceRequired, aTransparent, aOreValue, aDensityMultiplier, aDensityDivider, aColor); - this.mElement = aElement; - //mElement.mLinkedMaterials.add(this); - if (aElement == Element._NULL) { - this.mChemicalFormula = "Empty"; - } else { - this.mChemicalFormula = aElement.toString(); - this.mChemicalFormula = this.mChemicalFormula.replaceAll("_", "-"); - } - this.mAspects.addAll(aAspects); - } - - private GT_Materials(final int aMetaItemSubID, final TextureSet aIconSet, final float aToolSpeed, final int aToolDurability, final int aToolQuality, final int aTypes, final int aR, final int aG, final int aB, final int aA, final String aLocalName, final int aFuelType, final int aFuelPower, final int aMeltingPoint, final int aBlastFurnaceTemp, final boolean aBlastFurnaceRequired, final boolean aTransparent, final int aOreValue, final int aDensityMultiplier, final int aDensityDivider, final Dyes aColor, final int aExtraData, final List<MaterialStack> aMaterialList) { - this(aMetaItemSubID, aIconSet, aToolSpeed, aToolDurability, aToolQuality, aTypes, aR, aG, aB, aA, aLocalName, aFuelType, aFuelPower, aMeltingPoint, aBlastFurnaceTemp, aBlastFurnaceRequired, aTransparent, aOreValue, aDensityMultiplier, aDensityDivider, aColor, aExtraData, aMaterialList, null); - } - - private GT_Materials(final int aMetaItemSubID, final TextureSet aIconSet, final float aToolSpeed, final int aToolDurability, final int aToolQuality, final int aTypes, final int aR, final int aG, final int aB, final int aA, final String aLocalName, final int aFuelType, final int aFuelPower, final int aMeltingPoint, final int aBlastFurnaceTemp, final boolean aBlastFurnaceRequired, final boolean aTransparent, final int aOreValue, final int aDensityMultiplier, final int aDensityDivider, final Dyes aColor, final int aExtraData, final List<MaterialStack> aMaterialList, final List<TC_AspectStack> aAspects) { - this(aMetaItemSubID, aIconSet, aToolSpeed, aToolDurability, aToolQuality, aTypes, aR, aG, aB, aA, aLocalName, aFuelType, aFuelPower, aMeltingPoint, aBlastFurnaceTemp, aBlastFurnaceRequired, aTransparent, aOreValue, aDensityMultiplier, aDensityDivider, aColor); - this.mExtraData = aExtraData; - this.mMaterialList.addAll(aMaterialList); - this.mChemicalFormula = ""; - for (final MaterialStack tMaterial : this.mMaterialList) { - this.mChemicalFormula += tMaterial.toString(); - } - this.mChemicalFormula = this.mChemicalFormula.replaceAll("_", "-"); - - int tAmountOfComponents = 0, tMeltingPoint = 0; - for (final MaterialStack tMaterial : this.mMaterialList) { - tAmountOfComponents += tMaterial.mAmount; - if (tMaterial.mMaterial.mMeltingPoint > 0) { - tMeltingPoint += tMaterial.mMaterial.mMeltingPoint * tMaterial.mAmount; - } - if (aAspects == null) { - for (final TC_AspectStack tAspect : tMaterial.mMaterial.mAspects) { - tAspect.addToAspectList(this.mAspects); - } - } - } - - if (this.mMeltingPoint < 0) { - this.mMeltingPoint = (short) (tMeltingPoint / tAmountOfComponents); - } - - tAmountOfComponents *= aDensityMultiplier; - tAmountOfComponents /= aDensityDivider; - if (aAspects == null) { - for (final TC_AspectStack tAspect : this.mAspects) { - tAspect.mAmount = Math.max(1, tAspect.mAmount / Math.max(1, tAmountOfComponents)); - } - } else { - this.mAspects.addAll(aAspects); - } - } - - public static GT_Materials get(final String aMaterialName) { - final Object tObject = GT_Utility.getFieldContent(GT_Materials.class, aMaterialName, false, false); - if ((tObject != null) && (tObject instanceof GT_Materials)) { - return (GT_Materials) tObject; - } - return _NULL; - } - - public static GT_Materials getRealMaterial(final String aMaterialName) { - return get(aMaterialName).mMaterialInto; - } - - /** - * Called in preInit with the Config to set Values. - * - * @param aConfiguration - */ - public static void init(final GT_Config aConfiguration) { - for (final GT_Materials tMaterial : VALUES) { - final String tString = tMaterial.toString().toLowerCase(); - tMaterial.mHeatDamage = (float) aConfiguration.get(ConfigCategories.Materials.heatdamage, tString, tMaterial.mHeatDamage); - if (tMaterial.mBlastFurnaceRequired) { - tMaterial.mBlastFurnaceRequired = aConfiguration.get(ConfigCategories.Materials.blastfurnacerequirements, tString, true); - } - if (tMaterial.mBlastFurnaceRequired && aConfiguration.get(ConfigCategories.Materials.blastinductionsmelter, tString, tMaterial.mBlastFurnaceTemp < 1500)){} - //GT_ModHandler.ThermalExpansion.addSmelterBlastOre(tMaterial); - //tMaterial.mHandleMaterial = (tMaterial == Desh ? tMaterial.mHandleMaterial : tMaterial == Diamond || tMaterial == Thaumium ? Wood : tMaterial.contains(SubTag.BURNING) ? Blaze : tMaterial.contains(SubTag.MAGICAL) && tMaterial.contains(SubTag.CRYSTAL) && Loader.isModLoaded(MOD_ID_TC) ? Thaumium : tMaterial.getMass() > Element.Tc.getMass() * 2 ? TungstenSteel : tMaterial.getMass() > Element.Tc.getMass() ? Steel : Wood); - } - } - - public boolean isRadioactive() { - if (this.mElement != null) { - return this.mElement.mHalfLifeSeconds >= 0; - } - for (final MaterialStack tMaterial : this.mMaterialList) { - if (tMaterial.mMaterial.isRadioactive()) { - return true; - } - } - return false; - } - - public long getProtons() { - if (this.mElement != null) { - return this.mElement.getProtons(); - } - if (this.mMaterialList.size() <= 0) { - return Element.Tc.getProtons(); - } - long rAmount = 0, tAmount = 0; - for (final MaterialStack tMaterial : this.mMaterialList) { - tAmount += tMaterial.mAmount; - rAmount += tMaterial.mAmount * tMaterial.mMaterial.getProtons(); - } - return (this.getDensity() * rAmount) / (tAmount * M); - } - - public long getNeutrons() { - if (this.mElement != null) { - return this.mElement.getNeutrons(); - } - if (this.mMaterialList.size() <= 0) { - return Element.Tc.getNeutrons(); - } - long rAmount = 0, tAmount = 0; - for (final MaterialStack tMaterial : this.mMaterialList) { - tAmount += tMaterial.mAmount; - rAmount += tMaterial.mAmount * tMaterial.mMaterial.getNeutrons(); - } - return (this.getDensity() * rAmount) / (tAmount * M); - } - - public long getMass() { - if (this.mElement != null) { - return this.mElement.getMass(); - } - if (this.mMaterialList.size() <= 0) { - return Element.Tc.getMass(); - } - long rAmount = 0, tAmount = 0; - for (final MaterialStack tMaterial : this.mMaterialList) { - tAmount += tMaterial.mAmount; - rAmount += tMaterial.mAmount * tMaterial.mMaterial.getMass(); - } - return (this.getDensity() * rAmount) / (tAmount * M); - } - - public long getDensity() { - return this.mDensity; - } - - public String getToolTip() { - return this.getToolTip(1, false); - } - - public String getToolTip(final boolean aShowQuestionMarks) { - return this.getToolTip(1, aShowQuestionMarks); - } - - public String getToolTip(final long aMultiplier) { - return this.getToolTip(aMultiplier, false); - } - - public String getToolTip(final long aMultiplier, final boolean aShowQuestionMarks) { - if (!aShowQuestionMarks && this.mChemicalFormula.equals("?")) { - return ""; - } - if ((aMultiplier >= (M * 2)) && !this.mMaterialList.isEmpty()) { - return (((this.mElement != null) || ((this.mMaterialList.size() < 2) && (this.mMaterialList.get(0).mAmount == 1))) ? this.mChemicalFormula : "(" + this.mChemicalFormula + ")") + aMultiplier; - } - return this.mChemicalFormula; - } - - /** - * Adds an ItemStack to this Material. - */ - public GT_Materials add(final ItemStack aStack) { - if ((aStack != null) && !this.contains(aStack)) { - this.mMaterialItems.add(aStack); - } - return this; - } - - /** - * This is used to determine if any of the ItemStacks belongs to this Material. - */ - public boolean contains(final ItemStack... aStacks) { - if ((aStacks == null) || (aStacks.length <= 0)) { - return false; - } - for (final ItemStack tStack : this.mMaterialItems) { - for (final ItemStack aStack : aStacks) { - if (GT_Utility.areStacksEqual(aStack, tStack, !tStack.hasTagCompound())) { - return true; - } - } - } - return false; - } - - /** - * This is used to determine if an ItemStack belongs to this Material. - */ - public boolean remove(final ItemStack aStack) { - if (aStack == null) { - return false; - } - boolean temp = false; - for (int i = 0; i < this.mMaterialItems.size(); i++) { - if (GT_Utility.areStacksEqual(aStack, this.mMaterialItems.get(i))) { - this.mMaterialItems.remove(i--); - temp = true; - } - } - return temp; - } - - /** - * Adds a SubTag to this Material - */ - @Override - public ISubTagContainer add(final SubTag... aTags) { - if (aTags != null) { - for (final SubTag aTag : aTags) { - if ((aTag != null) && !this.contains(aTag)) { - aTag.addContainerToList(this); - this.mSubTags.add(aTag); - } - } - } - return this; - } - - /** - * If this Material has this exact SubTag - */ - @Override - public boolean contains(final SubTag aTag) { - return this.mSubTags.contains(aTag); - } - - /** - * Removes a SubTag from this Material - */ - @Override - public boolean remove(final SubTag aTag) { - return this.mSubTags.remove(aTag); - } - - /** - * Sets the Heat Damage for this Material (negative = frost) - */ - public GT_Materials setHeatDamage(final float aHeatDamage) { - this.mHeatDamage = aHeatDamage; - return this; - } - - /** - * Adds a Material to the List of Byproducts when grinding this Ore. - * Is used for more precise Ore grinding, so that it is possible to choose between certain kinds of Materials. - */ - public GT_Materials addOreByProduct(final GT_Materials aMaterial) { - if (!this.mOreByProducts.contains(aMaterial.mMaterialInto)) { - this.mOreByProducts.add(aMaterial.mMaterialInto); - } - return this; - } - - /** - * Adds multiple Materials to the List of Byproducts when grinding this Ore. - * Is used for more precise Ore grinding, so that it is possible to choose between certain kinds of Materials. - */ - public GT_Materials addOreByProducts(final GT_Materials... aMaterials) { - for (final GT_Materials tMaterial : aMaterials) { - if (tMaterial != null) { - this.addOreByProduct(tMaterial); - } - } - return this; - } - - /** - * If this Ore gives multiple drops of its Main Material. - * Lapis Ore for example gives about 6 drops. - */ - public GT_Materials setOreMultiplier(final int aOreMultiplier) { - if (aOreMultiplier > 0) { - this.mOreMultiplier = aOreMultiplier; - } - return this; - } - - /** - * If this Ore gives multiple drops of its Byproduct Material. - */ - public GT_Materials setByProductMultiplier(final int aByProductMultiplier) { - if (aByProductMultiplier > 0) { - this.mByProductMultiplier = aByProductMultiplier; - } - return this; - } - - /** - * If this Ore gives multiple drops of its Main Material. - * Lapis Ore for example gives about 6 drops. - */ - public GT_Materials setSmeltingMultiplier(final int aSmeltingMultiplier) { - if (aSmeltingMultiplier > 0) { - this.mSmeltingMultiplier = aSmeltingMultiplier; - } - return this; - } - - /** - * This Ore should be smolten directly into an Ingot of this Material instead of an Ingot of itself. - */ - public GT_Materials setDirectSmelting(final GT_Materials aMaterial) { - if (aMaterial != null) { - this.mDirectSmelting = aMaterial.mMaterialInto.mDirectSmelting; - } - return this; - } - - /** - * This Material should be the Main Material this Ore gets ground into. - * Example, Chromite giving Chrome or Tungstate giving Tungsten. - */ - public GT_Materials setOreReplacement(final GT_Materials aMaterial) { - if (aMaterial != null) { - this.mOreReplacement = aMaterial.mMaterialInto.mOreReplacement; - } - return this; - } - - /** - * This Material smelts always into an instance of aMaterial. Used for Magnets. - */ - public GT_Materials setSmeltingInto(final GT_Materials aMaterial) { - if (aMaterial != null) { - this.mSmeltInto = aMaterial.mMaterialInto.mSmeltInto; - } - return this; - } - - /** - * This Material arc smelts always into an instance of aMaterial. Used for Wrought Iron. - */ - public GT_Materials setArcSmeltingInto(final GT_Materials aMaterial) { - if (aMaterial != null) { - this.mArcSmeltInto = aMaterial.mMaterialInto.mArcSmeltInto; - } - return this; - } - - /** - * This Material macerates always into an instance of aMaterial. - */ - public GT_Materials setMaceratingInto(final GT_Materials aMaterial) { - if (aMaterial != null) { - this.mMacerateInto = aMaterial.mMaterialInto.mMacerateInto; - } - return this; - } - - public GT_Materials setEnchantmentForTools(final Enchantment aEnchantment, final int aEnchantmentLevel) { - this.mEnchantmentTools = aEnchantment; - this.mEnchantmentToolsLevel = (byte) aEnchantmentLevel; - return this; - } - - public GT_Materials setEnchantmentForArmors(final Enchantment aEnchantment, final int aEnchantmentLevel) { - this.mEnchantmentArmors = aEnchantment; - this.mEnchantmentArmorsLevel = (byte) aEnchantmentLevel; - return this; - } - - public FluidStack getSolid(final long aAmount) { - if (this.mSolid == null) { - return null; - } - return new GT_FluidStack(this.mSolid, (int) aAmount); - } - - public FluidStack getFluid(final long aAmount) { - if (this.mFluid == null) { - return null; - } - return new GT_FluidStack(this.mFluid, (int) aAmount); - } - - public FluidStack getGas(final long aAmount) { - if (this.mGas == null) { - return null; - } - return new GT_FluidStack(this.mGas, (int) aAmount); - } - - public FluidStack getPlasma(final long aAmount) { - if (this.mPlasma == null) { - return null; - } - return new GT_FluidStack(this.mPlasma, (int) aAmount); - } - - public FluidStack getMolten(final long aAmount) { - if (this.mStandardMoltenFluid == null) { - return null; - } - return new GT_FluidStack(this.mStandardMoltenFluid, (int) aAmount); - } - - @Override - public short[] getRGBA() { - return this.mRGBa; - } - - public static volatile int VERSION = 508; - - } - - -}
\ No newline at end of file + /* Electric Components. + * + * usual Materials for this are: + * Primitive (Tier 1) + * Basic (Tier 2) as used by UE as well : IC2 Circuit and RE-Battery + * Good (Tier 3) + * Advanced (Tier 4) as used by UE as well : Advanced Circuit, Advanced Battery and Lithium Battery + * Data (Tier 5) : Data Storage Circuit + * Elite (Tier 6) as used by UE as well : Energy Crystal and Data Control Circuit + * Master (Tier 7) : Energy Flow Circuit and Lapotron Crystal + * Ultimate (Tier 8) : Data Orb and Lapotronic Energy Orb + * Infinite (Cheaty) + */ + ingotHot( + "Hot Ingots", + "Hot ", + " Ingot", + true, + true, + false, + false, + false, + false, + false, + true, + false, + false, + B[1], + M * 1, + 16, + 12), // A hot Ingot, which has to be cooled down by a Vacuum Freezer. + ingot( + "Ingots", "", " Ingot", true, true, false, false, false, false, false, true, false, false, B[1], M * 1, 64, + 11), // A regular Ingot. Introduced by Eloraam + dustTiny( + "Tiny Dusts", + "Tiny Pile of ", + " Dust", + true, + true, + false, + false, + false, + false, + false, + true, + false, + false, + B[0] | B[1] | B[2] | B[3], + M / 9, + 64, + 0), // 1/9th of a Dust. + dustSmall( + "Small Dusts", + "Small Pile of ", + " Dust", + true, + true, + false, + false, + false, + false, + false, + true, + false, + false, + B[0] | B[1] | B[2] | B[3], + M / 4, + 64, + 1), // 1/4th of a Dust. + dustImpure( + "Impure Dusts", + "Impure Pile of ", + " Dust", + true, + true, + false, + false, + false, + false, + false, + true, + false, + true, + B[3], + M * 1, + 64, + 3), // Dust with impurities. 1 Unit of Main Material and 1/9 - 1/4 Unit of secondary Material + dustRefined( + "Refined Dusts", + "Refined Pile of ", + " Dust", + true, + true, + false, + false, + false, + false, + false, + true, + false, + true, + B[3], + M * 1, + 64, + 2), + dustPure( + "Purified Dusts", + "Purified Pile of ", + " Dust", + true, + true, + false, + false, + false, + false, + false, + true, + false, + true, + B[3], + M * 1, + 64, + 4), + dust( + "Dusts", + "", + " Dust", + true, + true, + false, + false, + false, + false, + false, + true, + false, + false, + B[0] | B[1] | B[2] | B[3], + M * 1, + 64, + 2), // Pure Dust worth of one Ingot or Gem. Introduced by Alblaka. + nugget( + "Nuggets", "", " Nugget", true, true, false, false, false, false, false, true, false, false, B[1], M / 9, + 64, 9), // A Nugget. Introduced by Eloraam + plate( + "Plates", + "", + " Plate", + true, + true, + false, + false, + false, + false, + true, + true, + false, + false, + B[1] | B[2], + M * 1, + 64, + 17), // Regular Plate made of one Ingot/Dust. Introduced by Calclavia + block( + "Storage Blocks", + "Block of ", + "", + true, + true, + false, + false, + false, + true, + true, + false, + false, + false, + 0, + M * 9, + 64, + 71), // Storage Block consisting out of 9 Ingots/Gems/Dusts. Introduced by CovertJaguar + gem( + "Gemstones", + "", + "", + true, + true, + true, + false, + false, + false, + true, + true, + false, + false, + B[2], + M * 1, + 64, + 8), // A regular Gem worth one Dust. Introduced by Eloraam + gemChipped( + "Chipped Gemstones", + "Chipped ", + "", + true, + true, + true, + false, + false, + false, + true, + true, + false, + false, + B[2], + M / 4, + 64, + 59), // A regular Gem worth one small Dust. Introduced by TerraFirmaCraft + gemFlawed( + "Flawed Gemstones", + "Flawed ", + "", + true, + true, + true, + false, + false, + false, + true, + true, + false, + false, + B[2], + M / 2, + 64, + 60), // A regular Gem worth two small Dusts. Introduced by TerraFirmaCraft + gemFlawless( + "Flawless Gemstones", + "Flawless ", + "", + true, + true, + true, + false, + false, + false, + true, + true, + false, + false, + B[2], + M * 2, + 32, + 61), // A regular Gem worth two Dusts. Introduced by TerraFirmaCraft + gemExquisite( + "Exquisite Gemstones", + "Exquisite ", + "", + true, + true, + true, + false, + false, + false, + true, + true, + false, + false, + B[2], + M * 4, + 16, + 62), // A regular Gem worth four Dusts. Introduced by TerraFirmaCraft + stick( + "Sticks/Rods", + "", + " Rod", + true, + true, + false, + false, + false, + false, + true, + true, + false, + false, + B[1] | B[2], + M / 2, + 64, + 23), // Stick made of half an Ingot. Introduced by Eloraam + type2( + "16x Wires", + "16x ", + " Wire", + true, + true, + false, + false, + false, + false, + true, + false, + false, + false, + 0, + M * 8, + 64, + -1), + + toolSkookumChoocher( + "Skookum Choocher", + "", + " Skookum Choocher", + true, + true, + false, + false, + false, + false, + true, + true, + false, + false, + B[6], + M * 6, + 16, + 37), // consisting out of 6 Ingots. + toolAngleGrinder( + "Angle Grinder", + "", + "Angle Grinder", + true, + true, + false, + false, + false, + false, + true, + true, + false, + false, + B[6], + M * 6, + 16, + 37), // consisting out of 6 Ingots. + toolElectricSnips( + "Electric Snips", + "", + "Electric Snips", + true, + true, + false, + false, + false, + false, + true, + true, + false, + false, + B[6], + M * 6, + 16, + 37), // consisting out of 6 Ingots. + toolElectricLighter( + "Electric Lighter", + "", + "Electric Lighter", + true, + true, + false, + false, + false, + false, + true, + true, + false, + false, + B[6], + M * 6, + 16, + 37), // consisting out of 6 Ingots. + toolElectricButcherKnife( + "Electric Butcher Knife", + "", + "Electric Butcher Knife", + true, + true, + false, + false, + false, + false, + true, + true, + false, + false, + B[6], + M * 6, + 16, + 37), // consisting out of 6 Ingots. + + batterySingleuse( + "Single Use Batteries", + "", + "", + false, + true, + false, + false, + false, + false, + false, + false, + false, + false, + 0, + -1, + 64, + -1), + battery( + "Reusable Batteries", + "", + "", + false, + true, + false, + false, + false, + false, + false, + false, + false, + false, + 0, + -1, + 64, + -1), // Introduced by Calclavia + circuit( + "Circuits", + "", + "", + true, + true, + false, + false, + false, + false, + false, + false, + false, + false, + 0, + -1, + 64, + -1), // Introduced by Calclavia + chipset( + "Chipsets", + "", + "", + true, + true, + false, + false, + false, + false, + false, + false, + false, + false, + 0, + -1, + 64, + -1), // Introduced by Buildcraft + computer("Computers", "", "", true, true, false, false, true, false, false, false, false, false, 0, -1, 64, -1), + ; // A whole Computer. "computerMaster" = ComputerCube + + public static volatile int VERSION = 508; + + static { + ingotHot.mHeatDamage = 3.0F; + } + + public final ArrayList<ItemStack> mPrefixedItems = new ArrayList<>(); + public final short mTextureIndex; + public final String mRegularLocalName, mLocalizedMaterialPre, mLocalizedMaterialPost; + public final boolean mIsUsedForOreProcessing, + mIsEnchantable, + mIsUnificatable, + mIsMaterialBased, + mIsSelfReferencing, + mIsContainer, + mDontUnificateActively, + mIsUsedForBlocks, + mAllowNormalRecycling, + mGenerateDefaultItem; + public final List<TC_AspectStack> mAspects = new ArrayList<>(); + public final Collection<GregtechOrePrefixes> mFamiliarPrefixes = new HashSet<>(); + /** + * Used to determine the amount of Material this Prefix contains. + * Multiply or Divide GregTech_API.MATERIAL_UNIT to get the Amounts in comparision to one Ingot. + * 0 = Null + * Negative = Undefined Amount + */ + public final long mMaterialAmount; + + private final Collection<Materials> mNotGeneratedItems = new HashSet<>(), + mIgnoredMaterials = new HashSet<>(), + mGeneratedItems = new HashSet<>(); + private final ArrayList<Interface_OreRecipeRegistrator> mOreProcessing = new ArrayList<>(); + private final ArrayList<Interface_OreRecipeRegistrator> mOreProcessingFake = new ArrayList<>(); + public ItemStack mContainerItem = null; + public ICondition<ISubTagContainer> mCondition = null; + public byte mDefaultStackSize = 64; + public GregtechMaterialStack mSecondaryMaterial = null; + public GregtechOrePrefixes mPrefixInto = this; + public float mHeatDamage = 0.0F; // Negative for Frost Damage + /** + * Yes this Value can be changed to add Bits for the MetaGenerated-Item-Check. + */ + public int mMaterialGenerationBits = 0; + + private GregtechOrePrefixes( + final String aRegularLocalName, + final String aLocalizedMaterialPre, + final String aLocalizedMaterialPost, + final boolean aIsUnificatable, + final boolean aIsMaterialBased, + final boolean aIsSelfReferencing, + final boolean aIsContainer, + final boolean aDontUnificateActively, + final boolean aIsUsedForBlocks, + final boolean aAllowNormalRecycling, + final boolean aGenerateDefaultItem, + final boolean aIsEnchantable, + final boolean aIsUsedForOreProcessing, + final int aMaterialGenerationBits, + final long aMaterialAmount, + final int aDefaultStackSize, + final int aTextureindex) { + this.mIsUnificatable = aIsUnificatable; + this.mIsMaterialBased = aIsMaterialBased; + this.mIsSelfReferencing = aIsSelfReferencing; + this.mIsContainer = aIsContainer; + this.mDontUnificateActively = aDontUnificateActively; + this.mIsUsedForBlocks = aIsUsedForBlocks; + this.mAllowNormalRecycling = aAllowNormalRecycling; + this.mGenerateDefaultItem = aGenerateDefaultItem; + this.mIsEnchantable = aIsEnchantable; + this.mIsUsedForOreProcessing = aIsUsedForOreProcessing; + this.mMaterialGenerationBits = aMaterialGenerationBits; + this.mMaterialAmount = aMaterialAmount; + this.mRegularLocalName = aRegularLocalName; + this.mLocalizedMaterialPre = aLocalizedMaterialPre; + this.mLocalizedMaterialPost = aLocalizedMaterialPost; + this.mDefaultStackSize = (byte) aDefaultStackSize; + this.mTextureIndex = (short) aTextureindex; + + // TODO - Utilise some form of way to check if it's gt 5.9 if so, use string switch. + if (this.name().startsWith("ore")) { + getTcAspectStack(TC_Aspects.TERRA.name(), 1).addToAspectList(this.mAspects); + } else if (this.name().startsWith("wire") || this.name().startsWith("cable")) { + getTcAspectStack(TC_Aspects.ELECTRUM.name(), 1).addToAspectList(this.mAspects); + } else if (this.name().startsWith("dust")) { + getTcAspectStack(TC_Aspects.PERDITIO.name(), 1).addToAspectList(this.mAspects); + } else if (this.name().startsWith("crushed")) { + getTcAspectStack(TC_Aspects.PERFODIO.name(), 1).addToAspectList(this.mAspects); + } else if (this.name().startsWith("ingot") || this.name().startsWith("nugget")) { + getTcAspectStack(TC_Aspects.METALLUM.name(), 1).addToAspectList(this.mAspects); + } else if (this.name().startsWith("armor")) { + getTcAspectStack(TC_Aspects.TUTAMEN.name(), 1).addToAspectList(this.mAspects); + } else if (this.name().startsWith("stone")) { + getTcAspectStack(TC_Aspects.TERRA.name(), 1).addToAspectList(this.mAspects); + } else if (this.name().startsWith("pipe")) { + getTcAspectStack(TC_Aspects.ITER.name(), 1).addToAspectList(this.mAspects); + } else if (this.name().startsWith("gear")) { + getTcAspectStack(TC_Aspects.MOTUS.name(), 1).addToAspectList(this.mAspects); + getTcAspectStack(TC_Aspects.MACHINA.name(), 1).addToAspectList(this.mAspects); + } else if (this.name().startsWith("frame") || this.name().startsWith("plate")) { + getTcAspectStack(TC_Aspects.FABRICO.name(), 1).addToAspectList(this.mAspects); + } else if (this.name().startsWith("tool")) { + getTcAspectStack(TC_Aspects.INSTRUMENTUM.name(), 2).addToAspectList(this.mAspects); + } else if (this.name().startsWith("gem") + || this.name().startsWith("crystal") + || this.name().startsWith("lens")) { + getTcAspectStack(TC_Aspects.VITREUS.name(), 1).addToAspectList(this.mAspects); + } else if (this.name().startsWith("crate")) { + getTcAspectStack(TC_Aspects.ITER.name(), 2).addToAspectList(this.mAspects); + } else if (this.name().startsWith("circuit")) { + getTcAspectStack("COGNITIO", 1); + } else if (this.name().startsWith("computer")) { + getTcAspectStack("COGNITIO", 4).addToAspectList(this.mAspects); + } else if (this.name().startsWith("battery")) { + getTcAspectStack(TC_Aspects.ELECTRUM.name(), 1).addToAspectList(this.mAspects); + } + } + + public static GregtechOrePrefixes getOrePrefix(final String aOre) { + for (final GregtechOrePrefixes tPrefix : values()) { + if (aOre.startsWith(tPrefix.toString())) { + return tPrefix; + } + } + return null; + } + + public static String stripPrefix(final String aOre) { + for (final GregtechOrePrefixes tPrefix : values()) { + if (aOre.startsWith(tPrefix.toString())) { + return aOre.replaceFirst(tPrefix.toString(), ""); + } + } + return aOre; + } + + public static String replacePrefix(final String aOre, final GregtechOrePrefixes aPrefix) { + for (final GregtechOrePrefixes tPrefix : values()) { + if (aOre.startsWith(tPrefix.toString())) { + return aOre.replaceFirst(tPrefix.toString(), aPrefix.toString()); + } + } + return ""; + } + + public static GregtechOrePrefixes getPrefix(final String aPrefixName) { + return getPrefix(aPrefixName, null); + } + + public static GregtechOrePrefixes getPrefix(final String aPrefixName, final GregtechOrePrefixes aReplacement) { + final Object tObject = GT_Utility.getFieldContent(GregtechOrePrefixes.class, aPrefixName, false, false); + if ((tObject != null) && (tObject instanceof GregtechOrePrefixes)) { + return (GregtechOrePrefixes) tObject; + } + return aReplacement; + } + + public static Materials getMaterial(final String aOre) { + return Materials.get(stripPrefix(aOre)); + } + + public static Materials getMaterial(final String aOre, final GregtechOrePrefixes aPrefix) { + return Materials.get(aOre.replaceFirst(aPrefix.toString(), "")); + } + + public static Materials getRealMaterial(final String aOre, final GregtechOrePrefixes aPrefix) { + return Materials.getRealMaterial(aOre.replaceFirst(aPrefix.toString(), "")); + } + + public static boolean isInstanceOf(final String aName, final GregtechOrePrefixes aPrefix) { + return aName == null ? false : aName.startsWith(aPrefix.toString()); + } + + public boolean add(final ItemStack aStack) { + if (aStack == null) { + return false; + } + if (!this.contains(aStack)) { + this.mPrefixedItems.add(aStack); + } + while (this.mPrefixedItems.contains(null)) { + this.mPrefixedItems.remove(null); + } + return true; + } + + public boolean contains(final ItemStack aStack) { + if (aStack == null) { + return false; + } + for (final ItemStack tStack : this.mPrefixedItems) { + if (GT_Utility.areStacksEqual(aStack, tStack, !tStack.hasTagCompound())) { + return true; + } + } + return false; + } + + public boolean doGenerateItem(final Materials aMaterial) { + return (aMaterial != null) + && (aMaterial != Materials._NULL) + && (((aMaterial.mTypes & this.mMaterialGenerationBits) != 0) + || this.mGeneratedItems.contains(aMaterial)) + && !this.mNotGeneratedItems.contains(aMaterial) + && ((this.mCondition == null) || this.mCondition.isTrue(aMaterial)); + } + + public boolean ignoreMaterials(final Materials... aMaterials) { + for (final Materials tMaterial : aMaterials) { + if (tMaterial != null) { + this.mIgnoredMaterials.add(tMaterial); + } + } + return true; + } + + public boolean addFamiliarPrefix(final GregtechOrePrefixes aPrefix) { + if ((aPrefix == null) || this.mFamiliarPrefixes.contains(aPrefix) || (aPrefix == this)) { + return false; + } + return this.mFamiliarPrefixes.add(aPrefix); + } + + public boolean add(final Interface_OreRecipeRegistrator aRegistrator) { + if (aRegistrator == null) { + return false; + } + return this.mOreProcessing.add(aRegistrator); + } + + public void processOre( + final GT_Materials aMaterial, final String aOreDictName, final String aModName, final ItemStack aStack) { + if ((aMaterial != null) + && ((aMaterial != GT_Materials._NULL) || this.mIsSelfReferencing || !this.mIsMaterialBased) + && GT_Utility.isStackValid(aStack)) { + for (final Interface_OreRecipeRegistrator tRegistrator : this.mOreProcessing) { + if (D2) { + GT_Log.ore.println( + "Processing '" + aOreDictName + "' with the Prefix '" + this.name() + "' and the Material '" + + aMaterial.name() + "' at " + GT_Utility.getClassName(tRegistrator)); + } + tRegistrator.registerOre(this, aMaterial, aOreDictName, aModName, GT_Utility.copyAmount(1, aStack)); + } + } + } + + // TODO + public void processOre( + final Materials aMaterial, final String aOreDictName, final String aModName, final ItemStack aStack) { + if ((aMaterial != null) + && ((aMaterial != Materials._NULL) || this.mIsSelfReferencing || !this.mIsMaterialBased) + && GT_Utility.isStackValid(aStack)) { + for (final Interface_OreRecipeRegistrator tRegistrator : this.mOreProcessingFake) { + if (D2) { + GT_Log.ore.println( + "Processing '" + aOreDictName + "' with the Prefix '" + this.name() + "' and the Material '" + + aMaterial.name() + "' at " + GT_Utility.getClassName(tRegistrator)); + } + tRegistrator.registerOre(this, aMaterial, aOreDictName, aModName, GT_Utility.copyAmount(1, aStack)); + } + } + } + + public Object get(final Object aMaterial) { + if (aMaterial instanceof GT_Materials) { + return new GregtechItemData(this, (GT_Materials) aMaterial); + } + return this.name() + aMaterial; + } + + public String getDefaultLocalNameForItem(final Materials aMaterial) { + + // Use Standard Localization + return this.mLocalizedMaterialPre + aMaterial.mDefaultLocalName + this.mLocalizedMaterialPost; + } + + public enum GT_Materials implements IColorModulationContainer, ISubTagContainer { + + /** + * This is the Default Material returned in case no Material has been found or a NullPointer has been inserted at a location where it shouldn't happen. + * <p/> + * Mainly for preventing NullPointer Exceptions and providing Default Values. + * + * Unknown Material Components. Dead End Section. + * + * Alkalus Range 730-799 & 970-998 + * (aMetaItemSubID, TextureSet, aToolSpeed, aToolDurability, aToolQuality, aTypes, R, G, B, Alpha, aLocalName, + * aFuelType, aFuelPower, aMeltingPoint, aBlastFurnaceTemp, aBlastFurnaceRequired, aTransparent, aOreValue, aDensityMultiplier, aDensityDivider, aColor + * this(aMetaItemSubID, aIconSet, aToolSpeed, aToolDurability, aToolQuality, true); + * + */ + _NULL( + -1, + TextureSet.SET_NONE, + 1.0F, + 0, + 0, + 0, + 255, + 255, + 255, + 0, + "NULL", + 0, + 0, + 0, + 0, + false, + false, + 1, + 1, + 1, + Dyes._NULL, + Element._NULL, + Arrays.asList(getTcAspectStack(TC_Aspects.VACUOS.name(), 1))), + + // Lapis(526, TextureSet.SET_LAPIS, 1.0F, 0, 1, 1 | 4 | 8, 70, 70, 220, 0, "Lapis", 0, 0, -1, 0, false, false, + // 3, 1, 1, Dyes.dyeBlue, 2, Arrays.asList(new MaterialStack(Materials.Lazurite, 12), new + // MaterialStack(Materials.Sodalite, 2), new MaterialStack(Materials.Pyrite, 1), new + // MaterialStack(Materials.Calcite, 1)), Arrays.asList(getTcAspectStack(TC_Aspects.SENSUS, 1))), + Pyrotheum( + 20, + TextureSet.SET_FLUID, + 1.0F, + 0, + 1, + 2 | 16 | 32, + 255, + 128, + 0, + 0, + "Pyrotheum", + 0, + 0, + -1, + 0, + false, + false, + 2, + 3, + 1, + Dyes.dyeYellow, + 2, + Arrays.asList( + new MaterialStack(Materials.Coal, 1), + new MaterialStack(Materials.Redstone, 1), + new MaterialStack(Materials.Blaze, 1), + new MaterialStack(Materials.Sulfur, 1)), + Arrays.asList(getTcAspectStack("PRAECANTATIO", 2), getTcAspectStack(TC_Aspects.IGNIS, 1))), + Cryotheum( + 21, + TextureSet.SET_FLUID, + 1.0F, + 0, + 1, + 2 | 16 | 32, + 102, + 178, + 255, + 0, + "Cryotheum", + 0, + 0, + -1, + 0, + false, + false, + 2, + 3, + 1, + Dyes.dyeLightBlue, + 2, + Arrays.asList( + new MaterialStack(Materials.Blizz, 1), + new MaterialStack(Materials.Redstone, 1), + new MaterialStack(Materials.Snow, 1), + new MaterialStack(Materials.Niter, 1)), + Arrays.asList(getTcAspectStack("PRAECANTATIO", 2), getTcAspectStack(TC_Aspects.GELUM, 1))), + Ender( + 22, + TextureSet.SET_FLUID, + 1.0F, + 0, + 2, + 1, + 255, + 255, + 255, + 0, + "Ender", + 0, + 0, + -1, + 0, + false, + false, + 3, + 1, + 1, + Dyes.dyeGreen), + + /** + * Circuitry, Batteries and other Technical things + */ + Symbiotic( + -1, + TextureSet.SET_NONE, + 1.0F, + 0, + 0, + 0, + 255, + 255, + 255, + 0, + "IV Tier", + 0, + 0, + -1, + 0, + false, + false, + 1, + 1, + 1, + Dyes.dyeLightGray, + Arrays.asList(getTcAspectStack(TC_Aspects.ELECTRUM, 4), getTcAspectStack(TC_Aspects.MACHINA, 4))), + Neutronic( + -1, + TextureSet.SET_NONE, + 1.0F, + 0, + 0, + 0, + 255, + 255, + 255, + 0, + "LuV Tier", + 0, + 0, + -1, + 0, + false, + false, + 1, + 1, + 1, + Dyes.dyeLightGray, + Arrays.asList(getTcAspectStack(TC_Aspects.ELECTRUM, 6), getTcAspectStack(TC_Aspects.MACHINA, 6))), + Quantum( + -1, + TextureSet.SET_NONE, + 1.0F, + 0, + 0, + 0, + 255, + 255, + 255, + 0, + "ZPM Tier", + 0, + 0, + -1, + 0, + false, + false, + 1, + 1, + 1, + Dyes.dyeLightGray, + Arrays.asList(getTcAspectStack(TC_Aspects.ELECTRUM, 8), getTcAspectStack(TC_Aspects.MACHINA, 8))), + + Superconductor( + -1, + TextureSet.SET_NONE, + 1.0F, + 0, + 0, + 0, + 190, + 240, + 190, + 0, + "Superconductor", + 0, + 0, + -1, + 0, + false, + false, + 1, + 1, + 1, + Dyes.dyeGreen, + Arrays.asList(getTcAspectStack(TC_Aspects.ELECTRUM, 8))), + + Staballoy( + 30, + TextureSet.SET_ROUGH, + 10.0F, + 5120, + 4, + 1 | 2 | 16 | 32 | 64 | 128, + 68, + 75, + 66, + 0, + "Staballoy", + 0, + 0, + 1500, + 2800, + true, + false, + 1, + 3, + 1, + Dyes.dyeGreen, + 2, + Arrays.asList(new MaterialStack(Materials.Titanium, 1), new MaterialStack(Materials.Uranium, 9)), + Arrays.asList(getTcAspectStack(TC_Aspects.METALLUM, 8), getTcAspectStack(TC_Aspects.STRONTIO, 3))), + Bedrockium( + 31, + TextureSet.SET_FINE, + 8.0F, + 8196, + 3, + 1 | 2 | 16 | 32 | 64 | 128, + 39, + 39, + 39, + 0, + "Bedrockium", + 0, + 0, + -1, + 0, + false, + false, + 1, + 5, + 1, + Dyes.dyeLightGray, + 2, + Arrays.asList(new MaterialStack(Materials.Carbon, 63), new MaterialStack(Materials.Carbon, 56)), + Arrays.asList(getTcAspectStack(TC_Aspects.VACUOS, 8), getTcAspectStack(TC_Aspects.TUTAMEN, 3))), + BloodSteel( + 32, + TextureSet.SET_METALLIC, + 11.0F, + 768, + 4, + 1 | 2 | 16 | 32 | 64 | 128, + 142, + 28, + 0, + 0, + "Blood Steel", + 0, + 0, + -1, + 0, + false, + false, + 1, + 1, + 1, + Dyes.dyeRed, + 2, + Arrays.asList(new MaterialStack(Materials.Steel, 3)), + Arrays.asList(getTcAspectStack(TC_Aspects.VICTUS, 8), getTcAspectStack(TC_Aspects.IGNIS, 3))), + Void( + 33, + TextureSet.SET_METALLIC, + 6.0F, + 1280, + 3, + 1 | 2 | 16 | 32 | 64 | 128, + 82, + 17, + 82, + 0, + "Void Metal", + 0, + 0, + -1, + 0, + false, + false, + 3, + 1, + 1, + Dyes.dyeBlack, + Arrays.asList(getTcAspectStack("PRAECANTATIO", 5), getTcAspectStack(TC_Aspects.VACUOS, 7))), + ConductiveIron( + 34, + TextureSet.SET_METALLIC, + 5.0F, + 256, + 2, + 1 | 2, + 164, + 109, + 100, + 0, + "Conductive Iron", + 0, + 0, + -1, + 0, + false, + false, + 3, + 1, + 1, + Dyes.dyeRed, + 2, + Arrays.asList(new MaterialStack(Materials.Iron, 6), new MaterialStack(Materials.Redstone, 2)), + Arrays.asList(getTcAspectStack(TC_Aspects.POTENTIA, 2), getTcAspectStack(TC_Aspects.METALLUM, 2))), + ElectricalSteel( + 35, + TextureSet.SET_METALLIC, + 7.0F, + 768, + 3, + 1 | 2 | 64 | 128, + 194, + 194, + 194, + 0, + "Electrical Steel", + 0, + 0, + 1811, + 1000, + true, + false, + 3, + 1, + 1, + Dyes.dyeLightGray, + 2, + Arrays.asList( + new MaterialStack(Materials.Iron, 3), + new MaterialStack(Materials.Coal, 2), + new MaterialStack(Materials.Silicon, 2)), + Arrays.asList(getTcAspectStack(TC_Aspects.MAGNETO, 2), getTcAspectStack(TC_Aspects.ELECTRUM, 5))), + EnergeticAlloy( + 36, + TextureSet.SET_SHINY, + 5.0F, + 512, + 3, + 1 | 2 | 64 | 128, + 252, + 152, + 45, + 0, + "Energetic Alloy", + 0, + 0, + -1, + 0, + false, + false, + 3, + 1, + 1, + Dyes.dyeOrange, + 2, + Arrays.asList( + new MaterialStack(Materials.Gold, 3), + new MaterialStack(Materials.Glowstone, 2), + new MaterialStack(Materials.Redstone, 2)), + Arrays.asList(getTcAspectStack(TC_Aspects.POTENTIA, 4), getTcAspectStack(TC_Aspects.LUX, 3))), + VibrantAlloy( + 37, + TextureSet.SET_SHINY, + 7.0F, + 1280, + 4, + 1 | 2 | 64 | 128, + 204, + 242, + 142, + 0, + "Vibrant Alloy", + 0, + 0, + -1, + 0, + false, + false, + 3, + 1, + 1, + Dyes.dyeLime, + 2, + Arrays.asList( + new MaterialStack(Materials.EnergeticAlloy, 1), new MaterialStack(Materials.EnderPearl, 3)), + Arrays.asList(getTcAspectStack(TC_Aspects.MACHINA, 5), getTcAspectStack(TC_Aspects.TELUM, 4))), + PulsatingIron( + 38, + TextureSet.SET_SHINY, + 5.0F, + 256, + 2, + 1 | 2 | 64 | 128, + 50, + 91, + 21, + 0, + "Pulsating Iron", + 0, + 0, + -1, + 0, + false, + false, + 3, + 1, + 1, + Dyes.dyeGreen, + 2, + Arrays.asList(new MaterialStack(Materials.Iron, 2), new MaterialStack(Materials.EnderPearl, 2)), + Arrays.asList(getTcAspectStack(TC_Aspects.ALIENIS, 3), getTcAspectStack(TC_Aspects.METALLUM, 3))), + /* TODO*/ RedstoneAlloy( + 39, + TextureSet.SET_METALLIC, + 1.0F, + 256, + 2, + 1 | 2 | 16 | 32 | 64, + 178, + 34, + 34, + 0, + "Redstone Alloy", + 0, + 0, + -1, + 0, + false, + false, + 3, + 1, + 1, + Dyes.dyeRed, + 2, + Arrays.asList(new MaterialStack(Materials.Iron, 2), new MaterialStack(Materials.Redstone, 4))), + + // Needs more Use, I think. + Tantalloy60( + 40, + TextureSet.SET_DULL, + 8.0F, + 5120, + 3, + 1 | 2 | 16 | 32 | 64 | 128, + 68, + 75, + 166, + 0, + "Tantalloy-60", + 0, + 0, + 3035, + 2200, + true, + false, + 1, + 2, + 1, + Dyes.dyeLightBlue, + 2, + Arrays.asList(new MaterialStack(Materials.Tungsten, 1), new MaterialStack(Materials.Tantalum, 9)), + Arrays.asList(getTcAspectStack(TC_Aspects.METALLUM, 8), getTcAspectStack(TC_Aspects.STRONTIO, 3))), + Tantalloy61( + 41, + TextureSet.SET_DULL, + 7.0F, + 5120, + 2, + 1 | 2 | 16 | 32 | 64 | 128, + 122, + 135, + 196, + 0, + "Tantalloy-61", + 0, + 0, + 3015, + 2150, + true, + false, + 1, + 2, + 1, + Dyes.dyeLightBlue, + 2, + Arrays.asList( + new MaterialStack(Materials.Tungsten, 1), + new MaterialStack(Materials.Tantalum, 9), + new MaterialStack(Materials.Titanium, 1)), + Arrays.asList(getTcAspectStack(TC_Aspects.METALLUM, 8), getTcAspectStack(TC_Aspects.STRONTIO, 3))), + + Potin( + 42, + TextureSet.SET_METALLIC, + 7.0F, + 5120, + 2, + 1 | 2 | 16 | 32 | 64 | 128, + 201, + 151, + 129, + 0, + "Potin", + 0, + 0, + 3015, + 2150, + true, + false, + 1, + 2, + 1, + Dyes.dyeLightBlue, + 2, + Arrays.asList( + new MaterialStack(Materials.Tungsten, 1), + new MaterialStack(Materials.Tantalum, 9), + new MaterialStack(Materials.Titanium, 1)), + Arrays.asList(getTcAspectStack(TC_Aspects.METALLUM, 8), getTcAspectStack(TC_Aspects.STRONTIO, 3))), + Inconel792( + 43, + TextureSet.SET_METALLIC, + 7.0F, + 5120, + 2, + 1 | 2 | 16 | 32 | 64 | 128, + 108, + 240, + 118, + 0, + "Inconel-792", + 0, + 0, + 3015, + 2150, + true, + false, + 1, + 2, + 1, + Dyes.dyeLightBlue, + 2, + Arrays.asList( + new MaterialStack(Materials.Tungsten, 1), + new MaterialStack(Materials.Tantalum, 9), + new MaterialStack(Materials.Titanium, 1)), + Arrays.asList(getTcAspectStack(TC_Aspects.METALLUM, 8), getTcAspectStack(TC_Aspects.STRONTIO, 3))), + Inconel690( + 44, + TextureSet.SET_DULL, + 7.0F, + 5120, + 2, + 1 | 2 | 16 | 32 | 64 | 128, + 118, + 220, + 138, + 0, + "Inconel-690", + 0, + 0, + 3015, + 2150, + true, + false, + 1, + 2, + 1, + Dyes.dyeLightBlue, + 2, + Arrays.asList( + new MaterialStack(Materials.Tungsten, 1), + new MaterialStack(Materials.Tantalum, 9), + new MaterialStack(Materials.Titanium, 1)), + Arrays.asList(getTcAspectStack(TC_Aspects.METALLUM, 8), getTcAspectStack(TC_Aspects.STRONTIO, 3))), + MaragingSteel300( + 45, + TextureSet.SET_METALLIC, + 7.0F, + 5120, + 2, + 1 | 2 | 16 | 32 | 64 | 128, + 150, + 150, + 150, + 0, + "Maraging Steel 300", + 0, + 0, + 3015, + 2150, + true, + false, + 1, + 2, + 1, + Dyes.dyeLightBlue, + 2, + Arrays.asList( + new MaterialStack(Materials.Tungsten, 1), + new MaterialStack(Materials.Tantalum, 9), + new MaterialStack(Materials.Titanium, 1)), + Arrays.asList(getTcAspectStack(TC_Aspects.METALLUM, 8), getTcAspectStack(TC_Aspects.STRONTIO, 3))), + MaragingSteel350( + 46, + TextureSet.SET_METALLIC, + 7.0F, + 5120, + 2, + 1 | 2 | 16 | 32 | 64 | 128, + 160, + 160, + 160, + 0, + "Maraging Steel 350", + 0, + 0, + 3015, + 2150, + true, + false, + 1, + 2, + 1, + Dyes.dyeLightBlue, + 2, + Arrays.asList( + new MaterialStack(Materials.Tungsten, 1), + new MaterialStack(Materials.Tantalum, 9), + new MaterialStack(Materials.Titanium, 1)), + Arrays.asList(getTcAspectStack(TC_Aspects.METALLUM, 8), getTcAspectStack(TC_Aspects.STRONTIO, 3))), + HastelloyX( + 47, + TextureSet.SET_SHINY, + 7.0F, + 5120, + 2, + 1 | 2 | 16 | 32 | 64 | 128, + 255, + 193, + 37, + 0, + "Hastelloy-X", + 0, + 0, + 3015, + 2150, + true, + false, + 1, + 2, + 1, + Dyes.dyeLightBlue, + 2, + Arrays.asList( + new MaterialStack(Materials.Tungsten, 1), + new MaterialStack(Materials.Tantalum, 9), + new MaterialStack(Materials.Titanium, 1)), + Arrays.asList(getTcAspectStack(TC_Aspects.METALLUM, 8), getTcAspectStack(TC_Aspects.STRONTIO, 3))), + + TriniumNaquadahCarbonite( + 48, + TextureSet.SET_SHINY, + 7.0F, + 5120, + 2, + 1 | 2 | 16 | 32 | 64 | 128, + 255, + 233, + 0, + 0, + "Trinium Naquadah Carbonite", + 0, + 0, + 3015, + 2150, + true, + false, + 1, + 2, + 1, + Dyes.dyeLightBlue, + 2, + Arrays.asList( + new MaterialStack(Materials.Tungsten, 1), + new MaterialStack(Materials.Tantalum, 9), + new MaterialStack(Materials.Titanium, 1)), + Arrays.asList(getTcAspectStack(TC_Aspects.METALLUM, 8), getTcAspectStack(TC_Aspects.STRONTIO, 3))), + + // Radioactive Materials + HydrofluoricAcid( + -1, + TextureSet.SET_FLUID, + 1.0F, + 0, + 1, + 2 | 16 | 32, + 200, + 200, + 200, + 0, + "Hydrofluoric Acid", + 0, + 0, + -1, + 0, + false, + false, + 2, + 3, + 1, + Dyes.dyeWhite, + 2, + Arrays.asList( + new MaterialStack(Materials.Coal, 1), + new MaterialStack(Materials.Redstone, 1), + new MaterialStack(Materials.Blaze, 1), + new MaterialStack(Materials.Sulfur, 1))), + UraniumHexaFluoride( + -1, + TextureSet.SET_FLUID, + 1.0F, + 0, + 1, + 2 | 16 | 32, + 73, + 220, + 83, + 0, + "Uranium Hexafluoride", + 0, + 0, + -1, + 0, + false, + false, + 2, + 3, + 1, + Dyes.dyeLime, + 2, + Arrays.asList( + new MaterialStack(Materials.Coal, 1), + new MaterialStack(Materials.Redstone, 1), + new MaterialStack(Materials.Blaze, 1), + new MaterialStack(Materials.Sulfur, 1))), + UraniumTetraFluoride( + -1, + TextureSet.SET_FLUID, + 1.0F, + 0, + 1, + 2 | 16 | 32, + 73, + 220, + 83, + 0, + "Uranium Tetrafluoride", + 0, + 0, + -1, + 0, + false, + false, + 2, + 3, + 1, + Dyes.dyeLime, + 2, + Arrays.asList( + new MaterialStack(Materials.Coal, 1), + new MaterialStack(Materials.Redstone, 1), + new MaterialStack(Materials.Blaze, 1), + new MaterialStack(Materials.Sulfur, 1))), + ThoriumTetraFluoride( + -1, + TextureSet.SET_FLUID, + 1.0F, + 0, + 1, + 2 | 16 | 32, + 15, + 120, + 15, + 0, + "Thorium Tetrafluoride", + 0, + 0, + -1, + 0, + false, + false, + 2, + 3, + 1, + Dyes.dyeGreen, + 2, + Arrays.asList( + new MaterialStack(Materials.Coal, 1), + new MaterialStack(Materials.Redstone, 1), + new MaterialStack(Materials.Blaze, 1), + new MaterialStack(Materials.Sulfur, 1))), + + SulfurousAcid( + -1, + TextureSet.SET_FLUID, + 1.0F, + 0, + 1, + 2 | 16 | 32, + 110, + 220, + 30, + 0, + "Sulfurous Acid", + 0, + 0, + -1, + 0, + false, + false, + 2, + 3, + 1, + Dyes.dyeWhite, + 2, + Arrays.asList( + new MaterialStack(Materials.Coal, 1), + new MaterialStack(Materials.Redstone, 1), + new MaterialStack(Materials.Blaze, 1), + new MaterialStack(Materials.Sulfur, 1))), + SulfurDioxide( + -1, + TextureSet.SET_FLUID, + 1.0F, + 0, + 1, + 2 | 16 | 32, + 150, + 200, + 50, + 0, + "Sulfur Dioxide", + 0, + 0, + -1, + 0, + false, + false, + 2, + 3, + 1, + Dyes.dyeWhite, + 2, + Arrays.asList( + new MaterialStack(Materials.Coal, 1), + new MaterialStack(Materials.Redstone, 1), + new MaterialStack(Materials.Blaze, 1), + new MaterialStack(Materials.Sulfur, 1))), + HydrogenChloride( + -1, + TextureSet.SET_FLUID, + 1.0F, + 0, + 1, + 2 | 16 | 32, + 150, + 240, + 90, + 0, + "Hydrogen Chloride", + 0, + 0, + -1, + 0, + false, + false, + 2, + 3, + 1, + Dyes.dyeWhite, + 2, + Arrays.asList( + new MaterialStack(Materials.Coal, 1), + new MaterialStack(Materials.Redstone, 1), + new MaterialStack(Materials.Blaze, 1), + new MaterialStack(Materials.Sulfur, 1))), + SulfuricApatite( + -1, + TextureSet.SET_FLUID, + 1.0F, + 0, + 1, + 2 | 16 | 32, + 0, + 105, + 105, + 0, + "Sulfuric Apatite Solution", + 0, + 0, + -1, + 0, + false, + false, + 2, + 3, + 1, + Dyes.dyeWhite, + 2, + Arrays.asList( + new MaterialStack(Materials.Coal, 1), + new MaterialStack(Materials.Redstone, 1), + new MaterialStack(Materials.Blaze, 1), + new MaterialStack(Materials.Sulfur, 1))), + + SulfuricLithium( + -1, + TextureSet.SET_FLUID, + 1.0F, + 0, + 1, + 2 | 16 | 32, + 0, + 105, + 105, + 0, + "Sulfuric Lithium Solution", + 0, + 0, + -1, + 0, + false, + false, + 2, + 3, + 1, + Dyes.dyeWhite, + 2, + Arrays.asList( + new MaterialStack(Materials.Coal, 1), + new MaterialStack(Materials.Redstone, 1), + new MaterialStack(Materials.Blaze, 1), + new MaterialStack(Materials.Sulfur, 1))), + LithiumHydroxide( + -1, + TextureSet.SET_FLUID, + 1.0F, + 0, + 1, + 2 | 16 | 32, + 0, + 105, + 105, + 0, + "Lithium Hydroxide", + 0, + 0, + -1, + 0, + false, + false, + 2, + 3, + 1, + Dyes.dyeWhite, + 2, + Arrays.asList( + new MaterialStack(Materials.Coal, 1), + new MaterialStack(Materials.Redstone, 1), + new MaterialStack(Materials.Blaze, 1), + new MaterialStack(Materials.Sulfur, 1))), + ; + + /** + * List of all Materials. + */ + public static final Collection<GT_Materials> VALUES = new HashSet<>(Arrays.asList(values())); + + static { + /*Primitive.add(SubTag.NO_SMASHING, SubTag.NO_SMELTING); + Basic.add(SubTag.NO_SMASHING, SubTag.NO_SMELTING); + Good.add(SubTag.NO_SMASHING, SubTag.NO_SMELTING); + Advanced.add(SubTag.NO_SMASHING, SubTag.NO_SMELTING); + Data.add(SubTag.NO_SMASHING, SubTag.NO_SMELTING); + Elite.add(SubTag.NO_SMASHING, SubTag.NO_SMELTING); + Master.add(SubTag.NO_SMASHING, SubTag.NO_SMELTING); + Ultimate.add(SubTag.NO_SMASHING, SubTag.NO_SMELTING); + Superconductor.add(SubTag.NO_SMASHING, SubTag.NO_SMELTING); + Infinite.add(SubTag.NO_SMASHING, SubTag.NO_SMELTING);*/ + Symbiotic.add(SubTag.NO_SMASHING, SubTag.NO_SMELTING); + Neutronic.add(SubTag.NO_SMASHING, SubTag.NO_SMELTING); + Quantum.add(SubTag.NO_SMASHING, SubTag.NO_SMELTING); + } + + /** + * This Array can be changed dynamically by a Tick Handler in order to get a glowing Effect on all GT Meta Items out of this Material. + */ + public final short[] mRGBa = new short[] {255, 255, 255, 0}, mMoltenRGBa = new short[] {255, 255, 255, 0}; + + public final TextureSet mIconSet; + public final int mMetaItemSubID; + public final boolean mUnificatable; + public final GT_Materials mMaterialInto; + public final List<MaterialStack> mMaterialList = new ArrayList<>(); + public final List<GT_Materials> mOreByProducts = new ArrayList<>(), mOreReRegistrations = new ArrayList<>(); + public final List<TC_AspectStack> mAspects = new ArrayList<>(); + private final ArrayList<ItemStack> mMaterialItems = new ArrayList<>(); + private final Collection<SubTag> mSubTags = new HashSet<>(); + public Enchantment mEnchantmentTools = null, mEnchantmentArmors = null; + public byte mEnchantmentToolsLevel = 0, mEnchantmentArmorsLevel = 0; + public boolean mBlastFurnaceRequired = false; + public float mToolSpeed = 1.0F, mHeatDamage = 0.0F; + public String mChemicalFormula = "?", mDefaultLocalName = "null"; + public Dyes mColor = Dyes._NULL; + public short mMeltingPoint = 0, mBlastFurnaceTemp = 0; + public int mTypes = 0, + mDurability = 16, + mFuelPower = 0, + mFuelType = 0, + mExtraData = 0, + mOreValue = 0, + mOreMultiplier = 1, + mByProductMultiplier = 1, + mSmeltingMultiplier = 1; + public long mDensity = M; + public Element mElement = null; + public GT_Materials mDirectSmelting = this, + mOreReplacement = this, + mMacerateInto = this, + mSmeltInto = this, + mArcSmeltInto = this, + mHandleMaterial = this; + public byte mToolQuality = 0; + public Fluid mSolid = null, mFluid = null, mGas = null, mPlasma = null; + /** + * This Fluid is used as standard Unit for Molten Materials. 1296 is a Molten Block, what means 144 is one Material Unit worth + */ + public Fluid mStandardMoltenFluid = null; + + private GT_Materials( + final int aMetaItemSubID, + final TextureSet aIconSet, + final float aToolSpeed, + final int aToolDurability, + final int aToolQuality, + final boolean aUnificatable) { + this.mUnificatable = aUnificatable; + this.mMaterialInto = this; + this.mMetaItemSubID = aMetaItemSubID; + this.mToolQuality = (byte) aToolQuality; + this.mDurability = aToolDurability; + this.mToolSpeed = aToolSpeed; + this.mIconSet = aIconSet; + if (aMetaItemSubID >= 0) { + if (CORE.sMU_GeneratedMaterials[aMetaItemSubID] == null) { + CORE.sMU_GeneratedMaterials[aMetaItemSubID] = this; + } else { + throw new IllegalArgumentException("The Index " + aMetaItemSubID + " is already used!"); + } + } + } + + private GT_Materials(final GT_Materials aMaterialInto, final boolean aReRegisterIntoThis) { + this.mUnificatable = false; + this.mDefaultLocalName = aMaterialInto.mDefaultLocalName; + this.mMaterialInto = aMaterialInto.mMaterialInto; + if (aReRegisterIntoThis) { + this.mMaterialInto.mOreReRegistrations.add(this); + } + this.mChemicalFormula = aMaterialInto.mChemicalFormula; + this.mMetaItemSubID = -1; + this.mIconSet = TextureSet.SET_NONE; + } + + /** + * @param aMetaItemSubID the Sub-ID used in my own MetaItems. Range 0-1000. -1 for no Material + * @param aTypes which kind of Items should be generated. Bitmask as follows: + * 1 = Dusts of all kinds. + * 2 = Dusts, Ingots, Plates, Rods/Sticks, Machine Components and other Metal specific things. + * 4 = Dusts, Gems, Plates, Lenses (if transparent). + * 8 = Dusts, Impure Dusts, crushed Ores, purified Ores, centrifuged Ores etc. + * 16 = Cells + * 32 = Plasma Cells + * 64 = Tool Heads + * 128 = Gears + * @param aR, aG, aB Color of the Material 0-255 each. + * @param aA transparency of the Material Texture. 0 = fully visible, 255 = Invisible. + * @param aLocalName The Name used as Default for localization. + * @param aFuelType Type of Generator to get Energy from this Material. + * @param aFuelPower EU generated. Will be multiplied by 1000, also additionally multiplied by 2 for Gems. + * @param aAmplificationValue Amount of UUM amplifier gotten from this. + * @param aUUMEnergy Amount of EU needed to shape the UUM into this Material. + * @param aMeltingPoint Used to determine the smelting Costs in Furnii. + * @param aBlastFurnaceTemp Used to determine the needed Heat capactiy Costs in Blast Furnii. + * @param aBlastFurnaceRequired If this requires a Blast Furnace. + * @param aColor Vanilla MC Wool Color which comes the closest to this. + */ + private GT_Materials( + final int aMetaItemSubID, + final TextureSet aIconSet, + final float aToolSpeed, + final int aToolDurability, + final int aToolQuality, + final int aTypes, + final int aR, + final int aG, + final int aB, + final int aA, + final String aLocalName, + final int aFuelType, + final int aFuelPower, + final int aMeltingPoint, + final int aBlastFurnaceTemp, + final boolean aBlastFurnaceRequired, + final boolean aTransparent, + final int aOreValue, + final int aDensityMultiplier, + final int aDensityDivider, + final Dyes aColor) { + this(aMetaItemSubID, aIconSet, aToolSpeed, aToolDurability, aToolQuality, true); + this.mDefaultLocalName = aLocalName; + this.mMeltingPoint = (short) aMeltingPoint; + this.mBlastFurnaceTemp = (short) aBlastFurnaceTemp; + this.mBlastFurnaceRequired = aBlastFurnaceRequired; + if (aTransparent) { + this.add(SubTag.TRANSPARENT); + } + this.mFuelPower = aFuelPower; + this.mFuelType = aFuelType; + this.mOreValue = aOreValue; + this.mDensity = (M * aDensityMultiplier) / aDensityDivider; + this.mColor = aColor == null ? Dyes._NULL : aColor; + if (this.mColor != null) { + this.add(SubTag.HAS_COLOR); + } + this.mRGBa[0] = this.mMoltenRGBa[0] = (short) aR; + this.mRGBa[1] = this.mMoltenRGBa[1] = (short) aG; + this.mRGBa[2] = this.mMoltenRGBa[2] = (short) aB; + this.mRGBa[3] = this.mMoltenRGBa[3] = (short) aA; + this.mTypes = aTypes; + if ((this.mTypes & 2) != 0) { + this.add(SubTag.SMELTING_TO_FLUID); + } + } + + private GT_Materials( + final int aMetaItemSubID, + final TextureSet aIconSet, + final float aToolSpeed, + final int aToolDurability, + final int aToolQuality, + final int aTypes, + final int aR, + final int aG, + final int aB, + final int aA, + final String aLocalName, + final int aFuelType, + final int aFuelPower, + final int aMeltingPoint, + final int aBlastFurnaceTemp, + final boolean aBlastFurnaceRequired, + final boolean aTransparent, + final int aOreValue, + final int aDensityMultiplier, + final int aDensityDivider, + final Dyes aColor, + final List<TC_AspectStack> aAspects) { + this( + aMetaItemSubID, + aIconSet, + aToolSpeed, + aToolDurability, + aToolQuality, + aTypes, + aR, + aG, + aB, + aA, + aLocalName, + aFuelType, + aFuelPower, + aMeltingPoint, + aBlastFurnaceTemp, + aBlastFurnaceRequired, + aTransparent, + aOreValue, + aDensityMultiplier, + aDensityDivider, + aColor); + this.mAspects.addAll(aAspects); + } + + /** + * @param aElement The Element Enum represented by this Material + */ + private GT_Materials( + final int aMetaItemSubID, + final TextureSet aIconSet, + final float aToolSpeed, + final int aToolDurability, + final int aToolQuality, + final int aTypes, + final int aR, + final int aG, + final int aB, + final int aA, + final String aLocalName, + final int aFuelType, + final int aFuelPower, + final int aMeltingPoint, + final int aBlastFurnaceTemp, + final boolean aBlastFurnaceRequired, + final boolean aTransparent, + final int aOreValue, + final int aDensityMultiplier, + final int aDensityDivider, + final Dyes aColor, + final Element aElement, + final List<TC_AspectStack> aAspects) { + this( + aMetaItemSubID, + aIconSet, + aToolSpeed, + aToolDurability, + aToolQuality, + aTypes, + aR, + aG, + aB, + aA, + aLocalName, + aFuelType, + aFuelPower, + aMeltingPoint, + aBlastFurnaceTemp, + aBlastFurnaceRequired, + aTransparent, + aOreValue, + aDensityMultiplier, + aDensityDivider, + aColor); + this.mElement = aElement; + // mElement.mLinkedMaterials.add(this); + if (aElement == Element._NULL) { + this.mChemicalFormula = "Empty"; + } else { + this.mChemicalFormula = aElement.toString(); + this.mChemicalFormula = this.mChemicalFormula.replaceAll("_", "-"); + } + this.mAspects.addAll(aAspects); + } + + private GT_Materials( + final int aMetaItemSubID, + final TextureSet aIconSet, + final float aToolSpeed, + final int aToolDurability, + final int aToolQuality, + final int aTypes, + final int aR, + final int aG, + final int aB, + final int aA, + final String aLocalName, + final int aFuelType, + final int aFuelPower, + final int aMeltingPoint, + final int aBlastFurnaceTemp, + final boolean aBlastFurnaceRequired, + final boolean aTransparent, + final int aOreValue, + final int aDensityMultiplier, + final int aDensityDivider, + final Dyes aColor, + final int aExtraData, + final List<MaterialStack> aMaterialList) { + this( + aMetaItemSubID, + aIconSet, + aToolSpeed, + aToolDurability, + aToolQuality, + aTypes, + aR, + aG, + aB, + aA, + aLocalName, + aFuelType, + aFuelPower, + aMeltingPoint, + aBlastFurnaceTemp, + aBlastFurnaceRequired, + aTransparent, + aOreValue, + aDensityMultiplier, + aDensityDivider, + aColor, + aExtraData, + aMaterialList, + null); + } + + private GT_Materials( + final int aMetaItemSubID, + final TextureSet aIconSet, + final float aToolSpeed, + final int aToolDurability, + final int aToolQuality, + final int aTypes, + final int aR, + final int aG, + final int aB, + final int aA, + final String aLocalName, + final int aFuelType, + final int aFuelPower, + final int aMeltingPoint, + final int aBlastFurnaceTemp, + final boolean aBlastFurnaceRequired, + final boolean aTransparent, + final int aOreValue, + final int aDensityMultiplier, + final int aDensityDivider, + final Dyes aColor, + final int aExtraData, + final List<MaterialStack> aMaterialList, + final List<TC_AspectStack> aAspects) { + this( + aMetaItemSubID, + aIconSet, + aToolSpeed, + aToolDurability, + aToolQuality, + aTypes, + aR, + aG, + aB, + aA, + aLocalName, + aFuelType, + aFuelPower, + aMeltingPoint, + aBlastFurnaceTemp, + aBlastFurnaceRequired, + aTransparent, + aOreValue, + aDensityMultiplier, + aDensityDivider, + aColor); + this.mExtraData = aExtraData; + this.mMaterialList.addAll(aMaterialList); + this.mChemicalFormula = ""; + for (final MaterialStack tMaterial : this.mMaterialList) { + this.mChemicalFormula += tMaterial.toString(); + } + this.mChemicalFormula = this.mChemicalFormula.replaceAll("_", "-"); + + int tAmountOfComponents = 0, tMeltingPoint = 0; + for (final MaterialStack tMaterial : this.mMaterialList) { + tAmountOfComponents += tMaterial.mAmount; + if (tMaterial.mMaterial.mMeltingPoint > 0) { + tMeltingPoint += tMaterial.mMaterial.mMeltingPoint * tMaterial.mAmount; + } + if (aAspects == null) { + for (final TC_AspectStack tAspect : tMaterial.mMaterial.mAspects) { + tAspect.addToAspectList(this.mAspects); + } + } + } + + if (this.mMeltingPoint < 0) { + this.mMeltingPoint = (short) (tMeltingPoint / tAmountOfComponents); + } + + tAmountOfComponents *= aDensityMultiplier; + tAmountOfComponents /= aDensityDivider; + if (aAspects == null) { + for (final TC_AspectStack tAspect : this.mAspects) { + tAspect.mAmount = Math.max(1, tAspect.mAmount / Math.max(1, tAmountOfComponents)); + } + } else { + this.mAspects.addAll(aAspects); + } + } + + public static GT_Materials get(final String aMaterialName) { + final Object tObject = GT_Utility.getFieldContent(GT_Materials.class, aMaterialName, false, false); + if ((tObject != null) && (tObject instanceof GT_Materials)) { + return (GT_Materials) tObject; + } + return _NULL; + } + + public static GT_Materials getRealMaterial(final String aMaterialName) { + return get(aMaterialName).mMaterialInto; + } + + /** + * Called in preInit with the Config to set Values. + * + * @param aConfiguration + */ + public static void init(final GT_Config aConfiguration) { + for (final GT_Materials tMaterial : VALUES) { + final String tString = tMaterial.toString().toLowerCase(); + tMaterial.mHeatDamage = (float) + aConfiguration.get(ConfigCategories.Materials.heatdamage, tString, tMaterial.mHeatDamage); + if (tMaterial.mBlastFurnaceRequired) { + tMaterial.mBlastFurnaceRequired = + aConfiguration.get(ConfigCategories.Materials.blastfurnacerequirements, tString, true); + } + if (tMaterial.mBlastFurnaceRequired + && aConfiguration.get( + ConfigCategories.Materials.blastinductionsmelter, + tString, + tMaterial.mBlastFurnaceTemp < 1500)) {} + // GT_ModHandler.ThermalExpansion.addSmelterBlastOre(tMaterial); + // tMaterial.mHandleMaterial = (tMaterial == Desh ? tMaterial.mHandleMaterial : tMaterial == Diamond || + // tMaterial == Thaumium ? Wood : tMaterial.contains(SubTag.BURNING) ? Blaze : + // tMaterial.contains(SubTag.MAGICAL) && tMaterial.contains(SubTag.CRYSTAL) && + // Loader.isModLoaded(MOD_ID_TC) ? Thaumium : tMaterial.getMass() > Element.Tc.getMass() * 2 ? + // TungstenSteel : tMaterial.getMass() > Element.Tc.getMass() ? Steel : Wood); + } + } + + public boolean isRadioactive() { + if (this.mElement != null) { + return this.mElement.mHalfLifeSeconds >= 0; + } + for (final MaterialStack tMaterial : this.mMaterialList) { + if (tMaterial.mMaterial.isRadioactive()) { + return true; + } + } + return false; + } + + public long getProtons() { + if (this.mElement != null) { + return this.mElement.getProtons(); + } + if (this.mMaterialList.size() <= 0) { + return Element.Tc.getProtons(); + } + long rAmount = 0, tAmount = 0; + for (final MaterialStack tMaterial : this.mMaterialList) { + tAmount += tMaterial.mAmount; + rAmount += tMaterial.mAmount * tMaterial.mMaterial.getProtons(); + } + return (this.getDensity() * rAmount) / (tAmount * M); + } + + public long getNeutrons() { + if (this.mElement != null) { + return this.mElement.getNeutrons(); + } + if (this.mMaterialList.size() <= 0) { + return Element.Tc.getNeutrons(); + } + long rAmount = 0, tAmount = 0; + for (final MaterialStack tMaterial : this.mMaterialList) { + tAmount += tMaterial.mAmount; + rAmount += tMaterial.mAmount * tMaterial.mMaterial.getNeutrons(); + } + return (this.getDensity() * rAmount) / (tAmount * M); + } + + public long getMass() { + if (this.mElement != null) { + return this.mElement.getMass(); + } + if (this.mMaterialList.size() <= 0) { + return Element.Tc.getMass(); + } + long rAmount = 0, tAmount = 0; + for (final MaterialStack tMaterial : this.mMaterialList) { + tAmount += tMaterial.mAmount; + rAmount += tMaterial.mAmount * tMaterial.mMaterial.getMass(); + } + return (this.getDensity() * rAmount) / (tAmount * M); + } + + public long getDensity() { + return this.mDensity; + } + + public String getToolTip() { + return this.getToolTip(1, false); + } + + public String getToolTip(final boolean aShowQuestionMarks) { + return this.getToolTip(1, aShowQuestionMarks); + } + + public String getToolTip(final long aMultiplier) { + return this.getToolTip(aMultiplier, false); + } + + public String getToolTip(final long aMultiplier, final boolean aShowQuestionMarks) { + if (!aShowQuestionMarks && this.mChemicalFormula.equals("?")) { + return ""; + } + if ((aMultiplier >= (M * 2)) && !this.mMaterialList.isEmpty()) { + return (((this.mElement != null) + || ((this.mMaterialList.size() < 2) + && (this.mMaterialList.get(0).mAmount == 1))) + ? this.mChemicalFormula + : "(" + this.mChemicalFormula + ")") + + aMultiplier; + } + return this.mChemicalFormula; + } + + /** + * Adds an ItemStack to this Material. + */ + public GT_Materials add(final ItemStack aStack) { + if ((aStack != null) && !this.contains(aStack)) { + this.mMaterialItems.add(aStack); + } + return this; + } + + /** + * This is used to determine if any of the ItemStacks belongs to this Material. + */ + public boolean contains(final ItemStack... aStacks) { + if ((aStacks == null) || (aStacks.length <= 0)) { + return false; + } + for (final ItemStack tStack : this.mMaterialItems) { + for (final ItemStack aStack : aStacks) { + if (GT_Utility.areStacksEqual(aStack, tStack, !tStack.hasTagCompound())) { + return true; + } + } + } + return false; + } + + /** + * This is used to determine if an ItemStack belongs to this Material. + */ + public boolean remove(final ItemStack aStack) { + if (aStack == null) { + return false; + } + boolean temp = false; + for (int i = 0; i < this.mMaterialItems.size(); i++) { + if (GT_Utility.areStacksEqual(aStack, this.mMaterialItems.get(i))) { + this.mMaterialItems.remove(i--); + temp = true; + } + } + return temp; + } + + /** + * Adds a SubTag to this Material + */ + @Override + public ISubTagContainer add(final SubTag... aTags) { + if (aTags != null) { + for (final SubTag aTag : aTags) { + if ((aTag != null) && !this.contains(aTag)) { + aTag.addContainerToList(this); + this.mSubTags.add(aTag); + } + } + } + return this; + } + + /** + * If this Material has this exact SubTag + */ + @Override + public boolean contains(final SubTag aTag) { + return this.mSubTags.contains(aTag); + } + + /** + * Removes a SubTag from this Material + */ + @Override + public boolean remove(final SubTag aTag) { + return this.mSubTags.remove(aTag); + } + + /** + * Sets the Heat Damage for this Material (negative = frost) + */ + public GT_Materials setHeatDamage(final float aHeatDamage) { + this.mHeatDamage = aHeatDamage; + return this; + } + + /** + * Adds a Material to the List of Byproducts when grinding this Ore. + * Is used for more precise Ore grinding, so that it is possible to choose between certain kinds of Materials. + */ + public GT_Materials addOreByProduct(final GT_Materials aMaterial) { + if (!this.mOreByProducts.contains(aMaterial.mMaterialInto)) { + this.mOreByProducts.add(aMaterial.mMaterialInto); + } + return this; + } + + /** + * Adds multiple Materials to the List of Byproducts when grinding this Ore. + * Is used for more precise Ore grinding, so that it is possible to choose between certain kinds of Materials. + */ + public GT_Materials addOreByProducts(final GT_Materials... aMaterials) { + for (final GT_Materials tMaterial : aMaterials) { + if (tMaterial != null) { + this.addOreByProduct(tMaterial); + } + } + return this; + } + + /** + * If this Ore gives multiple drops of its Main Material. + * Lapis Ore for example gives about 6 drops. + */ + public GT_Materials setOreMultiplier(final int aOreMultiplier) { + if (aOreMultiplier > 0) { + this.mOreMultiplier = aOreMultiplier; + } + return this; + } + + /** + * If this Ore gives multiple drops of its Byproduct Material. + */ + public GT_Materials setByProductMultiplier(final int aByProductMultiplier) { + if (aByProductMultiplier > 0) { + this.mByProductMultiplier = aByProductMultiplier; + } + return this; + } + + /** + * If this Ore gives multiple drops of its Main Material. + * Lapis Ore for example gives about 6 drops. + */ + public GT_Materials setSmeltingMultiplier(final int aSmeltingMultiplier) { + if (aSmeltingMultiplier > 0) { + this.mSmeltingMultiplier = aSmeltingMultiplier; + } + return this; + } + + /** + * This Ore should be smolten directly into an Ingot of this Material instead of an Ingot of itself. + */ + public GT_Materials setDirectSmelting(final GT_Materials aMaterial) { + if (aMaterial != null) { + this.mDirectSmelting = aMaterial.mMaterialInto.mDirectSmelting; + } + return this; + } + + /** + * This Material should be the Main Material this Ore gets ground into. + * Example, Chromite giving Chrome or Tungstate giving Tungsten. + */ + public GT_Materials setOreReplacement(final GT_Materials aMaterial) { + if (aMaterial != null) { + this.mOreReplacement = aMaterial.mMaterialInto.mOreReplacement; + } + return this; + } + + /** + * This Material smelts always into an instance of aMaterial. Used for Magnets. + */ + public GT_Materials setSmeltingInto(final GT_Materials aMaterial) { + if (aMaterial != null) { + this.mSmeltInto = aMaterial.mMaterialInto.mSmeltInto; + } + return this; + } + + /** + * This Material arc smelts always into an instance of aMaterial. Used for Wrought Iron. + */ + public GT_Materials setArcSmeltingInto(final GT_Materials aMaterial) { + if (aMaterial != null) { + this.mArcSmeltInto = aMaterial.mMaterialInto.mArcSmeltInto; + } + return this; + } + + /** + * This Material macerates always into an instance of aMaterial. + */ + public GT_Materials setMaceratingInto(final GT_Materials aMaterial) { + if (aMaterial != null) { + this.mMacerateInto = aMaterial.mMaterialInto.mMacerateInto; + } + return this; + } + + public GT_Materials setEnchantmentForTools(final Enchantment aEnchantment, final int aEnchantmentLevel) { + this.mEnchantmentTools = aEnchantment; + this.mEnchantmentToolsLevel = (byte) aEnchantmentLevel; + return this; + } + + public GT_Materials setEnchantmentForArmors(final Enchantment aEnchantment, final int aEnchantmentLevel) { + this.mEnchantmentArmors = aEnchantment; + this.mEnchantmentArmorsLevel = (byte) aEnchantmentLevel; + return this; + } + + public FluidStack getSolid(final long aAmount) { + if (this.mSolid == null) { + return null; + } + return new GT_FluidStack(this.mSolid, (int) aAmount); + } + + public FluidStack getFluid(final long aAmount) { + if (this.mFluid == null) { + return null; + } + return new GT_FluidStack(this.mFluid, (int) aAmount); + } + + public FluidStack getGas(final long aAmount) { + if (this.mGas == null) { + return null; + } + return new GT_FluidStack(this.mGas, (int) aAmount); + } + + public FluidStack getPlasma(final long aAmount) { + if (this.mPlasma == null) { + return null; + } + return new GT_FluidStack(this.mPlasma, (int) aAmount); + } + + public FluidStack getMolten(final long aAmount) { + if (this.mStandardMoltenFluid == null) { + return null; + } + return new GT_FluidStack(this.mStandardMoltenFluid, (int) aAmount); + } + + @Override + public short[] getRGBA() { + return this.mRGBa; + } + + public static volatile int VERSION = 508; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechTextureSet.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechTextureSet.java index 26ee2bd401..4874e84b7b 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechTextureSet.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechTextureSet.java @@ -4,141 +4,167 @@ import gregtech.api.enums.Textures; import gregtech.api.interfaces.IIconContainer; public class GregtechTextureSet { - public static final GregtechTextureSet - SET_NONE = new GregtechTextureSet("NONE"), SET_DULL = new GregtechTextureSet("DULL"), SET_RUBY = new GregtechTextureSet("RUBY"), SET_OPAL = new GregtechTextureSet("OPAL"), SET_LEAF = new GregtechTextureSet("LEAF"), SET_WOOD = new GregtechTextureSet("WOOD"), SET_SAND = new GregtechTextureSet("SAND"), SET_FINE = new GregtechTextureSet("FINE"), SET_FIERY = new GregtechTextureSet("FIERY"), SET_FLUID = new GregtechTextureSet("FLUID"), SET_ROUGH = new GregtechTextureSet("ROUGH"), SET_PAPER = new GregtechTextureSet("PAPER"), SET_GLASS = new GregtechTextureSet("GLASS"), SET_FLINT = new GregtechTextureSet("FLINT"), SET_LAPIS = new GregtechTextureSet("LAPIS"), SET_SHINY = new GregtechTextureSet("SHINY"), SET_SHARDS = new GregtechTextureSet("SHARDS"), SET_POWDER = new GregtechTextureSet("POWDER"), SET_QUARTZ = new GregtechTextureSet("QUARTZ"), SET_EMERALD = new GregtechTextureSet("EMERALD"), SET_DIAMOND = new GregtechTextureSet("DIAMOND"), SET_LIGNITE = new GregtechTextureSet("LIGNITE"), SET_MAGNETIC = new GregtechTextureSet("MAGNETIC"), SET_METALLIC = new GregtechTextureSet("METALLIC"), SET_NETHERSTAR = new GregtechTextureSet("NETHERSTAR"), SET_GEM_VERTICAL = new GregtechTextureSet("GEM_VERTICAL"), SET_GEM_HORIZONTAL = new GregtechTextureSet("GEM_HORIZONTAL"); + public static final GregtechTextureSet SET_NONE = new GregtechTextureSet("NONE"), + SET_DULL = new GregtechTextureSet("DULL"), + SET_RUBY = new GregtechTextureSet("RUBY"), + SET_OPAL = new GregtechTextureSet("OPAL"), + SET_LEAF = new GregtechTextureSet("LEAF"), + SET_WOOD = new GregtechTextureSet("WOOD"), + SET_SAND = new GregtechTextureSet("SAND"), + SET_FINE = new GregtechTextureSet("FINE"), + SET_FIERY = new GregtechTextureSet("FIERY"), + SET_FLUID = new GregtechTextureSet("FLUID"), + SET_ROUGH = new GregtechTextureSet("ROUGH"), + SET_PAPER = new GregtechTextureSet("PAPER"), + SET_GLASS = new GregtechTextureSet("GLASS"), + SET_FLINT = new GregtechTextureSet("FLINT"), + SET_LAPIS = new GregtechTextureSet("LAPIS"), + SET_SHINY = new GregtechTextureSet("SHINY"), + SET_SHARDS = new GregtechTextureSet("SHARDS"), + SET_POWDER = new GregtechTextureSet("POWDER"), + SET_QUARTZ = new GregtechTextureSet("QUARTZ"), + SET_EMERALD = new GregtechTextureSet("EMERALD"), + SET_DIAMOND = new GregtechTextureSet("DIAMOND"), + SET_LIGNITE = new GregtechTextureSet("LIGNITE"), + SET_MAGNETIC = new GregtechTextureSet("MAGNETIC"), + SET_METALLIC = new GregtechTextureSet("METALLIC"), + SET_NETHERSTAR = new GregtechTextureSet("NETHERSTAR"), + SET_GEM_VERTICAL = new GregtechTextureSet("GEM_VERTICAL"), + SET_GEM_HORIZONTAL = new GregtechTextureSet("GEM_HORIZONTAL"); - public final IIconContainer[] mTextures = new IIconContainer[128]; - public final String mSetName; + public final IIconContainer[] mTextures = new IIconContainer[128]; + public final String mSetName; - public GregtechTextureSet(final String aSetName) { - this.mSetName = aSetName; - this.mTextures[0] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/turbineBlade"); - this.mTextures[1] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/toolHeadSkookumChoocher"); - this.mTextures[2] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[3] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[4] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[5] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[6] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[7] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[8] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[9] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[10] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[11] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[12] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[13] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[14] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[15] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[16] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[17] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[18] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[19] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[20] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[21] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[22] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[23] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[24] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[25] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[26] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[27] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[28] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[29] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[30] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[31] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[32] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[33] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[34] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[35] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[36] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[37] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[38] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[39] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[40] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[41] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[42] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[43] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[44] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[45] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[46] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[47] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[48] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[49] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[50] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[51] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[52] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[53] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[54] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[55] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[56] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[57] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[58] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[59] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[60] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[61] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[62] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[63] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[64] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[65] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[66] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[67] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[68] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[69] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[70] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[71] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[72] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[73] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[74] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[75] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[76] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[77] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[78] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[79] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[80] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[81] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[82] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[83] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[84] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[85] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[86] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[87] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[88] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[89] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[90] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[91] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[92] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[93] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[94] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[95] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[96] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[97] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[98] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[99] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[100] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[101] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[102] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[103] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[104] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[105] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[106] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[107] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[108] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[109] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[110] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[111] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[112] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[113] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[114] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[115] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[116] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[117] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[118] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[119] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[120] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[121] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[122] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[123] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[124] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[125] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[126] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - this.mTextures[127] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); - } -}
\ No newline at end of file + public GregtechTextureSet(final String aSetName) { + this.mSetName = aSetName; + this.mTextures[0] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/turbineBlade"); + this.mTextures[1] = + new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/toolHeadSkookumChoocher"); + this.mTextures[2] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[3] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[4] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[5] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[6] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[7] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[8] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[9] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[10] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[11] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[12] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[13] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[14] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[15] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[16] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[17] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[18] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[19] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[20] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[21] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[22] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[23] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[24] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[25] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[26] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[27] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[28] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[29] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[30] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[31] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[32] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[33] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[34] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[35] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[36] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[37] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[38] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[39] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[40] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[41] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[42] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[43] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[44] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[45] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[46] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[47] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[48] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[49] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[50] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[51] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[52] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[53] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[54] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[55] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[56] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[57] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[58] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[59] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[60] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[61] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[62] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[63] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[64] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[65] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[66] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[67] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[68] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[69] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[70] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[71] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[72] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[73] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[74] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[75] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[76] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[77] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[78] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[79] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[80] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[81] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[82] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[83] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[84] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[85] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[86] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[87] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[88] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[89] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[90] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[91] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[92] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[93] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[94] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[95] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[96] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[97] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[98] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[99] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[100] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[101] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[102] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[103] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[104] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[105] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[106] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[107] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[108] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[109] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[110] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[111] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[112] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[113] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[114] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[115] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[116] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[117] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[118] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[119] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[120] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[121] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[122] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[123] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[124] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[125] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[126] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[127] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechTextures.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechTextures.java index 5b1a34590f..b4251bd646 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechTextures.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechTextures.java @@ -1,120 +1,130 @@ package gtPlusPlus.xmod.gregtech.api.enums; -import net.minecraft.client.renderer.texture.TextureMap; -import net.minecraft.util.IIcon; -import net.minecraft.util.ResourceLocation; - import gtPlusPlus.core.lib.CORE; import gtPlusPlus.xmod.gregtech.api.interfaces.internal.Interface_IconContainer; import gtPlusPlus.xmod.gregtech.api.interfaces.internal.Interface_Texture; import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; public class GregtechTextures { - public enum BlockIcons implements Interface_IconContainer, Runnable { - - VOID, - - LARGECENTRIFUGE1, LARGECENTRIFUGE2, LARGECENTRIFUGE3, - LARGECENTRIFUGE4, LARGECENTRIFUGE5, LARGECENTRIFUGE6, - LARGECENTRIFUGE7, LARGECENTRIFUGE8, LARGECENTRIFUGE9, - LARGECENTRIFUGE_ACTIVE1, LARGECENTRIFUGE_ACTIVE2, LARGECENTRIFUGE_ACTIVE3, - LARGECENTRIFUGE_ACTIVE4, LARGECENTRIFUGE_ACTIVE5, LARGECENTRIFUGE_ACTIVE6, - LARGECENTRIFUGE_ACTIVE7, LARGECENTRIFUGE_ACTIVE8, LARGECENTRIFUGE_ACTIVE9; - - public static final Interface_IconContainer[] - - CENTRIFUGE = new Interface_IconContainer[]{ - LARGECENTRIFUGE1, - LARGECENTRIFUGE2, - LARGECENTRIFUGE3, - LARGECENTRIFUGE4, - LARGECENTRIFUGE5, - LARGECENTRIFUGE6, - LARGECENTRIFUGE7, - LARGECENTRIFUGE8, - LARGECENTRIFUGE9 - }, - CENTRIFUGE_ACTIVE = new Interface_IconContainer[]{ - LARGECENTRIFUGE_ACTIVE1, - LARGECENTRIFUGE_ACTIVE2, - LARGECENTRIFUGE_ACTIVE3, - LARGECENTRIFUGE_ACTIVE4, - LARGECENTRIFUGE_ACTIVE5, - LARGECENTRIFUGE_ACTIVE6, - LARGECENTRIFUGE_ACTIVE7, - LARGECENTRIFUGE_ACTIVE8, - LARGECENTRIFUGE_ACTIVE9 - }; - - public static Interface_Texture[] - GT_CASING_BLOCKS = new Interface_Texture[64]; - - protected IIcon mIcon; - - private BlockIcons() { - Meta_GT_Proxy.GT_BlockIconload.add(this); - } - - @Override - public IIcon getIcon() { - return this.mIcon; - } - - @Override - public IIcon getOverlayIcon() { - return null; - } - - @Override - public void run() { - this.mIcon = Meta_GT_Proxy.sBlockIcons.registerIcon(CORE.MODID + ":" + "iconsets/" + this); - } - - @Override - public ResourceLocation getTextureFile() { - return TextureMap.locationBlocksTexture; - } - - public static class CustomIcon implements Interface_IconContainer, Runnable { - protected IIcon mIcon; - protected String mIconName; - - public CustomIcon(final String aIconName) { - this.mIconName = aIconName; - Meta_GT_Proxy.GT_BlockIconload.add(this); - } - - @Override - public IIcon getIcon() { - return this.mIcon; - } - - @Override - public IIcon getOverlayIcon() { - return null; - } - - @Override - public void run() { - this.mIcon = Meta_GT_Proxy.sBlockIcons.registerIcon(CORE.MODID + ":" + this.mIconName); - } - - @Override - public ResourceLocation getTextureFile() { - return TextureMap.locationBlocksTexture; - } - } - } - - - public enum ItemIcons implements Interface_IconContainer, Runnable { - VOID, // The Empty Texture - RENDERING_ERROR, //The Purple/Black Texture - SKOOKUMCHOOCHER, //The Skookum Tool Texture - PUMP, // The Hand Pump Texture - TURBINE_SMALL, TURBINE_LARGE, TURBINE_HUGE; - - /* public static final Interface_IconContainer[] + public enum BlockIcons implements Interface_IconContainer, Runnable { + VOID, + + LARGECENTRIFUGE1, + LARGECENTRIFUGE2, + LARGECENTRIFUGE3, + LARGECENTRIFUGE4, + LARGECENTRIFUGE5, + LARGECENTRIFUGE6, + LARGECENTRIFUGE7, + LARGECENTRIFUGE8, + LARGECENTRIFUGE9, + LARGECENTRIFUGE_ACTIVE1, + LARGECENTRIFUGE_ACTIVE2, + LARGECENTRIFUGE_ACTIVE3, + LARGECENTRIFUGE_ACTIVE4, + LARGECENTRIFUGE_ACTIVE5, + LARGECENTRIFUGE_ACTIVE6, + LARGECENTRIFUGE_ACTIVE7, + LARGECENTRIFUGE_ACTIVE8, + LARGECENTRIFUGE_ACTIVE9; + public static final Interface_IconContainer[] + CENTRIFUGE = + new Interface_IconContainer[] { + LARGECENTRIFUGE1, + LARGECENTRIFUGE2, + LARGECENTRIFUGE3, + LARGECENTRIFUGE4, + LARGECENTRIFUGE5, + LARGECENTRIFUGE6, + LARGECENTRIFUGE7, + LARGECENTRIFUGE8, + LARGECENTRIFUGE9 + }, + CENTRIFUGE_ACTIVE = + new Interface_IconContainer[] { + LARGECENTRIFUGE_ACTIVE1, + LARGECENTRIFUGE_ACTIVE2, + LARGECENTRIFUGE_ACTIVE3, + LARGECENTRIFUGE_ACTIVE4, + LARGECENTRIFUGE_ACTIVE5, + LARGECENTRIFUGE_ACTIVE6, + LARGECENTRIFUGE_ACTIVE7, + LARGECENTRIFUGE_ACTIVE8, + LARGECENTRIFUGE_ACTIVE9 + }; + + public static Interface_Texture[] GT_CASING_BLOCKS = new Interface_Texture[64]; + + protected IIcon mIcon; + + private BlockIcons() { + Meta_GT_Proxy.GT_BlockIconload.add(this); + } + + @Override + public IIcon getIcon() { + return this.mIcon; + } + + @Override + public IIcon getOverlayIcon() { + return null; + } + + @Override + public void run() { + this.mIcon = Meta_GT_Proxy.sBlockIcons.registerIcon(CORE.MODID + ":" + "iconsets/" + this); + } + + @Override + public ResourceLocation getTextureFile() { + return TextureMap.locationBlocksTexture; + } + + public static class CustomIcon implements Interface_IconContainer, Runnable { + protected IIcon mIcon; + protected String mIconName; + + public CustomIcon(final String aIconName) { + this.mIconName = aIconName; + Meta_GT_Proxy.GT_BlockIconload.add(this); + } + + @Override + public IIcon getIcon() { + return this.mIcon; + } + + @Override + public IIcon getOverlayIcon() { + return null; + } + + @Override + public void run() { + this.mIcon = Meta_GT_Proxy.sBlockIcons.registerIcon(CORE.MODID + ":" + this.mIconName); + } + + @Override + public ResourceLocation getTextureFile() { + return TextureMap.locationBlocksTexture; + } + } + } + + public enum ItemIcons implements Interface_IconContainer, Runnable { + VOID, // The Empty Texture + RENDERING_ERROR, // The Purple/Black Texture + SKOOKUMCHOOCHER, // The Skookum Tool Texture + PUMP, // The Hand Pump Texture + TURBINE_SMALL, + TURBINE_LARGE, + TURBINE_HUGE; + + /* public static final Interface_IconContainer[] DURABILITY_BAR = new Interface_IconContainer[]{ DURABILITY_BAR_0, DURABILITY_BAR_1, @@ -138,66 +148,65 @@ public class GregtechTextures { ENERGY_BAR_8, };*/ - //public static final Interface_Texture[] ERROR_RENDERING = new Interface_Texture[]{new GregtechRenderedTexture(RENDERING_ERROR)}; - - protected IIcon mIcon, mOverlay; - - private ItemIcons() { - Meta_GT_Proxy.GT_ItemIconload.add(this); - } - - @Override - public IIcon getIcon() { - return this.mIcon; - } - - @Override - public IIcon getOverlayIcon() { - return this.mOverlay; - } - - @Override - public ResourceLocation getTextureFile() { - return TextureMap.locationItemsTexture; - } - - @Override - public void run() { - this.mIcon = Meta_GT_Proxy.sItemIcons.registerIcon(CORE.MODID+ ":" + "iconsets/" + this); - this.mOverlay = Meta_GT_Proxy.sItemIcons.registerIcon(CORE.MODID+ ":" + "iconsets/" + this + "_OVERLAY"); - } - - public static class CustomIcon implements Interface_IconContainer, Runnable { - protected IIcon mIcon, mOverlay; - protected String mIconName; - - public CustomIcon(final String aIconName) { - this.mIconName = aIconName; - Meta_GT_Proxy.GT_ItemIconload.add(this); - } - - @Override - public IIcon getIcon() { - return this.mIcon; - } - - @Override - public IIcon getOverlayIcon() { - return this.mOverlay; - } - - @Override - public void run() { - this.mIcon = Meta_GT_Proxy.sItemIcons.registerIcon(CORE.MODID+ ":" + this.mIconName); - this.mOverlay = Meta_GT_Proxy.sItemIcons.registerIcon(CORE.MODID+ ":" + this.mIconName + "_OVERLAY"); - } - - @Override - public ResourceLocation getTextureFile() { - return TextureMap.locationItemsTexture; - } - } - } - + // public static final Interface_Texture[] ERROR_RENDERING = new Interface_Texture[]{new + // GregtechRenderedTexture(RENDERING_ERROR)}; + + protected IIcon mIcon, mOverlay; + + private ItemIcons() { + Meta_GT_Proxy.GT_ItemIconload.add(this); + } + + @Override + public IIcon getIcon() { + return this.mIcon; + } + + @Override + public IIcon getOverlayIcon() { + return this.mOverlay; + } + + @Override + public ResourceLocation getTextureFile() { + return TextureMap.locationItemsTexture; + } + + @Override + public void run() { + this.mIcon = Meta_GT_Proxy.sItemIcons.registerIcon(CORE.MODID + ":" + "iconsets/" + this); + this.mOverlay = Meta_GT_Proxy.sItemIcons.registerIcon(CORE.MODID + ":" + "iconsets/" + this + "_OVERLAY"); + } + + public static class CustomIcon implements Interface_IconContainer, Runnable { + protected IIcon mIcon, mOverlay; + protected String mIconName; + + public CustomIcon(final String aIconName) { + this.mIconName = aIconName; + Meta_GT_Proxy.GT_ItemIconload.add(this); + } + + @Override + public IIcon getIcon() { + return this.mIcon; + } + + @Override + public IIcon getOverlayIcon() { + return this.mOverlay; + } + + @Override + public void run() { + this.mIcon = Meta_GT_Proxy.sItemIcons.registerIcon(CORE.MODID + ":" + this.mIconName); + this.mOverlay = Meta_GT_Proxy.sItemIcons.registerIcon(CORE.MODID + ":" + this.mIconName + "_OVERLAY"); + } + + @Override + public ResourceLocation getTextureFile() { + return TextureMap.locationItemsTexture; + } + } + } } - diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechToolDictNames.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechToolDictNames.java index 105023065c..bae91b53fe 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechToolDictNames.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechToolDictNames.java @@ -1,7 +1,10 @@ package gtPlusPlus.xmod.gregtech.api.enums; public enum GregtechToolDictNames { - - craftingToolSkookumChoocher, craftingToolHandPump, craftingToolAngleGrinder, craftingToolElectricSnips, craftingToolElectricLighter, craftingToolElectricButcherKnife; - -}
\ No newline at end of file + craftingToolSkookumChoocher, + craftingToolHandPump, + craftingToolAngleGrinder, + craftingToolElectricSnips, + craftingToolElectricLighter, + craftingToolElectricButcherKnife; +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_AdvancedBoiler.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_AdvancedBoiler.java index 04d8d91201..005485cbde 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_AdvancedBoiler.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_AdvancedBoiler.java @@ -1,32 +1,27 @@ package gtPlusPlus.xmod.gregtech.api.gui; -import java.util.Iterator; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.ICrafting; -import net.minecraft.inventory.Slot; - import gregtech.api.gui.GT_ContainerMetaTile_Machine; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; - import gtPlusPlus.xmod.gregtech.common.tileentities.generators.GT_MetaTileEntity_Boiler_Base; +import java.util.Iterator; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.Slot; -public class CONTAINER_AdvancedBoiler - extends GT_ContainerMetaTile_Machine { +public class CONTAINER_AdvancedBoiler extends GT_ContainerMetaTile_Machine { public int mWaterAmount = 0; public int mSteamAmount = 0; public int mProcessingEnergy = 0; public int mTemperature = 2; - + public CONTAINER_AdvancedBoiler(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { super(aInventoryPlayer, aTileEntity); } @Override - public void addSlots(InventoryPlayer aInventoryPlayer) { + public void addSlots(InventoryPlayer aInventoryPlayer) { addSlotToContainer(new Slot(this.mTileEntity, 2, 116, 62)); addSlotToContainer(new Slot(this.mTileEntity, 0, 44, 26)); addSlotToContainer(new Slot(this.mTileEntity, 1, 44, 62)); @@ -34,33 +29,47 @@ public class CONTAINER_AdvancedBoiler } @Override - public int getSlotCount() { + public int getSlotCount() { return 4; } @Override - public int getShiftClickSlotCount() { + public int getShiftClickSlotCount() { return 1; } @Override - public void detectAndSendChanges() { + public void detectAndSendChanges() { super.detectAndSendChanges(); if ((this.mTileEntity.isClientSide()) || (this.mTileEntity.getMetaTileEntity() == null)) { return; } - + int steamCapacity = ((GT_MetaTileEntity_Boiler_Base) this.mTileEntity.getMetaTileEntity()).getSteamCapacity(); int waterCapacity = ((GT_MetaTileEntity_Boiler_Base) this.mTileEntity.getMetaTileEntity()).getCapacity(); this.mTemperature = ((GT_MetaTileEntity_Boiler_Base) this.mTileEntity.getMetaTileEntity()).mTemperature; - this.mProcessingEnergy = ((GT_MetaTileEntity_Boiler_Base) this.mTileEntity.getMetaTileEntity()).mProcessingEnergy; - this.mSteamAmount = (((GT_MetaTileEntity_Boiler_Base) this.mTileEntity.getMetaTileEntity()).mSteam == null ? 0 : ((GT_MetaTileEntity_Boiler_Base) this.mTileEntity.getMetaTileEntity()).mSteam.amount); - this.mWaterAmount = (((GT_MetaTileEntity_Boiler_Base) this.mTileEntity.getMetaTileEntity()).mFluid == null ? 0 : ((GT_MetaTileEntity_Boiler_Base) this.mTileEntity.getMetaTileEntity()).mFluid.amount); + this.mProcessingEnergy = + ((GT_MetaTileEntity_Boiler_Base) this.mTileEntity.getMetaTileEntity()).mProcessingEnergy; + this.mSteamAmount = (((GT_MetaTileEntity_Boiler_Base) this.mTileEntity.getMetaTileEntity()).mSteam == null + ? 0 + : ((GT_MetaTileEntity_Boiler_Base) this.mTileEntity.getMetaTileEntity()).mSteam.amount); + this.mWaterAmount = (((GT_MetaTileEntity_Boiler_Base) this.mTileEntity.getMetaTileEntity()).mFluid == null + ? 0 + : ((GT_MetaTileEntity_Boiler_Base) this.mTileEntity.getMetaTileEntity()).mFluid.amount); - this.mTemperature = Math.min(54, Math.max(0, this.mTemperature * 54 / (((GT_MetaTileEntity_Boiler_Base) this.mTileEntity.getMetaTileEntity()).maxProgresstime() - 10))); + this.mTemperature = Math.min( + 54, + Math.max( + 0, + this.mTemperature + * 54 + / (((GT_MetaTileEntity_Boiler_Base) this.mTileEntity.getMetaTileEntity()) + .maxProgresstime() + - 10))); this.mSteamAmount = Math.min(54, Math.max(0, this.mSteamAmount * 54 / (steamCapacity - 100))); this.mWaterAmount = Math.min(54, Math.max(0, this.mWaterAmount * 54 / (waterCapacity - 100))); - this.mProcessingEnergy = Math.min(14, Math.max(this.mProcessingEnergy > 0 ? 1 : 0, this.mProcessingEnergy * 14 / 1000)); + this.mProcessingEnergy = + Math.min(14, Math.max(this.mProcessingEnergy > 0 ? 1 : 0, this.mProcessingEnergy * 14 / 1000)); Iterator<?> var2 = this.crafters.iterator(); while (var2.hasNext()) { @@ -73,7 +82,7 @@ public class CONTAINER_AdvancedBoiler } @Override - @SideOnly(Side.CLIENT) + @SideOnly(Side.CLIENT) public void updateProgressBar(int par1, int par2) { super.updateProgressBar(par1, par2); switch (par1) { diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_Cyclotron.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_Cyclotron.java index 6d0eb6b14c..f11a943e44 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_Cyclotron.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_Cyclotron.java @@ -11,27 +11,30 @@ import net.minecraft.entity.player.InventoryPlayer; */ public class CONTAINER_Cyclotron extends GT_ContainerMetaTile_Machine { - public CONTAINER_Cyclotron(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity) { - - super(aInventoryPlayer, aTileEntity); - } - - public CONTAINER_Cyclotron(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity, final boolean bindInventory) { - super(aInventoryPlayer, aTileEntity, bindInventory); - } - - @Override - public void addSlots(final InventoryPlayer aInventoryPlayer) { - //this.addSlotToContainer(new Slot(this.mTileEntity, 1, 154, 42)); - } - - @Override - public int getSlotCount() { - return 0; - } - - @Override - public int getShiftClickSlotCount() { - return 0; - } + public CONTAINER_Cyclotron(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity) { + + super(aInventoryPlayer, aTileEntity); + } + + public CONTAINER_Cyclotron( + final InventoryPlayer aInventoryPlayer, + final IGregTechTileEntity aTileEntity, + final boolean bindInventory) { + super(aInventoryPlayer, aTileEntity, bindInventory); + } + + @Override + public void addSlots(final InventoryPlayer aInventoryPlayer) { + // this.addSlotToContainer(new Slot(this.mTileEntity, 1, 154, 42)); + } + + @Override + public int getSlotCount() { + return 0; + } + + @Override + public int getShiftClickSlotCount() { + return 0; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_DataHatch.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_DataHatch.java index fe100955e0..0951c231d5 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_DataHatch.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_DataHatch.java @@ -3,9 +3,7 @@ package gtPlusPlus.xmod.gregtech.api.gui; import gregtech.api.enums.ItemList; import gregtech.api.gui.GT_ContainerMetaTile_Machine; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.slots.SlotIntegratedCircuit; -import gtPlusPlus.core.util.minecraft.ItemUtils; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; @@ -36,7 +34,6 @@ public class CONTAINER_DataHatch extends GT_ContainerMetaTile_Machine { addSlotToContainer(new GT_Slot_DataOrb(mTileEntity, 14, 89, 62)); addSlotToContainer(new GT_Slot_DataOrb(mTileEntity, 15, 107, 62)); addSlotToContainer(new SlotIntegratedCircuit(mTileEntity, 16, 19, 35)); - } @Override @@ -48,23 +45,23 @@ public class CONTAINER_DataHatch extends GT_ContainerMetaTile_Machine { public int getShiftClickSlotCount() { return 0; } - - @Override - public void putStackInSlot(int par1, ItemStack par2ItemStack) { - /*Logger.INFO("Slot: "+par1); - if (par1 < 16 && ItemList.Tool_DataOrb.isStackEqual(par2ItemStack)) { - super.putStackInSlot(par1, par2ItemStack); - } - if (par1 == 16 && ItemUtils.isControlCircuit(par2ItemStack)) { - super.putStackInSlot(par1, par2ItemStack); - }*/ - super.putStackInSlot(par1, par2ItemStack); - } - @Override - public boolean canDragIntoSlot(Slot par1Slot) { - return super.canDragIntoSlot(par1Slot); - } + @Override + public void putStackInSlot(int par1, ItemStack par2ItemStack) { + /*Logger.INFO("Slot: "+par1); + if (par1 < 16 && ItemList.Tool_DataOrb.isStackEqual(par2ItemStack)) { + super.putStackInSlot(par1, par2ItemStack); + } + if (par1 == 16 && ItemUtils.isControlCircuit(par2ItemStack)) { + super.putStackInSlot(par1, par2ItemStack); + }*/ + super.putStackInSlot(par1, par2ItemStack); + } + + @Override + public boolean canDragIntoSlot(Slot par1Slot) { + return super.canDragIntoSlot(par1Slot); + } public class GT_Slot_DataOrb extends Slot { public GT_Slot_DataOrb(IInventory par1iInventory, int par2, int par3, int par4) { @@ -76,7 +73,4 @@ public class CONTAINER_DataHatch extends GT_ContainerMetaTile_Machine { return ItemList.Tool_DataOrb.isStackEqual(aStack, false, true); } } - - - } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_DeluxeTank.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_DeluxeTank.java index a4508781aa..e0698f9d24 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_DeluxeTank.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_DeluxeTank.java @@ -1,20 +1,16 @@ package gtPlusPlus.xmod.gregtech.api.gui; -import java.util.Iterator; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.ICrafting; -import net.minecraft.inventory.Slot; - import gregtech.api.gui.GT_Container_BasicTank; import gregtech.api.gui.GT_Slot_Output; import gregtech.api.gui.GT_Slot_Render; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; - import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_DeluxeTank; +import java.util.Iterator; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.Slot; /** * NEVER INCLUDE THIS FILE IN YOUR MOD!!! @@ -23,58 +19,58 @@ import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEn */ public class CONTAINER_DeluxeTank extends GT_Container_BasicTank { - public CONTAINER_DeluxeTank(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity) { - super(aInventoryPlayer, aTileEntity); - } + public CONTAINER_DeluxeTank(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity) { + super(aInventoryPlayer, aTileEntity); + } - @Override - public void addSlots(final InventoryPlayer aInventoryPlayer) { - this.addSlotToContainer(new Slot(this.mTileEntity, 0, 80, 17)); - this.addSlotToContainer(new GT_Slot_Output(this.mTileEntity, 1, 80, 53)); - this.addSlotToContainer(new GT_Slot_Render(this.mTileEntity, 2, 41, 42)); - this.addSlotToContainer(new GT_Slot_Render(this.mTileEntity, 3, 59, 42)); - } + @Override + public void addSlots(final InventoryPlayer aInventoryPlayer) { + this.addSlotToContainer(new Slot(this.mTileEntity, 0, 80, 17)); + this.addSlotToContainer(new GT_Slot_Output(this.mTileEntity, 1, 80, 53)); + this.addSlotToContainer(new GT_Slot_Render(this.mTileEntity, 2, 41, 42)); + this.addSlotToContainer(new GT_Slot_Render(this.mTileEntity, 3, 59, 42)); + } - @Override - public void detectAndSendChanges() { - super.detectAndSendChanges(); - if (this.mTileEntity.isClientSide() || (this.mTileEntity.getMetaTileEntity() == null)) { - return; - } - if (((GT_MetaTileEntity_DeluxeTank) this.mTileEntity.getMetaTileEntity()).mFluid != null) { - this.mContent = ((GT_MetaTileEntity_DeluxeTank) this.mTileEntity.getMetaTileEntity()).mFluid.amount; - } else { - this.mContent = 0; - } - final Iterator var2 = this.crafters.iterator(); - while (var2.hasNext()) { - final ICrafting var1 = (ICrafting) var2.next(); - var1.sendProgressBarUpdate(this, 100, this.mContent & 65535); - var1.sendProgressBarUpdate(this, 101, this.mContent >>> 16); - } - } + @Override + public void detectAndSendChanges() { + super.detectAndSendChanges(); + if (this.mTileEntity.isClientSide() || (this.mTileEntity.getMetaTileEntity() == null)) { + return; + } + if (((GT_MetaTileEntity_DeluxeTank) this.mTileEntity.getMetaTileEntity()).mFluid != null) { + this.mContent = ((GT_MetaTileEntity_DeluxeTank) this.mTileEntity.getMetaTileEntity()).mFluid.amount; + } else { + this.mContent = 0; + } + final Iterator var2 = this.crafters.iterator(); + while (var2.hasNext()) { + final ICrafting var1 = (ICrafting) var2.next(); + var1.sendProgressBarUpdate(this, 100, this.mContent & 65535); + var1.sendProgressBarUpdate(this, 101, this.mContent >>> 16); + } + } - @Override - @SideOnly(Side.CLIENT) - public void updateProgressBar(final int par1, final int par2) { - super.updateProgressBar(par1, par2); - switch (par1) { - case 100: - this.mContent = (this.mContent & -65536) | par2; - break; - case 101: - this.mContent = (this.mContent & 65535) | (par2 << 16); - break; - } - } + @Override + @SideOnly(Side.CLIENT) + public void updateProgressBar(final int par1, final int par2) { + super.updateProgressBar(par1, par2); + switch (par1) { + case 100: + this.mContent = (this.mContent & -65536) | par2; + break; + case 101: + this.mContent = (this.mContent & 65535) | (par2 << 16); + break; + } + } - @Override - public int getSlotCount() { - return 2; - } + @Override + public int getSlotCount() { + return 2; + } - @Override - public int getShiftClickSlotCount() { - return 1; - } + @Override + public int getShiftClickSlotCount() { + return 1; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_Hatch_Muffler_Advanced.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_Hatch_Muffler_Advanced.java index 17226a399e..9031003349 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_Hatch_Muffler_Advanced.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_Hatch_Muffler_Advanced.java @@ -5,47 +5,49 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gtPlusPlus.core.slots.SlotAirFilter; import net.minecraft.entity.player.InventoryPlayer; - public class CONTAINER_Hatch_Muffler_Advanced extends GT_ContainerMetaTile_Machine { - public long maxEU = 0; - public long storedEU = 0; - - public CONTAINER_Hatch_Muffler_Advanced(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity) { - super(aInventoryPlayer, aTileEntity); - } - - public CONTAINER_Hatch_Muffler_Advanced(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity, final boolean bindInventory) { - super(aInventoryPlayer, aTileEntity, bindInventory); - } - - @Override - public void addSlots(final InventoryPlayer aInventoryPlayer) { - this.addSlotToContainer(new SlotAirFilter(this.mTileEntity, 0, 80, 35)); - } - - @Override - public int getSlotCount() { - return 1; - } - - @Override - public int getShiftClickSlotCount() { - return 1; - } - - @Override - public void updateProgressBar(final int id, final int value) { - super.updateProgressBar(id, value); - switch (id) { - default: - break; - } - } - - @Override - public void detectAndSendChanges() { - super.detectAndSendChanges(); - } - -}
\ No newline at end of file + public long maxEU = 0; + public long storedEU = 0; + + public CONTAINER_Hatch_Muffler_Advanced( + final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity) { + super(aInventoryPlayer, aTileEntity); + } + + public CONTAINER_Hatch_Muffler_Advanced( + final InventoryPlayer aInventoryPlayer, + final IGregTechTileEntity aTileEntity, + final boolean bindInventory) { + super(aInventoryPlayer, aTileEntity, bindInventory); + } + + @Override + public void addSlots(final InventoryPlayer aInventoryPlayer) { + this.addSlotToContainer(new SlotAirFilter(this.mTileEntity, 0, 80, 35)); + } + + @Override + public int getSlotCount() { + return 1; + } + + @Override + public int getShiftClickSlotCount() { + return 1; + } + + @Override + public void updateProgressBar(final int id, final int value) { + super.updateProgressBar(id, value); + switch (id) { + default: + break; + } + } + + @Override + public void detectAndSendChanges() { + super.detectAndSendChanges(); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_IndustrialCentrifuge.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_IndustrialCentrifuge.java index df8df2f775..a24288e877 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_IndustrialCentrifuge.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_IndustrialCentrifuge.java @@ -1,10 +1,9 @@ package gtPlusPlus.xmod.gregtech.api.gui; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Slot; - import gregtech.api.gui.GT_ContainerMetaTile_Machine; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Slot; /** * NEVER INCLUDE THIS FILE IN YOUR MOD!!! @@ -13,27 +12,31 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; */ public class CONTAINER_IndustrialCentrifuge extends GT_ContainerMetaTile_Machine { - public CONTAINER_IndustrialCentrifuge(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity) { - - super(aInventoryPlayer, aTileEntity); - } - - public CONTAINER_IndustrialCentrifuge(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity, final boolean bindInventory) { - super(aInventoryPlayer, aTileEntity, bindInventory); - } - - @Override - public void addSlots(final InventoryPlayer aInventoryPlayer) { - this.addSlotToContainer(new Slot(this.mTileEntity, 1, 154, 42)); - } - - @Override - public int getSlotCount() { - return 1; - } - - @Override - public int getShiftClickSlotCount() { - return 1; - } + public CONTAINER_IndustrialCentrifuge( + final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity) { + + super(aInventoryPlayer, aTileEntity); + } + + public CONTAINER_IndustrialCentrifuge( + final InventoryPlayer aInventoryPlayer, + final IGregTechTileEntity aTileEntity, + final boolean bindInventory) { + super(aInventoryPlayer, aTileEntity, bindInventory); + } + + @Override + public void addSlots(final InventoryPlayer aInventoryPlayer) { + this.addSlotToContainer(new Slot(this.mTileEntity, 1, 154, 42)); + } + + @Override + public int getSlotCount() { + return 1; + } + + @Override + public int getShiftClickSlotCount() { + return 1; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_IronBlastFurnace.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_IronBlastFurnace.java index 78150aedbe..483a1abc16 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_IronBlastFurnace.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_IronBlastFurnace.java @@ -1,32 +1,31 @@ package gtPlusPlus.xmod.gregtech.api.gui; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Slot; - import gregtech.api.gui.GT_ContainerMetaTile_Machine; import gregtech.api.gui.GT_Slot_Output; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Slot; public class CONTAINER_IronBlastFurnace extends GT_ContainerMetaTile_Machine { - public CONTAINER_IronBlastFurnace(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity) { - super(aInventoryPlayer, aTileEntity); - } + public CONTAINER_IronBlastFurnace(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity) { + super(aInventoryPlayer, aTileEntity); + } - @Override - public void addSlots(final InventoryPlayer aInventoryPlayer) { - this.addSlotToContainer(new Slot(this.mTileEntity, 0, 34, 16)); - this.addSlotToContainer(new Slot(this.mTileEntity, 1, 34, 34)); - this.addSlotToContainer(new GT_Slot_Output(this.mTileEntity, 2, 86, 25)); - this.addSlotToContainer(new GT_Slot_Output(this.mTileEntity, 3, 104, 25)); - } + @Override + public void addSlots(final InventoryPlayer aInventoryPlayer) { + this.addSlotToContainer(new Slot(this.mTileEntity, 0, 34, 16)); + this.addSlotToContainer(new Slot(this.mTileEntity, 1, 34, 34)); + this.addSlotToContainer(new GT_Slot_Output(this.mTileEntity, 2, 86, 25)); + this.addSlotToContainer(new GT_Slot_Output(this.mTileEntity, 3, 104, 25)); + } - @Override - public int getSlotCount() { - return 4; - } + @Override + public int getSlotCount() { + return 4; + } - @Override - public int getShiftClickSlotCount() { - return 2; - } + @Override + public int getShiftClickSlotCount() { + return 2; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_MatterFab.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_MatterFab.java index 93591b2aaf..43996e25c8 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_MatterFab.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_MatterFab.java @@ -1,13 +1,11 @@ package gtPlusPlus.xmod.gregtech.api.gui; -import java.util.Iterator; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.gui.GT_ContainerMetaTile_Machine; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gtPlusPlus.api.objects.Logger; import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.GregtechMetaTileEntity_MassFabricator; +import java.util.Iterator; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.ICrafting; @@ -17,24 +15,27 @@ import net.minecraft.inventory.ICrafting; * The Container I use for all my Basic Machines */ public class CONTAINER_MatterFab extends GT_ContainerMetaTile_Machine { - - public int mMatterProduced = 0; - public int mScrapProduced = 0; - public int mAmplifierProduced = 0; - public int mScrapUsed = 0; - public int mAmplifierUsed = 0; - public CONTAINER_MatterFab(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity) { - super(aInventoryPlayer, aTileEntity); - } + public int mMatterProduced = 0; + public int mScrapProduced = 0; + public int mAmplifierProduced = 0; + public int mScrapUsed = 0; + public int mAmplifierUsed = 0; + + public CONTAINER_MatterFab(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity) { + super(aInventoryPlayer, aTileEntity); + } - public CONTAINER_MatterFab(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity, final boolean bindInventory) { - super(aInventoryPlayer, aTileEntity, bindInventory); - } + public CONTAINER_MatterFab( + final InventoryPlayer aInventoryPlayer, + final IGregTechTileEntity aTileEntity, + final boolean bindInventory) { + super(aInventoryPlayer, aTileEntity, bindInventory); + } - @Override + @Override public void addSlots(InventoryPlayer aInventoryPlayer) { - //addSlotToContainer(new SlotNoInput(mTileEntity, 1, 152, 5)); + // addSlotToContainer(new SlotNoInput(mTileEntity, 1, 152, 5)); } @Override @@ -46,58 +47,58 @@ public class CONTAINER_MatterFab extends GT_ContainerMetaTile_Machine { public int getShiftClickSlotCount() { return 0; } - - @Override - public void detectAndSendChanges() { - super.detectAndSendChanges(); - if (mTileEntity.isClientSide() || mTileEntity.getMetaTileEntity() == null) { - return; - } - GregtechMetaTileEntity_MassFabricator aTile = ((GregtechMetaTileEntity_MassFabricator)this.mTileEntity.getMetaTileEntity()); - mAmplifierProduced = aTile.mAmplifierProduced; - mAmplifierUsed = aTile.mAmplifierUsed; - mMatterProduced = aTile.mMatterProduced; - mScrapProduced = aTile.mScrapProduced; - mScrapUsed = aTile.mScrapUsed; - - Iterator var2 = this.crafters.iterator(); - while (var2.hasNext()) { - ICrafting var1 = (ICrafting) var2.next(); - var1.sendProgressBarUpdate(this, 201, mAmplifierProduced); - var1.sendProgressBarUpdate(this, 202, mAmplifierUsed); - var1.sendProgressBarUpdate(this, 203, mMatterProduced); - var1.sendProgressBarUpdate(this, 204, mScrapProduced); - var1.sendProgressBarUpdate(this, 205, mScrapUsed); - } - } + @Override + public void detectAndSendChanges() { + super.detectAndSendChanges(); + if (mTileEntity.isClientSide() || mTileEntity.getMetaTileEntity() == null) { + return; + } + GregtechMetaTileEntity_MassFabricator aTile = + ((GregtechMetaTileEntity_MassFabricator) this.mTileEntity.getMetaTileEntity()); - @Override - public void addCraftingToCrafters(ICrafting par1ICrafting) { - super.addCraftingToCrafters(par1ICrafting); - } + mAmplifierProduced = aTile.mAmplifierProduced; + mAmplifierUsed = aTile.mAmplifierUsed; + mMatterProduced = aTile.mMatterProduced; + mScrapProduced = aTile.mScrapProduced; + mScrapUsed = aTile.mScrapUsed; - @Override - @SideOnly(Side.CLIENT) - public void updateProgressBar(int par1, int par2) { - super.updateProgressBar(par1, par2); - switch (par1) { - case 201: - mAmplifierProduced = (par2); - break; - case 202: - mAmplifierUsed = (par2); - break; - case 203: - mMatterProduced = (par2); - break; - case 204: - mScrapProduced = (par2); - break; - case 205: - mScrapUsed = (par2); - break; - } - } - + Iterator var2 = this.crafters.iterator(); + while (var2.hasNext()) { + ICrafting var1 = (ICrafting) var2.next(); + var1.sendProgressBarUpdate(this, 201, mAmplifierProduced); + var1.sendProgressBarUpdate(this, 202, mAmplifierUsed); + var1.sendProgressBarUpdate(this, 203, mMatterProduced); + var1.sendProgressBarUpdate(this, 204, mScrapProduced); + var1.sendProgressBarUpdate(this, 205, mScrapUsed); + } + } + + @Override + public void addCraftingToCrafters(ICrafting par1ICrafting) { + super.addCraftingToCrafters(par1ICrafting); + } + + @Override + @SideOnly(Side.CLIENT) + public void updateProgressBar(int par1, int par2) { + super.updateProgressBar(par1, par2); + switch (par1) { + case 201: + mAmplifierProduced = (par2); + break; + case 202: + mAmplifierUsed = (par2); + break; + case 203: + mMatterProduced = (par2); + break; + case 204: + mScrapProduced = (par2); + break; + case 205: + mScrapUsed = (par2); + break; + } + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_MetaTileMachineLong.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_MetaTileMachineLong.java index 6a3322ab2e..456d501fdc 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_MetaTileMachineLong.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_MetaTileMachineLong.java @@ -2,243 +2,255 @@ package gtPlusPlus.xmod.gregtech.api.gui; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - import gregtech.api.gui.GT_Container; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.util.GT_LanguageManager; - import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.Pair; - +import java.util.Iterator; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.ICrafting; -import java.util.Iterator; - public class CONTAINER_MetaTileMachineLong extends GT_Container { - public int mActive = 0, mMaxProgressTime = 0, mProgressTime = 0, mSteam = 0, mSteamStorage = 0, mOutput = 0, mInput = 0, mID = 0, mDisplayErrorCode = 0; - private int oActive = 0, oMaxProgressTime = 0, oProgressTime = 0, oSteam = 0, oSteamStorage = 0, oOutput = 0, oInput = 0, oID = 0, oDisplayErrorCode = 0, mTimer = 0; - - public long pEnergy, pStorage; - private long nEnergy, nStorage; - - public short pIntMaxCountCurrent, pIntMaxCountMax; - private short nIntMaxCountCurrent, nIntMaxCountMax; - - public CONTAINER_MetaTileMachineLong(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { - super(aInventoryPlayer, aTileEntity); - - mTileEntity = aTileEntity; - - if (mTileEntity != null && mTileEntity.getMetaTileEntity() != null) { - addSlots(aInventoryPlayer); - if (doesBindPlayerInventory()) bindPlayerInventory(aInventoryPlayer); - detectAndSendChanges(); - } else { - aInventoryPlayer.player.openContainer = aInventoryPlayer.player.inventoryContainer; - } - } - public CONTAINER_MetaTileMachineLong(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, boolean doesBindInventory) { - super(aInventoryPlayer, aTileEntity); - mTileEntity = aTileEntity; - - if (mTileEntity != null && mTileEntity.getMetaTileEntity() != null) { - addSlots(aInventoryPlayer); - if (doesBindPlayerInventory() && doesBindInventory) bindPlayerInventory(aInventoryPlayer); - detectAndSendChanges(); - } else { - aInventoryPlayer.player.openContainer = aInventoryPlayer.player.inventoryContainer; - } - } - - private Pair<Integer, Integer> getPowerStored(){ - final long mStoredPower = this.pEnergy; - long mMaxInts = (mStoredPower/Integer.MAX_VALUE); - long mLeftOver = (mStoredPower % Integer.MAX_VALUE); - if (mMaxInts < 0 || mMaxInts >= /*4294967298L*/ Integer.MAX_VALUE) { - return new Pair<Integer, Integer>(-1, 0); - } - if (mLeftOver < 0 || mLeftOver > Integer.MAX_VALUE) { - mLeftOver = 0; - } - Pair<Integer, Integer> power = new Pair<Integer, Integer>((int) mMaxInts, (int) mLeftOver); - return power; - } - - private Pair<Integer, Integer> getMaxPowerStored(){ - final long mMaxStoredPower = this.pStorage; - long mMaxInts = (mMaxStoredPower/Integer.MAX_VALUE); - long mLeftOver = (mMaxStoredPower % Integer.MAX_VALUE); - if (mMaxInts < 0 || mMaxInts >= /*4294967298L*/ Integer.MAX_VALUE) { - return new Pair<Integer, Integer>(-1, 0); - } - if (mLeftOver < 0 || mLeftOver > Integer.MAX_VALUE) { - mLeftOver = 0; - } - Pair<Integer, Integer> power = new Pair<Integer, Integer>((int) mMaxInts, (int) mLeftOver); - return power; - } - - @Override - public void detectAndSendChanges() { - super.detectAndSendChanges(); - if (mTileEntity.isClientSide() || mTileEntity.getMetaTileEntity() == null) return; - pStorage = Math.min(Long.MAX_VALUE, mTileEntity.getEUCapacity()); - pEnergy = Math.min(Long.MAX_VALUE, mTileEntity.getStoredEU()); - mSteamStorage = (int) Math.min(Integer.MAX_VALUE, mTileEntity.getSteamCapacity()); - mSteam = (int) Math.min(Integer.MAX_VALUE, mTileEntity.getStoredSteam()); - mOutput = (int) Math.min(Integer.MAX_VALUE, mTileEntity.getOutputVoltage()); - mInput = (int) Math.min(Integer.MAX_VALUE, mTileEntity.getInputVoltage()); - mDisplayErrorCode = mTileEntity.getErrorDisplayID(); - mProgressTime = mTileEntity.getProgress(); - mMaxProgressTime = mTileEntity.getMaxProgress(); - mActive = mTileEntity.isActive() ? 1 : 0; - mTimer++; - - Pair<Integer, Integer> powerPacket = getPowerStored(); - Pair<Integer, Integer> maxPowerPacket = getMaxPowerStored(); - - int mPacketsToSend = powerPacket.getKey(); - int mLeftOverPowerStored = powerPacket.getValue(); - - int mMaxStorageA = maxPowerPacket.getKey(); - int mMaxStorageB = maxPowerPacket.getValue(); - - //Someone has a VERY FULL power supply. - if (mPacketsToSend == -1) { - Logger.INFO("TOO MUCH MATH - USE BIGINTEGER - GAME BREAKING BUG MAY OCCUR"); - return; - } - - - Iterator var2 = this.crafters.iterator(); - while (var2.hasNext()) { - ICrafting var1 = (ICrafting) var2.next(); - if (mTimer % 500 == 10 || nEnergy != pEnergy) { - var1.sendProgressBarUpdate(this, 0, mLeftOverPowerStored & 65535); - var1.sendProgressBarUpdate(this, 1, mLeftOverPowerStored >>> 16); - var1.sendProgressBarUpdate(this, 7730, mPacketsToSend); - } - if (mTimer % 500 == 10 || nStorage != pStorage) { - var1.sendProgressBarUpdate(this, 2, mMaxStorageB & 65535); - var1.sendProgressBarUpdate(this, 3, mMaxStorageB >>> 16); - var1.sendProgressBarUpdate(this, 7731, mMaxStorageA); - } - if (mTimer % 500 == 10 || oOutput != mOutput) { - var1.sendProgressBarUpdate(this, 4, mOutput); - } - if (mTimer % 500 == 10 || oInput != mInput) { - var1.sendProgressBarUpdate(this, 5, mInput); - } - if (mTimer % 500 == 10 || oDisplayErrorCode != mDisplayErrorCode) { - var1.sendProgressBarUpdate(this, 6, mDisplayErrorCode); - } - if (mTimer % 500 == 10 || oProgressTime != mProgressTime) { - var1.sendProgressBarUpdate(this, 11, mProgressTime & 65535); - var1.sendProgressBarUpdate(this, 12, mProgressTime >>> 16); - } - if (mTimer % 500 == 10 || oMaxProgressTime != mMaxProgressTime) { - var1.sendProgressBarUpdate(this, 13, mMaxProgressTime & 65535); - var1.sendProgressBarUpdate(this, 14, mMaxProgressTime >>> 16); - } - if (mTimer % 500 == 10 || oID != mID) { - var1.sendProgressBarUpdate(this, 15, mID); - } - if (mTimer % 500 == 10 || oActive != mActive) { - var1.sendProgressBarUpdate(this, 16, mActive); - } - if (mTimer % 500 == 10 || oSteam != mSteam) { - var1.sendProgressBarUpdate(this, 17, mSteam & 65535); - var1.sendProgressBarUpdate(this, 18, mSteam >>> 16); - } - if (mTimer % 500 == 10 || oSteamStorage != mSteamStorage) { - var1.sendProgressBarUpdate(this, 19, mSteamStorage & 65535); - var1.sendProgressBarUpdate(this, 20, mSteamStorage >>> 16); - } - } - - oID = mID; - oSteam = mSteam; - oInput = mInput; - oActive = mActive; - oOutput = mOutput; - nEnergy = pEnergy; - nStorage = pStorage; - oSteamStorage = mSteamStorage; - oProgressTime = mProgressTime; - oMaxProgressTime = mMaxProgressTime; - oDisplayErrorCode = mDisplayErrorCode; - } - - @SideOnly(Side.CLIENT) - @Override - public void updateProgressBar(int par1, int par2) { - super.updateProgressBar(par1, par2); - switch (par1) { - /*case 7730: - pIntMaxCountCurrent = par2;*/ - case 0: - pEnergy = pEnergy & -65536 | par2; - break; - case 1: - pEnergy = pEnergy & 65535 | par2 << 16; - break; - case 2: - pStorage = pStorage & -65536 | par2; - break; - case 3: - pStorage = pStorage & 65535 | par2 << 16; - break; - case 4: - mOutput = par2; - break; - case 5: - mInput = par2; - break; - case 6: - mDisplayErrorCode = par2; - break; - case 11: - mProgressTime = mProgressTime & -65536 | par2; - break; - case 12: - mProgressTime = mProgressTime & 65535 | par2 << 16; - break; - case 13: - mMaxProgressTime = mMaxProgressTime & -65536 | par2; - break; - case 14: - mMaxProgressTime = mMaxProgressTime & 65535 | par2 << 16; - break; - case 15: - mID = par2; - break; - case 16: - mActive = par2; - break; - case 17: - mSteam = mSteam & -65536 | par2; - break; - case 18: - mSteam = mSteam & 65535 | par2 << 16; - break; - case 19: - mSteamStorage = mSteamStorage & -65536 | par2; - break; - case 20: - mSteamStorage = mSteamStorage & 65535 | par2 << 16; - break; - } - } - - @Override - public boolean canInteractWith(EntityPlayer player) { - return mTileEntity.isUseableByPlayer(player); - } - - public String trans(String aKey, String aEnglish){ - return GT_LanguageManager.addStringLocalization("Interaction_DESCRIPTION_Index_"+aKey, aEnglish, false); - } -}
\ No newline at end of file + public int mActive = 0, + mMaxProgressTime = 0, + mProgressTime = 0, + mSteam = 0, + mSteamStorage = 0, + mOutput = 0, + mInput = 0, + mID = 0, + mDisplayErrorCode = 0; + private int oActive = 0, + oMaxProgressTime = 0, + oProgressTime = 0, + oSteam = 0, + oSteamStorage = 0, + oOutput = 0, + oInput = 0, + oID = 0, + oDisplayErrorCode = 0, + mTimer = 0; + public long pEnergy, pStorage; + private long nEnergy, nStorage; + public short pIntMaxCountCurrent, pIntMaxCountMax; + private short nIntMaxCountCurrent, nIntMaxCountMax; + + public CONTAINER_MetaTileMachineLong(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { + super(aInventoryPlayer, aTileEntity); + + mTileEntity = aTileEntity; + + if (mTileEntity != null && mTileEntity.getMetaTileEntity() != null) { + addSlots(aInventoryPlayer); + if (doesBindPlayerInventory()) bindPlayerInventory(aInventoryPlayer); + detectAndSendChanges(); + } else { + aInventoryPlayer.player.openContainer = aInventoryPlayer.player.inventoryContainer; + } + } + + public CONTAINER_MetaTileMachineLong( + InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, boolean doesBindInventory) { + super(aInventoryPlayer, aTileEntity); + mTileEntity = aTileEntity; + + if (mTileEntity != null && mTileEntity.getMetaTileEntity() != null) { + addSlots(aInventoryPlayer); + if (doesBindPlayerInventory() && doesBindInventory) bindPlayerInventory(aInventoryPlayer); + detectAndSendChanges(); + } else { + aInventoryPlayer.player.openContainer = aInventoryPlayer.player.inventoryContainer; + } + } + + private Pair<Integer, Integer> getPowerStored() { + final long mStoredPower = this.pEnergy; + long mMaxInts = (mStoredPower / Integer.MAX_VALUE); + long mLeftOver = (mStoredPower % Integer.MAX_VALUE); + if (mMaxInts < 0 || mMaxInts >= /*4294967298L*/ Integer.MAX_VALUE) { + return new Pair<Integer, Integer>(-1, 0); + } + if (mLeftOver < 0 || mLeftOver > Integer.MAX_VALUE) { + mLeftOver = 0; + } + Pair<Integer, Integer> power = new Pair<Integer, Integer>((int) mMaxInts, (int) mLeftOver); + return power; + } + + private Pair<Integer, Integer> getMaxPowerStored() { + final long mMaxStoredPower = this.pStorage; + long mMaxInts = (mMaxStoredPower / Integer.MAX_VALUE); + long mLeftOver = (mMaxStoredPower % Integer.MAX_VALUE); + if (mMaxInts < 0 || mMaxInts >= /*4294967298L*/ Integer.MAX_VALUE) { + return new Pair<Integer, Integer>(-1, 0); + } + if (mLeftOver < 0 || mLeftOver > Integer.MAX_VALUE) { + mLeftOver = 0; + } + Pair<Integer, Integer> power = new Pair<Integer, Integer>((int) mMaxInts, (int) mLeftOver); + return power; + } + + @Override + public void detectAndSendChanges() { + super.detectAndSendChanges(); + if (mTileEntity.isClientSide() || mTileEntity.getMetaTileEntity() == null) return; + pStorage = Math.min(Long.MAX_VALUE, mTileEntity.getEUCapacity()); + pEnergy = Math.min(Long.MAX_VALUE, mTileEntity.getStoredEU()); + mSteamStorage = (int) Math.min(Integer.MAX_VALUE, mTileEntity.getSteamCapacity()); + mSteam = (int) Math.min(Integer.MAX_VALUE, mTileEntity.getStoredSteam()); + mOutput = (int) Math.min(Integer.MAX_VALUE, mTileEntity.getOutputVoltage()); + mInput = (int) Math.min(Integer.MAX_VALUE, mTileEntity.getInputVoltage()); + mDisplayErrorCode = mTileEntity.getErrorDisplayID(); + mProgressTime = mTileEntity.getProgress(); + mMaxProgressTime = mTileEntity.getMaxProgress(); + mActive = mTileEntity.isActive() ? 1 : 0; + mTimer++; + + Pair<Integer, Integer> powerPacket = getPowerStored(); + Pair<Integer, Integer> maxPowerPacket = getMaxPowerStored(); + + int mPacketsToSend = powerPacket.getKey(); + int mLeftOverPowerStored = powerPacket.getValue(); + + int mMaxStorageA = maxPowerPacket.getKey(); + int mMaxStorageB = maxPowerPacket.getValue(); + + // Someone has a VERY FULL power supply. + if (mPacketsToSend == -1) { + Logger.INFO("TOO MUCH MATH - USE BIGINTEGER - GAME BREAKING BUG MAY OCCUR"); + return; + } + + Iterator var2 = this.crafters.iterator(); + while (var2.hasNext()) { + ICrafting var1 = (ICrafting) var2.next(); + if (mTimer % 500 == 10 || nEnergy != pEnergy) { + var1.sendProgressBarUpdate(this, 0, mLeftOverPowerStored & 65535); + var1.sendProgressBarUpdate(this, 1, mLeftOverPowerStored >>> 16); + var1.sendProgressBarUpdate(this, 7730, mPacketsToSend); + } + if (mTimer % 500 == 10 || nStorage != pStorage) { + var1.sendProgressBarUpdate(this, 2, mMaxStorageB & 65535); + var1.sendProgressBarUpdate(this, 3, mMaxStorageB >>> 16); + var1.sendProgressBarUpdate(this, 7731, mMaxStorageA); + } + if (mTimer % 500 == 10 || oOutput != mOutput) { + var1.sendProgressBarUpdate(this, 4, mOutput); + } + if (mTimer % 500 == 10 || oInput != mInput) { + var1.sendProgressBarUpdate(this, 5, mInput); + } + if (mTimer % 500 == 10 || oDisplayErrorCode != mDisplayErrorCode) { + var1.sendProgressBarUpdate(this, 6, mDisplayErrorCode); + } + if (mTimer % 500 == 10 || oProgressTime != mProgressTime) { + var1.sendProgressBarUpdate(this, 11, mProgressTime & 65535); + var1.sendProgressBarUpdate(this, 12, mProgressTime >>> 16); + } + if (mTimer % 500 == 10 || oMaxProgressTime != mMaxProgressTime) { + var1.sendProgressBarUpdate(this, 13, mMaxProgressTime & 65535); + var1.sendProgressBarUpdate(this, 14, mMaxProgressTime >>> 16); + } + if (mTimer % 500 == 10 || oID != mID) { + var1.sendProgressBarUpdate(this, 15, mID); + } + if (mTimer % 500 == 10 || oActive != mActive) { + var1.sendProgressBarUpdate(this, 16, mActive); + } + if (mTimer % 500 == 10 || oSteam != mSteam) { + var1.sendProgressBarUpdate(this, 17, mSteam & 65535); + var1.sendProgressBarUpdate(this, 18, mSteam >>> 16); + } + if (mTimer % 500 == 10 || oSteamStorage != mSteamStorage) { + var1.sendProgressBarUpdate(this, 19, mSteamStorage & 65535); + var1.sendProgressBarUpdate(this, 20, mSteamStorage >>> 16); + } + } + + oID = mID; + oSteam = mSteam; + oInput = mInput; + oActive = mActive; + oOutput = mOutput; + nEnergy = pEnergy; + nStorage = pStorage; + oSteamStorage = mSteamStorage; + oProgressTime = mProgressTime; + oMaxProgressTime = mMaxProgressTime; + oDisplayErrorCode = mDisplayErrorCode; + } + + @SideOnly(Side.CLIENT) + @Override + public void updateProgressBar(int par1, int par2) { + super.updateProgressBar(par1, par2); + switch (par1) { + /*case 7730: + pIntMaxCountCurrent = par2;*/ + case 0: + pEnergy = pEnergy & -65536 | par2; + break; + case 1: + pEnergy = pEnergy & 65535 | par2 << 16; + break; + case 2: + pStorage = pStorage & -65536 | par2; + break; + case 3: + pStorage = pStorage & 65535 | par2 << 16; + break; + case 4: + mOutput = par2; + break; + case 5: + mInput = par2; + break; + case 6: + mDisplayErrorCode = par2; + break; + case 11: + mProgressTime = mProgressTime & -65536 | par2; + break; + case 12: + mProgressTime = mProgressTime & 65535 | par2 << 16; + break; + case 13: + mMaxProgressTime = mMaxProgressTime & -65536 | par2; + break; + case 14: + mMaxProgressTime = mMaxProgressTime & 65535 | par2 << 16; + break; + case 15: + mID = par2; + break; + case 16: + mActive = par2; + break; + case 17: + mSteam = mSteam & -65536 | par2; + break; + case 18: + mSteam = mSteam & 65535 | par2 << 16; + break; + case 19: + mSteamStorage = mSteamStorage & -65536 | par2; + break; + case 20: + mSteamStorage = mSteamStorage & 65535 | par2 << 16; + break; + } + } + + @Override + public boolean canInteractWith(EntityPlayer player) { + return mTileEntity.isUseableByPlayer(player); + } + + public String trans(String aKey, String aEnglish) { + return GT_LanguageManager.addStringLocalization("Interaction_DESCRIPTION_Index_" + aKey, aEnglish, false); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_MultiMachine.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_MultiMachine.java index 88b9661c95..fd4aff592e 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_MultiMachine.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_MultiMachine.java @@ -1,9 +1,5 @@ package gtPlusPlus.xmod.gregtech.api.gui; -import java.lang.reflect.Field; -import java.util.ArrayList; -import java.util.List; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.gui.GT_ContainerMetaTile_Machine; @@ -14,6 +10,9 @@ import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.List; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.ICrafting; @@ -25,259 +24,263 @@ import net.minecraft.inventory.ICrafting; */ public class CONTAINER_MultiMachine extends GT_ContainerMetaTile_Machine { - public String[] mTileDescription; - private String[] oTileDescription; - - private GregtechMeta_MultiBlockBase mMCTEI; - private boolean mControllerSet = false; + public String[] mTileDescription; + private String[] oTileDescription; + + private GregtechMeta_MultiBlockBase mMCTEI; + private boolean mControllerSet = false; + + public CONTAINER_MultiMachine(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity) { + super(aInventoryPlayer, aTileEntity); + } + public CONTAINER_MultiMachine( + final InventoryPlayer aInventoryPlayer, + final IGregTechTileEntity aTileEntity, + final boolean bindInventory) { + super(aInventoryPlayer, aTileEntity, bindInventory); + } - public CONTAINER_MultiMachine(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity) { - super(aInventoryPlayer, aTileEntity); - } + public static void setControllerInstance(CONTAINER_MultiMachine aContainer, IGregTechTileEntity aTile) { + if (aTile == null) { + return; + } + final IMetaTileEntity aMetaTileEntity = aTile.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return; + } + if (aMetaTileEntity instanceof GregtechMeta_MultiBlockBase) { + aContainer.mMCTEI = (GregtechMeta_MultiBlockBase) aMetaTileEntity; + } + } - public CONTAINER_MultiMachine(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity, final boolean bindInventory) { - super(aInventoryPlayer, aTileEntity, bindInventory); - } - - public static void setControllerInstance(CONTAINER_MultiMachine aContainer, IGregTechTileEntity aTile) { - if (aTile == null) { - return; - } - final IMetaTileEntity aMetaTileEntity = aTile.getMetaTileEntity(); - if (aMetaTileEntity == null) { - return; - } - if (aMetaTileEntity instanceof GregtechMeta_MultiBlockBase) { - aContainer.mMCTEI = (GregtechMeta_MultiBlockBase) aMetaTileEntity; - } - } + public int aTotalTickTime = 0; + public int aMaxParallel = 0; + public int aPollutionTick = 0; + public int aMaxInputVoltage = 0; + public int aInputTier = 0; + public int aOutputTier = 0; + public int aRecipeDuration = 0; + public int aRecipeEU = 0; + public int aRecipeSpecial = 0; + public int aPollutionReduction = 0; + public int aStoredEnergy = 0; + public int aMaxEnergy = 0; + public int aEfficiency = 0; - public int aTotalTickTime = 0; - public int aMaxParallel = 0; - public int aPollutionTick = 0; - public int aMaxInputVoltage = 0; - public int aInputTier = 0; - public int aOutputTier = 0; - public int aRecipeDuration = 0; - public int aRecipeEU = 0; - public int aRecipeSpecial = 0; - public int aPollutionReduction = 0; - public int aStoredEnergy = 0; - public int aMaxEnergy = 0; - public int aEfficiency = 0; + private int oTotalTickTime = 0; + private int oMaxParallel = 0; + private int oPollutionTick = 0; + private int oMaxInputVoltage = 0; + private int oInputTier = 0; + private int oOutputTier = 0; + private int oRecipeDuration = 0; + private int oRecipeEU = 0; + private int oRecipeSpecial = 0; + private int oPollutionReduction = 0; + private int oStoredEnergy = 0; + private int oMaxEnergy = 0; + private int oEfficiency = 0; - private int oTotalTickTime = 0; - private int oMaxParallel = 0; - private int oPollutionTick = 0; - private int oMaxInputVoltage = 0; - private int oInputTier = 0; - private int oOutputTier = 0; - private int oRecipeDuration = 0; - private int oRecipeEU = 0; - private int oRecipeSpecial = 0; - private int oPollutionReduction = 0; - private int oStoredEnergy = 0; - private int oMaxEnergy = 0; - private int oEfficiency = 0; + private static Field timer; + // private static Field crafters; - private static Field timer; - //private static Field crafters; + @Override + public final void detectAndSendChanges() { + super.detectAndSendChanges(); + if (this.mTileEntity.isClientSide() || this.mTileEntity.getMetaTileEntity() == null) { + return; + } + if (!mControllerSet) { + setControllerInstance(this, this.mTileEntity); + } + mControllerSet = (mMCTEI != null); + if (timer == null) { + timer = ReflectionUtils.getField(getClass(), "mTimer"); + } + if (crafters == null) { + // crafters = ReflectionUtils.getField(getClass(), "crafters"); + } + if (timer != null && crafters != null && mControllerSet) { + // Logger.INFO("Trying to update clientside GUI data"); + try { + // Logger.INFO("0"); + int aTimer = (int) ReflectionUtils.getFieldValue(timer, this); - @Override - public final void detectAndSendChanges() { - super.detectAndSendChanges(); - if (this.mTileEntity.isClientSide() || this.mTileEntity.getMetaTileEntity() == null) { - return; - } - if (!mControllerSet) { - setControllerInstance(this, this.mTileEntity); - } - mControllerSet = (mMCTEI != null); - if (timer == null) { - timer = ReflectionUtils.getField(getClass(), "mTimer"); - } - if (crafters == null) { - //crafters = ReflectionUtils.getField(getClass(), "crafters"); - } - if (timer != null && crafters != null && mControllerSet) { - //Logger.INFO("Trying to update clientside GUI data"); - try { - //Logger.INFO("0"); - int aTimer = (int) ReflectionUtils.getFieldValue(timer, this); - - //List crafters1List = (List) crafters1; - List<ICrafting> crafters2 = new ArrayList<ICrafting>(); - //Logger.INFO("1"); - for (Object o : crafters) { - if (o instanceof ICrafting) { - crafters2.add((ICrafting) o); - } - } - //Logger.INFO("2"); - if (!crafters2.isEmpty()) { - //Logger.INFO("3"); - handleInitialFieldSetting(); + // List crafters1List = (List) crafters1; + List<ICrafting> crafters2 = new ArrayList<ICrafting>(); + // Logger.INFO("1"); + for (Object o : crafters) { + if (o instanceof ICrafting) { + crafters2.add((ICrafting) o); + } + } + // Logger.INFO("2"); + if (!crafters2.isEmpty()) { + // Logger.INFO("3"); + handleInitialFieldSetting(); - try { - //Logger.INFO("4"); - for (final ICrafting var3 : crafters2) { - handleCraftingEvent(aTimer, var3); - } - //Logger.INFO("5"); - handleInternalFieldSetting(); - //Logger.INFO("6"); - } catch (Throwable t) { + try { + // Logger.INFO("4"); + for (final ICrafting var3 : crafters2) { + handleCraftingEvent(aTimer, var3); + } + // Logger.INFO("5"); + handleInternalFieldSetting(); + // Logger.INFO("6"); + } catch (Throwable t) { - } - } - } catch (Throwable t) { - t.printStackTrace(); - } - } - else { - Logger.INFO("Failed."); - } - } + } + } + } catch (Throwable t) { + t.printStackTrace(); + } + } else { + Logger.INFO("Failed."); + } + } - public void handleInitialFieldSetting() { - this.aTotalTickTime = MathUtils.balance((int) mMCTEI.getTotalRuntimeInTicks(), Integer.MIN_VALUE, Integer.MAX_VALUE); - this.aMaxParallel = mMCTEI.getMaxParallelRecipes(); - this.aPollutionTick = mMCTEI.getPollutionPerTick(null); - this.aMaxInputVoltage = MathUtils.balance((int) mMCTEI.getMaxInputVoltage(), Integer.MIN_VALUE, Integer.MAX_VALUE); - this.aInputTier = MathUtils.balance((int) mMCTEI.getInputTier(), Integer.MIN_VALUE, Integer.MAX_VALUE); - this.aOutputTier = MathUtils.balance((int) mMCTEI.getOutputTier(), Integer.MIN_VALUE, Integer.MAX_VALUE); - if (mMCTEI.mLastRecipe != null) { - GT_Recipe aRecipe = mMCTEI.mLastRecipe; - this.aRecipeDuration = MathUtils.balance(aRecipe.mDuration, Integer.MIN_VALUE, Integer.MAX_VALUE); - this.aRecipeEU = MathUtils.balance(aRecipe.mEUt, Integer.MIN_VALUE, Integer.MAX_VALUE); - this.aRecipeSpecial = MathUtils.balance(aRecipe.mSpecialValue, Integer.MIN_VALUE, Integer.MAX_VALUE); - } - this.aPollutionReduction = mMCTEI.getPollutionReductionForAllMufflers(); - - this.aStoredEnergy = MathUtils.balance((int) mMCTEI.getStoredEnergyInAllEnergyHatches(), Integer.MIN_VALUE, Integer.MAX_VALUE); - this.aMaxEnergy = MathUtils.balance((int) mMCTEI.getMaxEnergyStorageOfAllEnergyHatches(), Integer.MIN_VALUE, Integer.MAX_VALUE); - this.aEfficiency = MathUtils.balance(mMCTEI.mEfficiency, Integer.MIN_VALUE, Integer.MAX_VALUE); - } + public void handleInitialFieldSetting() { + this.aTotalTickTime = + MathUtils.balance((int) mMCTEI.getTotalRuntimeInTicks(), Integer.MIN_VALUE, Integer.MAX_VALUE); + this.aMaxParallel = mMCTEI.getMaxParallelRecipes(); + this.aPollutionTick = mMCTEI.getPollutionPerTick(null); + this.aMaxInputVoltage = + MathUtils.balance((int) mMCTEI.getMaxInputVoltage(), Integer.MIN_VALUE, Integer.MAX_VALUE); + this.aInputTier = MathUtils.balance((int) mMCTEI.getInputTier(), Integer.MIN_VALUE, Integer.MAX_VALUE); + this.aOutputTier = MathUtils.balance((int) mMCTEI.getOutputTier(), Integer.MIN_VALUE, Integer.MAX_VALUE); + if (mMCTEI.mLastRecipe != null) { + GT_Recipe aRecipe = mMCTEI.mLastRecipe; + this.aRecipeDuration = MathUtils.balance(aRecipe.mDuration, Integer.MIN_VALUE, Integer.MAX_VALUE); + this.aRecipeEU = MathUtils.balance(aRecipe.mEUt, Integer.MIN_VALUE, Integer.MAX_VALUE); + this.aRecipeSpecial = MathUtils.balance(aRecipe.mSpecialValue, Integer.MIN_VALUE, Integer.MAX_VALUE); + } + this.aPollutionReduction = mMCTEI.getPollutionReductionForAllMufflers(); - public void handleCraftingEvent(int aTimer, ICrafting aCrafter) { - int aID = 750; - if (aTimer % 500 == 10 || this.oTotalTickTime != this.aTotalTickTime) { - aCrafter.sendProgressBarUpdate((Container) this, aID++, this.aTotalTickTime); - } - if (aTimer % 500 == 10 || this.oMaxParallel != this.aMaxParallel) { - aCrafter.sendProgressBarUpdate((Container) this, aID++, this.aMaxParallel); - } - if (aTimer % 500 == 10 || this.oPollutionTick != this.aPollutionTick) { - aCrafter.sendProgressBarUpdate((Container) this, aID++, this.aPollutionTick); - } - if (aTimer % 500 == 10 || this.oMaxInputVoltage != this.aMaxInputVoltage) { - aCrafter.sendProgressBarUpdate((Container) this, aID++, this.aMaxInputVoltage); - } - if (aTimer % 500 == 10 || this.oInputTier != this.aInputTier) { - aCrafter.sendProgressBarUpdate((Container) this, aID++, this.aInputTier); - } - if (aTimer % 500 == 10 || this.oOutputTier != this.aOutputTier) { - aCrafter.sendProgressBarUpdate((Container) this, aID++, this.aOutputTier); - } - if (aTimer % 500 == 10 || this.oRecipeDuration != this.aRecipeDuration) { - aCrafter.sendProgressBarUpdate((Container) this, aID++, this.aRecipeDuration); - } - if (aTimer % 500 == 10 || this.oRecipeEU != this.aRecipeEU) { - aCrafter.sendProgressBarUpdate((Container) this, aID++, this.aRecipeEU); - } - if (aTimer % 500 == 10 || this.oRecipeSpecial != this.aRecipeSpecial) { - aCrafter.sendProgressBarUpdate((Container) this, aID++, this.aRecipeSpecial); - } - if (aTimer % 500 == 10 || this.oPollutionReduction != this.aPollutionReduction) { - aCrafter.sendProgressBarUpdate((Container) this, aID++, this.aPollutionReduction); - } - if (aTimer % 500 == 10 || this.oStoredEnergy != this.aStoredEnergy) { - aCrafter.sendProgressBarUpdate((Container) this, aID++, this.aStoredEnergy); - } - if (aTimer % 500 == 10 || this.oMaxEnergy != this.aMaxEnergy) { - aCrafter.sendProgressBarUpdate((Container) this, aID++, this.aMaxEnergy); - } - if (aTimer % 500 == 10 || this.oEfficiency != this.aEfficiency) { - aCrafter.sendProgressBarUpdate((Container) this, aID++, this.aEfficiency); - } - } + this.aStoredEnergy = MathUtils.balance( + (int) mMCTEI.getStoredEnergyInAllEnergyHatches(), Integer.MIN_VALUE, Integer.MAX_VALUE); + this.aMaxEnergy = MathUtils.balance( + (int) mMCTEI.getMaxEnergyStorageOfAllEnergyHatches(), Integer.MIN_VALUE, Integer.MAX_VALUE); + this.aEfficiency = MathUtils.balance(mMCTEI.mEfficiency, Integer.MIN_VALUE, Integer.MAX_VALUE); + } - public void handleInternalFieldSetting() { - this.oTotalTickTime = this.aTotalTickTime; - this.oMaxParallel = this.aMaxParallel; - this.oPollutionTick = this.aPollutionTick; - this.oMaxInputVoltage = this.aMaxInputVoltage; - this.oInputTier = this.aInputTier; - this.oOutputTier = this.aOutputTier; - this.oRecipeDuration = this.aRecipeDuration; - this.oRecipeEU = this.aRecipeEU; - this.oRecipeSpecial = this.aRecipeSpecial; - this.oPollutionReduction = this.aPollutionReduction; - this.oStoredEnergy = this.aStoredEnergy; - this.oMaxEnergy = this.aMaxEnergy; - this.oEfficiency = this.aEfficiency; - } + public void handleCraftingEvent(int aTimer, ICrafting aCrafter) { + int aID = 750; + if (aTimer % 500 == 10 || this.oTotalTickTime != this.aTotalTickTime) { + aCrafter.sendProgressBarUpdate((Container) this, aID++, this.aTotalTickTime); + } + if (aTimer % 500 == 10 || this.oMaxParallel != this.aMaxParallel) { + aCrafter.sendProgressBarUpdate((Container) this, aID++, this.aMaxParallel); + } + if (aTimer % 500 == 10 || this.oPollutionTick != this.aPollutionTick) { + aCrafter.sendProgressBarUpdate((Container) this, aID++, this.aPollutionTick); + } + if (aTimer % 500 == 10 || this.oMaxInputVoltage != this.aMaxInputVoltage) { + aCrafter.sendProgressBarUpdate((Container) this, aID++, this.aMaxInputVoltage); + } + if (aTimer % 500 == 10 || this.oInputTier != this.aInputTier) { + aCrafter.sendProgressBarUpdate((Container) this, aID++, this.aInputTier); + } + if (aTimer % 500 == 10 || this.oOutputTier != this.aOutputTier) { + aCrafter.sendProgressBarUpdate((Container) this, aID++, this.aOutputTier); + } + if (aTimer % 500 == 10 || this.oRecipeDuration != this.aRecipeDuration) { + aCrafter.sendProgressBarUpdate((Container) this, aID++, this.aRecipeDuration); + } + if (aTimer % 500 == 10 || this.oRecipeEU != this.aRecipeEU) { + aCrafter.sendProgressBarUpdate((Container) this, aID++, this.aRecipeEU); + } + if (aTimer % 500 == 10 || this.oRecipeSpecial != this.aRecipeSpecial) { + aCrafter.sendProgressBarUpdate((Container) this, aID++, this.aRecipeSpecial); + } + if (aTimer % 500 == 10 || this.oPollutionReduction != this.aPollutionReduction) { + aCrafter.sendProgressBarUpdate((Container) this, aID++, this.aPollutionReduction); + } + if (aTimer % 500 == 10 || this.oStoredEnergy != this.aStoredEnergy) { + aCrafter.sendProgressBarUpdate((Container) this, aID++, this.aStoredEnergy); + } + if (aTimer % 500 == 10 || this.oMaxEnergy != this.aMaxEnergy) { + aCrafter.sendProgressBarUpdate((Container) this, aID++, this.aMaxEnergy); + } + if (aTimer % 500 == 10 || this.oEfficiency != this.aEfficiency) { + aCrafter.sendProgressBarUpdate((Container) this, aID++, this.aEfficiency); + } + } - @SideOnly(Side.CLIENT) - @Override - public void updateProgressBar(final int par1, final int par2) { - super.updateProgressBar(par1, par2); - int shiftedSwitch = par1 - 750; - switch (shiftedSwitch) { - case 0: { - this.aTotalTickTime = par2; - break; - } - case 1: { - this.aMaxParallel = par2; - break; - } - case 2: { - this.aPollutionTick = par2; - break; - } - case 3: { - this.aMaxInputVoltage = par2; - break; - } - case 4: { - this.aInputTier = par2; - break; - } - case 5: { - this.aOutputTier = par2; - break; - } - case 6: { - this.aRecipeDuration = par2; - break; - } - case 7: { - this.aRecipeEU = par2; - break; - } - case 8: { - this.aRecipeSpecial = par2; - break; - } - case 9: { - this.aPollutionReduction = par2; - break; - } - case 10: { - this.aStoredEnergy = par2; - break; - } - case 11: { - this.aMaxEnergy = par2; - break; - } - case 12: { - this.aEfficiency = par2; - break; - } - } - } + public void handleInternalFieldSetting() { + this.oTotalTickTime = this.aTotalTickTime; + this.oMaxParallel = this.aMaxParallel; + this.oPollutionTick = this.aPollutionTick; + this.oMaxInputVoltage = this.aMaxInputVoltage; + this.oInputTier = this.aInputTier; + this.oOutputTier = this.aOutputTier; + this.oRecipeDuration = this.aRecipeDuration; + this.oRecipeEU = this.aRecipeEU; + this.oRecipeSpecial = this.aRecipeSpecial; + this.oPollutionReduction = this.aPollutionReduction; + this.oStoredEnergy = this.aStoredEnergy; + this.oMaxEnergy = this.aMaxEnergy; + this.oEfficiency = this.aEfficiency; + } + @SideOnly(Side.CLIENT) + @Override + public void updateProgressBar(final int par1, final int par2) { + super.updateProgressBar(par1, par2); + int shiftedSwitch = par1 - 750; + switch (shiftedSwitch) { + case 0: { + this.aTotalTickTime = par2; + break; + } + case 1: { + this.aMaxParallel = par2; + break; + } + case 2: { + this.aPollutionTick = par2; + break; + } + case 3: { + this.aMaxInputVoltage = par2; + break; + } + case 4: { + this.aInputTier = par2; + break; + } + case 5: { + this.aOutputTier = par2; + break; + } + case 6: { + this.aRecipeDuration = par2; + break; + } + case 7: { + this.aRecipeEU = par2; + break; + } + case 8: { + this.aRecipeSpecial = par2; + break; + } + case 9: { + this.aPollutionReduction = par2; + break; + } + case 10: { + this.aStoredEnergy = par2; + break; + } + case 11: { + this.aMaxEnergy = par2; + break; + } + case 12: { + this.aEfficiency = par2; + break; + } + } + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_MultiMachine_NoPlayerInventory.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_MultiMachine_NoPlayerInventory.java index 2d63a13d60..579e0a7e1d 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_MultiMachine_NoPlayerInventory.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_MultiMachine_NoPlayerInventory.java @@ -7,21 +7,25 @@ import net.minecraft.item.ItemStack; public class CONTAINER_MultiMachine_NoPlayerInventory extends CONTAINER_MultiMachine { - public CONTAINER_MultiMachine_NoPlayerInventory(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity) { - super(aInventoryPlayer, aTileEntity); - } + public CONTAINER_MultiMachine_NoPlayerInventory( + final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity) { + super(aInventoryPlayer, aTileEntity); + } + + public CONTAINER_MultiMachine_NoPlayerInventory( + final InventoryPlayer aInventoryPlayer, + final IGregTechTileEntity aTileEntity, + final boolean bindInventory) { + super(aInventoryPlayer, aTileEntity, bindInventory); + } - public CONTAINER_MultiMachine_NoPlayerInventory(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity, final boolean bindInventory) { - super(aInventoryPlayer, aTileEntity, bindInventory); - } - public boolean doesBindPlayerInventory() { return false; } @Override - public ItemStack slotClick(final int aSlotIndex, final int aMouseclick, final int aShifthold, final EntityPlayer aPlayer) { - return null; + public ItemStack slotClick( + final int aSlotIndex, final int aMouseclick, final int aShifthold, final EntityPlayer aPlayer) { + return null; } - } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_PowerSubStation.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_PowerSubStation.java index c42fa98cd3..f975539b83 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_PowerSubStation.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_PowerSubStation.java @@ -5,76 +5,81 @@ import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.gui.GT_Container_MultiMachine; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gtPlusPlus.core.slots.SlotNoInput; -import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.storage.GregtechMetaTileEntity_PowerSubStationController; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.*; public class CONTAINER_PowerSubStation extends GT_Container_MultiMachine { - private final SyncedValueManager manager = new SyncedValueManager(21); - public final SyncedLong mStoredEU = manager.allocateLong(); - public final SyncedLong mMaxStoredEU = manager.allocateLong(); - public final SyncedLong mAverageEuAdded = manager.allocateLong(); - public final SyncedLong mAverageEuConsumed = manager.allocateLong(); - - public CONTAINER_PowerSubStation(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity) { - super(aInventoryPlayer, aTileEntity); - } - - public CONTAINER_PowerSubStation(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity, final boolean bindInventory) { - super(aInventoryPlayer, aTileEntity, bindInventory); - } - - public void addSlots(final InventoryPlayer aInventoryPlayer) { - this.addSlotToContainer(new Slot(this.mTileEntity, 1, 155, 5)); - this.addSlotToContainer(new SlotNoInput(this.mTileEntity, 2, 155, 23)); - - for (int i = 0; i < 9; ++i) { this.addSlotToContainer(new Slot(aInventoryPlayer, i, 8 + i * 18, 167)); } - - } - - @Override - public boolean doesBindPlayerInventory() { - return false; - } - - public int getSlotCount() { - return 10; - } - - public int getShiftClickSlotCount() { - return 1; - } - - @Override - public void detectAndSendChanges() { - super.detectAndSendChanges(); - - if (manager == null) - // maybe not yet initialized - // stupid java - // ask greg why he wants to call a method that's definitely going to be overridden in subclass in constructor - return; - - GregtechMetaTileEntity_PowerSubStationController aPSS = (GregtechMetaTileEntity_PowerSubStationController) mTileEntity.getMetaTileEntity(); - mStoredEU.setValue(mTileEntity.getStoredEU()); - mMaxStoredEU.setValue(mTileEntity.getEUCapacity()); - mAverageEuAdded.setValue(aPSS.getAverageEuAdded()); - mAverageEuConsumed.setValue(aPSS.getAverageEuConsumed()); - - manager.detectAndSendChanges(this::sendProgressBarUpdate, mTimer); - } - - @SideOnly(Side.CLIENT) - @Override - public void updateProgressBar(int par1, int par2) { - super.updateProgressBar(par1, par2); - manager.updateProgressBar(par1, par2); - } - - private void sendProgressBarUpdate(int short1, int short2) { - for (Object crafter : this.crafters) { - ((ICrafting) crafter).sendProgressBarUpdate(this, short1, short2); - } - } + private final SyncedValueManager manager = new SyncedValueManager(21); + public final SyncedLong mStoredEU = manager.allocateLong(); + public final SyncedLong mMaxStoredEU = manager.allocateLong(); + public final SyncedLong mAverageEuAdded = manager.allocateLong(); + public final SyncedLong mAverageEuConsumed = manager.allocateLong(); + + public CONTAINER_PowerSubStation(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity) { + super(aInventoryPlayer, aTileEntity); + } + + public CONTAINER_PowerSubStation( + final InventoryPlayer aInventoryPlayer, + final IGregTechTileEntity aTileEntity, + final boolean bindInventory) { + super(aInventoryPlayer, aTileEntity, bindInventory); + } + + public void addSlots(final InventoryPlayer aInventoryPlayer) { + this.addSlotToContainer(new Slot(this.mTileEntity, 1, 155, 5)); + this.addSlotToContainer(new SlotNoInput(this.mTileEntity, 2, 155, 23)); + + for (int i = 0; i < 9; ++i) { + this.addSlotToContainer(new Slot(aInventoryPlayer, i, 8 + i * 18, 167)); + } + } + + @Override + public boolean doesBindPlayerInventory() { + return false; + } + + public int getSlotCount() { + return 10; + } + + public int getShiftClickSlotCount() { + return 1; + } + + @Override + public void detectAndSendChanges() { + super.detectAndSendChanges(); + + if (manager == null) + // maybe not yet initialized + // stupid java + // ask greg why he wants to call a method that's definitely going to be overridden in subclass in + // constructor + return; + + GregtechMetaTileEntity_PowerSubStationController aPSS = + (GregtechMetaTileEntity_PowerSubStationController) mTileEntity.getMetaTileEntity(); + mStoredEU.setValue(mTileEntity.getStoredEU()); + mMaxStoredEU.setValue(mTileEntity.getEUCapacity()); + mAverageEuAdded.setValue(aPSS.getAverageEuAdded()); + mAverageEuConsumed.setValue(aPSS.getAverageEuConsumed()); + + manager.detectAndSendChanges(this::sendProgressBarUpdate, mTimer); + } + + @SideOnly(Side.CLIENT) + @Override + public void updateProgressBar(int par1, int par2) { + super.updateProgressBar(par1, par2); + manager.updateProgressBar(par1, par2); + } + + private void sendProgressBarUpdate(int short1, int short2) { + for (Object crafter : this.crafters) { + ((ICrafting) crafter).sendProgressBarUpdate(this, short1, short2); + } + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_SafeBlock.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_SafeBlock.java index 9a84ba66ab..e317583413 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_SafeBlock.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_SafeBlock.java @@ -1,57 +1,54 @@ package gtPlusPlus.xmod.gregtech.api.gui; -import java.util.UUID; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; - import gregtech.api.gui.GT_ContainerMetaTile_Machine; import gregtech.api.gui.GT_Slot_Holo; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; - import gtPlusPlus.core.util.player.PlayerCache; import gtPlusPlus.xmod.gregtech.common.tileentities.storage.GregtechMetaSafeBlock; +import java.util.UUID; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; -public class CONTAINER_SafeBlock -extends GT_ContainerMetaTile_Machine { - public CONTAINER_SafeBlock(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity) { - super(aInventoryPlayer, aTileEntity); - } - - //public String UUID = ((BaseMetaTileEntity)mTileEntity).getMetaTileEntity().getBaseMetaTileEntity().getOwnerName(); - public UUID ownerUUID = ((GregtechMetaSafeBlock)this.mTileEntity.getMetaTileEntity()).ownerUUID; - public String tempPlayer = PlayerCache.lookupPlayerByUUID(this.ownerUUID); - public boolean blockStatus = ((GregtechMetaSafeBlock)this.mTileEntity.getMetaTileEntity()).bUnbreakable; - - @Override - public void addSlots(final InventoryPlayer aInventoryPlayer) { - for (int y = 0; y < 3; y++) { - for (int x = 0; x < 9; x++) { - this.addSlotToContainer(new Slot(this.mTileEntity, x + (y * 9), 8 + (x * 18), 5 + (y * 18))); - } - } - this.addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 27, 8, 63, false, true, 1)); - this.addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 27, 26, 63, false, true, 1)); - this.addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 27, 44, 63, false, true, 1)); - } - - @Override - public ItemStack slotClick(final int aSlotIndex, final int aMouseclick, final int aShifthold, final EntityPlayer aPlayer) { - final int runs = 0; - if (aSlotIndex < 27) { - return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); - } - final Slot tSlot = (Slot) this.inventorySlots.get(aSlotIndex); - if (tSlot != null) { - if (this.mTileEntity.getMetaTileEntity() == null) { - return null; - } - if (aSlotIndex == 27) { - +public class CONTAINER_SafeBlock extends GT_ContainerMetaTile_Machine { + public CONTAINER_SafeBlock(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity) { + super(aInventoryPlayer, aTileEntity); + } + + // public String UUID = + // ((BaseMetaTileEntity)mTileEntity).getMetaTileEntity().getBaseMetaTileEntity().getOwnerName(); + public UUID ownerUUID = ((GregtechMetaSafeBlock) this.mTileEntity.getMetaTileEntity()).ownerUUID; + public String tempPlayer = PlayerCache.lookupPlayerByUUID(this.ownerUUID); + public boolean blockStatus = ((GregtechMetaSafeBlock) this.mTileEntity.getMetaTileEntity()).bUnbreakable; + + @Override + public void addSlots(final InventoryPlayer aInventoryPlayer) { + for (int y = 0; y < 3; y++) { + for (int x = 0; x < 9; x++) { + this.addSlotToContainer(new Slot(this.mTileEntity, x + (y * 9), 8 + (x * 18), 5 + (y * 18))); + } + } + this.addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 27, 8, 63, false, true, 1)); + this.addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 27, 26, 63, false, true, 1)); + this.addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 27, 44, 63, false, true, 1)); + } + + @Override + public ItemStack slotClick( + final int aSlotIndex, final int aMouseclick, final int aShifthold, final EntityPlayer aPlayer) { + final int runs = 0; + if (aSlotIndex < 27) { + return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + } + final Slot tSlot = (Slot) this.inventorySlots.get(aSlotIndex); + if (tSlot != null) { + if (this.mTileEntity.getMetaTileEntity() == null) { + return null; + } + if (aSlotIndex == 27) { - /*((GregtechMetaSafeBlock) this.mTileEntity.getMetaTileEntity()).bOutput = (!((GregtechMetaSafeBlock) this.mTileEntity.getMetaTileEntity()).bOutput); + /*((GregtechMetaSafeBlock) this.mTileEntity.getMetaTileEntity()).bOutput = (!((GregtechMetaSafeBlock) this.mTileEntity.getMetaTileEntity()).bOutput); if (((GregtechMetaSafeBlock) this.mTileEntity.getMetaTileEntity()).bOutput) { if (aPlayer != null && aPlayer instanceof EntityPlayerMP && (((GregtechMetaSafeBlock)this.mTileEntity.getMetaTileEntity()).bOutput != false)) { @@ -65,10 +62,9 @@ extends GT_ContainerMetaTile_Machine { } return null;*/ - - } - if (aSlotIndex == 28) {} - /* ((GregtechMetaSafeBlock) this.mTileEntity.getMetaTileEntity()).bRedstoneIfFull = (!((GregtechMetaSafeBlock) this.mTileEntity.getMetaTileEntity()).bRedstoneIfFull); + } + if (aSlotIndex == 28) {} + /* ((GregtechMetaSafeBlock) this.mTileEntity.getMetaTileEntity()).bRedstoneIfFull = (!((GregtechMetaSafeBlock) this.mTileEntity.getMetaTileEntity()).bRedstoneIfFull); if (((GregtechMetaSafeBlock) this.mTileEntity.getMetaTileEntity()).bRedstoneIfFull) { GT_Utility.sendChatToPlayer(aPlayer, "Emit Redstone if no Slot is free"); } else { @@ -76,7 +72,7 @@ extends GT_ContainerMetaTile_Machine { } return null; }*/ - if (aSlotIndex == 29) /*{ + if (aSlotIndex == 29) /*{ if (((GregtechMetaSafeBlock) this.mTileEntity.getMetaTileEntity()).bUnbreakable) { if (((GregtechMetaSafeBlock) this.mTileEntity.getMetaTileEntity()).bUnbreakable) { makeIndestructible(aPlayer); @@ -88,37 +84,35 @@ extends GT_ContainerMetaTile_Machine { makeIndestructible(aPlayer); } return null; - }*/ - - { - ((GregtechMetaSafeBlock) this.mTileEntity.getMetaTileEntity()).bUnbreakable = (!((GregtechMetaSafeBlock) this.mTileEntity.getMetaTileEntity()).bUnbreakable); - this.blockStatus = ((GregtechMetaSafeBlock)this.mTileEntity.getMetaTileEntity()).bUnbreakable; - this.ownerUUID = ((GregtechMetaSafeBlock)this.mTileEntity.getMetaTileEntity()).ownerUUID; - //Utils.messagePlayer(aPlayer, "Is the safe locked? "+String.valueOf(((GregtechMetaSafeBlock) this.mTileEntity.getMetaTileEntity()).bUnbreakable).toUpperCase()); - /*if (aPlayer != null && aPlayer instanceof EntityPlayerMP && (((GregtechMetaSafeBlock)this.mTileEntity.getMetaTileEntity()).bUnbreakable != false)) { - UnbreakableBlockManager Xasda = new UnbreakableBlockManager(); - Xasda.setmTileEntity((BaseMetaTileEntity) mTileEntity, aPlayer); - } - else { - UnbreakableBlockManager Xasda = new UnbreakableBlockManager(); - Xasda.setmTileEntity((BaseMetaTileEntity) mTileEntity, aPlayer); - }*/ - return null; - } - - - } - return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); - } - - @Override - public int getSlotCount() { - return 27; - } - - @Override - public int getShiftClickSlotCount() { - return 27; - } - + }*/ { + + ((GregtechMetaSafeBlock) this.mTileEntity.getMetaTileEntity()).bUnbreakable = + (!((GregtechMetaSafeBlock) this.mTileEntity.getMetaTileEntity()).bUnbreakable); + this.blockStatus = ((GregtechMetaSafeBlock) this.mTileEntity.getMetaTileEntity()).bUnbreakable; + this.ownerUUID = ((GregtechMetaSafeBlock) this.mTileEntity.getMetaTileEntity()).ownerUUID; + // Utils.messagePlayer(aPlayer, "Is the safe locked? "+String.valueOf(((GregtechMetaSafeBlock) + // this.mTileEntity.getMetaTileEntity()).bUnbreakable).toUpperCase()); + /*if (aPlayer != null && aPlayer instanceof EntityPlayerMP && (((GregtechMetaSafeBlock)this.mTileEntity.getMetaTileEntity()).bUnbreakable != false)) { + UnbreakableBlockManager Xasda = new UnbreakableBlockManager(); + Xasda.setmTileEntity((BaseMetaTileEntity) mTileEntity, aPlayer); + } + else { + UnbreakableBlockManager Xasda = new UnbreakableBlockManager(); + Xasda.setmTileEntity((BaseMetaTileEntity) mTileEntity, aPlayer); + }*/ + return null; + } + } + return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + } + + @Override + public int getSlotCount() { + return 27; + } + + @Override + public int getShiftClickSlotCount() { + return 27; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_SolarGenerator.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_SolarGenerator.java index a3f58836e3..93ba937f45 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_SolarGenerator.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_SolarGenerator.java @@ -1,85 +1,90 @@ package gtPlusPlus.xmod.gregtech.api.gui; -import java.util.Iterator; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.ICrafting; - import gregtech.api.gui.GT_ContainerMetaTile_Machine; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; - import gtPlusPlus.xmod.gregtech.common.tileentities.generators.GregtechMetaTileEntitySolarGenerator; +import java.util.Iterator; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.ICrafting; + +public class CONTAINER_SolarGenerator extends GT_ContainerMetaTile_Machine { + public int mWaterAmount = 0; + public int mSteamAmount = 0; + public int mProcessingEnergy = 0; + public int mTemperature = 2; -public class CONTAINER_SolarGenerator -extends GT_ContainerMetaTile_Machine { - public int mWaterAmount = 0; - public int mSteamAmount = 0; - public int mProcessingEnergy = 0; - public int mTemperature = 2; - public CONTAINER_SolarGenerator(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity) { - super(aInventoryPlayer, aTileEntity); - } + public CONTAINER_SolarGenerator(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity) { + super(aInventoryPlayer, aTileEntity); + } - @Override - public void addSlots(final InventoryPlayer aInventoryPlayer) { - //addSlotToContainer(new Slot(this.mTileEntity, 2, 116, 62)); - //addSlotToContainer(new Slot(this.mTileEntity, 0, 44, 26)); - //addSlotToContainer(new Slot(this.mTileEntity, 1, 44, 62)); - //addSlotToContainer(new Slot(this.mTileEntity, 3, 116, 26)); - } + @Override + public void addSlots(final InventoryPlayer aInventoryPlayer) { + // addSlotToContainer(new Slot(this.mTileEntity, 2, 116, 62)); + // addSlotToContainer(new Slot(this.mTileEntity, 0, 44, 26)); + // addSlotToContainer(new Slot(this.mTileEntity, 1, 44, 62)); + // addSlotToContainer(new Slot(this.mTileEntity, 3, 116, 26)); + } - @Override - public int getSlotCount() { - return 0; - } + @Override + public int getSlotCount() { + return 0; + } - @Override - public int getShiftClickSlotCount() { - return 0; - } + @Override + public int getShiftClickSlotCount() { + return 0; + } - @Override - public void detectAndSendChanges() { - super.detectAndSendChanges(); - if ((this.mTileEntity.isClientSide()) || (this.mTileEntity.getMetaTileEntity() == null)) { - return; - } - this.mTemperature = ((GregtechMetaTileEntitySolarGenerator) this.mTileEntity.getMetaTileEntity()).mSolarCharge; - this.mProcessingEnergy = ((GregtechMetaTileEntitySolarGenerator) this.mTileEntity.getMetaTileEntity()).mProcessingEnergy; + @Override + public void detectAndSendChanges() { + super.detectAndSendChanges(); + if ((this.mTileEntity.isClientSide()) || (this.mTileEntity.getMetaTileEntity() == null)) { + return; + } + this.mTemperature = ((GregtechMetaTileEntitySolarGenerator) this.mTileEntity.getMetaTileEntity()).mSolarCharge; + this.mProcessingEnergy = + ((GregtechMetaTileEntitySolarGenerator) this.mTileEntity.getMetaTileEntity()).mProcessingEnergy; - this.mTemperature = Math.min(54, Math.max(0, (this.mTemperature * 54) / (((GregtechMetaTileEntitySolarGenerator) this.mTileEntity.getMetaTileEntity()).maxProgresstime() - 10))); - this.mEnergy = (int) Math.min(Integer.MAX_VALUE, this.mTileEntity.getStoredEU()); - this.mProcessingEnergy = Math.min(14, Math.max(this.mProcessingEnergy > 0 ? 1 : 0, (this.mProcessingEnergy * 14) / 1000)); + this.mTemperature = Math.min( + 54, + Math.max( + 0, + (this.mTemperature * 54) + / (((GregtechMetaTileEntitySolarGenerator) this.mTileEntity.getMetaTileEntity()) + .maxProgresstime() + - 10))); + this.mEnergy = (int) Math.min(Integer.MAX_VALUE, this.mTileEntity.getStoredEU()); + this.mProcessingEnergy = + Math.min(14, Math.max(this.mProcessingEnergy > 0 ? 1 : 0, (this.mProcessingEnergy * 14) / 1000)); - final Iterator var2 = this.crafters.iterator(); - while (var2.hasNext()) { - final ICrafting var1 = (ICrafting) var2.next(); - var1.sendProgressBarUpdate(this, 100, this.mTemperature); - var1.sendProgressBarUpdate(this, 101, this.mProcessingEnergy); - var1.sendProgressBarUpdate(this, 102, this.mSteamAmount); - var1.sendProgressBarUpdate(this, 103, this.mWaterAmount); - } - } + final Iterator var2 = this.crafters.iterator(); + while (var2.hasNext()) { + final ICrafting var1 = (ICrafting) var2.next(); + var1.sendProgressBarUpdate(this, 100, this.mTemperature); + var1.sendProgressBarUpdate(this, 101, this.mProcessingEnergy); + var1.sendProgressBarUpdate(this, 102, this.mSteamAmount); + var1.sendProgressBarUpdate(this, 103, this.mWaterAmount); + } + } - @Override - @SideOnly(Side.CLIENT) - public void updateProgressBar(final int par1, final int par2) { - super.updateProgressBar(par1, par2); - switch (par1) { - case 100: - this.mTemperature = par2; - break; - case 101: - this.mProcessingEnergy = par2; - break; - case 102: - this.mSteamAmount = par2; - break; - case 103: - this.mWaterAmount = par2; - } - } + @Override + @SideOnly(Side.CLIENT) + public void updateProgressBar(final int par1, final int par2) { + super.updateProgressBar(par1, par2); + switch (par1) { + case 100: + this.mTemperature = par2; + break; + case 101: + this.mProcessingEnergy = par2; + break; + case 102: + this.mSteamAmount = par2; + break; + case 103: + this.mWaterAmount = par2; + } + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_SteamCondenser.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_SteamCondenser.java index 6fcd53b139..361f24c4a1 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_SteamCondenser.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_SteamCondenser.java @@ -1,99 +1,100 @@ package gtPlusPlus.xmod.gregtech.api.gui; -import java.util.Iterator; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.ICrafting; -import net.minecraft.inventory.Slot; - import gregtech.api.gui.GT_ContainerMetaTile_Machine; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; - import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.generators.GregtechMetaBoilerBase; +import java.util.Iterator; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.Slot; -public class CONTAINER_SteamCondenser extends GT_ContainerMetaTile_Machine -{ - public CONTAINER_SteamCondenser(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity) - { - super(aInventoryPlayer, aTileEntity); - } +public class CONTAINER_SteamCondenser extends GT_ContainerMetaTile_Machine { + public CONTAINER_SteamCondenser(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity) { + super(aInventoryPlayer, aTileEntity); + } - @Override - public void addSlots(final InventoryPlayer aInventoryPlayer) - { - this.addSlotToContainer(new Slot(this.mTileEntity, 2, 116, 62)); - this.addSlotToContainer(new Slot(this.mTileEntity, 0, 44, 26)); - this.addSlotToContainer(new Slot(this.mTileEntity, 1, 44, 62)); - this.addSlotToContainer(new Slot(this.mTileEntity, 3, 116, 26)); - } + @Override + public void addSlots(final InventoryPlayer aInventoryPlayer) { + this.addSlotToContainer(new Slot(this.mTileEntity, 2, 116, 62)); + this.addSlotToContainer(new Slot(this.mTileEntity, 0, 44, 26)); + this.addSlotToContainer(new Slot(this.mTileEntity, 1, 44, 62)); + this.addSlotToContainer(new Slot(this.mTileEntity, 3, 116, 26)); + } - @Override - public int getSlotCount() - { - return 4; - } + @Override + public int getSlotCount() { + return 4; + } - @Override - public int getShiftClickSlotCount() - { - return 1; - } + @Override + public int getShiftClickSlotCount() { + return 1; + } - public int mWaterAmount = 0; - public int mSteamAmount = 0; - public int mProcessingEnergy = 0; - public int mTemperature = 2; - public long mTickingTime = ((GregtechMetaBoilerBase)this.mTileEntity.getMetaTileEntity()).RI; + public int mWaterAmount = 0; + public int mSteamAmount = 0; + public int mProcessingEnergy = 0; + public int mTemperature = 2; + public long mTickingTime = ((GregtechMetaBoilerBase) this.mTileEntity.getMetaTileEntity()).RI; - @Override - public void detectAndSendChanges() - { - super.detectAndSendChanges(); - if ((this.mTileEntity.isClientSide()) || (this.mTileEntity.getMetaTileEntity() == null)) { - return; - } - int steamCapacity = ((GregtechMetaBoilerBase)this.mTileEntity.getMetaTileEntity()).getSteamCapacity(); - int waterCapacity = ((GregtechMetaBoilerBase)this.mTileEntity.getMetaTileEntity()).getCapacity(); - this.mTemperature = ((GregtechMetaBoilerBase)this.mTileEntity.getMetaTileEntity()).mTemperature; - this.mProcessingEnergy = ((GregtechMetaBoilerBase)this.mTileEntity.getMetaTileEntity()).mProcessingEnergy; - this.mSteamAmount = (((GregtechMetaBoilerBase)this.mTileEntity.getMetaTileEntity()).mSteam == null ? 0 : ((GregtechMetaBoilerBase)this.mTileEntity.getMetaTileEntity()).mSteam.amount); - this.mWaterAmount = (((GregtechMetaBoilerBase)this.mTileEntity.getMetaTileEntity()).mFluid == null ? 0 : ((GregtechMetaBoilerBase)this.mTileEntity.getMetaTileEntity()).mFluid.amount); - this.mTickingTime = ((GregtechMetaBoilerBase)this.mTileEntity.getMetaTileEntity()).RI; + @Override + public void detectAndSendChanges() { + super.detectAndSendChanges(); + if ((this.mTileEntity.isClientSide()) || (this.mTileEntity.getMetaTileEntity() == null)) { + return; + } + int steamCapacity = ((GregtechMetaBoilerBase) this.mTileEntity.getMetaTileEntity()).getSteamCapacity(); + int waterCapacity = ((GregtechMetaBoilerBase) this.mTileEntity.getMetaTileEntity()).getCapacity(); + this.mTemperature = ((GregtechMetaBoilerBase) this.mTileEntity.getMetaTileEntity()).mTemperature; + this.mProcessingEnergy = ((GregtechMetaBoilerBase) this.mTileEntity.getMetaTileEntity()).mProcessingEnergy; + this.mSteamAmount = (((GregtechMetaBoilerBase) this.mTileEntity.getMetaTileEntity()).mSteam == null + ? 0 + : ((GregtechMetaBoilerBase) this.mTileEntity.getMetaTileEntity()).mSteam.amount); + this.mWaterAmount = (((GregtechMetaBoilerBase) this.mTileEntity.getMetaTileEntity()).mFluid == null + ? 0 + : ((GregtechMetaBoilerBase) this.mTileEntity.getMetaTileEntity()).mFluid.amount); + this.mTickingTime = ((GregtechMetaBoilerBase) this.mTileEntity.getMetaTileEntity()).RI; - this.mTemperature = Math.min(54, Math.max(0, (this.mTemperature * 54) / (((GregtechMetaBoilerBase)this.mTileEntity.getMetaTileEntity()).maxProgresstime() - 10))); - this.mSteamAmount = Math.min(54, Math.max(0, (this.mSteamAmount * 54) / (steamCapacity - 100))); - this.mWaterAmount = Math.min(54, Math.max(0, (this.mWaterAmount * 54) / (waterCapacity - 100))); - this.mProcessingEnergy = Math.min(14, Math.max(this.mProcessingEnergy > 0 ? 1 : 0, (this.mProcessingEnergy * 14) / 1000)); + this.mTemperature = Math.min( + 54, + Math.max( + 0, + (this.mTemperature * 54) + / (((GregtechMetaBoilerBase) this.mTileEntity.getMetaTileEntity()).maxProgresstime() + - 10))); + this.mSteamAmount = Math.min(54, Math.max(0, (this.mSteamAmount * 54) / (steamCapacity - 100))); + this.mWaterAmount = Math.min(54, Math.max(0, (this.mWaterAmount * 54) / (waterCapacity - 100))); + this.mProcessingEnergy = + Math.min(14, Math.max(this.mProcessingEnergy > 0 ? 1 : 0, (this.mProcessingEnergy * 14) / 1000)); - final Iterator var2 = this.crafters.iterator(); - while (var2.hasNext()) - { - final ICrafting var1 = (ICrafting)var2.next(); - var1.sendProgressBarUpdate(this, 100, this.mTemperature); - var1.sendProgressBarUpdate(this, 101, this.mProcessingEnergy); - var1.sendProgressBarUpdate(this, 102, this.mSteamAmount); - var1.sendProgressBarUpdate(this, 103, this.mWaterAmount); - } - } + final Iterator var2 = this.crafters.iterator(); + while (var2.hasNext()) { + final ICrafting var1 = (ICrafting) var2.next(); + var1.sendProgressBarUpdate(this, 100, this.mTemperature); + var1.sendProgressBarUpdate(this, 101, this.mProcessingEnergy); + var1.sendProgressBarUpdate(this, 102, this.mSteamAmount); + var1.sendProgressBarUpdate(this, 103, this.mWaterAmount); + } + } - @Override - @SideOnly(Side.CLIENT) - public void updateProgressBar(final int par1, final int par2) - { - super.updateProgressBar(par1, par2); - switch (par1) - { - case 100: - this.mTemperature = par2; break; - case 101: - this.mProcessingEnergy = par2; break; - case 102: - this.mSteamAmount = par2; break; - case 103: - this.mWaterAmount = par2; - } - } -}
\ No newline at end of file + @Override + @SideOnly(Side.CLIENT) + public void updateProgressBar(final int par1, final int par2) { + super.updateProgressBar(par1, par2); + switch (par1) { + case 100: + this.mTemperature = par2; + break; + case 101: + this.mProcessingEnergy = par2; + break; + case 102: + this.mSteamAmount = par2; + break; + case 103: + this.mWaterAmount = par2; + } + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_SuperChest.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_SuperChest.java index dcab57c380..65d4e46069 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_SuperChest.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_SuperChest.java @@ -1,7 +1,5 @@ package gtPlusPlus.xmod.gregtech.api.gui; -import java.util.Iterator; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.gui.GT_ContainerMetaTile_Machine; @@ -11,68 +9,67 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gtPlusPlus.core.slots.SlotLockedInput; import gtPlusPlus.xmod.gregtech.common.tileentities.storage.GT_MetaTileEntity_TieredChest; import gtPlusPlus.xmod.gregtech.common.tileentities.storage.shelving.GT4Entity_Shelf_Large; +import java.util.Iterator; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.ICrafting; import net.minecraft.item.ItemStack; public class CONTAINER_SuperChest extends GT_ContainerMetaTile_Machine { - - public int mContent = 0; - private ItemStack mLockedSlotStack = null; - public CONTAINER_SuperChest(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { - super(aInventoryPlayer, aTileEntity); - } + public int mContent = 0; + private ItemStack mLockedSlotStack = null; - public void addSlots(InventoryPlayer aInventoryPlayer) { - this.addSlotToContainer(new SlotLockedInput(this.mTileEntity, 0, 80, 17, mLockedSlotStack)); - this.addSlotToContainer(new GT_Slot_Output(this.mTileEntity, 1, 80, 53)); - this.addSlotToContainer(new GT_Slot_Render(this.mTileEntity, 2, 59, 42)); - } + public CONTAINER_SuperChest(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { + super(aInventoryPlayer, aTileEntity); + } - public void detectAndSendChanges() { - super.detectAndSendChanges(); - if (!this.mTileEntity.isClientSide() && this.mTileEntity.getMetaTileEntity() != null) { - if (this.mTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_TieredChest) { - this.mContent = ((GT_MetaTileEntity_TieredChest) this.mTileEntity.getMetaTileEntity()).mItemCount; - mLockedSlotStack = ((GT_MetaTileEntity_TieredChest) this.mTileEntity.getMetaTileEntity()).mItemStack; - } - if (this.mTileEntity.getMetaTileEntity() instanceof GT4Entity_Shelf_Large) { - this.mContent = ((GT4Entity_Shelf_Large) this.mTileEntity.getMetaTileEntity()).mItemCount; - mLockedSlotStack = ((GT4Entity_Shelf_Large) this.mTileEntity.getMetaTileEntity()).mItemStack; - } - else { - this.mContent = 0; - } + public void addSlots(InventoryPlayer aInventoryPlayer) { + this.addSlotToContainer(new SlotLockedInput(this.mTileEntity, 0, 80, 17, mLockedSlotStack)); + this.addSlotToContainer(new GT_Slot_Output(this.mTileEntity, 1, 80, 53)); + this.addSlotToContainer(new GT_Slot_Render(this.mTileEntity, 2, 59, 42)); + } - Iterator var2 = this.crafters.iterator(); + public void detectAndSendChanges() { + super.detectAndSendChanges(); + if (!this.mTileEntity.isClientSide() && this.mTileEntity.getMetaTileEntity() != null) { + if (this.mTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_TieredChest) { + this.mContent = ((GT_MetaTileEntity_TieredChest) this.mTileEntity.getMetaTileEntity()).mItemCount; + mLockedSlotStack = ((GT_MetaTileEntity_TieredChest) this.mTileEntity.getMetaTileEntity()).mItemStack; + } + if (this.mTileEntity.getMetaTileEntity() instanceof GT4Entity_Shelf_Large) { + this.mContent = ((GT4Entity_Shelf_Large) this.mTileEntity.getMetaTileEntity()).mItemCount; + mLockedSlotStack = ((GT4Entity_Shelf_Large) this.mTileEntity.getMetaTileEntity()).mItemStack; + } else { + this.mContent = 0; + } - while (var2.hasNext()) { - ICrafting var1 = (ICrafting) var2.next(); - var1.sendProgressBarUpdate(this, 100, this.mContent & 65535); - var1.sendProgressBarUpdate(this, 101, this.mContent >>> 16); - } - } - } + Iterator var2 = this.crafters.iterator(); - @SideOnly(Side.CLIENT) - public void updateProgressBar(int par1, int par2) { - super.updateProgressBar(par1, par2); - switch (par1) { - case 100 : - this.mContent = this.mContent & -65536 | par2; - break; - case 101 : - this.mContent = this.mContent & 65535 | par2 << 16; - } + while (var2.hasNext()) { + ICrafting var1 = (ICrafting) var2.next(); + var1.sendProgressBarUpdate(this, 100, this.mContent & 65535); + var1.sendProgressBarUpdate(this, 101, this.mContent >>> 16); + } + } + } - } + @SideOnly(Side.CLIENT) + public void updateProgressBar(int par1, int par2) { + super.updateProgressBar(par1, par2); + switch (par1) { + case 100: + this.mContent = this.mContent & -65536 | par2; + break; + case 101: + this.mContent = this.mContent & 65535 | par2 << 16; + } + } - public int getSlotCount() { - return 2; - } + public int getSlotCount() { + return 2; + } - public int getShiftClickSlotCount() { - return 1; - } -}
\ No newline at end of file + public int getShiftClickSlotCount() { + return 1; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_TreeFarmer.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_TreeFarmer.java index bf4dffb904..5724ab6c04 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_TreeFarmer.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_TreeFarmer.java @@ -1,71 +1,72 @@ - package gtPlusPlus.xmod.gregtech.api.gui; -import java.util.List; - -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.ICrafting; - import gregtech.api.gui.GT_ContainerMetaTile_Machine; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; - import gtPlusPlus.core.slots.SlotBuzzSaw; import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.GregtechMetaTileEntityTreeFarm; +import java.util.List; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.ICrafting; public class CONTAINER_TreeFarmer extends GT_ContainerMetaTile_Machine { - public long maxEU = 0; - public long storedEU = 0; - - public CONTAINER_TreeFarmer(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity) { - super(aInventoryPlayer, aTileEntity); - } + public long maxEU = 0; + public long storedEU = 0; - public CONTAINER_TreeFarmer(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity, final boolean bindInventory) { - super(aInventoryPlayer, aTileEntity, bindInventory); - } + public CONTAINER_TreeFarmer(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity) { + super(aInventoryPlayer, aTileEntity); + } - @Override - public void addSlots(final InventoryPlayer aInventoryPlayer) { - this.addSlotToContainer(new SlotBuzzSaw(this.mTileEntity, 1, 80, 17)); - } + public CONTAINER_TreeFarmer( + final InventoryPlayer aInventoryPlayer, + final IGregTechTileEntity aTileEntity, + final boolean bindInventory) { + super(aInventoryPlayer, aTileEntity, bindInventory); + } - @Override - public int getSlotCount() { - return 1; - } + @Override + public void addSlots(final InventoryPlayer aInventoryPlayer) { + this.addSlotToContainer(new SlotBuzzSaw(this.mTileEntity, 1, 80, 17)); + } - @Override - public int getShiftClickSlotCount() { - return 1; - } + @Override + public int getSlotCount() { + return 1; + } - @Override - public void updateProgressBar(final int id, final int value) { - super.updateProgressBar(id, value); - switch (id) { - case 100: - this.maxEU = value; - return; - case 101: - this.storedEU = value; - break; - default: - break; - } - } + @Override + public int getShiftClickSlotCount() { + return 1; + } - @SuppressWarnings("unchecked") - @Override - public void detectAndSendChanges() { - super.detectAndSendChanges(); - for(final ICrafting crafting : (List<ICrafting>)this.crafters) { - crafting.sendProgressBarUpdate(this, 100, (int) ((GregtechMetaTileEntityTreeFarm) this.mTileEntity.getMetaTileEntity()).maxEUStore()); - crafting.sendProgressBarUpdate(this, 101, (int) ((GregtechMetaTileEntityTreeFarm) this.mTileEntity.getMetaTileEntity()).getEUVar()); - if (((GregtechMetaTileEntityTreeFarm) this.mTileEntity.getMetaTileEntity()).isCorrectMachinePart(this.mTileEntity.getStackInSlot(1))){ - this.mTileEntity.markDirty(); - } - } - } + @Override + public void updateProgressBar(final int id, final int value) { + super.updateProgressBar(id, value); + switch (id) { + case 100: + this.maxEU = value; + return; + case 101: + this.storedEU = value; + break; + default: + break; + } + } + @SuppressWarnings("unchecked") + @Override + public void detectAndSendChanges() { + super.detectAndSendChanges(); + for (final ICrafting crafting : (List<ICrafting>) this.crafters) { + crafting.sendProgressBarUpdate(this, 100, (int) + ((GregtechMetaTileEntityTreeFarm) this.mTileEntity.getMetaTileEntity()).maxEUStore()); + crafting.sendProgressBarUpdate(this, 101, (int) + ((GregtechMetaTileEntityTreeFarm) this.mTileEntity.getMetaTileEntity()).getEUVar()); + if (((GregtechMetaTileEntityTreeFarm) this.mTileEntity.getMetaTileEntity()) + .isCorrectMachinePart(this.mTileEntity.getStackInSlot(1))) { + this.mTileEntity.markDirty(); + } + } + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_AdvancedBoiler.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_AdvancedBoiler.java index d532a98030..a924e2a6a5 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_AdvancedBoiler.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_AdvancedBoiler.java @@ -1,23 +1,21 @@ package gtPlusPlus.xmod.gregtech.api.gui; -import net.minecraft.entity.player.InventoryPlayer; - import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import net.minecraft.entity.player.InventoryPlayer; -public class GUI_AdvancedBoiler - extends GT_GUIContainerMetaTile_Machine { +public class GUI_AdvancedBoiler extends GT_GUIContainerMetaTile_Machine { public GUI_AdvancedBoiler(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aTextureName) { super(new CONTAINER_AdvancedBoiler(aInventoryPlayer, aTileEntity), "miscutils:textures/gui/" + aTextureName); } @Override - protected void drawGuiContainerForegroundLayer(int par1, int par2) { + protected void drawGuiContainerForegroundLayer(int par1, int par2) { this.fontRendererObj.drawString("Advanced Boiler", 8, 4, 4210752); } @Override - protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { + protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { super.drawGuiContainerBackgroundLayer(par1, par2, par3); int x = (this.width - this.xSize) / 2; int y = (this.height - this.ySize) / 2; diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_Cyclotron.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_Cyclotron.java index 0be44fa616..b31bc7b24c 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_Cyclotron.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_Cyclotron.java @@ -5,40 +5,45 @@ import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import net.minecraft.entity.player.InventoryPlayer; -public class GUI_Cyclotron extends GT_GUIContainerMetaTile_Machine -{ +public class GUI_Cyclotron extends GT_GUIContainerMetaTile_Machine { public final String mNEI; public final String mName; - - public GUI_Cyclotron(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity, final String aName, final String aNEI) { - super(new GT_Container_MultiMachine(aInventoryPlayer, aTileEntity, false), "gregtech:textures/gui/multimachines/" + "FusionComputer.png"); + + public GUI_Cyclotron( + final InventoryPlayer aInventoryPlayer, + final IGregTechTileEntity aTileEntity, + final String aName, + final String aNEI) { + super( + new GT_Container_MultiMachine(aInventoryPlayer, aTileEntity, false), + "gregtech:textures/gui/multimachines/" + "FusionComputer.png"); this.mName = aName; this.mNEI = aNEI; } - + @Override protected void drawGuiContainerForegroundLayer(final int par1, final int par2) { this.fontRendererObj.drawString(this.mName, 8, -10, 16448255); if (this.mContainer != null) { - if ((((GT_Container_MultiMachine)this.mContainer).mDisplayErrorCode & 0x40) != 0x0) { + if ((((GT_Container_MultiMachine) this.mContainer).mDisplayErrorCode & 0x40) != 0x0) { this.fontRendererObj.drawString("Incomplete Structure.", 10, 8, 16448255); } - if (((GT_Container_MultiMachine)this.mContainer).mDisplayErrorCode == 0) { - if (((GT_Container_MultiMachine)this.mContainer).mActive == 0) { - this.fontRendererObj.drawString("Hit with Soft Hammer to (re-)start the Machine if it doesn't start.", -70, 170, 16448255); - } - else { + if (((GT_Container_MultiMachine) this.mContainer).mDisplayErrorCode == 0) { + if (((GT_Container_MultiMachine) this.mContainer).mActive == 0) { + this.fontRendererObj.drawString( + "Hit with Soft Hammer to (re-)start the Machine if it doesn't start.", -70, 170, 16448255); + } else { this.fontRendererObj.drawString("Running perfectly.", 10, 170, 16448255); } - } + } } } - + @Override protected void drawGuiContainerBackgroundLayer(final float par1, final int par2, final int par3) { super.drawGuiContainerBackgroundLayer(par1, par2, par3); final int x = (this.width - this.xSize) / 2; final int y = (this.height - this.ySize) / 2; - this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); + this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_DataHatch.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_DataHatch.java index 77cb0d71a2..b42e2fae2f 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_DataHatch.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_DataHatch.java @@ -1,11 +1,10 @@ package gtPlusPlus.xmod.gregtech.api.gui; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import net.minecraft.entity.player.InventoryPlayer; - import static gregtech.api.enums.GT_Values.RES_PATH_GUI; import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import net.minecraft.entity.player.InventoryPlayer; public class GUI_DataHatch extends GT_GUIContainerMetaTile_Machine { @@ -16,7 +15,8 @@ public class GUI_DataHatch extends GT_GUIContainerMetaTile_Machine { mName = aName; } - public GUI_DataHatch(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName, String aBackground) { + public GUI_DataHatch( + InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName, String aBackground) { super(new CONTAINER_DataHatch(aInventoryPlayer, aTileEntity), RES_PATH_GUI + aBackground + "HatchDataOrb.png"); mName = aName; } @@ -24,11 +24,11 @@ public class GUI_DataHatch extends GT_GUIContainerMetaTile_Machine { @Override protected void drawGuiContainerForegroundLayer(int par1, int par2) { fontRendererObj.drawString(mName, 8, 4, 4210752); - /*String[] aName = mName.trim().split("\\s+"); - int aY = 4; - for (String s : aName) { - fontRendererObj.drawString(s, 120, (aY += 12), 4210752); - }*/ + /*String[] aName = mName.trim().split("\\s+"); + int aY = 4; + for (String s : aName) { + fontRendererObj.drawString(s, 120, (aY += 12), 4210752); + }*/ } @Override diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_DeluxeTank.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_DeluxeTank.java index c6d8d4ef7e..0b851332b8 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_DeluxeTank.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_DeluxeTank.java @@ -2,36 +2,38 @@ package gtPlusPlus.xmod.gregtech.api.gui; import static gregtech.api.enums.GT_Values.RES_PATH_GUI; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.util.StatCollector; - import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.StatCollector; public class GUI_DeluxeTank extends GT_GUIContainerMetaTile_Machine { - private final String mName; - - public GUI_DeluxeTank(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity, final String aName) { - super(new CONTAINER_DeluxeTank(aInventoryPlayer, aTileEntity), RES_PATH_GUI + "BasicTank.png"); - this.mName = aName; - } - - @Override - protected void drawGuiContainerForegroundLayer(final int par1, final int par2) { - this.fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 8, (this.ySize - 96) + 2, 4210752); - this.fontRendererObj.drawString(this.mName, 8, 6, 4210752); - if (this.mContainer != null) { - this.fontRendererObj.drawString("Fuel | A | B |", 10, 20, 16448255); - //fontRendererObj.drawString(GT_Utility.parseNumberToString(((CONTAINER_DeluxeTank) mContainer).mContent), 10, 30, 16448255); - } - } - - @Override - protected void drawGuiContainerBackgroundLayer(final float par1, final int par2, final int par3) { - super.drawGuiContainerBackgroundLayer(par1, par2, par3); - final int x = (this.width - this.xSize) / 2; - final int y = (this.height - this.ySize) / 2; - this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); - } + private final String mName; + + public GUI_DeluxeTank( + final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity, final String aName) { + super(new CONTAINER_DeluxeTank(aInventoryPlayer, aTileEntity), RES_PATH_GUI + "BasicTank.png"); + this.mName = aName; + } + + @Override + protected void drawGuiContainerForegroundLayer(final int par1, final int par2) { + this.fontRendererObj.drawString( + StatCollector.translateToLocal("container.inventory"), 8, (this.ySize - 96) + 2, 4210752); + this.fontRendererObj.drawString(this.mName, 8, 6, 4210752); + if (this.mContainer != null) { + this.fontRendererObj.drawString("Fuel | A | B |", 10, 20, 16448255); + // fontRendererObj.drawString(GT_Utility.parseNumberToString(((CONTAINER_DeluxeTank) mContainer).mContent), + // 10, 30, 16448255); + } + } + + @Override + protected void drawGuiContainerBackgroundLayer(final float par1, final int par2, final int par3) { + super.drawGuiContainerBackgroundLayer(par1, par2, par3); + final int x = (this.width - this.xSize) / 2; + final int y = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_Hatch_Muffler_Advanced.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_Hatch_Muffler_Advanced.java index 4b998f6487..af0462b773 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_Hatch_Muffler_Advanced.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_Hatch_Muffler_Advanced.java @@ -1,6 +1,5 @@ package gtPlusPlus.xmod.gregtech.api.gui; - import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gtPlusPlus.core.lib.CORE; @@ -8,39 +7,45 @@ import net.minecraft.entity.player.InventoryPlayer; public class GUI_Hatch_Muffler_Advanced extends GT_GUIContainerMetaTile_Machine { - String mName = ""; - long maxPower = 0; - long storedPower = 0; + String mName = ""; + long maxPower = 0; + long storedPower = 0; - public GUI_Hatch_Muffler_Advanced(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity, final String aName, final String aTextureFile) { - super(new CONTAINER_Hatch_Muffler_Advanced(aInventoryPlayer, aTileEntity), CORE.RES_PATH_GUI + (aTextureFile == null ? "MultiblockDisplay" : aTextureFile)); - this.mName = aName; - } + public GUI_Hatch_Muffler_Advanced( + final InventoryPlayer aInventoryPlayer, + final IGregTechTileEntity aTileEntity, + final String aName, + final String aTextureFile) { + super( + new CONTAINER_Hatch_Muffler_Advanced(aInventoryPlayer, aTileEntity), + CORE.RES_PATH_GUI + (aTextureFile == null ? "MultiblockDisplay" : aTextureFile)); + this.mName = aName; + } - @Override - protected void drawGuiContainerForegroundLayer(final int par1, final int par2) { - this.fontRendererObj.drawString(this.mName, 8, 8, 16448255); - /* - * ReflectionUtils.setField(this.fontRendererObj, "underlineStyle", true); - * ReflectionUtils.setField(this.fontRendererObj, "italicStyle", true); - * ReflectionUtils.setField(this.fontRendererObj, "boldStyle", true); boolean - * isBold = ReflectionUtils.getField(this.fontRendererObj, "boldStyle"); - * this.fontRendererObj.drawString("Insert Air Filters - Bold: "+isBold, 8, 18, - * 16448255); - */ - if (this.mContainer != null) { - //this.maxPower = ((CONTAINER_TreeFarmer)this.mContainer).maxEU; - //this.storedPower = ((CONTAINER_TreeFarmer)this.mContainer).storedEU; - } - } + @Override + protected void drawGuiContainerForegroundLayer(final int par1, final int par2) { + this.fontRendererObj.drawString(this.mName, 8, 8, 16448255); + /* + * ReflectionUtils.setField(this.fontRendererObj, "underlineStyle", true); + * ReflectionUtils.setField(this.fontRendererObj, "italicStyle", true); + * ReflectionUtils.setField(this.fontRendererObj, "boldStyle", true); boolean + * isBold = ReflectionUtils.getField(this.fontRendererObj, "boldStyle"); + * this.fontRendererObj.drawString("Insert Air Filters - Bold: "+isBold, 8, 18, + * 16448255); + */ + if (this.mContainer != null) { + // this.maxPower = ((CONTAINER_TreeFarmer)this.mContainer).maxEU; + // this.storedPower = ((CONTAINER_TreeFarmer)this.mContainer).storedEU; + } + } - @Override - protected void drawGuiContainerBackgroundLayer(final float par1, final int par2, final int par3) { - super.drawGuiContainerBackgroundLayer(par1, par2, par3); - //this.maxPower = ((CONTAINER_TreeFarmer)this.mContainer).maxEU; - //this.storedPower = ((CONTAINER_TreeFarmer)this.mContainer).storedEU; - final int x = (this.width - this.xSize) / 2; - final int y = (this.height - this.ySize) / 2; - this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); - } + @Override + protected void drawGuiContainerBackgroundLayer(final float par1, final int par2, final int par3) { + super.drawGuiContainerBackgroundLayer(par1, par2, par3); + // this.maxPower = ((CONTAINER_TreeFarmer)this.mContainer).maxEU; + // this.storedPower = ((CONTAINER_TreeFarmer)this.mContainer).storedEU; + final int x = (this.width - this.xSize) / 2; + final int y = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_IndustrialCentrifuge.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_IndustrialCentrifuge.java index 2e1f76f362..d28e46b1d9 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_IndustrialCentrifuge.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_IndustrialCentrifuge.java @@ -1,73 +1,74 @@ package gtPlusPlus.xmod.gregtech.api.gui; - -import net.minecraft.entity.player.InventoryPlayer; - import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; - import gtPlusPlus.core.lib.CORE; - +import net.minecraft.entity.player.InventoryPlayer; public class GUI_IndustrialCentrifuge extends GT_GUIContainerMetaTile_Machine { - String mName = ""; - private short counter = 0; + String mName = ""; + private short counter = 0; - public GUI_IndustrialCentrifuge(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity, final String aName, final String aTextureFile) { - super(new CONTAINER_IndustrialCentrifuge(aInventoryPlayer, aTileEntity), CORE.RES_PATH_GUI + (aTextureFile == null ? "MultiblockDisplay" : aTextureFile)); - this.mName = aName; - } + public GUI_IndustrialCentrifuge( + final InventoryPlayer aInventoryPlayer, + final IGregTechTileEntity aTileEntity, + final String aName, + final String aTextureFile) { + super( + new CONTAINER_IndustrialCentrifuge(aInventoryPlayer, aTileEntity), + CORE.RES_PATH_GUI + (aTextureFile == null ? "MultiblockDisplay" : aTextureFile)); + this.mName = aName; + } - @Override - protected void drawGuiContainerForegroundLayer(final int par1, final int par2) { - this.fontRendererObj.drawString(this.mName, 10, 8, 16448255); - if (this.counter >= 100){ - this.counter = 0; - } - else { - this.counter++; - } - if (this.mContainer != null) { - if ((((CONTAINER_IndustrialCentrifuge) this.mContainer).mDisplayErrorCode & 1) != 0) { - this.fontRendererObj.drawString("Pipe is loose.", 10, 16, 16448255); - } - if ((((CONTAINER_IndustrialCentrifuge) this.mContainer).mDisplayErrorCode & 2) != 0) { - this.fontRendererObj.drawString("Screws are missing.", 10, 24, 16448255); - } - if ((((CONTAINER_IndustrialCentrifuge) this.mContainer).mDisplayErrorCode & 4) != 0) { - this.fontRendererObj.drawString("Something is stuck.", 10, 32, 16448255); - } - if ((((CONTAINER_IndustrialCentrifuge) this.mContainer).mDisplayErrorCode & 8) != 0) { - this.fontRendererObj.drawString("Platings are dented.", 10, 40, 16448255); - } - if ((((CONTAINER_IndustrialCentrifuge) this.mContainer).mDisplayErrorCode & 32) != 0) { - this.fontRendererObj.drawString("That doesn't belong there.", 10, 56, 16448255); - } - if ((((CONTAINER_IndustrialCentrifuge) this.mContainer).mDisplayErrorCode & 64) != 0) { - this.fontRendererObj.drawString("Incomplete Structure.", 10, 64, 16448255); - } + @Override + protected void drawGuiContainerForegroundLayer(final int par1, final int par2) { + this.fontRendererObj.drawString(this.mName, 10, 8, 16448255); + if (this.counter >= 100) { + this.counter = 0; + } else { + this.counter++; + } + if (this.mContainer != null) { + if ((((CONTAINER_IndustrialCentrifuge) this.mContainer).mDisplayErrorCode & 1) != 0) { + this.fontRendererObj.drawString("Pipe is loose.", 10, 16, 16448255); + } + if ((((CONTAINER_IndustrialCentrifuge) this.mContainer).mDisplayErrorCode & 2) != 0) { + this.fontRendererObj.drawString("Screws are missing.", 10, 24, 16448255); + } + if ((((CONTAINER_IndustrialCentrifuge) this.mContainer).mDisplayErrorCode & 4) != 0) { + this.fontRendererObj.drawString("Something is stuck.", 10, 32, 16448255); + } + if ((((CONTAINER_IndustrialCentrifuge) this.mContainer).mDisplayErrorCode & 8) != 0) { + this.fontRendererObj.drawString("Platings are dented.", 10, 40, 16448255); + } + if ((((CONTAINER_IndustrialCentrifuge) this.mContainer).mDisplayErrorCode & 32) != 0) { + this.fontRendererObj.drawString("That doesn't belong there.", 10, 56, 16448255); + } + if ((((CONTAINER_IndustrialCentrifuge) this.mContainer).mDisplayErrorCode & 64) != 0) { + this.fontRendererObj.drawString("Incomplete Structure.", 10, 64, 16448255); + } - if (((CONTAINER_IndustrialCentrifuge) this.mContainer).mDisplayErrorCode == 0) { - if (((CONTAINER_IndustrialCentrifuge) this.mContainer).mActive == 0) { - this.fontRendererObj.drawString("Hit with Soft Hammer", 10, 16, 16448255); - this.fontRendererObj.drawString("to (re-)start the Machine", 10, 24, 16448255); - this.fontRendererObj.drawString("if it doesn't start.", 10, 32, 16448255); - } else { - this.fontRendererObj.drawString("Running perfectly.", 10, 16, 16448255); - /*if (CORE.DEBUG){ - fontRendererObj.drawString("Debug Counter: "+counter, 10, 56, 16448255); - }*/ - } - } - } - } + if (((CONTAINER_IndustrialCentrifuge) this.mContainer).mDisplayErrorCode == 0) { + if (((CONTAINER_IndustrialCentrifuge) this.mContainer).mActive == 0) { + this.fontRendererObj.drawString("Hit with Soft Hammer", 10, 16, 16448255); + this.fontRendererObj.drawString("to (re-)start the Machine", 10, 24, 16448255); + this.fontRendererObj.drawString("if it doesn't start.", 10, 32, 16448255); + } else { + this.fontRendererObj.drawString("Running perfectly.", 10, 16, 16448255); + /*if (CORE.DEBUG){ + fontRendererObj.drawString("Debug Counter: "+counter, 10, 56, 16448255); + }*/ + } + } + } + } - @Override - protected void drawGuiContainerBackgroundLayer(final float par1, final int par2, final int par3) { - super.drawGuiContainerBackgroundLayer(par1, par2, par3); - final int x = (this.width - this.xSize) / 2; - final int y = (this.height - this.ySize) / 2; - this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); - } + @Override + protected void drawGuiContainerBackgroundLayer(final float par1, final int par2, final int par3) { + super.drawGuiContainerBackgroundLayer(par1, par2, par3); + final int x = (this.width - this.xSize) / 2; + final int y = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_IronBlastFurnace.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_IronBlastFurnace.java index b44ad916b7..409e7a29ae 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_IronBlastFurnace.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_IronBlastFurnace.java @@ -1,32 +1,44 @@ package gtPlusPlus.xmod.gregtech.api.gui; -import net.minecraft.entity.player.InventoryPlayer; - import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; - import gtPlusPlus.core.lib.CORE; +import net.minecraft.entity.player.InventoryPlayer; -public class GUI_IronBlastFurnace -extends GT_GUIContainerMetaTile_Machine { - public GUI_IronBlastFurnace(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity) { - super(new CONTAINER_IronBlastFurnace(aInventoryPlayer, aTileEntity), CORE.RES_PATH_GUI+"IronBlastFurnace.png"); - } +public class GUI_IronBlastFurnace extends GT_GUIContainerMetaTile_Machine { + public GUI_IronBlastFurnace(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity) { + super( + new CONTAINER_IronBlastFurnace(aInventoryPlayer, aTileEntity), + CORE.RES_PATH_GUI + "IronBlastFurnace.png"); + } - @Override - protected void drawGuiContainerForegroundLayer(final int par1, final int par2) { - this.fontRendererObj.drawString("Iron Blast Furnace", 8, 4, 4210752); - } + @Override + protected void drawGuiContainerForegroundLayer(final int par1, final int par2) { + this.fontRendererObj.drawString("Iron Blast Furnace", 8, 4, 4210752); + } - @Override - protected void drawGuiContainerBackgroundLayer(final float par1, final int par2, final int par3) { - super.drawGuiContainerBackgroundLayer(par1, par2, par3); - final int x = (this.width - this.xSize) / 2; - final int y = (this.height - this.ySize) / 2; - this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); - if ((this.mContainer != null) && - (this.mContainer.mProgressTime > 0)) { - this.drawTexturedModalRect(x + 58, y + 28, 176, 0, Math.max(0, Math.min(20, 1 + ((this.mContainer.mProgressTime * 20) / (this.mContainer.mMaxProgressTime < 1 ? 1 : this.mContainer.mMaxProgressTime)))), 11); - } - } + @Override + protected void drawGuiContainerBackgroundLayer(final float par1, final int par2, final int par3) { + super.drawGuiContainerBackgroundLayer(par1, par2, par3); + final int x = (this.width - this.xSize) / 2; + final int y = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); + if ((this.mContainer != null) && (this.mContainer.mProgressTime > 0)) { + this.drawTexturedModalRect( + x + 58, + y + 28, + 176, + 0, + Math.max( + 0, + Math.min( + 20, + 1 + + ((this.mContainer.mProgressTime * 20) + / (this.mContainer.mMaxProgressTime < 1 + ? 1 + : this.mContainer.mMaxProgressTime)))), + 11); + } + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_MatterFab.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_MatterFab.java index f7869bff60..9dc0c8b9e2 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_MatterFab.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_MatterFab.java @@ -1,12 +1,9 @@ package gtPlusPlus.xmod.gregtech.api.gui; - -import net.minecraft.entity.player.InventoryPlayer; - import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.lib.CORE; +import net.minecraft.entity.player.InventoryPlayer; /** * NEVER INCLUDE THIS FILE IN YOUR MOD!!! @@ -17,78 +14,82 @@ import gtPlusPlus.core.lib.CORE; */ public class GUI_MatterFab extends GT_GUIContainerMetaTile_Machine { - String mName = ""; - public int mMatterProduced = 0; - public int mScrapProduced = 0; - public int mAmplifierProduced = 0; - public int mScrapUsed = 0; - public int mAmplifierUsed = 0; + String mName = ""; + public int mMatterProduced = 0; + public int mScrapProduced = 0; + public int mAmplifierProduced = 0; + public int mScrapUsed = 0; + public int mAmplifierUsed = 0; + + public GUI_MatterFab( + final InventoryPlayer aInventoryPlayer, + final IGregTechTileEntity aTileEntity, + final String aName, + final String aTextureFile) { + super( + new CONTAINER_MatterFab(aInventoryPlayer, aTileEntity), + CORE.RES_PATH_GUI + (aTextureFile == null ? "MultiblockDisplay" : aTextureFile)); + this.mName = aName; + } - public GUI_MatterFab(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity, final String aName, final String aTextureFile) { - super(new CONTAINER_MatterFab(aInventoryPlayer, aTileEntity), CORE.RES_PATH_GUI + (aTextureFile == null ? "MultiblockDisplay" : aTextureFile)); - this.mName = aName; - } + @Override + protected void drawGuiContainerForegroundLayer(final int par1, final int par2) { + this.fontRendererObj.drawString(this.mName, 10, 8, 16448255); - @Override - protected void drawGuiContainerForegroundLayer(final int par1, final int par2) { - this.fontRendererObj.drawString(this.mName, 10, 8, 16448255); + if (this.mContainer != null) { + if ((((CONTAINER_MatterFab) this.mContainer).mDisplayErrorCode & 1) != 0) { + this.fontRendererObj.drawString("Pipe is loose.", 10, 16, 16448255); + } + if ((((CONTAINER_MatterFab) this.mContainer).mDisplayErrorCode & 2) != 0) { + this.fontRendererObj.drawString("Screws are missing.", 10, 24, 16448255); + } + if ((((CONTAINER_MatterFab) this.mContainer).mDisplayErrorCode & 4) != 0) { + this.fontRendererObj.drawString("Something is stuck.", 10, 32, 16448255); + } + if ((((CONTAINER_MatterFab) this.mContainer).mDisplayErrorCode & 8) != 0) { + this.fontRendererObj.drawString("Platings are dented.", 10, 40, 16448255); + } + if ((((CONTAINER_MatterFab) this.mContainer).mDisplayErrorCode & 16) != 0) { + this.fontRendererObj.drawString("Circuitry burned out.", 10, 48, 16448255); + } + if ((((CONTAINER_MatterFab) this.mContainer).mDisplayErrorCode & 32) != 0) { + this.fontRendererObj.drawString("That doesn't belong there.", 10, 56, 16448255); + } + if ((((CONTAINER_MatterFab) this.mContainer).mDisplayErrorCode & 64) != 0) { + this.fontRendererObj.drawString("Incomplete Structure.", 10, 64, 16448255); + } + if (((CONTAINER_MatterFab) this.mContainer).mDisplayErrorCode == 0) { + if (((CONTAINER_MatterFab) this.mContainer).mActive == 0) { + this.fontRendererObj.drawString("Hit with Soft Hammer", 10, 16, 16448255); + this.fontRendererObj.drawString("to (re-)start the Machine", 10, 24, 16448255); + this.fontRendererObj.drawString("if it doesn't start.", 10, 32, 16448255); + } else { + CONTAINER_MatterFab aContainer = (CONTAINER_MatterFab) this.mContainer; + this.mMatterProduced = aContainer.mMatterProduced; + this.mAmplifierProduced = aContainer.mAmplifierProduced; + this.mAmplifierUsed = aContainer.mAmplifierUsed; + this.mScrapProduced = aContainer.mScrapProduced; + this.mScrapUsed = aContainer.mScrapUsed; - if (this.mContainer != null) { - if ((((CONTAINER_MatterFab) this.mContainer).mDisplayErrorCode & 1) != 0) { - this.fontRendererObj.drawString("Pipe is loose.", 10, 16, 16448255); - } - if ((((CONTAINER_MatterFab) this.mContainer).mDisplayErrorCode & 2) != 0) { - this.fontRendererObj.drawString("Screws are missing.", 10, 24, 16448255); - } - if ((((CONTAINER_MatterFab) this.mContainer).mDisplayErrorCode & 4) != 0) { - this.fontRendererObj.drawString("Something is stuck.", 10, 32, 16448255); - } - if ((((CONTAINER_MatterFab) this.mContainer).mDisplayErrorCode & 8) != 0) { - this.fontRendererObj.drawString("Platings are dented.", 10, 40, 16448255); - } - if ((((CONTAINER_MatterFab) this.mContainer).mDisplayErrorCode & 16) != 0) { - this.fontRendererObj.drawString("Circuitry burned out.", 10, 48, 16448255); - } - if ((((CONTAINER_MatterFab) this.mContainer).mDisplayErrorCode & 32) != 0) { - this.fontRendererObj.drawString("That doesn't belong there.", 10, 56, 16448255); - } - if ((((CONTAINER_MatterFab) this.mContainer).mDisplayErrorCode & 64) != 0) { - this.fontRendererObj.drawString("Incomplete Structure.", 10, 64, 16448255); - } + this.fontRendererObj.drawString("Running perfectly.", 10, 16, 16448255); - if (((CONTAINER_MatterFab) this.mContainer).mDisplayErrorCode == 0) { - if (((CONTAINER_MatterFab) this.mContainer).mActive == 0) { - this.fontRendererObj.drawString("Hit with Soft Hammer", 10, 16, 16448255); - this.fontRendererObj.drawString("to (re-)start the Machine", 10, 24, 16448255); - this.fontRendererObj.drawString("if it doesn't start.", 10, 32, 16448255); - } else { - CONTAINER_MatterFab aContainer = (CONTAINER_MatterFab) this.mContainer; - - this.mMatterProduced = aContainer.mMatterProduced; - this.mAmplifierProduced = aContainer.mAmplifierProduced; - this.mAmplifierUsed = aContainer.mAmplifierUsed; - this.mScrapProduced = aContainer.mScrapProduced; - this.mScrapUsed = aContainer.mScrapUsed; - - this.fontRendererObj.drawString("Running perfectly.", 10, 16, 16448255); - - this.fontRendererObj.drawString("Scrap Made: "+this.mScrapProduced, 10, 32, 16448255); - this.fontRendererObj.drawString("Scrap Used: "+this.mScrapUsed, 10, 40, 16448255); - this.fontRendererObj.drawString("UUA Made: "+this.mAmplifierProduced, 10, 48, 16448255); - this.fontRendererObj.drawString("UUA Used: "+this.mAmplifierUsed, 10, 56, 16448255); - this.fontRendererObj.drawString("UUM Made: "+this.mMatterProduced, 10, 64, 16448255); - } - } - } - } + this.fontRendererObj.drawString("Scrap Made: " + this.mScrapProduced, 10, 32, 16448255); + this.fontRendererObj.drawString("Scrap Used: " + this.mScrapUsed, 10, 40, 16448255); + this.fontRendererObj.drawString("UUA Made: " + this.mAmplifierProduced, 10, 48, 16448255); + this.fontRendererObj.drawString("UUA Used: " + this.mAmplifierUsed, 10, 56, 16448255); + this.fontRendererObj.drawString("UUM Made: " + this.mMatterProduced, 10, 64, 16448255); + } + } + } + } - @Override - protected void drawGuiContainerBackgroundLayer(final float par1, final int par2, final int par3) { - super.drawGuiContainerBackgroundLayer(par1, par2, par3); - final int x = (this.width - this.xSize) / 2; - final int y = (this.height - this.ySize) / 2; - this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); - } + @Override + protected void drawGuiContainerBackgroundLayer(final float par1, final int par2, final int par3) { + super.drawGuiContainerBackgroundLayer(par1, par2, par3); + final int x = (this.width - this.xSize) / 2; + final int y = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_MultiMachine.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_MultiMachine.java index 61cf59f6c9..7322570bab 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_MultiMachine.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_MultiMachine.java @@ -1,12 +1,5 @@ package gtPlusPlus.xmod.gregtech.api.gui; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.TimeUnit; - import gregtech.api.enums.GT_Values; import gregtech.api.enums.Materials; import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; @@ -16,6 +9,11 @@ import gregtech.common.items.GT_MetaGenerated_Tool_01; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.reflect.ReflectionUtils; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.TimeUnit; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; @@ -31,278 +29,330 @@ import net.minecraft.util.StatCollector; */ public class GUI_MultiMachine extends GT_GUIContainerMetaTile_Machine { - private final static Materials GOOD; - private final static Materials BAD; - private final String mName; - - private final static ConcurrentHashMap<String, ItemStack> mToolStacks = new ConcurrentHashMap<String, ItemStack>(); - - //net.minecraft.client.gui.inventory.GuiContainer.drawItemStack(ItemStack, int, int, String) - private final static Method mDrawItemStack; - - static { - GOOD = Materials.Uranium; - BAD = Materials.Plutonium; - - //net.minecraft.client.gui.inventory.GuiContainer.drawItemStack(ItemStack, int, int, String) - mDrawItemStack = ReflectionUtils.getMethod(GuiContainer.class, "drawItemStack", new Class[] {ItemStack.class, int.class, int.class, String.class}); - } - - public GUI_MultiMachine(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity, final String aName, final String aTextureFile) { - super(new CONTAINER_MultiMachine_NoPlayerInventory(aInventoryPlayer, aTileEntity), CORE.RES_PATH_GUI + (aTextureFile == null ? "MultiblockDisplay" : aTextureFile)); - this.mName = aName != null ? aName : ""; - } - - @Override - protected void drawGuiContainerForegroundLayer(final int par1, final int par2) { - if (this.mContainer != null) { - drawGuiInfoTextLayer(par1, par2); - drawGuiRepairStatusLayer(par1, par2); - } - } - - - protected void drawGuiInfoTextLayer(final float par1, final int par2) { - - if ((((CONTAINER_MultiMachine) this.mContainer).mDisplayErrorCode & 64) != 0) { - this.fontRendererObj.drawString(mName, 6, 7, 16448255); // Move down 8px - this.fontRendererObj.drawString("Incomplete Structure.", 6, 15, 16448255); // Move down 8px - } - else { - int aTotalTickTime = ((CONTAINER_MultiMachine) this.mContainer).aTotalTickTime; - int aMaxParallel = ((CONTAINER_MultiMachine) this.mContainer).aMaxParallel; - int aPollutionTick = ((CONTAINER_MultiMachine) this.mContainer).aPollutionTick; - int aMaxInputVoltage = ((CONTAINER_MultiMachine) this.mContainer).aMaxInputVoltage; - int aInputTier = ((CONTAINER_MultiMachine) this.mContainer).aInputTier; - int aOutputTier = ((CONTAINER_MultiMachine) this.mContainer).aOutputTier; - int aRecipeDuration = ((CONTAINER_MultiMachine) this.mContainer).aRecipeDuration; - int aRecipeEU = ((CONTAINER_MultiMachine) this.mContainer).aRecipeEU; - int aRecipeSpecial = ((CONTAINER_MultiMachine) this.mContainer).aRecipeSpecial; - int aEfficiency = ((CONTAINER_MultiMachine) this.mContainer).aEfficiency; - - int aPollutionReduction = ((CONTAINER_MultiMachine) this.mContainer).aPollutionReduction; - - - long aStoredEnergy = ((CONTAINER_MultiMachine) this.mContainer).aStoredEnergy; - long aMaxEnergy = ((CONTAINER_MultiMachine) this.mContainer).aMaxEnergy; - - /* - * Logic Block - */ - - long seconds = (aTotalTickTime/20); - int weeks = (int) (TimeUnit.SECONDS.toDays(seconds) / 7); - int days = (int) (TimeUnit.SECONDS.toDays(seconds) - 7 * weeks); - long hours = TimeUnit.SECONDS.toHours(seconds) - TimeUnit.DAYS.toHours(days) - TimeUnit.DAYS.toHours(7*weeks); - long minutes = TimeUnit.SECONDS.toMinutes(seconds) - (TimeUnit.SECONDS.toHours(seconds) * 60); - long second = TimeUnit.SECONDS.toSeconds(seconds) - (TimeUnit.SECONDS.toMinutes(seconds) *60); - - ArrayList<String> mInfo = new ArrayList<String>(); - - String EU = StatCollector.translateToLocal("GTPP.info.eu"); - - //GTPP.machines.tier - - mInfo.add(mName); - - if (aInputTier > 0) { - mInfo.add(StatCollector.translateToLocal("GTPP.machines.input")+" "+StatCollector.translateToLocal("GTPP.machines.tier")+": "+ EnumChatFormatting.GREEN +GT_Values.VOLTAGE_NAMES[aInputTier]); - } - if (aOutputTier > 0) { - mInfo.add(StatCollector.translateToLocal("GTPP.machines.output")+" "+StatCollector.translateToLocal("GTPP.machines.tier")+": "+ EnumChatFormatting.GREEN +GT_Values.VOLTAGE_NAMES[aOutputTier]); - } - - - - - mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.progress")+": "+ - EnumChatFormatting.GREEN + Integer.toString(((CONTAINER_MultiMachine) this.mContainer).mProgressTime/20) + EnumChatFormatting.RESET +" s / "+ - EnumChatFormatting.YELLOW + Integer.toString(((CONTAINER_MultiMachine) this.mContainer).mMaxProgressTime/20) + EnumChatFormatting.RESET +" s"); - - - - - - - - mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.energy")+":"); - mInfo.add(StatCollector.translateToLocal(""+EnumChatFormatting.GREEN + Long.toString(aStoredEnergy) + EnumChatFormatting.RESET +" EU / "+ - EnumChatFormatting.YELLOW + Long.toString(aMaxEnergy) + EnumChatFormatting.RESET +" EU")); - - if (aRecipeEU != 0 && aRecipeDuration > 0) { - if (aRecipeEU > 0) { - mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.usage")+":"); - mInfo.add(StatCollector.translateToLocal(""+EnumChatFormatting.RED + Integer.toString(-aRecipeEU) + EnumChatFormatting.RESET + " EU/t/parallel")); - } - else { - mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.generation")+":"); - mInfo.add(StatCollector.translateToLocal(""+EnumChatFormatting.GREEN + Integer.toString(aRecipeEU) + EnumChatFormatting.RESET + " EU/t/parallel")); - } - mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.duration")+": "+ - EnumChatFormatting.RED + Integer.toString(aRecipeDuration) + EnumChatFormatting.RESET + " ticks"); - if (aRecipeSpecial > 0) { - mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.specialvalue")+": "+ - EnumChatFormatting.RED + Integer.toString(aRecipeEU) + EnumChatFormatting.RESET + ""); - } - } - - mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.mei")+":"); - mInfo.add(StatCollector.translateToLocal(""+EnumChatFormatting.YELLOW+Long.toString(aMaxInputVoltage)+EnumChatFormatting.RESET+ " EU/t(*2A) "+StatCollector.translateToLocal("GTPP.machines.tier")+": "+ - EnumChatFormatting.YELLOW+GT_Values.VN[GT_Utility.getTier(aMaxInputVoltage)]+ EnumChatFormatting.RESET)); - - mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.efficiency")+": "+ EnumChatFormatting.YELLOW+Float.toString(aEfficiency / 100.0F)+EnumChatFormatting.RESET + " %"); - - mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.pollution")+": "+ EnumChatFormatting.RED + (aPollutionTick*20)+ EnumChatFormatting.RESET+"/sec"); - mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.pollutionreduced")+": "+ EnumChatFormatting.GREEN + aPollutionReduction + EnumChatFormatting.RESET+" %"); - - //mInfo.add(StatCollector.translateToLocal("GTPP.CC.parallel")+": "+EnumChatFormatting.GREEN+(aMaxParallel)+EnumChatFormatting.RESET); - - mInfo.add("Total Time Since Built: "); - mInfo.add("" + EnumChatFormatting.DARK_GREEN + Integer.toString(weeks)+EnumChatFormatting.RESET+" Weeks,"); - mInfo.add("" + EnumChatFormatting.DARK_GREEN+ Integer.toString(days) +EnumChatFormatting.RESET+ " Days,"); - mInfo.add("" + EnumChatFormatting.DARK_GREEN+ Long.toString(hours) +EnumChatFormatting.RESET+ " Hours,"); - mInfo.add("" + EnumChatFormatting.DARK_GREEN+ Long.toString(minutes) +EnumChatFormatting.RESET+ " Minutes,"); - mInfo.add("" + EnumChatFormatting.DARK_GREEN+ Long.toString(second) +EnumChatFormatting.RESET+ " Seconds"); - - - - // Machine Name - //fontRendererObj.drawString(this.mName, 6, 7, 16448255); - - for (int i=0;i<mInfo.size();i++) { - fontRendererObj.drawString(mInfo.get(i), 6, 7+(i*8), 16448255); - } - - } - - - - - } - - - protected void drawGuiRepairStatusLayer(final float par1, final int par2) { - - boolean aWrench = (((CONTAINER_MultiMachine) this.mContainer).mDisplayErrorCode & 1) != 0; - boolean aScrewdriver = (((CONTAINER_MultiMachine) this.mContainer).mDisplayErrorCode & 2) != 0; - boolean aMallet = (((CONTAINER_MultiMachine) this.mContainer).mDisplayErrorCode & 4) != 0; - boolean aHammer = (((CONTAINER_MultiMachine) this.mContainer).mDisplayErrorCode & 8) != 0; - boolean aSoldering = (((CONTAINER_MultiMachine) this.mContainer).mDisplayErrorCode & 16) != 0; - boolean aCrowbar = (((CONTAINER_MultiMachine) this.mContainer).mDisplayErrorCode & 32) != 0; - - if (mToolStacks.isEmpty()) { - // Map Stacks of Repair items - aWrench = false; - aScrewdriver = false; - aMallet = false; - aHammer = false; - aSoldering = false; - aCrowbar = false; - mToolStacks.put(aWrench+"WRENCH", GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats(GT_MetaGenerated_Tool_01.WRENCH, 1, (aWrench ? BAD : GOOD), Materials.Tungsten, null)); - mToolStacks.put(aCrowbar+"CROWBAR", GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats(GT_MetaGenerated_Tool_01.CROWBAR, 1, (aCrowbar ? BAD : GOOD), Materials.Tungsten, null)); - mToolStacks.put(aHammer+"HARDHAMMER", GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats(GT_MetaGenerated_Tool_01.HARDHAMMER, 1, (aHammer ? BAD : GOOD), Materials.Tungsten, null)); - mToolStacks.put(aMallet+"SOFTHAMMER", GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats(GT_MetaGenerated_Tool_01.SOFTHAMMER, 1, (aMallet ? BAD : GOOD), Materials.Tungsten, null)); - mToolStacks.put(aScrewdriver+"SCREWDRIVER", GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats(GT_MetaGenerated_Tool_01.SCREWDRIVER, 1, (aScrewdriver ? BAD : GOOD), Materials.Tungsten, null)); - mToolStacks.put(aSoldering+"SOLDERING_IRON_LV", GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats(GT_MetaGenerated_Tool_01.SOLDERING_IRON_LV, 1, (aSoldering ? BAD : GOOD), Materials.Tungsten, null)); - - // Map Stacks of valid items - aWrench = true; - aScrewdriver = true; - aMallet = true; - aHammer = true; - aSoldering = true; - aCrowbar = true; - mToolStacks.put(aWrench+"WRENCH", GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats(GT_MetaGenerated_Tool_01.WRENCH, 1, (aWrench ? BAD : GOOD), Materials.Tungsten, null)); - mToolStacks.put(aCrowbar+"CROWBAR", GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats(GT_MetaGenerated_Tool_01.CROWBAR, 1, (aCrowbar ? BAD : GOOD), Materials.Tungsten, null)); - mToolStacks.put(aHammer+"HARDHAMMER", GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats(GT_MetaGenerated_Tool_01.HARDHAMMER, 1, (aHammer ? BAD : GOOD), Materials.Tungsten, null)); - mToolStacks.put(aMallet+"SOFTHAMMER", GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats(GT_MetaGenerated_Tool_01.SOFTHAMMER, 1, (aMallet ? BAD : GOOD), Materials.Tungsten, null)); - mToolStacks.put(aScrewdriver+"SCREWDRIVER", GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats(GT_MetaGenerated_Tool_01.SCREWDRIVER, 1, (aScrewdriver ? BAD : GOOD), Materials.Tungsten, null)); - mToolStacks.put(aSoldering+"SOLDERING_IRON_LV", GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats(GT_MetaGenerated_Tool_01.SOLDERING_IRON_LV, 1, (aSoldering ? BAD : GOOD), Materials.Tungsten, null)); - - ItemStack aGlassPane1 = ItemUtils.getItemStackOfAmountFromOreDict("paneGlassRed", 1); - ItemStack aGlassPane2 = ItemUtils.getItemStackOfAmountFromOreDict("paneGlassLime", 1); - mToolStacks.put("falseGLASS", aGlassPane1); - mToolStacks.put("trueGLASS", aGlassPane2); - - // Reset vars to real state - aWrench = (((CONTAINER_MultiMachine) this.mContainer).mDisplayErrorCode & 1) != 0; - aScrewdriver = (((CONTAINER_MultiMachine) this.mContainer).mDisplayErrorCode & 2) != 0; - aMallet = (((CONTAINER_MultiMachine) this.mContainer).mDisplayErrorCode & 4) != 0; - aHammer = (((CONTAINER_MultiMachine) this.mContainer).mDisplayErrorCode & 8) != 0; - aSoldering = (((CONTAINER_MultiMachine) this.mContainer).mDisplayErrorCode & 16) != 0; - aCrowbar = (((CONTAINER_MultiMachine) this.mContainer).mDisplayErrorCode & 32) != 0; - - } - - ItemStack aWrenchStack; - ItemStack aCrowbarStack; - ItemStack aHammerStack; - ItemStack aMalletStack; - ItemStack aScrewdriverStack; - ItemStack aSolderingStack; - if (!mToolStacks.isEmpty() && mDrawItemStack != null) { - - aWrenchStack = mToolStacks.get(aWrench + "WRENCH"); - aCrowbarStack = mToolStacks.get(aCrowbar + "CROWBAR"); - aHammerStack = mToolStacks.get(aHammer + "HARDHAMMER"); - aMalletStack = mToolStacks.get(aMallet + "SOFTHAMMER"); - aScrewdriverStack = mToolStacks.get(aScrewdriver + "SCREWDRIVER"); - aSolderingStack = mToolStacks.get(aSoldering + "SOLDERING_IRON_LV"); - - try { - - ItemStack[] aToolStacks2 = new ItemStack[] { - aWrenchStack, aCrowbarStack, - aHammerStack, aMalletStack, - aScrewdriverStack, aSolderingStack }; - - int aIndex = 0; - //Draw Repair status tools - for (aIndex = 0; aIndex < 6; aIndex++) { - int x = 156; - int y = 112 - (18 * 3) + (aIndex * 18); - mDrawItemStack.invoke(this, - new Object[] { - aToolStacks2[aIndex] != null ? aToolStacks2[aIndex] - : ItemUtils.getErrorStack(1, "Bad Times"), - x, y, "" + (aIndex == 2 ? "H" : aIndex == 3 ? "M" : "") // Stacksize Overlay - }); - //this.fontRendererObj.drawString("", 10, 64, 16448255); - } - - //Draw Running status - boolean running = ((CONTAINER_MultiMachine) this.mContainer).mActive != 0; - ItemStack aGlassPane = mToolStacks.get(running+"GLASS"); - - if (aGlassPane == null) { - aGlassPane = ItemUtils.getItemStackOfAmountFromOreDict("paneGlass" + (running ? "Lime" : "Red"), 1); - mToolStacks.put(running+"GLASS", aGlassPane); - } - - mDrawItemStack.invoke(this, - new Object[] { - aGlassPane != null ? aGlassPane - : ItemUtils.getErrorStack(1, "Bad Times"), - 156, - 112 - (18 * 5), - running ? "On" : "Off"}); // Stacksize Overlay - - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - e.printStackTrace(); - } - } - - - - - } - - - @Override - protected void drawGuiContainerBackgroundLayer(final float par1, final int par2, final int par3) { - super.drawGuiContainerBackgroundLayer(par1, par2, par3); - final int x = (this.width - this.xSize) / 2; - final int y = (this.height - this.ySize) / 2; - this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); - } + private static final Materials GOOD; + private static final Materials BAD; + private final String mName; + + private static final ConcurrentHashMap<String, ItemStack> mToolStacks = new ConcurrentHashMap<String, ItemStack>(); + + // net.minecraft.client.gui.inventory.GuiContainer.drawItemStack(ItemStack, int, int, String) + private static final Method mDrawItemStack; + + static { + GOOD = Materials.Uranium; + BAD = Materials.Plutonium; + + // net.minecraft.client.gui.inventory.GuiContainer.drawItemStack(ItemStack, int, int, String) + mDrawItemStack = ReflectionUtils.getMethod( + GuiContainer.class, "drawItemStack", new Class[] {ItemStack.class, int.class, int.class, String.class}); + } + + public GUI_MultiMachine( + final InventoryPlayer aInventoryPlayer, + final IGregTechTileEntity aTileEntity, + final String aName, + final String aTextureFile) { + super( + new CONTAINER_MultiMachine_NoPlayerInventory(aInventoryPlayer, aTileEntity), + CORE.RES_PATH_GUI + (aTextureFile == null ? "MultiblockDisplay" : aTextureFile)); + this.mName = aName != null ? aName : ""; + } + + @Override + protected void drawGuiContainerForegroundLayer(final int par1, final int par2) { + if (this.mContainer != null) { + drawGuiInfoTextLayer(par1, par2); + drawGuiRepairStatusLayer(par1, par2); + } + } + + protected void drawGuiInfoTextLayer(final float par1, final int par2) { + + if ((((CONTAINER_MultiMachine) this.mContainer).mDisplayErrorCode & 64) != 0) { + this.fontRendererObj.drawString(mName, 6, 7, 16448255); // Move down 8px + this.fontRendererObj.drawString("Incomplete Structure.", 6, 15, 16448255); // Move down 8px + } else { + int aTotalTickTime = ((CONTAINER_MultiMachine) this.mContainer).aTotalTickTime; + int aMaxParallel = ((CONTAINER_MultiMachine) this.mContainer).aMaxParallel; + int aPollutionTick = ((CONTAINER_MultiMachine) this.mContainer).aPollutionTick; + int aMaxInputVoltage = ((CONTAINER_MultiMachine) this.mContainer).aMaxInputVoltage; + int aInputTier = ((CONTAINER_MultiMachine) this.mContainer).aInputTier; + int aOutputTier = ((CONTAINER_MultiMachine) this.mContainer).aOutputTier; + int aRecipeDuration = ((CONTAINER_MultiMachine) this.mContainer).aRecipeDuration; + int aRecipeEU = ((CONTAINER_MultiMachine) this.mContainer).aRecipeEU; + int aRecipeSpecial = ((CONTAINER_MultiMachine) this.mContainer).aRecipeSpecial; + int aEfficiency = ((CONTAINER_MultiMachine) this.mContainer).aEfficiency; + + int aPollutionReduction = ((CONTAINER_MultiMachine) this.mContainer).aPollutionReduction; + + long aStoredEnergy = ((CONTAINER_MultiMachine) this.mContainer).aStoredEnergy; + long aMaxEnergy = ((CONTAINER_MultiMachine) this.mContainer).aMaxEnergy; + + /* + * Logic Block + */ + + long seconds = (aTotalTickTime / 20); + int weeks = (int) (TimeUnit.SECONDS.toDays(seconds) / 7); + int days = (int) (TimeUnit.SECONDS.toDays(seconds) - 7 * weeks); + long hours = + TimeUnit.SECONDS.toHours(seconds) - TimeUnit.DAYS.toHours(days) - TimeUnit.DAYS.toHours(7 * weeks); + long minutes = TimeUnit.SECONDS.toMinutes(seconds) - (TimeUnit.SECONDS.toHours(seconds) * 60); + long second = TimeUnit.SECONDS.toSeconds(seconds) - (TimeUnit.SECONDS.toMinutes(seconds) * 60); + + ArrayList<String> mInfo = new ArrayList<String>(); + + String EU = StatCollector.translateToLocal("GTPP.info.eu"); + + // GTPP.machines.tier + + mInfo.add(mName); + + if (aInputTier > 0) { + mInfo.add(StatCollector.translateToLocal("GTPP.machines.input") + " " + + StatCollector.translateToLocal("GTPP.machines.tier") + ": " + EnumChatFormatting.GREEN + + GT_Values.VOLTAGE_NAMES[aInputTier]); + } + if (aOutputTier > 0) { + mInfo.add(StatCollector.translateToLocal("GTPP.machines.output") + " " + + StatCollector.translateToLocal("GTPP.machines.tier") + ": " + EnumChatFormatting.GREEN + + GT_Values.VOLTAGE_NAMES[aOutputTier]); + } + + mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.progress") + ": " + EnumChatFormatting.GREEN + + Integer.toString(((CONTAINER_MultiMachine) this.mContainer).mProgressTime / 20) + + EnumChatFormatting.RESET + " s / " + EnumChatFormatting.YELLOW + + Integer.toString(((CONTAINER_MultiMachine) this.mContainer).mMaxProgressTime / 20) + + EnumChatFormatting.RESET + " s"); + + mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.energy") + ":"); + mInfo.add(StatCollector.translateToLocal("" + EnumChatFormatting.GREEN + Long.toString(aStoredEnergy) + + EnumChatFormatting.RESET + " EU / " + EnumChatFormatting.YELLOW + Long.toString(aMaxEnergy) + + EnumChatFormatting.RESET + " EU")); + + if (aRecipeEU != 0 && aRecipeDuration > 0) { + if (aRecipeEU > 0) { + mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.usage") + ":"); + mInfo.add(StatCollector.translateToLocal("" + EnumChatFormatting.RED + Integer.toString(-aRecipeEU) + + EnumChatFormatting.RESET + " EU/t/parallel")); + } else { + mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.generation") + ":"); + mInfo.add(StatCollector.translateToLocal("" + EnumChatFormatting.GREEN + Integer.toString(aRecipeEU) + + EnumChatFormatting.RESET + " EU/t/parallel")); + } + mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.duration") + ": " + EnumChatFormatting.RED + + Integer.toString(aRecipeDuration) + EnumChatFormatting.RESET + " ticks"); + if (aRecipeSpecial > 0) { + mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.specialvalue") + ": " + + EnumChatFormatting.RED + Integer.toString(aRecipeEU) + EnumChatFormatting.RESET + ""); + } + } + + mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.mei") + ":"); + mInfo.add(StatCollector.translateToLocal("" + EnumChatFormatting.YELLOW + Long.toString(aMaxInputVoltage) + + EnumChatFormatting.RESET + " EU/t(*2A) " + StatCollector.translateToLocal("GTPP.machines.tier") + + ": " + EnumChatFormatting.YELLOW + GT_Values.VN[GT_Utility.getTier(aMaxInputVoltage)] + + EnumChatFormatting.RESET)); + + mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.efficiency") + ": " + EnumChatFormatting.YELLOW + + Float.toString(aEfficiency / 100.0F) + EnumChatFormatting.RESET + " %"); + + mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.pollution") + ": " + EnumChatFormatting.RED + + (aPollutionTick * 20) + EnumChatFormatting.RESET + "/sec"); + mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.pollutionreduced") + ": " + + EnumChatFormatting.GREEN + aPollutionReduction + EnumChatFormatting.RESET + " %"); + + // mInfo.add(StatCollector.translateToLocal("GTPP.CC.parallel")+": + // "+EnumChatFormatting.GREEN+(aMaxParallel)+EnumChatFormatting.RESET); + + mInfo.add("Total Time Since Built: "); + mInfo.add("" + EnumChatFormatting.DARK_GREEN + Integer.toString(weeks) + EnumChatFormatting.RESET + + " Weeks,"); + mInfo.add( + "" + EnumChatFormatting.DARK_GREEN + Integer.toString(days) + EnumChatFormatting.RESET + " Days,"); + mInfo.add("" + EnumChatFormatting.DARK_GREEN + Long.toString(hours) + EnumChatFormatting.RESET + " Hours,"); + mInfo.add("" + EnumChatFormatting.DARK_GREEN + Long.toString(minutes) + EnumChatFormatting.RESET + + " Minutes,"); + mInfo.add( + "" + EnumChatFormatting.DARK_GREEN + Long.toString(second) + EnumChatFormatting.RESET + " Seconds"); + + // Machine Name + // fontRendererObj.drawString(this.mName, 6, 7, 16448255); + + for (int i = 0; i < mInfo.size(); i++) { + fontRendererObj.drawString(mInfo.get(i), 6, 7 + (i * 8), 16448255); + } + } + } + + protected void drawGuiRepairStatusLayer(final float par1, final int par2) { + + boolean aWrench = (((CONTAINER_MultiMachine) this.mContainer).mDisplayErrorCode & 1) != 0; + boolean aScrewdriver = (((CONTAINER_MultiMachine) this.mContainer).mDisplayErrorCode & 2) != 0; + boolean aMallet = (((CONTAINER_MultiMachine) this.mContainer).mDisplayErrorCode & 4) != 0; + boolean aHammer = (((CONTAINER_MultiMachine) this.mContainer).mDisplayErrorCode & 8) != 0; + boolean aSoldering = (((CONTAINER_MultiMachine) this.mContainer).mDisplayErrorCode & 16) != 0; + boolean aCrowbar = (((CONTAINER_MultiMachine) this.mContainer).mDisplayErrorCode & 32) != 0; + + if (mToolStacks.isEmpty()) { + // Map Stacks of Repair items + aWrench = false; + aScrewdriver = false; + aMallet = false; + aHammer = false; + aSoldering = false; + aCrowbar = false; + mToolStacks.put( + aWrench + "WRENCH", + GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats( + GT_MetaGenerated_Tool_01.WRENCH, 1, (aWrench ? BAD : GOOD), Materials.Tungsten, null)); + mToolStacks.put( + aCrowbar + "CROWBAR", + GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats( + GT_MetaGenerated_Tool_01.CROWBAR, 1, (aCrowbar ? BAD : GOOD), Materials.Tungsten, null)); + mToolStacks.put( + aHammer + "HARDHAMMER", + GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats( + GT_MetaGenerated_Tool_01.HARDHAMMER, 1, (aHammer ? BAD : GOOD), Materials.Tungsten, null)); + mToolStacks.put( + aMallet + "SOFTHAMMER", + GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats( + GT_MetaGenerated_Tool_01.SOFTHAMMER, 1, (aMallet ? BAD : GOOD), Materials.Tungsten, null)); + mToolStacks.put( + aScrewdriver + "SCREWDRIVER", + GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats( + GT_MetaGenerated_Tool_01.SCREWDRIVER, + 1, + (aScrewdriver ? BAD : GOOD), + Materials.Tungsten, + null)); + mToolStacks.put( + aSoldering + "SOLDERING_IRON_LV", + GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats( + GT_MetaGenerated_Tool_01.SOLDERING_IRON_LV, + 1, + (aSoldering ? BAD : GOOD), + Materials.Tungsten, + null)); + + // Map Stacks of valid items + aWrench = true; + aScrewdriver = true; + aMallet = true; + aHammer = true; + aSoldering = true; + aCrowbar = true; + mToolStacks.put( + aWrench + "WRENCH", + GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats( + GT_MetaGenerated_Tool_01.WRENCH, 1, (aWrench ? BAD : GOOD), Materials.Tungsten, null)); + mToolStacks.put( + aCrowbar + "CROWBAR", + GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats( + GT_MetaGenerated_Tool_01.CROWBAR, 1, (aCrowbar ? BAD : GOOD), Materials.Tungsten, null)); + mToolStacks.put( + aHammer + "HARDHAMMER", + GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats( + GT_MetaGenerated_Tool_01.HARDHAMMER, 1, (aHammer ? BAD : GOOD), Materials.Tungsten, null)); + mToolStacks.put( + aMallet + "SOFTHAMMER", + GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats( + GT_MetaGenerated_Tool_01.SOFTHAMMER, 1, (aMallet ? BAD : GOOD), Materials.Tungsten, null)); + mToolStacks.put( + aScrewdriver + "SCREWDRIVER", + GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats( + GT_MetaGenerated_Tool_01.SCREWDRIVER, + 1, + (aScrewdriver ? BAD : GOOD), + Materials.Tungsten, + null)); + mToolStacks.put( + aSoldering + "SOLDERING_IRON_LV", + GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats( + GT_MetaGenerated_Tool_01.SOLDERING_IRON_LV, + 1, + (aSoldering ? BAD : GOOD), + Materials.Tungsten, + null)); + + ItemStack aGlassPane1 = ItemUtils.getItemStackOfAmountFromOreDict("paneGlassRed", 1); + ItemStack aGlassPane2 = ItemUtils.getItemStackOfAmountFromOreDict("paneGlassLime", 1); + mToolStacks.put("falseGLASS", aGlassPane1); + mToolStacks.put("trueGLASS", aGlassPane2); + + // Reset vars to real state + aWrench = (((CONTAINER_MultiMachine) this.mContainer).mDisplayErrorCode & 1) != 0; + aScrewdriver = (((CONTAINER_MultiMachine) this.mContainer).mDisplayErrorCode & 2) != 0; + aMallet = (((CONTAINER_MultiMachine) this.mContainer).mDisplayErrorCode & 4) != 0; + aHammer = (((CONTAINER_MultiMachine) this.mContainer).mDisplayErrorCode & 8) != 0; + aSoldering = (((CONTAINER_MultiMachine) this.mContainer).mDisplayErrorCode & 16) != 0; + aCrowbar = (((CONTAINER_MultiMachine) this.mContainer).mDisplayErrorCode & 32) != 0; + } + + ItemStack aWrenchStack; + ItemStack aCrowbarStack; + ItemStack aHammerStack; + ItemStack aMalletStack; + ItemStack aScrewdriverStack; + ItemStack aSolderingStack; + if (!mToolStacks.isEmpty() && mDrawItemStack != null) { + + aWrenchStack = mToolStacks.get(aWrench + "WRENCH"); + aCrowbarStack = mToolStacks.get(aCrowbar + "CROWBAR"); + aHammerStack = mToolStacks.get(aHammer + "HARDHAMMER"); + aMalletStack = mToolStacks.get(aMallet + "SOFTHAMMER"); + aScrewdriverStack = mToolStacks.get(aScrewdriver + "SCREWDRIVER"); + aSolderingStack = mToolStacks.get(aSoldering + "SOLDERING_IRON_LV"); + + try { + + ItemStack[] aToolStacks2 = new ItemStack[] { + aWrenchStack, aCrowbarStack, + aHammerStack, aMalletStack, + aScrewdriverStack, aSolderingStack + }; + + int aIndex = 0; + // Draw Repair status tools + for (aIndex = 0; aIndex < 6; aIndex++) { + int x = 156; + int y = 112 - (18 * 3) + (aIndex * 18); + mDrawItemStack.invoke(this, new Object[] { + aToolStacks2[aIndex] != null ? aToolStacks2[aIndex] : ItemUtils.getErrorStack(1, "Bad Times"), + x, + y, + "" + (aIndex == 2 ? "H" : aIndex == 3 ? "M" : "") // Stacksize Overlay + }); + // this.fontRendererObj.drawString("", 10, 64, 16448255); + } + + // Draw Running status + boolean running = ((CONTAINER_MultiMachine) this.mContainer).mActive != 0; + ItemStack aGlassPane = mToolStacks.get(running + "GLASS"); + + if (aGlassPane == null) { + aGlassPane = ItemUtils.getItemStackOfAmountFromOreDict("paneGlass" + (running ? "Lime" : "Red"), 1); + mToolStacks.put(running + "GLASS", aGlassPane); + } + + mDrawItemStack.invoke(this, new Object[] { + aGlassPane != null ? aGlassPane : ItemUtils.getErrorStack(1, "Bad Times"), + 156, + 112 - (18 * 5), + running ? "On" : "Off" + }); // Stacksize Overlay + + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + e.printStackTrace(); + } + } + } + + @Override + protected void drawGuiContainerBackgroundLayer(final float par1, final int par2, final int par3) { + super.drawGuiContainerBackgroundLayer(par1, par2, par3); + final int x = (this.width - this.xSize) / 2; + final int y = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_MultiMachine_Default.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_MultiMachine_Default.java index 0cfab4e71e..cfc2c10ef5 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_MultiMachine_Default.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_MultiMachine_Default.java @@ -6,58 +6,62 @@ import gregtech.api.util.GT_LanguageManager; import gtPlusPlus.core.lib.CORE; import net.minecraft.entity.player.InventoryPlayer; -public class GUI_MultiMachine_Default extends GT_GUIContainerMetaTile_Machine -{ +public class GUI_MultiMachine_Default extends GT_GUIContainerMetaTile_Machine { String mName; - - public GUI_MultiMachine_Default(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity, final String aName, final String aTextureFile) { - super(new CONTAINER_MultiMachine(aInventoryPlayer, aTileEntity), CORE.RES_PATH_GUI + ((aTextureFile == null) ? "MultiblockDisplay" : aTextureFile)); + + public GUI_MultiMachine_Default( + final InventoryPlayer aInventoryPlayer, + final IGregTechTileEntity aTileEntity, + final String aName, + final String aTextureFile) { + super( + new CONTAINER_MultiMachine(aInventoryPlayer, aTileEntity), + CORE.RES_PATH_GUI + ((aTextureFile == null) ? "MultiblockDisplay" : aTextureFile)); this.mName = ""; this.mName = aName; } - + @Override protected void drawGuiContainerForegroundLayer(final int par1, final int par2) { this.fontRendererObj.drawString(this.mName, 10, 8, 16448255); if (this.mContainer != null) { - if ((((CONTAINER_MultiMachine)this.mContainer).mDisplayErrorCode & 0x1) != 0x0) { + if ((((CONTAINER_MultiMachine) this.mContainer).mDisplayErrorCode & 0x1) != 0x0) { this.fontRendererObj.drawString(this.trans("132", "Pipe is loose."), 10, 16, 16448255); } - if ((((CONTAINER_MultiMachine)this.mContainer).mDisplayErrorCode & 0x2) != 0x0) { + if ((((CONTAINER_MultiMachine) this.mContainer).mDisplayErrorCode & 0x2) != 0x0) { this.fontRendererObj.drawString(this.trans("133", "Screws are missing."), 10, 24, 16448255); } - if ((((CONTAINER_MultiMachine)this.mContainer).mDisplayErrorCode & 0x4) != 0x0) { + if ((((CONTAINER_MultiMachine) this.mContainer).mDisplayErrorCode & 0x4) != 0x0) { this.fontRendererObj.drawString(this.trans("134", "Something is stuck."), 10, 32, 16448255); } - if ((((CONTAINER_MultiMachine)this.mContainer).mDisplayErrorCode & 0x8) != 0x0) { + if ((((CONTAINER_MultiMachine) this.mContainer).mDisplayErrorCode & 0x8) != 0x0) { this.fontRendererObj.drawString(this.trans("135", "Platings are dented."), 10, 40, 16448255); } - if ((((CONTAINER_MultiMachine)this.mContainer).mDisplayErrorCode & 0x10) != 0x0) { + if ((((CONTAINER_MultiMachine) this.mContainer).mDisplayErrorCode & 0x10) != 0x0) { this.fontRendererObj.drawString(this.trans("136", "Circuitry burned out."), 10, 48, 16448255); } - if ((((CONTAINER_MultiMachine)this.mContainer).mDisplayErrorCode & 0x20) != 0x0) { + if ((((CONTAINER_MultiMachine) this.mContainer).mDisplayErrorCode & 0x20) != 0x0) { this.fontRendererObj.drawString(this.trans("137", "That doesn't belong there."), 10, 56, 16448255); } - if ((((CONTAINER_MultiMachine)this.mContainer).mDisplayErrorCode & 0x40) != 0x0) { + if ((((CONTAINER_MultiMachine) this.mContainer).mDisplayErrorCode & 0x40) != 0x0) { this.fontRendererObj.drawString(this.trans("138", "Incomplete Structure."), 10, 64, 16448255); } - if (((CONTAINER_MultiMachine)this.mContainer).mDisplayErrorCode == 0) { - if (((CONTAINER_MultiMachine)this.mContainer).mActive == 0) { + if (((CONTAINER_MultiMachine) this.mContainer).mDisplayErrorCode == 0) { + if (((CONTAINER_MultiMachine) this.mContainer).mActive == 0) { this.fontRendererObj.drawString(this.trans("139", "Hit with Soft Hammer"), 10, 16, 16448255); this.fontRendererObj.drawString(this.trans("140", "to (re-)start the Machine"), 10, 24, 16448255); this.fontRendererObj.drawString(this.trans("141", "if it doesn't start."), 10, 32, 16448255); - } - else { + } else { this.fontRendererObj.drawString(this.trans("142", "Running perfectly."), 10, 16, 16448255); } } } } - + public String trans(final String aKey, final String aEnglish) { return GT_LanguageManager.addStringLocalization("Interaction_DESCRIPTION_Index_" + aKey, aEnglish, false); } - + @Override protected void drawGuiContainerBackgroundLayer(final float par1, final int par2, final int par3) { super.drawGuiContainerBackgroundLayer(par1, par2, par3); diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_Multi_Basic_Slotted.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_Multi_Basic_Slotted.java index 0756effa26..a3ed8749c6 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_Multi_Basic_Slotted.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_Multi_Basic_Slotted.java @@ -4,8 +4,6 @@ import gregtech.api.gui.GT_Container_MultiMachine; import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.util.GT_LanguageManager; -import gregtech.api.util.GT_ModHandler; -import gregtech.api.util.GT_Utility; import gregtech.common.items.GT_MetaGenerated_Tool_01; import gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_LargeTurbine; import gtPlusPlus.core.lib.CORE; @@ -13,76 +11,82 @@ import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; public class GUI_Multi_Basic_Slotted extends GT_GUIContainerMetaTile_Machine { - String mName = ""; + String mName = ""; - public GUI_Multi_Basic_Slotted(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName, - String aTextureFile) { - super(new GT_Container_MultiMachine(aInventoryPlayer, aTileEntity), CORE.RES_PATH_GUI + (aTextureFile == null ? "MultiblockDisplay" : aTextureFile)); - this.mName = aName; - } + public GUI_Multi_Basic_Slotted( + InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName, String aTextureFile) { + super( + new GT_Container_MultiMachine(aInventoryPlayer, aTileEntity), + CORE.RES_PATH_GUI + (aTextureFile == null ? "MultiblockDisplay" : aTextureFile)); + this.mName = aName; + } - protected void drawGuiContainerForegroundLayer(int par1, int par2) { - this.fontRendererObj.drawString(this.mName, 10, 8, 16448255); - if (this.mContainer != null) { - if ((((GT_Container_MultiMachine) this.mContainer).mDisplayErrorCode & 1) != 0) { - this.fontRendererObj.drawString(this.trans("132", "Pipe is loose."), 10, 16, 16448255); - } + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + this.fontRendererObj.drawString(this.mName, 10, 8, 16448255); + if (this.mContainer != null) { + if ((((GT_Container_MultiMachine) this.mContainer).mDisplayErrorCode & 1) != 0) { + this.fontRendererObj.drawString(this.trans("132", "Pipe is loose."), 10, 16, 16448255); + } - if ((((GT_Container_MultiMachine) this.mContainer).mDisplayErrorCode & 2) != 0) { - this.fontRendererObj.drawString(this.trans("133", "Screws are missing."), 10, 24, 16448255); - } + if ((((GT_Container_MultiMachine) this.mContainer).mDisplayErrorCode & 2) != 0) { + this.fontRendererObj.drawString(this.trans("133", "Screws are missing."), 10, 24, 16448255); + } - if ((((GT_Container_MultiMachine) this.mContainer).mDisplayErrorCode & 4) != 0) { - this.fontRendererObj.drawString(this.trans("134", "Something is stuck."), 10, 32, 16448255); - } + if ((((GT_Container_MultiMachine) this.mContainer).mDisplayErrorCode & 4) != 0) { + this.fontRendererObj.drawString(this.trans("134", "Something is stuck."), 10, 32, 16448255); + } - if ((((GT_Container_MultiMachine) this.mContainer).mDisplayErrorCode & 8) != 0) { - this.fontRendererObj.drawString(this.trans("135", "Platings are dented."), 10, 40, 16448255); - } + if ((((GT_Container_MultiMachine) this.mContainer).mDisplayErrorCode & 8) != 0) { + this.fontRendererObj.drawString(this.trans("135", "Platings are dented."), 10, 40, 16448255); + } - if ((((GT_Container_MultiMachine) this.mContainer).mDisplayErrorCode & 16) != 0) { - this.fontRendererObj.drawString(this.trans("136", "Circuitry burned out."), 10, 48, 16448255); - } + if ((((GT_Container_MultiMachine) this.mContainer).mDisplayErrorCode & 16) != 0) { + this.fontRendererObj.drawString(this.trans("136", "Circuitry burned out."), 10, 48, 16448255); + } - if ((((GT_Container_MultiMachine) this.mContainer).mDisplayErrorCode & 32) != 0) { - this.fontRendererObj.drawString(this.trans("137", "That doesn\'t belong there."), 10, 56, 16448255); - } + if ((((GT_Container_MultiMachine) this.mContainer).mDisplayErrorCode & 32) != 0) { + this.fontRendererObj.drawString(this.trans("137", "That doesn\'t belong there."), 10, 56, 16448255); + } - if ((((GT_Container_MultiMachine) this.mContainer).mDisplayErrorCode & 64) != 0) { - this.fontRendererObj.drawString(this.trans("138", "Incomplete Structure."), 10, 64, 16448255); - } + if ((((GT_Container_MultiMachine) this.mContainer).mDisplayErrorCode & 64) != 0) { + this.fontRendererObj.drawString(this.trans("138", "Incomplete Structure."), 10, 64, 16448255); + } - if (((GT_Container_MultiMachine) this.mContainer).mDisplayErrorCode == 0) { - if (((GT_Container_MultiMachine) this.mContainer).mActive == 0) { - this.fontRendererObj.drawString(this.trans("139", "Hit with Soft Hammer"), 10, 16, 16448255); - this.fontRendererObj.drawString(this.trans("140", "to (re-)start the Machine"), 10, 24, 16448255); - this.fontRendererObj.drawString(this.trans("141", "if it doesn\'t start."), 10, 32, 16448255); - } else { - this.fontRendererObj.drawString(this.trans("142", "Running perfectly."), 10, 16, 16448255); - } + if (((GT_Container_MultiMachine) this.mContainer).mDisplayErrorCode == 0) { + if (((GT_Container_MultiMachine) this.mContainer).mActive == 0) { + this.fontRendererObj.drawString(this.trans("139", "Hit with Soft Hammer"), 10, 16, 16448255); + this.fontRendererObj.drawString(this.trans("140", "to (re-)start the Machine"), 10, 24, 16448255); + this.fontRendererObj.drawString(this.trans("141", "if it doesn\'t start."), 10, 32, 16448255); + } else { + this.fontRendererObj.drawString(this.trans("142", "Running perfectly."), 10, 16, 16448255); + } - ItemStack tItem; - if (this.mContainer.mTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_LargeTurbine) { - tItem = this.mContainer.mTileEntity.getMetaTileEntity().getStackInSlot(1); - if (tItem == null || tItem.getItem() != GT_MetaGenerated_Tool_01.INSTANCE - || tItem.getItemDamage() < 170 || tItem.getItemDamage() > 177) { - this.fontRendererObj.drawString(this.trans("144", "Missing Turbine Rotor"), 10, - ((GT_Container_MultiMachine) this.mContainer).mActive == 0 ? 40 : 24, 16448255); - } - } - } - } + ItemStack tItem; + if (this.mContainer.mTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_LargeTurbine) { + tItem = this.mContainer.mTileEntity.getMetaTileEntity().getStackInSlot(1); + if (tItem == null + || tItem.getItem() != GT_MetaGenerated_Tool_01.INSTANCE + || tItem.getItemDamage() < 170 + || tItem.getItemDamage() > 177) { + this.fontRendererObj.drawString( + this.trans("144", "Missing Turbine Rotor"), + 10, + ((GT_Container_MultiMachine) this.mContainer).mActive == 0 ? 40 : 24, + 16448255); + } + } + } + } + } - } + public String trans(String aKey, String aEnglish) { + return GT_LanguageManager.addStringLocalization("Interaction_DESCRIPTION_Index_" + aKey, aEnglish, false); + } - public String trans(String aKey, String aEnglish) { - return GT_LanguageManager.addStringLocalization("Interaction_DESCRIPTION_Index_" + aKey, aEnglish, false); - } - - protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { - super.drawGuiContainerBackgroundLayer(par1, par2, par3); - int x = (this.width - this.xSize) / 2; - int y = (this.height - this.ySize) / 2; - this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); - } -}
\ No newline at end of file + protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { + super.drawGuiContainerBackgroundLayer(par1, par2, par3); + int x = (this.width - this.xSize) / 2; + int y = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_PowerSubStation.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_PowerSubStation.java index e80235565e..beb6c1dc3e 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_PowerSubStation.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_PowerSubStation.java @@ -9,118 +9,126 @@ import gtPlusPlus.core.util.math.MathUtils; import net.minecraft.entity.player.InventoryPlayer; public class GUI_PowerSubStation extends GT_GUIContainerMetaTile_Machine { - public String mNEI; - String mName; - boolean[] mRepairStatus = new boolean[6]; + public String mNEI; + String mName; + boolean[] mRepairStatus = new boolean[6]; - public final CONTAINER_PowerSubStation mPowerContainer; + public final CONTAINER_PowerSubStation mPowerContainer; - public GUI_PowerSubStation(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity, final String aName, final String aNEI) { - super(new CONTAINER_PowerSubStation(aInventoryPlayer, aTileEntity, false), CORE.RES_PATH_GUI + "PowerSubStation.png"); - this.mName = aName; - this.mNEI = aNEI; - mPowerContainer = (CONTAINER_PowerSubStation) mContainer; - /** The X size of the inventory window in pixels. */ - this.xSize = 196; - /** The Y size of the inventory window in pixels. */ - this.ySize = 191; - } + public GUI_PowerSubStation( + final InventoryPlayer aInventoryPlayer, + final IGregTechTileEntity aTileEntity, + final String aName, + final String aNEI) { + super( + new CONTAINER_PowerSubStation(aInventoryPlayer, aTileEntity, false), + CORE.RES_PATH_GUI + "PowerSubStation.png"); + this.mName = aName; + this.mNEI = aNEI; + mPowerContainer = (CONTAINER_PowerSubStation) mContainer; + /** The X size of the inventory window in pixels. */ + this.xSize = 196; + /** The Y size of the inventory window in pixels. */ + this.ySize = 191; + } - protected void drawGuiContainerForegroundLayer(final int par1, final int par2) { - this.fontRendererObj.drawString(this.mName, 8, -10, 16448255); - if (this.mPowerContainer != null) { + protected void drawGuiContainerForegroundLayer(final int par1, final int par2) { + this.fontRendererObj.drawString(this.mName, 8, -10, 16448255); + if (this.mPowerContainer != null) { - //this.fontRendererObj.drawString("Error Code: " + mPowerContainer.mDisplayErrorCode, 10, 142, 16448255); + // this.fontRendererObj.drawString("Error Code: " + mPowerContainer.mDisplayErrorCode, 10, 142, 16448255); + if (((this.mContainer).mDisplayErrorCode & 1) != 0) { + mRepairStatus[0] = false; + } else { + mRepairStatus[0] = true; + } + if ((mPowerContainer.mDisplayErrorCode & 2) != 0) { + mRepairStatus[1] = false; + } else { + mRepairStatus[1] = true; + } + if ((mPowerContainer.mDisplayErrorCode & 4) != 0) { + mRepairStatus[2] = false; + } else { + mRepairStatus[2] = true; + } + if ((mPowerContainer.mDisplayErrorCode & 8) != 0) { + mRepairStatus[3] = false; + } else { + mRepairStatus[3] = true; + } + if ((mPowerContainer.mDisplayErrorCode & 16) != 0) { + mRepairStatus[4] = false; + } else { + mRepairStatus[4] = true; + } + if ((mPowerContainer.mDisplayErrorCode & 32) != 0) { + mRepairStatus[5] = false; + } else { + mRepairStatus[5] = true; + } + if (mPowerContainer.mDisplayErrorCode == 0) { + if (mPowerContainer.mActive == 0) { + this.fontRendererObj.drawString("Turn on with Mallet", 10, 8, 16448255); + } else { + this.fontRendererObj.drawString("Running perfectly", 10, 8, 16448255); + } + } - if (((this.mContainer).mDisplayErrorCode & 1) != 0) { - mRepairStatus[0] = false; - } - else { - mRepairStatus[0] = true; - } - if ((mPowerContainer.mDisplayErrorCode & 2) != 0) { - mRepairStatus[1] = false; - } - else { - mRepairStatus[1] = true; - } - if ((mPowerContainer.mDisplayErrorCode & 4) != 0) { - mRepairStatus[2] = false; - } - else { - mRepairStatus[2] = true; - } - if ((mPowerContainer.mDisplayErrorCode & 8) != 0) { - mRepairStatus[3] = false; - } - else { - mRepairStatus[3] = true; - } - if ((mPowerContainer.mDisplayErrorCode & 16) != 0) { - mRepairStatus[4] = false; - } - else { - mRepairStatus[4] = true; - } - if ((mPowerContainer.mDisplayErrorCode & 32) != 0) { - mRepairStatus[5] = false; - } - else { - mRepairStatus[5] = true; - } - if (mPowerContainer.mDisplayErrorCode == 0) { - if (mPowerContainer.mActive == 0) { - this.fontRendererObj.drawString("Turn on with Mallet", 10, 8, 16448255); - } - else { - this.fontRendererObj.drawString("Running perfectly", 10, 8, 16448255); - } - } + this.fontRendererObj.drawString("In", 178, 10, 16448255); + this.fontRendererObj.drawString("Out", 176, 28, 16448255); + this.fontRendererObj.drawString( + "Avg In: " + GT_Utility.formatNumbers(this.mPowerContainer.mAverageEuAdded.getValue()) + " EU", + 10, + 20, + 16448255); + this.fontRendererObj.drawString( + "Avg Out: " + GT_Utility.formatNumbers(this.mPowerContainer.mAverageEuConsumed.getValue()) + " EU", + 10, + 30, + 16448255); - this.fontRendererObj.drawString("In", 178, 10, 16448255); - this.fontRendererObj.drawString("Out", 176, 28, 16448255); - this.fontRendererObj.drawString("Avg In: "+GT_Utility.formatNumbers(this.mPowerContainer.mAverageEuAdded.getValue())+" EU", 10, 20, 16448255); - this.fontRendererObj.drawString("Avg Out: "+GT_Utility.formatNumbers(this.mPowerContainer.mAverageEuConsumed.getValue())+" EU", 10, 30, 16448255); + final double tScale2 = MathUtils.findPercentage( + this.mPowerContainer.mStoredEU.getValue(), this.mPowerContainer.mMaxStoredEU.getValue()); + final int tScale = (int) (tScale2 * 2.55); + this.fontRendererObj.drawString("Stored:", 10, 132, 16448255); + this.fontRendererObj.drawString( + GT_Utility.formatNumbers(this.mPowerContainer.mStoredEU.getValue()) + " EU", + 10, + 142, + Utils.rgbtoHexValue((255 - tScale), (0 + tScale), 0)); + this.fontRendererObj.drawString(GT_Utility.formatNumbers(tScale2) + "%", 70, 155, 16448255); + } + } - final double tScale2 = MathUtils.findPercentage(this.mPowerContainer.mStoredEU.getValue(), this.mPowerContainer.mMaxStoredEU.getValue()); - final int tScale = (int) (tScale2 * 2.55); - this.fontRendererObj.drawString("Stored:", 10, 132, 16448255); - this.fontRendererObj.drawString(GT_Utility.formatNumbers(this.mPowerContainer.mStoredEU.getValue()) + " EU", 10, 142, Utils.rgbtoHexValue((255 - tScale), (0 + tScale), 0)); - this.fontRendererObj.drawString(GT_Utility.formatNumbers(tScale2)+"%", 70, 155, 16448255); + protected void drawGuiContainerBackgroundLayer(final float par1, final int par2, final int par3) { + /** The X size of the inventory window in pixels. */ + if (this.xSize != 196) this.xSize = 196; + /** The Y size of the inventory window in pixels. */ + if (this.ySize != 191) this.ySize = 191; + super.drawGuiContainerBackgroundLayer(par1, par2, par3); + final int x = (this.width - this.xSize) / 2; + final int y = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); + if (this.mPowerContainer != null) { + final double tScale = MathUtils.findPercentage( + this.mPowerContainer.mStoredEU.getValue(), this.mPowerContainer.mMaxStoredEU.getValue()) + / 100; + this.drawTexturedModalRect(x + 5, y + 156, 0, 251, Math.min(147, (int) (tScale * 148.0)), 5); - } - } - - protected void drawGuiContainerBackgroundLayer(final float par1, final int par2, final int par3) { - /** The X size of the inventory window in pixels. */ - if (this.xSize != 196) - this.xSize = 196; - /** The Y size of the inventory window in pixels. */ - if (this.ySize != 191) - this.ySize = 191; - super.drawGuiContainerBackgroundLayer(par1, par2, par3); - final int x = (this.width - this.xSize) / 2; - final int y = (this.height - this.ySize) / 2; - this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); - if (this.mPowerContainer != null) { - final double tScale = MathUtils.findPercentage(this.mPowerContainer.mStoredEU.getValue(), this.mPowerContainer.mMaxStoredEU.getValue()) / 100; - this.drawTexturedModalRect(x + 5, y + 156, 0, 251, Math.min(147, (int) (tScale * 148.0)), 5); - - // A1 - this.drawTexturedModalRect(x + 154, y + 76, 238, (!mRepairStatus[0] ? 0 : 18), 18, 18); - // A2 - this.drawTexturedModalRect(x + 154 + 20, y + 76, 238, (!mRepairStatus[1] ? 0 : 18), 18, 18); - // B1 - this.drawTexturedModalRect(x + 154, y + 76 + 18, 238, (!mRepairStatus[2] ? 0 : 18), 18, 18); - // B2 - this.drawTexturedModalRect(x + 154 + 20, y + 76 + 18, 238, (!mRepairStatus[3] ? 0 : 18), 18, 18); - // C1 - this.drawTexturedModalRect(x + 154, y + 76 + 36, 238, (!mRepairStatus[4] ? 0 : 18), 18, 18); - // C2 - this.drawTexturedModalRect(x + 154 + 20, y + 76 + 36, 238, (!mRepairStatus[5] ? 0 : 18), 18, 18); - - - } - } + // A1 + this.drawTexturedModalRect(x + 154, y + 76, 238, (!mRepairStatus[0] ? 0 : 18), 18, 18); + // A2 + this.drawTexturedModalRect(x + 154 + 20, y + 76, 238, (!mRepairStatus[1] ? 0 : 18), 18, 18); + // B1 + this.drawTexturedModalRect(x + 154, y + 76 + 18, 238, (!mRepairStatus[2] ? 0 : 18), 18, 18); + // B2 + this.drawTexturedModalRect(x + 154 + 20, y + 76 + 18, 238, (!mRepairStatus[3] ? 0 : 18), 18, 18); + // C1 + this.drawTexturedModalRect(x + 154, y + 76 + 36, 238, (!mRepairStatus[4] ? 0 : 18), 18, 18); + // C2 + this.drawTexturedModalRect(x + 154 + 20, y + 76 + 36, 238, (!mRepairStatus[5] ? 0 : 18), 18, 18); + } + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_SafeBlock.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_SafeBlock.java index c18d58b4b6..c44dbd0e1f 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_SafeBlock.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_SafeBlock.java @@ -1,51 +1,46 @@ package gtPlusPlus.xmod.gregtech.api.gui; -import net.minecraft.entity.player.InventoryPlayer; - import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; - import gtPlusPlus.core.lib.CORE; +import net.minecraft.entity.player.InventoryPlayer; -public class GUI_SafeBlock -extends GT_GUIContainerMetaTile_Machine { - public GUI_SafeBlock(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity) { - super(new CONTAINER_SafeBlock(aInventoryPlayer, aTileEntity), CORE.RES_PATH_GUI + "SafeBlock.png"); - } - - //String UUID = ((CONTAINER_SafeBlock)this.mContainer).ownerUUID.toString(); - boolean blockStatus = ((CONTAINER_SafeBlock)this.mContainer).blockStatus; - //String tempPlayer; - - private void updateVars(){ - //UUID = ((CONTAINER_SafeBlock)this.mContainer).ownerUUID; - this.blockStatus = ((CONTAINER_SafeBlock)this.mContainer).blockStatus; - // tempPlayer = PlayerCache.lookupPlayerByUUID(UUID); - } - - @Override - protected void drawGuiContainerForegroundLayer(final int par1, final int par2) - { - this.updateVars(); - //this.fontRendererObj.drawString("Owner: "+ tempPlayer, 64, 72, 4210752); - //this.fontRendererObj.drawString(": "+ UUID.toLowerCase(), 44, 82, 4210752); - this.fontRendererObj.drawString("Safe Status", 76, 61, 4210752); - if (this.blockStatus){ - this.fontRendererObj.drawString("Locked", 88, 73, 4210752); - } - else { - this.fontRendererObj.drawString("Unlocked", 82, 73, 4210752); - } - } - - @Override - protected void drawGuiContainerBackgroundLayer(final float par1, final int par2, final int par3) { - super.drawGuiContainerBackgroundLayer(par1, par2, par3); - final int x = (this.width - this.xSize) / 2; - final int y = (this.height - this.ySize) / 2; - this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); - /*String UUID = ((CONTAINER_SafeBlock)this.mContainer).UUID; +public class GUI_SafeBlock extends GT_GUIContainerMetaTile_Machine { + public GUI_SafeBlock(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity) { + super(new CONTAINER_SafeBlock(aInventoryPlayer, aTileEntity), CORE.RES_PATH_GUI + "SafeBlock.png"); + } + + // String UUID = ((CONTAINER_SafeBlock)this.mContainer).ownerUUID.toString(); + boolean blockStatus = ((CONTAINER_SafeBlock) this.mContainer).blockStatus; + // String tempPlayer; + + private void updateVars() { + // UUID = ((CONTAINER_SafeBlock)this.mContainer).ownerUUID; + this.blockStatus = ((CONTAINER_SafeBlock) this.mContainer).blockStatus; + // tempPlayer = PlayerCache.lookupPlayerByUUID(UUID); + } + + @Override + protected void drawGuiContainerForegroundLayer(final int par1, final int par2) { + this.updateVars(); + // this.fontRendererObj.drawString("Owner: "+ tempPlayer, 64, 72, 4210752); + // this.fontRendererObj.drawString(": "+ UUID.toLowerCase(), 44, 82, 4210752); + this.fontRendererObj.drawString("Safe Status", 76, 61, 4210752); + if (this.blockStatus) { + this.fontRendererObj.drawString("Locked", 88, 73, 4210752); + } else { + this.fontRendererObj.drawString("Unlocked", 82, 73, 4210752); + } + } + + @Override + protected void drawGuiContainerBackgroundLayer(final float par1, final int par2, final int par3) { + super.drawGuiContainerBackgroundLayer(par1, par2, par3); + final int x = (this.width - this.xSize) / 2; + final int y = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); + /*String UUID = ((CONTAINER_SafeBlock)this.mContainer).UUID; this.fontRendererObj.drawString("Owner UUID: "+ UUID, 8, 12, 4210752);*/ - } + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_SolarGenerator.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_SolarGenerator.java index f0b3a0c879..8fb63fe148 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_SolarGenerator.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_SolarGenerator.java @@ -1,44 +1,43 @@ package gtPlusPlus.xmod.gregtech.api.gui; -import net.minecraft.entity.player.InventoryPlayer; - import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import net.minecraft.entity.player.InventoryPlayer; -public class GUI_SolarGenerator -extends GT_GUIContainerMetaTile_Machine { - public GUI_SolarGenerator(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity, final String aTextureName) { - super(new CONTAINER_SolarGenerator(aInventoryPlayer, aTileEntity), "gregtech:textures/gui/" + aTextureName); - } +public class GUI_SolarGenerator extends GT_GUIContainerMetaTile_Machine { + public GUI_SolarGenerator( + final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity, final String aTextureName) { + super(new CONTAINER_SolarGenerator(aInventoryPlayer, aTileEntity), "gregtech:textures/gui/" + aTextureName); + } - @Override - protected void drawGuiContainerForegroundLayer(final int par1, final int par2) { - this.fontRendererObj.drawString("Solar Generator", 8, 4, 4210752); - } + @Override + protected void drawGuiContainerForegroundLayer(final int par1, final int par2) { + this.fontRendererObj.drawString("Solar Generator", 8, 4, 4210752); + } - @Override - protected void drawGuiContainerBackgroundLayer(final float par1, final int par2, final int par3) { - super.drawGuiContainerBackgroundLayer(par1, par2, par3); - final int x = (this.width - this.xSize) / 2; - final int y = (this.height - this.ySize) / 2; - this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); - if (this.mContainer != null) { - int tScale = ((CONTAINER_SolarGenerator) this.mContainer).mProcessingEnergy; - if (tScale > 0) { - this.drawTexturedModalRect(x + 70, (y + 25 + 54) - tScale, 194, 54 - tScale, 10, tScale); - } - tScale = ((CONTAINER_SolarGenerator) this.mContainer).mEnergy; - if (tScale > 0) { - this.drawTexturedModalRect(x + 83, (y + 25 + 54) - tScale, 204, 54 - tScale, 10, tScale); - } - tScale = ((CONTAINER_SolarGenerator) this.mContainer).mTemperature; - if (tScale > 0) { - this.drawTexturedModalRect(x + 96, (y + 25 + 54) - tScale, 214, 54 - tScale, 10, tScale); - } - tScale = ((CONTAINER_SolarGenerator) this.mContainer).mProcessingEnergy; - if (tScale > 0) { - this.drawTexturedModalRect(x + 117, (y + 44 + 14) - tScale, 177, 14 - tScale, 15, tScale + 1); - } - } - } + @Override + protected void drawGuiContainerBackgroundLayer(final float par1, final int par2, final int par3) { + super.drawGuiContainerBackgroundLayer(par1, par2, par3); + final int x = (this.width - this.xSize) / 2; + final int y = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); + if (this.mContainer != null) { + int tScale = ((CONTAINER_SolarGenerator) this.mContainer).mProcessingEnergy; + if (tScale > 0) { + this.drawTexturedModalRect(x + 70, (y + 25 + 54) - tScale, 194, 54 - tScale, 10, tScale); + } + tScale = ((CONTAINER_SolarGenerator) this.mContainer).mEnergy; + if (tScale > 0) { + this.drawTexturedModalRect(x + 83, (y + 25 + 54) - tScale, 204, 54 - tScale, 10, tScale); + } + tScale = ((CONTAINER_SolarGenerator) this.mContainer).mTemperature; + if (tScale > 0) { + this.drawTexturedModalRect(x + 96, (y + 25 + 54) - tScale, 214, 54 - tScale, 10, tScale); + } + tScale = ((CONTAINER_SolarGenerator) this.mContainer).mProcessingEnergy; + if (tScale > 0) { + this.drawTexturedModalRect(x + 117, (y + 44 + 14) - tScale, 177, 14 - tScale, 15, tScale + 1); + } + } + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_SteamCondenser.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_SteamCondenser.java index 88a3e00bb5..de3d56bdac 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_SteamCondenser.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_SteamCondenser.java @@ -6,51 +6,47 @@ import gtPlusPlus.core.lib.CORE; import gtPlusPlus.preloader.CORE_Preloader; import net.minecraft.entity.player.InventoryPlayer; -public class GUI_SteamCondenser extends GT_GUIContainerMetaTile_Machine -{ - long tickTime = 0; +public class GUI_SteamCondenser extends GT_GUIContainerMetaTile_Machine { + long tickTime = 0; - public GUI_SteamCondenser(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity, final String aTextureName) - { - super(new CONTAINER_SteamCondenser(aInventoryPlayer, aTileEntity), CORE.RES_PATH_GUI + aTextureName); - } + public GUI_SteamCondenser( + final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity, final String aTextureName) { + super(new CONTAINER_SteamCondenser(aInventoryPlayer, aTileEntity), CORE.RES_PATH_GUI + aTextureName); + } - @Override - protected void drawGuiContainerForegroundLayer(final int par1, final int par2) - { - this.fontRendererObj.drawString("Condenser", 8, 4, 4210752); - if (CORE_Preloader.DEBUG_MODE){ - this.tickTime = ((CONTAINER_SteamCondenser)this.mContainer).mTickingTime; - this.fontRendererObj.drawString("Tick Time: "+this.tickTime, 8, 12, 4210752); - } - } + @Override + protected void drawGuiContainerForegroundLayer(final int par1, final int par2) { + this.fontRendererObj.drawString("Condenser", 8, 4, 4210752); + if (CORE_Preloader.DEBUG_MODE) { + this.tickTime = ((CONTAINER_SteamCondenser) this.mContainer).mTickingTime; + this.fontRendererObj.drawString("Tick Time: " + this.tickTime, 8, 12, 4210752); + } + } - @Override - protected void drawGuiContainerBackgroundLayer(final float par1, final int par2, final int par3) - { - super.drawGuiContainerBackgroundLayer(par1, par2, par3); - final int x = (this.width - this.xSize) / 2; - final int y = (this.height - this.ySize) / 2; - this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); - if (this.mContainer != null) - { + @Override + protected void drawGuiContainerBackgroundLayer(final float par1, final int par2, final int par3) { + super.drawGuiContainerBackgroundLayer(par1, par2, par3); + final int x = (this.width - this.xSize) / 2; + final int y = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); + if (this.mContainer != null) { - int tScale = ((CONTAINER_SteamCondenser)this.mContainer).mSteamAmount; - if (tScale > 0) { - this.drawTexturedModalRect(x + 70, (y + 25 + 54) - tScale, 194, 54 - tScale, 10, tScale); - } - tScale = ((CONTAINER_SteamCondenser)this.mContainer).mWaterAmount; - if (tScale > 0) { - this.drawTexturedModalRect(x + 83, (y + 25 + 54) - tScale, 204, 54 - tScale, 10, tScale); - } - tScale = ((CONTAINER_SteamCondenser)this.mContainer).mTemperature; - if (tScale > 0) { - this.drawTexturedModalRect(x + 96, (y + 25 + 54) - tScale, 214, 54 - tScale, 10, tScale); - } - tScale = ((CONTAINER_SteamCondenser)this.mContainer).mProcessingEnergy; - if (tScale > 0) { - this.drawTexturedModalRect(x + 115, y + 44 + 2/* - tScale*/, 177, 14 - tScale, 15, 1+tScale); - } - } - } -}
\ No newline at end of file + int tScale = ((CONTAINER_SteamCondenser) this.mContainer).mSteamAmount; + if (tScale > 0) { + this.drawTexturedModalRect(x + 70, (y + 25 + 54) - tScale, 194, 54 - tScale, 10, tScale); + } + tScale = ((CONTAINER_SteamCondenser) this.mContainer).mWaterAmount; + if (tScale > 0) { + this.drawTexturedModalRect(x + 83, (y + 25 + 54) - tScale, 204, 54 - tScale, 10, tScale); + } + tScale = ((CONTAINER_SteamCondenser) this.mContainer).mTemperature; + if (tScale > 0) { + this.drawTexturedModalRect(x + 96, (y + 25 + 54) - tScale, 214, 54 - tScale, 10, tScale); + } + tScale = ((CONTAINER_SteamCondenser) this.mContainer).mProcessingEnergy; + if (tScale > 0) { + this.drawTexturedModalRect(x + 115, y + 44 + 2 /* - tScale*/, 177, 14 - tScale, 15, 1 + tScale); + } + } + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_SuperChest.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_SuperChest.java index d324c50dd0..b65ac110c3 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_SuperChest.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_SuperChest.java @@ -1,38 +1,37 @@ package gtPlusPlus.xmod.gregtech.api.gui; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.util.StatCollector; - import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.util.GT_Utility; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.StatCollector; public class GUI_SuperChest extends GT_GUIContainerMetaTile_Machine { - private final String mName; - - public GUI_SuperChest(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, - String aName) { - super(new CONTAINER_SuperChest(aInventoryPlayer, aTileEntity), "gregtech:textures/gui/BasicTank.png"); - this.mName = aName; - } + private final String mName; - protected void drawGuiContainerForegroundLayer(int par1, int par2) { - this.fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 8, this.ySize - 96 + 2, - 4210752); - this.fontRendererObj.drawString(this.mName, 8, 6, 4210752); - if (this.mContainer != null) { - this.fontRendererObj.drawString("Item Amount", 10, 20, 16448255); - this.fontRendererObj.drawString( - GT_Utility.parseNumberToString(((CONTAINER_SuperChest) this.mContainer).mContent), 10, 30, - 16448255); - } + public GUI_SuperChest(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName) { + super(new CONTAINER_SuperChest(aInventoryPlayer, aTileEntity), "gregtech:textures/gui/BasicTank.png"); + this.mName = aName; + } - } + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + this.fontRendererObj.drawString( + StatCollector.translateToLocal("container.inventory"), 8, this.ySize - 96 + 2, 4210752); + this.fontRendererObj.drawString(this.mName, 8, 6, 4210752); + if (this.mContainer != null) { + this.fontRendererObj.drawString("Item Amount", 10, 20, 16448255); + this.fontRendererObj.drawString( + GT_Utility.parseNumberToString(((CONTAINER_SuperChest) this.mContainer).mContent), + 10, + 30, + 16448255); + } + } - protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { - super.drawGuiContainerBackgroundLayer(par1, par2, par3); - int x = (this.width - this.xSize) / 2; - int y = (this.height - this.ySize) / 2; - this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); - } -}
\ No newline at end of file + protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { + super.drawGuiContainerBackgroundLayer(par1, par2, par3); + int x = (this.width - this.xSize) / 2; + int y = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_TreeFarmer.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_TreeFarmer.java index b236b0ff32..af6c212fdf 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_TreeFarmer.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_TreeFarmer.java @@ -1,46 +1,48 @@ - package gtPlusPlus.xmod.gregtech.api.gui; - -import net.minecraft.entity.player.InventoryPlayer; - import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; - import gtPlusPlus.core.lib.CORE; +import net.minecraft.entity.player.InventoryPlayer; public class GUI_TreeFarmer extends GT_GUIContainerMetaTile_Machine { - String mName = ""; - long maxPower = 0; - long storedPower = 0; - - public GUI_TreeFarmer(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity, final String aName, final String aTextureFile) { - super(new CONTAINER_TreeFarmer(aInventoryPlayer, aTileEntity), CORE.RES_PATH_GUI + (aTextureFile == null ? "MultiblockDisplay" : aTextureFile)); - this.mName = aName; - } - - @Override - protected void drawGuiContainerForegroundLayer(final int par1, final int par2) { - this.fontRendererObj.drawString(this.mName, 64, 6, 16448255); - if (this.mContainer != null) { - this.maxPower = ((CONTAINER_TreeFarmer)this.mContainer).maxEU; - this.storedPower = ((CONTAINER_TreeFarmer)this.mContainer).storedEU; - if (((CONTAINER_TreeFarmer) this.mContainer).mDisplayErrorCode == 0) { - this.fontRendererObj.drawString("Current Power: "+this.storedPower+"EU", 8, 52, 16448255); - this.fontRendererObj.drawString("Max Power: "+this.maxPower+"EU", 8, 60, 16448255); - this.fontRendererObj.drawString("Current operations left: "+(this.storedPower/32), 8, 68, 16448255); - } - } - } - - @Override - protected void drawGuiContainerBackgroundLayer(final float par1, final int par2, final int par3) { - super.drawGuiContainerBackgroundLayer(par1, par2, par3); - this.maxPower = ((CONTAINER_TreeFarmer)this.mContainer).maxEU; - this.storedPower = ((CONTAINER_TreeFarmer)this.mContainer).storedEU; - final int x = (this.width - this.xSize) / 2; - final int y = (this.height - this.ySize) / 2; - this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); - } + String mName = ""; + long maxPower = 0; + long storedPower = 0; + + public GUI_TreeFarmer( + final InventoryPlayer aInventoryPlayer, + final IGregTechTileEntity aTileEntity, + final String aName, + final String aTextureFile) { + super( + new CONTAINER_TreeFarmer(aInventoryPlayer, aTileEntity), + CORE.RES_PATH_GUI + (aTextureFile == null ? "MultiblockDisplay" : aTextureFile)); + this.mName = aName; + } + + @Override + protected void drawGuiContainerForegroundLayer(final int par1, final int par2) { + this.fontRendererObj.drawString(this.mName, 64, 6, 16448255); + if (this.mContainer != null) { + this.maxPower = ((CONTAINER_TreeFarmer) this.mContainer).maxEU; + this.storedPower = ((CONTAINER_TreeFarmer) this.mContainer).storedEU; + if (((CONTAINER_TreeFarmer) this.mContainer).mDisplayErrorCode == 0) { + this.fontRendererObj.drawString("Current Power: " + this.storedPower + "EU", 8, 52, 16448255); + this.fontRendererObj.drawString("Max Power: " + this.maxPower + "EU", 8, 60, 16448255); + this.fontRendererObj.drawString("Current operations left: " + (this.storedPower / 32), 8, 68, 16448255); + } + } + } + + @Override + protected void drawGuiContainerBackgroundLayer(final float par1, final int par2, final int par3) { + super.drawGuiContainerBackgroundLayer(par1, par2, par3); + this.maxPower = ((CONTAINER_TreeFarmer) this.mContainer).maxEU; + this.storedPower = ((CONTAINER_TreeFarmer) this.mContainer).storedEU; + final int x = (this.width - this.xSize) / 2; + final int y = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/SyncedLong.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/SyncedLong.java index 4214d32469..c738d41422 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/SyncedLong.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/SyncedLong.java @@ -38,7 +38,7 @@ class SyncedLong { dirty = false; } } - + private long getPiece(int index) { return ((long) pieces[index]) & 0xffff; } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/SyncedValueManager.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/SyncedValueManager.java index ecf591698b..219e503a99 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/SyncedValueManager.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/SyncedValueManager.java @@ -29,7 +29,6 @@ class SyncedValueManager { } } - public void updateProgressBar(int short1, int short2) { for (SyncedLong val : longs) { if (val.updateProgressBar(short1, short2)) return; diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/automation/GT_Container_ElectricAutoWorkbench.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/automation/GT_Container_ElectricAutoWorkbench.java index 1af597c05a..4efc08dad0 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/automation/GT_Container_ElectricAutoWorkbench.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/automation/GT_Container_ElectricAutoWorkbench.java @@ -1,7 +1,5 @@ package gtPlusPlus.xmod.gregtech.api.gui.automation; -import com.google.gson.JsonObject; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.gui.GT_ContainerMetaTile_Machine; @@ -10,7 +8,6 @@ import gregtech.api.gui.GT_Slot_Output; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.util.GT_Utility; import gtPlusPlus.xmod.gregtech.common.tileentities.automation.GT_MetaTileEntity_ElectricAutoWorkbench; -import gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic.GT_MetaTileEntity_CropHarvestor; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.ICrafting; @@ -18,124 +15,123 @@ import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; public class GT_Container_ElectricAutoWorkbench extends GT_ContainerMetaTile_Machine { - - public int mMode; - public int mThroughPut; - public GT_Container_ElectricAutoWorkbench(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { - super(aInventoryPlayer, aTileEntity); - } + public int mMode; + public int mThroughPut; + + public GT_Container_ElectricAutoWorkbench(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { + super(aInventoryPlayer, aTileEntity); + } public void addSlots(InventoryPlayer aInventoryPlayer) { - addSlotToContainer(new Slot(mTileEntity, 0, 8, 5)); - addSlotToContainer(new Slot(mTileEntity, 1, 26, 5)); - addSlotToContainer(new Slot(mTileEntity, 2, 44, 5)); - addSlotToContainer(new Slot(mTileEntity, 3, 8, 23)); - addSlotToContainer(new Slot(mTileEntity, 4, 26, 23)); - addSlotToContainer(new Slot(mTileEntity, 5, 44, 23)); - addSlotToContainer(new Slot(mTileEntity, 6, 8, 41)); - addSlotToContainer(new Slot(mTileEntity, 7, 26, 41)); - addSlotToContainer(new Slot(mTileEntity, 8, 44, 41)); - - addSlotToContainer(new GT_Slot_Output(mTileEntity, 9, 8, 60)); - addSlotToContainer(new GT_Slot_Output(mTileEntity, 10, 26, 60)); - addSlotToContainer(new GT_Slot_Output(mTileEntity, 11, 44, 60)); - addSlotToContainer(new GT_Slot_Output(mTileEntity, 12, 62, 60)); - addSlotToContainer(new GT_Slot_Output(mTileEntity, 13, 80, 60)); - addSlotToContainer(new GT_Slot_Output(mTileEntity, 14, 98, 60)); + addSlotToContainer(new Slot(mTileEntity, 0, 8, 5)); + addSlotToContainer(new Slot(mTileEntity, 1, 26, 5)); + addSlotToContainer(new Slot(mTileEntity, 2, 44, 5)); + addSlotToContainer(new Slot(mTileEntity, 3, 8, 23)); + addSlotToContainer(new Slot(mTileEntity, 4, 26, 23)); + addSlotToContainer(new Slot(mTileEntity, 5, 44, 23)); + addSlotToContainer(new Slot(mTileEntity, 6, 8, 41)); + addSlotToContainer(new Slot(mTileEntity, 7, 26, 41)); + addSlotToContainer(new Slot(mTileEntity, 8, 44, 41)); + + addSlotToContainer(new GT_Slot_Output(mTileEntity, 9, 8, 60)); + addSlotToContainer(new GT_Slot_Output(mTileEntity, 10, 26, 60)); + addSlotToContainer(new GT_Slot_Output(mTileEntity, 11, 44, 60)); + addSlotToContainer(new GT_Slot_Output(mTileEntity, 12, 62, 60)); + addSlotToContainer(new GT_Slot_Output(mTileEntity, 13, 80, 60)); + addSlotToContainer(new GT_Slot_Output(mTileEntity, 14, 98, 60)); addSlotToContainer(new GT_Slot_Output(mTileEntity, 15, 116, 60)); addSlotToContainer(new GT_Slot_Output(mTileEntity, 16, 134, 60)); addSlotToContainer(new GT_Slot_Output(mTileEntity, 17, 152, 60)); - + addSlotToContainer(new GT_Slot_Output(mTileEntity, 18, 152, 41)); - - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 19, 64, 6, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 20, 81, 6, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 21, 98, 6, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 22, 64, 23, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 23, 81, 23, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 24, 98, 23, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 25, 64, 40, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 26, 81, 40, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 27, 98, 40, false, false, 1)); - - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 28, 152, 5, false, false, 1)); + + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 19, 64, 6, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 20, 81, 6, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 21, 98, 6, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 22, 64, 23, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 23, 81, 23, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 24, 98, 23, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 25, 64, 40, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 26, 81, 40, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 27, 98, 40, false, false, 1)); + + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 28, 152, 5, false, false, 1)); addSlotToContainer(new GT_Slot_Holo(mTileEntity, 29, 121, 41, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 29, 121, 5, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 29, 121, 5, false, false, 1)); } public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { - if (aSlotIndex < 18) return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); - - Slot tSlot = (Slot)inventorySlots.get(aSlotIndex); - if (tSlot != null) { - if (mTileEntity.getMetaTileEntity() == null) return null; - if (aSlotIndex > 18 && aSlotIndex < 28) { - ItemStack tStack = aPlayer.inventory.getItemStack(); - if (tStack != null) { - tStack = GT_Utility.copy(1, tStack); - } - tSlot.putStack(tStack); - return null; - } - if (aSlotIndex == 28) return null; - if (aSlotIndex == 29) { - if (aMouseclick == 0) { - ((GT_MetaTileEntity_ElectricAutoWorkbench)mTileEntity.getMetaTileEntity()).switchModeForward(); - } else { - ((GT_MetaTileEntity_ElectricAutoWorkbench)mTileEntity.getMetaTileEntity()).switchModeBackward(); - } - return null; - } - if (aSlotIndex == 30) { - ((GT_MetaTileEntity_ElectricAutoWorkbench)mTileEntity.getMetaTileEntity()).switchThrough(); - return null; - } - } - - return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + if (aSlotIndex < 18) return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + + Slot tSlot = (Slot) inventorySlots.get(aSlotIndex); + if (tSlot != null) { + if (mTileEntity.getMetaTileEntity() == null) return null; + if (aSlotIndex > 18 && aSlotIndex < 28) { + ItemStack tStack = aPlayer.inventory.getItemStack(); + if (tStack != null) { + tStack = GT_Utility.copy(1, tStack); + } + tSlot.putStack(tStack); + return null; + } + if (aSlotIndex == 28) return null; + if (aSlotIndex == 29) { + if (aMouseclick == 0) { + ((GT_MetaTileEntity_ElectricAutoWorkbench) mTileEntity.getMetaTileEntity()).switchModeForward(); + } else { + ((GT_MetaTileEntity_ElectricAutoWorkbench) mTileEntity.getMetaTileEntity()).switchModeBackward(); + } + return null; + } + if (aSlotIndex == 30) { + ((GT_MetaTileEntity_ElectricAutoWorkbench) mTileEntity.getMetaTileEntity()).switchThrough(); + return null; + } + } + + return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); } - + public int getSlotCount() { - return 19; + return 19; } - + public int getShiftClickSlotCount() { - return 9; + return 9; + } + + @Override + public void detectAndSendChanges() { + super.detectAndSendChanges(); + if (mTileEntity.isClientSide() || mTileEntity.getMetaTileEntity() == null) { + return; + } + mMode = ((GT_MetaTileEntity_ElectricAutoWorkbench) mTileEntity.getMetaTileEntity()).mMode; + mThroughPut = ((GT_MetaTileEntity_ElectricAutoWorkbench) mTileEntity.getMetaTileEntity()).mThroughPut; + for (Object crafter : this.crafters) { + ICrafting var1 = (ICrafting) crafter; + var1.sendProgressBarUpdate(this, 103, this.mMode); + var1.sendProgressBarUpdate(this, 104, this.mThroughPut); + } + } + + @Override + public void addCraftingToCrafters(ICrafting par1ICrafting) { + super.addCraftingToCrafters(par1ICrafting); + } + + @Override + @SideOnly(Side.CLIENT) + public void updateProgressBar(int par1, int par2) { + super.updateProgressBar(par1, par2); + switch (par1) { + case 103: + this.mMode = par2; + break; + case 104: + this.mThroughPut = par2; + break; + } } - - @Override - public void detectAndSendChanges() { - super.detectAndSendChanges(); - if (mTileEntity.isClientSide() || mTileEntity.getMetaTileEntity() == null) { - return; - } - mMode = ((GT_MetaTileEntity_ElectricAutoWorkbench) mTileEntity.getMetaTileEntity()).mMode; - mThroughPut = ((GT_MetaTileEntity_ElectricAutoWorkbench) mTileEntity.getMetaTileEntity()).mThroughPut; - for (Object crafter : this.crafters) { - ICrafting var1 = (ICrafting) crafter; - var1.sendProgressBarUpdate(this, 103, this.mMode); - var1.sendProgressBarUpdate(this, 104, this.mThroughPut); - } - } - - @Override - public void addCraftingToCrafters(ICrafting par1ICrafting) { - super.addCraftingToCrafters(par1ICrafting); - } - - @Override - @SideOnly(Side.CLIENT) - public void updateProgressBar(int par1, int par2) { - super.updateProgressBar(par1, par2); - switch (par1) { - case 103: - this.mMode = par2; - break; - case 104: - this.mThroughPut = par2; - break; - } - } - } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/automation/GT_Container_ElectricInventoryManager.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/automation/GT_Container_ElectricInventoryManager.java index 3e8f509dfd..0796c28a79 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/automation/GT_Container_ElectricInventoryManager.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/automation/GT_Container_ElectricInventoryManager.java @@ -1,7 +1,5 @@ package gtPlusPlus.xmod.gregtech.api.gui.automation; -import java.util.Iterator; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.gui.GT_ContainerMetaTile_Machine; @@ -9,6 +7,7 @@ import gregtech.api.gui.GT_Slot_Holo; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.util.GT_Utility; import gtPlusPlus.xmod.gregtech.common.tileentities.automation.GT_MetaTileEntity_ElectricInventoryManager; +import java.util.Iterator; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.ICrafting; @@ -18,250 +17,300 @@ import net.minecraftforge.oredict.OreDictionary; public class GT_Container_ElectricInventoryManager extends GT_ContainerMetaTile_Machine { - public int[] mTargetDirections = new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - public int[] mRangeDirections = new int[]{0, 0, 0, 0}; - public int mTargetInOut; - public int mTargetEnergy; + public int[] mTargetDirections = new int[] {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + public int[] mRangeDirections = new int[] {0, 0, 0, 0}; + public int mTargetInOut; + public int mTargetEnergy; - public GT_Container_ElectricInventoryManager(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { - super(aInventoryPlayer, aTileEntity); - } + public GT_Container_ElectricInventoryManager(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { + super(aInventoryPlayer, aTileEntity); + } - public void addSlots(InventoryPlayer aInventoryPlayer) { - addSlotToContainer(new Slot(mTileEntity, 0, 155, 5)); - addSlotToContainer(new Slot(mTileEntity, 1, 155, 23)); - addSlotToContainer(new Slot(mTileEntity, 2, 155, 41)); + public void addSlots(InventoryPlayer aInventoryPlayer) { + addSlotToContainer(new Slot(mTileEntity, 0, 155, 5)); + addSlotToContainer(new Slot(mTileEntity, 1, 155, 23)); + addSlotToContainer(new Slot(mTileEntity, 2, 155, 41)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 3, 5, 5, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 4, 5, 23, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 5, 5, 41, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 6, 61, 5, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 7, 61, 23, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 8, 61, 41, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 9, 80, 5, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 10, 80, 23, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 11, 80, 41, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 12, 136, 5, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 13, 136, 23, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 14, 136, 41, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 3, 5, 5, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 4, 5, 23, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 5, 5, 41, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 6, 61, 5, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 7, 61, 23, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 8, 61, 41, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 9, 80, 5, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 10, 80, 23, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 11, 80, 41, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 12, 136, 5, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 13, 136, 23, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 14, 136, 41, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 24, 5, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 24, 23, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 24, 41, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 42, 5, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 42, 23, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 42, 41, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 99, 5, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 99, 23, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 99, 41, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 117, 5, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 117, 23, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 117, 41, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 24, 5, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 24, 23, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 24, 41, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 42, 5, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 42, 23, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 42, 41, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 99, 5, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 99, 23, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 99, 41, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 117, 5, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 117, 23, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 117, 41, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 24, 60, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 42, 60, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 99, 60, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 117, 60, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 24, 60, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 42, 60, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 99, 60, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 117, 60, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 5, 60, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 61, 60, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 80, 60, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 136, 60, false, true, 1)); - } + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 5, 60, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 61, 60, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 80, 60, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 15, 136, 60, false, true, 1)); + } - public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { - if (aSlotIndex < 3 || aSlotIndex >= getAllSlotCount()) - return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); - Slot tSlot = (Slot) inventorySlots.get(aSlotIndex); - if (tSlot != null) { - if (mTileEntity.getMetaTileEntity() == null) - return null; - if (aSlotIndex < 15) { - ItemStack tStack = aPlayer.inventory.getItemStack(); - if (tStack != null) { - tStack = GT_Utility.copy(tStack); - if (aMouseclick != 0) { - tStack.setItemDamage(OreDictionary.WILDCARD_VALUE); - } - tSlot.putStack(tStack); - } - else { - if (tSlot.getStack() != null) { - if (aMouseclick == 0) { - tSlot.getStack().stackSize -= (aShifthold == 1 ? 8 : 1); - if (tSlot.getStack().stackSize <= 0) { - tSlot.putStack(null); - } - } - else { - tSlot.getStack().stackSize += (aShifthold == 1 ? 8 : 1); - if (tSlot.getStack().stackSize > tSlot.getStack().getMaxStackSize()) { - tSlot.getStack().stackSize = tSlot.getStack().getMaxStackSize(); - } - } - } - } - return null; - } - else if (aSlotIndex >= 27 && aSlotIndex <= 30) { - ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).iterateRangeDirection(aSlotIndex - 27); - } - else if (aSlotIndex >= 31 && aSlotIndex <= 34) { - ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).switchRangeEnergy(aSlotIndex - 31); - } - else if (aSlotIndex % 3 == 0) { - if (aMouseclick != 0) - ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).switchSlot1InOut((aSlotIndex - 15) / 3); - else - ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).iterateSlot1Direction((aSlotIndex - 15) / 3); - } - else if (aSlotIndex % 3 == 1) { - if (aMouseclick != 0) - ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).switchSlot2InOut((aSlotIndex - 16) / 3); - else - ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).iterateSlot2Direction((aSlotIndex - 16) / 3); - } - else if (aSlotIndex % 3 == 2) { - if (aMouseclick != 0) - ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).switchSlot3InOut((aSlotIndex - 17) / 3); - else - ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).iterateSlot3Direction((aSlotIndex - 17) / 3); - } - } - return null; - } + public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { + if (aSlotIndex < 3 || aSlotIndex >= getAllSlotCount()) + return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + Slot tSlot = (Slot) inventorySlots.get(aSlotIndex); + if (tSlot != null) { + if (mTileEntity.getMetaTileEntity() == null) return null; + if (aSlotIndex < 15) { + ItemStack tStack = aPlayer.inventory.getItemStack(); + if (tStack != null) { + tStack = GT_Utility.copy(tStack); + if (aMouseclick != 0) { + tStack.setItemDamage(OreDictionary.WILDCARD_VALUE); + } + tSlot.putStack(tStack); + } else { + if (tSlot.getStack() != null) { + if (aMouseclick == 0) { + tSlot.getStack().stackSize -= (aShifthold == 1 ? 8 : 1); + if (tSlot.getStack().stackSize <= 0) { + tSlot.putStack(null); + } + } else { + tSlot.getStack().stackSize += (aShifthold == 1 ? 8 : 1); + if (tSlot.getStack().stackSize > tSlot.getStack().getMaxStackSize()) { + tSlot.getStack().stackSize = tSlot.getStack().getMaxStackSize(); + } + } + } + } + return null; + } else if (aSlotIndex >= 27 && aSlotIndex <= 30) { + ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()) + .iterateRangeDirection(aSlotIndex - 27); + } else if (aSlotIndex >= 31 && aSlotIndex <= 34) { + ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()) + .switchRangeEnergy(aSlotIndex - 31); + } else if (aSlotIndex % 3 == 0) { + if (aMouseclick != 0) + ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()) + .switchSlot1InOut((aSlotIndex - 15) / 3); + else + ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()) + .iterateSlot1Direction((aSlotIndex - 15) / 3); + } else if (aSlotIndex % 3 == 1) { + if (aMouseclick != 0) + ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()) + .switchSlot2InOut((aSlotIndex - 16) / 3); + else + ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()) + .iterateSlot2Direction((aSlotIndex - 16) / 3); + } else if (aSlotIndex % 3 == 2) { + if (aMouseclick != 0) + ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()) + .switchSlot3InOut((aSlotIndex - 17) / 3); + else + ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()) + .iterateSlot3Direction((aSlotIndex - 17) / 3); + } + } + return null; + } - public void detectAndSendChanges() { - super.detectAndSendChanges(); - if (mTileEntity.isClientSide() || mTileEntity.getMetaTileEntity() == null) { - return; - } - mTargetDirections = new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - mRangeDirections = new int[]{0, 0, 0, 0}; + public void detectAndSendChanges() { + super.detectAndSendChanges(); + if (mTileEntity.isClientSide() || mTileEntity.getMetaTileEntity() == null) { + return; + } + mTargetDirections = new int[] {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + mRangeDirections = new int[] {0, 0, 0, 0}; - mRangeDirections[0] = ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getRangeDirection(0); - mRangeDirections[1] = ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getRangeDirection(1); - mRangeDirections[2] = ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getRangeDirection(2); - mRangeDirections[3] = ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getRangeDirection(3); + mRangeDirections[0] = + ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getRangeDirection(0); + mRangeDirections[1] = + ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getRangeDirection(1); + mRangeDirections[2] = + ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getRangeDirection(2); + mRangeDirections[3] = + ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getRangeDirection(3); - mTargetDirections[0] = ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot1Direction(0); - mTargetDirections[1] = ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot2Direction(0); - mTargetDirections[2] = ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot3Direction(0); - mTargetDirections[3] = ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot1Direction(1); - mTargetDirections[4] = ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot2Direction(1); - mTargetDirections[5] = ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot3Direction(1); - mTargetDirections[6] = ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot1Direction(2); - mTargetDirections[7] = ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot2Direction(2); - mTargetDirections[8] = ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot3Direction(2); - mTargetDirections[9] = ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot1Direction(3); - mTargetDirections[10] = ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot2Direction(3); - mTargetDirections[11] = ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot3Direction(3); + mTargetDirections[0] = + ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot1Direction(0); + mTargetDirections[1] = + ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot2Direction(0); + mTargetDirections[2] = + ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot3Direction(0); + mTargetDirections[3] = + ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot1Direction(1); + mTargetDirections[4] = + ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot2Direction(1); + mTargetDirections[5] = + ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot3Direction(1); + mTargetDirections[6] = + ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot1Direction(2); + mTargetDirections[7] = + ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot2Direction(2); + mTargetDirections[8] = + ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot3Direction(2); + mTargetDirections[9] = + ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot1Direction(3); + mTargetDirections[10] = + ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot2Direction(3); + mTargetDirections[11] = + ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot3Direction(3); - mTargetInOut = 0; - mTargetInOut |= ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot1InOut(0) ? 1 << 0 : 0; - mTargetInOut |= ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot2InOut(0) ? 1 << 1 : 0; - mTargetInOut |= ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot3InOut(0) ? 1 << 2 : 0; - mTargetInOut |= ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot1InOut(1) ? 1 << 3 : 0; - mTargetInOut |= ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot2InOut(1) ? 1 << 4 : 0; - mTargetInOut |= ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot3InOut(1) ? 1 << 5 : 0; - mTargetInOut |= ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot1InOut(2) ? 1 << 6 : 0; - mTargetInOut |= ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot2InOut(2) ? 1 << 7 : 0; - mTargetInOut |= ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot3InOut(2) ? 1 << 8 : 0; - mTargetInOut |= ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot1InOut(3) ? 1 << 9 : 0; - mTargetInOut |= ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot2InOut(3) ? 1 << 10 : 0; - mTargetInOut |= ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot3InOut(3) ? 1 << 11 : 0; + mTargetInOut = 0; + mTargetInOut |= ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot1InOut(0) + ? 1 << 0 + : 0; + mTargetInOut |= ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot2InOut(0) + ? 1 << 1 + : 0; + mTargetInOut |= ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot3InOut(0) + ? 1 << 2 + : 0; + mTargetInOut |= ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot1InOut(1) + ? 1 << 3 + : 0; + mTargetInOut |= ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot2InOut(1) + ? 1 << 4 + : 0; + mTargetInOut |= ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot3InOut(1) + ? 1 << 5 + : 0; + mTargetInOut |= ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot1InOut(2) + ? 1 << 6 + : 0; + mTargetInOut |= ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot2InOut(2) + ? 1 << 7 + : 0; + mTargetInOut |= ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot3InOut(2) + ? 1 << 8 + : 0; + mTargetInOut |= ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot1InOut(3) + ? 1 << 9 + : 0; + mTargetInOut |= ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot2InOut(3) + ? 1 << 10 + : 0; + mTargetInOut |= ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getSlot3InOut(3) + ? 1 << 11 + : 0; - mTargetEnergy = 0; - mTargetEnergy |= ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getRangeEnergy(0) ? 1 << 0 : 0; - mTargetEnergy |= ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getRangeEnergy(1) ? 1 << 1 : 0; - mTargetEnergy |= ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getRangeEnergy(2) ? 1 << 2 : 0; - mTargetEnergy |= ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getRangeEnergy(3) ? 1 << 3 : 0; + mTargetEnergy = 0; + mTargetEnergy |= + ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getRangeEnergy(0) + ? 1 << 0 + : 0; + mTargetEnergy |= + ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getRangeEnergy(1) + ? 1 << 1 + : 0; + mTargetEnergy |= + ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getRangeEnergy(2) + ? 1 << 2 + : 0; + mTargetEnergy |= + ((GT_MetaTileEntity_ElectricInventoryManager) mTileEntity.getMetaTileEntity()).getRangeEnergy(3) + ? 1 << 3 + : 0; - Iterator var2 = this.crafters.iterator(); - while (var2.hasNext()) { - ICrafting var1 = (ICrafting) var2.next(); - for (int i = 0; i < 12; i++) - var1.sendProgressBarUpdate(this, 100 + i, mTargetDirections[i]); - var1.sendProgressBarUpdate(this, 113, mTargetInOut); - var1.sendProgressBarUpdate(this, 114, mTargetEnergy); - for (int i = 0; i < 4; i++) - var1.sendProgressBarUpdate(this, 115 + i, mRangeDirections[i]); - } - } + Iterator var2 = this.crafters.iterator(); + while (var2.hasNext()) { + ICrafting var1 = (ICrafting) var2.next(); + for (int i = 0; i < 12; i++) var1.sendProgressBarUpdate(this, 100 + i, mTargetDirections[i]); + var1.sendProgressBarUpdate(this, 113, mTargetInOut); + var1.sendProgressBarUpdate(this, 114, mTargetEnergy); + for (int i = 0; i < 4; i++) var1.sendProgressBarUpdate(this, 115 + i, mRangeDirections[i]); + } + } - @Override - public void addCraftingToCrafters(ICrafting par1ICrafting) { - super.addCraftingToCrafters(par1ICrafting); - } + @Override + public void addCraftingToCrafters(ICrafting par1ICrafting) { + super.addCraftingToCrafters(par1ICrafting); + } - @Override - @SideOnly(Side.CLIENT) - public void updateProgressBar(int par1, int par2) { - super.updateProgressBar(par1, par2); - switch (par1) { - case 100 : - mTargetDirections[0] = par2; - break; - case 101 : - mTargetDirections[1] = par2; - break; - case 102 : - mTargetDirections[2] = par2; - break; - case 103 : - mTargetDirections[3] = par2; - break; - case 104 : - mTargetDirections[4] = par2; - break; - case 105 : - mTargetDirections[5] = par2; - break; - case 106 : - mTargetDirections[6] = par2; - break; - case 107 : - mTargetDirections[7] = par2; - break; - case 108 : - mTargetDirections[8] = par2; - break; - case 109 : - mTargetDirections[9] = par2; - break; - case 110 : - mTargetDirections[10] = par2; - break; - case 111 : - mTargetDirections[11] = par2; - break; + @Override + @SideOnly(Side.CLIENT) + public void updateProgressBar(int par1, int par2) { + super.updateProgressBar(par1, par2); + switch (par1) { + case 100: + mTargetDirections[0] = par2; + break; + case 101: + mTargetDirections[1] = par2; + break; + case 102: + mTargetDirections[2] = par2; + break; + case 103: + mTargetDirections[3] = par2; + break; + case 104: + mTargetDirections[4] = par2; + break; + case 105: + mTargetDirections[5] = par2; + break; + case 106: + mTargetDirections[6] = par2; + break; + case 107: + mTargetDirections[7] = par2; + break; + case 108: + mTargetDirections[8] = par2; + break; + case 109: + mTargetDirections[9] = par2; + break; + case 110: + mTargetDirections[10] = par2; + break; + case 111: + mTargetDirections[11] = par2; + break; - case 113 : - mTargetInOut = par2; - break; - case 114 : - mTargetEnergy = par2; - break; - case 115 : - mRangeDirections[0] = par2; - break; - case 116 : - mRangeDirections[1] = par2; - break; - case 117 : - mRangeDirections[2] = par2; - break; - case 118 : - mRangeDirections[3] = par2; - break; - } - } + case 113: + mTargetInOut = par2; + break; + case 114: + mTargetEnergy = par2; + break; + case 115: + mRangeDirections[0] = par2; + break; + case 116: + mRangeDirections[1] = par2; + break; + case 117: + mRangeDirections[2] = par2; + break; + case 118: + mRangeDirections[3] = par2; + break; + } + } - public int getSlotCount() { - return 3; - } + public int getSlotCount() { + return 3; + } - public int getShiftClickSlotCount() { - return 3; - } + public int getShiftClickSlotCount() { + return 3; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/automation/GT_GUIContainer_ElectricAutoWorkbench.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/automation/GT_GUIContainer_ElectricAutoWorkbench.java index 90f8380d14..6be7eb042e 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/automation/GT_GUIContainer_ElectricAutoWorkbench.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/automation/GT_GUIContainer_ElectricAutoWorkbench.java @@ -1,62 +1,66 @@ package gtPlusPlus.xmod.gregtech.api.gui.automation; -import java.util.ArrayList; -import java.util.List; - import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.xmod.gregtech.api.gui.basic.GT_Container_CropHarvestor; +import java.util.ArrayList; +import java.util.List; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.entity.player.InventoryPlayer; public class GT_GUIContainer_ElectricAutoWorkbench extends GT_GUIContainerMetaTile_Machine { - - private static final String[] mModeText = new String[] {"Normal Crafting Table", "???", "1x1", "2x2", "3x3", "Unifier", "Dust", "???", "Hammer?", "Circle"}; - + + private static final String[] mModeText = new String[] { + "Normal Crafting Table", "???", "1x1", "2x2", "3x3", "Unifier", "Dust", "???", "Hammer?", "Circle" + }; + public GT_GUIContainer_ElectricAutoWorkbench(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { - super(new GT_Container_ElectricAutoWorkbench(aInventoryPlayer, aTileEntity), CORE.RES_PATH_GUI + "ElectricAutoWorkbench.png"); + super( + new GT_Container_ElectricAutoWorkbench(aInventoryPlayer, aTileEntity), + CORE.RES_PATH_GUI + "ElectricAutoWorkbench.png"); } - + @Override protected void drawGuiContainerForegroundLayer(int par1, int par2) { - drawTooltip(par1, par2); + drawTooltip(par1, par2); } @Override protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { - super.drawGuiContainerBackgroundLayer(par1, par2, par3); + super.drawGuiContainerBackgroundLayer(par1, par2, par3); int x = (width - xSize) / 2; int y = (height - ySize) / 2; drawTexturedModalRect(x, y, 0, 0, xSize, ySize); - - if (mContainer != null) { - int tMode = ((GT_Container_ElectricAutoWorkbench)mContainer).mMode; - if (tMode != 0) drawTexturedModalRect(x + 120, y + 40, tMode*18, 166, 18, 18); - tMode = ((GT_Container_ElectricAutoWorkbench)mContainer).mThroughPut; - drawTexturedModalRect(x + 120, y + 4, tMode*18, 184, 18, 18); - } + + if (mContainer != null) { + int tMode = ((GT_Container_ElectricAutoWorkbench) mContainer).mMode; + if (tMode != 0) drawTexturedModalRect(x + 120, y + 40, tMode * 18, 166, 18, 18); + tMode = ((GT_Container_ElectricAutoWorkbench) mContainer).mThroughPut; + drawTexturedModalRect(x + 120, y + 4, tMode * 18, 184, 18, 18); + } + } + + private void drawTooltip(final int x2, final int y2) { + final int xStart = (this.width - this.xSize) / 2; + final int yStart = (this.height - this.ySize) / 2; + final int x3 = x2 - xStart; + final int y3 = y2 - yStart + 5; + List<String> list = new ArrayList<>(); + String[] mModeText = new String[] { + "Normal Crafting Table", "???", "1x1", "2x2", "3x3", "Unifier", "Dust", "???", "Hammer?", "Circle" + }; + if (y3 >= 45 && y3 <= 62) { + if (x3 >= 120 && x3 <= 137) { + list.add("Mode: " + mModeText[((GT_Container_ElectricAutoWorkbench) mContainer).mMode]); + /*switch (((GT_Container_ElectricAutoWorkbench) mContainer).mMode) { + case 0: + list.add("Mode: "); + }*/ + } + } + if (!list.isEmpty()) { + drawHoveringText(list, x3, y3, fontRendererObj); + RenderHelper.enableGUIStandardItemLighting(); + } } - - private void drawTooltip(final int x2, final int y2) { - final int xStart = (this.width - this.xSize) / 2; - final int yStart = (this.height - this.ySize) / 2; - final int x3 = x2 - xStart; - final int y3 = y2 - yStart + 5; - List<String> list = new ArrayList<>(); - String[] mModeText = new String[] {"Normal Crafting Table", "???", "1x1", "2x2", "3x3", "Unifier", "Dust", "???", "Hammer?", "Circle"}; - if (y3 >= 45 && y3 <= 62) { - if (x3 >= 120 && x3 <= 137) { - list.add("Mode: "+mModeText[((GT_Container_ElectricAutoWorkbench) mContainer).mMode]); - /*switch (((GT_Container_ElectricAutoWorkbench) mContainer).mMode) { - case 0: - list.add("Mode: "); - }*/ - } - } - if (!list.isEmpty()) { - drawHoveringText(list, x3, y3, fontRendererObj); - RenderHelper.enableGUIStandardItemLighting(); - } - } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/automation/GT_GUIContainer_ElectricInventoryManager.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/automation/GT_GUIContainer_ElectricInventoryManager.java index cf57d3faf1..77357056ba 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/automation/GT_GUIContainer_ElectricInventoryManager.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/automation/GT_GUIContainer_ElectricInventoryManager.java @@ -6,53 +6,197 @@ import gtPlusPlus.core.lib.CORE; import net.minecraft.entity.player.InventoryPlayer; public class GT_GUIContainer_ElectricInventoryManager extends GT_GUIContainerMetaTile_Machine { - + public GT_GUIContainer_ElectricInventoryManager(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { - super(new GT_Container_ElectricInventoryManager(aInventoryPlayer, aTileEntity), CORE.RES_PATH_GUI + "InventoryManager.png"); + super( + new GT_Container_ElectricInventoryManager(aInventoryPlayer, aTileEntity), + CORE.RES_PATH_GUI + "InventoryManager.png"); } - + @Override - protected void drawGuiContainerForegroundLayer(int par1, int par2) { - - } + protected void drawGuiContainerForegroundLayer(int par1, int par2) {} @Override protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { - super.drawGuiContainerBackgroundLayer(par1, par2, par3); + super.drawGuiContainerBackgroundLayer(par1, par2, par3); int x = (width - xSize) / 2; int y = (height - ySize) / 2; drawTexturedModalRect(x, y, 0, 0, xSize, ySize); - + if (mContainer != null) { - drawTexturedModalRect(x + 4, y + 4, ((GT_Container_ElectricInventoryManager)mContainer).mRangeDirections[0]*18, 202, 18, 54); - drawTexturedModalRect(x + 60, y + 4, ((GT_Container_ElectricInventoryManager)mContainer).mRangeDirections[1]*18, 202, 18, 54); - drawTexturedModalRect(x + 79, y + 4, ((GT_Container_ElectricInventoryManager)mContainer).mRangeDirections[2]*18, 202, 18, 54); - drawTexturedModalRect(x + 135, y + 4, ((GT_Container_ElectricInventoryManager)mContainer).mRangeDirections[3]*18, 202, 18, 54); - - drawTexturedModalRect(x + 23, y + 59, ((GT_Container_ElectricInventoryManager)mContainer).mRangeDirections[0]*18+126, 166, 18, 18); - drawTexturedModalRect(x + 41, y + 59, ((GT_Container_ElectricInventoryManager)mContainer).mRangeDirections[1]*18+126, 166, 18, 18); - drawTexturedModalRect(x + 98, y + 59, ((GT_Container_ElectricInventoryManager)mContainer).mRangeDirections[2]*18+126, 166, 18, 18); - drawTexturedModalRect(x + 116, y + 59, ((GT_Container_ElectricInventoryManager)mContainer).mRangeDirections[3]*18+126, 166, 18, 18); - - drawTexturedModalRect(x + 4, y + 59, 108, (((GT_Container_ElectricInventoryManager)mContainer).mTargetEnergy & 1)!=0?184:166, 18, 18); - drawTexturedModalRect(x + 60, y + 59, 108, (((GT_Container_ElectricInventoryManager)mContainer).mTargetEnergy & 2)!=0?184:166, 18, 18); - drawTexturedModalRect(x + 79, y + 59, 108, (((GT_Container_ElectricInventoryManager)mContainer).mTargetEnergy & 4)!=0?184:166, 18, 18); - drawTexturedModalRect(x + 135, y + 59, 108, (((GT_Container_ElectricInventoryManager)mContainer).mTargetEnergy & 8)!=0?184:166, 18, 18); - - int i = -1; - - drawTexturedModalRect(x + 23, y + 4, ((GT_Container_ElectricInventoryManager)mContainer).mTargetDirections[++i]*18, (((GT_Container_ElectricInventoryManager)mContainer).mTargetInOut&(1<<i))!=0?184:166, 18, 18); - drawTexturedModalRect(x + 23, y + 22, ((GT_Container_ElectricInventoryManager)mContainer).mTargetDirections[++i]*18, (((GT_Container_ElectricInventoryManager)mContainer).mTargetInOut&(1<<i))!=0?184:166, 18, 18); - drawTexturedModalRect(x + 23, y + 40, ((GT_Container_ElectricInventoryManager)mContainer).mTargetDirections[++i]*18, (((GT_Container_ElectricInventoryManager)mContainer).mTargetInOut&(1<<i))!=0?184:166, 18, 18); - drawTexturedModalRect(x + 41, y + 4, ((GT_Container_ElectricInventoryManager)mContainer).mTargetDirections[++i]*18, (((GT_Container_ElectricInventoryManager)mContainer).mTargetInOut&(1<<i))!=0?184:166, 18, 18); - drawTexturedModalRect(x + 41, y + 22, ((GT_Container_ElectricInventoryManager)mContainer).mTargetDirections[++i]*18, (((GT_Container_ElectricInventoryManager)mContainer).mTargetInOut&(1<<i))!=0?184:166, 18, 18); - drawTexturedModalRect(x + 41, y + 40, ((GT_Container_ElectricInventoryManager)mContainer).mTargetDirections[++i]*18, (((GT_Container_ElectricInventoryManager)mContainer).mTargetInOut&(1<<i))!=0?184:166, 18, 18); - drawTexturedModalRect(x + 98, y + 4, ((GT_Container_ElectricInventoryManager)mContainer).mTargetDirections[++i]*18, (((GT_Container_ElectricInventoryManager)mContainer).mTargetInOut&(1<<i))!=0?184:166, 18, 18); - drawTexturedModalRect(x + 98, y + 22, ((GT_Container_ElectricInventoryManager)mContainer).mTargetDirections[++i]*18, (((GT_Container_ElectricInventoryManager)mContainer).mTargetInOut&(1<<i))!=0?184:166, 18, 18); - drawTexturedModalRect(x + 98, y + 40, ((GT_Container_ElectricInventoryManager)mContainer).mTargetDirections[++i]*18, (((GT_Container_ElectricInventoryManager)mContainer).mTargetInOut&(1<<i))!=0?184:166, 18, 18); - drawTexturedModalRect(x + 116, y + 4, ((GT_Container_ElectricInventoryManager)mContainer).mTargetDirections[++i]*18, (((GT_Container_ElectricInventoryManager)mContainer).mTargetInOut&(1<<i))!=0?184:166, 18, 18); - drawTexturedModalRect(x + 116, y + 22, ((GT_Container_ElectricInventoryManager)mContainer).mTargetDirections[++i]*18, (((GT_Container_ElectricInventoryManager)mContainer).mTargetInOut&(1<<i))!=0?184:166, 18, 18); - drawTexturedModalRect(x + 116, y + 40, ((GT_Container_ElectricInventoryManager)mContainer).mTargetDirections[++i]*18, (((GT_Container_ElectricInventoryManager)mContainer).mTargetInOut&(1<<i))!=0?184:166, 18, 18); + drawTexturedModalRect( + x + 4, + y + 4, + ((GT_Container_ElectricInventoryManager) mContainer).mRangeDirections[0] * 18, + 202, + 18, + 54); + drawTexturedModalRect( + x + 60, + y + 4, + ((GT_Container_ElectricInventoryManager) mContainer).mRangeDirections[1] * 18, + 202, + 18, + 54); + drawTexturedModalRect( + x + 79, + y + 4, + ((GT_Container_ElectricInventoryManager) mContainer).mRangeDirections[2] * 18, + 202, + 18, + 54); + drawTexturedModalRect( + x + 135, + y + 4, + ((GT_Container_ElectricInventoryManager) mContainer).mRangeDirections[3] * 18, + 202, + 18, + 54); + + drawTexturedModalRect( + x + 23, + y + 59, + ((GT_Container_ElectricInventoryManager) mContainer).mRangeDirections[0] * 18 + 126, + 166, + 18, + 18); + drawTexturedModalRect( + x + 41, + y + 59, + ((GT_Container_ElectricInventoryManager) mContainer).mRangeDirections[1] * 18 + 126, + 166, + 18, + 18); + drawTexturedModalRect( + x + 98, + y + 59, + ((GT_Container_ElectricInventoryManager) mContainer).mRangeDirections[2] * 18 + 126, + 166, + 18, + 18); + drawTexturedModalRect( + x + 116, + y + 59, + ((GT_Container_ElectricInventoryManager) mContainer).mRangeDirections[3] * 18 + 126, + 166, + 18, + 18); + + drawTexturedModalRect( + x + 4, + y + 59, + 108, + (((GT_Container_ElectricInventoryManager) mContainer).mTargetEnergy & 1) != 0 ? 184 : 166, + 18, + 18); + drawTexturedModalRect( + x + 60, + y + 59, + 108, + (((GT_Container_ElectricInventoryManager) mContainer).mTargetEnergy & 2) != 0 ? 184 : 166, + 18, + 18); + drawTexturedModalRect( + x + 79, + y + 59, + 108, + (((GT_Container_ElectricInventoryManager) mContainer).mTargetEnergy & 4) != 0 ? 184 : 166, + 18, + 18); + drawTexturedModalRect( + x + 135, + y + 59, + 108, + (((GT_Container_ElectricInventoryManager) mContainer).mTargetEnergy & 8) != 0 ? 184 : 166, + 18, + 18); + + int i = -1; + + drawTexturedModalRect( + x + 23, + y + 4, + ((GT_Container_ElectricInventoryManager) mContainer).mTargetDirections[++i] * 18, + (((GT_Container_ElectricInventoryManager) mContainer).mTargetInOut & (1 << i)) != 0 ? 184 : 166, + 18, + 18); + drawTexturedModalRect( + x + 23, + y + 22, + ((GT_Container_ElectricInventoryManager) mContainer).mTargetDirections[++i] * 18, + (((GT_Container_ElectricInventoryManager) mContainer).mTargetInOut & (1 << i)) != 0 ? 184 : 166, + 18, + 18); + drawTexturedModalRect( + x + 23, + y + 40, + ((GT_Container_ElectricInventoryManager) mContainer).mTargetDirections[++i] * 18, + (((GT_Container_ElectricInventoryManager) mContainer).mTargetInOut & (1 << i)) != 0 ? 184 : 166, + 18, + 18); + drawTexturedModalRect( + x + 41, + y + 4, + ((GT_Container_ElectricInventoryManager) mContainer).mTargetDirections[++i] * 18, + (((GT_Container_ElectricInventoryManager) mContainer).mTargetInOut & (1 << i)) != 0 ? 184 : 166, + 18, + 18); + drawTexturedModalRect( + x + 41, + y + 22, + ((GT_Container_ElectricInventoryManager) mContainer).mTargetDirections[++i] * 18, + (((GT_Container_ElectricInventoryManager) mContainer).mTargetInOut & (1 << i)) != 0 ? 184 : 166, + 18, + 18); + drawTexturedModalRect( + x + 41, + y + 40, + ((GT_Container_ElectricInventoryManager) mContainer).mTargetDirections[++i] * 18, + (((GT_Container_ElectricInventoryManager) mContainer).mTargetInOut & (1 << i)) != 0 ? 184 : 166, + 18, + 18); + drawTexturedModalRect( + x + 98, + y + 4, + ((GT_Container_ElectricInventoryManager) mContainer).mTargetDirections[++i] * 18, + (((GT_Container_ElectricInventoryManager) mContainer).mTargetInOut & (1 << i)) != 0 ? 184 : 166, + 18, + 18); + drawTexturedModalRect( + x + 98, + y + 22, + ((GT_Container_ElectricInventoryManager) mContainer).mTargetDirections[++i] * 18, + (((GT_Container_ElectricInventoryManager) mContainer).mTargetInOut & (1 << i)) != 0 ? 184 : 166, + 18, + 18); + drawTexturedModalRect( + x + 98, + y + 40, + ((GT_Container_ElectricInventoryManager) mContainer).mTargetDirections[++i] * 18, + (((GT_Container_ElectricInventoryManager) mContainer).mTargetInOut & (1 << i)) != 0 ? 184 : 166, + 18, + 18); + drawTexturedModalRect( + x + 116, + y + 4, + ((GT_Container_ElectricInventoryManager) mContainer).mTargetDirections[++i] * 18, + (((GT_Container_ElectricInventoryManager) mContainer).mTargetInOut & (1 << i)) != 0 ? 184 : 166, + 18, + 18); + drawTexturedModalRect( + x + 116, + y + 22, + ((GT_Container_ElectricInventoryManager) mContainer).mTargetDirections[++i] * 18, + (((GT_Container_ElectricInventoryManager) mContainer).mTargetInOut & (1 << i)) != 0 ? 184 : 166, + 18, + 18); + drawTexturedModalRect( + x + 116, + y + 40, + ((GT_Container_ElectricInventoryManager) mContainer).mTargetDirections[++i] * 18, + (((GT_Container_ElectricInventoryManager) mContainer).mTargetInOut & (1 << i)) != 0 ? 184 : 166, + 18, + 18); } } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/basic/CONTAINER_PollutionCleaner.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/basic/CONTAINER_PollutionCleaner.java index e4dc7835cb..373ba8ae08 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/basic/CONTAINER_PollutionCleaner.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/basic/CONTAINER_PollutionCleaner.java @@ -1,22 +1,18 @@ package gtPlusPlus.xmod.gregtech.api.gui.basic; -import java.util.Iterator; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.ICrafting; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; - import gregtech.api.gui.*; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.slots.SlotPollutionScrubber; import gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic.GregtechMetaAtmosphericReconditioner; +import java.util.Iterator; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.ICrafting; +import net.minecraft.item.ItemStack; /** * NEVER INCLUDE THIS FILE IN YOUR MOD!!! @@ -25,82 +21,80 @@ import gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic.GregtechMetaA */ public class CONTAINER_PollutionCleaner extends GT_Container_BasicTank { - public boolean mFluidTransfer = false, mItemTransfer = false, mStuttering = false; - public int mReduction = 0; - - public CONTAINER_PollutionCleaner(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { - super(aInventoryPlayer, aTileEntity); - } - - @Override - public void addSlots(InventoryPlayer aInventoryPlayer) { - - int tStartIndex = ((GT_MetaTileEntity_BasicMachine) mTileEntity.getMetaTileEntity()).getInputSlot(); - int aTier = ((GT_MetaTileEntity_BasicMachine) mTileEntity.getMetaTileEntity()).mTier; - - - //Add 2 Item Slots - addSlotToContainer(new SlotPollutionScrubber(0, aTier, mTileEntity, tStartIndex++, 53, 25)); - addSlotToContainer(new SlotPollutionScrubber(1, aTier, mTileEntity, tStartIndex++, 107, 25)); - // Upgrade Slot - addSlotToContainer(new SlotPollutionScrubber(2, aTier, mTileEntity, tStartIndex++, 125, 63)); - - } - - @Override - public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { - Logger.INFO("Clicked on slot "+aSlotIndex); - return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); - } - - @Override - public void detectAndSendChanges() { - super.detectAndSendChanges(); - if (mTileEntity.isClientSide() || mTileEntity.getMetaTileEntity() == null) return; - - Logger.INFO("TEST"); - mReduction = ((GregtechMetaAtmosphericReconditioner) mTileEntity.getMetaTileEntity()).mPollutionReduction; - - Iterator var2 = this.crafters.iterator(); - while (var2.hasNext()) { - ICrafting var1 = (ICrafting) var2.next(); - var1.sendProgressBarUpdate(this, 105, mReduction); - } - } - - @Override - public void addCraftingToCrafters(ICrafting par1ICrafting) { - super.addCraftingToCrafters(par1ICrafting); - } - - @Override - @SideOnly(Side.CLIENT) - public void updateProgressBar(int par1, int par2) { - super.updateProgressBar(par1, par2); - switch (par1) { - case 105: - mReduction = (par2); - break; - } - } - - @Override - public int getSlotStartIndex() { - return 0; - } - - @Override - public int getShiftClickStartIndex() { - return 0; - } - - @Override - public int getSlotCount() { - return getShiftClickSlotCount(); - } - - @Override - public int getShiftClickSlotCount() { - return 3; - } + public boolean mFluidTransfer = false, mItemTransfer = false, mStuttering = false; + public int mReduction = 0; + + public CONTAINER_PollutionCleaner(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { + super(aInventoryPlayer, aTileEntity); + } + + @Override + public void addSlots(InventoryPlayer aInventoryPlayer) { + + int tStartIndex = ((GT_MetaTileEntity_BasicMachine) mTileEntity.getMetaTileEntity()).getInputSlot(); + int aTier = ((GT_MetaTileEntity_BasicMachine) mTileEntity.getMetaTileEntity()).mTier; + + // Add 2 Item Slots + addSlotToContainer(new SlotPollutionScrubber(0, aTier, mTileEntity, tStartIndex++, 53, 25)); + addSlotToContainer(new SlotPollutionScrubber(1, aTier, mTileEntity, tStartIndex++, 107, 25)); + // Upgrade Slot + addSlotToContainer(new SlotPollutionScrubber(2, aTier, mTileEntity, tStartIndex++, 125, 63)); + } + + @Override + public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { + Logger.INFO("Clicked on slot " + aSlotIndex); + return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + } + + @Override + public void detectAndSendChanges() { + super.detectAndSendChanges(); + if (mTileEntity.isClientSide() || mTileEntity.getMetaTileEntity() == null) return; + + Logger.INFO("TEST"); + mReduction = ((GregtechMetaAtmosphericReconditioner) mTileEntity.getMetaTileEntity()).mPollutionReduction; + + Iterator var2 = this.crafters.iterator(); + while (var2.hasNext()) { + ICrafting var1 = (ICrafting) var2.next(); + var1.sendProgressBarUpdate(this, 105, mReduction); + } + } + + @Override + public void addCraftingToCrafters(ICrafting par1ICrafting) { + super.addCraftingToCrafters(par1ICrafting); + } + + @Override + @SideOnly(Side.CLIENT) + public void updateProgressBar(int par1, int par2) { + super.updateProgressBar(par1, par2); + switch (par1) { + case 105: + mReduction = (par2); + break; + } + } + + @Override + public int getSlotStartIndex() { + return 0; + } + + @Override + public int getShiftClickStartIndex() { + return 0; + } + + @Override + public int getSlotCount() { + return getShiftClickSlotCount(); + } + + @Override + public int getShiftClickSlotCount() { + return 3; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/basic/GT_Container_CropHarvestor.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/basic/GT_Container_CropHarvestor.java index 9bca97de82..8380b2958f 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/basic/GT_Container_CropHarvestor.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/basic/GT_Container_CropHarvestor.java @@ -17,171 +17,163 @@ import net.minecraft.item.ItemStack; public class GT_Container_CropHarvestor extends GT_ContainerMetaTile_Machine { - public boolean mModeAlternative = false; - public int mWaterAmount = 0; - public int mWaterRealAmount = 0; - - public GT_Container_CropHarvestor(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { - super(aInventoryPlayer, aTileEntity); - } - - public void addSlots(InventoryPlayer aInventoryPlayer) { - - - int aSlot = 1; - - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 0, 48, 64, false, true, 1)); - addSlotToContainer(new SlotWeedEx(mTileEntity, aSlot++, 8, 14)); - addSlotToContainer(new SlotWeedEx(mTileEntity, aSlot++, 26, 14)); - addSlotToContainer(new SlotFertilizer(mTileEntity, aSlot++, 8, 32)); - addSlotToContainer(new SlotFertilizer(mTileEntity, aSlot++, 26, 32)); - addSlotToContainer(new SlotFertilizer(mTileEntity, aSlot++, 8, 50)); - addSlotToContainer(new SlotFertilizer(mTileEntity, aSlot++, 26, 50)); - - - addSlotToContainer(new SlotNoInput(mTileEntity, aSlot++, 61, 7)); - addSlotToContainer(new SlotNoInput(mTileEntity, aSlot++, 79, 7)); - addSlotToContainer(new SlotNoInput(mTileEntity, aSlot++, 97, 7)); - addSlotToContainer(new SlotNoInput(mTileEntity, aSlot++, 115, 7)); - addSlotToContainer(new SlotNoInput(mTileEntity, aSlot++, 133, 7)); - addSlotToContainer(new SlotNoInput(mTileEntity, aSlot++, 151, 7)); - - addSlotToContainer(new SlotNoInput(mTileEntity, aSlot++, 61, 25)); - addSlotToContainer(new SlotNoInput(mTileEntity, aSlot++, 79, 25)); - addSlotToContainer(new SlotNoInput(mTileEntity, aSlot++, 97, 25)); - addSlotToContainer(new SlotNoInput(mTileEntity, aSlot++, 115, 25)); - addSlotToContainer(new SlotNoInput(mTileEntity, aSlot++, 133, 25)); - addSlotToContainer(new SlotNoInput(mTileEntity, aSlot++, 151, 25)); - - addSlotToContainer(new SlotNoInput(mTileEntity, aSlot++, 61, 43)); - addSlotToContainer(new SlotNoInput(mTileEntity, aSlot++, 79, 43)); - addSlotToContainer(new SlotNoInput(mTileEntity, aSlot++, 97, 43)); - addSlotToContainer(new SlotNoInput(mTileEntity, aSlot++, 115, 43)); - addSlotToContainer(new SlotNoInput(mTileEntity, aSlot++, 133, 43)); - addSlotToContainer(new SlotNoInput(mTileEntity, aSlot++, 151, 43)); - - - } - - public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { - - GT_MetaTileEntity_CropHarvestor machine = (GT_MetaTileEntity_CropHarvestor) mTileEntity.getMetaTileEntity(); - - if (aSlotIndex == 0) { - machine.mModeAlternative = !machine.mModeAlternative; - return null; - } - - return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); - } - - @Override - public int getSlotCount() { - return 24; - } - - @Override - public int getSlotStartIndex() { - return 1; - } - - @Override - public int getShiftClickSlotCount() { - return 6; - } - - @Override - public void detectAndSendChanges() { - super.detectAndSendChanges(); - if (mTileEntity.isClientSide() || mTileEntity.getMetaTileEntity() == null) { - return; - } - - // GT_MetaTileEntity_Boiler.getCapacity() is used for both water and steam capacity. - int capacity = ((GT_MetaTileEntity_CropHarvestor) this.mTileEntity.getMetaTileEntity()).getCapacity(); - - mModeAlternative = ((GT_MetaTileEntity_CropHarvestor) mTileEntity.getMetaTileEntity()).mModeAlternative; - mWaterRealAmount = ((GT_MetaTileEntity_CropHarvestor) mTileEntity.getMetaTileEntity()).getFluidAmount(); - this.mWaterAmount = Math.min(54, Math.max(0, this.mWaterRealAmount * 54 / (capacity - 100))); - for (Object crafter : this.crafters) { - ICrafting var1 = (ICrafting) crafter; - var1.sendProgressBarUpdate(this, 102, mModeAlternative ? 1 : 0); - var1.sendProgressBarUpdate(this, 103, this.mWaterAmount); - var1.sendProgressBarUpdate(this, 104, this.mWaterRealAmount); - } - } - - @Override - public void addCraftingToCrafters(ICrafting par1ICrafting) { - super.addCraftingToCrafters(par1ICrafting); - } - - @Override - @SideOnly(Side.CLIENT) - public void updateProgressBar(int par1, int par2) { - super.updateProgressBar(par1, par2); - switch (par1) { - case 102: - mModeAlternative = (par2 != 0); - break; - case 103: - this.mWaterAmount = par2; - break; - case 104: - this.mWaterRealAmount = par2; - break; - } - } - - public static class SlotWeedEx extends Slot { - - public SlotWeedEx(final IInventory inventory, final int slot, final int x, final int y) { - super(inventory, slot, x, y); - - } - - @Override - public synchronized boolean isItemValid(final ItemStack itemstack) { - return isWeedEx(itemstack); - } - - @Override - public int getSlotStackLimit() { - return 1; - } - - private static boolean isWeedEx(ItemStack aStack) { - if (aStack != null && aStack.getItem() instanceof ItemIC2) { - if (aStack.getItem().getUnlocalizedName().equals("ic2.itemWeedEx")) { - return true; - } - } - return false; - } - } - - public class SlotFertilizer extends Slot { - - public SlotFertilizer(final IInventory inventory, final int slot, final int x, final int y) { - super(inventory, slot, x, y); - - } - - @Override - public synchronized boolean isItemValid(final ItemStack aStack) { - if (aStack != null && aStack.getItem() instanceof ItemIC2) { - if (aStack.getItem().getUnlocalizedName().equals("ic2.itemFertilizer")) { - return true; - } - } - return false; - } - - @Override - public int getSlotStackLimit() { - return 64; - } - - } - + public boolean mModeAlternative = false; + public int mWaterAmount = 0; + public int mWaterRealAmount = 0; + + public GT_Container_CropHarvestor(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { + super(aInventoryPlayer, aTileEntity); + } + + public void addSlots(InventoryPlayer aInventoryPlayer) { + + int aSlot = 1; + + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 0, 48, 64, false, true, 1)); + addSlotToContainer(new SlotWeedEx(mTileEntity, aSlot++, 8, 14)); + addSlotToContainer(new SlotWeedEx(mTileEntity, aSlot++, 26, 14)); + addSlotToContainer(new SlotFertilizer(mTileEntity, aSlot++, 8, 32)); + addSlotToContainer(new SlotFertilizer(mTileEntity, aSlot++, 26, 32)); + addSlotToContainer(new SlotFertilizer(mTileEntity, aSlot++, 8, 50)); + addSlotToContainer(new SlotFertilizer(mTileEntity, aSlot++, 26, 50)); + + addSlotToContainer(new SlotNoInput(mTileEntity, aSlot++, 61, 7)); + addSlotToContainer(new SlotNoInput(mTileEntity, aSlot++, 79, 7)); + addSlotToContainer(new SlotNoInput(mTileEntity, aSlot++, 97, 7)); + addSlotToContainer(new SlotNoInput(mTileEntity, aSlot++, 115, 7)); + addSlotToContainer(new SlotNoInput(mTileEntity, aSlot++, 133, 7)); + addSlotToContainer(new SlotNoInput(mTileEntity, aSlot++, 151, 7)); + + addSlotToContainer(new SlotNoInput(mTileEntity, aSlot++, 61, 25)); + addSlotToContainer(new SlotNoInput(mTileEntity, aSlot++, 79, 25)); + addSlotToContainer(new SlotNoInput(mTileEntity, aSlot++, 97, 25)); + addSlotToContainer(new SlotNoInput(mTileEntity, aSlot++, 115, 25)); + addSlotToContainer(new SlotNoInput(mTileEntity, aSlot++, 133, 25)); + addSlotToContainer(new SlotNoInput(mTileEntity, aSlot++, 151, 25)); + + addSlotToContainer(new SlotNoInput(mTileEntity, aSlot++, 61, 43)); + addSlotToContainer(new SlotNoInput(mTileEntity, aSlot++, 79, 43)); + addSlotToContainer(new SlotNoInput(mTileEntity, aSlot++, 97, 43)); + addSlotToContainer(new SlotNoInput(mTileEntity, aSlot++, 115, 43)); + addSlotToContainer(new SlotNoInput(mTileEntity, aSlot++, 133, 43)); + addSlotToContainer(new SlotNoInput(mTileEntity, aSlot++, 151, 43)); + } + + public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { + + GT_MetaTileEntity_CropHarvestor machine = (GT_MetaTileEntity_CropHarvestor) mTileEntity.getMetaTileEntity(); + + if (aSlotIndex == 0) { + machine.mModeAlternative = !machine.mModeAlternative; + return null; + } + + return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + } + + @Override + public int getSlotCount() { + return 24; + } + + @Override + public int getSlotStartIndex() { + return 1; + } + + @Override + public int getShiftClickSlotCount() { + return 6; + } + + @Override + public void detectAndSendChanges() { + super.detectAndSendChanges(); + if (mTileEntity.isClientSide() || mTileEntity.getMetaTileEntity() == null) { + return; + } + + // GT_MetaTileEntity_Boiler.getCapacity() is used for both water and steam capacity. + int capacity = ((GT_MetaTileEntity_CropHarvestor) this.mTileEntity.getMetaTileEntity()).getCapacity(); + + mModeAlternative = ((GT_MetaTileEntity_CropHarvestor) mTileEntity.getMetaTileEntity()).mModeAlternative; + mWaterRealAmount = ((GT_MetaTileEntity_CropHarvestor) mTileEntity.getMetaTileEntity()).getFluidAmount(); + this.mWaterAmount = Math.min(54, Math.max(0, this.mWaterRealAmount * 54 / (capacity - 100))); + for (Object crafter : this.crafters) { + ICrafting var1 = (ICrafting) crafter; + var1.sendProgressBarUpdate(this, 102, mModeAlternative ? 1 : 0); + var1.sendProgressBarUpdate(this, 103, this.mWaterAmount); + var1.sendProgressBarUpdate(this, 104, this.mWaterRealAmount); + } + } + + @Override + public void addCraftingToCrafters(ICrafting par1ICrafting) { + super.addCraftingToCrafters(par1ICrafting); + } + + @Override + @SideOnly(Side.CLIENT) + public void updateProgressBar(int par1, int par2) { + super.updateProgressBar(par1, par2); + switch (par1) { + case 102: + mModeAlternative = (par2 != 0); + break; + case 103: + this.mWaterAmount = par2; + break; + case 104: + this.mWaterRealAmount = par2; + break; + } + } + + public static class SlotWeedEx extends Slot { + + public SlotWeedEx(final IInventory inventory, final int slot, final int x, final int y) { + super(inventory, slot, x, y); + } + + @Override + public synchronized boolean isItemValid(final ItemStack itemstack) { + return isWeedEx(itemstack); + } + + @Override + public int getSlotStackLimit() { + return 1; + } + + private static boolean isWeedEx(ItemStack aStack) { + if (aStack != null && aStack.getItem() instanceof ItemIC2) { + if (aStack.getItem().getUnlocalizedName().equals("ic2.itemWeedEx")) { + return true; + } + } + return false; + } + } + + public class SlotFertilizer extends Slot { + + public SlotFertilizer(final IInventory inventory, final int slot, final int x, final int y) { + super(inventory, slot, x, y); + } + + @Override + public synchronized boolean isItemValid(final ItemStack aStack) { + if (aStack != null && aStack.getItem() instanceof ItemIC2) { + if (aStack.getItem().getUnlocalizedName().equals("ic2.itemFertilizer")) { + return true; + } + } + return false; + } + + @Override + public int getSlotStackLimit() { + return 64; + } + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/basic/GT_GUIContainer_CropHarvestor.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/basic/GT_GUIContainer_CropHarvestor.java index 504ae61b4a..1b04ab15fe 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/basic/GT_GUIContainer_CropHarvestor.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/basic/GT_GUIContainer_CropHarvestor.java @@ -1,75 +1,77 @@ package gtPlusPlus.xmod.gregtech.api.gui.basic; -import java.util.ArrayList; -import java.util.List; - import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.common.gui.GT_Container_Boiler; import gtPlusPlus.core.lib.CORE; +import java.util.ArrayList; +import java.util.List; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.entity.player.InventoryPlayer; public class GT_GUIContainer_CropHarvestor extends GT_GUIContainerMetaTile_Machine { - private final String mLocalName; - - public GT_GUIContainer_CropHarvestor(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aLocalName) { - super(new GT_Container_CropHarvestor(aInventoryPlayer, aTileEntity), CORE.RES_PATH_GUI + "CropHarvestor.png"); - mLocalName = aLocalName; - } - - @Override - protected void drawGuiContainerForegroundLayer(int par1, int par2) { - drawTooltip(par1, par2); - //fontRendererObj.drawString("Crop Manager ("+this.mContainer.mTileEntity.getInputVoltage()+"v)", 8, 4, 4210752); - //fontRendererObj.drawString(mLocalName, 70, 69, 4210752); - } + private final String mLocalName; - @Override - protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { - super.drawGuiContainerBackgroundLayer(par1, par2, par3); - int x = (width - xSize) / 2; - int y = (height - ySize) / 2; - drawTexturedModalRect(x, y, 0, 0, xSize, ySize); + public GT_GUIContainer_CropHarvestor( + InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aLocalName) { + super(new GT_Container_CropHarvestor(aInventoryPlayer, aTileEntity), CORE.RES_PATH_GUI + "CropHarvestor.png"); + mLocalName = aLocalName; + } - if (((GT_Container_CropHarvestor) mContainer).mModeAlternative) { - drawTexturedModalRect(x + 48, y + 64, 177, 37, 16, 16); - } + @Override + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + drawTooltip(par1, par2); + // fontRendererObj.drawString("Crop Manager ("+this.mContainer.mTileEntity.getInputVoltage()+"v)", 8, 4, + // 4210752); + // fontRendererObj.drawString(mLocalName, 70, 69, 4210752); + } - int tScale = ((GT_Container_CropHarvestor) this.mContainer).mWaterAmount; - if (tScale > 0) { - drawTexturedModalRect(x + 47, y + 61 - tScale, 204, 54 - tScale, 10, tScale); - }; + @Override + protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { + super.drawGuiContainerBackgroundLayer(par1, par2, par3); + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + drawTexturedModalRect(x, y, 0, 0, xSize, ySize); - } + if (((GT_Container_CropHarvestor) mContainer).mModeAlternative) { + drawTexturedModalRect(x + 48, y + 64, 177, 37, 16, 16); + } - private void drawTooltip(int x2, int y2) { - int xStart = (width - xSize) / 2; - int yStart = (height - ySize) / 2; - int x = x2 - xStart; - int y = y2 - yStart + 5; - List<String> list = new ArrayList<>(); - if (y >= 68 && y <= 85) { - if (x >= 47 && x <= 64) { - if (((GT_Container_CropHarvestor) mContainer).mModeAlternative) { - list.add("Disable Hydration/Fertilizing/Weed-EX"); - } - else { - list.add("Enable Hydration/Fertilizing/Weed-EX"); - } - } - } - if (y >= 12 && y <= 66) { - if (x >= 47 && x <= 56) { - int aWater = ((GT_Container_CropHarvestor) mContainer).mWaterRealAmount; - list.add("Water: "+aWater+"L / "+((GT_Container_CropHarvestor) mContainer).mTileEntity.getMetaTileEntity().getCapacity()+"L"); - } - } - if (!list.isEmpty()) { - drawHoveringText(list, x, y, fontRendererObj); - RenderHelper.enableGUIStandardItemLighting(); - } - } + int tScale = ((GT_Container_CropHarvestor) this.mContainer).mWaterAmount; + if (tScale > 0) { + drawTexturedModalRect(x + 47, y + 61 - tScale, 204, 54 - tScale, 10, tScale); + } + ; + } + private void drawTooltip(int x2, int y2) { + int xStart = (width - xSize) / 2; + int yStart = (height - ySize) / 2; + int x = x2 - xStart; + int y = y2 - yStart + 5; + List<String> list = new ArrayList<>(); + if (y >= 68 && y <= 85) { + if (x >= 47 && x <= 64) { + if (((GT_Container_CropHarvestor) mContainer).mModeAlternative) { + list.add("Disable Hydration/Fertilizing/Weed-EX"); + } else { + list.add("Enable Hydration/Fertilizing/Weed-EX"); + } + } + } + if (y >= 12 && y <= 66) { + if (x >= 47 && x <= 56) { + int aWater = ((GT_Container_CropHarvestor) mContainer).mWaterRealAmount; + list.add("Water: " + aWater + "L / " + + ((GT_Container_CropHarvestor) mContainer) + .mTileEntity + .getMetaTileEntity() + .getCapacity() + "L"); + } + } + if (!list.isEmpty()) { + drawHoveringText(list, x, y, fontRendererObj); + RenderHelper.enableGUIStandardItemLighting(); + } + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/basic/GUI_PollutionCleaner.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/basic/GUI_PollutionCleaner.java index 96e8e362ef..3e4280f650 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/basic/GUI_PollutionCleaner.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/basic/GUI_PollutionCleaner.java @@ -1,67 +1,76 @@ package gtPlusPlus.xmod.gregtech.api.gui.basic; -import java.util.ArrayList; -import java.util.List; - import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gtPlusPlus.core.lib.CORE; +import java.util.ArrayList; +import java.util.List; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.entity.player.InventoryPlayer; public class GUI_PollutionCleaner extends GT_GUIContainerMetaTile_Machine { - public final String mName; - public final String mNEI; - public final byte mProgressBarDirection; - public final byte mProgressBarAmount; - public int mReduction; + public final String mName; + public final String mNEI; + public final byte mProgressBarDirection; + public final byte mProgressBarAmount; + public int mReduction; - public GUI_PollutionCleaner(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity, - final String aName, final String aTextureFile) { - this(aInventoryPlayer, aTileEntity, aName, aTextureFile, "PollutionCleaner",(byte) 0, (byte) 1); - } + public GUI_PollutionCleaner( + final InventoryPlayer aInventoryPlayer, + final IGregTechTileEntity aTileEntity, + final String aName, + final String aTextureFile) { + this(aInventoryPlayer, aTileEntity, aName, aTextureFile, "PollutionCleaner", (byte) 0, (byte) 1); + } - public GUI_PollutionCleaner(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity, - final String aName, final String aTextureFile, final String aNEI, final byte aProgressBarDirection, - final byte aProgressBarAmount) { - super(new CONTAINER_PollutionCleaner(aInventoryPlayer, aTileEntity), CORE.RES_PATH_GUI + "PollutionCleaner.png"); - this.mProgressBarDirection = aProgressBarDirection; - this.mProgressBarAmount = (byte) Math.max(1, aProgressBarAmount); - this.mName = aName; - this.mNEI = aNEI; - } + public GUI_PollutionCleaner( + final InventoryPlayer aInventoryPlayer, + final IGregTechTileEntity aTileEntity, + final String aName, + final String aTextureFile, + final String aNEI, + final byte aProgressBarDirection, + final byte aProgressBarAmount) { + super( + new CONTAINER_PollutionCleaner(aInventoryPlayer, aTileEntity), + CORE.RES_PATH_GUI + "PollutionCleaner.png"); + this.mProgressBarDirection = aProgressBarDirection; + this.mProgressBarAmount = (byte) Math.max(1, aProgressBarAmount); + this.mName = aName; + this.mNEI = aNEI; + } - @Override - protected void drawGuiContainerForegroundLayer(final int par1, final int par2) { - this.fontRendererObj.drawString(this.mName, 8, 4, 4210752); - this.drawTooltip(par1, par2); - } + @Override + protected void drawGuiContainerForegroundLayer(final int par1, final int par2) { + this.fontRendererObj.drawString(this.mName, 8, 4, 4210752); + this.drawTooltip(par1, par2); + } - private void drawTooltip(final int x2, final int y2) { - final int xStart = (this.width - this.xSize) / 2; - final int yStart = (this.height - this.ySize) / 2; - final int x3 = x2 - xStart; - final int y3 = y2 - yStart + 5; - final List<String> list = new ArrayList<String>(); - if (y3 >= 67 && y3 <= 84) { - if (x3 >= 77 && x3 <= 95) { - //Do Dumb shit - CONTAINER_PollutionCleaner aContainerCast = (CONTAINER_PollutionCleaner) this.mContainer; - mReduction = aContainerCast.mReduction; - list.add("Reduction: "+mReduction+"/s"); - } - } - if (!list.isEmpty()) { - this.drawHoveringText(list, x3, y3, this.fontRendererObj); - RenderHelper.enableGUIStandardItemLighting(); - } - } + private void drawTooltip(final int x2, final int y2) { + final int xStart = (this.width - this.xSize) / 2; + final int yStart = (this.height - this.ySize) / 2; + final int x3 = x2 - xStart; + final int y3 = y2 - yStart + 5; + final List<String> list = new ArrayList<String>(); + if (y3 >= 67 && y3 <= 84) { + if (x3 >= 77 && x3 <= 95) { + // Do Dumb shit + CONTAINER_PollutionCleaner aContainerCast = (CONTAINER_PollutionCleaner) this.mContainer; + mReduction = aContainerCast.mReduction; + list.add("Reduction: " + mReduction + "/s"); + } + } + if (!list.isEmpty()) { + this.drawHoveringText(list, x3, y3, this.fontRendererObj); + RenderHelper.enableGUIStandardItemLighting(); + } + } - @Override - protected void drawGuiContainerBackgroundLayer(final float par1, final int par2, final int par3) { - super.drawGuiContainerBackgroundLayer(par1, par2, par3); - final int x = (this.width - this.xSize) / 2; - final int y = (this.height - this.ySize) / 2; - this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); - } -}
\ No newline at end of file + @Override + protected void drawGuiContainerBackgroundLayer(final float par1, final int par2, final int par3) { + super.drawGuiContainerBackgroundLayer(par1, par2, par3); + final int x = (this.width - this.xSize) / 2; + final int y = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/computer/GT_Container_ComputerCube.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/computer/GT_Container_ComputerCube.java index 8abe7bff66..5aa0da1c8c 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/computer/GT_Container_ComputerCube.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/computer/GT_Container_ComputerCube.java @@ -1,7 +1,5 @@ package gtPlusPlus.xmod.gregtech.api.gui.computer; -import java.util.Iterator; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.gui.*; @@ -12,398 +10,398 @@ import gtPlusPlus.core.slots.SlotDataStick; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.xmod.gregtech.common.tileentities.misc.GT_TileEntity_ComputerCube; +import java.util.Iterator; import net.minecraft.entity.player.*; import net.minecraft.inventory.*; import net.minecraft.item.ItemStack; public class GT_Container_ComputerCube extends GT_ContainerMetaTile_Machine { - public long mEUOut; - public int mEUOut1; - public int mEUOut2; + public long mEUOut; + public int mEUOut1; + public int mEUOut2; - public int mHeat; + public int mHeat; - public int mMaxHeat; + public int mMaxHeat; - public int mHEM; + public int mHEM; - public int mExplosionStrength; + public int mExplosionStrength; - public long mEU; - public int mEU1; - public int mEU2; - - public long mStoredEU; - public int mStoredEU1; - public int mStoredEU2; - public long mMaxStoredEU; - public int mMaxStoredEU1; - public int mMaxStoredEU2; + public long mEU; + public int mEU1; + public int mEU2; - public int mProgress; + public long mStoredEU; + public int mStoredEU1; + public int mStoredEU2; + public long mMaxStoredEU; + public int mMaxStoredEU1; + public int mMaxStoredEU2; - public int mID; + public int mProgress; - public GT_Container_ComputerCube(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, int aID) { - super(aInventoryPlayer, aTileEntity); - Logger.INFO("1 Container Mode: "+aID); - Logger.INFO("2 Container Mode: "+getMode()); - mID = getMode(); - Logger.INFO("3 Container Mode: "+getMode()); - // addSlotsComputer(aInventoryPlayer); - detectAndSendChanges(); - } + public int mID; - public void addSlots(InventoryPlayer aInventoryPlayer) { - addSlotsComputer(aInventoryPlayer); - } + public GT_Container_ComputerCube(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, int aID) { + super(aInventoryPlayer, aTileEntity); + Logger.INFO("1 Container Mode: " + aID); + Logger.INFO("2 Container Mode: " + getMode()); + mID = getMode(); + Logger.INFO("3 Container Mode: " + getMode()); + // addSlotsComputer(aInventoryPlayer); + detectAndSendChanges(); + } - private int getMode() { - return ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mMode; - } + public void addSlots(InventoryPlayer aInventoryPlayer) { + addSlotsComputer(aInventoryPlayer); + } - public void addSlotsComputer(InventoryPlayer aInventoryPlayer) { - int y; - mID = ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mMode; - Logger.INFO(""+(Utils.isClient() ? "Client" : "Server")+" Mode: " + mID); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 58, 156 + ((this.mID == 5) ? 50 : 0), 4, false, false, 1)); - switch (this.mID) { - case 1 : - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 58, 156, 86, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 58, 156, 70, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 58, 156, 54, false, false, 1)); - for (y = 0; y < 6; y++) { - for (int x = 0; x < 9; x++) - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, x + y * 9, 5 + x * 16, 5 + y * 16, false, false, 64)); - } - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 113, 153, 28, false, false, 64)); - break; - case 2 : - addSlotToContainer(new SlotDataStick(this.mTileEntity, 54, 8, 28)); - addSlotToContainer(new Slot(this.mTileEntity, 55, 26, 28)); - addSlotToContainer(new GT_Slot_Output(this.mTileEntity, 56, 134, 28)); - addSlotToContainer(new GT_Slot_Output(this.mTileEntity, 57, 152, 28)); - break; - case 3 : - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 58, 88, 65, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 58, 104, 65, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 59, 122, 35, false, false, 64)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 60, 92, 5, false, false, 64)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 61, 122, 5, false, false, 64)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 62, 152, 35, false, false, 64)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 63, 122, 65, false, false, 64)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 64, 92, 35, false, false, 64)); - break; - case 4 : - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 58, 88, 65, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 58, 104, 65, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 59, 122, 5, false, false, 64)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 60, 122, 65, false, false, 64)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 61, 152, 35, false, false, 64)); - break; - case 5 : - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 58, 190, 146, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 58, 206, 146, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 59, 206, 38, false, false, 64)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 60, 206, 56, false, false, 64)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 61, 206, 74, false, false, 64)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 62, 206, 92, false, false, 64)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 63, 206, 110, false, false, 64)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 64, 153, 7, false, false, 64)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 65, 169, 7, false, false, 64)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 66, 185, 7, false, false, 64)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 67, 153, 23, false, false, 64)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 68, 169, 23, false, false, 64)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 69, 185, 23, false, false, 64)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 70, 153, 39, false, false, 64)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 71, 169, 39, false, false, 64)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 72, 185, 39, false, false, 64)); - break; - case 6 : - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 58, 88, 65, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 58, 104, 65, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 59, 122, 35, false, false, 64)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 60, 92, 5, false, false, 64)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 61, 122, 5, false, false, 64)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 62, 152, 35, false, false, 64)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 63, 122, 65, false, false, 64)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 64, 92, 35, false, false, 64)); - break; - } - } + private int getMode() { + return ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mMode; + } - public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { - //Logger.INFO("Clicked slot " + aSlotIndex); - if (aSlotIndex < 0) { - //Logger.INFO(""); - return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); - } - if (this.mID != ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mMode) { - //Logger.INFO("This ID: " + mID + ", Tile: " + ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mMode); - return null; - } - Slot tSlot = (Slot) this.inventorySlots.get(aSlotIndex); - if (tSlot == null) { - //Logger.INFO("Null Slot?"); - } - else { - ItemStack tStack = tSlot.getStack(); - //Logger.INFO("Good Slot!"); - if (aSlotIndex == 0) { - //Logger.INFO("Slot is 0"); - if (aMouseclick == 0) { - Logger.INFO("Forward"); - ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).switchModeForward(); - } - else { - Logger.INFO("Backwards"); - ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).switchModeBackward(); - } - if (aPlayer instanceof EntityPlayerMP) { - EntityPlayerMP aPlayerMP = (EntityPlayerMP) aPlayer; - changePage(aPlayerMP, ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mMode); - } - //FMLNetworkHandler.openGui(entityPlayer, mod, modGuiId, world, x, y, z); - //aPlayer.openGui(CORE.MODID, getComputerCubeGUIID(), this.mTileEntity.getWorld(), this.mTileEntity.getXCoord(), this.mTileEntity.getYCoord(), this.mTileEntity.getZCoord()); - } - else if (aSlotIndex <= 2 && this.mID == 3) { - if (aSlotIndex == 1) { - ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).switchCentrifugePageBackward(); - onCraftMatrixChanged(this.mTileEntity); - } - else if (aSlotIndex == 2) { - ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).switchCentrifugePageForward(); - onCraftMatrixChanged(this.mTileEntity); - } - } - else if (aSlotIndex <= 2 && this.mID == 6) { - if (aSlotIndex == 1) { - ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).switchElectrolyzerPageBackward(); - onCraftMatrixChanged(this.mTileEntity); - } - else if (aSlotIndex == 2) { - ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).switchElectrolyzerPageForward(); - onCraftMatrixChanged(this.mTileEntity); - } - } - else if (aSlotIndex <= 2 && this.mID == 4) { - if (aSlotIndex == 1) { - ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).switchFusionPageBackward(); - onCraftMatrixChanged(this.mTileEntity); - } - else if (aSlotIndex == 2) { - ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).switchFusionPageForward(); - onCraftMatrixChanged(this.mTileEntity); - } - } - else if (aSlotIndex <= 2 && this.mID == 5) { - if (aSlotIndex == 1) { - ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).switchDescriptionPageBackward(); - onCraftMatrixChanged(this.mTileEntity); - } - else if (aSlotIndex == 2) { - ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).switchDescriptionPageForward(); - onCraftMatrixChanged(this.mTileEntity); - } - } - else if (aSlotIndex <= 58 && this.mID == 1) { - if (aSlotIndex == 1) { - ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).switchNuclearReactor(); - onCraftMatrixChanged(this.mTileEntity); - } - else if (aSlotIndex == 2) { - ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).loadNuclearReactor(); - onCraftMatrixChanged(this.mTileEntity); - } - else if (aSlotIndex == 3) { - ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).saveNuclearReactor(); - } - else { - if (aShifthold == 1) { - tSlot.putStack(null); - ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).getSimulator().slotClick(aSlotIndex, null); - return null; - } + public void addSlotsComputer(InventoryPlayer aInventoryPlayer) { + int y; + mID = ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mMode; + Logger.INFO("" + (Utils.isClient() ? "Client" : "Server") + " Mode: " + mID); + addSlotToContainer( + new GT_Slot_Holo(this.mTileEntity, 58, 156 + ((this.mID == 5) ? 50 : 0), 4, false, false, 1)); + switch (this.mID) { + case 1: + addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 58, 156, 86, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 58, 156, 70, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 58, 156, 54, false, false, 1)); + for (y = 0; y < 6; y++) { + for (int x = 0; x < 9; x++) + addSlotToContainer(new GT_Slot_Holo( + this.mTileEntity, x + y * 9, 5 + x * 16, 5 + y * 16, false, false, 64)); + } + addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 113, 153, 28, false, false, 64)); + break; + case 2: + addSlotToContainer(new SlotDataStick(this.mTileEntity, 54, 8, 28)); + addSlotToContainer(new Slot(this.mTileEntity, 55, 26, 28)); + addSlotToContainer(new GT_Slot_Output(this.mTileEntity, 56, 134, 28)); + addSlotToContainer(new GT_Slot_Output(this.mTileEntity, 57, 152, 28)); + break; + case 3: + addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 58, 88, 65, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 58, 104, 65, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 59, 122, 35, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 60, 92, 5, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 61, 122, 5, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 62, 152, 35, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 63, 122, 65, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 64, 92, 35, false, false, 64)); + break; + case 4: + addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 58, 88, 65, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 58, 104, 65, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 59, 122, 5, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 60, 122, 65, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 61, 152, 35, false, false, 64)); + break; + case 5: + addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 58, 190, 146, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 58, 206, 146, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 59, 206, 38, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 60, 206, 56, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 61, 206, 74, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 62, 206, 92, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 63, 206, 110, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 64, 153, 7, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 65, 169, 7, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 66, 185, 7, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 67, 153, 23, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 68, 169, 23, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 69, 185, 23, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 70, 153, 39, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 71, 169, 39, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 72, 185, 39, false, false, 64)); + break; + case 6: + addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 58, 88, 65, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 58, 104, 65, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 59, 122, 35, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 60, 92, 5, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 61, 122, 5, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 62, 152, 35, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 63, 122, 65, false, false, 64)); + addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 64, 92, 35, false, false, 64)); + break; + } + } - if (aMouseclick == 1) { - tSlot.putStack(null); - } - if (aMouseclick == 0) { - if (tStack == null) { - if (getSlot(58).getStack() != null && aSlotIndex != 58) { - tSlot.putStack(getSlot(58).getStack().copy()); - ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).getSimulator().slotClick(aSlotIndex, new GT_ItemStack(getSlot(58).getStack().copy())); - } - else { - tSlot.putStack(new ItemStack(GT_TileEntity_ComputerCube.sReactorList.get(0).mItem, 1)); - ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).getSimulator().slotClick(aSlotIndex, GT_TileEntity_ComputerCube.sReactorList.get(0)); - } - return null; - } - for (int i = 1; i < GT_TileEntity_ComputerCube.sReactorList.size(); i++) { - if (GT_TileEntity_ComputerCube.sReactorList.get(i - 1).mItem == tStack.getItem()) { - tSlot.putStack(new ItemStack(GT_TileEntity_ComputerCube.sReactorList.get(i).mItem, 1, 0)); - ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).getSimulator().slotClick(aSlotIndex, GT_TileEntity_ComputerCube.sReactorList.get(i)); - /*if (tSlot.getStack() != null && tSlot.getStack().getItem() == GT_ModHandler.getIC2Item("reactorIsotopeCell", 1).getItem()) { - tSlot.getStack().setItemDamage(tSlot.getStack().getMaxDamage() - 1); - }*/ - return null; - } - } - tSlot.putStack(null); - ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).getSimulator().slotClick(aSlotIndex, null); - return null; - } - if (tStack == null) - return null; - if (tStack.stackSize < tStack.getMaxStackSize()) { - tStack.stackSize++; - return null; - } - tStack.stackSize = 1; - return null; - } - } - else { - //Logger.INFO("Super 2"); - return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); - } - } - //Logger.INFO("???"); - return null; - } + public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { + // Logger.INFO("Clicked slot " + aSlotIndex); + if (aSlotIndex < 0) { + // Logger.INFO(""); + return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + } + if (this.mID != ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mMode) { + // Logger.INFO("This ID: " + mID + ", Tile: " + ((GT_TileEntity_ComputerCube) + // mTileEntity.getMetaTileEntity()).mMode); + return null; + } + Slot tSlot = (Slot) this.inventorySlots.get(aSlotIndex); + if (tSlot == null) { + // Logger.INFO("Null Slot?"); + } else { + ItemStack tStack = tSlot.getStack(); + // Logger.INFO("Good Slot!"); + if (aSlotIndex == 0) { + // Logger.INFO("Slot is 0"); + if (aMouseclick == 0) { + Logger.INFO("Forward"); + ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).switchModeForward(); + } else { + Logger.INFO("Backwards"); + ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).switchModeBackward(); + } + if (aPlayer instanceof EntityPlayerMP) { + EntityPlayerMP aPlayerMP = (EntityPlayerMP) aPlayer; + changePage(aPlayerMP, ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mMode); + } + // FMLNetworkHandler.openGui(entityPlayer, mod, modGuiId, world, x, y, z); + // aPlayer.openGui(CORE.MODID, getComputerCubeGUIID(), this.mTileEntity.getWorld(), + // this.mTileEntity.getXCoord(), this.mTileEntity.getYCoord(), this.mTileEntity.getZCoord()); + } else if (aSlotIndex <= 2 && this.mID == 3) { + if (aSlotIndex == 1) { + ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).switchCentrifugePageBackward(); + onCraftMatrixChanged(this.mTileEntity); + } else if (aSlotIndex == 2) { + ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).switchCentrifugePageForward(); + onCraftMatrixChanged(this.mTileEntity); + } + } else if (aSlotIndex <= 2 && this.mID == 6) { + if (aSlotIndex == 1) { + ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).switchElectrolyzerPageBackward(); + onCraftMatrixChanged(this.mTileEntity); + } else if (aSlotIndex == 2) { + ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).switchElectrolyzerPageForward(); + onCraftMatrixChanged(this.mTileEntity); + } + } else if (aSlotIndex <= 2 && this.mID == 4) { + if (aSlotIndex == 1) { + ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).switchFusionPageBackward(); + onCraftMatrixChanged(this.mTileEntity); + } else if (aSlotIndex == 2) { + ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).switchFusionPageForward(); + onCraftMatrixChanged(this.mTileEntity); + } + } else if (aSlotIndex <= 2 && this.mID == 5) { + if (aSlotIndex == 1) { + ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).switchDescriptionPageBackward(); + onCraftMatrixChanged(this.mTileEntity); + } else if (aSlotIndex == 2) { + ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).switchDescriptionPageForward(); + onCraftMatrixChanged(this.mTileEntity); + } + } else if (aSlotIndex <= 58 && this.mID == 1) { + if (aSlotIndex == 1) { + ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).switchNuclearReactor(); + onCraftMatrixChanged(this.mTileEntity); + } else if (aSlotIndex == 2) { + ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).loadNuclearReactor(); + onCraftMatrixChanged(this.mTileEntity); + } else if (aSlotIndex == 3) { + ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).saveNuclearReactor(); + } else { + if (aShifthold == 1) { + tSlot.putStack(null); + ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()) + .getSimulator() + .slotClick(aSlotIndex, null); + return null; + } + if (aMouseclick == 1) { + tSlot.putStack(null); + } + if (aMouseclick == 0) { + if (tStack == null) { + if (getSlot(58).getStack() != null && aSlotIndex != 58) { + tSlot.putStack(getSlot(58).getStack().copy()); + ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()) + .getSimulator() + .slotClick( + aSlotIndex, + new GT_ItemStack( + getSlot(58).getStack().copy())); + } else { + tSlot.putStack(new ItemStack(GT_TileEntity_ComputerCube.sReactorList.get(0).mItem, 1)); + ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()) + .getSimulator() + .slotClick(aSlotIndex, GT_TileEntity_ComputerCube.sReactorList.get(0)); + } + return null; + } + for (int i = 1; i < GT_TileEntity_ComputerCube.sReactorList.size(); i++) { + if (GT_TileEntity_ComputerCube.sReactorList.get(i - 1).mItem == tStack.getItem()) { + tSlot.putStack( + new ItemStack(GT_TileEntity_ComputerCube.sReactorList.get(i).mItem, 1, 0)); + ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()) + .getSimulator() + .slotClick(aSlotIndex, GT_TileEntity_ComputerCube.sReactorList.get(i)); + /*if (tSlot.getStack() != null && tSlot.getStack().getItem() == GT_ModHandler.getIC2Item("reactorIsotopeCell", 1).getItem()) { + tSlot.getStack().setItemDamage(tSlot.getStack().getMaxDamage() - 1); + }*/ + return null; + } + } + tSlot.putStack(null); + ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()) + .getSimulator() + .slotClick(aSlotIndex, null); + return null; + } + if (tStack == null) return null; + if (tStack.stackSize < tStack.getMaxStackSize()) { + tStack.stackSize++; + return null; + } + tStack.stackSize = 1; + return null; + } + } else { + // Logger.INFO("Super 2"); + return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + } + } + // Logger.INFO("???"); + return null; + } + public void changePage(EntityPlayerMP aPlayerMP, int aMode) { + GT_TileEntity_ComputerCube aCompTile = (GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity(); + aCompTile.onRightclick(mTileEntity, aPlayerMP); + } - public void changePage(EntityPlayerMP aPlayerMP, int aMode) { - GT_TileEntity_ComputerCube aCompTile = (GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity(); - aCompTile.onRightclick(mTileEntity, aPlayerMP); - } + public boolean doesBindPlayerInventory() { + return (this.mID != 1 && this.mID != 5); + } - public boolean doesBindPlayerInventory() { - return (this.mID != 1 && this.mID != 5); - } + public void detectAndSendChanges() { + super.detectAndSendChanges(); + if (mTileEntity.isClientSide() || mTileEntity.getMetaTileEntity() == null) { + return; + } + mStoredEU = mTileEntity.getStoredEU(); + mMaxStoredEU = mTileEntity.getEUCapacity(); + int[] aStored = MathUtils.splitLongIntoTwoIntegers(mStoredEU); + int[] aMaxStorage = MathUtils.splitLongIntoTwoIntegers(mMaxStoredEU); + mStoredEU1 = aStored[0]; + mStoredEU2 = aStored[1]; + mMaxStoredEU1 = aMaxStorage[0]; + mMaxStoredEU2 = aMaxStorage[1]; - public void detectAndSendChanges() { - super.detectAndSendChanges(); - if (mTileEntity.isClientSide() || mTileEntity.getMetaTileEntity() == null) { - return; - } - mStoredEU = mTileEntity.getStoredEU(); - mMaxStoredEU = mTileEntity.getEUCapacity(); - int[] aStored = MathUtils.splitLongIntoTwoIntegers(mStoredEU); - int[] aMaxStorage = MathUtils.splitLongIntoTwoIntegers(mMaxStoredEU); - mStoredEU1 = aStored[0]; - mStoredEU2 = aStored[1]; - mMaxStoredEU1 = aMaxStorage[0]; - mMaxStoredEU2 = aMaxStorage[1]; - - - this.mID = ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mMode; - this.mEUOut = ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mEUOut; - int[] aEUSplit1 = MathUtils.splitLongIntoTwoIntegers(mEUOut); - this.mEUOut1 = aEUSplit1[0]; - this.mEUOut2 = aEUSplit1[1]; - this.mHeat = ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mHeat; - this.mMaxHeat = ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mMaxHeat; - this.mHEM = (int) (((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mHEM * 10000.0F); - this.mExplosionStrength = (int) (((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mExplosionStrength * 100.0F); - this.mEU = ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mEU; - this.mProgress = ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mProgress; - this.mMaxProgressTime = ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mMaxProgress; - this.mProgressTime = (int) ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).getEUVar(); - int[] aEUSplit2 = MathUtils.splitLongIntoTwoIntegers(mEU); - this.mEU1 = aEUSplit2[0]; - this.mEU2 = aEUSplit2[1]; - Iterator<ICrafting> var2 = this.crafters.iterator(); - while (var2.hasNext()) { - ICrafting var1 = var2.next(); - var1.sendProgressBarUpdate(this, 101, this.mID); - var1.sendProgressBarUpdate(this, 102, this.mHeat & 0xFFFF); - var1.sendProgressBarUpdate(this, 103, this.mMaxHeat & 0xFFFF); - var1.sendProgressBarUpdate(this, 104, this.mHEM); - var1.sendProgressBarUpdate(this, 105, this.mExplosionStrength); - var1.sendProgressBarUpdate(this, 106, this.mHeat >>> 16); - var1.sendProgressBarUpdate(this, 107, this.mMaxHeat >>> 16); - var1.sendProgressBarUpdate(this, 108, this.mEU1); - var1.sendProgressBarUpdate(this, 109, this.mEU2); - var1.sendProgressBarUpdate(this, 110, this.mProgress); - var1.sendProgressBarUpdate(this, 111, this.mEUOut1); - var1.sendProgressBarUpdate(this, 112, this.mEUOut2); - var1.sendProgressBarUpdate(this, 113, mStoredEU1); - var1.sendProgressBarUpdate(this, 114, mStoredEU2); - var1.sendProgressBarUpdate(this, 115, mMaxStoredEU1); - var1.sendProgressBarUpdate(this, 116, mMaxStoredEU2); - } - } + this.mID = ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mMode; + this.mEUOut = ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mEUOut; + int[] aEUSplit1 = MathUtils.splitLongIntoTwoIntegers(mEUOut); + this.mEUOut1 = aEUSplit1[0]; + this.mEUOut2 = aEUSplit1[1]; + this.mHeat = ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mHeat; + this.mMaxHeat = ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mMaxHeat; + this.mHEM = (int) (((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mHEM * 10000.0F); + this.mExplosionStrength = + (int) (((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mExplosionStrength * 100.0F); + this.mEU = ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mEU; + this.mProgress = ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mProgress; + this.mMaxProgressTime = ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).mMaxProgress; + this.mProgressTime = (int) ((GT_TileEntity_ComputerCube) mTileEntity.getMetaTileEntity()).getEUVar(); + int[] aEUSplit2 = MathUtils.splitLongIntoTwoIntegers(mEU); + this.mEU1 = aEUSplit2[0]; + this.mEU2 = aEUSplit2[1]; + Iterator<ICrafting> var2 = this.crafters.iterator(); + while (var2.hasNext()) { + ICrafting var1 = var2.next(); + var1.sendProgressBarUpdate(this, 101, this.mID); + var1.sendProgressBarUpdate(this, 102, this.mHeat & 0xFFFF); + var1.sendProgressBarUpdate(this, 103, this.mMaxHeat & 0xFFFF); + var1.sendProgressBarUpdate(this, 104, this.mHEM); + var1.sendProgressBarUpdate(this, 105, this.mExplosionStrength); + var1.sendProgressBarUpdate(this, 106, this.mHeat >>> 16); + var1.sendProgressBarUpdate(this, 107, this.mMaxHeat >>> 16); + var1.sendProgressBarUpdate(this, 108, this.mEU1); + var1.sendProgressBarUpdate(this, 109, this.mEU2); + var1.sendProgressBarUpdate(this, 110, this.mProgress); + var1.sendProgressBarUpdate(this, 111, this.mEUOut1); + var1.sendProgressBarUpdate(this, 112, this.mEUOut2); + var1.sendProgressBarUpdate(this, 113, mStoredEU1); + var1.sendProgressBarUpdate(this, 114, mStoredEU2); + var1.sendProgressBarUpdate(this, 115, mMaxStoredEU1); + var1.sendProgressBarUpdate(this, 116, mMaxStoredEU2); + } + } - @SideOnly(Side.CLIENT) - public void updateProgressBar(int par1, int par2) { - super.updateProgressBar(par1, par2); - switch (par1) { - case 101 : - this.mID = par2; - break; - case 102 : - this.mHeat = this.mHeat & 0xFFFF0000 | par2; - break; - case 103 : - this.mMaxHeat = this.mMaxHeat & 0xFFFF0000 | par2; - break; - case 104 : - this.mHEM = par2; - break; - case 105 : - this.mExplosionStrength = par2; - break; - case 106 : - this.mHeat = this.mHeat & 0xFFFF | par2 << 16; - break; - case 107 : - this.mMaxHeat = this.mMaxHeat & 0xFFFF | par2 << 16; - break; - case 108 : - this.mEU1 = par2; - case 109 : - this.mEU2 = par2; - this.mEU = MathUtils.combineTwoIntegersToLong(mEU1, mEU2); - break; - case 110 : - this.mProgress = par2; - break; - case 111 : - this.mEUOut1 = par2; - case 112 : - this.mEUOut2 = par2; - this.mEUOut = MathUtils.combineTwoIntegersToLong(mEUOut1, mEUOut2); - break; - case 113 : - mStoredEU1 = par2; - break; - case 114 : - mStoredEU2 = par2; - mStoredEU = MathUtils.combineTwoIntegersToLong(mStoredEU1, mStoredEU2); - break; - case 115 : - mMaxStoredEU1 = par2; - break; - case 116 : - mMaxStoredEU2 = par2; - mMaxStoredEU = MathUtils.combineTwoIntegersToLong(mMaxStoredEU1, mMaxStoredEU2); - break; - } - } + @SideOnly(Side.CLIENT) + public void updateProgressBar(int par1, int par2) { + super.updateProgressBar(par1, par2); + switch (par1) { + case 101: + this.mID = par2; + break; + case 102: + this.mHeat = this.mHeat & 0xFFFF0000 | par2; + break; + case 103: + this.mMaxHeat = this.mMaxHeat & 0xFFFF0000 | par2; + break; + case 104: + this.mHEM = par2; + break; + case 105: + this.mExplosionStrength = par2; + break; + case 106: + this.mHeat = this.mHeat & 0xFFFF | par2 << 16; + break; + case 107: + this.mMaxHeat = this.mMaxHeat & 0xFFFF | par2 << 16; + break; + case 108: + this.mEU1 = par2; + case 109: + this.mEU2 = par2; + this.mEU = MathUtils.combineTwoIntegersToLong(mEU1, mEU2); + break; + case 110: + this.mProgress = par2; + break; + case 111: + this.mEUOut1 = par2; + case 112: + this.mEUOut2 = par2; + this.mEUOut = MathUtils.combineTwoIntegersToLong(mEUOut1, mEUOut2); + break; + case 113: + mStoredEU1 = par2; + break; + case 114: + mStoredEU2 = par2; + mStoredEU = MathUtils.combineTwoIntegersToLong(mStoredEU1, mStoredEU2); + break; + case 115: + mMaxStoredEU1 = par2; + break; + case 116: + mMaxStoredEU2 = par2; + mMaxStoredEU = MathUtils.combineTwoIntegersToLong(mMaxStoredEU1, mMaxStoredEU2); + break; + } + } - public int getSlotStartIndex() { - return 1; - } + public int getSlotStartIndex() { + return 1; + } - public int getSlotCount() { - return (this.mID == 2) ? 4 : 0; - } + public int getSlotCount() { + return (this.mID == 2) ? 4 : 0; + } - public int getShiftClickSlotCount() { - return (this.mID == 2) ? 2 : 0; - } + public int getShiftClickSlotCount() { + return (this.mID == 2) ? 2 : 0; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/computer/GT_Container_RedstoneCircuitBlock.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/computer/GT_Container_RedstoneCircuitBlock.java index acae0d39c5..d02061185a 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/computer/GT_Container_RedstoneCircuitBlock.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/computer/GT_Container_RedstoneCircuitBlock.java @@ -1,7 +1,5 @@ package gtPlusPlus.xmod.gregtech.api.gui.computer; -import java.util.Iterator; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.gui.GT_ContainerMetaTile_Machine; @@ -9,6 +7,7 @@ import gregtech.api.gui.GT_Slot_Holo; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.util.GT_Utility; import gtPlusPlus.xmod.gregtech.common.tileentities.redstone.GT_MetaTileEntity_RedstoneCircuitBlock; +import java.util.Iterator; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.ICrafting; @@ -18,159 +17,159 @@ import net.minecraftforge.oredict.OreDictionary; public class GT_Container_RedstoneCircuitBlock extends GT_ContainerMetaTile_Machine { - public GT_Container_RedstoneCircuitBlock(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { - super(aInventoryPlayer, aTileEntity); - } + public GT_Container_RedstoneCircuitBlock(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { + super(aInventoryPlayer, aTileEntity); + } - public void addSlots(InventoryPlayer aInventoryPlayer) { - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 0, 8, 6, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 0, 8, 24, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 0, 8, 42, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 0, 8, 60, false, true, 1)); + public void addSlots(InventoryPlayer aInventoryPlayer) { + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 0, 8, 6, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 0, 8, 24, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 0, 8, 42, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 0, 8, 60, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 0, 152, 6, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 0, 152, 24, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 0, 152, 42, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 0, 152, 6, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 0, 152, 24, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 0, 152, 42, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 1, 26, 6, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 26, 24, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 3, 26, 42, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 4, 26, 60, false, true, 1)); - } + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 1, 26, 6, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 26, 24, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 3, 26, 42, false, true, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 4, 26, 60, false, true, 1)); + } - public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { - if (aSlotIndex < 0 || aSlotIndex > 6) - return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { + if (aSlotIndex < 0 || aSlotIndex > 6) return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); - Slot tSlot = (Slot) inventorySlots.get(aSlotIndex); - if (tSlot != null) { - if (mTileEntity.getMetaTileEntity() == null) - return null; - if (aSlotIndex < 4) { - ItemStack tStack = aPlayer.inventory.getItemStack(); - if (tStack == null) { - ((GT_MetaTileEntity_RedstoneCircuitBlock) mTileEntity.getMetaTileEntity()).changeGateData(aSlotIndex, aMouseclick == 0 ? aShifthold == 0 ? +1 : aShifthold == 1 ? +128 : +16 : aShifthold == 0 ? -1 : aShifthold == 1 ? -128 : -16); - } - else { - tStack = GT_Utility.copy(tStack); - if (aMouseclick != 0) - tStack.setItemDamage(OreDictionary.WILDCARD_VALUE); - ((GT_MetaTileEntity_RedstoneCircuitBlock) mTileEntity.getMetaTileEntity()).stackGateData(aSlotIndex, tStack); - } - return null; - } - else if (aSlotIndex == 4) { - ((GT_MetaTileEntity_RedstoneCircuitBlock) mTileEntity.getMetaTileEntity()).switchOutput(); - } - else if (aSlotIndex == 5) { - mTileEntity.setActive(!mTileEntity.isActive()); - } - else if (aSlotIndex == 6) { - if (aMouseclick == 0) - ((GT_MetaTileEntity_RedstoneCircuitBlock) mTileEntity.getMetaTileEntity()).switchGateForward(aShifthold != 0); - else - ((GT_MetaTileEntity_RedstoneCircuitBlock) mTileEntity.getMetaTileEntity()).switchGateBackward(aShifthold != 0); - } - } - return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); - } + Slot tSlot = (Slot) inventorySlots.get(aSlotIndex); + if (tSlot != null) { + if (mTileEntity.getMetaTileEntity() == null) return null; + if (aSlotIndex < 4) { + ItemStack tStack = aPlayer.inventory.getItemStack(); + if (tStack == null) { + ((GT_MetaTileEntity_RedstoneCircuitBlock) mTileEntity.getMetaTileEntity()) + .changeGateData( + aSlotIndex, + aMouseclick == 0 + ? aShifthold == 0 ? +1 : aShifthold == 1 ? +128 : +16 + : aShifthold == 0 ? -1 : aShifthold == 1 ? -128 : -16); + } else { + tStack = GT_Utility.copy(tStack); + if (aMouseclick != 0) tStack.setItemDamage(OreDictionary.WILDCARD_VALUE); + ((GT_MetaTileEntity_RedstoneCircuitBlock) mTileEntity.getMetaTileEntity()) + .stackGateData(aSlotIndex, tStack); + } + return null; + } else if (aSlotIndex == 4) { + ((GT_MetaTileEntity_RedstoneCircuitBlock) mTileEntity.getMetaTileEntity()).switchOutput(); + } else if (aSlotIndex == 5) { + mTileEntity.setActive(!mTileEntity.isActive()); + } else if (aSlotIndex == 6) { + if (aMouseclick == 0) + ((GT_MetaTileEntity_RedstoneCircuitBlock) mTileEntity.getMetaTileEntity()) + .switchGateForward(aShifthold != 0); + else + ((GT_MetaTileEntity_RedstoneCircuitBlock) mTileEntity.getMetaTileEntity()) + .switchGateBackward(aShifthold != 0); + } + } + return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + } - public int mData[] = new int[]{0, 0, 0, 0, 0, 0, 0, 0}, mGate = 0; + public int mData[] = new int[] {0, 0, 0, 0, 0, 0, 0, 0}, mGate = 0; - @SuppressWarnings("rawtypes") - public void detectAndSendChanges() { - super.detectAndSendChanges(); - if (mTileEntity.isClientSide() || mTileEntity.getMetaTileEntity() == null) - return; - mGate = ((GT_MetaTileEntity_RedstoneCircuitBlock) mTileEntity.getMetaTileEntity()).mGate; - mData = ((GT_MetaTileEntity_RedstoneCircuitBlock) mTileEntity.getMetaTileEntity()).mGateData; + @SuppressWarnings("rawtypes") + public void detectAndSendChanges() { + super.detectAndSendChanges(); + if (mTileEntity.isClientSide() || mTileEntity.getMetaTileEntity() == null) return; + mGate = ((GT_MetaTileEntity_RedstoneCircuitBlock) mTileEntity.getMetaTileEntity()).mGate; + mData = ((GT_MetaTileEntity_RedstoneCircuitBlock) mTileEntity.getMetaTileEntity()).mGateData; - Iterator var2 = this.crafters.iterator(); - while (var2.hasNext()) { - ICrafting var1 = (ICrafting) var2.next(); - var1.sendProgressBarUpdate(this, 100, mGate & 65535); - var1.sendProgressBarUpdate(this, 101, mGate >>> 16); - var1.sendProgressBarUpdate(this, 102, mData[0] & 65535); - var1.sendProgressBarUpdate(this, 103, mData[0] >>> 16); - var1.sendProgressBarUpdate(this, 104, mData[1] & 65535); - var1.sendProgressBarUpdate(this, 105, mData[1] >>> 16); - var1.sendProgressBarUpdate(this, 106, mData[2] & 65535); - var1.sendProgressBarUpdate(this, 107, mData[2] >>> 16); - var1.sendProgressBarUpdate(this, 108, mData[3] & 65535); - var1.sendProgressBarUpdate(this, 109, mData[3] >>> 16); - var1.sendProgressBarUpdate(this, 110, mData[4] & 65535); - var1.sendProgressBarUpdate(this, 111, mData[4] >>> 16); - var1.sendProgressBarUpdate(this, 112, mData[5] & 65535); - var1.sendProgressBarUpdate(this, 113, mData[5] >>> 16); - var1.sendProgressBarUpdate(this, 114, mData[6] & 65535); - var1.sendProgressBarUpdate(this, 115, mData[6] >>> 16); - var1.sendProgressBarUpdate(this, 116, mData[7] & 65535); - var1.sendProgressBarUpdate(this, 117, mData[7] >>> 16); - } - } + Iterator var2 = this.crafters.iterator(); + while (var2.hasNext()) { + ICrafting var1 = (ICrafting) var2.next(); + var1.sendProgressBarUpdate(this, 100, mGate & 65535); + var1.sendProgressBarUpdate(this, 101, mGate >>> 16); + var1.sendProgressBarUpdate(this, 102, mData[0] & 65535); + var1.sendProgressBarUpdate(this, 103, mData[0] >>> 16); + var1.sendProgressBarUpdate(this, 104, mData[1] & 65535); + var1.sendProgressBarUpdate(this, 105, mData[1] >>> 16); + var1.sendProgressBarUpdate(this, 106, mData[2] & 65535); + var1.sendProgressBarUpdate(this, 107, mData[2] >>> 16); + var1.sendProgressBarUpdate(this, 108, mData[3] & 65535); + var1.sendProgressBarUpdate(this, 109, mData[3] >>> 16); + var1.sendProgressBarUpdate(this, 110, mData[4] & 65535); + var1.sendProgressBarUpdate(this, 111, mData[4] >>> 16); + var1.sendProgressBarUpdate(this, 112, mData[5] & 65535); + var1.sendProgressBarUpdate(this, 113, mData[5] >>> 16); + var1.sendProgressBarUpdate(this, 114, mData[6] & 65535); + var1.sendProgressBarUpdate(this, 115, mData[6] >>> 16); + var1.sendProgressBarUpdate(this, 116, mData[7] & 65535); + var1.sendProgressBarUpdate(this, 117, mData[7] >>> 16); + } + } - public void addCraftingToCrafters(ICrafting par1ICrafting) { - super.addCraftingToCrafters(par1ICrafting); - } + public void addCraftingToCrafters(ICrafting par1ICrafting) { + super.addCraftingToCrafters(par1ICrafting); + } - @SideOnly(Side.CLIENT) - public void updateProgressBar(int par1, int par2) { - super.updateProgressBar(par1, par2); - switch (par1) { - case 100 : - mGate = mGate & -65536 | par2; - break; - case 101 : - mGate = mGate & 65535 | par2 << 16; - break; - case 102 : - mData[0] = mData[0] & -65536 | par2; - break; - case 103 : - mData[0] = mData[0] & 65535 | par2 << 16; - break; - case 104 : - mData[1] = mData[1] & -65536 | par2; - break; - case 105 : - mData[1] = mData[1] & 65535 | par2 << 16; - break; - case 106 : - mData[2] = mData[2] & -65536 | par2; - break; - case 107 : - mData[2] = mData[2] & 65535 | par2 << 16; - break; - case 108 : - mData[3] = mData[3] & -65536 | par2; - break; - case 109 : - mData[3] = mData[3] & 65535 | par2 << 16; - break; - case 110 : - mData[4] = mData[4] & -65536 | par2; - break; - case 111 : - mData[4] = mData[4] & 65535 | par2 << 16; - break; - case 112 : - mData[5] = mData[5] & -65536 | par2; - break; - case 113 : - mData[5] = mData[5] & 65535 | par2 << 16; - break; - case 114 : - mData[6] = mData[6] & -65536 | par2; - break; - case 115 : - mData[6] = mData[6] & 65535 | par2 << 16; - break; - case 116 : - mData[7] = mData[7] & -65536 | par2; - break; - case 117 : - mData[7] = mData[7] & 65535 | par2 << 16; - break; - } - } + @SideOnly(Side.CLIENT) + public void updateProgressBar(int par1, int par2) { + super.updateProgressBar(par1, par2); + switch (par1) { + case 100: + mGate = mGate & -65536 | par2; + break; + case 101: + mGate = mGate & 65535 | par2 << 16; + break; + case 102: + mData[0] = mData[0] & -65536 | par2; + break; + case 103: + mData[0] = mData[0] & 65535 | par2 << 16; + break; + case 104: + mData[1] = mData[1] & -65536 | par2; + break; + case 105: + mData[1] = mData[1] & 65535 | par2 << 16; + break; + case 106: + mData[2] = mData[2] & -65536 | par2; + break; + case 107: + mData[2] = mData[2] & 65535 | par2 << 16; + break; + case 108: + mData[3] = mData[3] & -65536 | par2; + break; + case 109: + mData[3] = mData[3] & 65535 | par2 << 16; + break; + case 110: + mData[4] = mData[4] & -65536 | par2; + break; + case 111: + mData[4] = mData[4] & 65535 | par2 << 16; + break; + case 112: + mData[5] = mData[5] & -65536 | par2; + break; + case 113: + mData[5] = mData[5] & 65535 | par2 << 16; + break; + case 114: + mData[6] = mData[6] & -65536 | par2; + break; + case 115: + mData[6] = mData[6] & 65535 | par2 << 16; + break; + case 116: + mData[7] = mData[7] & -65536 | par2; + break; + case 117: + mData[7] = mData[7] & 65535 | par2 << 16; + break; + } + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/computer/GT_GUIContainer_ComputerCube.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/computer/GT_GUIContainer_ComputerCube.java index 71defdc72a..c7d2c47f7b 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/computer/GT_GUIContainer_ComputerCube.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/computer/GT_GUIContainer_ComputerCube.java @@ -14,159 +14,212 @@ import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; public class GT_GUIContainer_ComputerCube extends GT_GUIContainerMetaTile_Machine { - - public final GT_Container_ComputerCube mPowerContainer; - - public GT_GUIContainer_ComputerCube(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aBaseMetaTileEntity, int aID) { - super(new GT_Container_ComputerCube(aInventoryPlayer, aBaseMetaTileEntity, aID), CORE.RES_PATH_GUI + "computer/"+aID+".png"); - mPowerContainer = (GT_Container_ComputerCube) mContainer; - if (mPowerContainer.mID == 5) { - this.xSize += 50; - } - } - + + public final GT_Container_ComputerCube mPowerContainer; + + public GT_GUIContainer_ComputerCube( + InventoryPlayer aInventoryPlayer, IGregTechTileEntity aBaseMetaTileEntity, int aID) { + super( + new GT_Container_ComputerCube(aInventoryPlayer, aBaseMetaTileEntity, aID), + CORE.RES_PATH_GUI + "computer/" + aID + ".png"); + mPowerContainer = (GT_Container_ComputerCube) mContainer; + if (mPowerContainer.mID == 5) { + this.xSize += 50; + } + } public static ResourceLocation[] mGUIbackground = new ResourceLocation[8]; - + static { - mGUIbackground[0] = new ResourceLocation(CORE.RES_PATH_GUI + "computer/0.png"); - mGUIbackground[1] = new ResourceLocation(CORE.RES_PATH_GUI + "computer/1.png"); - mGUIbackground[2] = new ResourceLocation(CORE.RES_PATH_GUI + "computer/2.png"); - mGUIbackground[3] = new ResourceLocation(CORE.RES_PATH_GUI + "computer/3.png"); - mGUIbackground[4] = new ResourceLocation(CORE.RES_PATH_GUI + "computer/4.png"); - mGUIbackground[5] = new ResourceLocation(CORE.RES_PATH_GUI + "computer/5.png"); - mGUIbackground[6] = new ResourceLocation(CORE.RES_PATH_GUI + "computer/6.png"); - mGUIbackground[7] = new ResourceLocation(CORE.RES_PATH_GUI + "computer/Redstone.png"); - + mGUIbackground[0] = new ResourceLocation(CORE.RES_PATH_GUI + "computer/0.png"); + mGUIbackground[1] = new ResourceLocation(CORE.RES_PATH_GUI + "computer/1.png"); + mGUIbackground[2] = new ResourceLocation(CORE.RES_PATH_GUI + "computer/2.png"); + mGUIbackground[3] = new ResourceLocation(CORE.RES_PATH_GUI + "computer/3.png"); + mGUIbackground[4] = new ResourceLocation(CORE.RES_PATH_GUI + "computer/4.png"); + mGUIbackground[5] = new ResourceLocation(CORE.RES_PATH_GUI + "computer/5.png"); + mGUIbackground[6] = new ResourceLocation(CORE.RES_PATH_GUI + "computer/6.png"); + mGUIbackground[7] = new ResourceLocation(CORE.RES_PATH_GUI + "computer/Redstone.png"); } - protected void drawGuiContainerForegroundLayer(int par1, int par2) { - GT_Container_ComputerCube tContainer = (GT_Container_ComputerCube) this.mContainer; - //Logger.INFO("3 GUI Mode: "+xSize); - //GT_TileEntity_ComputerCube tTileEntity = (GT_TileEntity_ComputerCube) tContainer.mTileEntity; - if (tContainer != null) - switch (tContainer.mID) { - case 0 : - this.fontRendererObj.drawString("Solaris 1.7.10", 56, 70, Utils.rgbtoHexValue(100, 190, 255)); - //this.fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 8, this.ySize - 96 + 2, 4210752); - break; - case 1 : - this.fontRendererObj.drawString("Reactorstats:", 7, 108, 16448255); - this.fontRendererObj.drawString(toNumber(tContainer.mEU) + "EU at " + tContainer.mEUOut + "EU/t", 7, 120, 16448255); - this.fontRendererObj.drawString("HEM: " + (tContainer.mHEM / 10000.0F), 7, 128, 16448255); - this.fontRendererObj.drawString(toNumber(tContainer.mHeat) + "/" + toNumber(tContainer.mMaxHeat) + "Heat", 7, 136, 16448255); - this.fontRendererObj.drawString("Explosionpower: " + (tContainer.mExplosionStrength / 100.0F), 7, 144, 16448255); - this.fontRendererObj.drawString("Runtime: " + ((tContainer.mProgress > 0) ? (/*(tContainer.mEU / tContainer.mEUOut)*/ tContainer.mProgress / 20) : 0) + "secs", 7, 152, 16448255); - break; - case 2 : - this.fontRendererObj.drawString("Scanner", 51, 7, 16448255); - if (tContainer.mProgress == 0) { - this.fontRendererObj.drawString("Can be used to", 51, 24, 16448255); - this.fontRendererObj.drawString("scan things", 51, 32, 16448255); - this.fontRendererObj.drawString("Currently", 51, 48, Utils.rgbtoHexValue(200, 20, 20)); - this.fontRendererObj.drawString("Disabled", 51, 56, Utils.rgbtoHexValue(200, 20, 20)); - } - else { - this.fontRendererObj.drawString("Progress:", 51, 24, 16448255); - this.fontRendererObj.drawString(MathUtils.findPercentage(tContainer.mProgress, tContainer.mMaxProgressTime) + " %", 51, 32, 16448255); - } - this.fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 8, this.ySize - 96 + 2, 4210752); - break; - case 3 : - this.fontRendererObj.drawString("Centrifuge", 7, 7, 16448255); - this.fontRendererObj.drawString("Recipe: " + (tContainer.mMaxHeat + 1) + "/" + GT_Recipe_Map.sCentrifugeRecipes.mRecipeList.size(), 7, 23, 16448255); - this.fontRendererObj.drawString("EU: " + toNumber(tContainer.mEU), 7, 31, 16448255); - break; - case 4 : - this.fontRendererObj.drawString("Fusionreactor", 7, 7, 16448255); - this.fontRendererObj.drawString("Recipe: " + (tContainer.mMaxHeat + 1) + "/" + GT_TileEntity_ComputerCube.sFusionReactorRecipes.size(), 7, 15, 16448255); - this.fontRendererObj.drawString("Start: " + toNumber(tContainer.mEU) + "EU", 7, 23, 16448255); - this.fontRendererObj.drawString("EU/t: " + toNumber(tContainer.mEUOut), 7, 31, 16448255); - this.fontRendererObj.drawString(toNumber(tContainer.mHeat) + " Ticks", 7, 39, 16448255); - GT_Recipe tRecipe = GT_TileEntity_ComputerCube.sFusionReactorRecipes.get(tContainer.mMaxHeat); - this.fontRendererObj.drawString(""+tRecipe.mFluidOutputs[0].getLocalizedName(), 7, 55, 16448255); - if (tContainer.mEUOut < 0) { - this.fontRendererObj.drawString("IN: " + toNumber(-tContainer.mEUOut * tContainer.mHeat) + "EU", 7, 47, 16448255); - break; - } - this.fontRendererObj.drawString("OUT: " + toNumber(tContainer.mEUOut * tContainer.mHeat) + "EU", 7, 47, 16448255); - break; - case 5 : - if (tContainer.mID == 5 && this.xSize == 176) { - this.xSize += 50; - } - if (tContainer.mMaxHeat >= 0 && tContainer.mMaxHeat < GT_Computercube_Description.sDescriptions.size()) - for (int i = 0; i < ((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(tContainer.mMaxHeat)).mDescription.length; i++) { - if (i == 0) { - this.fontRendererObj.drawString(((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(tContainer.mMaxHeat)).mDescription[i], 7, 7, 16448255); - } - else { - this.fontRendererObj.drawString(((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get(tContainer.mMaxHeat)).mDescription[i], 7, 7 - + 8 * i, 16448255); - } - } - break; - case 6 : - this.fontRendererObj.drawString("Electrolyzer", 7, 7, 16448255); - this.fontRendererObj.drawString("Recipe: " + (tContainer.mMaxHeat + 1) + "/" + GT_Recipe_Map.sElectrolyzerRecipes.mRecipeList.size(), 7, 23, 16448255); - this.fontRendererObj.drawString("EU: " + toNumber(tContainer.mEU), 7, 31, 16448255); - break; - } - } + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + GT_Container_ComputerCube tContainer = (GT_Container_ComputerCube) this.mContainer; + // Logger.INFO("3 GUI Mode: "+xSize); + // GT_TileEntity_ComputerCube tTileEntity = (GT_TileEntity_ComputerCube) tContainer.mTileEntity; + if (tContainer != null) + switch (tContainer.mID) { + case 0: + this.fontRendererObj.drawString("Solaris 1.7.10", 56, 70, Utils.rgbtoHexValue(100, 190, 255)); + // this.fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 8, + // this.ySize - 96 + 2, 4210752); + break; + case 1: + this.fontRendererObj.drawString("Reactorstats:", 7, 108, 16448255); + this.fontRendererObj.drawString( + toNumber(tContainer.mEU) + "EU at " + tContainer.mEUOut + "EU/t", 7, 120, 16448255); + this.fontRendererObj.drawString("HEM: " + (tContainer.mHEM / 10000.0F), 7, 128, 16448255); + this.fontRendererObj.drawString( + toNumber(tContainer.mHeat) + "/" + toNumber(tContainer.mMaxHeat) + "Heat", + 7, + 136, + 16448255); + this.fontRendererObj.drawString( + "Explosionpower: " + (tContainer.mExplosionStrength / 100.0F), 7, 144, 16448255); + this.fontRendererObj.drawString( + "Runtime: " + + ((tContainer.mProgress > 0) + ? ( + /*(tContainer.mEU / tContainer.mEUOut)*/ tContainer.mProgress / 20) + : 0) + + "secs", + 7, + 152, + 16448255); + break; + case 2: + this.fontRendererObj.drawString("Scanner", 51, 7, 16448255); + if (tContainer.mProgress == 0) { + this.fontRendererObj.drawString("Can be used to", 51, 24, 16448255); + this.fontRendererObj.drawString("scan things", 51, 32, 16448255); + this.fontRendererObj.drawString("Currently", 51, 48, Utils.rgbtoHexValue(200, 20, 20)); + this.fontRendererObj.drawString("Disabled", 51, 56, Utils.rgbtoHexValue(200, 20, 20)); + } else { + this.fontRendererObj.drawString("Progress:", 51, 24, 16448255); + this.fontRendererObj.drawString( + MathUtils.findPercentage(tContainer.mProgress, tContainer.mMaxProgressTime) + " %", + 51, + 32, + 16448255); + } + this.fontRendererObj.drawString( + StatCollector.translateToLocal("container.inventory"), 8, this.ySize - 96 + 2, 4210752); + break; + case 3: + this.fontRendererObj.drawString("Centrifuge", 7, 7, 16448255); + this.fontRendererObj.drawString( + "Recipe: " + (tContainer.mMaxHeat + 1) + "/" + + GT_Recipe_Map.sCentrifugeRecipes.mRecipeList.size(), + 7, + 23, + 16448255); + this.fontRendererObj.drawString("EU: " + toNumber(tContainer.mEU), 7, 31, 16448255); + break; + case 4: + this.fontRendererObj.drawString("Fusionreactor", 7, 7, 16448255); + this.fontRendererObj.drawString( + "Recipe: " + (tContainer.mMaxHeat + 1) + "/" + + GT_TileEntity_ComputerCube.sFusionReactorRecipes.size(), + 7, + 15, + 16448255); + this.fontRendererObj.drawString("Start: " + toNumber(tContainer.mEU) + "EU", 7, 23, 16448255); + this.fontRendererObj.drawString("EU/t: " + toNumber(tContainer.mEUOut), 7, 31, 16448255); + this.fontRendererObj.drawString(toNumber(tContainer.mHeat) + " Ticks", 7, 39, 16448255); + GT_Recipe tRecipe = GT_TileEntity_ComputerCube.sFusionReactorRecipes.get(tContainer.mMaxHeat); + this.fontRendererObj.drawString("" + tRecipe.mFluidOutputs[0].getLocalizedName(), 7, 55, 16448255); + if (tContainer.mEUOut < 0) { + this.fontRendererObj.drawString( + "IN: " + toNumber(-tContainer.mEUOut * tContainer.mHeat) + "EU", 7, 47, 16448255); + break; + } + this.fontRendererObj.drawString( + "OUT: " + toNumber(tContainer.mEUOut * tContainer.mHeat) + "EU", 7, 47, 16448255); + break; + case 5: + if (tContainer.mID == 5 && this.xSize == 176) { + this.xSize += 50; + } + if (tContainer.mMaxHeat >= 0 + && tContainer.mMaxHeat < GT_Computercube_Description.sDescriptions.size()) + for (int i = 0; + i + < ((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get( + tContainer.mMaxHeat)) + .mDescription + .length; + i++) { + if (i == 0) { + this.fontRendererObj.drawString( + ((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get( + tContainer.mMaxHeat)) + .mDescription[i], + 7, + 7, + 16448255); + } else { + this.fontRendererObj.drawString( + ((GT_Computercube_Description) GT_Computercube_Description.sDescriptions.get( + tContainer.mMaxHeat)) + .mDescription[i], + 7, + 7 + 8 * i, + 16448255); + } + } + break; + case 6: + this.fontRendererObj.drawString("Electrolyzer", 7, 7, 16448255); + this.fontRendererObj.drawString( + "Recipe: " + (tContainer.mMaxHeat + 1) + "/" + + GT_Recipe_Map.sElectrolyzerRecipes.mRecipeList.size(), + 7, + 23, + 16448255); + this.fontRendererObj.drawString("EU: " + toNumber(tContainer.mEU), 7, 31, 16448255); + break; + } + } - protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { - if (mContainer != null) { - GT_Container_ComputerCube tContainer = (GT_Container_ComputerCube) this.mContainer; - mc.renderEngine.bindTexture(mGUIbackground[((GT_Container_ComputerCube) this.mContainer).mID]); - int x = (width - xSize) / 2; - int y = (height - ySize) / 2; - drawTexturedModalRect(x, y, 0, 0, xSize, ySize); - switch (tContainer.mID) { - case 0 : - if (this.mPowerContainer.mStoredEU > 0 && this.mPowerContainer.mMaxStoredEU > 0) { - final double tScale = MathUtils.findPercentage(this.mPowerContainer.mStoredEU, this.mPowerContainer.mMaxStoredEU); - this.drawTexturedModalRect(x + 44, y + 8, 0, 166, Math.min(MathUtils.roundToClosestInt(tScale), 95), 5); - } - else { - // - //Logger.INFO("1 No Power? "+tContainer.mProgressTime+" | "+tContainer.mTileEntity.getEUCapacity()); - //Logger.INFO("2 No Power? "+aComp.getEUVar()+" | "+aComp.maxEUStore()); - } - break; - case 5 : - if (tContainer.mExplosionStrength != 0) - drawTexturedModalRect(x + 152, y + 6, 0, 166, 50, 50); - break; - } - } - } + protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { + if (mContainer != null) { + GT_Container_ComputerCube tContainer = (GT_Container_ComputerCube) this.mContainer; + mc.renderEngine.bindTexture(mGUIbackground[((GT_Container_ComputerCube) this.mContainer).mID]); + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + drawTexturedModalRect(x, y, 0, 0, xSize, ySize); + switch (tContainer.mID) { + case 0: + if (this.mPowerContainer.mStoredEU > 0 && this.mPowerContainer.mMaxStoredEU > 0) { + final double tScale = MathUtils.findPercentage( + this.mPowerContainer.mStoredEU, this.mPowerContainer.mMaxStoredEU); + this.drawTexturedModalRect( + x + 44, y + 8, 0, 166, Math.min(MathUtils.roundToClosestInt(tScale), 95), 5); + } else { + // + // Logger.INFO("1 No Power? "+tContainer.mProgressTime+" | + // "+tContainer.mTileEntity.getEUCapacity()); + // Logger.INFO("2 No Power? "+aComp.getEUVar()+" | "+aComp.maxEUStore()); + } + break; + case 5: + if (tContainer.mExplosionStrength != 0) drawTexturedModalRect(x + 152, y + 6, 0, 166, 50, 50); + break; + } + } + } - public String toNumber(long mEU) { - String tString = ""; - boolean temp = true, negative = false; - if (mEU < 0) { - mEU *= -1; - negative = true; - } - int i; - for (i = 1000000000; i > 0; i /= 10) { - long tDigit = mEU / i % 10; - if (temp && tDigit != 0) - temp = false; - if (!temp) { - tString = tString + tDigit; - if (i != 1) { - int j; - for (j = i; j > 0;) { - if (j == 1) - tString = tString + ","; - j /= 1000; - } - } - } - } - if (tString.equals("")) - tString = "0"; - return negative ? ("-" + tString) : tString; - } + public String toNumber(long mEU) { + String tString = ""; + boolean temp = true, negative = false; + if (mEU < 0) { + mEU *= -1; + negative = true; + } + int i; + for (i = 1000000000; i > 0; i /= 10) { + long tDigit = mEU / i % 10; + if (temp && tDigit != 0) temp = false; + if (!temp) { + tString = tString + tDigit; + if (i != 1) { + int j; + for (j = i; j > 0; ) { + if (j == 1) tString = tString + ","; + j /= 1000; + } + } + } + } + if (tString.equals("")) tString = "0"; + return negative ? ("-" + tString) : tString; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/computer/GT_GUIContainer_RedstoneCircuitBlock.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/computer/GT_GUIContainer_RedstoneCircuitBlock.java index 53d60c3a68..2612ad5592 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/computer/GT_GUIContainer_RedstoneCircuitBlock.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/computer/GT_GUIContainer_RedstoneCircuitBlock.java @@ -1,95 +1,136 @@ package gtPlusPlus.xmod.gregtech.api.gui.computer; -import java.util.ArrayList; -import java.util.List; - import gregtech.api.GregTech_API; import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.util.GT_CircuitryBehavior; import gregtech.api.util.GT_Utility; import gtPlusPlus.core.lib.CORE; +import java.util.ArrayList; +import java.util.List; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.entity.player.InventoryPlayer; public class GT_GUIContainer_RedstoneCircuitBlock extends GT_GUIContainerMetaTile_Machine { - public GT_GUIContainer_RedstoneCircuitBlock(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { - super(new GT_Container_RedstoneCircuitBlock(aInventoryPlayer, aTileEntity), CORE.RES_PATH_GUI + "RedstoneCircuitBlock.png"); - } + public GT_GUIContainer_RedstoneCircuitBlock(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { + super( + new GT_Container_RedstoneCircuitBlock(aInventoryPlayer, aTileEntity), + CORE.RES_PATH_GUI + "RedstoneCircuitBlock.png"); + } - @Override - protected void drawGuiContainerForegroundLayer(int par1, int par2) { - GT_CircuitryBehavior tCircuit = GregTech_API.sCircuitryBehaviors.get(((GT_Container_RedstoneCircuitBlock) mContainer).mGate); - if (tCircuit != null) { - this.fontRendererObj.drawString(tCircuit.getName(), 46, 8, 16448255); - this.fontRendererObj.drawString(tCircuit.getDescription(), 46, 19, 16448255); + @Override + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + GT_CircuitryBehavior tCircuit = + GregTech_API.sCircuitryBehaviors.get(((GT_Container_RedstoneCircuitBlock) mContainer).mGate); + if (tCircuit != null) { + this.fontRendererObj.drawString(tCircuit.getName(), 46, 8, 16448255); + this.fontRendererObj.drawString(tCircuit.getDescription(), 46, 19, 16448255); - this.fontRendererObj.drawString(tCircuit.getDataDescription(((GT_Container_RedstoneCircuitBlock) mContainer).mData, 0), 46, 33, 16448255); - this.fontRendererObj.drawString(tCircuit.getDataDescription(((GT_Container_RedstoneCircuitBlock) mContainer).mData, 1), 46, 44, 16448255); - this.fontRendererObj.drawString(tCircuit.getDataDescription(((GT_Container_RedstoneCircuitBlock) mContainer).mData, 2), 46, 55, 16448255); - this.fontRendererObj.drawString(tCircuit.getDataDescription(((GT_Container_RedstoneCircuitBlock) mContainer).mData, 3), 46, 66, 16448255); + this.fontRendererObj.drawString( + tCircuit.getDataDescription(((GT_Container_RedstoneCircuitBlock) mContainer).mData, 0), + 46, + 33, + 16448255); + this.fontRendererObj.drawString( + tCircuit.getDataDescription(((GT_Container_RedstoneCircuitBlock) mContainer).mData, 1), + 46, + 44, + 16448255); + this.fontRendererObj.drawString( + tCircuit.getDataDescription(((GT_Container_RedstoneCircuitBlock) mContainer).mData, 2), + 46, + 55, + 16448255); + this.fontRendererObj.drawString( + tCircuit.getDataDescription(((GT_Container_RedstoneCircuitBlock) mContainer).mData, 3), + 46, + 66, + 16448255); - String tString; - tString = tCircuit.getDataDisplay(((GT_Container_RedstoneCircuitBlock) mContainer).mData, 0); - this.fontRendererObj.drawString(tString == null ? GT_Utility.parseNumberToString(((GT_Container_RedstoneCircuitBlock) mContainer).mData[0]) : tString, 99, 33, 16448255); - tString = tCircuit.getDataDisplay(((GT_Container_RedstoneCircuitBlock) mContainer).mData, 1); - this.fontRendererObj.drawString(tString == null ? GT_Utility.parseNumberToString(((GT_Container_RedstoneCircuitBlock) mContainer).mData[1]) : tString, 99, 44, 16448255); - tString = tCircuit.getDataDisplay(((GT_Container_RedstoneCircuitBlock) mContainer).mData, 2); - this.fontRendererObj.drawString(tString == null ? GT_Utility.parseNumberToString(((GT_Container_RedstoneCircuitBlock) mContainer).mData[2]) : tString, 99, 55, 16448255); - tString = tCircuit.getDataDisplay(((GT_Container_RedstoneCircuitBlock) mContainer).mData, 3); - this.fontRendererObj.drawString(tString == null ? GT_Utility.parseNumberToString(((GT_Container_RedstoneCircuitBlock) mContainer).mData[3]) : tString, 99, 66, 16448255); - } - this.drawTooltip(par1, par2); - } + String tString; + tString = tCircuit.getDataDisplay(((GT_Container_RedstoneCircuitBlock) mContainer).mData, 0); + this.fontRendererObj.drawString( + tString == null + ? GT_Utility.parseNumberToString(((GT_Container_RedstoneCircuitBlock) mContainer).mData[0]) + : tString, + 99, + 33, + 16448255); + tString = tCircuit.getDataDisplay(((GT_Container_RedstoneCircuitBlock) mContainer).mData, 1); + this.fontRendererObj.drawString( + tString == null + ? GT_Utility.parseNumberToString(((GT_Container_RedstoneCircuitBlock) mContainer).mData[1]) + : tString, + 99, + 44, + 16448255); + tString = tCircuit.getDataDisplay(((GT_Container_RedstoneCircuitBlock) mContainer).mData, 2); + this.fontRendererObj.drawString( + tString == null + ? GT_Utility.parseNumberToString(((GT_Container_RedstoneCircuitBlock) mContainer).mData[2]) + : tString, + 99, + 55, + 16448255); + tString = tCircuit.getDataDisplay(((GT_Container_RedstoneCircuitBlock) mContainer).mData, 3); + this.fontRendererObj.drawString( + tString == null + ? GT_Utility.parseNumberToString(((GT_Container_RedstoneCircuitBlock) mContainer).mData[3]) + : tString, + 99, + 66, + 16448255); + } + this.drawTooltip(par1, par2); + } - @Override - protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { - super.drawGuiContainerBackgroundLayer(par1, par2, par3); - int x = (width - xSize) / 2; - int y = (height - ySize) / 2; - drawTexturedModalRect(x, y, 0, 0, xSize, ySize); + @Override + protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { + super.drawGuiContainerBackgroundLayer(par1, par2, par3); + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + drawTexturedModalRect(x, y, 0, 0, xSize, ySize); - if (mContainer != null) { - if (((GT_Container_RedstoneCircuitBlock) mContainer).mOutput > 0) - drawTexturedModalRect(x + 151, y + 5, 176, 0, 18, 18); - if ((((GT_Container_RedstoneCircuitBlock) mContainer).mActive & 1) > 0) - drawTexturedModalRect(x + 151, y + 23, 176, 18, 18, 18); - if (((GT_Container_RedstoneCircuitBlock) mContainer).mDisplayErrorCode > 0) - if ((((GT_Container_RedstoneCircuitBlock) mContainer).mTileEntity.getTimer() / 5) % 2 == 0) - drawTexturedModalRect(x + 140, y + 9, 194, 0, 7, 7); - else - ; - else - drawTexturedModalRect(x + 140, y + 9, 201, 0, 7, 7); - } - } + if (mContainer != null) { + if (((GT_Container_RedstoneCircuitBlock) mContainer).mOutput > 0) + drawTexturedModalRect(x + 151, y + 5, 176, 0, 18, 18); + if ((((GT_Container_RedstoneCircuitBlock) mContainer).mActive & 1) > 0) + drawTexturedModalRect(x + 151, y + 23, 176, 18, 18, 18); + if (((GT_Container_RedstoneCircuitBlock) mContainer).mDisplayErrorCode > 0) + if ((((GT_Container_RedstoneCircuitBlock) mContainer).mTileEntity.getTimer() / 5) % 2 == 0) + drawTexturedModalRect(x + 140, y + 9, 194, 0, 7, 7); + else + ; + else drawTexturedModalRect(x + 140, y + 9, 201, 0, 7, 7); + } + } - private void drawTooltip(final int x2, final int y2) { - final int xStart = (this.width - this.xSize) / 2; - final int yStart = (this.height - this.ySize) / 2; - final int x3 = x2 - xStart; - final int y3 = y2 - yStart + 5; - final List<String> list = new ArrayList<String>(); + private void drawTooltip(final int x2, final int y2) { + final int xStart = (this.width - this.xSize) / 2; + final int yStart = (this.height - this.ySize) / 2; + final int x3 = x2 - xStart; + final int y3 = y2 - yStart + 5; + final List<String> list = new ArrayList<String>(); - int y = 10; - if (x3 >= 151 && x3 <= 168) { - if (y3 >= y && y3 <= (y + 17)) { - list.add("Toggle EU Output"); - } - if (y3 >= (y + 18) && y3 <= (y + 35)) { - list.add("Toggle Active State"); - } - if (y3 >= (y + 36) && y3 <= (y + 53)) { - list.add("Change Redstone Circuit"); - } - } + int y = 10; + if (x3 >= 151 && x3 <= 168) { + if (y3 >= y && y3 <= (y + 17)) { + list.add("Toggle EU Output"); + } + if (y3 >= (y + 18) && y3 <= (y + 35)) { + list.add("Toggle Active State"); + } + if (y3 >= (y + 36) && y3 <= (y + 53)) { + list.add("Change Redstone Circuit"); + } + } - if (!list.isEmpty()) { - //RenderHelper.enableGUIStandardItemLighting(); - this.drawHoveringText(list, x3, y3, this.fontRendererObj); - RenderHelper.enableGUIStandardItemLighting(); - } - //RenderHelper.enableStandardItemLighting(); - } + if (!list.isEmpty()) { + // RenderHelper.enableGUIStandardItemLighting(); + this.drawHoveringText(list, x3, y3, this.fontRendererObj); + RenderHelper.enableGUIStandardItemLighting(); + } + // RenderHelper.enableStandardItemLighting(); + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/fluidreactor/Container_FluidReactor.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/fluidreactor/Container_FluidReactor.java index cdca065e60..dff58351e0 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/fluidreactor/Container_FluidReactor.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/fluidreactor/Container_FluidReactor.java @@ -1,7 +1,5 @@ package gtPlusPlus.xmod.gregtech.api.gui.fluidreactor; -import java.util.Iterator; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.gui.GT_Container_BasicMachine; @@ -11,9 +9,9 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.slots.SlotChemicalPlantInput; import gtPlusPlus.core.slots.SlotNoInput; -import gtPlusPlus.core.slots.SlotNoInputLogging; import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic.GregtechMetaTileEntity_ChemicalReactor; +import java.util.Iterator; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.ICrafting; @@ -21,164 +19,156 @@ import net.minecraft.item.ItemStack; public class Container_FluidReactor extends GT_Container_BasicMachine { - public boolean mFluidTransfer_1 = false; - public boolean mFluidTransfer_2 = false; - public boolean oFluidTransfer_1 = false; - public boolean oFluidTransfer_2 = false; - - public Container_FluidReactor(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { - super(aInventoryPlayer, aTileEntity); - } - - @Override - public void addSlots(InventoryPlayer aInventoryPlayer) { - - // Gui Buttons - this.addSlotToContainer(new SlotNoInput(this.mTileEntity, 0, 8, 63)); // Fluid 1 - this.addSlotToContainer(new SlotNoInput(this.mTileEntity, 1, 44, 63)); - this.addSlotToContainer(new SlotNoInput(this.mTileEntity, 2, 26, 63)); // Fluid 2 - - int tStartIndex = 3; - // Input Slots - this.addSlotToContainer(new SlotChemicalPlantInput(this.mTileEntity, tStartIndex++, 8, 7)); - this.addSlotToContainer(new SlotChemicalPlantInput(this.mTileEntity, tStartIndex++, 26, 7)); - this.addSlotToContainer(new SlotChemicalPlantInput(this.mTileEntity, tStartIndex++, 44, 7)); - this.addSlotToContainer(new SlotChemicalPlantInput(this.mTileEntity, tStartIndex++, 62, 7)); - - // Output Slots - this.addSlotToContainer(new SlotNoInput(this.mTileEntity, tStartIndex++, 107, 16)); - this.addSlotToContainer(new SlotNoInput(this.mTileEntity, tStartIndex++, 125, 16)); - this.addSlotToContainer(new SlotNoInput(this.mTileEntity, tStartIndex++, 107, 34)); - this.addSlotToContainer(new SlotNoInput(this.mTileEntity, tStartIndex++, 125, 34)); - - // Cell Collector Slot - this.addSlotToContainer(new SlotNoInput(this.mTileEntity, tStartIndex++, 116, 63)); - - - // Inputs Fluids - this.addSlotToContainer(new GT_Slot_Render(this.mTileEntity, tStartIndex++, 8, 42)); - this.addSlotToContainer(new GT_Slot_Render(this.mTileEntity, tStartIndex++, 26, 42)); - this.addSlotToContainer(new GT_Slot_Render(this.mTileEntity, tStartIndex++, 44, 42)); - this.addSlotToContainer(new GT_Slot_Render(this.mTileEntity, tStartIndex++, 62, 42)); - - // Output Fluids - this.addSlotToContainer(new GT_Slot_Render(this.mTileEntity, tStartIndex++, 143, 16)); - this.addSlotToContainer(new GT_Slot_Render(this.mTileEntity, tStartIndex++, 143, 34)); - - - - - } - - public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { - if (aSlotIndex == 0 || aSlotIndex == 2) { - if (this.mTileEntity != null && this.mTileEntity.isServerSide()) { - try { - final IMetaTileEntity aMetaTileEntity = this.mTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) { - return null; - } - if (aMetaTileEntity instanceof GregtechMetaTileEntity_ChemicalReactor) { - //Set Tile - if (aSlotIndex == 0) { - ((GregtechMetaTileEntity_ChemicalReactor)aMetaTileEntity).mFluidTransfer_1 = !((GregtechMetaTileEntity_ChemicalReactor)aMetaTileEntity).mFluidTransfer_1; - } - else if (aSlotIndex == 2) { - ((GregtechMetaTileEntity_ChemicalReactor)aMetaTileEntity).mFluidTransfer_2 = !((GregtechMetaTileEntity_ChemicalReactor)aMetaTileEntity).mFluidTransfer_2; - } - return null; - } - } - catch (Throwable t) { - t.printStackTrace(); - } - } - } - //Logger.INFO("Clicked slot "+aSlotIndex); - return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); - } - - public void detectAndSendChanges() { - super.detectAndSendChanges(); - if (this.mTileEntity != null && this.mTileEntity.isServerSide()) { - try { - Iterator var2 = this.crafters.iterator(); - final IMetaTileEntity aMetaTileEntity = this.mTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) { - Logger.INFO("bad"); - return; - } - if (aMetaTileEntity instanceof GregtechMetaTileEntity_ChemicalReactor) { - //Read from Tile - this.mFluidTransfer_1 = ((GregtechMetaTileEntity_ChemicalReactor)aMetaTileEntity).mFluidTransfer_1; - this.mFluidTransfer_2 = ((GregtechMetaTileEntity_ChemicalReactor)aMetaTileEntity).mFluidTransfer_2; - int mTimer; - mTimer = (int) ReflectionUtils.getField(this.getClass(), "mTimer").get(this); - while (true) { - ICrafting var1; - do { - if (!var2.hasNext()) { - this.oFluidTransfer_1 = this.mFluidTransfer_1; - this.oFluidTransfer_2 = this.mFluidTransfer_2; - return; - } - var1 = (ICrafting) var2.next(); - if (mTimer % 500 == 10 || this.oFluidTransfer_1 != this.mFluidTransfer_1) { - var1.sendProgressBarUpdate(this, -50, this.mFluidTransfer_1 ? 1 : 0); - } - if (mTimer % 500 == 10 || this.oFluidTransfer_2 != this.mFluidTransfer_2) { - var1.sendProgressBarUpdate(this, -51, this.mFluidTransfer_2 ? 1 : 0); - } - } while (mTimer % 500 != 10); - } - } - else { - Logger.INFO("bad cast"); - } - } - catch (IllegalArgumentException | IllegalAccessException e) { - e.printStackTrace(); - } - } - - } - - public void addCraftingToCrafters(ICrafting par1ICrafting) { - super.addCraftingToCrafters(par1ICrafting); - } - - @SideOnly(Side.CLIENT) - public void updateProgressBar(int par1, int par2) { - if (par1 > 0) { - super.updateProgressBar(par1, par2); - } - else { - switch (par1) { - case -50 : - this.mFluidTransfer_1 = par2 != 0; - break; - case -51 : - this.mFluidTransfer_2 = par2 != 0; - break; - default : - break; - } - } - } - - public int getSlotStartIndex() { - return 3; - } - - public int getShiftClickStartIndex() { - return 3; - } - - public int getSlotCount() { - return this.getShiftClickSlotCount() + 5 + 2; - } - - public int getShiftClickSlotCount() { - return 4; - } -}
\ No newline at end of file + public boolean mFluidTransfer_1 = false; + public boolean mFluidTransfer_2 = false; + public boolean oFluidTransfer_1 = false; + public boolean oFluidTransfer_2 = false; + + public Container_FluidReactor(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { + super(aInventoryPlayer, aTileEntity); + } + + @Override + public void addSlots(InventoryPlayer aInventoryPlayer) { + + // Gui Buttons + this.addSlotToContainer(new SlotNoInput(this.mTileEntity, 0, 8, 63)); // Fluid 1 + this.addSlotToContainer(new SlotNoInput(this.mTileEntity, 1, 44, 63)); + this.addSlotToContainer(new SlotNoInput(this.mTileEntity, 2, 26, 63)); // Fluid 2 + + int tStartIndex = 3; + // Input Slots + this.addSlotToContainer(new SlotChemicalPlantInput(this.mTileEntity, tStartIndex++, 8, 7)); + this.addSlotToContainer(new SlotChemicalPlantInput(this.mTileEntity, tStartIndex++, 26, 7)); + this.addSlotToContainer(new SlotChemicalPlantInput(this.mTileEntity, tStartIndex++, 44, 7)); + this.addSlotToContainer(new SlotChemicalPlantInput(this.mTileEntity, tStartIndex++, 62, 7)); + + // Output Slots + this.addSlotToContainer(new SlotNoInput(this.mTileEntity, tStartIndex++, 107, 16)); + this.addSlotToContainer(new SlotNoInput(this.mTileEntity, tStartIndex++, 125, 16)); + this.addSlotToContainer(new SlotNoInput(this.mTileEntity, tStartIndex++, 107, 34)); + this.addSlotToContainer(new SlotNoInput(this.mTileEntity, tStartIndex++, 125, 34)); + + // Cell Collector Slot + this.addSlotToContainer(new SlotNoInput(this.mTileEntity, tStartIndex++, 116, 63)); + + // Inputs Fluids + this.addSlotToContainer(new GT_Slot_Render(this.mTileEntity, tStartIndex++, 8, 42)); + this.addSlotToContainer(new GT_Slot_Render(this.mTileEntity, tStartIndex++, 26, 42)); + this.addSlotToContainer(new GT_Slot_Render(this.mTileEntity, tStartIndex++, 44, 42)); + this.addSlotToContainer(new GT_Slot_Render(this.mTileEntity, tStartIndex++, 62, 42)); + + // Output Fluids + this.addSlotToContainer(new GT_Slot_Render(this.mTileEntity, tStartIndex++, 143, 16)); + this.addSlotToContainer(new GT_Slot_Render(this.mTileEntity, tStartIndex++, 143, 34)); + } + + public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { + if (aSlotIndex == 0 || aSlotIndex == 2) { + if (this.mTileEntity != null && this.mTileEntity.isServerSide()) { + try { + final IMetaTileEntity aMetaTileEntity = this.mTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return null; + } + if (aMetaTileEntity instanceof GregtechMetaTileEntity_ChemicalReactor) { + // Set Tile + if (aSlotIndex == 0) { + ((GregtechMetaTileEntity_ChemicalReactor) aMetaTileEntity).mFluidTransfer_1 = + !((GregtechMetaTileEntity_ChemicalReactor) aMetaTileEntity).mFluidTransfer_1; + } else if (aSlotIndex == 2) { + ((GregtechMetaTileEntity_ChemicalReactor) aMetaTileEntity).mFluidTransfer_2 = + !((GregtechMetaTileEntity_ChemicalReactor) aMetaTileEntity).mFluidTransfer_2; + } + return null; + } + } catch (Throwable t) { + t.printStackTrace(); + } + } + } + // Logger.INFO("Clicked slot "+aSlotIndex); + return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + } + + public void detectAndSendChanges() { + super.detectAndSendChanges(); + if (this.mTileEntity != null && this.mTileEntity.isServerSide()) { + try { + Iterator var2 = this.crafters.iterator(); + final IMetaTileEntity aMetaTileEntity = this.mTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + Logger.INFO("bad"); + return; + } + if (aMetaTileEntity instanceof GregtechMetaTileEntity_ChemicalReactor) { + // Read from Tile + this.mFluidTransfer_1 = ((GregtechMetaTileEntity_ChemicalReactor) aMetaTileEntity).mFluidTransfer_1; + this.mFluidTransfer_2 = ((GregtechMetaTileEntity_ChemicalReactor) aMetaTileEntity).mFluidTransfer_2; + int mTimer; + mTimer = (int) + ReflectionUtils.getField(this.getClass(), "mTimer").get(this); + while (true) { + ICrafting var1; + do { + if (!var2.hasNext()) { + this.oFluidTransfer_1 = this.mFluidTransfer_1; + this.oFluidTransfer_2 = this.mFluidTransfer_2; + return; + } + var1 = (ICrafting) var2.next(); + if (mTimer % 500 == 10 || this.oFluidTransfer_1 != this.mFluidTransfer_1) { + var1.sendProgressBarUpdate(this, -50, this.mFluidTransfer_1 ? 1 : 0); + } + if (mTimer % 500 == 10 || this.oFluidTransfer_2 != this.mFluidTransfer_2) { + var1.sendProgressBarUpdate(this, -51, this.mFluidTransfer_2 ? 1 : 0); + } + } while (mTimer % 500 != 10); + } + } else { + Logger.INFO("bad cast"); + } + } catch (IllegalArgumentException | IllegalAccessException e) { + e.printStackTrace(); + } + } + } + + public void addCraftingToCrafters(ICrafting par1ICrafting) { + super.addCraftingToCrafters(par1ICrafting); + } + + @SideOnly(Side.CLIENT) + public void updateProgressBar(int par1, int par2) { + if (par1 > 0) { + super.updateProgressBar(par1, par2); + } else { + switch (par1) { + case -50: + this.mFluidTransfer_1 = par2 != 0; + break; + case -51: + this.mFluidTransfer_2 = par2 != 0; + break; + default: + break; + } + } + } + + public int getSlotStartIndex() { + return 3; + } + + public int getShiftClickStartIndex() { + return 3; + } + + public int getSlotCount() { + return this.getShiftClickSlotCount() + 5 + 2; + } + + public int getShiftClickSlotCount() { + return 4; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/fluidreactor/GUI_FluidReactor.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/fluidreactor/GUI_FluidReactor.java index 4d35df251c..fa8c9f571d 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/fluidreactor/GUI_FluidReactor.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/fluidreactor/GUI_FluidReactor.java @@ -4,122 +4,132 @@ import gregtech.api.gui.GT_Container_BasicMachine; import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gtPlusPlus.core.lib.CORE; - import java.util.ArrayList; import java.util.List; - import net.minecraft.client.renderer.RenderHelper; import net.minecraft.entity.player.InventoryPlayer; public class GUI_FluidReactor extends GT_GUIContainerMetaTile_Machine { - public final String mName; - public final String mNEI; - public final byte mProgressBarDirection; - public final byte mProgressBarAmount; - - public GUI_FluidReactor(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName, - String aTextureFile, String aNEI) { - this(aInventoryPlayer, aTileEntity, aName, aTextureFile, aNEI, (byte) 0, (byte) 1); - } - - public GUI_FluidReactor(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName, - String aTextureFile, String aNEI, byte aProgressBarDirection, byte aProgressBarAmount) { - super(new Container_FluidReactor(aInventoryPlayer, aTileEntity), CORE.MODID+":textures/gui/FluidReactor.png"); - this.mProgressBarDirection = aProgressBarDirection; - this.mProgressBarAmount = (byte) Math.max(1, aProgressBarAmount); - this.mName = aName; - this.mNEI = aNEI; - } + public final String mName; + public final String mNEI; + public final byte mProgressBarDirection; + public final byte mProgressBarAmount; - protected void drawGuiContainerForegroundLayer(int par1, int par2) { - this.fontRendererObj.drawString(this.mName, 82, 5, 4210752); - this.drawTooltip(par1, par2); - } + public GUI_FluidReactor( + InventoryPlayer aInventoryPlayer, + IGregTechTileEntity aTileEntity, + String aName, + String aTextureFile, + String aNEI) { + this(aInventoryPlayer, aTileEntity, aName, aTextureFile, aNEI, (byte) 0, (byte) 1); + } - private void drawTooltip(int x2, int y2) { - int xStart = (this.width - this.xSize) / 2; - int yStart = (this.height - this.ySize) / 2; - int x = x2 - xStart; - int y = y2 - yStart + 5; - List<String> list = new ArrayList(); - if (y >= 67 && y <= 84) { - if (x >= 7 && x <= 24) { - list.add("Fluid 1 Auto-Output"); - } - if (x >= 25 && x <= 42) { - list.add("Fluid 2 Auto-Output"); - } - if (x >= 43 && x <= 61) { - list.add("Item Auto-Output"); - } - } + public GUI_FluidReactor( + InventoryPlayer aInventoryPlayer, + IGregTechTileEntity aTileEntity, + String aName, + String aTextureFile, + String aNEI, + byte aProgressBarDirection, + byte aProgressBarAmount) { + super(new Container_FluidReactor(aInventoryPlayer, aTileEntity), CORE.MODID + ":textures/gui/FluidReactor.png"); + this.mProgressBarDirection = aProgressBarDirection; + this.mProgressBarAmount = (byte) Math.max(1, aProgressBarAmount); + this.mName = aName; + this.mNEI = aNEI; + } - if (!list.isEmpty()) { - this.drawHoveringText(list, x, y, this.fontRendererObj); - RenderHelper.enableGUIStandardItemLighting(); - } + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + this.fontRendererObj.drawString(this.mName, 82, 5, 4210752); + this.drawTooltip(par1, par2); + } - } + private void drawTooltip(int x2, int y2) { + int xStart = (this.width - this.xSize) / 2; + int yStart = (this.height - this.ySize) / 2; + int x = x2 - xStart; + int y = y2 - yStart + 5; + List<String> list = new ArrayList(); + if (y >= 67 && y <= 84) { + if (x >= 7 && x <= 24) { + list.add("Fluid 1 Auto-Output"); + } + if (x >= 25 && x <= 42) { + list.add("Fluid 2 Auto-Output"); + } + if (x >= 43 && x <= 61) { + list.add("Item Auto-Output"); + } + } - protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { - super.drawGuiContainerBackgroundLayer(par1, par2, par3); - int x = (this.width - this.xSize) / 2; - int y = (this.height - this.ySize) / 2; - this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); - if (this.mContainer != null) { - if (((Container_FluidReactor) this.mContainer).mFluidTransfer_1) { - this.drawTexturedModalRect(x + 7, y + 62, 176, 18, 18, 18); - } - if (((Container_FluidReactor) this.mContainer).mFluidTransfer_2) { - this.drawTexturedModalRect(x + 25, y + 62, 194, 18, 18, 18); - } - if (((GT_Container_BasicMachine) this.mContainer).mItemTransfer) { - this.drawTexturedModalRect(x + 43, y + 62, 176, 36, 18, 18); - } + if (!list.isEmpty()) { + this.drawHoveringText(list, x, y, this.fontRendererObj); + RenderHelper.enableGUIStandardItemLighting(); + } + } - if (((GT_Container_BasicMachine) this.mContainer).mStuttering) { - this.drawTexturedModalRect(x + 79, y + 44, 176, 54, 18, 18); - } + protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { + super.drawGuiContainerBackgroundLayer(par1, par2, par3); + int x = (this.width - this.xSize) / 2; + int y = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); + if (this.mContainer != null) { + if (((Container_FluidReactor) this.mContainer).mFluidTransfer_1) { + this.drawTexturedModalRect(x + 7, y + 62, 176, 18, 18, 18); + } + if (((Container_FluidReactor) this.mContainer).mFluidTransfer_2) { + this.drawTexturedModalRect(x + 25, y + 62, 194, 18, 18, 18); + } + if (((GT_Container_BasicMachine) this.mContainer).mItemTransfer) { + this.drawTexturedModalRect(x + 43, y + 62, 176, 36, 18, 18); + } - if (this.mContainer.mMaxProgressTime > 0) { - int tSize = this.mProgressBarDirection < 2 ? 20 : 18; - int tProgress = Math - .max(1, Math - .min(tSize * this.mProgressBarAmount, - (this.mContainer.mProgressTime > 0 ? 1 : 0) + this.mContainer.mProgressTime - * tSize * this.mProgressBarAmount / this.mContainer.mMaxProgressTime)) - % (tSize + 1); - switch (this.mProgressBarDirection) { - case 0 : - this.drawTexturedModalRect(x + 82, y + 24, 176, 0, tProgress, 18); - break; - case 1 : - this.drawTexturedModalRect(x + 82 + 20 - tProgress, y + 24, 196 - tProgress, 0, tProgress, 18); - break; - case 2 : - this.drawTexturedModalRect(x + 82, y + 24, 176, 0, 20, tProgress); - break; - case 3 : - this.drawTexturedModalRect(x + 82, y + 24 + 18 - tProgress, 176, 18 - tProgress, 20, tProgress); - break; - case 4 : - tProgress = 20 - tProgress; - this.drawTexturedModalRect(x + 82, y + 24, 176, 0, tProgress, 18); - break; - case 5 : - tProgress = 20 - tProgress; - this.drawTexturedModalRect(x + 82 + 20 - tProgress, y + 24, 196 - tProgress, 0, tProgress, 18); - break; - case 6 : - tProgress = 18 - tProgress; - this.drawTexturedModalRect(x + 82, y + 24, 176, 0, 20, tProgress); - break; - case 7 : - tProgress = 18 - tProgress; - this.drawTexturedModalRect(x + 82, y + 24 + 18 - tProgress, 176, 18 - tProgress, 20, tProgress); - } - } - } + if (((GT_Container_BasicMachine) this.mContainer).mStuttering) { + this.drawTexturedModalRect(x + 79, y + 44, 176, 54, 18, 18); + } - } -}
\ No newline at end of file + if (this.mContainer.mMaxProgressTime > 0) { + int tSize = this.mProgressBarDirection < 2 ? 20 : 18; + int tProgress = Math.max( + 1, + Math.min( + tSize * this.mProgressBarAmount, + (this.mContainer.mProgressTime > 0 ? 1 : 0) + + this.mContainer.mProgressTime + * tSize + * this.mProgressBarAmount + / this.mContainer.mMaxProgressTime)) + % (tSize + 1); + switch (this.mProgressBarDirection) { + case 0: + this.drawTexturedModalRect(x + 82, y + 24, 176, 0, tProgress, 18); + break; + case 1: + this.drawTexturedModalRect(x + 82 + 20 - tProgress, y + 24, 196 - tProgress, 0, tProgress, 18); + break; + case 2: + this.drawTexturedModalRect(x + 82, y + 24, 176, 0, 20, tProgress); + break; + case 3: + this.drawTexturedModalRect(x + 82, y + 24 + 18 - tProgress, 176, 18 - tProgress, 20, tProgress); + break; + case 4: + tProgress = 20 - tProgress; + this.drawTexturedModalRect(x + 82, y + 24, 176, 0, tProgress, 18); + break; + case 5: + tProgress = 20 - tProgress; + this.drawTexturedModalRect(x + 82 + 20 - tProgress, y + 24, 196 - tProgress, 0, tProgress, 18); + break; + case 6: + tProgress = 18 - tProgress; + this.drawTexturedModalRect(x + 82, y + 24, 176, 0, 20, tProgress); + break; + case 7: + tProgress = 18 - tProgress; + this.drawTexturedModalRect(x + 82, y + 24 + 18 - tProgress, 176, 18 - tProgress, 20, tProgress); + } + } + } + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/CONTAINER_1by1_Turbine.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/CONTAINER_1by1_Turbine.java index 606880d6e9..836e7198c3 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/CONTAINER_1by1_Turbine.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/CONTAINER_1by1_Turbine.java @@ -2,7 +2,6 @@ package gtPlusPlus.xmod.gregtech.api.gui.hatches; import gregtech.api.gui.GT_Container_1by1; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.items.GT_MetaGenerated_Tool; import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.turbines.GregtechMetaTileEntity_LargerTurbineBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; @@ -21,37 +20,41 @@ public class CONTAINER_1by1_Turbine extends GT_Container_1by1 { addSlotToContainer(new SlotTurbine(mTileEntity, 0, 80, 35)); } - @Override - public int getShiftClickSlotCount() { - return 0; - } + @Override + public int getShiftClickSlotCount() { + return 0; + } + + @Override + public boolean canDragIntoSlot(Slot par1Slot) { + return false; + } - @Override - public boolean canDragIntoSlot(Slot par1Slot) { - return false; - } - public class SlotTurbine extends Slot { - public SlotTurbine(final IInventory inventory, final int x, final int y, final int z) { - super(inventory, x, y, z); - } - @Override - public boolean isItemValid(final ItemStack itemstack) { - return GregtechMetaTileEntity_LargerTurbineBase.isValidTurbine(itemstack); - } - @Override - public int getSlotStackLimit() { - return 1; - } - @Override - public boolean canTakeStack(EntityPlayer p_82869_1_) { - return false; - } - @Override - public void putStack(ItemStack aStack) { - if (isItemValid(aStack)) { - this.inventory.setInventorySlotContents(0, aStack); - } - } - } + public SlotTurbine(final IInventory inventory, final int x, final int y, final int z) { + super(inventory, x, y, z); + } + + @Override + public boolean isItemValid(final ItemStack itemstack) { + return GregtechMetaTileEntity_LargerTurbineBase.isValidTurbine(itemstack); + } + + @Override + public int getSlotStackLimit() { + return 1; + } + + @Override + public boolean canTakeStack(EntityPlayer p_82869_1_) { + return false; + } + + @Override + public void putStack(ItemStack aStack) { + if (isItemValid(aStack)) { + this.inventory.setInventorySlotContents(0, aStack); + } + } + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/CONTAINER_2by2.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/CONTAINER_2by2.java index 1d396811c1..60106825a0 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/CONTAINER_2by2.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/CONTAINER_2by2.java @@ -1,10 +1,9 @@ package gtPlusPlus.xmod.gregtech.api.gui.hatches; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Slot; - import gregtech.api.gui.GT_ContainerMetaTile_Machine; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Slot; public class CONTAINER_2by2 extends GT_ContainerMetaTile_Machine { diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/CONTAINER_4by4.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/CONTAINER_4by4.java index 8efe60a06e..0c011f164b 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/CONTAINER_4by4.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/CONTAINER_4by4.java @@ -1,10 +1,9 @@ package gtPlusPlus.xmod.gregtech.api.gui.hatches; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Slot; - import gregtech.api.gui.GT_ContainerMetaTile_Machine; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Slot; public class CONTAINER_4by4 extends GT_ContainerMetaTile_Machine { diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/CONTAINER_HatchNbtConsumable.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/CONTAINER_HatchNbtConsumable.java index 9596d41387..9f3f42bb9b 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/CONTAINER_HatchNbtConsumable.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/CONTAINER_HatchNbtConsumable.java @@ -1,13 +1,12 @@ package gtPlusPlus.xmod.gregtech.api.gui.hatches; -import java.util.Iterator; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.gui.GT_Container; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.util.GT_LanguageManager; import gtPlusPlus.core.slots.SlotNoInput; +import java.util.Iterator; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.ICrafting; @@ -17,18 +16,19 @@ import net.minecraft.item.ItemStack; public class CONTAINER_HatchNbtConsumable extends GT_Container { - public final int mInputslotCount; - private final int mTotalSlotCount; - - public CONTAINER_HatchNbtConsumable(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, int aInputslotCount) { + public final int mInputslotCount; + private final int mTotalSlotCount; + + public CONTAINER_HatchNbtConsumable( + InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, int aInputslotCount) { super(aInventoryPlayer, aTileEntity); - mInputslotCount = aInputslotCount; - mTotalSlotCount = aInputslotCount*2; + mInputslotCount = aInputslotCount; + mTotalSlotCount = aInputslotCount * 2; mTileEntity = aTileEntity; if (mTileEntity != null && mTileEntity.getMetaTileEntity() != null) { addSlots(aInventoryPlayer); if (doesBindPlayerInventory()) { - bindPlayerInventory(aInventoryPlayer); + bindPlayerInventory(aInventoryPlayer); } detectAndSendChanges(); } else { @@ -38,63 +38,61 @@ public class CONTAINER_HatchNbtConsumable extends GT_Container { @Override public void addSlots(InventoryPlayer aInventoryPlayer) { - if (mTotalSlotCount == 8) { - final int aSlotYStart = 26; - final int aSlotYFinish = aSlotYStart + (18*2); - final int aSlotXStart1 = 26; - final int aSlotXFinish1 = aSlotXStart1 + (18*2); - final int aSlotXStart2 = 116; - final int aSlotXFinish2 = aSlotXStart2 + (18*2); - int aSlotID = 0; - for (int y = aSlotYStart; y < aSlotYFinish; y += 18) { - for (int x = aSlotXStart1; x < aSlotXFinish1; x += 18) { - addSlotToContainer(new Slot(mTileEntity, aSlotID++, x, y)); - } - } - for (int y = aSlotYStart; y < aSlotYFinish; y += 18) { - for (int x = aSlotXStart2; x < aSlotXFinish2; x += 18) { - addSlotToContainer(new ViewingSlot(mTileEntity, aSlotID++, x, y)); - } - } - } - else if (mTotalSlotCount == 18) { - int aSlotYStart = 20; - int aSlotYFinish = aSlotYStart + (18*3); - int aSlotXStart1 = 26; - int aSlotXFinish1 = aSlotXStart1 + (18*3); - int aSlotXStart2 = 98; - int aSlotXFinish2 = aSlotXStart2 + (18*3); - int aSlotID = 0; - for (int y = aSlotYStart; y < aSlotYFinish; y += 18) { - for (int x = aSlotXStart1; x < aSlotXFinish1; x += 18) { - addSlotToContainer(new Slot(mTileEntity, aSlotID++, x, y)); - } - } - for (int y = aSlotYStart; y < aSlotYFinish; y += 18) { - for (int x = aSlotXStart2; x < aSlotXFinish2; x += 18) { - addSlotToContainer(new ViewingSlot(mTileEntity, aSlotID++, x, y)); - } - } - } - else if (mTotalSlotCount == 32) { - int aSlotYStart = 8; - int aSlotYFinish = aSlotYStart + (18*4); - int aSlotXStart1 = 8; - int aSlotXFinish1 = aSlotXStart1 + (18*4); - int aSlotXStart2 = 97; - int aSlotXFinish2 = aSlotXStart2 + (18*4); - int aSlotID = 0; - for (int y = aSlotYStart; y < aSlotYFinish; y += 18) { - for (int x = aSlotXStart1; x < aSlotXFinish1; x += 18) { - addSlotToContainer(new Slot(mTileEntity, aSlotID++, x, y)); - } - } - for (int y = aSlotYStart; y < aSlotYFinish; y += 18) { - for (int x = aSlotXStart2; x < aSlotXFinish2; x += 18) { - addSlotToContainer(new ViewingSlot(mTileEntity, aSlotID++, x, y)); - } - } - } + if (mTotalSlotCount == 8) { + final int aSlotYStart = 26; + final int aSlotYFinish = aSlotYStart + (18 * 2); + final int aSlotXStart1 = 26; + final int aSlotXFinish1 = aSlotXStart1 + (18 * 2); + final int aSlotXStart2 = 116; + final int aSlotXFinish2 = aSlotXStart2 + (18 * 2); + int aSlotID = 0; + for (int y = aSlotYStart; y < aSlotYFinish; y += 18) { + for (int x = aSlotXStart1; x < aSlotXFinish1; x += 18) { + addSlotToContainer(new Slot(mTileEntity, aSlotID++, x, y)); + } + } + for (int y = aSlotYStart; y < aSlotYFinish; y += 18) { + for (int x = aSlotXStart2; x < aSlotXFinish2; x += 18) { + addSlotToContainer(new ViewingSlot(mTileEntity, aSlotID++, x, y)); + } + } + } else if (mTotalSlotCount == 18) { + int aSlotYStart = 20; + int aSlotYFinish = aSlotYStart + (18 * 3); + int aSlotXStart1 = 26; + int aSlotXFinish1 = aSlotXStart1 + (18 * 3); + int aSlotXStart2 = 98; + int aSlotXFinish2 = aSlotXStart2 + (18 * 3); + int aSlotID = 0; + for (int y = aSlotYStart; y < aSlotYFinish; y += 18) { + for (int x = aSlotXStart1; x < aSlotXFinish1; x += 18) { + addSlotToContainer(new Slot(mTileEntity, aSlotID++, x, y)); + } + } + for (int y = aSlotYStart; y < aSlotYFinish; y += 18) { + for (int x = aSlotXStart2; x < aSlotXFinish2; x += 18) { + addSlotToContainer(new ViewingSlot(mTileEntity, aSlotID++, x, y)); + } + } + } else if (mTotalSlotCount == 32) { + int aSlotYStart = 8; + int aSlotYFinish = aSlotYStart + (18 * 4); + int aSlotXStart1 = 8; + int aSlotXFinish1 = aSlotXStart1 + (18 * 4); + int aSlotXStart2 = 97; + int aSlotXFinish2 = aSlotXStart2 + (18 * 4); + int aSlotID = 0; + for (int y = aSlotYStart; y < aSlotYFinish; y += 18) { + for (int x = aSlotXStart1; x < aSlotXFinish1; x += 18) { + addSlotToContainer(new Slot(mTileEntity, aSlotID++, x, y)); + } + } + for (int y = aSlotYStart; y < aSlotYFinish; y += 18) { + for (int x = aSlotXStart2; x < aSlotXFinish2; x += 18) { + addSlotToContainer(new ViewingSlot(mTileEntity, aSlotID++, x, y)); + } + } + } } @Override @@ -106,16 +104,35 @@ public class CONTAINER_HatchNbtConsumable extends GT_Container { public int getShiftClickSlotCount() { return mInputslotCount; } - + /* * Uselss stuff copied from GT */ - - public int mActive = 0, mMaxProgressTime = 0, mProgressTime = 0, mEnergy = 0, mSteam = 0, mSteamStorage = 0, mStorage = 0, mOutput = 0, mInput = 0, mID = 0, mDisplayErrorCode = 0; - private int oActive = 0, oMaxProgressTime = 0, oProgressTime = 0, oEnergy = 0, oSteam = 0, oSteamStorage = 0, oStorage = 0, oOutput = 0, oInput = 0, oID = 0, oDisplayErrorCode = 0, mTimer = 0; + public int mActive = 0, + mMaxProgressTime = 0, + mProgressTime = 0, + mEnergy = 0, + mSteam = 0, + mSteamStorage = 0, + mStorage = 0, + mOutput = 0, + mInput = 0, + mID = 0, + mDisplayErrorCode = 0; + private int oActive = 0, + oMaxProgressTime = 0, + oProgressTime = 0, + oEnergy = 0, + oSteam = 0, + oSteamStorage = 0, + oStorage = 0, + oOutput = 0, + oInput = 0, + oID = 0, + oDisplayErrorCode = 0, + mTimer = 0; - @Override public void detectAndSendChanges() { super.detectAndSendChanges(); @@ -252,31 +269,30 @@ public class CONTAINER_HatchNbtConsumable extends GT_Container { public boolean canInteractWith(EntityPlayer player) { return mTileEntity.isUseableByPlayer(player); } - - public String trans(String aKey, String aEnglish){ - return GT_LanguageManager.addStringLocalization("Interaction_DESCRIPTION_Index_"+aKey, aEnglish, false); + + public String trans(String aKey, String aEnglish) { + return GT_LanguageManager.addStringLocalization("Interaction_DESCRIPTION_Index_" + aKey, aEnglish, false); } - + private static class ViewingSlot extends SlotNoInput { - public ViewingSlot(IInventory inventory, int index, int x, int y) { - super(inventory, index, x, y); - } + public ViewingSlot(IInventory inventory, int index, int x, int y) { + super(inventory, index, x, y); + } - @Override - public boolean isItemValid(ItemStack itemstack) { - return false; - } + @Override + public boolean isItemValid(ItemStack itemstack) { + return false; + } - @Override - public int getSlotStackLimit() { - return 1; - } + @Override + public int getSlotStackLimit() { + return 1; + } - @Override - public boolean canTakeStack(EntityPlayer p_82869_1_) { - return true; - } - + @Override + public boolean canTakeStack(EntityPlayer p_82869_1_) { + return true; + } } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/GUI_1by1_Turbine.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/GUI_1by1_Turbine.java index 5623f0e224..cd0381a1f1 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/GUI_1by1_Turbine.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/GUI_1by1_Turbine.java @@ -1,11 +1,10 @@ package gtPlusPlus.xmod.gregtech.api.gui.hatches; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import net.minecraft.entity.player.InventoryPlayer; - import static gregtech.api.enums.GT_Values.RES_PATH_GUI; import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import net.minecraft.entity.player.InventoryPlayer; public class GUI_1by1_Turbine extends GT_GUIContainerMetaTile_Machine { @@ -15,8 +14,9 @@ public class GUI_1by1_Turbine extends GT_GUIContainerMetaTile_Machine { super(new CONTAINER_1by1_Turbine(aInventoryPlayer, aTileEntity), RES_PATH_GUI + "1by1.png"); mName = aName; } - - public GUI_1by1_Turbine(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName, String aBackground) { + + public GUI_1by1_Turbine( + InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName, String aBackground) { super(new CONTAINER_1by1_Turbine(aInventoryPlayer, aTileEntity), RES_PATH_GUI + aBackground + "1by1.png"); mName = aName; } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/GUI_2by2.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/GUI_2by2.java index b427a632f7..c31b74b0f8 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/GUI_2by2.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/GUI_2by2.java @@ -2,21 +2,29 @@ package gtPlusPlus.xmod.gregtech.api.gui.hatches; import static gregtech.api.enums.GT_Values.RES_PATH_GUI; -import net.minecraft.entity.player.InventoryPlayer; - import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import net.minecraft.entity.player.InventoryPlayer; public class GUI_2by2 extends GT_GUIContainerMetaTile_Machine { private final String mName; - public GUI_2by2(CONTAINER_2by2 containerType, InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName) { + public GUI_2by2( + CONTAINER_2by2 containerType, + InventoryPlayer aInventoryPlayer, + IGregTechTileEntity aTileEntity, + String aName) { super(containerType, RES_PATH_GUI + "2by2.png"); mName = aName; } - - public GUI_2by2(CONTAINER_2by2 containerType, InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName, String aBackground) { + + public GUI_2by2( + CONTAINER_2by2 containerType, + InventoryPlayer aInventoryPlayer, + IGregTechTileEntity aTileEntity, + String aName, + String aBackground) { super(containerType, RES_PATH_GUI + aBackground + "2by2.png"); mName = aName; } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/GUI_4by4.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/GUI_4by4.java index aced4342b3..379d1d7941 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/GUI_4by4.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/GUI_4by4.java @@ -2,21 +2,29 @@ package gtPlusPlus.xmod.gregtech.api.gui.hatches; import static gregtech.api.enums.GT_Values.RES_PATH_GUI; -import net.minecraft.entity.player.InventoryPlayer; - import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import net.minecraft.entity.player.InventoryPlayer; public class GUI_4by4 extends GT_GUIContainerMetaTile_Machine { private final String mName; - public GUI_4by4(CONTAINER_4by4 containerType, InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName) { + public GUI_4by4( + CONTAINER_4by4 containerType, + InventoryPlayer aInventoryPlayer, + IGregTechTileEntity aTileEntity, + String aName) { super(containerType, RES_PATH_GUI + "4by4.png"); mName = aName; } - - public GUI_4by4(CONTAINER_4by4 containerType, InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName, String aBackground) { + + public GUI_4by4( + CONTAINER_4by4 containerType, + InventoryPlayer aInventoryPlayer, + IGregTechTileEntity aTileEntity, + String aName, + String aBackground) { super(containerType, RES_PATH_GUI + aBackground + "4by4.png"); mName = aName; } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/GUI_HatchNbtConsumable.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/GUI_HatchNbtConsumable.java index dd19571646..47d24764cc 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/GUI_HatchNbtConsumable.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/GUI_HatchNbtConsumable.java @@ -7,46 +7,42 @@ import gregtech.api.gui.GT_GUIContainer; public class GUI_HatchNbtConsumable extends GT_GUIContainer { private final String mName; - private final int mTotalSlotCount; + private final int mTotalSlotCount; public final CONTAINER_HatchNbtConsumable mContainer; - + public GUI_HatchNbtConsumable(CONTAINER_HatchNbtConsumable aContainer, String aName) { - super(aContainer, RES_PATH_GUI + getTextureForGUI(aContainer.mInputslotCount*2)+".png"); + super(aContainer, RES_PATH_GUI + getTextureForGUI(aContainer.mInputslotCount * 2) + ".png"); mContainer = aContainer; mName = aName; - mTotalSlotCount = aContainer.mInputslotCount*2; - } - - private static final String getTextureForGUI(int aTotalSlotCOunt) { - if (aTotalSlotCOunt == 18) { - return "HatchNbtConsumable_3By3"; - } - else if (aTotalSlotCOunt == 32) { - return "HatchNbtConsumable_4By4"; - } - else { - return "HatchNbtConsumable_2By2"; - } + mTotalSlotCount = aContainer.mInputslotCount * 2; + } + + private static final String getTextureForGUI(int aTotalSlotCOunt) { + if (aTotalSlotCOunt == 18) { + return "HatchNbtConsumable_3By3"; + } else if (aTotalSlotCOunt == 32) { + return "HatchNbtConsumable_4By4"; + } else { + return "HatchNbtConsumable_2By2"; + } } @Override protected void drawGuiContainerForegroundLayer(int par1, int par2) { - if (mTotalSlotCount == 18) { + if (mTotalSlotCount == 18) { fontRendererObj.drawString(mName, 8, 4, 4210752); fontRendererObj.drawString("Stock", 25, 14, 4210752); - fontRendererObj.drawString("Active", 115, 14, 4210752); - } - else if (mTotalSlotCount == 32) { - //fontRendererObj.drawString("Slots: "+mTotalSlotCount, 8, 4, 4210752); - //fontRendererObj.drawString(mName, 8, 4, 4210752); - //fontRendererObj.drawString("Stock", 25, 16, 4210752); - //fontRendererObj.drawString("Active", 115, 16, 4210752); - } - else { + fontRendererObj.drawString("Active", 115, 14, 4210752); + } else if (mTotalSlotCount == 32) { + // fontRendererObj.drawString("Slots: "+mTotalSlotCount, 8, 4, 4210752); + // fontRendererObj.drawString(mName, 8, 4, 4210752); + // fontRendererObj.drawString("Stock", 25, 16, 4210752); + // fontRendererObj.drawString("Active", 115, 16, 4210752); + } else { fontRendererObj.drawString(mName, 8, 4, 4210752); fontRendererObj.drawString("Stock", 25, 16, 4210752); - fontRendererObj.drawString("Active", 115, 16, 4210752); - } + fontRendererObj.drawString("Active", 115, 16, 4210752); + } } @Override diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/charge/CONTAINER_Electric_2by2.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/charge/CONTAINER_Electric_2by2.java index 00d022c481..52627305e2 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/charge/CONTAINER_Electric_2by2.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/charge/CONTAINER_Electric_2by2.java @@ -1,24 +1,21 @@ package gtPlusPlus.xmod.gregtech.api.gui.hatches.charge; -import net.minecraft.entity.player.InventoryPlayer; - import gregtech.api.interfaces.tileentity.IGregTechTileEntity; - import gtPlusPlus.core.slots.SlotElectric; import gtPlusPlus.xmod.gregtech.api.gui.hatches.CONTAINER_2by2; +import net.minecraft.entity.player.InventoryPlayer; -public class CONTAINER_Electric_2by2 extends CONTAINER_2by2{ +public class CONTAINER_Electric_2by2 extends CONTAINER_2by2 { - public CONTAINER_Electric_2by2(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { - super(aInventoryPlayer, aTileEntity); - } - - @Override + public CONTAINER_Electric_2by2(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { + super(aInventoryPlayer, aTileEntity); + } + + @Override public void addSlots(InventoryPlayer aInventoryPlayer) { addSlotToContainer(new SlotElectric(mTileEntity, 0, 71, 26)); addSlotToContainer(new SlotElectric(mTileEntity, 1, 89, 26)); addSlotToContainer(new SlotElectric(mTileEntity, 2, 71, 44)); addSlotToContainer(new SlotElectric(mTileEntity, 3, 89, 44)); } - } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/charge/CONTAINER_Electric_4by4.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/charge/CONTAINER_Electric_4by4.java index 1f833eb3cb..64f0f00fbd 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/charge/CONTAINER_Electric_4by4.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/charge/CONTAINER_Electric_4by4.java @@ -1,18 +1,15 @@ package gtPlusPlus.xmod.gregtech.api.gui.hatches.charge; -import net.minecraft.entity.player.InventoryPlayer; - import gregtech.api.interfaces.tileentity.IGregTechTileEntity; - import gtPlusPlus.core.slots.SlotElectric; import gtPlusPlus.xmod.gregtech.api.gui.hatches.CONTAINER_4by4; +import net.minecraft.entity.player.InventoryPlayer; -public class CONTAINER_Electric_4by4 extends CONTAINER_4by4{ - - public CONTAINER_Electric_4by4(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { - super(aInventoryPlayer, aTileEntity); - } +public class CONTAINER_Electric_4by4 extends CONTAINER_4by4 { + public CONTAINER_Electric_4by4(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { + super(aInventoryPlayer, aTileEntity); + } @Override public void addSlots(InventoryPlayer aInventoryPlayer) { @@ -33,5 +30,4 @@ public class CONTAINER_Electric_4by4 extends CONTAINER_4by4{ addSlotToContainer(new SlotElectric(mTileEntity, 14, 89, 62)); addSlotToContainer(new SlotElectric(mTileEntity, 15, 107, 62)); } - } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/charge/GUI_Electric_2by2.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/charge/GUI_Electric_2by2.java index 9be7104bbc..de06a97aaa 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/charge/GUI_Electric_2by2.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/charge/GUI_Electric_2by2.java @@ -2,20 +2,22 @@ package gtPlusPlus.xmod.gregtech.api.gui.hatches.charge; import static gregtech.api.enums.GT_Values.RES_PATH_GUI; -import net.minecraft.entity.player.InventoryPlayer; - import gregtech.api.interfaces.tileentity.IGregTechTileEntity; - import gtPlusPlus.xmod.gregtech.api.gui.hatches.GUI_2by2; +import net.minecraft.entity.player.InventoryPlayer; -public class GUI_Electric_2by2 extends GUI_2by2{ +public class GUI_Electric_2by2 extends GUI_2by2 { - public GUI_Electric_2by2(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName) { - super(new CONTAINER_Electric_2by2(aInventoryPlayer, aTileEntity), aInventoryPlayer, aTileEntity, aName); - } - - public GUI_Electric_2by2(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName, String aBackground) { - super(new CONTAINER_Electric_2by2(aInventoryPlayer, aTileEntity), aInventoryPlayer, aTileEntity, RES_PATH_GUI + aBackground + "2by2.png"); + public GUI_Electric_2by2(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName) { + super(new CONTAINER_Electric_2by2(aInventoryPlayer, aTileEntity), aInventoryPlayer, aTileEntity, aName); } + public GUI_Electric_2by2( + InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName, String aBackground) { + super( + new CONTAINER_Electric_2by2(aInventoryPlayer, aTileEntity), + aInventoryPlayer, + aTileEntity, + RES_PATH_GUI + aBackground + "2by2.png"); + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/charge/GUI_Electric_4by4.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/charge/GUI_Electric_4by4.java index ed3fce5e2c..16b1a44fea 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/charge/GUI_Electric_4by4.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/charge/GUI_Electric_4by4.java @@ -2,21 +2,22 @@ package gtPlusPlus.xmod.gregtech.api.gui.hatches.charge; import static gregtech.api.enums.GT_Values.RES_PATH_GUI; -import net.minecraft.entity.player.InventoryPlayer; - import gregtech.api.interfaces.tileentity.IGregTechTileEntity; - import gtPlusPlus.xmod.gregtech.api.gui.hatches.GUI_4by4; +import net.minecraft.entity.player.InventoryPlayer; -public class GUI_Electric_4by4 extends GUI_4by4{ - - public GUI_Electric_4by4(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName) { - super(new CONTAINER_Electric_4by4(aInventoryPlayer, aTileEntity), aInventoryPlayer, aTileEntity, aName); - } - - public GUI_Electric_4by4(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName, String aBackground) { - super(new CONTAINER_Electric_4by4(aInventoryPlayer, aTileEntity), aInventoryPlayer, aTileEntity, RES_PATH_GUI + aBackground + "4by4.png"); +public class GUI_Electric_4by4 extends GUI_4by4 { + public GUI_Electric_4by4(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName) { + super(new CONTAINER_Electric_4by4(aInventoryPlayer, aTileEntity), aInventoryPlayer, aTileEntity, aName); } + public GUI_Electric_4by4( + InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName, String aBackground) { + super( + new CONTAINER_Electric_4by4(aInventoryPlayer, aTileEntity), + aInventoryPlayer, + aTileEntity, + RES_PATH_GUI + aBackground + "4by4.png"); + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/power/CONTAINER_BasicTank.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/power/CONTAINER_BasicTank.java index 9a58e74ec4..71c362b88b 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/power/CONTAINER_BasicTank.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/power/CONTAINER_BasicTank.java @@ -7,63 +7,60 @@ import gregtech.api.gui.GT_Slot_Output; import gregtech.api.gui.GT_Slot_Render; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gtPlusPlus.xmod.gregtech.api.metatileentity.custom.power.GTPP_MTE_BasicTank; - import java.util.Iterator; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.ICrafting; import net.minecraft.inventory.Slot; public class CONTAINER_BasicTank extends GT_ContainerMetaTile_Machine { - public int mContent = 0; - - public CONTAINER_BasicTank(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { - super(aInventoryPlayer, aTileEntity); - } - - public void addSlots(InventoryPlayer aInventoryPlayer) { - this.addSlotToContainer(new Slot(this.mTileEntity, 0, 80, 17)); - this.addSlotToContainer(new GT_Slot_Output(this.mTileEntity, 1, 80, 53)); - this.addSlotToContainer(new GT_Slot_Render(this.mTileEntity, 2, 59, 42)); - } + public int mContent = 0; - public void detectAndSendChanges() { - super.detectAndSendChanges(); - if (!this.mTileEntity.isClientSide() && this.mTileEntity.getMetaTileEntity() != null) { - if (((GTPP_MTE_BasicTank) this.mTileEntity.getMetaTileEntity()).mFluid != null) { - this.mContent = ((GTPP_MTE_BasicTank) this.mTileEntity.getMetaTileEntity()).mFluid.amount; - } else { - this.mContent = 0; - } + public CONTAINER_BasicTank(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { + super(aInventoryPlayer, aTileEntity); + } - Iterator var2 = this.crafters.iterator(); + public void addSlots(InventoryPlayer aInventoryPlayer) { + this.addSlotToContainer(new Slot(this.mTileEntity, 0, 80, 17)); + this.addSlotToContainer(new GT_Slot_Output(this.mTileEntity, 1, 80, 53)); + this.addSlotToContainer(new GT_Slot_Render(this.mTileEntity, 2, 59, 42)); + } - while (var2.hasNext()) { - ICrafting var1 = (ICrafting) var2.next(); - var1.sendProgressBarUpdate(this, 100, this.mContent & 'ï¿¿'); - var1.sendProgressBarUpdate(this, 101, this.mContent >>> 16); - } + public void detectAndSendChanges() { + super.detectAndSendChanges(); + if (!this.mTileEntity.isClientSide() && this.mTileEntity.getMetaTileEntity() != null) { + if (((GTPP_MTE_BasicTank) this.mTileEntity.getMetaTileEntity()).mFluid != null) { + this.mContent = ((GTPP_MTE_BasicTank) this.mTileEntity.getMetaTileEntity()).mFluid.amount; + } else { + this.mContent = 0; + } - } - } + Iterator var2 = this.crafters.iterator(); - @SideOnly(Side.CLIENT) - public void updateProgressBar(int par1, int par2) { - super.updateProgressBar(par1, par2); - switch (par1) { - case 100 : - this.mContent = this.mContent & -65536 | par2; - break; - case 101 : - this.mContent = this.mContent & 'ï¿¿' | par2 << 16; - } + while (var2.hasNext()) { + ICrafting var1 = (ICrafting) var2.next(); + var1.sendProgressBarUpdate(this, 100, this.mContent & 'ï¿¿'); + var1.sendProgressBarUpdate(this, 101, this.mContent >>> 16); + } + } + } - } + @SideOnly(Side.CLIENT) + public void updateProgressBar(int par1, int par2) { + super.updateProgressBar(par1, par2); + switch (par1) { + case 100: + this.mContent = this.mContent & -65536 | par2; + break; + case 101: + this.mContent = this.mContent & 'ï¿¿' | par2 << 16; + } + } - public int getSlotCount() { - return 2; - } + public int getSlotCount() { + return 2; + } - public int getShiftClickSlotCount() { - return 1; - } -}
\ No newline at end of file + public int getShiftClickSlotCount() { + return 1; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/power/GUI_BasicTank.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/power/GUI_BasicTank.java index a03aac346b..468b7dc7a9 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/power/GUI_BasicTank.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/power/GUI_BasicTank.java @@ -7,30 +7,28 @@ import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.util.StatCollector; public class GUI_BasicTank extends GT_GUIContainerMetaTile_Machine { - private final String mName; + private final String mName; - public GUI_BasicTank(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName) { - super(new CONTAINER_BasicTank(aInventoryPlayer, aTileEntity), "gregtech:textures/gui/BasicTank.png"); - this.mName = aName; - } + public GUI_BasicTank(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName) { + super(new CONTAINER_BasicTank(aInventoryPlayer, aTileEntity), "gregtech:textures/gui/BasicTank.png"); + this.mName = aName; + } - protected void drawGuiContainerForegroundLayer(int par1, int par2) { - this.fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 8, this.ySize - 96 + 2, - 4210752); - this.fontRendererObj.drawString(this.mName, 8, 6, 4210752); - if (this.mContainer != null) { - this.fontRendererObj.drawString("Liquid Amount", 10, 20, 16448255); - this.fontRendererObj.drawString( - GT_Utility.parseNumberToString(((CONTAINER_BasicTank) this.mContainer).mContent), 10, 30, - 16448255); - } + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + this.fontRendererObj.drawString( + StatCollector.translateToLocal("container.inventory"), 8, this.ySize - 96 + 2, 4210752); + this.fontRendererObj.drawString(this.mName, 8, 6, 4210752); + if (this.mContainer != null) { + this.fontRendererObj.drawString("Liquid Amount", 10, 20, 16448255); + this.fontRendererObj.drawString( + GT_Utility.parseNumberToString(((CONTAINER_BasicTank) this.mContainer).mContent), 10, 30, 16448255); + } + } - } - - protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { - super.drawGuiContainerBackgroundLayer(par1, par2, par3); - int x = (this.width - this.xSize) / 2; - int y = (this.height - this.ySize) / 2; - this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); - } -}
\ No newline at end of file + protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { + super.drawGuiContainerBackgroundLayer(par1, par2, par3); + int x = (this.width - this.xSize) / 2; + int y = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/workbench/GT_Container_AdvancedWorkbench.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/workbench/GT_Container_AdvancedWorkbench.java index d7ec19a9ac..23dd924702 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/workbench/GT_Container_AdvancedWorkbench.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/workbench/GT_Container_AdvancedWorkbench.java @@ -15,110 +15,144 @@ import net.minecraft.item.ItemStack; public class GT_Container_AdvancedWorkbench extends GT_ContainerMetaTile_Machine { - public GT_Container_AdvancedWorkbench(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { - super(aInventoryPlayer, aTileEntity); - } - + public GT_Container_AdvancedWorkbench(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { + super(aInventoryPlayer, aTileEntity); + } + public void addSlots(InventoryPlayer aInventoryPlayer) { - addSlotToContainer(new Slot(mTileEntity, 0, 8, 8)); - addSlotToContainer(new Slot(mTileEntity, 1, 26, 8)); - addSlotToContainer(new Slot(mTileEntity, 2, 44, 8)); - addSlotToContainer(new Slot(mTileEntity, 3, 62, 8)); - addSlotToContainer(new Slot(mTileEntity, 4, 8, 26)); - addSlotToContainer(new Slot(mTileEntity, 5, 26, 26)); - addSlotToContainer(new Slot(mTileEntity, 6, 44, 26)); - addSlotToContainer(new Slot(mTileEntity, 7, 62, 26)); - addSlotToContainer(new Slot(mTileEntity, 8, 8, 44)); - addSlotToContainer(new Slot(mTileEntity, 9, 26, 44)); - addSlotToContainer(new Slot(mTileEntity, 10, 44, 44)); - addSlotToContainer(new Slot(mTileEntity, 11, 62, 44)); - addSlotToContainer(new Slot(mTileEntity, 12, 8, 62)); - addSlotToContainer(new Slot(mTileEntity, 13, 26, 62)); - addSlotToContainer(new Slot(mTileEntity, 14, 44, 62)); - addSlotToContainer(new Slot(mTileEntity, 15, 62, 62)); - - addSlotToContainer(new SlotElectric(mTileEntity, 16, 82, 8)); - addSlotToContainer(new SlotElectric(mTileEntity, 17, 100, 8)); - addSlotToContainer(new SlotElectric(mTileEntity, 18, 118, 8)); - addSlotToContainer(new SlotElectric(mTileEntity, 19, 136, 8)); - addSlotToContainer(new SlotElectric(mTileEntity, 20, 154, 8)); - - addSlotToContainer(new Slot(mTileEntity, 21, 82, 28)); + addSlotToContainer(new Slot(mTileEntity, 0, 8, 8)); + addSlotToContainer(new Slot(mTileEntity, 1, 26, 8)); + addSlotToContainer(new Slot(mTileEntity, 2, 44, 8)); + addSlotToContainer(new Slot(mTileEntity, 3, 62, 8)); + addSlotToContainer(new Slot(mTileEntity, 4, 8, 26)); + addSlotToContainer(new Slot(mTileEntity, 5, 26, 26)); + addSlotToContainer(new Slot(mTileEntity, 6, 44, 26)); + addSlotToContainer(new Slot(mTileEntity, 7, 62, 26)); + addSlotToContainer(new Slot(mTileEntity, 8, 8, 44)); + addSlotToContainer(new Slot(mTileEntity, 9, 26, 44)); + addSlotToContainer(new Slot(mTileEntity, 10, 44, 44)); + addSlotToContainer(new Slot(mTileEntity, 11, 62, 44)); + addSlotToContainer(new Slot(mTileEntity, 12, 8, 62)); + addSlotToContainer(new Slot(mTileEntity, 13, 26, 62)); + addSlotToContainer(new Slot(mTileEntity, 14, 44, 62)); + addSlotToContainer(new Slot(mTileEntity, 15, 62, 62)); + + addSlotToContainer(new SlotElectric(mTileEntity, 16, 82, 8)); + addSlotToContainer(new SlotElectric(mTileEntity, 17, 100, 8)); + addSlotToContainer(new SlotElectric(mTileEntity, 18, 118, 8)); + addSlotToContainer(new SlotElectric(mTileEntity, 19, 136, 8)); + addSlotToContainer(new SlotElectric(mTileEntity, 20, 154, 8)); + + addSlotToContainer(new Slot(mTileEntity, 21, 82, 28)); addSlotToContainer(new Slot(mTileEntity, 22, 100, 28)); addSlotToContainer(new Slot(mTileEntity, 23, 118, 28)); - addSlotToContainer(new Slot(mTileEntity, 24, 82, 46)); + addSlotToContainer(new Slot(mTileEntity, 24, 82, 46)); addSlotToContainer(new Slot(mTileEntity, 25, 100, 46)); addSlotToContainer(new Slot(mTileEntity, 26, 118, 46)); - addSlotToContainer(new Slot(mTileEntity, 27, 82, 64)); + addSlotToContainer(new Slot(mTileEntity, 27, 82, 64)); addSlotToContainer(new Slot(mTileEntity, 28, 100, 64)); addSlotToContainer(new Slot(mTileEntity, 29, 118, 64)); - + addSlotToContainer(new Slot(mTileEntity, 33, 154, 28)); addSlotToContainer(new Slot(mTileEntity, 34, 154, 64)); - + addSlotToContainer(new SlotBlueprint(mTileEntity, 30, 136, 28)); addSlotToContainer(new GT_Slot_Holo(mTileEntity, 31, 136, 64, false, false, 1)); addSlotToContainer(new GT_Slot_Holo(mTileEntity, 32, 154, 46, false, false, 1)); addSlotToContainer(new GT_Slot_Holo(mTileEntity, 32, 136, 46, false, false, 1)); - } - + public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { - Logger.INFO("Clicked on slot "+aSlotIndex); - if (aSlotIndex < 21 || aSlotIndex > 35) return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); - if (mTileEntity == null || mTileEntity.getMetaTileEntity() == null) return null; - try { - ItemStack tStack = ((Slot)inventorySlots.get(aSlotIndex)).getStack(); - if (tStack != null && tStack.stackSize <= 0 && !GT_Utility.areStacksEqual(tStack, aPlayer.inventory.getItemStack())) { - return null; - } - if (aSlotIndex == 32) { - if (aMouseclick == 0 && aShifthold == 1) { - ((GT_MetaTileEntity_AdvancedCraftingTable)mTileEntity.getMetaTileEntity()).setBluePrint(null); - return null; - } - } else if (aSlotIndex == 33) { - ItemStack tStack2, tCraftedStack = ((GT_MetaTileEntity_AdvancedCraftingTable)mTileEntity.getMetaTileEntity()).getCraftingOutput(); - if (tCraftedStack != null) { - if (aShifthold == 1) { - for (byte i = 0; i < aPlayer.inventory.mainInventory.length; i++) { - for (byte j = 0; j < tCraftedStack.getMaxStackSize() / tCraftedStack.stackSize && ((GT_MetaTileEntity_AdvancedCraftingTable)mTileEntity.getMetaTileEntity()).canDoCraftingOutput(); j++) { - if (!GT_Utility.areStacksEqual(tStack2 = ((GT_MetaTileEntity_AdvancedCraftingTable)mTileEntity.getMetaTileEntity()).getCraftingOutput(), tCraftedStack) || tStack.stackSize != tStack2.stackSize) return aPlayer.inventory.getItemStack(); - aPlayer.inventory.mainInventory[i] = (((GT_MetaTileEntity_AdvancedCraftingTable)mTileEntity.getMetaTileEntity()).consumeMaterials(aPlayer, aPlayer.inventory.mainInventory[i])); - } - } - } else { - if (aMouseclick == 0) { - if (((GT_MetaTileEntity_AdvancedCraftingTable)mTileEntity.getMetaTileEntity()).canDoCraftingOutput()) aPlayer.inventory.setItemStack(((GT_MetaTileEntity_AdvancedCraftingTable)mTileEntity.getMetaTileEntity()).consumeMaterials(aPlayer, aPlayer.inventory.getItemStack())); - return aPlayer.inventory.getItemStack(); - } else { - for (int i = 0; i < tCraftedStack.getMaxStackSize() / tCraftedStack.stackSize && ((GT_MetaTileEntity_AdvancedCraftingTable)mTileEntity.getMetaTileEntity()).canDoCraftingOutput(); i++) { - if (!GT_Utility.areStacksEqual(tStack2 = ((GT_MetaTileEntity_AdvancedCraftingTable)mTileEntity.getMetaTileEntity()).getCraftingOutput(), tCraftedStack) || tStack.stackSize != tStack2.stackSize) return aPlayer.inventory.getItemStack(); - aPlayer.inventory.setItemStack(((GT_MetaTileEntity_AdvancedCraftingTable)mTileEntity.getMetaTileEntity()).consumeMaterials(aPlayer, aPlayer.inventory.getItemStack())); - } - return aPlayer.inventory.getItemStack(); - } - } - } - return null; - } else if (aSlotIndex == 34) { - ((GT_MetaTileEntity_AdvancedCraftingTable)mTileEntity.getMetaTileEntity()).mFlushMode = true; - return null; - } else if (aSlotIndex == 35) { - ((GT_MetaTileEntity_AdvancedCraftingTable)mTileEntity.getMetaTileEntity()).sortIntoTheInputSlots(); - return null; - } - } catch(Throwable e) { - //GT_Log.log.catching(e); - } - return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + Logger.INFO("Clicked on slot " + aSlotIndex); + if (aSlotIndex < 21 || aSlotIndex > 35) return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + if (mTileEntity == null || mTileEntity.getMetaTileEntity() == null) return null; + try { + ItemStack tStack = ((Slot) inventorySlots.get(aSlotIndex)).getStack(); + if (tStack != null + && tStack.stackSize <= 0 + && !GT_Utility.areStacksEqual(tStack, aPlayer.inventory.getItemStack())) { + return null; + } + if (aSlotIndex == 32) { + if (aMouseclick == 0 && aShifthold == 1) { + ((GT_MetaTileEntity_AdvancedCraftingTable) mTileEntity.getMetaTileEntity()).setBluePrint(null); + return null; + } + } else if (aSlotIndex == 33) { + ItemStack tStack2, + tCraftedStack = + ((GT_MetaTileEntity_AdvancedCraftingTable) mTileEntity.getMetaTileEntity()) + .getCraftingOutput(); + if (tCraftedStack != null) { + if (aShifthold == 1) { + for (byte i = 0; i < aPlayer.inventory.mainInventory.length; i++) { + for (byte j = 0; + j < tCraftedStack.getMaxStackSize() / tCraftedStack.stackSize + && ((GT_MetaTileEntity_AdvancedCraftingTable) + mTileEntity.getMetaTileEntity()) + .canDoCraftingOutput(); + j++) { + if (!GT_Utility.areStacksEqual( + tStack2 = ((GT_MetaTileEntity_AdvancedCraftingTable) + mTileEntity.getMetaTileEntity()) + .getCraftingOutput(), + tCraftedStack) + || tStack.stackSize != tStack2.stackSize) + return aPlayer.inventory.getItemStack(); + aPlayer.inventory.mainInventory[i] = (((GT_MetaTileEntity_AdvancedCraftingTable) + mTileEntity.getMetaTileEntity()) + .consumeMaterials(aPlayer, aPlayer.inventory.mainInventory[i])); + } + } + } else { + if (aMouseclick == 0) { + if (((GT_MetaTileEntity_AdvancedCraftingTable) mTileEntity.getMetaTileEntity()) + .canDoCraftingOutput()) + aPlayer.inventory.setItemStack( + ((GT_MetaTileEntity_AdvancedCraftingTable) mTileEntity.getMetaTileEntity()) + .consumeMaterials(aPlayer, aPlayer.inventory.getItemStack())); + return aPlayer.inventory.getItemStack(); + } else { + for (int i = 0; + i < tCraftedStack.getMaxStackSize() / tCraftedStack.stackSize + && ((GT_MetaTileEntity_AdvancedCraftingTable) + mTileEntity.getMetaTileEntity()) + .canDoCraftingOutput(); + i++) { + if (!GT_Utility.areStacksEqual( + tStack2 = ((GT_MetaTileEntity_AdvancedCraftingTable) + mTileEntity.getMetaTileEntity()) + .getCraftingOutput(), + tCraftedStack) + || tStack.stackSize != tStack2.stackSize) + return aPlayer.inventory.getItemStack(); + aPlayer.inventory.setItemStack( + ((GT_MetaTileEntity_AdvancedCraftingTable) mTileEntity.getMetaTileEntity()) + .consumeMaterials(aPlayer, aPlayer.inventory.getItemStack())); + } + return aPlayer.inventory.getItemStack(); + } + } + } + return null; + } else if (aSlotIndex == 34) { + ((GT_MetaTileEntity_AdvancedCraftingTable) mTileEntity.getMetaTileEntity()).mFlushMode = true; + return null; + } else if (aSlotIndex == 35) { + ((GT_MetaTileEntity_AdvancedCraftingTable) mTileEntity.getMetaTileEntity()).sortIntoTheInputSlots(); + return null; + } + } catch (Throwable e) { + // GT_Log.log.catching(e); + } + return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); } - + public int getSlotCount() { - return 33; + return 33; } - + public int getShiftClickSlotCount() { - return 21; + return 21; } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/workbench/GT_Container_BronzeWorkbench.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/workbench/GT_Container_BronzeWorkbench.java index d26c4d49fd..46bd70e55a 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/workbench/GT_Container_BronzeWorkbench.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/workbench/GT_Container_BronzeWorkbench.java @@ -13,109 +13,141 @@ import net.minecraft.item.ItemStack; public class GT_Container_BronzeWorkbench extends GT_ContainerMetaTile_Machine { - public GT_Container_BronzeWorkbench(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { - super(aInventoryPlayer, aTileEntity); - } - + public GT_Container_BronzeWorkbench(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { + super(aInventoryPlayer, aTileEntity); + } + public void addSlots(InventoryPlayer aInventoryPlayer) { - addSlotToContainer(new Slot(mTileEntity, 0, 8, 8)); - addSlotToContainer(new Slot(mTileEntity, 1, 26, 8)); - addSlotToContainer(new Slot(mTileEntity, 2, 44, 8)); - addSlotToContainer(new Slot(mTileEntity, 3, 62, 8)); - addSlotToContainer(new Slot(mTileEntity, 4, 8, 26)); - addSlotToContainer(new Slot(mTileEntity, 5, 26, 26)); - addSlotToContainer(new Slot(mTileEntity, 6, 44, 26)); - addSlotToContainer(new Slot(mTileEntity, 7, 62, 26)); - addSlotToContainer(new Slot(mTileEntity, 8, 8, 44)); - addSlotToContainer(new Slot(mTileEntity, 9, 26, 44)); - addSlotToContainer(new Slot(mTileEntity, 10, 44, 44)); - addSlotToContainer(new Slot(mTileEntity, 11, 62, 44)); - addSlotToContainer(new Slot(mTileEntity, 12, 8, 62)); - addSlotToContainer(new Slot(mTileEntity, 13, 26, 62)); - addSlotToContainer(new Slot(mTileEntity, 14, 44, 62)); - addSlotToContainer(new Slot(mTileEntity, 15, 62, 62)); - - addSlotToContainer(new Slot(mTileEntity, 16, 82, 8)); - addSlotToContainer(new Slot(mTileEntity, 17, 100, 8)); - addSlotToContainer(new Slot(mTileEntity, 18, 118, 8)); - addSlotToContainer(new Slot(mTileEntity, 19, 136, 8)); - addSlotToContainer(new Slot(mTileEntity, 20, 154, 8)); - - addSlotToContainer(new Slot(mTileEntity, 21, 82, 28)); + addSlotToContainer(new Slot(mTileEntity, 0, 8, 8)); + addSlotToContainer(new Slot(mTileEntity, 1, 26, 8)); + addSlotToContainer(new Slot(mTileEntity, 2, 44, 8)); + addSlotToContainer(new Slot(mTileEntity, 3, 62, 8)); + addSlotToContainer(new Slot(mTileEntity, 4, 8, 26)); + addSlotToContainer(new Slot(mTileEntity, 5, 26, 26)); + addSlotToContainer(new Slot(mTileEntity, 6, 44, 26)); + addSlotToContainer(new Slot(mTileEntity, 7, 62, 26)); + addSlotToContainer(new Slot(mTileEntity, 8, 8, 44)); + addSlotToContainer(new Slot(mTileEntity, 9, 26, 44)); + addSlotToContainer(new Slot(mTileEntity, 10, 44, 44)); + addSlotToContainer(new Slot(mTileEntity, 11, 62, 44)); + addSlotToContainer(new Slot(mTileEntity, 12, 8, 62)); + addSlotToContainer(new Slot(mTileEntity, 13, 26, 62)); + addSlotToContainer(new Slot(mTileEntity, 14, 44, 62)); + addSlotToContainer(new Slot(mTileEntity, 15, 62, 62)); + + addSlotToContainer(new Slot(mTileEntity, 16, 82, 8)); + addSlotToContainer(new Slot(mTileEntity, 17, 100, 8)); + addSlotToContainer(new Slot(mTileEntity, 18, 118, 8)); + addSlotToContainer(new Slot(mTileEntity, 19, 136, 8)); + addSlotToContainer(new Slot(mTileEntity, 20, 154, 8)); + + addSlotToContainer(new Slot(mTileEntity, 21, 82, 28)); addSlotToContainer(new Slot(mTileEntity, 22, 100, 28)); addSlotToContainer(new Slot(mTileEntity, 23, 118, 28)); - addSlotToContainer(new Slot(mTileEntity, 24, 82, 46)); + addSlotToContainer(new Slot(mTileEntity, 24, 82, 46)); addSlotToContainer(new Slot(mTileEntity, 25, 100, 46)); addSlotToContainer(new Slot(mTileEntity, 26, 118, 46)); - addSlotToContainer(new Slot(mTileEntity, 27, 82, 64)); + addSlotToContainer(new Slot(mTileEntity, 27, 82, 64)); addSlotToContainer(new Slot(mTileEntity, 28, 100, 64)); addSlotToContainer(new Slot(mTileEntity, 29, 118, 64)); - + addSlotToContainer(new Slot(mTileEntity, 33, 154, 28)); addSlotToContainer(new Slot(mTileEntity, 34, 154, 64)); - + addSlotToContainer(new SlotBlueprint(mTileEntity, 30, 136, 28)); addSlotToContainer(new GT_Slot_Holo(mTileEntity, 31, 136, 64, false, false, 1)); addSlotToContainer(new GT_Slot_Holo(mTileEntity, 32, 154, 46, false, false, 1)); addSlotToContainer(new GT_Slot_Holo(mTileEntity, 32, 136, 46, false, false, 1)); - } - + public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { - if (aSlotIndex < 21 || aSlotIndex > 35) return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); - if (mTileEntity == null || mTileEntity.getMetaTileEntity() == null) return null; - try { - ItemStack tStack = ((Slot)inventorySlots.get(aSlotIndex)).getStack(); - if (tStack != null && tStack.stackSize <= 0 && !GT_Utility.areStacksEqual(tStack, aPlayer.inventory.getItemStack())) { - return null; - } - if (aSlotIndex == 32) { - if (aMouseclick == 0 && aShifthold == 1) { - ((GT_MetaTileEntity_BronzeCraftingTable)mTileEntity.getMetaTileEntity()).setBluePrint(null); - return null; - } - } else if (aSlotIndex == 33) { - ItemStack tStack2, tCraftedStack = ((GT_MetaTileEntity_BronzeCraftingTable)mTileEntity.getMetaTileEntity()).getCraftingOutput(); - if (tCraftedStack != null) { - if (aShifthold == 1) { - for (byte i = 0; i < aPlayer.inventory.mainInventory.length; i++) { - for (byte j = 0; j < tCraftedStack.getMaxStackSize() / tCraftedStack.stackSize && ((GT_MetaTileEntity_BronzeCraftingTable)mTileEntity.getMetaTileEntity()).canDoCraftingOutput(); j++) { - if (!GT_Utility.areStacksEqual(tStack2 = ((GT_MetaTileEntity_BronzeCraftingTable)mTileEntity.getMetaTileEntity()).getCraftingOutput(), tCraftedStack) || tStack.stackSize != tStack2.stackSize) return aPlayer.inventory.getItemStack(); - aPlayer.inventory.mainInventory[i] = (((GT_MetaTileEntity_BronzeCraftingTable)mTileEntity.getMetaTileEntity()).consumeMaterials(aPlayer, aPlayer.inventory.mainInventory[i])); - } - } - } else { - if (aMouseclick == 0) { - if (((GT_MetaTileEntity_BronzeCraftingTable)mTileEntity.getMetaTileEntity()).canDoCraftingOutput()) aPlayer.inventory.setItemStack(((GT_MetaTileEntity_BronzeCraftingTable)mTileEntity.getMetaTileEntity()).consumeMaterials(aPlayer, aPlayer.inventory.getItemStack())); - return aPlayer.inventory.getItemStack(); - } else { - for (int i = 0; i < tCraftedStack.getMaxStackSize() / tCraftedStack.stackSize && ((GT_MetaTileEntity_BronzeCraftingTable)mTileEntity.getMetaTileEntity()).canDoCraftingOutput(); i++) { - if (!GT_Utility.areStacksEqual(tStack2 = ((GT_MetaTileEntity_BronzeCraftingTable)mTileEntity.getMetaTileEntity()).getCraftingOutput(), tCraftedStack) || tStack.stackSize != tStack2.stackSize) return aPlayer.inventory.getItemStack(); - aPlayer.inventory.setItemStack(((GT_MetaTileEntity_BronzeCraftingTable)mTileEntity.getMetaTileEntity()).consumeMaterials(aPlayer, aPlayer.inventory.getItemStack())); - } - return aPlayer.inventory.getItemStack(); - } - } - } - return null; - } else if (aSlotIndex == 34) { - ((GT_MetaTileEntity_BronzeCraftingTable)mTileEntity.getMetaTileEntity()).mFlushMode = true; - return null; - } else if (aSlotIndex == 35) { - ((GT_MetaTileEntity_BronzeCraftingTable)mTileEntity.getMetaTileEntity()).sortIntoTheInputSlots(); - return null; - } - } catch(Throwable e) { - //GT_Log.log.catching(e); - } - return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + if (aSlotIndex < 21 || aSlotIndex > 35) return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + if (mTileEntity == null || mTileEntity.getMetaTileEntity() == null) return null; + try { + ItemStack tStack = ((Slot) inventorySlots.get(aSlotIndex)).getStack(); + if (tStack != null + && tStack.stackSize <= 0 + && !GT_Utility.areStacksEqual(tStack, aPlayer.inventory.getItemStack())) { + return null; + } + if (aSlotIndex == 32) { + if (aMouseclick == 0 && aShifthold == 1) { + ((GT_MetaTileEntity_BronzeCraftingTable) mTileEntity.getMetaTileEntity()).setBluePrint(null); + return null; + } + } else if (aSlotIndex == 33) { + ItemStack tStack2, + tCraftedStack = + ((GT_MetaTileEntity_BronzeCraftingTable) mTileEntity.getMetaTileEntity()) + .getCraftingOutput(); + if (tCraftedStack != null) { + if (aShifthold == 1) { + for (byte i = 0; i < aPlayer.inventory.mainInventory.length; i++) { + for (byte j = 0; + j < tCraftedStack.getMaxStackSize() / tCraftedStack.stackSize + && ((GT_MetaTileEntity_BronzeCraftingTable) mTileEntity.getMetaTileEntity()) + .canDoCraftingOutput(); + j++) { + if (!GT_Utility.areStacksEqual( + tStack2 = ((GT_MetaTileEntity_BronzeCraftingTable) + mTileEntity.getMetaTileEntity()) + .getCraftingOutput(), + tCraftedStack) + || tStack.stackSize != tStack2.stackSize) + return aPlayer.inventory.getItemStack(); + aPlayer.inventory.mainInventory[i] = (((GT_MetaTileEntity_BronzeCraftingTable) + mTileEntity.getMetaTileEntity()) + .consumeMaterials(aPlayer, aPlayer.inventory.mainInventory[i])); + } + } + } else { + if (aMouseclick == 0) { + if (((GT_MetaTileEntity_BronzeCraftingTable) mTileEntity.getMetaTileEntity()) + .canDoCraftingOutput()) + aPlayer.inventory.setItemStack( + ((GT_MetaTileEntity_BronzeCraftingTable) mTileEntity.getMetaTileEntity()) + .consumeMaterials(aPlayer, aPlayer.inventory.getItemStack())); + return aPlayer.inventory.getItemStack(); + } else { + for (int i = 0; + i < tCraftedStack.getMaxStackSize() / tCraftedStack.stackSize + && ((GT_MetaTileEntity_BronzeCraftingTable) mTileEntity.getMetaTileEntity()) + .canDoCraftingOutput(); + i++) { + if (!GT_Utility.areStacksEqual( + tStack2 = ((GT_MetaTileEntity_BronzeCraftingTable) + mTileEntity.getMetaTileEntity()) + .getCraftingOutput(), + tCraftedStack) + || tStack.stackSize != tStack2.stackSize) + return aPlayer.inventory.getItemStack(); + aPlayer.inventory.setItemStack( + ((GT_MetaTileEntity_BronzeCraftingTable) mTileEntity.getMetaTileEntity()) + .consumeMaterials(aPlayer, aPlayer.inventory.getItemStack())); + } + return aPlayer.inventory.getItemStack(); + } + } + } + return null; + } else if (aSlotIndex == 34) { + ((GT_MetaTileEntity_BronzeCraftingTable) mTileEntity.getMetaTileEntity()).mFlushMode = true; + return null; + } else if (aSlotIndex == 35) { + ((GT_MetaTileEntity_BronzeCraftingTable) mTileEntity.getMetaTileEntity()).sortIntoTheInputSlots(); + return null; + } + } catch (Throwable e) { + // GT_Log.log.catching(e); + } + return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); } - + public int getSlotCount() { - return 33; + return 33; } - + public int getShiftClickSlotCount() { - return 21; + return 21; } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/workbench/GT_GUIContainer_AdvancedWorkbench.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/workbench/GT_GUIContainer_AdvancedWorkbench.java index 094a7a7eb9..d341a0766d 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/workbench/GT_GUIContainer_AdvancedWorkbench.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/workbench/GT_GUIContainer_AdvancedWorkbench.java @@ -1,84 +1,87 @@ package gtPlusPlus.xmod.gregtech.api.gui.workbench; -import java.util.ArrayList; -import java.util.List; - import gregtech.api.gui.GT_ContainerMetaTile_Machine; import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.sys.KeyboardUtils; +import java.util.ArrayList; +import java.util.List; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.entity.player.InventoryPlayer; public class GT_GUIContainer_AdvancedWorkbench extends GT_GUIContainerMetaTile_Machine { - - private final String mLocalName; - - public GT_GUIContainer_AdvancedWorkbench(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aLocalName) { - super(new GT_Container_AdvancedWorkbench(aInventoryPlayer, aTileEntity), CORE.RES_PATH_GUI + "AdvancedCraftingTable.png"); + + private final String mLocalName; + + public GT_GUIContainer_AdvancedWorkbench( + InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aLocalName) { + super( + new GT_Container_AdvancedWorkbench(aInventoryPlayer, aTileEntity), + CORE.RES_PATH_GUI + "AdvancedCraftingTable.png"); mLocalName = aLocalName; } - - public GT_GUIContainer_AdvancedWorkbench(GT_ContainerMetaTile_Machine aContainer, String aLocalName, String aResource) { + + public GT_GUIContainer_AdvancedWorkbench( + GT_ContainerMetaTile_Machine aContainer, String aLocalName, String aResource) { super(aContainer, aResource); mLocalName = aLocalName; } - + @Override protected void drawGuiContainerForegroundLayer(int par1, int par2) { - //fontRendererObj.drawString(mLocalName, 8, 4, 4210752); - this.drawTooltip(par1, par2); - } + // fontRendererObj.drawString(mLocalName, 8, 4, 4210752); + this.drawTooltip(par1, par2); + } + + private void drawTooltip(final int x2, final int y2) { + final int xStart = (this.width - this.xSize) / 2; + final int yStart = (this.height - this.ySize) / 2; + final int x3 = x2 - xStart; + final int y3 = y2 - yStart + 5; + final List<String> list = new ArrayList<String>(); + // 154 - 172 + + if (KeyboardUtils.isShiftKeyDown()) { + if (y3 >= 30 && y3 <= 49) { + if (x3 >= 135 && x3 <= 154) { + list.add("Blueprint Slot"); + list.add("Shift+Lmb Sets to crafting output"); + } + if (x3 >= 153 && x3 <= 170) { + list.add("Extraction Slot"); + list.add("Things can always be pulled from here"); + } + } + if (y3 >= 50 && y3 <= 67) { + if (x3 >= 135 && x3 <= 152) { + list.add("Flush"); + list.add("Empty crafting grid back to storage"); + } + if (x3 >= 153 && x3 <= 170) { + list.add("Automation"); + list.add("Allows output while"); + list.add("crafting grid is full"); + } + } + if (y3 >= 68 && y3 <= 85) { + if (x3 >= 135 && x3 <= 152) { + list.add("Output Slot"); + } + if (x3 >= 153 && x3 <= 170) { + list.add("Free Parking"); + } + } + } + if (!list.isEmpty()) { + this.drawHoveringText(list, x3, y3, this.fontRendererObj); + RenderHelper.enableGUIStandardItemLighting(); + } + } - private void drawTooltip(final int x2, final int y2) { - final int xStart = (this.width - this.xSize) / 2; - final int yStart = (this.height - this.ySize) / 2; - final int x3 = x2 - xStart; - final int y3 = y2 - yStart + 5; - final List<String> list = new ArrayList<String>(); - //154 - 172 - - if (KeyboardUtils.isShiftKeyDown()) { - if (y3 >= 30 && y3 <= 49) { - if (x3 >= 135 && x3 <= 154) { - list.add("Blueprint Slot"); - list.add("Shift+Lmb Sets to crafting output"); - } - if (x3 >= 153 && x3 <= 170) { - list.add("Extraction Slot"); - list.add("Things can always be pulled from here"); - } - } - if (y3 >= 50 && y3 <= 67) { - if (x3 >= 135 && x3 <= 152) { - list.add("Flush"); - list.add("Empty crafting grid back to storage"); - } - if (x3 >= 153 && x3 <= 170) { - list.add("Automation"); - list.add("Allows output while"); - list.add("crafting grid is full"); - } - } - if (y3 >= 68 && y3 <= 85){ - if (x3 >= 135 && x3 <= 152) { - list.add("Output Slot"); - } - if (x3 >= 153 && x3 <= 170) { - list.add("Free Parking"); - } - } - } - if (!list.isEmpty()) { - this.drawHoveringText(list, x3, y3, this.fontRendererObj); - RenderHelper.enableGUIStandardItemLighting(); - } - } - @Override protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { - super.drawGuiContainerBackgroundLayer(par1, par2, par3); + super.drawGuiContainerBackgroundLayer(par1, par2, par3); int x = (width - xSize) / 2; int y = (height - ySize) / 2; drawTexturedModalRect(x, y, 0, 0, xSize, ySize); diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/workbench/GT_GUIContainer_BronzeWorkbench.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/workbench/GT_GUIContainer_BronzeWorkbench.java index 178c9241f1..0967317090 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/workbench/GT_GUIContainer_BronzeWorkbench.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/workbench/GT_GUIContainer_BronzeWorkbench.java @@ -6,8 +6,11 @@ import net.minecraft.entity.player.InventoryPlayer; public class GT_GUIContainer_BronzeWorkbench extends GT_GUIContainer_AdvancedWorkbench { - public GT_GUIContainer_BronzeWorkbench(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aLocalName) { - super(new GT_Container_BronzeWorkbench(aInventoryPlayer, aTileEntity), aLocalName, CORE.RES_PATH_GUI + "BronzeCraftingTable.png"); + public GT_GUIContainer_BronzeWorkbench( + InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aLocalName) { + super( + new GT_Container_BronzeWorkbench(aInventoryPlayer, aTileEntity), + aLocalName, + CORE.RES_PATH_GUI + "BronzeCraftingTable.png"); } - } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/GregtechItemContainer.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/GregtechItemContainer.java index 3c29b34e27..d49f1e9ed0 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/GregtechItemContainer.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/GregtechItemContainer.java @@ -5,20 +5,35 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; public interface GregtechItemContainer { - public Item getItem(); - public Block getBlock(); - public boolean isStackEqual(Object aStack); - public boolean isStackEqual(Object aStack, boolean aWildcard, boolean aIgnoreNBT); - public ItemStack get(long aAmount, Object... aReplacements); - public ItemStack getWildcard(long aAmount, Object... aReplacements); - public ItemStack getUndamaged(long aAmount, Object... aReplacements); - public ItemStack getAlmostBroken(long aAmount, Object... aReplacements); - public ItemStack getWithDamage(long aAmount, long aMetaValue, Object... aReplacements); - public GregtechItemContainer set(Item aItem); - public GregtechItemContainer set(ItemStack aStack); - public GregtechItemContainer registerOre(Object... aOreNames); - public GregtechItemContainer registerWildcardAsOre(Object... aOreNames); - public ItemStack getWithCharge(long aAmount, int aEnergy, Object... aReplacements); - public ItemStack getWithName(long aAmount, String aDisplayName, Object... aReplacements); - public boolean hasBeenSet(); -}
\ No newline at end of file + public Item getItem(); + + public Block getBlock(); + + public boolean isStackEqual(Object aStack); + + public boolean isStackEqual(Object aStack, boolean aWildcard, boolean aIgnoreNBT); + + public ItemStack get(long aAmount, Object... aReplacements); + + public ItemStack getWildcard(long aAmount, Object... aReplacements); + + public ItemStack getUndamaged(long aAmount, Object... aReplacements); + + public ItemStack getAlmostBroken(long aAmount, Object... aReplacements); + + public ItemStack getWithDamage(long aAmount, long aMetaValue, Object... aReplacements); + + public GregtechItemContainer set(Item aItem); + + public GregtechItemContainer set(ItemStack aStack); + + public GregtechItemContainer registerOre(Object... aOreNames); + + public GregtechItemContainer registerWildcardAsOre(Object... aOreNames); + + public ItemStack getWithCharge(long aAmount, int aEnergy, Object... aReplacements); + + public ItemStack getWithName(long aAmount, String aDisplayName, Object... aReplacements); + + public boolean hasBeenSet(); +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/IBaseCustomMetaTileEntity.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/IBaseCustomMetaTileEntity.java index 71d15e6e77..e210dfb487 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/IBaseCustomMetaTileEntity.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/IBaseCustomMetaTileEntity.java @@ -2,6 +2,5 @@ package gtPlusPlus.xmod.gregtech.api.interfaces; public interface IBaseCustomMetaTileEntity { - public boolean doesExplode(); - + public boolean doesExplode(); } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/IHeatEntity.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/IHeatEntity.java index 824bb258d8..cf1f137e0d 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/IHeatEntity.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/IHeatEntity.java @@ -5,22 +5,21 @@ import net.minecraftforge.common.util.ForgeDirection; public interface IHeatEntity extends IHeatSource, IHeatSink { - public int getHeatBuffer(); + public int getHeatBuffer(); - public void setHeatBuffer(int HeatBuffer); + public void setHeatBuffer(int HeatBuffer); - public void addtoHeatBuffer(int heat); + public void addtoHeatBuffer(int heat); - public int getTransmitHeat(); + public int getTransmitHeat(); - public int fillHeatBuffer(int maxAmount); + public int fillHeatBuffer(int maxAmount); - public int getMaxHeatEmittedPerTick(); - - public void updateHeatEntity(); + public int getMaxHeatEmittedPerTick(); - public int maxrequestHeatTick(ForgeDirection directionFrom); + public void updateHeatEntity(); - public int requestHeat(ForgeDirection directionFrom, int requestheat); - + public int maxrequestHeatTick(ForgeDirection directionFrom); + + public int requestHeat(ForgeDirection directionFrom, int requestheat); } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/IHeatSink.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/IHeatSink.java index 80adcf0d51..9e671fe538 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/IHeatSink.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/IHeatSink.java @@ -3,11 +3,8 @@ package gtPlusPlus.xmod.gregtech.api.interfaces; import net.minecraftforge.common.util.ForgeDirection; public interface IHeatSink { - - - int maxHeatInPerTick(ForgeDirection var1); - - int addHeat(ForgeDirection var1, int var2); - - -}
\ No newline at end of file + + int maxHeatInPerTick(ForgeDirection var1); + + int addHeat(ForgeDirection var1, int var2); +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/IMetaTileEntityHeatPipe.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/IMetaTileEntityHeatPipe.java index 770f249648..60477c9f31 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/IMetaTileEntityHeatPipe.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/IMetaTileEntityHeatPipe.java @@ -1,14 +1,10 @@ package gtPlusPlus.xmod.gregtech.api.interfaces; -import java.util.ArrayList; - import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import java.util.ArrayList; import net.minecraft.tileentity.TileEntity; public interface IMetaTileEntityHeatPipe extends IMetaTileEntity { - - - long transferHeat(byte var1, long var2, long var4, ArrayList<TileEntity> var6); - - -}
\ No newline at end of file + + long transferHeat(byte var1, long var2, long var4, ArrayList<TileEntity> var6); +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/IGregtech_RecipeAdder.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/IGregtech_RecipeAdder.java index 1f4951979d..530d7aa86c 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/IGregtech_RecipeAdder.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/IGregtech_RecipeAdder.java @@ -6,214 +6,336 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; public interface IGregtech_RecipeAdder { - /** - * Adds a Coke Oven Recipe - * - * @param aInput1 = first Input (not null, and respects StackSize) - * @param aInputb = second Input (can be null, and respects StackSize) - * @param aFluidOutput = Output of the Creosote (not null, and respects StackSize) - * @param aFluidInput = fluid Input (can be null, and respects StackSize) - * @param aOutput = Output of the Coal/coke (can be null, and respects StackSize) - * @param aDuration = Duration (must be >= 0) - * @param aEUt = EU needed for heating up (must be >= 0) - * @return true if the Recipe got added, otherwise false. - */ - //public boolean addCokeOvenRecipe(boolean aOptimize, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecial, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue); - public boolean addCokeOvenRecipe(ItemStack aInput1, ItemStack aInput2, FluidStack aFluidInput, FluidStack aFluidOutput, ItemStack aOutput, int aDuration, int aEUt); - - - public boolean addCokeOvenRecipe(int aCircuit, ItemStack aInput2, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, ItemStack[] aOutputs, int aDuration, int aEUt); - - - public boolean addCokeOvenRecipe(ItemStack aInput1, ItemStack aInput2, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, ItemStack[] aOutputs, int aDuration, int aEUt); - - - public boolean addFuel(ItemStack aInput1, ItemStack aOutput1, int aEU, int aType); - - - /** - * Adds a Matter Fabricator Recipe - * - * @param aFluidOutput = Output of the UU-Matter (not null, and respects StackSize) - * @param aFluidInput = fluid Input (can be UU_Amp or null, and respects StackSize) - * @param aDuration = Duration (must be >= 0) - * @param aEUt = EU needed for heating up (must be >= 0) - * @return true if the Recipe got added, otherwise false. - */ - public boolean addMatterFabricatorRecipe(FluidStack aFluidInput, FluidStack aFluidOutput, int aDuration, int aEUt); - - /** - * Adds a Matter Fabricator Recipe - * - * @param aItemInput = ItemStack Input, can be null I assume. - * @param aFluidInput = fluid Input (can be UU_Amp or null, and respects StackSize) - * @param aFluidOutput = Output of the UU-Matter (not null, and respects StackSize) - * @param aDuration = Duration (must be >= 0) - * @param aEUt = EU needed for heating up (must be >= 0) - * @return true if the Recipe got added, otherwise false. - */ - public boolean addMatterFabricatorRecipe(ItemStack aItemInput, FluidStack aFluidInput, FluidStack aFluidOutput, int aDuration, int aEUt); - - - - - /** - * Adds a Recipe for the Dehydrator. (up to 9 Outputs) - * - * @param aInput = Input itemstack (not null, and respects StackSize) - * @param aFluidInput = fluid Input (can be UU_Amp or null, and respects StackSize) - * @param aOutputItems = Itemstack[] (not null, and respects StackSize) - * @param aDuration = Duration (must be >= 0) - * @param aEUt = EU needed for heating up (must be >= 0) - * @return true if the Recipe got added, otherwise false. - */ - - //public boolean addDehydratorRecipe(ItemStack aInput, FluidStack aFluid, ItemStack[] aOutputItems, int aDuration, int aEUt); - /*public boolean addDehydratorRecipe(FluidStack aFluid, FluidStack aOutputFluid, ItemStack[] aOutputItems, int aDuration, int aEUt);*/ - /*public boolean addDehydratorRecipe(ItemStack aItemA, ItemStack aItemB, ItemStack[] aOutputItems, int aDuration, int aEUt); + /** + * Adds a Coke Oven Recipe + * + * @param aInput1 = first Input (not null, and respects StackSize) + * @param aInputb = second Input (can be null, and respects StackSize) + * @param aFluidOutput = Output of the Creosote (not null, and respects StackSize) + * @param aFluidInput = fluid Input (can be null, and respects StackSize) + * @param aOutput = Output of the Coal/coke (can be null, and respects StackSize) + * @param aDuration = Duration (must be >= 0) + * @param aEUt = EU needed for heating up (must be >= 0) + * @return true if the Recipe got added, otherwise false. + */ + // public boolean addCokeOvenRecipe(boolean aOptimize, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecial, + // FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue); + public boolean addCokeOvenRecipe( + ItemStack aInput1, + ItemStack aInput2, + FluidStack aFluidInput, + FluidStack aFluidOutput, + ItemStack aOutput, + int aDuration, + int aEUt); + + public boolean addCokeOvenRecipe( + int aCircuit, + ItemStack aInput2, + FluidStack[] aFluidInputs, + FluidStack[] aFluidOutputs, + ItemStack[] aOutputs, + int aDuration, + int aEUt); + + public boolean addCokeOvenRecipe( + ItemStack aInput1, + ItemStack aInput2, + FluidStack[] aFluidInputs, + FluidStack[] aFluidOutputs, + ItemStack[] aOutputs, + int aDuration, + int aEUt); + + public boolean addFuel(ItemStack aInput1, ItemStack aOutput1, int aEU, int aType); + + /** + * Adds a Matter Fabricator Recipe + * + * @param aFluidOutput = Output of the UU-Matter (not null, and respects StackSize) + * @param aFluidInput = fluid Input (can be UU_Amp or null, and respects StackSize) + * @param aDuration = Duration (must be >= 0) + * @param aEUt = EU needed for heating up (must be >= 0) + * @return true if the Recipe got added, otherwise false. + */ + public boolean addMatterFabricatorRecipe(FluidStack aFluidInput, FluidStack aFluidOutput, int aDuration, int aEUt); + + /** + * Adds a Matter Fabricator Recipe + * + * @param aItemInput = ItemStack Input, can be null I assume. + * @param aFluidInput = fluid Input (can be UU_Amp or null, and respects StackSize) + * @param aFluidOutput = Output of the UU-Matter (not null, and respects StackSize) + * @param aDuration = Duration (must be >= 0) + * @param aEUt = EU needed for heating up (must be >= 0) + * @return true if the Recipe got added, otherwise false. + */ + public boolean addMatterFabricatorRecipe( + ItemStack aItemInput, FluidStack aFluidInput, FluidStack aFluidOutput, int aDuration, int aEUt); + + /** + * Adds a Recipe for the Dehydrator. (up to 9 Outputs) + * + * @param aInput = Input itemstack (not null, and respects StackSize) + * @param aFluidInput = fluid Input (can be UU_Amp or null, and respects StackSize) + * @param aOutputItems = Itemstack[] (not null, and respects StackSize) + * @param aDuration = Duration (must be >= 0) + * @param aEUt = EU needed for heating up (must be >= 0) + * @return true if the Recipe got added, otherwise false. + */ + + // public boolean addDehydratorRecipe(ItemStack aInput, FluidStack aFluid, ItemStack[] aOutputItems, int aDuration, + // int aEUt); + /*public boolean addDehydratorRecipe(FluidStack aFluid, FluidStack aOutputFluid, ItemStack[] aOutputItems, int aDuration, int aEUt);*/ + /*public boolean addDehydratorRecipe(ItemStack aItemA, ItemStack aItemB, ItemStack[] aOutputItems, int aDuration, int aEUt); public boolean addDehydratorRecipe(ItemStack aItemA, ItemStack aItemB, FluidStack aFluid, ItemStack[] aOutputItems, FluidStack aOutputFluid, int aDuration, int aEUt);*/ - /** - * Adds a Recipe for the Dehydrator. (up to 9 Outputs) - * - * @param aInput = ItemStack[] (not null, and respects StackSize) - * @param aFluidInput = fluid Input (can be UU_Amp or null, and respects StackSize) - * @param aFluidOutput = Output of the UU-Matter (not null, and respects StackSize) - * @param aOutputItems = ItemStack[] (not null, and respects StackSize) - * @param aChances = Output Change (can be == 0) - * @param aDuration = Duration (must be >= 0) - * @param aEUt = EU needed for heating up (must be >= 0) - * @return true if the Recipe got added, otherwise false. - */ - public boolean addDehydratorRecipe(ItemStack[] aInput, FluidStack aFluidInput, FluidStack aFluidOutput, ItemStack[] aOutputItems, int[] aChances, int aDuration, int aEUt); - - - /** - * Adds a Recipe for the Alloy Blast Smelter. (up to 9 Inputs) - * - * @param aInput = ItemStack[] (not null, and respects StackSize) - * @param aFluidOutput = Output of the Molten Metal (not null, and respects StackSize) - * @param aChances = Output Chance (can be == 0) - * @param aDuration = Duration (must be >= 0) - * @param aEUt = EU per tick needed for heating up (must be >= 0) - * @return true if the Recipe got added, otherwise false. - */ - public boolean addBlastSmelterRecipe(ItemStack[] aInput, FluidStack aOutput, int aChance, int aDuration, int aEUt); - - /** - * Adds a Recipe for the Alloy Blast Smelter. (up to 9 Inputs) - * - * @param aInput = ItemStack[] (not null, and respects StackSize) - * @param aFluidInput = Input of a fluid (can be null, and respects StackSize) - * @param aFluidOutput = Output of the Molten Metal (not null, and respects StackSize) - * @param aChances = Output Chance (can be == 0) - * @param aDuration = Duration (must be >= 0) - * @param aEUt = EU per tick needed for heating up (must be >= 0) - * @return true if the Recipe got added, otherwise false. - */ - public boolean addBlastSmelterRecipe(ItemStack[] aInput, FluidStack aInputFluid, FluidStack aOutput, int aChance, int aDuration, int aEUt); - - /** - * Adds a Recipe for the Alloy Blast Smelter. (up to 9 Inputs) - * - * @param aInput = ItemStack[] (not null, and respects StackSize) - * @param aFluidInput = Input of a fluid (can be null, and respects StackSize) - * @param aFluidOutput = Output of the Molten Metal (not null, and respects StackSize) - * @param aOutputStack = Item Output (Can be null) - * @param aChances = Output Chance (can be == 0) - * @param aDuration = Duration (must be >= 0) - * @param aEUt = EU per tick needed for heating up (must be >= 0) - * @return true if the Recipe got added, otherwise false. - */ - public boolean addBlastSmelterRecipe(ItemStack[] aInput, FluidStack aInputFluid, FluidStack aOutput, ItemStack[] aOutputStack, int[] aChance, int aDuration, int aEUt); - - public boolean addBlastSmelterRecipe(ItemStack[] aInput, FluidStack aInputFluid, FluidStack aOutput, int aChance, int aDuration, int aEUt, int aSpecialValue); - - /** - * Adds a Recipe for the LFTRr. (up to 9 Inputs) - * - * @param aInput = ItemStack[] (not null, and respects StackSize) - * @param aFluidInput = Input of a fluid (can be null, and respects StackSize) - * @param aFluidOutput = Output of the Molten Salts (not null, and respects StackSize) - * @param aOutputStack = Item Output (Can be null) - * @param aChances = Output Chance (can be == 0) - * @param aDuration = Duration (must be >= 0) - * @param aEUt = EU per tick needed for heating up (must be >= 0) - * @param aSpecialValue = Power produced in EU/t per dynamo - * @return true if the Recipe got added, otherwise false. - */ - public boolean addBlastSmelterRecipe(ItemStack[] aInput, FluidStack aInputFluid, FluidStack aOutput, ItemStack[] aOutputStack, int[] aChance, int aDuration, int aEUt, int aSpecialValue); - - - public boolean addLFTRRecipe(ItemStack aInput1, ItemStack aInput2, ItemStack aOutput1, int aDuration, int aEUt); - public boolean addLFTRRecipe(ItemStack aInput1, FluidStack aInput2, ItemStack aOutput1, FluidStack aOutput2, int aDuration, int aEUt); - public boolean addLFTRRecipe(FluidStack aInput1, FluidStack aInput2, FluidStack aOutput1, int aDuration, int aEUt); - - - /** - * Adds a custom Semifluid fuel for the GT++ SemiFluid Generators. - * @param aFuelItem - A Fluidstack to be consumed. - * @param aFuelValue - Fuel value in thousands (1 = 1000) - * @return - Was the Fuel added? - */ - public boolean addSemifluidFuel(FluidStack aFuelItem, int aFuelValue); - - /** - * Adds a custom Semifluid fuel for the GT++ SemiFluid Generators. - * @param aFuelItem - A Fluidstack to be consumed. - * @param aFuelValue - Fuel value in thousands (1 = 1000) - * @return - Was the Fuel added? - */ - public boolean addSemifluidFuel(ItemStack aFuelItem, int aFuelValue); - - public boolean addFissionFuel( - FluidStack aInput1, FluidStack aInput2, FluidStack aInput3, - FluidStack aInput4, FluidStack aInput5, FluidStack aInput6, - FluidStack aInput7, FluidStack aInput8, FluidStack aInput9, - FluidStack aOutput1, FluidStack aOutput2, - int aDuration, int aEUt); - - public boolean addFissionFuel( - boolean aOptimise, - FluidStack aInput1, FluidStack aInput2, FluidStack aInput3, - FluidStack aInput4, FluidStack aInput5, FluidStack aInput6, - FluidStack aInput7, FluidStack aInput8, FluidStack aInput9, - FluidStack aOutput1, FluidStack aOutput2, - int aDuration, int aEUt); - - public boolean addCyclotronRecipe(ItemStack aInput, FluidStack aFluidInput, ItemStack[] aOutputs, - FluidStack aFluidOutput, int[] aChances, int aDuration, int aEUt, int aSpecialValue); - - boolean addCyclotronRecipe(ItemStack[] aInputs, FluidStack aFluidInput, ItemStack[] aOutput, FluidStack aFluidOutput, - int[] aChances, int aDuration, int aEUt, int aSpecialValue); - - public boolean addMixerRecipe(ItemStack aInput1, ItemStack aInput2, ItemStack aInput3, ItemStack aInput4, - FluidStack aFluidInput, FluidStack aFluidOutput, ItemStack aOutput1, ItemStack aOutput2, ItemStack aOutput3, ItemStack aOutput4, int aDuration, int aEUt); - - - /** - * Adds a Recipe for the Machine Component Assembler. (up to 6 Inputs) - * - * @param aInputs = ItemStack[] (not null, and respects StackSize) - * @param aFluidInput = Input of a fluid (can be null, and respects StackSize) - * @param aOutput1 = Output ItemStack (not null, and respects StackSize) - * @param aDuration = Duration (must be >= 0) - * @param aEUt = EU per tick needed for heating up (must be >= 0) - * @return true if the Recipe got added, otherwise false. - */ - public boolean addComponentMakerRecipe(ItemStack[] aInputs, FluidStack aFluidInput, ItemStack aOutput1, int aDuration, int aEUt); - - public boolean addMultiblockCentrifugeRecipe(ItemStack[] aInputs, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, ItemStack[] aOutputs, int[] aChances, int aDuration, int aEUtick, int aSpecial); - - public boolean addMultiblockElectrolyzerRecipe(ItemStack[] aInputs, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, ItemStack[] aOutputs, int[] aChances, int aDuration, int aEUtick, int aSpecial); - - public boolean addAdvancedFreezerRecipe(ItemStack[] aInputs, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, ItemStack[] aOutputs, int[] aChances, int aDuration, int aEUtick, int aSpecial); - - - public boolean addAssemblerRecipeWithOreDict(Object aInput1, int aAmount1, Object aInput2, int aAmount2, ItemStack aOutput, int a1, int a2); - public boolean addAssemblerRecipeWithOreDict(Object aInput1, int aAmount1, Object aInput2, int aAmount2, FluidStack aInputFluid, ItemStack aOutput, int a1, int a2); - - public boolean addSixSlotAssemblingRecipe(ItemStack[] aInputs, FluidStack aInputFluid, ItemStack aOutput1, int aDuration, int aEUt); + /** + * Adds a Recipe for the Dehydrator. (up to 9 Outputs) + * + * @param aInput = ItemStack[] (not null, and respects StackSize) + * @param aFluidInput = fluid Input (can be UU_Amp or null, and respects StackSize) + * @param aFluidOutput = Output of the UU-Matter (not null, and respects StackSize) + * @param aOutputItems = ItemStack[] (not null, and respects StackSize) + * @param aChances = Output Change (can be == 0) + * @param aDuration = Duration (must be >= 0) + * @param aEUt = EU needed for heating up (must be >= 0) + * @return true if the Recipe got added, otherwise false. + */ + public boolean addDehydratorRecipe( + ItemStack[] aInput, + FluidStack aFluidInput, + FluidStack aFluidOutput, + ItemStack[] aOutputItems, + int[] aChances, + int aDuration, + int aEUt); + + /** + * Adds a Recipe for the Alloy Blast Smelter. (up to 9 Inputs) + * + * @param aInput = ItemStack[] (not null, and respects StackSize) + * @param aFluidOutput = Output of the Molten Metal (not null, and respects StackSize) + * @param aChances = Output Chance (can be == 0) + * @param aDuration = Duration (must be >= 0) + * @param aEUt = EU per tick needed for heating up (must be >= 0) + * @return true if the Recipe got added, otherwise false. + */ + public boolean addBlastSmelterRecipe(ItemStack[] aInput, FluidStack aOutput, int aChance, int aDuration, int aEUt); + + /** + * Adds a Recipe for the Alloy Blast Smelter. (up to 9 Inputs) + * + * @param aInput = ItemStack[] (not null, and respects StackSize) + * @param aFluidInput = Input of a fluid (can be null, and respects StackSize) + * @param aFluidOutput = Output of the Molten Metal (not null, and respects StackSize) + * @param aChances = Output Chance (can be == 0) + * @param aDuration = Duration (must be >= 0) + * @param aEUt = EU per tick needed for heating up (must be >= 0) + * @return true if the Recipe got added, otherwise false. + */ + public boolean addBlastSmelterRecipe( + ItemStack[] aInput, FluidStack aInputFluid, FluidStack aOutput, int aChance, int aDuration, int aEUt); + + /** + * Adds a Recipe for the Alloy Blast Smelter. (up to 9 Inputs) + * + * @param aInput = ItemStack[] (not null, and respects StackSize) + * @param aFluidInput = Input of a fluid (can be null, and respects StackSize) + * @param aFluidOutput = Output of the Molten Metal (not null, and respects StackSize) + * @param aOutputStack = Item Output (Can be null) + * @param aChances = Output Chance (can be == 0) + * @param aDuration = Duration (must be >= 0) + * @param aEUt = EU per tick needed for heating up (must be >= 0) + * @return true if the Recipe got added, otherwise false. + */ + public boolean addBlastSmelterRecipe( + ItemStack[] aInput, + FluidStack aInputFluid, + FluidStack aOutput, + ItemStack[] aOutputStack, + int[] aChance, + int aDuration, + int aEUt); + + public boolean addBlastSmelterRecipe( + ItemStack[] aInput, + FluidStack aInputFluid, + FluidStack aOutput, + int aChance, + int aDuration, + int aEUt, + int aSpecialValue); + + /** + * Adds a Recipe for the LFTRr. (up to 9 Inputs) + * + * @param aInput = ItemStack[] (not null, and respects StackSize) + * @param aFluidInput = Input of a fluid (can be null, and respects StackSize) + * @param aFluidOutput = Output of the Molten Salts (not null, and respects StackSize) + * @param aOutputStack = Item Output (Can be null) + * @param aChances = Output Chance (can be == 0) + * @param aDuration = Duration (must be >= 0) + * @param aEUt = EU per tick needed for heating up (must be >= 0) + * @param aSpecialValue = Power produced in EU/t per dynamo + * @return true if the Recipe got added, otherwise false. + */ + public boolean addBlastSmelterRecipe( + ItemStack[] aInput, + FluidStack aInputFluid, + FluidStack aOutput, + ItemStack[] aOutputStack, + int[] aChance, + int aDuration, + int aEUt, + int aSpecialValue); + + public boolean addLFTRRecipe(ItemStack aInput1, ItemStack aInput2, ItemStack aOutput1, int aDuration, int aEUt); + + public boolean addLFTRRecipe( + ItemStack aInput1, FluidStack aInput2, ItemStack aOutput1, FluidStack aOutput2, int aDuration, int aEUt); + + public boolean addLFTRRecipe(FluidStack aInput1, FluidStack aInput2, FluidStack aOutput1, int aDuration, int aEUt); + + /** + * Adds a custom Semifluid fuel for the GT++ SemiFluid Generators. + * @param aFuelItem - A Fluidstack to be consumed. + * @param aFuelValue - Fuel value in thousands (1 = 1000) + * @return - Was the Fuel added? + */ + public boolean addSemifluidFuel(FluidStack aFuelItem, int aFuelValue); + + /** + * Adds a custom Semifluid fuel for the GT++ SemiFluid Generators. + * @param aFuelItem - A Fluidstack to be consumed. + * @param aFuelValue - Fuel value in thousands (1 = 1000) + * @return - Was the Fuel added? + */ + public boolean addSemifluidFuel(ItemStack aFuelItem, int aFuelValue); + + public boolean addFissionFuel( + FluidStack aInput1, + FluidStack aInput2, + FluidStack aInput3, + FluidStack aInput4, + FluidStack aInput5, + FluidStack aInput6, + FluidStack aInput7, + FluidStack aInput8, + FluidStack aInput9, + FluidStack aOutput1, + FluidStack aOutput2, + int aDuration, + int aEUt); + + public boolean addFissionFuel( + boolean aOptimise, + FluidStack aInput1, + FluidStack aInput2, + FluidStack aInput3, + FluidStack aInput4, + FluidStack aInput5, + FluidStack aInput6, + FluidStack aInput7, + FluidStack aInput8, + FluidStack aInput9, + FluidStack aOutput1, + FluidStack aOutput2, + int aDuration, + int aEUt); + + public boolean addCyclotronRecipe( + ItemStack aInput, + FluidStack aFluidInput, + ItemStack[] aOutputs, + FluidStack aFluidOutput, + int[] aChances, + int aDuration, + int aEUt, + int aSpecialValue); + + boolean addCyclotronRecipe( + ItemStack[] aInputs, + FluidStack aFluidInput, + ItemStack[] aOutput, + FluidStack aFluidOutput, + int[] aChances, + int aDuration, + int aEUt, + int aSpecialValue); + + public boolean addMixerRecipe( + ItemStack aInput1, + ItemStack aInput2, + ItemStack aInput3, + ItemStack aInput4, + FluidStack aFluidInput, + FluidStack aFluidOutput, + ItemStack aOutput1, + ItemStack aOutput2, + ItemStack aOutput3, + ItemStack aOutput4, + int aDuration, + int aEUt); + + /** + * Adds a Recipe for the Machine Component Assembler. (up to 6 Inputs) + * + * @param aInputs = ItemStack[] (not null, and respects StackSize) + * @param aFluidInput = Input of a fluid (can be null, and respects StackSize) + * @param aOutput1 = Output ItemStack (not null, and respects StackSize) + * @param aDuration = Duration (must be >= 0) + * @param aEUt = EU per tick needed for heating up (must be >= 0) + * @return true if the Recipe got added, otherwise false. + */ + public boolean addComponentMakerRecipe( + ItemStack[] aInputs, FluidStack aFluidInput, ItemStack aOutput1, int aDuration, int aEUt); + + public boolean addMultiblockCentrifugeRecipe( + ItemStack[] aInputs, + FluidStack[] aFluidInputs, + FluidStack[] aFluidOutputs, + ItemStack[] aOutputs, + int[] aChances, + int aDuration, + int aEUtick, + int aSpecial); + + public boolean addMultiblockElectrolyzerRecipe( + ItemStack[] aInputs, + FluidStack[] aFluidInputs, + FluidStack[] aFluidOutputs, + ItemStack[] aOutputs, + int[] aChances, + int aDuration, + int aEUtick, + int aSpecial); + + public boolean addAdvancedFreezerRecipe( + ItemStack[] aInputs, + FluidStack[] aFluidInputs, + FluidStack[] aFluidOutputs, + ItemStack[] aOutputs, + int[] aChances, + int aDuration, + int aEUtick, + int aSpecial); + + public boolean addAssemblerRecipeWithOreDict( + Object aInput1, int aAmount1, Object aInput2, int aAmount2, ItemStack aOutput, int a1, int a2); + + public boolean addAssemblerRecipeWithOreDict( + Object aInput1, + int aAmount1, + Object aInput2, + int aAmount2, + FluidStack aInputFluid, + ItemStack aOutput, + int a1, + int a2); + + public boolean addSixSlotAssemblingRecipe( + ItemStack[] aInputs, FluidStack aInputFluid, ItemStack aOutput1, int aDuration, int aEUt); /** * Adds an Assemblyline Recipe * @@ -223,8 +345,15 @@ public interface IGregtech_RecipeAdder { * @param aDuration must be > 0 * @param aEUt should be > 0 */ - public boolean addAssemblylineRecipe(ItemStack aResearchItem, int aResearchTime, ItemStack[] aInputs, FluidStack[] aFluidInputs, ItemStack aOutput, int aDuration, int aEUt); - + public boolean addAssemblylineRecipe( + ItemStack aResearchItem, + int aResearchTime, + ItemStack[] aInputs, + FluidStack[] aFluidInputs, + ItemStack aOutput, + int aDuration, + int aEUt); + /** * Adds a Assemblyline Recipe * @@ -232,35 +361,91 @@ public interface IGregtech_RecipeAdder { * ItemStack[] for multiple equivalent items; * {OreDict, amount} for oredict. */ - boolean addAssemblylineRecipe(ItemStack aResearchItem, int aResearchTime, Object[] aInputs, FluidStack[] aFluidInputs, ItemStack aOutput1, int aDuration, int aEUt); + boolean addAssemblylineRecipe( + ItemStack aResearchItem, + int aResearchTime, + Object[] aInputs, + FluidStack[] aFluidInputs, + ItemStack aOutput1, + int aDuration, + int aEUt); + + public boolean addChemicalRecipe( + ItemStack input1, + ItemStack input2, + FluidStack inputFluid, + FluidStack outputFluid, + ItemStack output, + int time, + int eu); + + public boolean addChemicalRecipe( + ItemStack input1, + ItemStack input2, + FluidStack inputFluid, + FluidStack outputFluid, + ItemStack output, + Object object, + int time, + int eu); + + public boolean addChemicalRecipe( + ItemStack input1, + ItemStack input2, + FluidStack inputFluid, + FluidStack outputFluid, + ItemStack output, + ItemStack object, + int time); + + public boolean addChemicalRecipe( + ItemStack input1, + ItemStack input2, + int aCircuit, + FluidStack inputFluid, + FluidStack outputFluid, + ItemStack output, + ItemStack output2, + int time, + int eu); + + public boolean addMultiblockChemicalRecipe( + ItemStack[] itemStacks, + FluidStack[] fluidStacks, + FluidStack[] fluidStacks2, + ItemStack[] outputs, + int time, + int eu); - - public boolean addChemicalRecipe(ItemStack input1, ItemStack input2, FluidStack inputFluid, FluidStack outputFluid, ItemStack output, int time, int eu); - public boolean addChemicalRecipe(ItemStack input1, ItemStack input2, FluidStack inputFluid, FluidStack outputFluid, ItemStack output, Object object, int time, int eu); - public boolean addChemicalRecipe(ItemStack input1, ItemStack input2, FluidStack inputFluid, FluidStack outputFluid, ItemStack output, ItemStack object, int time); - public boolean addChemicalRecipe(ItemStack input1, ItemStack input2, int aCircuit, FluidStack inputFluid, FluidStack outputFluid, ItemStack output, ItemStack output2, int time, int eu); + public boolean addCompressorRecipe(ItemStack aInput1, ItemStack aOutput1, int aDuration, int aEUt); - public boolean addMultiblockChemicalRecipe(ItemStack[] itemStacks, FluidStack[] fluidStacks, FluidStack[] fluidStacks2, ItemStack[] outputs, int time, int eu); + public boolean addBrewingRecipe( + ItemStack aIngredient, FluidStack aInput, FluidStack aOutput, int aTime, int aEu, boolean aHidden); - public boolean addCompressorRecipe(ItemStack aInput1, ItemStack aOutput1, int aDuration, int aEUt); + public boolean addBrewingRecipe( + int aCircuit, FluidStack aInput, FluidStack aOutput, int aTime, int aEu, boolean aHidden); + + public boolean addSmeltingAndAlloySmeltingRecipe(ItemStack aDust, ItemStack aOutput); + + public boolean addFluidExtractionRecipe(ItemStack input, FluidStack output, int aTime, int aEu); + + public boolean addFluidExtractionRecipe( + ItemStack aContainer, ItemStack aFullContainer, FluidStack rFluidOut, int aTime, int aEu); - public boolean addBrewingRecipe(ItemStack aIngredient, FluidStack aInput, FluidStack aOutput, int aTime, int aEu, boolean aHidden); - - public boolean addBrewingRecipe(int aCircuit, FluidStack aInput, FluidStack aOutput, int aTime, int aEu, boolean aHidden); + public boolean addFluidCannerRecipe(ItemStack aContainer, ItemStack aFullContainer, FluidStack rFluidIn); - public boolean addSmeltingAndAlloySmeltingRecipe(ItemStack aDust, ItemStack aOutput); + public boolean addFluidCannerRecipe( + ItemStack aContainer, ItemStack aFullContainer, FluidStack rFluidIn, FluidStack rFluidOut); - public boolean addFluidExtractionRecipe(ItemStack input, FluidStack output, int aTime, int aEu); - - public boolean addFluidExtractionRecipe(ItemStack aContainer, ItemStack aFullContainer, FluidStack rFluidOut, int aTime, int aEu); + public boolean addFluidCannerRecipe( + ItemStack aContainer, + ItemStack aFullContainer, + FluidStack rFluidIn, + FluidStack rFluidOut, + int aTime, + int aEu); - public boolean addFluidCannerRecipe(ItemStack aContainer, ItemStack aFullContainer, FluidStack rFluidIn); - - public boolean addFluidCannerRecipe(ItemStack aContainer, ItemStack aFullContainer, FluidStack rFluidIn, FluidStack rFluidOut); - - public boolean addFluidCannerRecipe(ItemStack aContainer, ItemStack aFullContainer, FluidStack rFluidIn, FluidStack rFluidOut, int aTime, int aEu); - - /** + /** * Adds a Fusion reactor Recipe * * @param aInput1 = first Input (not null, and respects StackSize) @@ -269,9 +454,15 @@ public interface IGregtech_RecipeAdder { * @param aFusionDurationInTicks = How many ticks the Fusion lasts (must be > 0) * @param aEu = The EU generated per Tick (can even be negative!) * @param aSpecial = EU needed for heating the Reactor up (must be >= 0) - */ - public boolean addFusionReactorRecipe(ItemStack aInputStackA, ItemStack aInputStackB, FluidStack plasma, int aFusionDurationInTicks, int aEu, int aSpecial); - /** + */ + public boolean addFusionReactorRecipe( + ItemStack aInputStackA, + ItemStack aInputStackB, + FluidStack plasma, + int aFusionDurationInTicks, + int aEu, + int aSpecial); + /** * Adds a Fusion reactor Recipe * * @param aInput1 = first Input (not null, and respects StackSize) @@ -281,9 +472,16 @@ public interface IGregtech_RecipeAdder { * @param aFusionDurationInTicks = How many ticks the Fusion lasts (must be > 0) * @param aEu = The EU generated per Tick (can even be negative!) * @param aSpecial = EU needed for heating the Reactor up (must be >= 0) - */ - public boolean addFusionReactorRecipe(FluidStack aInputStackA, FluidStack aInputStackB, FluidStack plasma, int aOutputChance, int aFusionDurationInTicks, int aEu, int aSpecial); - /** + */ + public boolean addFusionReactorRecipe( + FluidStack aInputStackA, + FluidStack aInputStackB, + FluidStack plasma, + int aOutputChance, + int aFusionDurationInTicks, + int aEu, + int aSpecial); + /** * Adds a Fusion reactor Recipe * * @param aInput1 = first Input (not null, and respects StackSize) @@ -293,54 +491,145 @@ public interface IGregtech_RecipeAdder { * @param aFusionDurationInTicks = How many ticks the Fusion lasts (must be > 0) * @param aEu = The EU generated per Tick (can even be negative!) * @param aSpecial = EU needed for heating the Reactor up (must be >= 0) - */ - public boolean addFusionReactorRecipe(ItemStack aInputStackA, ItemStack aInputStackB, FluidStack plasma, int aOutputChance, int aFusionDurationInTicks, int aEu, int aSpecial); - - - public boolean addVacuumFurnaceRecipe(ItemStack aInput1, ItemStack aInput2, - FluidStack aFluidInput, FluidStack aFluidOutput, ItemStack aOutput1, - ItemStack aOutput2, int aDuration, int aEUt, int aLevel); - - public boolean addVacuumFurnaceRecipe(ItemStack[] aInputs, FluidStack[] aFluidInputs, ItemStack[] aOutputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aLevel); - - public boolean addUvLaserRecipe(ItemStack aInput1, ItemStack aOutput, int time, long eu); - public boolean addIrLaserRecipe(ItemStack aInput1, ItemStack aOutput, int time, long eu); - - public boolean addChemicalPlantRecipe(ItemStack[] aInputs, FluidStack[] aInputFluids, ItemStack[] aOutputs, FluidStack[] aFluidOutputs, int time, long eu, int aTier); - public boolean addChemicalPlantRecipe(ItemStack[] aInputs, FluidStack[] aInputFluids, ItemStack[] aOutputs, FluidStack[] aFluidOutputs, int[] aChances, int time, long eu, int aTier); - - public boolean addBlastRecipe(ItemStack[] aInputs, FluidStack[] aInputFluids, ItemStack[] aOutputs, FluidStack[] aFluidOutputs, int time, long eu, int aHeat); - - public boolean addPyrolyseRecipe(ItemStack aInput, FluidStack aFluidInput, int intCircuit, ItemStack aOutput, FluidStack aFluidOutput, int aDuration, int aEUt); - - public boolean addExtractorRecipe(ItemStack aInput, ItemStack aOutput, int aDuration, int aEUt); - - public boolean addExtractorRecipe(ItemStack aInput, ItemStack aOutput, int aChance, int aDuration, int aEUt); - - public boolean addDistilleryRecipe(ItemStack aCircuit, FluidStack aInput, FluidStack aOutput, ItemStack aSolidOutput, int aDuration, int aEUt, boolean aHidden); - - public boolean addPulverisationRecipe(final ItemStack aInput, ItemStack aOutput1, ItemStack aOutput2, final ItemStack aOutput3); - - public boolean addMillingRecipe(Materials aMat, int aEU); - public boolean addMillingRecipe(Material aMat, int aEU); - - public boolean addFlotationRecipe(Materials aMat, ItemStack aXanthate, FluidStack[] aInputFluids, FluidStack[] aOutputFluids, int aTime, int aEU); - public boolean addFlotationRecipe(Material aMat, ItemStack aXanthate, FluidStack[] aInputFluids, FluidStack[] aOutputFluids, int aTime, int aEU); - - public boolean addpackagerRecipe(ItemStack aRecipeType, ItemStack aInput1, ItemStack aInput2, ItemStack aOutputStack1); - - public boolean addFuelForRTG(ItemStack aFuelPellet, int aFuelDays, int aVoltage); - - public boolean addColdTrapRecipe(int aCircuit, ItemStack aInput, FluidStack aFluidInput, ItemStack[] aOutputs, int[] aChances, FluidStack aFluidOutput, int aTime, int aEU); - - public boolean addReactorProcessingUnitRecipe(ItemStack aInput1, ItemStack aInput2, FluidStack aFluidInput, ItemStack[] aOutputs, int[] aChances, FluidStack aFluidOutput, int aTime, int aEU); - - public boolean addFluidHeaterRecipe(ItemStack aCircuit, FluidStack aInput, FluidStack aOutput, int aDuration, int aEUt); - - public boolean addVacuumFreezerRecipe(ItemStack aInput, ItemStack aOutput, int aDuration, int aEU); - - public boolean addMolecularTransformerRecipe(ItemStack aInput, ItemStack aOutput, int aDuration, int aEU); - - public boolean addMolecularTransformerRecipe(ItemStack aInput, ItemStack aOutput, int aDuration, int aEU, int aAmps); - + */ + public boolean addFusionReactorRecipe( + ItemStack aInputStackA, + ItemStack aInputStackB, + FluidStack plasma, + int aOutputChance, + int aFusionDurationInTicks, + int aEu, + int aSpecial); + + public boolean addVacuumFurnaceRecipe( + ItemStack aInput1, + ItemStack aInput2, + FluidStack aFluidInput, + FluidStack aFluidOutput, + ItemStack aOutput1, + ItemStack aOutput2, + int aDuration, + int aEUt, + int aLevel); + + public boolean addVacuumFurnaceRecipe( + ItemStack[] aInputs, + FluidStack[] aFluidInputs, + ItemStack[] aOutputs, + FluidStack[] aFluidOutputs, + int aDuration, + int aEUt, + int aLevel); + + public boolean addUvLaserRecipe(ItemStack aInput1, ItemStack aOutput, int time, long eu); + + public boolean addIrLaserRecipe(ItemStack aInput1, ItemStack aOutput, int time, long eu); + + public boolean addChemicalPlantRecipe( + ItemStack[] aInputs, + FluidStack[] aInputFluids, + ItemStack[] aOutputs, + FluidStack[] aFluidOutputs, + int time, + long eu, + int aTier); + + public boolean addChemicalPlantRecipe( + ItemStack[] aInputs, + FluidStack[] aInputFluids, + ItemStack[] aOutputs, + FluidStack[] aFluidOutputs, + int[] aChances, + int time, + long eu, + int aTier); + + public boolean addBlastRecipe( + ItemStack[] aInputs, + FluidStack[] aInputFluids, + ItemStack[] aOutputs, + FluidStack[] aFluidOutputs, + int time, + long eu, + int aHeat); + + public boolean addPyrolyseRecipe( + ItemStack aInput, + FluidStack aFluidInput, + int intCircuit, + ItemStack aOutput, + FluidStack aFluidOutput, + int aDuration, + int aEUt); + + public boolean addExtractorRecipe(ItemStack aInput, ItemStack aOutput, int aDuration, int aEUt); + + public boolean addExtractorRecipe(ItemStack aInput, ItemStack aOutput, int aChance, int aDuration, int aEUt); + + public boolean addDistilleryRecipe( + ItemStack aCircuit, + FluidStack aInput, + FluidStack aOutput, + ItemStack aSolidOutput, + int aDuration, + int aEUt, + boolean aHidden); + + public boolean addPulverisationRecipe( + final ItemStack aInput, ItemStack aOutput1, ItemStack aOutput2, final ItemStack aOutput3); + + public boolean addMillingRecipe(Materials aMat, int aEU); + + public boolean addMillingRecipe(Material aMat, int aEU); + + public boolean addFlotationRecipe( + Materials aMat, + ItemStack aXanthate, + FluidStack[] aInputFluids, + FluidStack[] aOutputFluids, + int aTime, + int aEU); + + public boolean addFlotationRecipe( + Material aMat, + ItemStack aXanthate, + FluidStack[] aInputFluids, + FluidStack[] aOutputFluids, + int aTime, + int aEU); + + public boolean addpackagerRecipe( + ItemStack aRecipeType, ItemStack aInput1, ItemStack aInput2, ItemStack aOutputStack1); + + public boolean addFuelForRTG(ItemStack aFuelPellet, int aFuelDays, int aVoltage); + + public boolean addColdTrapRecipe( + int aCircuit, + ItemStack aInput, + FluidStack aFluidInput, + ItemStack[] aOutputs, + int[] aChances, + FluidStack aFluidOutput, + int aTime, + int aEU); + + public boolean addReactorProcessingUnitRecipe( + ItemStack aInput1, + ItemStack aInput2, + FluidStack aFluidInput, + ItemStack[] aOutputs, + int[] aChances, + FluidStack aFluidOutput, + int aTime, + int aEU); + + public boolean addFluidHeaterRecipe( + ItemStack aCircuit, FluidStack aInput, FluidStack aOutput, int aDuration, int aEUt); + + public boolean addVacuumFreezerRecipe(ItemStack aInput, ItemStack aOutput, int aDuration, int aEU); + + public boolean addMolecularTransformerRecipe(ItemStack aInput, ItemStack aOutput, int aDuration, int aEU); + + public boolean addMolecularTransformerRecipe( + ItemStack aInput, ItemStack aOutput, int aDuration, int aEU, int aAmps); } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/Interface_IconContainer.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/Interface_IconContainer.java index b6c36483af..b597c221f5 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/Interface_IconContainer.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/Interface_IconContainer.java @@ -4,18 +4,18 @@ import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; public interface Interface_IconContainer { - /** - * @return A regular Icon. - */ - public IIcon getIcon(); + /** + * @return A regular Icon. + */ + public IIcon getIcon(); - /** - * @return Icon of the Overlay (or null if there is no Icon) - */ - public IIcon getOverlayIcon(); + /** + * @return Icon of the Overlay (or null if there is no Icon) + */ + public IIcon getOverlayIcon(); - /** - * @return the Default Texture File for this Icon. - */ - public ResourceLocation getTextureFile(); -}
\ No newline at end of file + /** + * @return the Default Texture File for this Icon. + */ + public ResourceLocation getTextureFile(); +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/Interface_ItemBehaviour.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/Interface_ItemBehaviour.java index e874258a7a..85ebb53217 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/Interface_ItemBehaviour.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/Interface_ItemBehaviour.java @@ -1,7 +1,8 @@ package gtPlusPlus.xmod.gregtech.api.interfaces.internal; +import gregtech.api.enums.SubTag; +import gtPlusPlus.xmod.gregtech.api.items.Gregtech_MetaItem_Base; import java.util.List; - import net.minecraft.dispenser.IBlockSource; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; @@ -11,32 +12,52 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.World; -import gregtech.api.enums.SubTag; - -import gtPlusPlus.xmod.gregtech.api.items.Gregtech_MetaItem_Base; - public interface Interface_ItemBehaviour<E extends Item> { - public boolean onLeftClickEntity(E aItem, ItemStack aStack, EntityPlayer aPlayer, Entity aEntity); - - public boolean onItemUse(E aItem, ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int aSide, float hitX, float hitY, float hitZ); - - public boolean onItemUseFirst(E aItem, ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int aSide, float hitX, float hitY, float hitZ); - - public ItemStack onItemRightClick(E aItem, ItemStack aStack, World aWorld, EntityPlayer aPlayer); - - public List<String> getAdditionalToolTips(E aItem, List<String> aList, ItemStack aStack); - - public void onUpdate(E aItem, ItemStack aStack, World aWorld, Entity aPlayer, int aTimer, boolean aIsInHand); - - public boolean isItemStackUsable(E aItem, ItemStack aStack); - - public boolean canDispense(E aItem, IBlockSource aSource, ItemStack aStack); - - public ItemStack onDispense(E aItem, IBlockSource aSource, ItemStack aStack); - - public boolean hasProjectile(Gregtech_MetaItem_Base aItem, SubTag aProjectileType, ItemStack aStack); - - public EntityArrow getProjectile(E aItem, SubTag aProjectileType, ItemStack aStack, World aWorld, double aX, double aY, double aZ); - - public EntityArrow getProjectile(E aItem, SubTag aProjectileType, ItemStack aStack, World aWorld, EntityLivingBase aEntity, float aSpeed); -}
\ No newline at end of file + public boolean onLeftClickEntity(E aItem, ItemStack aStack, EntityPlayer aPlayer, Entity aEntity); + + public boolean onItemUse( + E aItem, + ItemStack aStack, + EntityPlayer aPlayer, + World aWorld, + int aX, + int aY, + int aZ, + int aSide, + float hitX, + float hitY, + float hitZ); + + public boolean onItemUseFirst( + E aItem, + ItemStack aStack, + EntityPlayer aPlayer, + World aWorld, + int aX, + int aY, + int aZ, + int aSide, + float hitX, + float hitY, + float hitZ); + + public ItemStack onItemRightClick(E aItem, ItemStack aStack, World aWorld, EntityPlayer aPlayer); + + public List<String> getAdditionalToolTips(E aItem, List<String> aList, ItemStack aStack); + + public void onUpdate(E aItem, ItemStack aStack, World aWorld, Entity aPlayer, int aTimer, boolean aIsInHand); + + public boolean isItemStackUsable(E aItem, ItemStack aStack); + + public boolean canDispense(E aItem, IBlockSource aSource, ItemStack aStack); + + public ItemStack onDispense(E aItem, IBlockSource aSource, ItemStack aStack); + + public boolean hasProjectile(Gregtech_MetaItem_Base aItem, SubTag aProjectileType, ItemStack aStack); + + public EntityArrow getProjectile( + E aItem, SubTag aProjectileType, ItemStack aStack, World aWorld, double aX, double aY, double aZ); + + public EntityArrow getProjectile( + E aItem, SubTag aProjectileType, ItemStack aStack, World aWorld, EntityLivingBase aEntity, float aSpeed); +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/Interface_OreRecipeRegistrator.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/Interface_OreRecipeRegistrator.java index c997f14c9e..ec6bcae20c 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/Interface_OreRecipeRegistrator.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/Interface_OreRecipeRegistrator.java @@ -1,21 +1,29 @@ package gtPlusPlus.xmod.gregtech.api.interfaces.internal; -import net.minecraft.item.ItemStack; - import gregtech.api.enums.Materials; - import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes; import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes.GT_Materials; +import net.minecraft.item.ItemStack; public interface Interface_OreRecipeRegistrator { - /** - * Contains a Code Fragment, used in the OrePrefix to register Recipes. Better than using a switch/case, like I did before. - * - * @param aPrefix always != null - * @param aMaterial always != null, and can be == _NULL if the Prefix is Self Referencing or not Material based! - * @param aStack always != null - */ - public void registerOre(GregtechOrePrefixes aPrefix, GT_Materials aMaterial, String aOreDictName, String aModName, ItemStack aStack); + /** + * Contains a Code Fragment, used in the OrePrefix to register Recipes. Better than using a switch/case, like I did before. + * + * @param aPrefix always != null + * @param aMaterial always != null, and can be == _NULL if the Prefix is Self Referencing or not Material based! + * @param aStack always != null + */ + public void registerOre( + GregtechOrePrefixes aPrefix, + GT_Materials aMaterial, + String aOreDictName, + String aModName, + ItemStack aStack); - public void registerOre(GregtechOrePrefixes aPrefix, Materials aMaterial, String aOreDictName, String aModName, ItemStack copyAmount); -}
\ No newline at end of file + public void registerOre( + GregtechOrePrefixes aPrefix, + Materials aMaterial, + String aOreDictName, + String aModName, + ItemStack copyAmount); +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/Interface_OreRecipeRegistrator_GT.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/Interface_OreRecipeRegistrator_GT.java index 6037424d1f..616fdfdebf 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/Interface_OreRecipeRegistrator_GT.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/Interface_OreRecipeRegistrator_GT.java @@ -1,18 +1,17 @@ package gtPlusPlus.xmod.gregtech.api.interfaces.internal; -import net.minecraft.item.ItemStack; - import gregtech.api.enums.OrePrefixes; - import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes.GT_Materials; +import net.minecraft.item.ItemStack; public interface Interface_OreRecipeRegistrator_GT { - /** - * Contains a Code Fragment, used in the OrePrefix to register Recipes. Better than using a switch/case, like I did before. - * - * @param aPrefix always != null - * @param aMaterial always != null, and can be == _NULL if the Prefix is Self Referencing or not Material based! - * @param aStack always != null - */ - public void registerOre(OrePrefixes aPrefix, GT_Materials aMaterial, String aOreDictName, String aModName, ItemStack aStack); -}
\ No newline at end of file + /** + * Contains a Code Fragment, used in the OrePrefix to register Recipes. Better than using a switch/case, like I did before. + * + * @param aPrefix always != null + * @param aMaterial always != null, and can be == _NULL if the Prefix is Self Referencing or not Material based! + * @param aStack always != null + */ + public void registerOre( + OrePrefixes aPrefix, GT_Materials aMaterial, String aOreDictName, String aModName, ItemStack aStack); +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/Interface_Texture.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/Interface_Texture.java index 74c996d116..5780109a7b 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/Interface_Texture.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/Interface_Texture.java @@ -4,17 +4,17 @@ import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; public interface Interface_Texture { - public void renderXPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ); + public void renderXPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ); - public void renderXNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ); + public void renderXNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ); - public void renderYPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ); + public void renderYPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ); - public void renderYNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ); + public void renderYNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ); - public void renderZPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ); + public void renderZPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ); - public void renderZNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ); + public void renderZNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ); - public boolean isValidTexture(); -}
\ No newline at end of file + public boolean isValidTexture(); +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/Interface_ToolStats.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/Interface_ToolStats.java index ca167e4c7f..6578ddeb0b 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/Interface_ToolStats.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/Interface_ToolStats.java @@ -1,7 +1,10 @@ package gtPlusPlus.xmod.gregtech.api.interfaces.internal; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.interfaces.IToolStats; +import gregtech.api.items.GT_MetaGenerated_Tool; +import gtPlusPlus.xmod.gregtech.api.items.Gregtech_MetaTool; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.enchantment.Enchantment; import net.minecraft.entity.Entity; @@ -9,12 +12,6 @@ import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.DamageSource; - -import gregtech.api.interfaces.IIconContainer; -import gregtech.api.interfaces.IToolStats; -import gregtech.api.items.GT_MetaGenerated_Tool; - -import gtPlusPlus.xmod.gregtech.api.items.Gregtech_MetaTool; import net.minecraftforge.event.world.BlockEvent; /** @@ -22,172 +19,185 @@ import net.minecraftforge.event.world.BlockEvent; * <p/> * And this is supposed to not have any ItemStack Parameters as these are generic Stats. */ -public interface Interface_ToolStats extends IToolStats{ - /** - * Called when aPlayer crafts this Tool - */ - @Override - public void onToolCrafted(ItemStack aStack, EntityPlayer aPlayer); - - /** - * Called when this gets added to a Tool Item - */ - public void onStatsAddedToTool(Gregtech_MetaTool gregtech_MetaTool, int aID); - - /** - * @return Damage the Tool receives when breaking a Block. 100 is one Damage Point (or 100 EU). - */ - @Override - public int getToolDamagePerBlockBreak(); - - /** - * @return Damage the Tool receives when converting the drops of a Block. 100 is one Damage Point (or 100 EU). - */ - @Override - public int getToolDamagePerDropConversion(); - - /** - * @return Damage the Tool receives when being used as Container Item. 100 is one use, however it is usually 8 times more than normal. - */ - @Override - public int getToolDamagePerContainerCraft(); - - /** - * @return Damage the Tool receives when being used as Weapon, 200 is the normal Value, 100 for actual Weapons. - */ - @Override - public int getToolDamagePerEntityAttack(); - - /** - * @return Basic Quality of the Tool, 0 is normal. If increased, it will increase the general quality of all Tools of this Type. Decreasing is also possible. - */ - @Override - public int getBaseQuality(); - - /** - * @return The Damage Bonus for this Type of Tool against Mobs. 1.0F is normal punch. - */ - @Override - public float getBaseDamage(); - - /** - * @return This gets the Hurt Resistance time for Entities getting hit. (always does 1 as minimum) - */ - @Override - public int getHurtResistanceTime(int aOriginalHurtResistance, Entity aEntity); - - /** - * @return This is a multiplier for the Tool Speed. 1.0F = no special Speed. - */ - @Override - public float getSpeedMultiplier(); - - /** - * @return This is a multiplier for the Tool Speed. 1.0F = no special Durability. - */ - @Override - public float getMaxDurabilityMultiplier(); - - @Override - public DamageSource getDamageSource(EntityLivingBase aPlayer, Entity aEntity); - - @Override - public String getMiningSound(); - - @Override - public String getCraftingSound(); - - @Override - public String getEntityHitSound(); - - @Override - public String getBreakingSound(); - - @Override - public Enchantment[] getEnchantments(ItemStack aStack); - - @Override - public int[] getEnchantmentLevels(ItemStack aStack); - - /** - * @return If this Tool can be used for blocking Damage like a Sword. - */ - @Override - public boolean canBlock(); - - /** - * @return If this Tool can be used as an RC Crowbar. - */ - @Override - public boolean isCrowbar(); - - /** - * @return If this Tool can be used as an BC Wrench. - */ - public boolean isWrench(); - - /** - * @return If this Tool can be used as Weapon i.e. if that is the main purpose. - */ - @Override - public boolean isWeapon(); - - /** - * @return If this Tool is a Ranged Weapon. Return false at isWeapon unless you have a Blade attached to your Bow/Gun or something - */ - @Override - public boolean isRangedWeapon(); - - /** - * @return If this Tool can be used as Weapon i.e. if that is the main purpose. - */ - @Override - public boolean isMiningTool(); - - /** - * aBlock.getHarvestTool(aMetaData) can return the following Values for example. - * "axe", "pickaxe", "sword", "shovel", "hoe", "grafter", "saw", "wrench", "crowbar", "file", "hammer", "plow", "plunger", "scoop", "screwdriver", "sense", "scythe", "softhammer", "cutter", "plasmatorch" - * - * @return If this is a minable Block. Tool Quality checks (like Diamond Tier or something) are separate from this check. - */ - @Override - public boolean isMinableBlock(Block aBlock, byte aMetaData); - - /** - * This lets you modify the Drop List, when this type of Tool has been used. - * - * @return the Amount of modified Items. - */ - @Override - public int convertBlockDrops(List<ItemStack> aDrops, ItemStack aStack, EntityPlayer aPlayer, Block aBlock, int aX, int aY, int aZ, byte aMetaData, int aFortune, boolean aSilkTouch, BlockEvent.HarvestDropsEvent aEvent); - - /** - * @return Returns a broken Version of the Item. - */ - @Override - public ItemStack getBrokenItem(ItemStack aStack); - - /** - * @return the Damage actually done to the Mob. - */ - @Override - public float getNormalDamageAgainstEntity(float aOriginalDamage, Entity aEntity, ItemStack aStack, EntityPlayer aPlayer); - - /** - * @return the Damage actually done to the Mob. - */ - @Override - public float getMagicDamageAgainstEntity(float aOriginalDamage, Entity aEntity, ItemStack aStack, EntityPlayer aPlayer); - - @Override - public IIconContainer getIcon(boolean aIsToolHead, ItemStack aStack); - - @Override - public short[] getRGBa(boolean aIsToolHead, ItemStack aStack); - - /** - * Called when this gets added to a Tool Item - */ - @Override - public void onStatsAddedToTool(GT_MetaGenerated_Tool aItem, int aID); -}
\ No newline at end of file +public interface Interface_ToolStats extends IToolStats { + /** + * Called when aPlayer crafts this Tool + */ + @Override + public void onToolCrafted(ItemStack aStack, EntityPlayer aPlayer); + + /** + * Called when this gets added to a Tool Item + */ + public void onStatsAddedToTool(Gregtech_MetaTool gregtech_MetaTool, int aID); + + /** + * @return Damage the Tool receives when breaking a Block. 100 is one Damage Point (or 100 EU). + */ + @Override + public int getToolDamagePerBlockBreak(); + + /** + * @return Damage the Tool receives when converting the drops of a Block. 100 is one Damage Point (or 100 EU). + */ + @Override + public int getToolDamagePerDropConversion(); + + /** + * @return Damage the Tool receives when being used as Container Item. 100 is one use, however it is usually 8 times more than normal. + */ + @Override + public int getToolDamagePerContainerCraft(); + + /** + * @return Damage the Tool receives when being used as Weapon, 200 is the normal Value, 100 for actual Weapons. + */ + @Override + public int getToolDamagePerEntityAttack(); + + /** + * @return Basic Quality of the Tool, 0 is normal. If increased, it will increase the general quality of all Tools of this Type. Decreasing is also possible. + */ + @Override + public int getBaseQuality(); + + /** + * @return The Damage Bonus for this Type of Tool against Mobs. 1.0F is normal punch. + */ + @Override + public float getBaseDamage(); + + /** + * @return This gets the Hurt Resistance time for Entities getting hit. (always does 1 as minimum) + */ + @Override + public int getHurtResistanceTime(int aOriginalHurtResistance, Entity aEntity); + + /** + * @return This is a multiplier for the Tool Speed. 1.0F = no special Speed. + */ + @Override + public float getSpeedMultiplier(); + + /** + * @return This is a multiplier for the Tool Speed. 1.0F = no special Durability. + */ + @Override + public float getMaxDurabilityMultiplier(); + + @Override + public DamageSource getDamageSource(EntityLivingBase aPlayer, Entity aEntity); + + @Override + public String getMiningSound(); + + @Override + public String getCraftingSound(); + + @Override + public String getEntityHitSound(); + + @Override + public String getBreakingSound(); + + @Override + public Enchantment[] getEnchantments(ItemStack aStack); + + @Override + public int[] getEnchantmentLevels(ItemStack aStack); + + /** + * @return If this Tool can be used for blocking Damage like a Sword. + */ + @Override + public boolean canBlock(); + + /** + * @return If this Tool can be used as an RC Crowbar. + */ + @Override + public boolean isCrowbar(); + + /** + * @return If this Tool can be used as an BC Wrench. + */ + public boolean isWrench(); + + /** + * @return If this Tool can be used as Weapon i.e. if that is the main purpose. + */ + @Override + public boolean isWeapon(); + + /** + * @return If this Tool is a Ranged Weapon. Return false at isWeapon unless you have a Blade attached to your Bow/Gun or something + */ + @Override + public boolean isRangedWeapon(); + + /** + * @return If this Tool can be used as Weapon i.e. if that is the main purpose. + */ + @Override + public boolean isMiningTool(); + + /** + * aBlock.getHarvestTool(aMetaData) can return the following Values for example. + * "axe", "pickaxe", "sword", "shovel", "hoe", "grafter", "saw", "wrench", "crowbar", "file", "hammer", "plow", "plunger", "scoop", "screwdriver", "sense", "scythe", "softhammer", "cutter", "plasmatorch" + * + * @return If this is a minable Block. Tool Quality checks (like Diamond Tier or something) are separate from this check. + */ + @Override + public boolean isMinableBlock(Block aBlock, byte aMetaData); + + /** + * This lets you modify the Drop List, when this type of Tool has been used. + * + * @return the Amount of modified Items. + */ + @Override + public int convertBlockDrops( + List<ItemStack> aDrops, + ItemStack aStack, + EntityPlayer aPlayer, + Block aBlock, + int aX, + int aY, + int aZ, + byte aMetaData, + int aFortune, + boolean aSilkTouch, + BlockEvent.HarvestDropsEvent aEvent); + + /** + * @return Returns a broken Version of the Item. + */ + @Override + public ItemStack getBrokenItem(ItemStack aStack); + + /** + * @return the Damage actually done to the Mob. + */ + @Override + public float getNormalDamageAgainstEntity( + float aOriginalDamage, Entity aEntity, ItemStack aStack, EntityPlayer aPlayer); + + /** + * @return the Damage actually done to the Mob. + */ + @Override + public float getMagicDamageAgainstEntity( + float aOriginalDamage, Entity aEntity, ItemStack aStack, EntityPlayer aPlayer); + + @Override + public IIconContainer getIcon(boolean aIsToolHead, ItemStack aStack); + + @Override + public short[] getRGBa(boolean aIsToolHead, ItemStack aStack); + + /** + * Called when this gets added to a Tool Item + */ + @Override + public void onStatsAddedToTool(GT_MetaGenerated_Tool aItem, int aID); +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/items/Gregtech_Generic_Item.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/items/Gregtech_Generic_Item.java index 43998577c9..b9e402a2f6 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/items/Gregtech_Generic_Item.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/items/Gregtech_Generic_Item.java @@ -1,11 +1,17 @@ package gtPlusPlus.xmod.gregtech.api.items; -import java.util.List; - import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - +import gregtech.api.enums.SubTag; +import gregtech.api.interfaces.IProjectileItem; +import gregtech.api.util.GT_LanguageManager; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import java.util.List; import net.minecraft.block.BlockDispenser; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.dispenser.*; @@ -19,174 +25,175 @@ import net.minecraft.util.EnumFacing; import net.minecraft.util.IIcon; import net.minecraft.world.World; -import gregtech.api.enums.SubTag; -import gregtech.api.interfaces.IProjectileItem; -import gregtech.api.util.GT_LanguageManager; -import gregtech.api.util.GT_ModHandler; -import gregtech.api.util.GT_Utility; - -import gtPlusPlus.core.creative.AddToCreativeTab; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.Utils; - /** * Extended by most Items, also used as a fallback Item, to prevent the accidental deletion when Errors occur. */ public class Gregtech_Generic_Item extends Item implements IProjectileItem { - private final String mName, mTooltip; - protected IIcon mIcon; - - public Gregtech_Generic_Item(final String aUnlocalized, final String aEnglish, final String aEnglishTooltip) { - this(aUnlocalized, aEnglish, aEnglishTooltip, true); - } - - public Gregtech_Generic_Item(final String aUnlocalized, final String aEnglish, final String aEnglishTooltip, final boolean aWriteToolTipIntoLangFile) { - super(); - this.mName = aUnlocalized; - GT_LanguageManager.addStringLocalization(this.mName + ".name", aEnglish); - if (GT_Utility.isStringValid(aEnglishTooltip)) { - GT_LanguageManager.addStringLocalization(this.mTooltip = this.mName + ".tooltip_main", aEnglishTooltip, aWriteToolTipIntoLangFile); - } else { - this.mTooltip = null; - } - this.setCreativeTab(AddToCreativeTab.tabMachines); - GameRegistry.registerItem(this, this.mName, CORE.MODID); - BlockDispenser.dispenseBehaviorRegistry.putObject(this, new GT_Item_Dispense()); - } - - @Override - public final Item setUnlocalizedName(final String aName) { - return this; - } - - @Override - public final String getUnlocalizedName() { - return this.mName; - } - - @Override - public String getUnlocalizedName(final ItemStack aStack) { - return this.getHasSubtypes() ? this.mName + "." + this.getDamage(aStack) : this.mName; - } - - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(final IIconRegister aIconRegister) { - this.mIcon = aIconRegister.registerIcon(CORE.MODID+":"+this.mName); - } - - @Override - public boolean doesSneakBypassUse(final World aWorld, final int aX, final int aY, final int aZ, final EntityPlayer aPlayer) { - return true; - } - - @Override - public IIcon getIconFromDamage(final int par1) { - return this.mIcon; - } - - public int getTier(final ItemStack aStack) { - return 0; - } - - @Override - public void addInformation(final ItemStack aStack, final EntityPlayer aPlayer, final List aList, final boolean aF3_H) { - if ((this.getMaxDamage() > 0) && !this.getHasSubtypes()) { - aList.add((aStack.getMaxDamage() - this.getDamage(aStack)) + " / " + aStack.getMaxDamage()); - } - if (this.mTooltip != null) { - aList.add(GT_LanguageManager.getTranslation(this.mTooltip)); - } - if (GT_ModHandler.isElectricItem(aStack)) { - aList.add("Tier: " + this.getTier(aStack)); - } - this.addAdditionalToolTips(aList, aStack); - } - - protected void addAdditionalToolTips(final List aList, final ItemStack aStack) { - // - } - - @Override - public void onCreated(final ItemStack aStack, final World aWorld, final EntityPlayer aPlayer) { - this.isItemStackUsable(aStack); - } - - public boolean isItemStackUsable(final ItemStack aStack) { - return true; - } - - public ItemStack onDispense(final IBlockSource aSource, final ItemStack aStack) { - final EnumFacing enumfacing = BlockDispenser.func_149937_b(aSource.getBlockMetadata()); - final IPosition iposition = BlockDispenser.func_149939_a(aSource); - final ItemStack itemstack1 = aStack.splitStack(1); - BehaviorDefaultDispenseItem.doDispense(aSource.getWorld(), itemstack1, 6, enumfacing, iposition); - return aStack; - } - - @Override - public EntityArrow getProjectile(final SubTag aProjectileType, final ItemStack aStack, final World aWorld, final double aX, final double aY, final double aZ) { - return null; - } - - @Override - public EntityArrow getProjectile(final SubTag aProjectileType, final ItemStack aStack, final World aWorld, final EntityLivingBase aEntity, final float aSpeed) { - return null; - } - - @Override - public boolean hasProjectile(final SubTag aProjectileType, final ItemStack aStack) { - return false; - } - - @Override - public ItemStack getContainerItem(final ItemStack aStack) { - return null; - } - - @Override - public boolean hasContainerItem(final ItemStack aStack) { - return this.getContainerItem(aStack) != null; - } - - public static class GT_Item_Dispense extends BehaviorProjectileDispense { - @Override - public ItemStack dispenseStack(final IBlockSource aSource, final ItemStack aStack) { - return ((Gregtech_Generic_Item) aStack.getItem()).onDispense(aSource, aStack); - } - - @Override - protected IProjectile getProjectileEntity(final World aWorld, final IPosition aPosition) { - return null; - } - } - - @Override - public int getColorFromItemStack(final ItemStack stack, int HEX_OxFFFFFF) { - if (stack.getDisplayName().contains("LuV")){ - HEX_OxFFFFFF = 0xffffcc; - } - else if (stack.getDisplayName().contains("ZPM")){ - HEX_OxFFFFFF = 0xace600; - } - else if (stack.getDisplayName().contains("UV")){ - HEX_OxFFFFFF = 0xffff00; - } - else if (stack.getDisplayName().contains("MAX")){ - HEX_OxFFFFFF = 0xff0000; - } - else if (stack.getDisplayName().contains("Sodium")){ - HEX_OxFFFFFF = Utils.rgbtoHexValue(0, 0, 150); - } - else if (stack.getDisplayName().contains("Cadmium")){ - HEX_OxFFFFFF = Utils.rgbtoHexValue(50, 50, 60); - } - else if (stack.getDisplayName().contains("Lithium")){ - HEX_OxFFFFFF = Utils.rgbtoHexValue(225, 220, 255); - } - else { - HEX_OxFFFFFF = 0xffffff; - } - return HEX_OxFFFFFF; - } -}
\ No newline at end of file + private final String mName, mTooltip; + protected IIcon mIcon; + + public Gregtech_Generic_Item(final String aUnlocalized, final String aEnglish, final String aEnglishTooltip) { + this(aUnlocalized, aEnglish, aEnglishTooltip, true); + } + + public Gregtech_Generic_Item( + final String aUnlocalized, + final String aEnglish, + final String aEnglishTooltip, + final boolean aWriteToolTipIntoLangFile) { + super(); + this.mName = aUnlocalized; + GT_LanguageManager.addStringLocalization(this.mName + ".name", aEnglish); + if (GT_Utility.isStringValid(aEnglishTooltip)) { + GT_LanguageManager.addStringLocalization( + this.mTooltip = this.mName + ".tooltip_main", aEnglishTooltip, aWriteToolTipIntoLangFile); + } else { + this.mTooltip = null; + } + this.setCreativeTab(AddToCreativeTab.tabMachines); + GameRegistry.registerItem(this, this.mName, CORE.MODID); + BlockDispenser.dispenseBehaviorRegistry.putObject(this, new GT_Item_Dispense()); + } + + @Override + public final Item setUnlocalizedName(final String aName) { + return this; + } + + @Override + public final String getUnlocalizedName() { + return this.mName; + } + + @Override + public String getUnlocalizedName(final ItemStack aStack) { + return this.getHasSubtypes() ? this.mName + "." + this.getDamage(aStack) : this.mName; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(final IIconRegister aIconRegister) { + this.mIcon = aIconRegister.registerIcon(CORE.MODID + ":" + this.mName); + } + + @Override + public boolean doesSneakBypassUse( + final World aWorld, final int aX, final int aY, final int aZ, final EntityPlayer aPlayer) { + return true; + } + + @Override + public IIcon getIconFromDamage(final int par1) { + return this.mIcon; + } + + public int getTier(final ItemStack aStack) { + return 0; + } + + @Override + public void addInformation( + final ItemStack aStack, final EntityPlayer aPlayer, final List aList, final boolean aF3_H) { + if ((this.getMaxDamage() > 0) && !this.getHasSubtypes()) { + aList.add((aStack.getMaxDamage() - this.getDamage(aStack)) + " / " + aStack.getMaxDamage()); + } + if (this.mTooltip != null) { + aList.add(GT_LanguageManager.getTranslation(this.mTooltip)); + } + if (GT_ModHandler.isElectricItem(aStack)) { + aList.add("Tier: " + this.getTier(aStack)); + } + this.addAdditionalToolTips(aList, aStack); + } + + protected void addAdditionalToolTips(final List aList, final ItemStack aStack) { + // + } + + @Override + public void onCreated(final ItemStack aStack, final World aWorld, final EntityPlayer aPlayer) { + this.isItemStackUsable(aStack); + } + + public boolean isItemStackUsable(final ItemStack aStack) { + return true; + } + + public ItemStack onDispense(final IBlockSource aSource, final ItemStack aStack) { + final EnumFacing enumfacing = BlockDispenser.func_149937_b(aSource.getBlockMetadata()); + final IPosition iposition = BlockDispenser.func_149939_a(aSource); + final ItemStack itemstack1 = aStack.splitStack(1); + BehaviorDefaultDispenseItem.doDispense(aSource.getWorld(), itemstack1, 6, enumfacing, iposition); + return aStack; + } + + @Override + public EntityArrow getProjectile( + final SubTag aProjectileType, + final ItemStack aStack, + final World aWorld, + final double aX, + final double aY, + final double aZ) { + return null; + } + + @Override + public EntityArrow getProjectile( + final SubTag aProjectileType, + final ItemStack aStack, + final World aWorld, + final EntityLivingBase aEntity, + final float aSpeed) { + return null; + } + + @Override + public boolean hasProjectile(final SubTag aProjectileType, final ItemStack aStack) { + return false; + } + + @Override + public ItemStack getContainerItem(final ItemStack aStack) { + return null; + } + + @Override + public boolean hasContainerItem(final ItemStack aStack) { + return this.getContainerItem(aStack) != null; + } + + public static class GT_Item_Dispense extends BehaviorProjectileDispense { + @Override + public ItemStack dispenseStack(final IBlockSource aSource, final ItemStack aStack) { + return ((Gregtech_Generic_Item) aStack.getItem()).onDispense(aSource, aStack); + } + + @Override + protected IProjectile getProjectileEntity(final World aWorld, final IPosition aPosition) { + return null; + } + } + + @Override + public int getColorFromItemStack(final ItemStack stack, int HEX_OxFFFFFF) { + if (stack.getDisplayName().contains("LuV")) { + HEX_OxFFFFFF = 0xffffcc; + } else if (stack.getDisplayName().contains("ZPM")) { + HEX_OxFFFFFF = 0xace600; + } else if (stack.getDisplayName().contains("UV")) { + HEX_OxFFFFFF = 0xffff00; + } else if (stack.getDisplayName().contains("MAX")) { + HEX_OxFFFFFF = 0xff0000; + } else if (stack.getDisplayName().contains("Sodium")) { + HEX_OxFFFFFF = Utils.rgbtoHexValue(0, 0, 150); + } else if (stack.getDisplayName().contains("Cadmium")) { + HEX_OxFFFFFF = Utils.rgbtoHexValue(50, 50, 60); + } else if (stack.getDisplayName().contains("Lithium")) { + HEX_OxFFFFFF = Utils.rgbtoHexValue(225, 220, 255); + } else { + HEX_OxFFFFFF = 0xffffff; + } + return HEX_OxFFFFFF; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/items/Gregtech_MetaItem.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/items/Gregtech_MetaItem.java index 12b90c9a6c..3daf2d3f31 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/items/Gregtech_MetaItem.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/items/Gregtech_MetaItem.java @@ -2,20 +2,8 @@ package gtPlusPlus.xmod.gregtech.api.items; import static gregtech.api.enums.GT_Values.D1; -import java.util.*; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.EnumAction; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; -import net.minecraft.world.World; - import gregtech.api.GregTech_API; import gregtech.api.enums.Materials; import gregtech.api.enums.SubTag; @@ -27,319 +15,336 @@ import gregtech.api.objects.ItemData; import gregtech.api.util.GT_LanguageManager; import gregtech.api.util.GT_OreDictUnificator; import gregtech.api.util.GT_Utility; - import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.xmod.gregtech.api.interfaces.internal.Interface_ItemBehaviour; +import java.util.*; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumAction; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; public abstract class Gregtech_MetaItem extends Gregtech_MetaItem_Base { - /** - * All instances of this Item Class are listed here. - * This gets used to register the Renderer to all Items of this Type, if useStandardMetaItemRenderer() returns true. - * <p/> - * You can also use the unlocalized Name gotten from getUnlocalizedName() as Key if you want to get a specific Item. - */ - public static final HashMap<String, Gregtech_MetaItem> sInstances = new HashMap<>(); - - /* ---------- CONSTRUCTOR AND MEMBER VARIABLES ---------- */ - - public final short mOffset, mItemAmount; - public final BitSet mEnabledItems; - public final BitSet mVisibleItems; - public final IIcon[][] mIconList; - - public final HashMap<Short, IFoodStat> mFoodStats = new HashMap<>(); - public final HashMap<Short, Long[]> mElectricStats = new HashMap<>(); - public final HashMap<Short, Long[]> mFluidContainerStats = new HashMap<>(); - public final HashMap<Short, Short> mBurnValues = new HashMap<>(); - - /** - * Creates the Item using these Parameters. - * - * @param aUnlocalized The Unlocalized Name of this Item. - */ - public Gregtech_MetaItem(final String aUnlocalized, final short aOffset, final short aItemAmount) { - super(aUnlocalized); - this.setCreativeTab(AddToCreativeTab.tabMachines); - this.setHasSubtypes(true); - this.setMaxDamage(0); - this.mEnabledItems = new BitSet(aItemAmount); - this.mVisibleItems = new BitSet(aItemAmount); - - this.mOffset = (short) Math.min(32766, aOffset); - this.mItemAmount = (short) Math.min(aItemAmount, 32766 - this.mOffset); - this.mIconList = new IIcon[aItemAmount][1]; - - sInstances.put(this.getUnlocalizedName(), this); - } - - /** - * This adds a Custom Item to the ending Range. - * - * @param aID The Id of the assigned Item [0 - mItemAmount] (The MetaData gets auto-shifted by +mOffset) - * @param aEnglish The Default Localized Name of the created Item - * @param aToolTip The Default ToolTip of the created Item, you can also insert null for having no ToolTip - * @param aFoodBehavior The Food Value of this Item. Can be null aswell. Just a convenience thing. - * @param aRandomData The OreDict Names you want to give the Item. Also used for TC Aspects and some other things. - * @return An ItemStack containing the newly created Item. - */ - public final ItemStack addItem(final int aID, final String aEnglish, String aToolTip, final Object... aRandomData) { - if (aToolTip == null) { - aToolTip = ""; - } - if ((aID >= 0) && (aID < this.mItemAmount)) { - final ItemStack rStack = new ItemStack(this, 1, this.mOffset + aID); - this.mEnabledItems.set(aID); - this.mVisibleItems.set(aID); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName(rStack) + ".name", aEnglish); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName(rStack) + ".tooltip", aToolTip); - final List<TC_AspectStack> tAspects = new ArrayList<>(); - // Important Stuff to do first - for (final Object tRandomData : aRandomData) { - if (tRandomData instanceof SubTag) { - if (tRandomData == SubTag.INVISIBLE) { - this.mVisibleItems.set(aID, false); - continue; - } - if (tRandomData == SubTag.NO_UNIFICATION) { - GT_OreDictUnificator.addToBlacklist(rStack); - continue; - } - } - } - // now check for the rest - for (final Object tRandomData : aRandomData) { - if (tRandomData != null) { - boolean tUseOreDict = true; - - if (tRandomData instanceof Interface_ItemBehaviour) { - this.addItemBehavior(this.mOffset + aID, (Interface_ItemBehaviour<Gregtech_MetaItem_Base>) tRandomData); - tUseOreDict = false; - } - if (tRandomData instanceof IItemContainer) { - ((IItemContainer) tRandomData).set(rStack); - tUseOreDict = false; - } - if (tRandomData instanceof SubTag) { - continue; - } - if (tRandomData instanceof TC_AspectStack) { - ((TC_AspectStack) tRandomData).addToAspectList(tAspects); - continue; - } - if (tRandomData instanceof ItemData) { - if (GT_Utility.isStringValid(tRandomData)) { - GT_OreDictUnificator.registerOre(tRandomData, rStack); - } else { - GT_OreDictUnificator.addItemData(rStack, (ItemData) tRandomData); - } - continue; - } - if (tUseOreDict) { - GT_OreDictUnificator.registerOre(tRandomData, rStack); - continue; - } - } - } - if (GregTech_API.sThaumcraftCompat != null) { - GregTech_API.sThaumcraftCompat.registerThaumcraftAspectsToItem(rStack, tAspects, false); - } - return rStack; - } - return null; - } - - /** - * Sets the Furnace Burn Value for the Item. - * - * @param aMetaValue the Meta Value of the Item you want to set it to. [0 - 32765] - * @param aValue 200 = 1 Burn Process = 500 EU, max = 32767 (that is 81917.5 EU) - * @return the Item itself for convenience in constructing. - */ - public final Gregtech_MetaItem setBurnValue(final int aMetaValue, final int aValue) { - if ((aMetaValue < 0) || (aMetaValue >= (this.mOffset + this.mEnabledItems.length())) || (aValue < 0)) { - return this; - } - if (aValue == 0) { - this.mBurnValues.remove((short) aMetaValue); - } else { - this.mBurnValues.put((short) aMetaValue, aValue > Short.MAX_VALUE ? Short.MAX_VALUE : (short) aValue); - } - return this; - } - - /** - * @param aMetaValue the Meta Value of the Item you want to set it to. [0 - 32765] - * @param aMaxCharge Maximum Charge. (if this is == 0 it will remove the Electric Behavior) - * @param aTransferLimit Transfer Limit. - * @param aTier The electric Tier. - * @param aSpecialData If this Item has a Fixed Charge, like a SingleUse Battery (if > 0). - * Use -1 if you want to make this Battery chargeable (the use and canUse Functions will still discharge if you just use this) - * Use -2 if you want to make this Battery dischargeable. - * Use -3 if you want to make this Battery charge/discharge-able. - * @return the Item itself for convenience in constructing. - */ - public final Gregtech_MetaItem setElectricStats(final int aMetaValue, final long aMaxCharge, final long aTransferLimit, final long aTier, final long aSpecialData, final boolean aUseAnimations) { - if ((aMetaValue < 0) || (aMetaValue >= (this.mOffset + this.mEnabledItems.length()))) { - return this; - } - if (aMaxCharge == 0) { - this.mElectricStats.remove((short) aMetaValue); - } else { - this.mElectricStats.put((short) aMetaValue, new Long[]{aMaxCharge, Math.max(0, aTransferLimit), Math.max(-1, aTier), aSpecialData}); - if ((aMetaValue >= this.mOffset) && aUseAnimations) { - this.mIconList[aMetaValue - this.mOffset] = Arrays.copyOf(this.mIconList[aMetaValue - this.mOffset], Math.max(9, this.mIconList[aMetaValue - this.mOffset].length)); - } - } - return this; - } - - /** - * @param aMetaValue the Meta Value of the Item you want to set it to. [0 - 32765] - * @param aMaxCharge Maximum Charge. (if this is == 0 it will remove the Electric Behavior) - * @param aTransferLimit Transfer Limit. - * @param aTier The electric Tier. - * @param aSpecialData If this Item has a Fixed Charge, like a SingleUse Battery (if > 0). - * Use -1 if you want to make this Battery chargeable (the use and canUse Functions will still discharge if you just use this) - * Use -2 if you want to make this Battery dischargeable. - * Use -3 if you want to make this Battery charge/discharge-able. - * @return the Item itself for convenience in constructing. - */ - public final Gregtech_MetaItem setFluidContainerStats(final int aMetaValue, final long aCapacity, final long aStacksize) { - if ((aMetaValue < 0) || (aMetaValue >= (this.mOffset + this.mEnabledItems.length()))) { - return this; - } - if (aCapacity < 0) { - this.mElectricStats.remove((short) aMetaValue); - } else { - this.mFluidContainerStats.put((short) aMetaValue, new Long[]{aCapacity, Math.max(1, aStacksize)}); - } - return this; - } - - /** - * @return if this MetaGenerated Item should use my Default Renderer System. - */ - public boolean useStandardMetaItemRenderer() { - return true; - } - - /** - * @return the Color Modulation the Material is going to be rendered with. - */ - public short[] getRGBa(final ItemStack aStack) { - return Materials._NULL.getRGBA(); - } - - /** - * @return the Icon the Material is going to be rendered with. - */ - public IIconContainer getIconContainer(final int aMetaData) { - return null; - } - - /* ---------- INTERNAL OVERRIDES ---------- */ - - @Override - public ItemStack onItemRightClick(final ItemStack aStack, final World aWorld, final EntityPlayer aPlayer) { - return super.onItemRightClick(aStack, aWorld, aPlayer); - } - - @Override - public int getMaxItemUseDuration(final ItemStack aStack) { - return this.mFoodStats.get((short) this.getDamage(aStack)) == null ? 0 : 32; - } - - @Override - public EnumAction getItemUseAction(final ItemStack aStack) { - return EnumAction.none; - } - - @Override - public final ItemStack onEaten(final ItemStack aStack, final World aWorld, final EntityPlayer aPlayer) { - final IFoodStat tStat = this.mFoodStats.get((short) this.getDamage(aStack)); - if (tStat != null) { - - } - return aStack; - } - - @Override - @SideOnly(Side.CLIENT) - public void getSubItems(final Item var1, final CreativeTabs aCreativeTab, final List aList) { - for (int i = 0, j = this.mEnabledItems.length(); i < j; i++) { - if (this.mVisibleItems.get(i) || (D1 && this.mEnabledItems.get(i))) { - final Long[] tStats = this.mElectricStats.get((short) (this.mOffset + i)); - if ((tStats != null) && (tStats[3] < 0)) { - final ItemStack tStack = new ItemStack(this, 1, this.mOffset + i); - this.setCharge(tStack, Math.abs(tStats[0])); - this.isItemStackUsable(tStack); - aList.add(tStack); - } - if ((tStats == null) || (tStats[3] != -2)) { - final ItemStack tStack = new ItemStack(this, 1, this.mOffset + i); - this.isItemStackUsable(tStack); - aList.add(tStack); - } - } - } - } - - @Override - @SideOnly(Side.CLIENT) - public final void registerIcons(final IIconRegister aIconRegister) { - for (short i = 0, j = (short) this.mEnabledItems.length(); i < j; i++) { - if (this.mEnabledItems.get(i)) { - for (byte k = 1; k < this.mIconList[i].length; k++) { - this.mIconList[i][k] = aIconRegister.registerIcon(CORE.MODID+":"+this.getUnlocalizedName() + "/" + i + "/" + k); - } - this.mIconList[i][0] = aIconRegister.registerIcon(CORE.MODID+":"+this.getUnlocalizedName() + "/" + i); - } - } - } - - @Override - public final Long[] getElectricStats(final ItemStack aStack) { - return this.mElectricStats.get((short) aStack.getItemDamage()); - } - - @Override - public final Long[] getFluidContainerStats(final ItemStack aStack) { - return this.mFluidContainerStats.get((short) aStack.getItemDamage()); - } - - @Override - public int getItemEnchantability() { - return 0; - } - - @Override - public boolean isBookEnchantable(final ItemStack aStack, final ItemStack aBook) { - return false; - } - - @Override - public boolean getIsRepairable(final ItemStack aStack, final ItemStack aMaterial) { - return false; - } - - @Override - public int getColorFromItemStack(final ItemStack stack, int HEX_OxFFFFFF) { - if (stack.getDisplayName().contains("LuV")){ - HEX_OxFFFFFF = 0xffffcc; - } - else if (stack.getDisplayName().contains("ZPM")){ - HEX_OxFFFFFF = 0xace600; - } - else if (stack.getDisplayName().contains("UV")){ - HEX_OxFFFFFF = 0xffff00; - } - else if (stack.getDisplayName().contains("MAX")){ - HEX_OxFFFFFF = 0xff0000; - } - else { - HEX_OxFFFFFF = 0xffffff; - } - return HEX_OxFFFFFF; - } -}
\ No newline at end of file + /** + * All instances of this Item Class are listed here. + * This gets used to register the Renderer to all Items of this Type, if useStandardMetaItemRenderer() returns true. + * <p/> + * You can also use the unlocalized Name gotten from getUnlocalizedName() as Key if you want to get a specific Item. + */ + public static final HashMap<String, Gregtech_MetaItem> sInstances = new HashMap<>(); + + /* ---------- CONSTRUCTOR AND MEMBER VARIABLES ---------- */ + + public final short mOffset, mItemAmount; + public final BitSet mEnabledItems; + public final BitSet mVisibleItems; + public final IIcon[][] mIconList; + + public final HashMap<Short, IFoodStat> mFoodStats = new HashMap<>(); + public final HashMap<Short, Long[]> mElectricStats = new HashMap<>(); + public final HashMap<Short, Long[]> mFluidContainerStats = new HashMap<>(); + public final HashMap<Short, Short> mBurnValues = new HashMap<>(); + + /** + * Creates the Item using these Parameters. + * + * @param aUnlocalized The Unlocalized Name of this Item. + */ + public Gregtech_MetaItem(final String aUnlocalized, final short aOffset, final short aItemAmount) { + super(aUnlocalized); + this.setCreativeTab(AddToCreativeTab.tabMachines); + this.setHasSubtypes(true); + this.setMaxDamage(0); + this.mEnabledItems = new BitSet(aItemAmount); + this.mVisibleItems = new BitSet(aItemAmount); + + this.mOffset = (short) Math.min(32766, aOffset); + this.mItemAmount = (short) Math.min(aItemAmount, 32766 - this.mOffset); + this.mIconList = new IIcon[aItemAmount][1]; + + sInstances.put(this.getUnlocalizedName(), this); + } + + /** + * This adds a Custom Item to the ending Range. + * + * @param aID The Id of the assigned Item [0 - mItemAmount] (The MetaData gets auto-shifted by +mOffset) + * @param aEnglish The Default Localized Name of the created Item + * @param aToolTip The Default ToolTip of the created Item, you can also insert null for having no ToolTip + * @param aFoodBehavior The Food Value of this Item. Can be null aswell. Just a convenience thing. + * @param aRandomData The OreDict Names you want to give the Item. Also used for TC Aspects and some other things. + * @return An ItemStack containing the newly created Item. + */ + public final ItemStack addItem(final int aID, final String aEnglish, String aToolTip, final Object... aRandomData) { + if (aToolTip == null) { + aToolTip = ""; + } + if ((aID >= 0) && (aID < this.mItemAmount)) { + final ItemStack rStack = new ItemStack(this, 1, this.mOffset + aID); + this.mEnabledItems.set(aID); + this.mVisibleItems.set(aID); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName(rStack) + ".name", aEnglish); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName(rStack) + ".tooltip", aToolTip); + final List<TC_AspectStack> tAspects = new ArrayList<>(); + // Important Stuff to do first + for (final Object tRandomData : aRandomData) { + if (tRandomData instanceof SubTag) { + if (tRandomData == SubTag.INVISIBLE) { + this.mVisibleItems.set(aID, false); + continue; + } + if (tRandomData == SubTag.NO_UNIFICATION) { + GT_OreDictUnificator.addToBlacklist(rStack); + continue; + } + } + } + // now check for the rest + for (final Object tRandomData : aRandomData) { + if (tRandomData != null) { + boolean tUseOreDict = true; + + if (tRandomData instanceof Interface_ItemBehaviour) { + this.addItemBehavior( + this.mOffset + aID, (Interface_ItemBehaviour<Gregtech_MetaItem_Base>) tRandomData); + tUseOreDict = false; + } + if (tRandomData instanceof IItemContainer) { + ((IItemContainer) tRandomData).set(rStack); + tUseOreDict = false; + } + if (tRandomData instanceof SubTag) { + continue; + } + if (tRandomData instanceof TC_AspectStack) { + ((TC_AspectStack) tRandomData).addToAspectList(tAspects); + continue; + } + if (tRandomData instanceof ItemData) { + if (GT_Utility.isStringValid(tRandomData)) { + GT_OreDictUnificator.registerOre(tRandomData, rStack); + } else { + GT_OreDictUnificator.addItemData(rStack, (ItemData) tRandomData); + } + continue; + } + if (tUseOreDict) { + GT_OreDictUnificator.registerOre(tRandomData, rStack); + continue; + } + } + } + if (GregTech_API.sThaumcraftCompat != null) { + GregTech_API.sThaumcraftCompat.registerThaumcraftAspectsToItem(rStack, tAspects, false); + } + return rStack; + } + return null; + } + + /** + * Sets the Furnace Burn Value for the Item. + * + * @param aMetaValue the Meta Value of the Item you want to set it to. [0 - 32765] + * @param aValue 200 = 1 Burn Process = 500 EU, max = 32767 (that is 81917.5 EU) + * @return the Item itself for convenience in constructing. + */ + public final Gregtech_MetaItem setBurnValue(final int aMetaValue, final int aValue) { + if ((aMetaValue < 0) || (aMetaValue >= (this.mOffset + this.mEnabledItems.length())) || (aValue < 0)) { + return this; + } + if (aValue == 0) { + this.mBurnValues.remove((short) aMetaValue); + } else { + this.mBurnValues.put((short) aMetaValue, aValue > Short.MAX_VALUE ? Short.MAX_VALUE : (short) aValue); + } + return this; + } + + /** + * @param aMetaValue the Meta Value of the Item you want to set it to. [0 - 32765] + * @param aMaxCharge Maximum Charge. (if this is == 0 it will remove the Electric Behavior) + * @param aTransferLimit Transfer Limit. + * @param aTier The electric Tier. + * @param aSpecialData If this Item has a Fixed Charge, like a SingleUse Battery (if > 0). + * Use -1 if you want to make this Battery chargeable (the use and canUse Functions will still discharge if you just use this) + * Use -2 if you want to make this Battery dischargeable. + * Use -3 if you want to make this Battery charge/discharge-able. + * @return the Item itself for convenience in constructing. + */ + public final Gregtech_MetaItem setElectricStats( + final int aMetaValue, + final long aMaxCharge, + final long aTransferLimit, + final long aTier, + final long aSpecialData, + final boolean aUseAnimations) { + if ((aMetaValue < 0) || (aMetaValue >= (this.mOffset + this.mEnabledItems.length()))) { + return this; + } + if (aMaxCharge == 0) { + this.mElectricStats.remove((short) aMetaValue); + } else { + this.mElectricStats.put( + (short) aMetaValue, + new Long[] {aMaxCharge, Math.max(0, aTransferLimit), Math.max(-1, aTier), aSpecialData}); + if ((aMetaValue >= this.mOffset) && aUseAnimations) { + this.mIconList[aMetaValue - this.mOffset] = Arrays.copyOf( + this.mIconList[aMetaValue - this.mOffset], + Math.max(9, this.mIconList[aMetaValue - this.mOffset].length)); + } + } + return this; + } + + /** + * @param aMetaValue the Meta Value of the Item you want to set it to. [0 - 32765] + * @param aMaxCharge Maximum Charge. (if this is == 0 it will remove the Electric Behavior) + * @param aTransferLimit Transfer Limit. + * @param aTier The electric Tier. + * @param aSpecialData If this Item has a Fixed Charge, like a SingleUse Battery (if > 0). + * Use -1 if you want to make this Battery chargeable (the use and canUse Functions will still discharge if you just use this) + * Use -2 if you want to make this Battery dischargeable. + * Use -3 if you want to make this Battery charge/discharge-able. + * @return the Item itself for convenience in constructing. + */ + public final Gregtech_MetaItem setFluidContainerStats( + final int aMetaValue, final long aCapacity, final long aStacksize) { + if ((aMetaValue < 0) || (aMetaValue >= (this.mOffset + this.mEnabledItems.length()))) { + return this; + } + if (aCapacity < 0) { + this.mElectricStats.remove((short) aMetaValue); + } else { + this.mFluidContainerStats.put((short) aMetaValue, new Long[] {aCapacity, Math.max(1, aStacksize)}); + } + return this; + } + + /** + * @return if this MetaGenerated Item should use my Default Renderer System. + */ + public boolean useStandardMetaItemRenderer() { + return true; + } + + /** + * @return the Color Modulation the Material is going to be rendered with. + */ + public short[] getRGBa(final ItemStack aStack) { + return Materials._NULL.getRGBA(); + } + + /** + * @return the Icon the Material is going to be rendered with. + */ + public IIconContainer getIconContainer(final int aMetaData) { + return null; + } + + /* ---------- INTERNAL OVERRIDES ---------- */ + + @Override + public ItemStack onItemRightClick(final ItemStack aStack, final World aWorld, final EntityPlayer aPlayer) { + return super.onItemRightClick(aStack, aWorld, aPlayer); + } + + @Override + public int getMaxItemUseDuration(final ItemStack aStack) { + return this.mFoodStats.get((short) this.getDamage(aStack)) == null ? 0 : 32; + } + + @Override + public EnumAction getItemUseAction(final ItemStack aStack) { + return EnumAction.none; + } + + @Override + public final ItemStack onEaten(final ItemStack aStack, final World aWorld, final EntityPlayer aPlayer) { + final IFoodStat tStat = this.mFoodStats.get((short) this.getDamage(aStack)); + if (tStat != null) {} + + return aStack; + } + + @Override + @SideOnly(Side.CLIENT) + public void getSubItems(final Item var1, final CreativeTabs aCreativeTab, final List aList) { + for (int i = 0, j = this.mEnabledItems.length(); i < j; i++) { + if (this.mVisibleItems.get(i) || (D1 && this.mEnabledItems.get(i))) { + final Long[] tStats = this.mElectricStats.get((short) (this.mOffset + i)); + if ((tStats != null) && (tStats[3] < 0)) { + final ItemStack tStack = new ItemStack(this, 1, this.mOffset + i); + this.setCharge(tStack, Math.abs(tStats[0])); + this.isItemStackUsable(tStack); + aList.add(tStack); + } + if ((tStats == null) || (tStats[3] != -2)) { + final ItemStack tStack = new ItemStack(this, 1, this.mOffset + i); + this.isItemStackUsable(tStack); + aList.add(tStack); + } + } + } + } + + @Override + @SideOnly(Side.CLIENT) + public final void registerIcons(final IIconRegister aIconRegister) { + for (short i = 0, j = (short) this.mEnabledItems.length(); i < j; i++) { + if (this.mEnabledItems.get(i)) { + for (byte k = 1; k < this.mIconList[i].length; k++) { + this.mIconList[i][k] = aIconRegister.registerIcon( + CORE.MODID + ":" + this.getUnlocalizedName() + "/" + i + "/" + k); + } + this.mIconList[i][0] = + aIconRegister.registerIcon(CORE.MODID + ":" + this.getUnlocalizedName() + "/" + i); + } + } + } + + @Override + public final Long[] getElectricStats(final ItemStack aStack) { + return this.mElectricStats.get((short) aStack.getItemDamage()); + } + + @Override + public final Long[] getFluidContainerStats(final ItemStack aStack) { + return this.mFluidContainerStats.get((short) aStack.getItemDamage()); + } + + @Override + public int getItemEnchantability() { + return 0; + } + + @Override + public boolean isBookEnchantable(final ItemStack aStack, final ItemStack aBook) { + return false; + } + + @Override + public boolean getIsRepairable(final ItemStack aStack, final ItemStack aMaterial) { + return false; + } + + @Override + public int getColorFromItemStack(final ItemStack stack, int HEX_OxFFFFFF) { + if (stack.getDisplayName().contains("LuV")) { + HEX_OxFFFFFF = 0xffffcc; + } else if (stack.getDisplayName().contains("ZPM")) { + HEX_OxFFFFFF = 0xace600; + } else if (stack.getDisplayName().contains("UV")) { + HEX_OxFFFFFF = 0xffff00; + } else if (stack.getDisplayName().contains("MAX")) { + HEX_OxFFFFFF = 0xff0000; + } else { + HEX_OxFFFFFF = 0xffffff; + } + return HEX_OxFFFFFF; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/items/Gregtech_MetaItem_Base.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/items/Gregtech_MetaItem_Base.java index ec1c90186a..a961b28cf7 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/items/Gregtech_MetaItem_Base.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/items/Gregtech_MetaItem_Base.java @@ -2,10 +2,14 @@ package gtPlusPlus.xmod.gregtech.api.items; import static gregtech.api.enums.GT_Values.*; +import gregtech.api.enums.SubTag; +import gregtech.api.util.*; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.xmod.gregtech.api.interfaces.internal.Interface_ItemBehaviour; +import ic2.api.item.*; import java.util.ArrayList; import java.util.HashMap; import java.util.List; - import net.minecraft.dispenser.IBlockSource; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; @@ -17,659 +21,746 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import net.minecraft.world.World; - -import gregtech.api.enums.SubTag; -import gregtech.api.util.*; - -import gtPlusPlus.core.util.Utils; -import gtPlusPlus.xmod.gregtech.api.interfaces.internal.Interface_ItemBehaviour; -import ic2.api.item.*; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidContainerItem; -public abstract class Gregtech_MetaItem_Base extends Gregtech_Generic_Item implements ISpecialElectricItem, IElectricItemManager, IFluidContainerItem { - /* ---------- CONSTRUCTOR AND MEMBER VARIABLES ---------- */ - private final HashMap<Short, ArrayList<Interface_ItemBehaviour<Gregtech_MetaItem_Base>>> mItemBehaviors = new HashMap<>(); - - /** - * Creates the Item using these Parameters. - * - * @param aUnlocalized The Unlocalized Name of this Item. - * @param aGeneratedPrefixList The OreDict Prefixes you want to have generated. - */ - public Gregtech_MetaItem_Base(final String aUnlocalized) { - super(aUnlocalized, "Generated Item", null, false); - this.setHasSubtypes(true); - this.setMaxDamage(0); - } - - /** - * Adds a special Item Behaviour to the Item. - * <p/> - * Note: the boolean Behaviours sometimes won't be executed if another boolean Behaviour returned true before. - * - * @param aMetaValue the Meta Value of the Item you want to add it to. [0 - 32765] - * @param aBehavior the Click Behavior you want to add. - * @return the Item itself for convenience in constructing. - */ - public final Gregtech_MetaItem_Base addItemBehavior(final int aMetaValue, final Interface_ItemBehaviour<Gregtech_MetaItem_Base> aBehavior) { - if ((aMetaValue < 0) || (aMetaValue >= 32766) || (aBehavior == null)) { - return this; - } - ArrayList<Interface_ItemBehaviour<Gregtech_MetaItem_Base>> tList = this.mItemBehaviors.get((short) aMetaValue); - if (tList == null) { - tList = new ArrayList<>(1); - this.mItemBehaviors.put((short) aMetaValue, tList); - } - tList.add(aBehavior); - return this; - } - - public abstract Long[] getElectricStats(ItemStack aStack); - - public abstract Long[] getFluidContainerStats(ItemStack aStack); - - @Override - public boolean hasProjectile(final SubTag aProjectileType, final ItemStack aStack) { - final ArrayList<Interface_ItemBehaviour<Gregtech_MetaItem_Base>> tList = this.mItemBehaviors.get((short) this.getDamage(aStack)); - if (tList != null) { - for (final Interface_ItemBehaviour<Gregtech_MetaItem_Base> tBehavior : tList) { - if (tBehavior.hasProjectile(this, aProjectileType, aStack)) { - return true; - } - } - } - return super.hasProjectile(aProjectileType, aStack); - } - - @Override - public EntityArrow getProjectile(final SubTag aProjectileType, final ItemStack aStack, final World aWorld, final double aX, final double aY, final double aZ) { - final ArrayList<Interface_ItemBehaviour<Gregtech_MetaItem_Base>> tList = this.mItemBehaviors.get((short) this.getDamage(aStack)); - if (tList != null) { - for (final Interface_ItemBehaviour<Gregtech_MetaItem_Base> tBehavior : tList) { - final EntityArrow rArrow = tBehavior.getProjectile(this, aProjectileType, aStack, aWorld, aX, aY, aZ); - if (rArrow != null) { - return rArrow; - } - } - } - return super.getProjectile(aProjectileType, aStack, aWorld, aX, aY, aZ); - } - - @Override - public EntityArrow getProjectile(final SubTag aProjectileType, final ItemStack aStack, final World aWorld, final EntityLivingBase aEntity, final float aSpeed) { - final ArrayList<Interface_ItemBehaviour<Gregtech_MetaItem_Base>> tList = this.mItemBehaviors.get((short) this.getDamage(aStack)); - if (tList != null) { - for (final Interface_ItemBehaviour<Gregtech_MetaItem_Base> tBehavior : tList) { - final EntityArrow rArrow = tBehavior.getProjectile(this, aProjectileType, aStack, aWorld, aEntity, aSpeed); - if (rArrow != null) { - return rArrow; - } - } - } - return super.getProjectile(aProjectileType, aStack, aWorld, aEntity, aSpeed); - } - - @Override - public ItemStack onDispense(final IBlockSource aSource, final ItemStack aStack) { - final ArrayList<Interface_ItemBehaviour<Gregtech_MetaItem_Base>> tList = this.mItemBehaviors.get((short) this.getDamage(aStack)); - if (tList != null) { - for (final Interface_ItemBehaviour<Gregtech_MetaItem_Base> tBehavior : tList) { - if (tBehavior.canDispense(this, aSource, aStack)) { - return tBehavior.onDispense(this, aSource, aStack); - } - } - } - return super.onDispense(aSource, aStack); - } - - @Override - public boolean isItemStackUsable(final ItemStack aStack) { - final ArrayList<Interface_ItemBehaviour<Gregtech_MetaItem_Base>> tList = this.mItemBehaviors.get((short) this.getDamage(aStack)); - if (tList != null) { - for (final Interface_ItemBehaviour<Gregtech_MetaItem_Base> tBehavior : tList) { - if (!tBehavior.isItemStackUsable(this, aStack)) { - return false; - } - } - } - return super.isItemStackUsable(aStack); - } - - @Override - public boolean onLeftClickEntity(final ItemStack aStack, final EntityPlayer aPlayer, final Entity aEntity) { - this.use(aStack, 0, aPlayer); - this.isItemStackUsable(aStack); - final ArrayList<Interface_ItemBehaviour<Gregtech_MetaItem_Base>> tList = this.mItemBehaviors.get((short) this.getDamage(aStack)); - if (tList != null) { - for (final Interface_ItemBehaviour<Gregtech_MetaItem_Base> tBehavior : tList) { - try { - if (tBehavior.onLeftClickEntity(this, aStack, aPlayer, aEntity)) { - if (aStack.stackSize <= 0) { - aPlayer.destroyCurrentEquippedItem(); - } - return true; - } - if (aStack.stackSize <= 0) { - aPlayer.destroyCurrentEquippedItem(); - return false; - } - } catch (final Throwable e) { - if (D1) { - e.printStackTrace(GT_Log.err); - } - } - } - } - return false; - } - - @Override - public boolean onItemUse(final ItemStack aStack, final EntityPlayer aPlayer, final World aWorld, final int aX, final int aY, final int aZ, final int aSide, final float hitX, final float hitY, final float hitZ) { - this.use(aStack, 0, aPlayer); - this.isItemStackUsable(aStack); - final ArrayList<Interface_ItemBehaviour<Gregtech_MetaItem_Base>> tList = this.mItemBehaviors.get((short) this.getDamage(aStack)); - if (tList != null) { - for (final Interface_ItemBehaviour<Gregtech_MetaItem_Base> tBehavior : tList) { - try { - if (tBehavior.onItemUse(this, aStack, aPlayer, aWorld, aX, aY, aZ, aSide, hitX, hitY, hitZ)) { - if (aStack.stackSize <= 0) { - aPlayer.destroyCurrentEquippedItem(); - } - return true; - } - if (aStack.stackSize <= 0) { - aPlayer.destroyCurrentEquippedItem(); - return false; - } - } catch (final Throwable e) { - if (D1) { - e.printStackTrace(GT_Log.err); - } - } - } - } - return false; - } - - @Override - public boolean onItemUseFirst(final ItemStack aStack, final EntityPlayer aPlayer, final World aWorld, final int aX, final int aY, final int aZ, final int aSide, final float hitX, final float hitY, final float hitZ) { - this.use(aStack, 0, aPlayer); - this.isItemStackUsable(aStack); - final ArrayList<Interface_ItemBehaviour<Gregtech_MetaItem_Base>> tList = this.mItemBehaviors.get((short) this.getDamage(aStack)); - if (tList != null) { - for (final Interface_ItemBehaviour<Gregtech_MetaItem_Base> tBehavior : tList) { - try { - if (tBehavior.onItemUseFirst(this, aStack, aPlayer, aWorld, aX, aY, aZ, aSide, hitX, hitY, hitZ)) { - if (aStack.stackSize <= 0) { - aPlayer.destroyCurrentEquippedItem(); - } - return true; - } - if (aStack.stackSize <= 0) { - aPlayer.destroyCurrentEquippedItem(); - return false; - } - } catch (final Throwable e) { - if (D1) { - e.printStackTrace(GT_Log.err); - } - } - } - } - return false; - } - - @Override - public ItemStack onItemRightClick(ItemStack aStack, final World aWorld, final EntityPlayer aPlayer) { - this.use(aStack, 0, aPlayer); - this.isItemStackUsable(aStack); - final ArrayList<Interface_ItemBehaviour<Gregtech_MetaItem_Base>> tList = this.mItemBehaviors.get((short) this.getDamage(aStack)); - if (tList != null) { - for (final Interface_ItemBehaviour<Gregtech_MetaItem_Base> tBehavior : tList) { - try { - aStack = tBehavior.onItemRightClick(this, aStack, aWorld, aPlayer); - } catch (final Throwable e) { - if (D1) { - e.printStackTrace(GT_Log.err); - } - } - } - } - return aStack; - } - - @Override - public final void addInformation(final ItemStack aStack, final EntityPlayer aPlayer, List aList, final boolean aF3_H) { - final String tKey = this.getUnlocalizedName(aStack) + ".tooltip", tString = GT_LanguageManager.getTranslation(tKey); - if (GT_Utility.isStringValid(tString) && !tKey.equals(tString)) { - aList.add(tString); - } - - Long[] - tStats = this.getElectricStats(aStack); - if (tStats != null) { - if (tStats[3] > 0) { - aList.add(EnumChatFormatting.AQUA + "Contains " + GT_Utility.formatNumbers(tStats[3]) + " EU Tier: " + (tStats[2] >= 0 ? tStats[2] : 0) + EnumChatFormatting.GRAY); - } else { - final long tCharge = this.getRealCharge(aStack); - if ((tStats[3] == -2) && (tCharge <= 0)) { - aList.add(EnumChatFormatting.AQUA + "Empty. You should recycle it properly." + EnumChatFormatting.GRAY); - } else { - aList.add(EnumChatFormatting.AQUA + "" + GT_Utility.formatNumbers(tCharge) + " / " + GT_Utility.formatNumbers(Math.abs(tStats[0])) + " EU - Voltage: " + V[(int) (tStats[2] >= 0 ? tStats[2] < V.length ? tStats[2] : V.length - 1 : 1)] + EnumChatFormatting.GRAY); - } - } - } - - tStats = this.getFluidContainerStats(aStack); - if ((tStats != null) && (tStats[0] > 0)) { - final FluidStack tFluid = this.getFluidContent(aStack); - aList.add(EnumChatFormatting.BLUE + ((tFluid == null ? "No Fluids Contained" : GT_Utility.getFluidName(tFluid, true))) + EnumChatFormatting.GRAY); - aList.add(EnumChatFormatting.BLUE + ((tFluid == null ? 0 : tFluid.amount) + "L / " + tStats[0] + "L") + EnumChatFormatting.GRAY); - } - - final ArrayList<Interface_ItemBehaviour<Gregtech_MetaItem_Base>> tList = this.mItemBehaviors.get((short) this.getDamage(aStack)); - if (tList != null) { - for (final Interface_ItemBehaviour<Gregtech_MetaItem_Base> tBehavior : tList) { - aList = tBehavior.getAdditionalToolTips(this, aList, aStack); - } - } - - this.addAdditionalToolTips(aList, aStack); - } - - @Override - public void onUpdate(final ItemStack aStack, final World aWorld, final Entity aPlayer, final int aTimer, final boolean aIsInHand) { - final ArrayList<Interface_ItemBehaviour<Gregtech_MetaItem_Base>> tList = this.mItemBehaviors.get((short) this.getDamage(aStack)); - if (tList != null) { - for (final Interface_ItemBehaviour<Gregtech_MetaItem_Base> tBehavior : tList) { - tBehavior.onUpdate(this, aStack, aWorld, aPlayer, aTimer, aIsInHand); - } - } - } - - @Override - public final boolean canProvideEnergy(final ItemStack aStack) { - final Long[] tStats = this.getElectricStats(aStack); - if (tStats == null) { - return false; - } - return (tStats[3] > 0) || ((aStack.stackSize == 1) && ((tStats[3] == -2) || (tStats[3] == -3))); - } - - @Override - public final double getMaxCharge(final ItemStack aStack) { - final Long[] tStats = this.getElectricStats(aStack); - if (tStats == null) { - return 0; - } - return Math.abs(tStats[0]); - } - - @Override - public final double getTransferLimit(final ItemStack aStack) { - final Long[] tStats = this.getElectricStats(aStack); - if (tStats == null) { - return 0; - } - return Math.max(tStats[1], tStats[3]); - } - - @Override - public final double charge(final ItemStack aStack, final double aCharge, final int aTier, final boolean aIgnoreTransferLimit, final boolean aSimulate) { - final Long[] tStats = this.getElectricStats(aStack); - if ((tStats == null) || (tStats[2] > aTier) || !((tStats[3] == -1) || (tStats[3] == -3) || ((tStats[3] < 0) && (aCharge == Integer.MAX_VALUE))) || (aStack.stackSize != 1)) { - return 0; - } - final long tChargeBefore = this.getRealCharge(aStack), tNewCharge = aCharge == Integer.MAX_VALUE ? Long.MAX_VALUE : Math.min(Math.abs(tStats[0]), tChargeBefore + (aIgnoreTransferLimit ? (long) aCharge : Math.min(tStats[1], (long) aCharge))); - if (!aSimulate) { - this.setCharge(aStack, tNewCharge); - } - return tNewCharge - tChargeBefore; - } - - @Override - public final double discharge(final ItemStack aStack, final double aCharge, final int aTier, final boolean aIgnoreTransferLimit, final boolean aBatteryAlike, final boolean aSimulate) { - final Long[] tStats = this.getElectricStats(aStack); - if ((tStats == null) || (tStats[2] > aTier)) { - return 0; - } - if (aBatteryAlike && !this.canProvideEnergy(aStack)) { - return 0; - } - if (tStats[3] > 0) { - if ((aCharge < tStats[3]) || (aStack.stackSize < 1)) { - return 0; - } - if (!aSimulate) { - aStack.stackSize--; - } - return tStats[3]; - } - final long tChargeBefore = this.getRealCharge(aStack), tNewCharge = Math.max(0, tChargeBefore - (aIgnoreTransferLimit ? (long) aCharge : Math.min(tStats[1], (long) aCharge))); - if (!aSimulate) { - this.setCharge(aStack, tNewCharge); - } - return tChargeBefore - tNewCharge; - } - - @Override - public final double getCharge(final ItemStack aStack) { - return this.getRealCharge(aStack); - } - - @Override - public final boolean canUse(final ItemStack aStack, final double aAmount) { - return this.getRealCharge(aStack) >= aAmount; - } - - @Override - public final boolean use(final ItemStack aStack, final double aAmount, final EntityLivingBase aPlayer) { - this.chargeFromArmor(aStack, aPlayer); - if ((aPlayer instanceof EntityPlayer) && ((EntityPlayer) aPlayer).capabilities.isCreativeMode) { - return true; - } - final double tTransfer = this.discharge(aStack, aAmount, Integer.MAX_VALUE, true, false, true); - if (tTransfer == aAmount) { - this.discharge(aStack, aAmount, Integer.MAX_VALUE, true, false, false); - this.chargeFromArmor(aStack, aPlayer); - return true; - } - this.discharge(aStack, aAmount, Integer.MAX_VALUE, true, false, false); - this.chargeFromArmor(aStack, aPlayer); - return false; - } - - @Override - public final void chargeFromArmor(final ItemStack aStack, final EntityLivingBase aPlayer) { - if ((aPlayer == null) || aPlayer.worldObj.isRemote) { - return; - } - for (int i = 1; i < 5; i++) { - final ItemStack tArmor = aPlayer.getEquipmentInSlot(i); - if (GT_ModHandler.isElectricItem(tArmor)) { - final IElectricItem tArmorItem = (IElectricItem) tArmor.getItem(); - if (tArmorItem.canProvideEnergy(tArmor) && (tArmorItem.getTier(tArmor) >= this.getTier(aStack))) { - final double tCharge = ElectricItem.manager.discharge(tArmor, this.charge(aStack, Integer.MAX_VALUE - 1, Integer.MAX_VALUE, true, true), Integer.MAX_VALUE, true, true, false); - if (tCharge > 0) { - this.charge(aStack, tCharge, Integer.MAX_VALUE, true, false); - if (aPlayer instanceof EntityPlayer) { - final Container tContainer = ((EntityPlayer) aPlayer).openContainer; - if (tContainer != null) { - tContainer.detectAndSendChanges(); - } - } - } - } - } - } - } - - public final long getRealCharge(final ItemStack aStack) { - final Long[] tStats = this.getElectricStats(aStack); - if (tStats == null) { - return 0; - } - if (tStats[3] > 0) { - return (int) (long) tStats[3]; - } - final NBTTagCompound tNBT = aStack.getTagCompound(); - return tNBT == null ? 0 : tNBT.getLong("GT.ItemCharge"); - } - - public final boolean setCharge(final ItemStack aStack, long aCharge) { - final Long[] tStats = this.getElectricStats(aStack); - if ((tStats == null) || (tStats[3] > 0)) { - return false; - } - NBTTagCompound tNBT = aStack.getTagCompound(); - if (tNBT == null) { - tNBT = new NBTTagCompound(); - } - tNBT.removeTag("GT.ItemCharge"); - aCharge = Math.min(tStats[0] < 0 ? Math.abs(tStats[0] / 2) : aCharge, Math.abs(tStats[0])); - if (aCharge > 0) { - aStack.setItemDamage(this.getChargedMetaData(aStack)); - tNBT.setLong("GT.ItemCharge", aCharge); - } else { - aStack.setItemDamage(this.getEmptyMetaData(aStack)); - } - if (tNBT.hasNoTags()) { - aStack.setTagCompound(null); - } else { - aStack.setTagCompound(tNBT); - } - this.isItemStackUsable(aStack); - return true; - } - - public short getChargedMetaData(final ItemStack aStack) { - return (short) aStack.getItemDamage(); - } - - public short getEmptyMetaData(final ItemStack aStack) { - return (short) aStack.getItemDamage(); - } - - @Override - public FluidStack getFluid(final ItemStack aStack) { - return this.getFluidContent(aStack); - } - - @Override - public int getCapacity(final ItemStack aStack) { - final Long[] tStats = this.getFluidContainerStats(aStack); - return tStats == null ? 0 : (int) Math.max(0, tStats[0]); - } - - @Override - public int fill(final ItemStack aStack, final FluidStack aFluid, final boolean doFill) { - if ((aStack == null) || (aStack.stackSize != 1)) { - return 0; - } - - final ItemStack tStack = GT_Utility.fillFluidContainer(aFluid, aStack, false, false); - if (tStack != null) { - aStack.setItemDamage(tStack.getItemDamage()); - aStack.func_150996_a(tStack.getItem()); - return GT_Utility.getFluidForFilledItem(tStack, false).amount; - } - - final Long[] tStats = this.getFluidContainerStats(aStack); - if ((tStats == null) || (tStats[0] <= 0) || (aFluid == null) || (aFluid.getFluid().getID() <= 0) || (aFluid.amount <= 0)) { - return 0; - } - - FluidStack tFluid = this.getFluidContent(aStack); - - if ((tFluid == null) || (tFluid.getFluid().getID() <= 0)) { - if (aFluid.amount <= tStats[0]) { - if (doFill) { - this.setFluidContent(aStack, aFluid); - } - return aFluid.amount; - } - if (doFill) { - tFluid = aFluid.copy(); - tFluid.amount = (int) (long) tStats[0]; - this.setFluidContent(aStack, tFluid); - } - return (int) (long) tStats[0]; - } - - if (!tFluid.isFluidEqual(aFluid)) { - return 0; - } - - final int space = (int) (long) tStats[0] - tFluid.amount; - if (aFluid.amount <= space) { - if (doFill) { - tFluid.amount += aFluid.amount; - this.setFluidContent(aStack, tFluid); - } - return aFluid.amount; - } - if (doFill) { - tFluid.amount = (int) (long) tStats[0]; - this.setFluidContent(aStack, tFluid); - } - return space; - } - - @Override - public FluidStack drain(final ItemStack aStack, final int maxDrain, final boolean doDrain) { - if ((aStack == null) || (aStack.stackSize != 1)) { - return null; - } - - FluidStack tFluid = GT_Utility.getFluidForFilledItem(aStack, false); - if ((tFluid != null) && (maxDrain >= tFluid.amount)) { - final ItemStack tStack = GT_Utility.getContainerItem(aStack, false); - if (tStack == null) { - aStack.stackSize = 0; - return tFluid; - } - aStack.setItemDamage(tStack.getItemDamage()); - aStack.func_150996_a(tStack.getItem()); - return tFluid; - } - - final Long[] tStats = this.getFluidContainerStats(aStack); - if ((tStats == null) || (tStats[0] <= 0)) { - return null; - } - - tFluid = this.getFluidContent(aStack); - if (tFluid == null) { - return null; - } - - int used = maxDrain; - if (tFluid.amount < used) { - used = tFluid.amount; - } - if (doDrain) { - tFluid.amount -= used; - this.setFluidContent(aStack, tFluid); - } - - final FluidStack drained = tFluid.copy(); - drained.amount = used; - return drained; - } - - public FluidStack getFluidContent(final ItemStack aStack) { - final Long[] tStats = this.getFluidContainerStats(aStack); - if ((tStats == null) || (tStats[0] <= 0)) { - return GT_Utility.getFluidForFilledItem(aStack, false); - } - final NBTTagCompound tNBT = aStack.getTagCompound(); - return tNBT == null ? null : FluidStack.loadFluidStackFromNBT(tNBT.getCompoundTag("GT.FluidContent")); - } - - public void setFluidContent(final ItemStack aStack, final FluidStack aFluid) { - NBTTagCompound tNBT = aStack.getTagCompound(); - if (tNBT == null) { - tNBT = new NBTTagCompound(); - } else { - tNBT.removeTag("GT.FluidContent"); - } - if ((aFluid != null) && (aFluid.amount > 0)) { - tNBT.setTag("GT.FluidContent", aFluid.writeToNBT(new NBTTagCompound())); - } - if (tNBT.hasNoTags()) { - aStack.setTagCompound(null); - } else { - aStack.setTagCompound(tNBT); - } - this.isItemStackUsable(aStack); - } - - @Override - public int getItemStackLimit(final ItemStack aStack) { - Long[] tStats = this.getElectricStats(aStack); - if ((tStats != null) && ((tStats[3] == -1) || (tStats[3] == -3)) && (this.getRealCharge(aStack) > 0)) { - return 1; - } - tStats = this.getFluidContainerStats(aStack); - if (tStats != null) { - return (int) (long) tStats[1]; - } - return 64; - } - - @Override - public final Item getChargedItem(final ItemStack itemStack) { - return this; - } - - @Override - public final Item getEmptyItem(final ItemStack itemStack) { - return this; - } - - @Override - public final int getTier(final ItemStack aStack) { - final Long[] tStats = this.getElectricStats(aStack); - return (int) (tStats == null ? Integer.MAX_VALUE : tStats[2]); - } - - @Override - public final String getToolTip(final ItemStack aStack) { - return null; - } // This has its own ToolTip Handler, no need to let the IC2 Handler screw us up at this Point - - @Override - public final IElectricItemManager getManager(final ItemStack aStack) { - return this; - } // We are our own Manager - - @Override - public final boolean getShareTag() { - return true; - } // just to be sure. - - @Override - public int getItemEnchantability() { - return 0; - } - - @Override - public boolean isBookEnchantable(final ItemStack aStack, final ItemStack aBook) { - return false; - } - - @Override - public boolean getIsRepairable(final ItemStack aStack, final ItemStack aMaterial) { - return false; - } - - @Override - public int getColorFromItemStack(final ItemStack stack, int HEX_OxFFFFFF) { - if (stack.getDisplayName().contains("LuV")){ - HEX_OxFFFFFF = 0xffffcc; - } - else if (stack.getDisplayName().contains("ZPM")){ - HEX_OxFFFFFF = 0xace600; - } - else if (stack.getDisplayName().contains("UV")){ - HEX_OxFFFFFF = 0xffff00; - } - else if (stack.getDisplayName().contains("MAX")){ - HEX_OxFFFFFF = 0xff0000; - } - else if (stack.getDisplayName().contains("Sodium")){ - HEX_OxFFFFFF = Utils.rgbtoHexValue(0, 0, 150); - } - else if (stack.getDisplayName().contains("Cadmium")){ - HEX_OxFFFFFF = Utils.rgbtoHexValue(50, 50, 60); - } - else if (stack.getDisplayName().contains("Lithium")){ - HEX_OxFFFFFF = Utils.rgbtoHexValue(225, 220, 255); - } - else { - HEX_OxFFFFFF = 0xffffff; - } - return HEX_OxFFFFFF; - } -}
\ No newline at end of file +public abstract class Gregtech_MetaItem_Base extends Gregtech_Generic_Item + implements ISpecialElectricItem, IElectricItemManager, IFluidContainerItem { + /* ---------- CONSTRUCTOR AND MEMBER VARIABLES ---------- */ + private final HashMap<Short, ArrayList<Interface_ItemBehaviour<Gregtech_MetaItem_Base>>> mItemBehaviors = + new HashMap<>(); + + /** + * Creates the Item using these Parameters. + * + * @param aUnlocalized The Unlocalized Name of this Item. + * @param aGeneratedPrefixList The OreDict Prefixes you want to have generated. + */ + public Gregtech_MetaItem_Base(final String aUnlocalized) { + super(aUnlocalized, "Generated Item", null, false); + this.setHasSubtypes(true); + this.setMaxDamage(0); + } + + /** + * Adds a special Item Behaviour to the Item. + * <p/> + * Note: the boolean Behaviours sometimes won't be executed if another boolean Behaviour returned true before. + * + * @param aMetaValue the Meta Value of the Item you want to add it to. [0 - 32765] + * @param aBehavior the Click Behavior you want to add. + * @return the Item itself for convenience in constructing. + */ + public final Gregtech_MetaItem_Base addItemBehavior( + final int aMetaValue, final Interface_ItemBehaviour<Gregtech_MetaItem_Base> aBehavior) { + if ((aMetaValue < 0) || (aMetaValue >= 32766) || (aBehavior == null)) { + return this; + } + ArrayList<Interface_ItemBehaviour<Gregtech_MetaItem_Base>> tList = this.mItemBehaviors.get((short) aMetaValue); + if (tList == null) { + tList = new ArrayList<>(1); + this.mItemBehaviors.put((short) aMetaValue, tList); + } + tList.add(aBehavior); + return this; + } + + public abstract Long[] getElectricStats(ItemStack aStack); + + public abstract Long[] getFluidContainerStats(ItemStack aStack); + + @Override + public boolean hasProjectile(final SubTag aProjectileType, final ItemStack aStack) { + final ArrayList<Interface_ItemBehaviour<Gregtech_MetaItem_Base>> tList = + this.mItemBehaviors.get((short) this.getDamage(aStack)); + if (tList != null) { + for (final Interface_ItemBehaviour<Gregtech_MetaItem_Base> tBehavior : tList) { + if (tBehavior.hasProjectile(this, aProjectileType, aStack)) { + return true; + } + } + } + return super.hasProjectile(aProjectileType, aStack); + } + + @Override + public EntityArrow getProjectile( + final SubTag aProjectileType, + final ItemStack aStack, + final World aWorld, + final double aX, + final double aY, + final double aZ) { + final ArrayList<Interface_ItemBehaviour<Gregtech_MetaItem_Base>> tList = + this.mItemBehaviors.get((short) this.getDamage(aStack)); + if (tList != null) { + for (final Interface_ItemBehaviour<Gregtech_MetaItem_Base> tBehavior : tList) { + final EntityArrow rArrow = tBehavior.getProjectile(this, aProjectileType, aStack, aWorld, aX, aY, aZ); + if (rArrow != null) { + return rArrow; + } + } + } + return super.getProjectile(aProjectileType, aStack, aWorld, aX, aY, aZ); + } + + @Override + public EntityArrow getProjectile( + final SubTag aProjectileType, + final ItemStack aStack, + final World aWorld, + final EntityLivingBase aEntity, + final float aSpeed) { + final ArrayList<Interface_ItemBehaviour<Gregtech_MetaItem_Base>> tList = + this.mItemBehaviors.get((short) this.getDamage(aStack)); + if (tList != null) { + for (final Interface_ItemBehaviour<Gregtech_MetaItem_Base> tBehavior : tList) { + final EntityArrow rArrow = + tBehavior.getProjectile(this, aProjectileType, aStack, aWorld, aEntity, aSpeed); + if (rArrow != null) { + return rArrow; + } + } + } + return super.getProjectile(aProjectileType, aStack, aWorld, aEntity, aSpeed); + } + + @Override + public ItemStack onDispense(final IBlockSource aSource, final ItemStack aStack) { + final ArrayList<Interface_ItemBehaviour<Gregtech_MetaItem_Base>> tList = + this.mItemBehaviors.get((short) this.getDamage(aStack)); + if (tList != null) { + for (final Interface_ItemBehaviour<Gregtech_MetaItem_Base> tBehavior : tList) { + if (tBehavior.canDispense(this, aSource, aStack)) { + return tBehavior.onDispense(this, aSource, aStack); + } + } + } + return super.onDispense(aSource, aStack); + } + + @Override + public boolean isItemStackUsable(final ItemStack aStack) { + final ArrayList<Interface_ItemBehaviour<Gregtech_MetaItem_Base>> tList = + this.mItemBehaviors.get((short) this.getDamage(aStack)); + if (tList != null) { + for (final Interface_ItemBehaviour<Gregtech_MetaItem_Base> tBehavior : tList) { + if (!tBehavior.isItemStackUsable(this, aStack)) { + return false; + } + } + } + return super.isItemStackUsable(aStack); + } + + @Override + public boolean onLeftClickEntity(final ItemStack aStack, final EntityPlayer aPlayer, final Entity aEntity) { + this.use(aStack, 0, aPlayer); + this.isItemStackUsable(aStack); + final ArrayList<Interface_ItemBehaviour<Gregtech_MetaItem_Base>> tList = + this.mItemBehaviors.get((short) this.getDamage(aStack)); + if (tList != null) { + for (final Interface_ItemBehaviour<Gregtech_MetaItem_Base> tBehavior : tList) { + try { + if (tBehavior.onLeftClickEntity(this, aStack, aPlayer, aEntity)) { + if (aStack.stackSize <= 0) { + aPlayer.destroyCurrentEquippedItem(); + } + return true; + } + if (aStack.stackSize <= 0) { + aPlayer.destroyCurrentEquippedItem(); + return false; + } + } catch (final Throwable e) { + if (D1) { + e.printStackTrace(GT_Log.err); + } + } + } + } + return false; + } + + @Override + public boolean onItemUse( + final ItemStack aStack, + final EntityPlayer aPlayer, + final World aWorld, + final int aX, + final int aY, + final int aZ, + final int aSide, + final float hitX, + final float hitY, + final float hitZ) { + this.use(aStack, 0, aPlayer); + this.isItemStackUsable(aStack); + final ArrayList<Interface_ItemBehaviour<Gregtech_MetaItem_Base>> tList = + this.mItemBehaviors.get((short) this.getDamage(aStack)); + if (tList != null) { + for (final Interface_ItemBehaviour<Gregtech_MetaItem_Base> tBehavior : tList) { + try { + if (tBehavior.onItemUse(this, aStack, aPlayer, aWorld, aX, aY, aZ, aSide, hitX, hitY, hitZ)) { + if (aStack.stackSize <= 0) { + aPlayer.destroyCurrentEquippedItem(); + } + return true; + } + if (aStack.stackSize <= 0) { + aPlayer.destroyCurrentEquippedItem(); + return false; + } + } catch (final Throwable e) { + if (D1) { + e.printStackTrace(GT_Log.err); + } + } + } + } + return false; + } + + @Override + public boolean onItemUseFirst( + final ItemStack aStack, + final EntityPlayer aPlayer, + final World aWorld, + final int aX, + final int aY, + final int aZ, + final int aSide, + final float hitX, + final float hitY, + final float hitZ) { + this.use(aStack, 0, aPlayer); + this.isItemStackUsable(aStack); + final ArrayList<Interface_ItemBehaviour<Gregtech_MetaItem_Base>> tList = + this.mItemBehaviors.get((short) this.getDamage(aStack)); + if (tList != null) { + for (final Interface_ItemBehaviour<Gregtech_MetaItem_Base> tBehavior : tList) { + try { + if (tBehavior.onItemUseFirst(this, aStack, aPlayer, aWorld, aX, aY, aZ, aSide, hitX, hitY, hitZ)) { + if (aStack.stackSize <= 0) { + aPlayer.destroyCurrentEquippedItem(); + } + return true; + } + if (aStack.stackSize <= 0) { + aPlayer.destroyCurrentEquippedItem(); + return false; + } + } catch (final Throwable e) { + if (D1) { + e.printStackTrace(GT_Log.err); + } + } + } + } + return false; + } + + @Override + public ItemStack onItemRightClick(ItemStack aStack, final World aWorld, final EntityPlayer aPlayer) { + this.use(aStack, 0, aPlayer); + this.isItemStackUsable(aStack); + final ArrayList<Interface_ItemBehaviour<Gregtech_MetaItem_Base>> tList = + this.mItemBehaviors.get((short) this.getDamage(aStack)); + if (tList != null) { + for (final Interface_ItemBehaviour<Gregtech_MetaItem_Base> tBehavior : tList) { + try { + aStack = tBehavior.onItemRightClick(this, aStack, aWorld, aPlayer); + } catch (final Throwable e) { + if (D1) { + e.printStackTrace(GT_Log.err); + } + } + } + } + return aStack; + } + + @Override + public final void addInformation( + final ItemStack aStack, final EntityPlayer aPlayer, List aList, final boolean aF3_H) { + final String tKey = this.getUnlocalizedName(aStack) + ".tooltip", + tString = GT_LanguageManager.getTranslation(tKey); + if (GT_Utility.isStringValid(tString) && !tKey.equals(tString)) { + aList.add(tString); + } + + Long[] tStats = this.getElectricStats(aStack); + if (tStats != null) { + if (tStats[3] > 0) { + aList.add(EnumChatFormatting.AQUA + "Contains " + GT_Utility.formatNumbers(tStats[3]) + " EU Tier: " + + (tStats[2] >= 0 ? tStats[2] : 0) + EnumChatFormatting.GRAY); + } else { + final long tCharge = this.getRealCharge(aStack); + if ((tStats[3] == -2) && (tCharge <= 0)) { + aList.add(EnumChatFormatting.AQUA + "Empty. You should recycle it properly." + + EnumChatFormatting.GRAY); + } else { + aList.add(EnumChatFormatting.AQUA + "" + GT_Utility.formatNumbers(tCharge) + " / " + + GT_Utility.formatNumbers(Math.abs(tStats[0])) + " EU - Voltage: " + + V[(int) (tStats[2] >= 0 ? tStats[2] < V.length ? tStats[2] : V.length - 1 : 1)] + + EnumChatFormatting.GRAY); + } + } + } + + tStats = this.getFluidContainerStats(aStack); + if ((tStats != null) && (tStats[0] > 0)) { + final FluidStack tFluid = this.getFluidContent(aStack); + aList.add(EnumChatFormatting.BLUE + + ((tFluid == null ? "No Fluids Contained" : GT_Utility.getFluidName(tFluid, true))) + + EnumChatFormatting.GRAY); + aList.add(EnumChatFormatting.BLUE + + ((tFluid == null ? 0 : tFluid.amount) + "L / " + tStats[0] + "L") + + EnumChatFormatting.GRAY); + } + + final ArrayList<Interface_ItemBehaviour<Gregtech_MetaItem_Base>> tList = + this.mItemBehaviors.get((short) this.getDamage(aStack)); + if (tList != null) { + for (final Interface_ItemBehaviour<Gregtech_MetaItem_Base> tBehavior : tList) { + aList = tBehavior.getAdditionalToolTips(this, aList, aStack); + } + } + + this.addAdditionalToolTips(aList, aStack); + } + + @Override + public void onUpdate( + final ItemStack aStack, + final World aWorld, + final Entity aPlayer, + final int aTimer, + final boolean aIsInHand) { + final ArrayList<Interface_ItemBehaviour<Gregtech_MetaItem_Base>> tList = + this.mItemBehaviors.get((short) this.getDamage(aStack)); + if (tList != null) { + for (final Interface_ItemBehaviour<Gregtech_MetaItem_Base> tBehavior : tList) { + tBehavior.onUpdate(this, aStack, aWorld, aPlayer, aTimer, aIsInHand); + } + } + } + + @Override + public final boolean canProvideEnergy(final ItemStack aStack) { + final Long[] tStats = this.getElectricStats(aStack); + if (tStats == null) { + return false; + } + return (tStats[3] > 0) || ((aStack.stackSize == 1) && ((tStats[3] == -2) || (tStats[3] == -3))); + } + + @Override + public final double getMaxCharge(final ItemStack aStack) { + final Long[] tStats = this.getElectricStats(aStack); + if (tStats == null) { + return 0; + } + return Math.abs(tStats[0]); + } + + @Override + public final double getTransferLimit(final ItemStack aStack) { + final Long[] tStats = this.getElectricStats(aStack); + if (tStats == null) { + return 0; + } + return Math.max(tStats[1], tStats[3]); + } + + @Override + public final double charge( + final ItemStack aStack, + final double aCharge, + final int aTier, + final boolean aIgnoreTransferLimit, + final boolean aSimulate) { + final Long[] tStats = this.getElectricStats(aStack); + if ((tStats == null) + || (tStats[2] > aTier) + || !((tStats[3] == -1) || (tStats[3] == -3) || ((tStats[3] < 0) && (aCharge == Integer.MAX_VALUE))) + || (aStack.stackSize != 1)) { + return 0; + } + final long tChargeBefore = this.getRealCharge(aStack), + tNewCharge = + aCharge == Integer.MAX_VALUE + ? Long.MAX_VALUE + : Math.min( + Math.abs(tStats[0]), + tChargeBefore + + (aIgnoreTransferLimit + ? (long) aCharge + : Math.min(tStats[1], (long) aCharge))); + if (!aSimulate) { + this.setCharge(aStack, tNewCharge); + } + return tNewCharge - tChargeBefore; + } + + @Override + public final double discharge( + final ItemStack aStack, + final double aCharge, + final int aTier, + final boolean aIgnoreTransferLimit, + final boolean aBatteryAlike, + final boolean aSimulate) { + final Long[] tStats = this.getElectricStats(aStack); + if ((tStats == null) || (tStats[2] > aTier)) { + return 0; + } + if (aBatteryAlike && !this.canProvideEnergy(aStack)) { + return 0; + } + if (tStats[3] > 0) { + if ((aCharge < tStats[3]) || (aStack.stackSize < 1)) { + return 0; + } + if (!aSimulate) { + aStack.stackSize--; + } + return tStats[3]; + } + final long tChargeBefore = this.getRealCharge(aStack), + tNewCharge = + Math.max( + 0, + tChargeBefore + - (aIgnoreTransferLimit + ? (long) aCharge + : Math.min(tStats[1], (long) aCharge))); + if (!aSimulate) { + this.setCharge(aStack, tNewCharge); + } + return tChargeBefore - tNewCharge; + } + + @Override + public final double getCharge(final ItemStack aStack) { + return this.getRealCharge(aStack); + } + + @Override + public final boolean canUse(final ItemStack aStack, final double aAmount) { + return this.getRealCharge(aStack) >= aAmount; + } + + @Override + public final boolean use(final ItemStack aStack, final double aAmount, final EntityLivingBase aPlayer) { + this.chargeFromArmor(aStack, aPlayer); + if ((aPlayer instanceof EntityPlayer) && ((EntityPlayer) aPlayer).capabilities.isCreativeMode) { + return true; + } + final double tTransfer = this.discharge(aStack, aAmount, Integer.MAX_VALUE, true, false, true); + if (tTransfer == aAmount) { + this.discharge(aStack, aAmount, Integer.MAX_VALUE, true, false, false); + this.chargeFromArmor(aStack, aPlayer); + return true; + } + this.discharge(aStack, aAmount, Integer.MAX_VALUE, true, false, false); + this.chargeFromArmor(aStack, aPlayer); + return false; + } + + @Override + public final void chargeFromArmor(final ItemStack aStack, final EntityLivingBase aPlayer) { + if ((aPlayer == null) || aPlayer.worldObj.isRemote) { + return; + } + for (int i = 1; i < 5; i++) { + final ItemStack tArmor = aPlayer.getEquipmentInSlot(i); + if (GT_ModHandler.isElectricItem(tArmor)) { + final IElectricItem tArmorItem = (IElectricItem) tArmor.getItem(); + if (tArmorItem.canProvideEnergy(tArmor) && (tArmorItem.getTier(tArmor) >= this.getTier(aStack))) { + final double tCharge = ElectricItem.manager.discharge( + tArmor, + this.charge(aStack, Integer.MAX_VALUE - 1, Integer.MAX_VALUE, true, true), + Integer.MAX_VALUE, + true, + true, + false); + if (tCharge > 0) { + this.charge(aStack, tCharge, Integer.MAX_VALUE, true, false); + if (aPlayer instanceof EntityPlayer) { + final Container tContainer = ((EntityPlayer) aPlayer).openContainer; + if (tContainer != null) { + tContainer.detectAndSendChanges(); + } + } + } + } + } + } + } + + public final long getRealCharge(final ItemStack aStack) { + final Long[] tStats = this.getElectricStats(aStack); + if (tStats == null) { + return 0; + } + if (tStats[3] > 0) { + return (int) (long) tStats[3]; + } + final NBTTagCompound tNBT = aStack.getTagCompound(); + return tNBT == null ? 0 : tNBT.getLong("GT.ItemCharge"); + } + + public final boolean setCharge(final ItemStack aStack, long aCharge) { + final Long[] tStats = this.getElectricStats(aStack); + if ((tStats == null) || (tStats[3] > 0)) { + return false; + } + NBTTagCompound tNBT = aStack.getTagCompound(); + if (tNBT == null) { + tNBT = new NBTTagCompound(); + } + tNBT.removeTag("GT.ItemCharge"); + aCharge = Math.min(tStats[0] < 0 ? Math.abs(tStats[0] / 2) : aCharge, Math.abs(tStats[0])); + if (aCharge > 0) { + aStack.setItemDamage(this.getChargedMetaData(aStack)); + tNBT.setLong("GT.ItemCharge", aCharge); + } else { + aStack.setItemDamage(this.getEmptyMetaData(aStack)); + } + if (tNBT.hasNoTags()) { + aStack.setTagCompound(null); + } else { + aStack.setTagCompound(tNBT); + } + this.isItemStackUsable(aStack); + return true; + } + + public short getChargedMetaData(final ItemStack aStack) { + return (short) aStack.getItemDamage(); + } + + public short getEmptyMetaData(final ItemStack aStack) { + return (short) aStack.getItemDamage(); + } + + @Override + public FluidStack getFluid(final ItemStack aStack) { + return this.getFluidContent(aStack); + } + + @Override + public int getCapacity(final ItemStack aStack) { + final Long[] tStats = this.getFluidContainerStats(aStack); + return tStats == null ? 0 : (int) Math.max(0, tStats[0]); + } + + @Override + public int fill(final ItemStack aStack, final FluidStack aFluid, final boolean doFill) { + if ((aStack == null) || (aStack.stackSize != 1)) { + return 0; + } + + final ItemStack tStack = GT_Utility.fillFluidContainer(aFluid, aStack, false, false); + if (tStack != null) { + aStack.setItemDamage(tStack.getItemDamage()); + aStack.func_150996_a(tStack.getItem()); + return GT_Utility.getFluidForFilledItem(tStack, false).amount; + } + + final Long[] tStats = this.getFluidContainerStats(aStack); + if ((tStats == null) + || (tStats[0] <= 0) + || (aFluid == null) + || (aFluid.getFluid().getID() <= 0) + || (aFluid.amount <= 0)) { + return 0; + } + + FluidStack tFluid = this.getFluidContent(aStack); + + if ((tFluid == null) || (tFluid.getFluid().getID() <= 0)) { + if (aFluid.amount <= tStats[0]) { + if (doFill) { + this.setFluidContent(aStack, aFluid); + } + return aFluid.amount; + } + if (doFill) { + tFluid = aFluid.copy(); + tFluid.amount = (int) (long) tStats[0]; + this.setFluidContent(aStack, tFluid); + } + return (int) (long) tStats[0]; + } + + if (!tFluid.isFluidEqual(aFluid)) { + return 0; + } + + final int space = (int) (long) tStats[0] - tFluid.amount; + if (aFluid.amount <= space) { + if (doFill) { + tFluid.amount += aFluid.amount; + this.setFluidContent(aStack, tFluid); + } + return aFluid.amount; + } + if (doFill) { + tFluid.amount = (int) (long) tStats[0]; + this.setFluidContent(aStack, tFluid); + } + return space; + } + + @Override + public FluidStack drain(final ItemStack aStack, final int maxDrain, final boolean doDrain) { + if ((aStack == null) || (aStack.stackSize != 1)) { + return null; + } + + FluidStack tFluid = GT_Utility.getFluidForFilledItem(aStack, false); + if ((tFluid != null) && (maxDrain >= tFluid.amount)) { + final ItemStack tStack = GT_Utility.getContainerItem(aStack, false); + if (tStack == null) { + aStack.stackSize = 0; + return tFluid; + } + aStack.setItemDamage(tStack.getItemDamage()); + aStack.func_150996_a(tStack.getItem()); + return tFluid; + } + + final Long[] tStats = this.getFluidContainerStats(aStack); + if ((tStats == null) || (tStats[0] <= 0)) { + return null; + } + + tFluid = this.getFluidContent(aStack); + if (tFluid == null) { + return null; + } + + int used = maxDrain; + if (tFluid.amount < used) { + used = tFluid.amount; + } + if (doDrain) { + tFluid.amount -= used; + this.setFluidContent(aStack, tFluid); + } + + final FluidStack drained = tFluid.copy(); + drained.amount = used; + return drained; + } + + public FluidStack getFluidContent(final ItemStack aStack) { + final Long[] tStats = this.getFluidContainerStats(aStack); + if ((tStats == null) || (tStats[0] <= 0)) { + return GT_Utility.getFluidForFilledItem(aStack, false); + } + final NBTTagCompound tNBT = aStack.getTagCompound(); + return tNBT == null ? null : FluidStack.loadFluidStackFromNBT(tNBT.getCompoundTag("GT.FluidContent")); + } + + public void setFluidContent(final ItemStack aStack, final FluidStack aFluid) { + NBTTagCompound tNBT = aStack.getTagCompound(); + if (tNBT == null) { + tNBT = new NBTTagCompound(); + } else { + tNBT.removeTag("GT.FluidContent"); + } + if ((aFluid != null) && (aFluid.amount > 0)) { + tNBT.setTag("GT.FluidContent", aFluid.writeToNBT(new NBTTagCompound())); + } + if (tNBT.hasNoTags()) { + aStack.setTagCompound(null); + } else { + aStack.setTagCompound(tNBT); + } + this.isItemStackUsable(aStack); + } + + @Override + public int getItemStackLimit(final ItemStack aStack) { + Long[] tStats = this.getElectricStats(aStack); + if ((tStats != null) && ((tStats[3] == -1) || (tStats[3] == -3)) && (this.getRealCharge(aStack) > 0)) { + return 1; + } + tStats = this.getFluidContainerStats(aStack); + if (tStats != null) { + return (int) (long) tStats[1]; + } + return 64; + } + + @Override + public final Item getChargedItem(final ItemStack itemStack) { + return this; + } + + @Override + public final Item getEmptyItem(final ItemStack itemStack) { + return this; + } + + @Override + public final int getTier(final ItemStack aStack) { + final Long[] tStats = this.getElectricStats(aStack); + return (int) (tStats == null ? Integer.MAX_VALUE : tStats[2]); + } + + @Override + public final String getToolTip(final ItemStack aStack) { + return null; + } // This has its own ToolTip Handler, no need to let the IC2 Handler screw us up at this Point + + @Override + public final IElectricItemManager getManager(final ItemStack aStack) { + return this; + } // We are our own Manager + + @Override + public final boolean getShareTag() { + return true; + } // just to be sure. + + @Override + public int getItemEnchantability() { + return 0; + } + + @Override + public boolean isBookEnchantable(final ItemStack aStack, final ItemStack aBook) { + return false; + } + + @Override + public boolean getIsRepairable(final ItemStack aStack, final ItemStack aMaterial) { + return false; + } + + @Override + public int getColorFromItemStack(final ItemStack stack, int HEX_OxFFFFFF) { + if (stack.getDisplayName().contains("LuV")) { + HEX_OxFFFFFF = 0xffffcc; + } else if (stack.getDisplayName().contains("ZPM")) { + HEX_OxFFFFFF = 0xace600; + } else if (stack.getDisplayName().contains("UV")) { + HEX_OxFFFFFF = 0xffff00; + } else if (stack.getDisplayName().contains("MAX")) { + HEX_OxFFFFFF = 0xff0000; + } else if (stack.getDisplayName().contains("Sodium")) { + HEX_OxFFFFFF = Utils.rgbtoHexValue(0, 0, 150); + } else if (stack.getDisplayName().contains("Cadmium")) { + HEX_OxFFFFFF = Utils.rgbtoHexValue(50, 50, 60); + } else if (stack.getDisplayName().contains("Lithium")) { + HEX_OxFFFFFF = Utils.rgbtoHexValue(225, 220, 255); + } else { + HEX_OxFFFFFF = 0xffffff; + } + return HEX_OxFFFFFF; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/items/Gregtech_MetaItem_X32.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/items/Gregtech_MetaItem_X32.java index a5430846a9..a7f7cae271 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/items/Gregtech_MetaItem_X32.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/items/Gregtech_MetaItem_X32.java @@ -1,16 +1,7 @@ package gtPlusPlus.xmod.gregtech.api.items; -import java.util.Arrays; -import java.util.List; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; - import gregtech.api.GregTech_API; import gregtech.api.enums.GT_Values; import gregtech.api.enums.Materials; @@ -19,9 +10,14 @@ import gregtech.api.interfaces.IIconContainer; import gregtech.api.util.GT_LanguageManager; import gregtech.api.util.GT_OreDictUnificator; import gregtech.api.util.GT_Utility; - import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.math.MathUtils; +import java.util.Arrays; +import java.util.List; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; /** * @author Gregorius Techneticies @@ -37,207 +33,214 @@ import gtPlusPlus.core.util.math.MathUtils; */ public abstract class Gregtech_MetaItem_X32 extends Gregtech_MetaItem { - protected final OrePrefixes[] mGeneratedPrefixList; - - /** - * Creates the Item using these Parameters. - * - * @param aUnlocalized The Unlocalized Name of this Item. - * @param aGeneratedPrefixList The OreDict Prefixes you want to have generated. - */ - public Gregtech_MetaItem_X32(final String aUnlocalized, final OrePrefixes... aGeneratedPrefixList) { - super(aUnlocalized, (short) 32000, (short) 766); - this.mGeneratedPrefixList = Arrays.copyOf(aGeneratedPrefixList, 32); - - for (int i = 0; i < 32000; i++) { - final OrePrefixes tPrefix = this.mGeneratedPrefixList[i / 1000]; - if (tPrefix == null) { - continue; - } - final Materials tMaterial = GregTech_API.sGeneratedMaterials[i % 1000]; - if (tMaterial == null) { - continue; - } - if (this.doesMaterialAllowGeneration(tPrefix, tMaterial)) { - final ItemStack tStack = new ItemStack(this, 1, i); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName(tStack) + ".name", this.getDefaultLocalization(tPrefix, tMaterial, i)); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName(tStack) + ".tooltip", tMaterial.getToolTip(tPrefix.mMaterialAmount / GT_Values.M)); - if (tPrefix.mIsUnificatable) { - GT_OreDictUnificator.set(tPrefix, tMaterial, tStack); - } else { - GT_OreDictUnificator.registerOre(tPrefix.get(tMaterial), tStack); - } - if (((tPrefix == OrePrefixes.stick) || (tPrefix == OrePrefixes.wireFine)) && ((tMaterial == Materials.Lead) || (tMaterial == Materials.Tin) || (tMaterial == Materials.SolderingAlloy))) { - GregTech_API.sSolderingMetalList.add(tStack); - } - } - } - } - - /* ---------- OVERRIDEABLE FUNCTIONS ---------- */ - - /** - * @return the Color Modulation the Material is going to be rendered with. - */ - @Override - public short[] getRGBa(final ItemStack aStack) { - final Materials tMaterial = GregTech_API.sGeneratedMaterials[this.getDamage(aStack) % 1000]; - return tMaterial == null ? Materials._NULL.mRGBa : tMaterial.mRGBa; - } - - /** - * @param aPrefix this can be null, you have to return false in that case - * @param aMaterial this can be null, you have to return false in that case - * @return if this Item should be generated and visible. - */ - public boolean doesMaterialAllowGeneration(final OrePrefixes aPrefix, final Materials aMaterial) { - // You have to check for at least these Conditions in every Case! So add a super Call like the following for this before executing your Code: - // if (!super.doesMaterialAllowGeneration(aPrefix, aMaterial)) return false; - return (aPrefix != null) && (aMaterial != null) && aPrefix.doGenerateItem(aMaterial); - } - - /* ---------- OVERRIDEABLE FUNCTIONS ---------- */ - - /** - * @param aPrefix the OreDict Prefix - * @param aMaterial the Material - * @param aMetaData a Index from [0 - 31999] - * @return the Localized Name when default LangFiles are used. - */ - public String getDefaultLocalization(final OrePrefixes aPrefix, final Materials aMaterial, final int aMetaData) { - return aPrefix.getDefaultLocalNameForItem(aMaterial); - } - - /** - * @param aMetaData a Index from [0 - 31999] - * @param aMaterial the Material - * @return an Icon Container for the Item Display. - */ - public final IIconContainer getIconContainer(final int aMetaData, final Materials aMaterial) { - return (this.mGeneratedPrefixList[aMetaData / 1000] != null) && (this.mGeneratedPrefixList[aMetaData / 1000].mTextureIndex >= 0) ? aMaterial.mIconSet.mTextures[this.mGeneratedPrefixList[aMetaData / 1000].mTextureIndex] : null; - } - - /** - * @param aPrefix always != null - * @param aMaterial always != null - * @param aDoShowAllItems this is the Configuration Setting of the User, if he wants to see all the Stuff like Tiny Dusts or Crushed Ores as well. - * @return if this Item should be visible in NEI or Creative - */ - public boolean doesShowInCreative(final OrePrefixes aPrefix, final Materials aMaterial, final boolean aDoShowAllItems) { - return true; - } - - /* ---------- INTERNAL OVERRIDES ---------- */ - - @Override - public ItemStack getContainerItem(final ItemStack aStack) { - final int aDamage = aStack.getItemDamage(); - if ((aDamage < 32000) && (aDamage >= 0)) { - final Materials aMaterial = GregTech_API.sGeneratedMaterials[aDamage % 1000]; - if ((aMaterial != null) && (aMaterial != Materials.Empty) && (aMaterial != Materials._NULL)) { - final OrePrefixes aPrefix = this.mGeneratedPrefixList[aDamage / 1000]; - if (aPrefix != null) { - return GT_Utility.copyAmount(1, aPrefix.mContainerItem); - } - } - } - return null; - } - - @Override - public final IIconContainer getIconContainer(final int aMetaData) { - return GregTech_API.sGeneratedMaterials[aMetaData % 1000] == null ? null : this.getIconContainer(aMetaData, GregTech_API.sGeneratedMaterials[aMetaData % 1000]); - } - - @Override - @SideOnly(Side.CLIENT) - public final void getSubItems(final Item var1, final CreativeTabs aCreativeTab, final List aList) { - for (int i = 0; i < 32000; i++) { - if (this.doesMaterialAllowGeneration(this.mGeneratedPrefixList[i / 1000], GregTech_API.sGeneratedMaterials[i % 1000]) && this.doesShowInCreative(this.mGeneratedPrefixList[i / 1000], GregTech_API.sGeneratedMaterials[i % 1000], GregTech_API.sDoShowAllItemsInCreative)) { - final ItemStack tStack = new ItemStack(this, 1, i); - this.isItemStackUsable(tStack); - aList.add(tStack); - } - } - super.getSubItems(var1, aCreativeTab, aList); - } - - @Override - public final IIcon getIconFromDamage(final int aMetaData) { - if (aMetaData < 0) { - return null; - } - if (aMetaData < 32000) { - final Materials tMaterial = GregTech_API.sGeneratedMaterials[aMetaData % 1000]; - if (tMaterial == null) { - return null; - } - final IIconContainer tIcon = this.getIconContainer(aMetaData, tMaterial); - if (tIcon != null) { - return tIcon.getIcon(); - } - return null; - } - return (aMetaData - 32000) < this.mIconList.length ? this.mIconList[aMetaData - 32000][0] : null; - } - - @Override - public int getItemStackLimit(final ItemStack aStack) { - final int tDamage = this.getDamage(aStack); - if ((tDamage < 32000) && (this.mGeneratedPrefixList[tDamage / 1000] != null)) { - return Math.min(super.getItemStackLimit(aStack), this.mGeneratedPrefixList[tDamage / 1000].mDefaultStackSize); - } - return super.getItemStackLimit(aStack); - } - - @Override - public int getColorFromItemStack(final ItemStack stack, int HEX_OxFFFFFF) { - - int aMeta = stack.getItemDamage(); - if (stack.getDisplayName().contains("Sodium")){ - HEX_OxFFFFFF = Utils.rgbtoHexValue(90, 90, 255); - } - else if (stack.getDisplayName().contains("Cadmium")){ - HEX_OxFFFFFF = Utils.rgbtoHexValue(150, 150, 80); - } - else if (stack.getDisplayName().contains("Lithium")){ - HEX_OxFFFFFF = Utils.rgbtoHexValue(225, 220, 255); - } - else if (stack.getDisplayName().contains("Wrought")){ - HEX_OxFFFFFF = Utils.rgbtoHexValue(200, 180, 180); - } - else if (stack.getDisplayName().contains("Bronze")){ - HEX_OxFFFFFF = Utils.rgbtoHexValue(255, 128, 0); - } - else if (stack.getDisplayName().contains("Brass")){ - HEX_OxFFFFFF = Utils.rgbtoHexValue(255, 180, 0); - } - else if (stack.getDisplayName().contains("Invar")){ - HEX_OxFFFFFF = Utils.rgbtoHexValue(180, 180, 120); - } - else { - if (aMeta > 50 && aMeta != 150) { - HEX_OxFFFFFF = 0xffffff; - } - else if (stack.getDisplayName().contains("ULV")){ - HEX_OxFFFFFF = Utils.rgbtoHexValue(200, 180, 180); - } - else if (stack.getDisplayName().contains("LuV")){ - HEX_OxFFFFFF = 0xffffcc; - } - else if (stack.getDisplayName().contains("ZPM")){ - HEX_OxFFFFFF = 0xffe600; - } - else if (stack.getDisplayName().contains("UV")){ - HEX_OxFFFFFF = 0xffb300; - } - else if (stack.getDisplayName().contains("MAX")){ - HEX_OxFFFFFF = Utils.rgbtoHexValue(MathUtils.randInt(220, 250), MathUtils.randInt(221, 251), MathUtils.randInt(220, 250)); - } - else { - HEX_OxFFFFFF = 0xffffff; - } - } - return HEX_OxFFFFFF; - } -}
\ No newline at end of file + protected final OrePrefixes[] mGeneratedPrefixList; + + /** + * Creates the Item using these Parameters. + * + * @param aUnlocalized The Unlocalized Name of this Item. + * @param aGeneratedPrefixList The OreDict Prefixes you want to have generated. + */ + public Gregtech_MetaItem_X32(final String aUnlocalized, final OrePrefixes... aGeneratedPrefixList) { + super(aUnlocalized, (short) 32000, (short) 766); + this.mGeneratedPrefixList = Arrays.copyOf(aGeneratedPrefixList, 32); + + for (int i = 0; i < 32000; i++) { + final OrePrefixes tPrefix = this.mGeneratedPrefixList[i / 1000]; + if (tPrefix == null) { + continue; + } + final Materials tMaterial = GregTech_API.sGeneratedMaterials[i % 1000]; + if (tMaterial == null) { + continue; + } + if (this.doesMaterialAllowGeneration(tPrefix, tMaterial)) { + final ItemStack tStack = new ItemStack(this, 1, i); + GT_LanguageManager.addStringLocalization( + this.getUnlocalizedName(tStack) + ".name", this.getDefaultLocalization(tPrefix, tMaterial, i)); + GT_LanguageManager.addStringLocalization( + this.getUnlocalizedName(tStack) + ".tooltip", + tMaterial.getToolTip(tPrefix.mMaterialAmount / GT_Values.M)); + if (tPrefix.mIsUnificatable) { + GT_OreDictUnificator.set(tPrefix, tMaterial, tStack); + } else { + GT_OreDictUnificator.registerOre(tPrefix.get(tMaterial), tStack); + } + if (((tPrefix == OrePrefixes.stick) || (tPrefix == OrePrefixes.wireFine)) + && ((tMaterial == Materials.Lead) + || (tMaterial == Materials.Tin) + || (tMaterial == Materials.SolderingAlloy))) { + GregTech_API.sSolderingMetalList.add(tStack); + } + } + } + } + + /* ---------- OVERRIDEABLE FUNCTIONS ---------- */ + + /** + * @return the Color Modulation the Material is going to be rendered with. + */ + @Override + public short[] getRGBa(final ItemStack aStack) { + final Materials tMaterial = GregTech_API.sGeneratedMaterials[this.getDamage(aStack) % 1000]; + return tMaterial == null ? Materials._NULL.mRGBa : tMaterial.mRGBa; + } + + /** + * @param aPrefix this can be null, you have to return false in that case + * @param aMaterial this can be null, you have to return false in that case + * @return if this Item should be generated and visible. + */ + public boolean doesMaterialAllowGeneration(final OrePrefixes aPrefix, final Materials aMaterial) { + // You have to check for at least these Conditions in every Case! So add a super Call like the following for + // this before executing your Code: + // if (!super.doesMaterialAllowGeneration(aPrefix, aMaterial)) return false; + return (aPrefix != null) && (aMaterial != null) && aPrefix.doGenerateItem(aMaterial); + } + + /* ---------- OVERRIDEABLE FUNCTIONS ---------- */ + + /** + * @param aPrefix the OreDict Prefix + * @param aMaterial the Material + * @param aMetaData a Index from [0 - 31999] + * @return the Localized Name when default LangFiles are used. + */ + public String getDefaultLocalization(final OrePrefixes aPrefix, final Materials aMaterial, final int aMetaData) { + return aPrefix.getDefaultLocalNameForItem(aMaterial); + } + + /** + * @param aMetaData a Index from [0 - 31999] + * @param aMaterial the Material + * @return an Icon Container for the Item Display. + */ + public final IIconContainer getIconContainer(final int aMetaData, final Materials aMaterial) { + return (this.mGeneratedPrefixList[aMetaData / 1000] != null) + && (this.mGeneratedPrefixList[aMetaData / 1000].mTextureIndex >= 0) + ? aMaterial.mIconSet.mTextures[this.mGeneratedPrefixList[aMetaData / 1000].mTextureIndex] + : null; + } + + /** + * @param aPrefix always != null + * @param aMaterial always != null + * @param aDoShowAllItems this is the Configuration Setting of the User, if he wants to see all the Stuff like Tiny Dusts or Crushed Ores as well. + * @return if this Item should be visible in NEI or Creative + */ + public boolean doesShowInCreative( + final OrePrefixes aPrefix, final Materials aMaterial, final boolean aDoShowAllItems) { + return true; + } + + /* ---------- INTERNAL OVERRIDES ---------- */ + + @Override + public ItemStack getContainerItem(final ItemStack aStack) { + final int aDamage = aStack.getItemDamage(); + if ((aDamage < 32000) && (aDamage >= 0)) { + final Materials aMaterial = GregTech_API.sGeneratedMaterials[aDamage % 1000]; + if ((aMaterial != null) && (aMaterial != Materials.Empty) && (aMaterial != Materials._NULL)) { + final OrePrefixes aPrefix = this.mGeneratedPrefixList[aDamage / 1000]; + if (aPrefix != null) { + return GT_Utility.copyAmount(1, aPrefix.mContainerItem); + } + } + } + return null; + } + + @Override + public final IIconContainer getIconContainer(final int aMetaData) { + return GregTech_API.sGeneratedMaterials[aMetaData % 1000] == null + ? null + : this.getIconContainer(aMetaData, GregTech_API.sGeneratedMaterials[aMetaData % 1000]); + } + + @Override + @SideOnly(Side.CLIENT) + public final void getSubItems(final Item var1, final CreativeTabs aCreativeTab, final List aList) { + for (int i = 0; i < 32000; i++) { + if (this.doesMaterialAllowGeneration( + this.mGeneratedPrefixList[i / 1000], GregTech_API.sGeneratedMaterials[i % 1000]) + && this.doesShowInCreative( + this.mGeneratedPrefixList[i / 1000], + GregTech_API.sGeneratedMaterials[i % 1000], + GregTech_API.sDoShowAllItemsInCreative)) { + final ItemStack tStack = new ItemStack(this, 1, i); + this.isItemStackUsable(tStack); + aList.add(tStack); + } + } + super.getSubItems(var1, aCreativeTab, aList); + } + + @Override + public final IIcon getIconFromDamage(final int aMetaData) { + if (aMetaData < 0) { + return null; + } + if (aMetaData < 32000) { + final Materials tMaterial = GregTech_API.sGeneratedMaterials[aMetaData % 1000]; + if (tMaterial == null) { + return null; + } + final IIconContainer tIcon = this.getIconContainer(aMetaData, tMaterial); + if (tIcon != null) { + return tIcon.getIcon(); + } + return null; + } + return (aMetaData - 32000) < this.mIconList.length ? this.mIconList[aMetaData - 32000][0] : null; + } + + @Override + public int getItemStackLimit(final ItemStack aStack) { + final int tDamage = this.getDamage(aStack); + if ((tDamage < 32000) && (this.mGeneratedPrefixList[tDamage / 1000] != null)) { + return Math.min( + super.getItemStackLimit(aStack), this.mGeneratedPrefixList[tDamage / 1000].mDefaultStackSize); + } + return super.getItemStackLimit(aStack); + } + + @Override + public int getColorFromItemStack(final ItemStack stack, int HEX_OxFFFFFF) { + + int aMeta = stack.getItemDamage(); + if (stack.getDisplayName().contains("Sodium")) { + HEX_OxFFFFFF = Utils.rgbtoHexValue(90, 90, 255); + } else if (stack.getDisplayName().contains("Cadmium")) { + HEX_OxFFFFFF = Utils.rgbtoHexValue(150, 150, 80); + } else if (stack.getDisplayName().contains("Lithium")) { + HEX_OxFFFFFF = Utils.rgbtoHexValue(225, 220, 255); + } else if (stack.getDisplayName().contains("Wrought")) { + HEX_OxFFFFFF = Utils.rgbtoHexValue(200, 180, 180); + } else if (stack.getDisplayName().contains("Bronze")) { + HEX_OxFFFFFF = Utils.rgbtoHexValue(255, 128, 0); + } else if (stack.getDisplayName().contains("Brass")) { + HEX_OxFFFFFF = Utils.rgbtoHexValue(255, 180, 0); + } else if (stack.getDisplayName().contains("Invar")) { + HEX_OxFFFFFF = Utils.rgbtoHexValue(180, 180, 120); + } else { + if (aMeta > 50 && aMeta != 150) { + HEX_OxFFFFFF = 0xffffff; + } else if (stack.getDisplayName().contains("ULV")) { + HEX_OxFFFFFF = Utils.rgbtoHexValue(200, 180, 180); + } else if (stack.getDisplayName().contains("LuV")) { + HEX_OxFFFFFF = 0xffffcc; + } else if (stack.getDisplayName().contains("ZPM")) { + HEX_OxFFFFFF = 0xffe600; + } else if (stack.getDisplayName().contains("UV")) { + HEX_OxFFFFFF = 0xffb300; + } else if (stack.getDisplayName().contains("MAX")) { + HEX_OxFFFFFF = Utils.rgbtoHexValue( + MathUtils.randInt(220, 250), MathUtils.randInt(221, 251), MathUtils.randInt(220, 250)); + } else { + HEX_OxFFFFFF = 0xffffff; + } + } + return HEX_OxFFFFFF; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/items/Gregtech_MetaTool.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/items/Gregtech_MetaTool.java index ae84afb056..7cb79a4ad6 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/items/Gregtech_MetaTool.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/items/Gregtech_MetaTool.java @@ -1,12 +1,21 @@ package gtPlusPlus.xmod.gregtech.api.items; +import buildcraft.api.tools.IToolWrench; +import cpw.mods.fml.common.Optional; +import gregtech.api.enchants.Enchantment_Radioactivity; +import gregtech.api.enums.Materials; +import gregtech.api.interfaces.IDamagableItem; +import gregtech.api.interfaces.IToolStats; +import gregtech.api.items.GT_MetaGenerated_Tool; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.xmod.gregtech.api.interfaces.internal.Interface_ToolStats; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map.Entry; - -import cpw.mods.fml.common.Optional; - +import mods.railcraft.api.core.items.IToolCrowbar; import net.minecraft.block.Block; import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnchantmentHelper; @@ -23,481 +32,637 @@ import net.minecraft.stats.StatList; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.MathHelper; import net.minecraft.world.World; - -import gregtech.api.enchants.Enchantment_Radioactivity; -import gregtech.api.enums.Materials; -import gregtech.api.interfaces.IDamagableItem; -import gregtech.api.interfaces.IToolStats; -import gregtech.api.items.GT_MetaGenerated_Tool; -import gregtech.api.util.GT_ModHandler; -import gregtech.api.util.GT_Utility; - -import buildcraft.api.tools.IToolWrench; -import gtPlusPlus.core.creative.AddToCreativeTab; -import gtPlusPlus.xmod.gregtech.api.interfaces.internal.Interface_ToolStats; -import mods.railcraft.api.core.items.IToolCrowbar; import net.minecraftforge.event.world.BlockEvent; /** * This is an example on how you can create a Tool ItemStack, in this case a Bismuth Wrench: * GT_MetaGenerated_Tool.sInstances.get("gt.metatool.01").getToolWithStats(16, 1, Materials.Bismuth, Materials.Bismuth, null); */ -@Optional.InterfaceList({@Optional.Interface(iface = "forestry.api.arboriculture.IToolGrafter", modid = "Forestry"), - @Optional.Interface(iface = "mods.railcraft.api.core.items.IToolCrowbar", modid = "Railcraft"), - @Optional.Interface(iface = "buildcraft.api.tools.IToolWrench", modid = "BuildCraft"), - @Optional.Interface(iface = "crazypants.enderio.api.tool.ITool", modid = "EnderIO")}) -public abstract class Gregtech_MetaTool extends GT_MetaGenerated_Tool implements IDamagableItem, IToolCrowbar, IToolWrench { - /** - * All instances of this Item Class are listed here. - * This gets used to register the Renderer to all Items of this Type, if useStandardMetaItemRenderer() returns true. - * <p/> - * You can also use the unlocalized Name gotten from getUnlocalizedName() as Key if you want to get a specific Item. - */ - public static final HashMap<String, Gregtech_MetaTool> sInstances = new HashMap<>(); - - /* ---------- CONSTRUCTOR AND MEMBER VARIABLES ---------- */ - - public final HashMap<Short, IToolStats> mToolStats = new HashMap<>(); - - /** - * Creates the Item using these Parameters. - * - * @param aUnlocalized The Unlocalized Name of this Item. - */ - public Gregtech_MetaTool(final String aUnlocalized) { - super(aUnlocalized); - GT_ModHandler.registerBoxableItemToToolBox(this); - this.setCreativeTab(AddToCreativeTab.tabMachines); - this.setMaxStackSize(1); - sInstances.put(this.getUnlocalizedName(), this); - } - - /** - * Called by the Block Harvesting Event within the GT_Proxy - */ - @Override - public void onHarvestBlockEvent(final ArrayList<ItemStack> aDrops, final ItemStack aStack, final EntityPlayer aPlayer, final Block aBlock, final int aX, final int aY, final int aZ, final byte aMetaData, final int aFortune, final boolean aSilkTouch, final BlockEvent.HarvestDropsEvent aEvent) { - final IToolStats tStats = this.getToolStats(aStack); - if (this.isItemStackUsable(aStack) && (this.getDigSpeed(aStack, aBlock, aMetaData) > 0.0F)) { - this.doDamage(aStack, tStats.convertBlockDrops(aDrops, aStack, aPlayer, aBlock, aX, aY, aZ, aMetaData, aFortune, aSilkTouch, aEvent) * tStats.getToolDamagePerDropConversion()); - } - } - - @Override - public boolean onLeftClickEntity(final ItemStack aStack, final EntityPlayer aPlayer, final Entity aEntity) { - final IToolStats tStats = this.getToolStats(aStack); - if ((tStats == null) || !this.isItemStackUsable(aStack)) { - return true; - } - GT_Utility.doSoundAtClient(tStats.getEntityHitSound(), 1, 1.0F); - if (super.onLeftClickEntity(aStack, aPlayer, aEntity)) { - return true; - } - if (aEntity.canAttackWithItem() && !aEntity.hitByEntity(aPlayer)) { - final float tMagicDamage = tStats.getMagicDamageAgainstEntity(aEntity instanceof EntityLivingBase ? EnchantmentHelper.getEnchantmentModifierLiving(aPlayer, (EntityLivingBase) aEntity) : 0.0F, aEntity, aStack, aPlayer); - float tDamage = tStats.getNormalDamageAgainstEntity((float) aPlayer.getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue() + this.getToolCombatDamage(aStack), aEntity, aStack, aPlayer); - if ((tDamage + tMagicDamage) > 0.0F) { - final boolean tCriticalHit = (aPlayer.fallDistance > 0.0F) && !aPlayer.onGround && !aPlayer.isOnLadder() && !aPlayer.isInWater() && !aPlayer.isPotionActive(Potion.blindness) && (aPlayer.ridingEntity == null) && (aEntity instanceof EntityLivingBase); - if (tCriticalHit && (tDamage > 0.0F)) { - tDamage *= 1.5F; - } - tDamage += tMagicDamage; - if (aEntity.attackEntityFrom(tStats.getDamageSource(aPlayer, aEntity), tDamage)) { - if (aEntity instanceof EntityLivingBase) { - aEntity.setFire(EnchantmentHelper.getFireAspectModifier(aPlayer) * 4); - } - final int tKnockcack = (aPlayer.isSprinting() ? 1 : 0) + (aEntity instanceof EntityLivingBase ? EnchantmentHelper.getKnockbackModifier(aPlayer, (EntityLivingBase) aEntity) : 0); - if (tKnockcack > 0) { - aEntity.addVelocity(-MathHelper.sin((aPlayer.rotationYaw * (float) Math.PI) / 180.0F) * tKnockcack * 0.5F, 0.1D, MathHelper.cos((aPlayer.rotationYaw * (float) Math.PI) / 180.0F) * tKnockcack * 0.5F); - aPlayer.motionX *= 0.6D; - aPlayer.motionZ *= 0.6D; - aPlayer.setSprinting(false); - } - if (tCriticalHit) { - aPlayer.onCriticalHit(aEntity); - } - if (tMagicDamage > 0.0F) { - aPlayer.onEnchantmentCritical(aEntity); - } - if (tDamage >= 18.0F) { - aPlayer.triggerAchievement(AchievementList.overkill); - } - aPlayer.setLastAttacker(aEntity); - if (aEntity instanceof EntityLivingBase) { - EnchantmentHelper.func_151384_a((EntityLivingBase) aEntity, aPlayer); - } - EnchantmentHelper.func_151385_b(aPlayer, aEntity); - if (aEntity instanceof EntityLivingBase) { - aPlayer.addStat(StatList.damageDealtStat, Math.round(tDamage * 10.0F)); - } - aEntity.hurtResistantTime = Math.max(1, tStats.getHurtResistanceTime(aEntity.hurtResistantTime, aEntity)); - aPlayer.addExhaustion(0.3F); - this.doDamage(aStack, tStats.getToolDamagePerEntityAttack()); - } - } - } - if (aStack.stackSize <= 0) { - aPlayer.destroyCurrentEquippedItem(); - } - return true; - } - - @Override - public ItemStack onItemRightClick(final ItemStack aStack, final World aWorld, final EntityPlayer aPlayer) { - final IToolStats tStats = this.getToolStats(aStack); - if ((tStats != null) && tStats.canBlock()) { - aPlayer.setItemInUse(aStack, 72000); - } - return super.onItemRightClick(aStack, aWorld, aPlayer); - } - - - @SuppressWarnings("unchecked") - public void addAdditionalToolTips(final List aList, final ItemStack aStack) { - final long tMaxDamage = getToolMaxDamage(aStack); - final Materials tMaterial = getPrimaryMaterial(aStack); - final IToolStats tStats = this.getToolStats(aStack); - final int tOffset = this.getElectricStats(aStack) != null ? 2 : 1; - if (tStats != null) { - final String name = aStack.getUnlocalizedName(); - if (name.equals("gt.metatool.01.170") || name.equals("gt.metatool.01.172") || name.equals("gt.metatool.01.174") || name.equals("gt.metatool.01.176")) { - aList.add(tOffset + 0, EnumChatFormatting.WHITE + "Durability: " + EnumChatFormatting.GREEN + (tMaxDamage - getToolDamage(aStack)) + " / " + tMaxDamage + EnumChatFormatting.GRAY); - aList.add(tOffset + 1, EnumChatFormatting.WHITE + tMaterial.mDefaultLocalName + EnumChatFormatting.YELLOW + " lvl " + this.getHarvestLevel(aStack, "") + EnumChatFormatting.GRAY); - aList.add(tOffset + 2, EnumChatFormatting.WHITE + "Turbine Efficency: " + EnumChatFormatting.BLUE + (50.0F + (10.0F * this.getToolCombatDamage(aStack))) + EnumChatFormatting.GRAY); - aList.add(tOffset + 3, EnumChatFormatting.WHITE + "Optimal Steam flow: " + EnumChatFormatting.LIGHT_PURPLE + Math.max(Float.MIN_NORMAL, tStats.getSpeedMultiplier() * getPrimaryMaterial(aStack).mToolSpeed * 1000) + EnumChatFormatting.GRAY + "L/sec"); - aList.add(tOffset + 3, EnumChatFormatting.WHITE + "Optimal Gas flow(EU burnvalue per tick): " + EnumChatFormatting.LIGHT_PURPLE + Math.max(Float.MIN_NORMAL, tStats.getSpeedMultiplier() * getPrimaryMaterial(aStack).mToolSpeed * 25) + EnumChatFormatting.GRAY + "EU/t"); - aList.add(tOffset + 3, EnumChatFormatting.WHITE + "Optimal Plasma flow(Plasma energyvalue per tick): " + EnumChatFormatting.LIGHT_PURPLE + Math.max(Float.MIN_NORMAL, tStats.getSpeedMultiplier() * getPrimaryMaterial(aStack).mToolSpeed * 1000) + EnumChatFormatting.GRAY + "EU/t"); - - } else { - aList.add(tOffset + 0, EnumChatFormatting.WHITE + "Durability: " + EnumChatFormatting.GREEN + (tMaxDamage - getToolDamage(aStack)) + " / " + tMaxDamage + EnumChatFormatting.GRAY); - aList.add(tOffset + 1, EnumChatFormatting.WHITE + tMaterial.mDefaultLocalName + EnumChatFormatting.YELLOW + " lvl " + this.getHarvestLevel(aStack, "") + EnumChatFormatting.GRAY); - aList.add(tOffset + 2, EnumChatFormatting.WHITE + "Attack Damage: " + EnumChatFormatting.BLUE + this.getToolCombatDamage(aStack) + EnumChatFormatting.GRAY); - aList.add(tOffset + 3, EnumChatFormatting.WHITE + "Mining Speed: " + EnumChatFormatting.LIGHT_PURPLE + Math.max(Float.MIN_NORMAL, tStats.getSpeedMultiplier() * getPrimaryMaterial(aStack).mToolSpeed) + EnumChatFormatting.GRAY); - } - } - } - - @SuppressWarnings("unchecked") - public void addAdditionalToolTips(final List aList, final ItemStack aStack, final EntityPlayer aPlayer) { - final long tMaxDamage = getToolMaxDamage(aStack); - final Materials tMaterial = getPrimaryMaterial(aStack); - final IToolStats tStats = this.getToolStats(aStack); - final int tOffset = this.getElectricStats(aStack) != null ? 2 : 1; - if (tStats != null) { - final String name = aStack.getUnlocalizedName(); - if (name.equals("gt.metatool.01.170") || name.equals("gt.metatool.01.172") || name.equals("gt.metatool.01.174") || name.equals("gt.metatool.01.176")) { - aList.add(tOffset + 0, EnumChatFormatting.WHITE + "Durability: " + EnumChatFormatting.GREEN + (tMaxDamage - getToolDamage(aStack)) + " / " + tMaxDamage + EnumChatFormatting.GRAY); - aList.add(tOffset + 1, EnumChatFormatting.WHITE + tMaterial.mDefaultLocalName + EnumChatFormatting.YELLOW + " lvl " + this.getHarvestLevel(aStack, "") + EnumChatFormatting.GRAY); - aList.add(tOffset + 2, EnumChatFormatting.WHITE + "Turbine Efficency: " + EnumChatFormatting.BLUE + (50.0F + (10.0F * this.getToolCombatDamage(aStack))) + EnumChatFormatting.GRAY); - aList.add(tOffset + 3, EnumChatFormatting.WHITE + "Optimal Steam flow: " + EnumChatFormatting.LIGHT_PURPLE + Math.max(Float.MIN_NORMAL, tStats.getSpeedMultiplier() * getPrimaryMaterial(aStack).mToolSpeed * 1000) + EnumChatFormatting.GRAY + "L/sec"); - aList.add(tOffset + 3, EnumChatFormatting.WHITE + "Optimal Gas flow(EU burnvalue per tick): " + EnumChatFormatting.LIGHT_PURPLE + Math.max(Float.MIN_NORMAL, tStats.getSpeedMultiplier() * getPrimaryMaterial(aStack).mToolSpeed * 50) + EnumChatFormatting.GRAY + "EU/t"); - aList.add(tOffset + 3, EnumChatFormatting.WHITE + "Optimal Plasma flow(Plasma energyvalue per tick): " + EnumChatFormatting.LIGHT_PURPLE + Math.max(Float.MIN_NORMAL, tStats.getSpeedMultiplier() * getPrimaryMaterial(aStack).mToolSpeed * 1000) + EnumChatFormatting.GRAY + "EU/t"); - - } else { - aList.add(tOffset + 0, EnumChatFormatting.WHITE + "Durability: " + EnumChatFormatting.GREEN + (tMaxDamage - getToolDamage(aStack)) + " / " + tMaxDamage + EnumChatFormatting.GRAY); - aList.add(tOffset + 1, EnumChatFormatting.WHITE + tMaterial.mDefaultLocalName + EnumChatFormatting.YELLOW + " lvl " + this.getHarvestLevel(aStack, "") + EnumChatFormatting.GRAY); - aList.add(tOffset + 2, EnumChatFormatting.WHITE + "Attack Damage: " + EnumChatFormatting.BLUE + this.getToolCombatDamage(aStack) + EnumChatFormatting.GRAY); - aList.add(tOffset + 3, EnumChatFormatting.WHITE + "Mining Speed: " + EnumChatFormatting.LIGHT_PURPLE + Math.max(Float.MIN_NORMAL, tStats.getSpeedMultiplier() * getPrimaryMaterial(aStack).mToolSpeed) + EnumChatFormatting.GRAY); - NBTTagCompound aNBT = aStack.getTagCompound(); - if (aNBT != null) { - aNBT = aNBT.getCompoundTag("GT.ToolStats"); - if ((aNBT != null) && aNBT.hasKey("Heat")){ - int tHeat = aNBT.getInteger("Heat"); - final long tWorldTime = aPlayer.getEntityWorld().getWorldTime(); - if(aNBT.hasKey("HeatTime")){ - final long tHeatTime = aNBT.getLong("HeatTime"); - if(tWorldTime>(tHeatTime+10)){ - tHeat = (int) (tHeat - ((tWorldTime-tHeatTime)/10)); - if((tHeat<300)&&(tHeat>-10000)) { - tHeat=300; - } - } - aNBT.setLong("HeatTime", tWorldTime); - if(tHeat>-10000) { - aNBT.setInteger("Heat", tHeat); - } - } - - aList.add(tOffset + 3, EnumChatFormatting.RED + "Heat: " + aNBT.getInteger("Heat")+" K" + EnumChatFormatting.GRAY); - } - } - } - } - } - - @Override - public Long[] getFluidContainerStats(final ItemStack aStack) { - return null; - } - - @Override - public Long[] getElectricStats(final ItemStack aStack) { - NBTTagCompound aNBT = aStack.getTagCompound(); - if (aNBT != null) { - aNBT = aNBT.getCompoundTag("GT.ToolStats"); - if ((aNBT != null) && aNBT.getBoolean("Electric")) { - return new Long[]{aNBT.getLong("MaxCharge"), aNBT.getLong("Voltage"), aNBT.getLong("Tier"), aNBT.getLong("SpecialData")}; - } - } - return new Long[] {}; - } - - @Override - public float getToolCombatDamage(final ItemStack aStack) { - final IToolStats tStats = this.getToolStats(aStack); - if (tStats == null) { - return 0; - } - return tStats.getBaseDamage() + getPrimaryMaterial(aStack).mToolQuality; - } - - @Override - public float getDigSpeed(final ItemStack aStack, final Block aBlock, final int aMetaData) { - if (!this.isItemStackUsable(aStack)) { - return 0.0F; - } - final IToolStats tStats = this.getToolStats(aStack); - if ((tStats == null) || (Math.max(0, this.getHarvestLevel(aStack, "")) < aBlock.getHarvestLevel(aMetaData))) { - return 0.0F; - } - return tStats.isMinableBlock(aBlock, (byte) aMetaData) ? Math.max(Float.MIN_NORMAL, tStats.getSpeedMultiplier() * getPrimaryMaterial(aStack).mToolSpeed) : 0.0F; - } - - @Override - public boolean onBlockDestroyed(final ItemStack aStack, final World aWorld, final Block aBlock, final int aX, final int aY, final int aZ, final EntityLivingBase aPlayer) { - if (!this.isItemStackUsable(aStack)) { - return false; - } - final IToolStats tStats = this.getToolStats(aStack); - if (tStats == null) { - return false; - } - GT_Utility.doSoundAtClient(tStats.getMiningSound(), 1, 1.0F); - this.doDamage(aStack, (int) Math.max(1, aBlock.getBlockHardness(aWorld, aX, aY, aZ) * tStats.getToolDamagePerBlockBreak())); - return this.getDigSpeed(aStack, aBlock, aWorld.getBlockMetadata(aX, aY, aZ)) > 0.0F; - } - - private ItemStack getContainerItem(ItemStack aStack, final boolean playSound) { - if (!this.isItemStackUsable(aStack)) { - return null; - } - aStack = GT_Utility.copyAmount(1, aStack); - final IToolStats tStats = this.getToolStats(aStack); - if (tStats == null) { - return null; - } - this.doDamage(aStack, tStats.getToolDamagePerContainerCraft()); - aStack = aStack.stackSize > 0 ? aStack : null; - if (playSound) { - //String sound = (aStack == null) ? tStats.getBreakingSound() : tStats.getCraftingSound(); - //GT_Utility.doSoundAtClient(sound, 1, 1.0F); - } - return aStack; - } - - @Override - public Interface_ToolStats getToolStats(final ItemStack aStack) { - this.isItemStackUsable(aStack); - return this.getToolStatsInternal(aStack); - } - - private Interface_ToolStats getToolStatsInternal(final ItemStack aStack) { - return (Interface_ToolStats) (aStack == null ? null : this.mToolStats.get((short) aStack.getItemDamage())); - } - - @Override - public boolean canWhack(final EntityPlayer aPlayer, final ItemStack aStack, final int aX, final int aY, final int aZ) { - if (!this.isItemStackUsable(aStack)) { - return false; - } - final IToolStats tStats = this.getToolStats(aStack); - return (tStats != null) && tStats.isCrowbar(); - } - - @Override - public void onWhack(final EntityPlayer aPlayer, final ItemStack aStack, final int aX, final int aY, final int aZ) { - final IToolStats tStats = this.getToolStats(aStack); - if (tStats != null) { - this.doDamage(aStack, tStats.getToolDamagePerEntityAttack()); - } - } - - @Override - public boolean canWrench(final EntityPlayer player, final int x, final int y, final int z) { - //System.out.println("canWrench"); - if(player==null) { - return false; - } - if(player.getCurrentEquippedItem()==null) { - return false; - } - if (!this.isItemStackUsable(player.getCurrentEquippedItem())) { - return false; - } - final Interface_ToolStats tStats = this.getToolStats(player.getCurrentEquippedItem()); - return (tStats != null) && tStats.isWrench(); - } - - @Override - public void wrenchUsed(final EntityPlayer player, final int x, final int y, final int z) { - if(player==null) { - return; - } - if(player.getCurrentEquippedItem()==null) { - return; - } - final IToolStats tStats = this.getToolStats(player.getCurrentEquippedItem()); - if (tStats != null) { - this.doDamage(player.getCurrentEquippedItem(), tStats.getToolDamagePerEntityAttack()); - } - } - - @Override - public boolean canLink(final EntityPlayer aPlayer, final ItemStack aStack, final EntityMinecart cart) { - if (!this.isItemStackUsable(aStack)) { - return false; - } - final IToolStats tStats = this.getToolStats(aStack); - return (tStats != null) && tStats.isCrowbar(); - } - - @Override - public void onLink(final EntityPlayer aPlayer, final ItemStack aStack, final EntityMinecart cart) { - final IToolStats tStats = this.getToolStats(aStack); - if (tStats != null) { - this.doDamage(aStack, tStats.getToolDamagePerEntityAttack()); - } - } - - @Override - public boolean canBoost(final EntityPlayer aPlayer, final ItemStack aStack, final EntityMinecart cart) { - if (!this.isItemStackUsable(aStack)) { - return false; - } - final IToolStats tStats = this.getToolStats(aStack); - return (tStats != null) && tStats.isCrowbar(); - } - - @Override - public void onBoost(final EntityPlayer aPlayer, final ItemStack aStack, final EntityMinecart cart) { - final IToolStats tStats = this.getToolStats(aStack); - if (tStats != null) { - this.doDamage(aStack, tStats.getToolDamagePerEntityAttack()); - } - } - - @Override - public void onCreated(final ItemStack aStack, final World aWorld, final EntityPlayer aPlayer) { - final IToolStats tStats = this.getToolStats(aStack); - if ((tStats != null) && (aPlayer != null)) { - tStats.onToolCrafted(aStack, aPlayer); - } - super.onCreated(aStack, aWorld, aPlayer); - } - - @Override - public boolean isFull3D() { - return true; - } - - @Override - public boolean isItemStackUsable(final ItemStack aStack) { - final IToolStats tStats = this.getToolStatsInternal(aStack); - if (((aStack.getItemDamage() % 2) == 1) || (tStats == null)) { - final NBTTagCompound aNBT = aStack.getTagCompound(); - if (aNBT != null) { - aNBT.removeTag("ench"); - } - return false; - } - final Materials aMaterial = getPrimaryMaterial(aStack); - final HashMap<Integer, Integer> tMap = new HashMap<>(), tResult = new HashMap<>(); - if (aMaterial.mEnchantmentTools != null) { - tMap.put(aMaterial.mEnchantmentTools.effectId, (int) aMaterial.mEnchantmentToolsLevel); - if (aMaterial.mEnchantmentTools == Enchantment.fortune) { - tMap.put(Enchantment.looting.effectId, (int) aMaterial.mEnchantmentToolsLevel); - } - if (aMaterial.mEnchantmentTools == Enchantment.knockback) { - tMap.put(Enchantment.power.effectId, (int) aMaterial.mEnchantmentToolsLevel); - } - if (aMaterial.mEnchantmentTools == Enchantment.fireAspect) { - tMap.put(Enchantment.flame.effectId, (int) aMaterial.mEnchantmentToolsLevel); - } - } - final Enchantment[] tEnchants = tStats.getEnchantments(aStack); - final int[] tLevels = tStats.getEnchantmentLevels(aStack); - for (int i = 0; i < tEnchants.length; i++) { - if (tLevels[i] > 0) { - final Integer tLevel = tMap.get(tEnchants[i].effectId); - tMap.put(tEnchants[i].effectId, tLevel == null ? tLevels[i] : tLevel == tLevels[i] ? tLevel + 1 : Math.max(tLevel, tLevels[i])); - } - } - for (final Entry<Integer, Integer> tEntry : tMap.entrySet()) { - if ((tEntry.getKey() == 33) || ((tEntry.getKey() == 20) && (tEntry.getValue() > 2)) || (tEntry.getKey() == Enchantment_Radioactivity.INSTANCE.effectId)) { - tResult.put(tEntry.getKey(), tEntry.getValue()); - } else { - switch (Enchantment.enchantmentsList[tEntry.getKey()].type) { - case weapon: - if (tStats.isWeapon()) { - tResult.put(tEntry.getKey(), tEntry.getValue()); - } - break; - case all: - tResult.put(tEntry.getKey(), tEntry.getValue()); - break; - case armor: - case armor_feet: - case armor_head: - case armor_legs: - case armor_torso: - break; - case bow: - if (tStats.isRangedWeapon()) { - tResult.put(tEntry.getKey(), tEntry.getValue()); - } - break; - case breakable: - break; - case fishing_rod: - break; - case digger: - if (tStats.isMiningTool()) { - tResult.put(tEntry.getKey(), tEntry.getValue()); - } - break; - } - } - } - EnchantmentHelper.setEnchantments(tResult, aStack); - return true; - } - - @Override - public short getChargedMetaData(final ItemStack aStack) { - return (short) (aStack.getItemDamage() - (aStack.getItemDamage() % 2)); - } - - @Override - public short getEmptyMetaData(final ItemStack aStack) { - final NBTTagCompound aNBT = aStack.getTagCompound(); - if (aNBT != null) { - aNBT.removeTag("ench"); - } - return (short) ((aStack.getItemDamage() + 1) - (aStack.getItemDamage() % 2)); - } - - @Override - public int getItemEnchantability() { - return 0; - } - - @Override - public boolean isBookEnchantable(final ItemStack aStack, final ItemStack aBook) { - return false; - } - - @Override - public boolean getIsRepairable(final ItemStack aStack, final ItemStack aMaterial) { - return false; - } -}
\ No newline at end of file +@Optional.InterfaceList({ + @Optional.Interface(iface = "forestry.api.arboriculture.IToolGrafter", modid = "Forestry"), + @Optional.Interface(iface = "mods.railcraft.api.core.items.IToolCrowbar", modid = "Railcraft"), + @Optional.Interface(iface = "buildcraft.api.tools.IToolWrench", modid = "BuildCraft"), + @Optional.Interface(iface = "crazypants.enderio.api.tool.ITool", modid = "EnderIO") +}) +public abstract class Gregtech_MetaTool extends GT_MetaGenerated_Tool + implements IDamagableItem, IToolCrowbar, IToolWrench { + /** + * All instances of this Item Class are listed here. + * This gets used to register the Renderer to all Items of this Type, if useStandardMetaItemRenderer() returns true. + * <p/> + * You can also use the unlocalized Name gotten from getUnlocalizedName() as Key if you want to get a specific Item. + */ + public static final HashMap<String, Gregtech_MetaTool> sInstances = new HashMap<>(); + + /* ---------- CONSTRUCTOR AND MEMBER VARIABLES ---------- */ + + public final HashMap<Short, IToolStats> mToolStats = new HashMap<>(); + + /** + * Creates the Item using these Parameters. + * + * @param aUnlocalized The Unlocalized Name of this Item. + */ + public Gregtech_MetaTool(final String aUnlocalized) { + super(aUnlocalized); + GT_ModHandler.registerBoxableItemToToolBox(this); + this.setCreativeTab(AddToCreativeTab.tabMachines); + this.setMaxStackSize(1); + sInstances.put(this.getUnlocalizedName(), this); + } + + /** + * Called by the Block Harvesting Event within the GT_Proxy + */ + @Override + public void onHarvestBlockEvent( + final ArrayList<ItemStack> aDrops, + final ItemStack aStack, + final EntityPlayer aPlayer, + final Block aBlock, + final int aX, + final int aY, + final int aZ, + final byte aMetaData, + final int aFortune, + final boolean aSilkTouch, + final BlockEvent.HarvestDropsEvent aEvent) { + final IToolStats tStats = this.getToolStats(aStack); + if (this.isItemStackUsable(aStack) && (this.getDigSpeed(aStack, aBlock, aMetaData) > 0.0F)) { + this.doDamage( + aStack, + tStats.convertBlockDrops( + aDrops, + aStack, + aPlayer, + aBlock, + aX, + aY, + aZ, + aMetaData, + aFortune, + aSilkTouch, + aEvent) + * tStats.getToolDamagePerDropConversion()); + } + } + + @Override + public boolean onLeftClickEntity(final ItemStack aStack, final EntityPlayer aPlayer, final Entity aEntity) { + final IToolStats tStats = this.getToolStats(aStack); + if ((tStats == null) || !this.isItemStackUsable(aStack)) { + return true; + } + GT_Utility.doSoundAtClient(tStats.getEntityHitSound(), 1, 1.0F); + if (super.onLeftClickEntity(aStack, aPlayer, aEntity)) { + return true; + } + if (aEntity.canAttackWithItem() && !aEntity.hitByEntity(aPlayer)) { + final float tMagicDamage = tStats.getMagicDamageAgainstEntity( + aEntity instanceof EntityLivingBase + ? EnchantmentHelper.getEnchantmentModifierLiving(aPlayer, (EntityLivingBase) aEntity) + : 0.0F, + aEntity, + aStack, + aPlayer); + float tDamage = tStats.getNormalDamageAgainstEntity( + (float) aPlayer.getEntityAttribute(SharedMonsterAttributes.attackDamage) + .getAttributeValue() + + this.getToolCombatDamage(aStack), + aEntity, + aStack, + aPlayer); + if ((tDamage + tMagicDamage) > 0.0F) { + final boolean tCriticalHit = (aPlayer.fallDistance > 0.0F) + && !aPlayer.onGround + && !aPlayer.isOnLadder() + && !aPlayer.isInWater() + && !aPlayer.isPotionActive(Potion.blindness) + && (aPlayer.ridingEntity == null) + && (aEntity instanceof EntityLivingBase); + if (tCriticalHit && (tDamage > 0.0F)) { + tDamage *= 1.5F; + } + tDamage += tMagicDamage; + if (aEntity.attackEntityFrom(tStats.getDamageSource(aPlayer, aEntity), tDamage)) { + if (aEntity instanceof EntityLivingBase) { + aEntity.setFire(EnchantmentHelper.getFireAspectModifier(aPlayer) * 4); + } + final int tKnockcack = (aPlayer.isSprinting() ? 1 : 0) + + (aEntity instanceof EntityLivingBase + ? EnchantmentHelper.getKnockbackModifier(aPlayer, (EntityLivingBase) aEntity) + : 0); + if (tKnockcack > 0) { + aEntity.addVelocity( + -MathHelper.sin((aPlayer.rotationYaw * (float) Math.PI) / 180.0F) * tKnockcack * 0.5F, + 0.1D, + MathHelper.cos((aPlayer.rotationYaw * (float) Math.PI) / 180.0F) * tKnockcack * 0.5F); + aPlayer.motionX *= 0.6D; + aPlayer.motionZ *= 0.6D; + aPlayer.setSprinting(false); + } + if (tCriticalHit) { + aPlayer.onCriticalHit(aEntity); + } + if (tMagicDamage > 0.0F) { + aPlayer.onEnchantmentCritical(aEntity); + } + if (tDamage >= 18.0F) { + aPlayer.triggerAchievement(AchievementList.overkill); + } + aPlayer.setLastAttacker(aEntity); + if (aEntity instanceof EntityLivingBase) { + EnchantmentHelper.func_151384_a((EntityLivingBase) aEntity, aPlayer); + } + EnchantmentHelper.func_151385_b(aPlayer, aEntity); + if (aEntity instanceof EntityLivingBase) { + aPlayer.addStat(StatList.damageDealtStat, Math.round(tDamage * 10.0F)); + } + aEntity.hurtResistantTime = + Math.max(1, tStats.getHurtResistanceTime(aEntity.hurtResistantTime, aEntity)); + aPlayer.addExhaustion(0.3F); + this.doDamage(aStack, tStats.getToolDamagePerEntityAttack()); + } + } + } + if (aStack.stackSize <= 0) { + aPlayer.destroyCurrentEquippedItem(); + } + return true; + } + + @Override + public ItemStack onItemRightClick(final ItemStack aStack, final World aWorld, final EntityPlayer aPlayer) { + final IToolStats tStats = this.getToolStats(aStack); + if ((tStats != null) && tStats.canBlock()) { + aPlayer.setItemInUse(aStack, 72000); + } + return super.onItemRightClick(aStack, aWorld, aPlayer); + } + + @SuppressWarnings("unchecked") + public void addAdditionalToolTips(final List aList, final ItemStack aStack) { + final long tMaxDamage = getToolMaxDamage(aStack); + final Materials tMaterial = getPrimaryMaterial(aStack); + final IToolStats tStats = this.getToolStats(aStack); + final int tOffset = this.getElectricStats(aStack) != null ? 2 : 1; + if (tStats != null) { + final String name = aStack.getUnlocalizedName(); + if (name.equals("gt.metatool.01.170") + || name.equals("gt.metatool.01.172") + || name.equals("gt.metatool.01.174") + || name.equals("gt.metatool.01.176")) { + aList.add( + tOffset + 0, + EnumChatFormatting.WHITE + "Durability: " + EnumChatFormatting.GREEN + + (tMaxDamage - getToolDamage(aStack)) + " / " + tMaxDamage + EnumChatFormatting.GRAY); + aList.add( + tOffset + 1, + EnumChatFormatting.WHITE + tMaterial.mDefaultLocalName + EnumChatFormatting.YELLOW + " lvl " + + this.getHarvestLevel(aStack, "") + EnumChatFormatting.GRAY); + aList.add( + tOffset + 2, + EnumChatFormatting.WHITE + "Turbine Efficency: " + EnumChatFormatting.BLUE + + (50.0F + (10.0F * this.getToolCombatDamage(aStack))) + EnumChatFormatting.GRAY); + aList.add( + tOffset + 3, + EnumChatFormatting.WHITE + "Optimal Steam flow: " + EnumChatFormatting.LIGHT_PURPLE + + Math.max( + Float.MIN_NORMAL, + tStats.getSpeedMultiplier() * getPrimaryMaterial(aStack).mToolSpeed * 1000) + + EnumChatFormatting.GRAY + "L/sec"); + aList.add( + tOffset + 3, + EnumChatFormatting.WHITE + "Optimal Gas flow(EU burnvalue per tick): " + + EnumChatFormatting.LIGHT_PURPLE + + Math.max( + Float.MIN_NORMAL, + tStats.getSpeedMultiplier() * getPrimaryMaterial(aStack).mToolSpeed * 25) + + EnumChatFormatting.GRAY + "EU/t"); + aList.add( + tOffset + 3, + EnumChatFormatting.WHITE + "Optimal Plasma flow(Plasma energyvalue per tick): " + + EnumChatFormatting.LIGHT_PURPLE + + Math.max( + Float.MIN_NORMAL, + tStats.getSpeedMultiplier() * getPrimaryMaterial(aStack).mToolSpeed * 1000) + + EnumChatFormatting.GRAY + "EU/t"); + + } else { + aList.add( + tOffset + 0, + EnumChatFormatting.WHITE + "Durability: " + EnumChatFormatting.GREEN + + (tMaxDamage - getToolDamage(aStack)) + " / " + tMaxDamage + EnumChatFormatting.GRAY); + aList.add( + tOffset + 1, + EnumChatFormatting.WHITE + tMaterial.mDefaultLocalName + EnumChatFormatting.YELLOW + " lvl " + + this.getHarvestLevel(aStack, "") + EnumChatFormatting.GRAY); + aList.add( + tOffset + 2, + EnumChatFormatting.WHITE + "Attack Damage: " + EnumChatFormatting.BLUE + + this.getToolCombatDamage(aStack) + EnumChatFormatting.GRAY); + aList.add( + tOffset + 3, + EnumChatFormatting.WHITE + "Mining Speed: " + EnumChatFormatting.LIGHT_PURPLE + + Math.max( + Float.MIN_NORMAL, + tStats.getSpeedMultiplier() * getPrimaryMaterial(aStack).mToolSpeed) + + EnumChatFormatting.GRAY); + } + } + } + + @SuppressWarnings("unchecked") + public void addAdditionalToolTips(final List aList, final ItemStack aStack, final EntityPlayer aPlayer) { + final long tMaxDamage = getToolMaxDamage(aStack); + final Materials tMaterial = getPrimaryMaterial(aStack); + final IToolStats tStats = this.getToolStats(aStack); + final int tOffset = this.getElectricStats(aStack) != null ? 2 : 1; + if (tStats != null) { + final String name = aStack.getUnlocalizedName(); + if (name.equals("gt.metatool.01.170") + || name.equals("gt.metatool.01.172") + || name.equals("gt.metatool.01.174") + || name.equals("gt.metatool.01.176")) { + aList.add( + tOffset + 0, + EnumChatFormatting.WHITE + "Durability: " + EnumChatFormatting.GREEN + + (tMaxDamage - getToolDamage(aStack)) + " / " + tMaxDamage + EnumChatFormatting.GRAY); + aList.add( + tOffset + 1, + EnumChatFormatting.WHITE + tMaterial.mDefaultLocalName + EnumChatFormatting.YELLOW + " lvl " + + this.getHarvestLevel(aStack, "") + EnumChatFormatting.GRAY); + aList.add( + tOffset + 2, + EnumChatFormatting.WHITE + "Turbine Efficency: " + EnumChatFormatting.BLUE + + (50.0F + (10.0F * this.getToolCombatDamage(aStack))) + EnumChatFormatting.GRAY); + aList.add( + tOffset + 3, + EnumChatFormatting.WHITE + "Optimal Steam flow: " + EnumChatFormatting.LIGHT_PURPLE + + Math.max( + Float.MIN_NORMAL, + tStats.getSpeedMultiplier() * getPrimaryMaterial(aStack).mToolSpeed * 1000) + + EnumChatFormatting.GRAY + "L/sec"); + aList.add( + tOffset + 3, + EnumChatFormatting.WHITE + "Optimal Gas flow(EU burnvalue per tick): " + + EnumChatFormatting.LIGHT_PURPLE + + Math.max( + Float.MIN_NORMAL, + tStats.getSpeedMultiplier() * getPrimaryMaterial(aStack).mToolSpeed * 50) + + EnumChatFormatting.GRAY + "EU/t"); + aList.add( + tOffset + 3, + EnumChatFormatting.WHITE + "Optimal Plasma flow(Plasma energyvalue per tick): " + + EnumChatFormatting.LIGHT_PURPLE + + Math.max( + Float.MIN_NORMAL, + tStats.getSpeedMultiplier() * getPrimaryMaterial(aStack).mToolSpeed * 1000) + + EnumChatFormatting.GRAY + "EU/t"); + + } else { + aList.add( + tOffset + 0, + EnumChatFormatting.WHITE + "Durability: " + EnumChatFormatting.GREEN + + (tMaxDamage - getToolDamage(aStack)) + " / " + tMaxDamage + EnumChatFormatting.GRAY); + aList.add( + tOffset + 1, + EnumChatFormatting.WHITE + tMaterial.mDefaultLocalName + EnumChatFormatting.YELLOW + " lvl " + + this.getHarvestLevel(aStack, "") + EnumChatFormatting.GRAY); + aList.add( + tOffset + 2, + EnumChatFormatting.WHITE + "Attack Damage: " + EnumChatFormatting.BLUE + + this.getToolCombatDamage(aStack) + EnumChatFormatting.GRAY); + aList.add( + tOffset + 3, + EnumChatFormatting.WHITE + "Mining Speed: " + EnumChatFormatting.LIGHT_PURPLE + + Math.max( + Float.MIN_NORMAL, + tStats.getSpeedMultiplier() * getPrimaryMaterial(aStack).mToolSpeed) + + EnumChatFormatting.GRAY); + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag("GT.ToolStats"); + if ((aNBT != null) && aNBT.hasKey("Heat")) { + int tHeat = aNBT.getInteger("Heat"); + final long tWorldTime = aPlayer.getEntityWorld().getWorldTime(); + if (aNBT.hasKey("HeatTime")) { + final long tHeatTime = aNBT.getLong("HeatTime"); + if (tWorldTime > (tHeatTime + 10)) { + tHeat = (int) (tHeat - ((tWorldTime - tHeatTime) / 10)); + if ((tHeat < 300) && (tHeat > -10000)) { + tHeat = 300; + } + } + aNBT.setLong("HeatTime", tWorldTime); + if (tHeat > -10000) { + aNBT.setInteger("Heat", tHeat); + } + } + + aList.add( + tOffset + 3, + EnumChatFormatting.RED + "Heat: " + aNBT.getInteger("Heat") + " K" + + EnumChatFormatting.GRAY); + } + } + } + } + } + + @Override + public Long[] getFluidContainerStats(final ItemStack aStack) { + return null; + } + + @Override + public Long[] getElectricStats(final ItemStack aStack) { + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag("GT.ToolStats"); + if ((aNBT != null) && aNBT.getBoolean("Electric")) { + return new Long[] { + aNBT.getLong("MaxCharge"), + aNBT.getLong("Voltage"), + aNBT.getLong("Tier"), + aNBT.getLong("SpecialData") + }; + } + } + return new Long[] {}; + } + + @Override + public float getToolCombatDamage(final ItemStack aStack) { + final IToolStats tStats = this.getToolStats(aStack); + if (tStats == null) { + return 0; + } + return tStats.getBaseDamage() + getPrimaryMaterial(aStack).mToolQuality; + } + + @Override + public float getDigSpeed(final ItemStack aStack, final Block aBlock, final int aMetaData) { + if (!this.isItemStackUsable(aStack)) { + return 0.0F; + } + final IToolStats tStats = this.getToolStats(aStack); + if ((tStats == null) || (Math.max(0, this.getHarvestLevel(aStack, "")) < aBlock.getHarvestLevel(aMetaData))) { + return 0.0F; + } + return tStats.isMinableBlock(aBlock, (byte) aMetaData) + ? Math.max(Float.MIN_NORMAL, tStats.getSpeedMultiplier() * getPrimaryMaterial(aStack).mToolSpeed) + : 0.0F; + } + + @Override + public boolean onBlockDestroyed( + final ItemStack aStack, + final World aWorld, + final Block aBlock, + final int aX, + final int aY, + final int aZ, + final EntityLivingBase aPlayer) { + if (!this.isItemStackUsable(aStack)) { + return false; + } + final IToolStats tStats = this.getToolStats(aStack); + if (tStats == null) { + return false; + } + GT_Utility.doSoundAtClient(tStats.getMiningSound(), 1, 1.0F); + this.doDamage(aStack, (int) + Math.max(1, aBlock.getBlockHardness(aWorld, aX, aY, aZ) * tStats.getToolDamagePerBlockBreak())); + return this.getDigSpeed(aStack, aBlock, aWorld.getBlockMetadata(aX, aY, aZ)) > 0.0F; + } + + private ItemStack getContainerItem(ItemStack aStack, final boolean playSound) { + if (!this.isItemStackUsable(aStack)) { + return null; + } + aStack = GT_Utility.copyAmount(1, aStack); + final IToolStats tStats = this.getToolStats(aStack); + if (tStats == null) { + return null; + } + this.doDamage(aStack, tStats.getToolDamagePerContainerCraft()); + aStack = aStack.stackSize > 0 ? aStack : null; + if (playSound) { + // String sound = (aStack == null) ? tStats.getBreakingSound() : tStats.getCraftingSound(); + // GT_Utility.doSoundAtClient(sound, 1, 1.0F); + } + return aStack; + } + + @Override + public Interface_ToolStats getToolStats(final ItemStack aStack) { + this.isItemStackUsable(aStack); + return this.getToolStatsInternal(aStack); + } + + private Interface_ToolStats getToolStatsInternal(final ItemStack aStack) { + return (Interface_ToolStats) (aStack == null ? null : this.mToolStats.get((short) aStack.getItemDamage())); + } + + @Override + public boolean canWhack( + final EntityPlayer aPlayer, final ItemStack aStack, final int aX, final int aY, final int aZ) { + if (!this.isItemStackUsable(aStack)) { + return false; + } + final IToolStats tStats = this.getToolStats(aStack); + return (tStats != null) && tStats.isCrowbar(); + } + + @Override + public void onWhack(final EntityPlayer aPlayer, final ItemStack aStack, final int aX, final int aY, final int aZ) { + final IToolStats tStats = this.getToolStats(aStack); + if (tStats != null) { + this.doDamage(aStack, tStats.getToolDamagePerEntityAttack()); + } + } + + @Override + public boolean canWrench(final EntityPlayer player, final int x, final int y, final int z) { + // System.out.println("canWrench"); + if (player == null) { + return false; + } + if (player.getCurrentEquippedItem() == null) { + return false; + } + if (!this.isItemStackUsable(player.getCurrentEquippedItem())) { + return false; + } + final Interface_ToolStats tStats = this.getToolStats(player.getCurrentEquippedItem()); + return (tStats != null) && tStats.isWrench(); + } + + @Override + public void wrenchUsed(final EntityPlayer player, final int x, final int y, final int z) { + if (player == null) { + return; + } + if (player.getCurrentEquippedItem() == null) { + return; + } + final IToolStats tStats = this.getToolStats(player.getCurrentEquippedItem()); + if (tStats != null) { + this.doDamage(player.getCurrentEquippedItem(), tStats.getToolDamagePerEntityAttack()); + } + } + + @Override + public boolean canLink(final EntityPlayer aPlayer, final ItemStack aStack, final EntityMinecart cart) { + if (!this.isItemStackUsable(aStack)) { + return false; + } + final IToolStats tStats = this.getToolStats(aStack); + return (tStats != null) && tStats.isCrowbar(); + } + + @Override + public void onLink(final EntityPlayer aPlayer, final ItemStack aStack, final EntityMinecart cart) { + final IToolStats tStats = this.getToolStats(aStack); + if (tStats != null) { + this.doDamage(aStack, tStats.getToolDamagePerEntityAttack()); + } + } + + @Override + public boolean canBoost(final EntityPlayer aPlayer, final ItemStack aStack, final EntityMinecart cart) { + if (!this.isItemStackUsable(aStack)) { + return false; + } + final IToolStats tStats = this.getToolStats(aStack); + return (tStats != null) && tStats.isCrowbar(); + } + + @Override + public void onBoost(final EntityPlayer aPlayer, final ItemStack aStack, final EntityMinecart cart) { + final IToolStats tStats = this.getToolStats(aStack); + if (tStats != null) { + this.doDamage(aStack, tStats.getToolDamagePerEntityAttack()); + } + } + + @Override + public void onCreated(final ItemStack aStack, final World aWorld, final EntityPlayer aPlayer) { + final IToolStats tStats = this.getToolStats(aStack); + if ((tStats != null) && (aPlayer != null)) { + tStats.onToolCrafted(aStack, aPlayer); + } + super.onCreated(aStack, aWorld, aPlayer); + } + + @Override + public boolean isFull3D() { + return true; + } + + @Override + public boolean isItemStackUsable(final ItemStack aStack) { + final IToolStats tStats = this.getToolStatsInternal(aStack); + if (((aStack.getItemDamage() % 2) == 1) || (tStats == null)) { + final NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT.removeTag("ench"); + } + return false; + } + final Materials aMaterial = getPrimaryMaterial(aStack); + final HashMap<Integer, Integer> tMap = new HashMap<>(), tResult = new HashMap<>(); + if (aMaterial.mEnchantmentTools != null) { + tMap.put(aMaterial.mEnchantmentTools.effectId, (int) aMaterial.mEnchantmentToolsLevel); + if (aMaterial.mEnchantmentTools == Enchantment.fortune) { + tMap.put(Enchantment.looting.effectId, (int) aMaterial.mEnchantmentToolsLevel); + } + if (aMaterial.mEnchantmentTools == Enchantment.knockback) { + tMap.put(Enchantment.power.effectId, (int) aMaterial.mEnchantmentToolsLevel); + } + if (aMaterial.mEnchantmentTools == Enchantment.fireAspect) { + tMap.put(Enchantment.flame.effectId, (int) aMaterial.mEnchantmentToolsLevel); + } + } + final Enchantment[] tEnchants = tStats.getEnchantments(aStack); + final int[] tLevels = tStats.getEnchantmentLevels(aStack); + for (int i = 0; i < tEnchants.length; i++) { + if (tLevels[i] > 0) { + final Integer tLevel = tMap.get(tEnchants[i].effectId); + tMap.put( + tEnchants[i].effectId, + tLevel == null ? tLevels[i] : tLevel == tLevels[i] ? tLevel + 1 : Math.max(tLevel, tLevels[i])); + } + } + for (final Entry<Integer, Integer> tEntry : tMap.entrySet()) { + if ((tEntry.getKey() == 33) + || ((tEntry.getKey() == 20) && (tEntry.getValue() > 2)) + || (tEntry.getKey() == Enchantment_Radioactivity.INSTANCE.effectId)) { + tResult.put(tEntry.getKey(), tEntry.getValue()); + } else { + switch (Enchantment.enchantmentsList[tEntry.getKey()].type) { + case weapon: + if (tStats.isWeapon()) { + tResult.put(tEntry.getKey(), tEntry.getValue()); + } + break; + case all: + tResult.put(tEntry.getKey(), tEntry.getValue()); + break; + case armor: + case armor_feet: + case armor_head: + case armor_legs: + case armor_torso: + break; + case bow: + if (tStats.isRangedWeapon()) { + tResult.put(tEntry.getKey(), tEntry.getValue()); + } + break; + case breakable: + break; + case fishing_rod: + break; + case digger: + if (tStats.isMiningTool()) { + tResult.put(tEntry.getKey(), tEntry.getValue()); + } + break; + } + } + } + EnchantmentHelper.setEnchantments(tResult, aStack); + return true; + } + + @Override + public short getChargedMetaData(final ItemStack aStack) { + return (short) (aStack.getItemDamage() - (aStack.getItemDamage() % 2)); + } + + @Override + public short getEmptyMetaData(final ItemStack aStack) { + final NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT.removeTag("ench"); + } + return (short) ((aStack.getItemDamage() + 1) - (aStack.getItemDamage() % 2)); + } + + @Override + public int getItemEnchantability() { + return 0; + } + + @Override + public boolean isBookEnchantable(final ItemStack aStack, final ItemStack aBook) { + return false; + } + + @Override + public boolean getIsRepairable(final ItemStack aStack, final ItemStack aMaterial) { + return false; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/items/tools/GT_MetaGenTool.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/items/tools/GT_MetaGenTool.java index 6f4202fdd8..c9f337d47b 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/items/tools/GT_MetaGenTool.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/items/tools/GT_MetaGenTool.java @@ -1,10 +1,17 @@ package gtPlusPlus.xmod.gregtech.api.items.tools; +import gregtech.api.GregTech_API; +import gregtech.api.enchants.Enchantment_Radioactivity; +import gregtech.api.enums.Materials; +import gregtech.api.enums.TC_Aspects.TC_AspectStack; +import gregtech.api.interfaces.IToolStats; +import gregtech.api.items.GT_MetaGenerated_Tool; +import gregtech.api.util.*; +import gtPlusPlus.xmod.gregtech.api.interfaces.internal.Interface_ToolStats; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map.Entry; - import net.minecraft.block.Block; import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnchantmentHelper; @@ -20,16 +27,6 @@ import net.minecraft.stats.AchievementList; import net.minecraft.stats.StatList; import net.minecraft.util.MathHelper; import net.minecraft.world.World; - -import gregtech.api.GregTech_API; -import gregtech.api.enchants.Enchantment_Radioactivity; -import gregtech.api.enums.Materials; -import gregtech.api.enums.TC_Aspects.TC_AspectStack; -import gregtech.api.interfaces.IToolStats; -import gregtech.api.items.GT_MetaGenerated_Tool; -import gregtech.api.util.*; - -import gtPlusPlus.xmod.gregtech.api.interfaces.internal.Interface_ToolStats; import net.minecraftforge.event.world.BlockEvent; /** @@ -37,510 +34,601 @@ import net.minecraftforge.event.world.BlockEvent; * GT_MetaGenerated_Tool.sInstances.get("gt.metatool.01").getToolWithStats(16, 1, Materials.Bismuth, Materials.Bismuth, null); */ public abstract class GT_MetaGenTool extends GT_MetaGenerated_Tool { - /** - * All instances of this Item Class are listed here. - * This gets used to register the Renderer to all Items of this Type, if useStandardMetaItemRenderer() returns true. - * <p/> - * You can also use the unlocalized Name gotten from getUnlocalizedName() as Key if you want to get a specific Item. - */ - public static final HashMap<String, GT_MetaGenTool> sInstances = new HashMap<>(); - - /* ---------- CONSTRUCTOR AND MEMBER VARIABLES ---------- */ - - public final HashMap<Short, IToolStats> mToolStats = new HashMap<>(); - - /** - * Creates the Item using these Parameters. - * - * @param aUnlocalized The Unlocalized Name of this Item. - */ - public GT_MetaGenTool(final String aUnlocalized) { - super(aUnlocalized); - GT_ModHandler.registerBoxableItemToToolBox(this); - this.setCreativeTab(GregTech_API.TAB_GREGTECH); - this.setMaxStackSize(1); - sInstances.put(this.getUnlocalizedName(), this); - } - - /* ---------- FOR ADDING CUSTOM ITEMS INTO THE REMAINING 766 RANGE ---------- */ - - public static final Materials getPrimaryMaterialEx(final ItemStack aStack) { - NBTTagCompound aNBT = aStack.getTagCompound(); - if (aNBT != null) { - aNBT = aNBT.getCompoundTag("GT.ToolStats"); - if (aNBT != null) { - return Materials.getRealMaterial(aNBT.getString("PrimaryMaterial")); - } - } - return Materials._NULL; - } - - public static final Materials getSecondaryMaterialEx(final ItemStack aStack) { - NBTTagCompound aNBT = aStack.getTagCompound(); - if (aNBT != null) { - aNBT = aNBT.getCompoundTag("GT.ToolStats"); - if (aNBT != null) { - return Materials.getRealMaterial(aNBT.getString("SecondaryMaterial")); - } - } - return Materials._NULL; - } - - /** - * This adds a Custom Item to the ending Range. - * - * @param aID The Id of the assigned Tool Class [0 - 32765] (only even Numbers allowed! Uneven ID's are empty electric Items) - * @param aEnglish The Default Localized Name of the created Item - * @param aToolTip The Default ToolTip of the created Item, you can also insert null for having no ToolTip - * @param aToolStats The Food Value of this Item. Can be null as well. - * @param aOreDictNamesAndAspects The OreDict Names you want to give the Item. Also used to assign Thaumcraft Aspects. - * @return An ItemStack containing the newly created Item, but without specific Stats. - */ - public final ItemStack addToolEx(final int aID, final String aEnglish, String aToolTip, final IToolStats aToolStats, final Object... aOreDictNamesAndAspects) { - if (aToolTip == null) { - aToolTip = ""; - } - if ((aID >= 0) && (aID < 32766) && ((aID % 2) == 0)) { - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + "." + aID + ".name", aEnglish); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + "." + aID + ".tooltip", aToolTip); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + "." + (aID + 1) + ".name", aEnglish + " (Empty)"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + "." + (aID + 1) + ".tooltip", "You need to recharge it"); - this.mToolStats.put((short) aID, aToolStats); - this.mToolStats.put((short) (aID + 1), aToolStats); - aToolStats.onStatsAddedToTool(this, aID); - final ItemStack rStack = new ItemStack(this, 1, aID); - final List<TC_AspectStack> tAspects = new ArrayList<>(); - for (final Object tOreDictNameOrAspect : aOreDictNamesAndAspects) { - if (tOreDictNameOrAspect instanceof TC_AspectStack) { - ((TC_AspectStack) tOreDictNameOrAspect).addToAspectList(tAspects); - } else { - GT_OreDictUnificator.registerOre(tOreDictNameOrAspect, rStack); - } - } - if (GregTech_API.sThaumcraftCompat != null) { - GregTech_API.sThaumcraftCompat.registerThaumcraftAspectsToItem(rStack, tAspects, false); - } - return rStack; - } - return null; - } - - /** - * This Function gets an ItemStack Version of this Tool - * - * @param aToolID the ID of the Tool Class - * @param aAmount Amount of Items (well normally you only need 1) - * @param aPrimaryMaterial Primary Material of this Tool - * @param aSecondaryMaterial Secondary (Rod/Handle) Material of this Tool - * @param aElectricArray The Electric Stats of this Tool (or null if not electric) - */ - public final ItemStack getToolWithStatsEx(final int aToolID, final int aAmount, final Materials aPrimaryMaterial, final Materials aSecondaryMaterial, final long[] aElectricArray) { - final ItemStack rStack = new ItemStack(this, aAmount, aToolID); - final IToolStats tToolStats = this.getToolStats(rStack); - if (tToolStats != null) { - final NBTTagCompound tMainNBT = new NBTTagCompound(), tToolNBT = new NBTTagCompound(); - if (aPrimaryMaterial != null) { - tToolNBT.setString("PrimaryMaterial", aPrimaryMaterial.toString()); - tToolNBT.setLong("MaxDamage", 100L * (long) (aPrimaryMaterial.mDurability * tToolStats.getMaxDurabilityMultiplier())); - } - if (aSecondaryMaterial != null) { - tToolNBT.setString("SecondaryMaterial", aSecondaryMaterial.toString()); - } - - if (aElectricArray != null) { - tToolNBT.setBoolean("Electric", true); - tToolNBT.setLong("MaxCharge", aElectricArray[0]); - tToolNBT.setLong("Voltage", aElectricArray[1]); - tToolNBT.setLong("Tier", aElectricArray[2]); - tToolNBT.setLong("SpecialData", aElectricArray[3]); - } - - tMainNBT.setTag("GT.ToolStats", tToolNBT); - rStack.setTagCompound(tMainNBT); - } - this.isItemStackUsable(rStack); - return rStack; - } - - /** - * Called by the Block Harvesting Event within the GT_Proxy - */ - @Override - public void onHarvestBlockEvent(final ArrayList<ItemStack> aDrops, final ItemStack aStack, final EntityPlayer aPlayer, final Block aBlock, final int aX, final int aY, final int aZ, final byte aMetaData, final int aFortune, final boolean aSilkTouch, final BlockEvent.HarvestDropsEvent aEvent) { - final IToolStats tStats = this.getToolStats(aStack); - if (this.isItemStackUsable(aStack) && (this.getDigSpeed(aStack, aBlock, aMetaData) > 0.0F)) { - this.doDamage(aStack, tStats.convertBlockDrops(aDrops, aStack, aPlayer, aBlock, aX, aY, aZ, aMetaData, aFortune, aSilkTouch, aEvent) * tStats.getToolDamagePerDropConversion()); - } - } - - @Override - public boolean onLeftClickEntity(final ItemStack aStack, final EntityPlayer aPlayer, final Entity aEntity) { - final IToolStats tStats = this.getToolStats(aStack); - if ((tStats == null) || !this.isItemStackUsable(aStack)) { - return true; - } - GT_Utility.doSoundAtClient(tStats.getEntityHitSound(), 1, 1.0F); - if (super.onLeftClickEntity(aStack, aPlayer, aEntity)) { - return true; - } - if (aEntity.canAttackWithItem() && !aEntity.hitByEntity(aPlayer)) { - final float tMagicDamage = tStats.getMagicDamageAgainstEntity(aEntity instanceof EntityLivingBase ? EnchantmentHelper.getEnchantmentModifierLiving(aPlayer, (EntityLivingBase) aEntity) : 0.0F, aEntity, aStack, aPlayer); - float tDamage = tStats.getNormalDamageAgainstEntity((float) aPlayer.getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue() + this.getToolCombatDamage(aStack), aEntity, aStack, aPlayer); - if ((tDamage + tMagicDamage) > 0.0F) { - final boolean tCriticalHit = (aPlayer.fallDistance > 0.0F) && !aPlayer.onGround && !aPlayer.isOnLadder() && !aPlayer.isInWater() && !aPlayer.isPotionActive(Potion.blindness) && (aPlayer.ridingEntity == null) && (aEntity instanceof EntityLivingBase); - if (tCriticalHit && (tDamage > 0.0F)) { - tDamage *= 1.5F; - } - tDamage += tMagicDamage; - if (aEntity.attackEntityFrom(tStats.getDamageSource(aPlayer, aEntity), tDamage)) { - if (aEntity instanceof EntityLivingBase) { - aEntity.setFire(EnchantmentHelper.getFireAspectModifier(aPlayer) * 4); - } - final int tKnockcack = (aPlayer.isSprinting() ? 1 : 0) + (aEntity instanceof EntityLivingBase ? EnchantmentHelper.getKnockbackModifier(aPlayer, (EntityLivingBase) aEntity) : 0); - if (tKnockcack > 0) { - aEntity.addVelocity(-MathHelper.sin((aPlayer.rotationYaw * (float) Math.PI) / 180.0F) * tKnockcack * 0.5F, 0.1D, MathHelper.cos((aPlayer.rotationYaw * (float) Math.PI) / 180.0F) * tKnockcack * 0.5F); - aPlayer.motionX *= 0.6D; - aPlayer.motionZ *= 0.6D; - aPlayer.setSprinting(false); - } - if (tCriticalHit) { - aPlayer.onCriticalHit(aEntity); - } - if (tMagicDamage > 0.0F) { - aPlayer.onEnchantmentCritical(aEntity); - } - if (tDamage >= 18.0F) { - aPlayer.triggerAchievement(AchievementList.overkill); - } - aPlayer.setLastAttacker(aEntity); - if (aEntity instanceof EntityLivingBase) { - EnchantmentHelper.func_151384_a((EntityLivingBase) aEntity, aPlayer); - } - EnchantmentHelper.func_151385_b(aPlayer, aEntity); - if (aEntity instanceof EntityLivingBase) { - aPlayer.addStat(StatList.damageDealtStat, Math.round(tDamage * 10.0F)); - } - aEntity.hurtResistantTime = Math.max(1, tStats.getHurtResistanceTime(aEntity.hurtResistantTime, aEntity)); - aPlayer.addExhaustion(0.3F); - this.doDamage(aStack, tStats.getToolDamagePerEntityAttack()); - } - } - } - if (aStack.stackSize <= 0) { - aPlayer.destroyCurrentEquippedItem(); - } - return true; - } - - @Override - public ItemStack onItemRightClick(final ItemStack aStack, final World aWorld, final EntityPlayer aPlayer) { - final IToolStats tStats = this.getToolStats(aStack); - if ((tStats != null) && tStats.canBlock()) { - aPlayer.setItemInUse(aStack, 72000); - } - return super.onItemRightClick(aStack, aWorld, aPlayer); - } - - - @Override - public Long[] getFluidContainerStats(final ItemStack aStack) { - return null; - } - - @Override - public Long[] getElectricStats(final ItemStack aStack) { - NBTTagCompound aNBT = aStack.getTagCompound(); - if (aNBT != null) { - aNBT = aNBT.getCompoundTag("GT.ToolStats"); - if ((aNBT != null) && aNBT.getBoolean("Electric")) { - return new Long[]{aNBT.getLong("MaxCharge"), aNBT.getLong("Voltage"), aNBT.getLong("Tier"), aNBT.getLong("SpecialData")}; - } - } - return null; - } - - @Override - public float getToolCombatDamage(final ItemStack aStack) { - final IToolStats tStats = this.getToolStats(aStack); - if (tStats == null) { - return 0; - } - return tStats.getBaseDamage() + getPrimaryMaterial(aStack).mToolQuality; - } - - @Override - public float getDigSpeed(final ItemStack aStack, final Block aBlock, final int aMetaData) { - if (!this.isItemStackUsable(aStack)) { - return 0.0F; - } - final IToolStats tStats = this.getToolStats(aStack); - if ((tStats == null) || (Math.max(0, this.getHarvestLevel(aStack, "")) < aBlock.getHarvestLevel(aMetaData))) { - return 0.0F; - } - return tStats.isMinableBlock(aBlock, (byte) aMetaData) ? Math.max(Float.MIN_NORMAL, tStats.getSpeedMultiplier() * getPrimaryMaterial(aStack).mToolSpeed) : 0.0F; - } - - @Override - public boolean onBlockDestroyed(final ItemStack aStack, final World aWorld, final Block aBlock, final int aX, final int aY, final int aZ, final EntityLivingBase aPlayer) { - if (!this.isItemStackUsable(aStack)) { - return false; - } - final IToolStats tStats = this.getToolStats(aStack); - if (tStats == null) { - return false; - } - GT_Utility.doSoundAtClient(tStats.getMiningSound(), 1, 1.0F); - this.doDamage(aStack, (int) Math.max(1, aBlock.getBlockHardness(aWorld, aX, aY, aZ) * tStats.getToolDamagePerBlockBreak())); - return this.getDigSpeed(aStack, aBlock, aWorld.getBlockMetadata(aX, aY, aZ)) > 0.0F; - } - - private ItemStack getContainerItem(ItemStack aStack, final boolean playSound) { - if (!this.isItemStackUsable(aStack)) { - return null; - } - aStack = GT_Utility.copyAmount(1, aStack); - final IToolStats tStats = this.getToolStats(aStack); - if (tStats == null) { - return null; - } - this.doDamage(aStack, tStats.getToolDamagePerContainerCraft()); - aStack = aStack.stackSize > 0 ? aStack : null; - if (playSound) { - //String sound = (aStack == null) ? tStats.getBreakingSound() : tStats.getCraftingSound(); - //GT_Utility.doSoundAtClient(sound, 1, 1.0F); - } - return aStack; - } - - @Override - public Interface_ToolStats getToolStats(final ItemStack aStack) { - this.isItemStackUsable(aStack); - return this.getToolStatsInternal(aStack); - } - - private Interface_ToolStats getToolStatsInternal(final ItemStack aStack) { - return (Interface_ToolStats) (aStack == null ? null : this.mToolStats.get((short) aStack.getItemDamage())); - } - - @Override - public float getSaplingModifier(final ItemStack aStack, final World aWorld, final EntityPlayer aPlayer, final int aX, final int aY, final int aZ) { - final IToolStats tStats = this.getToolStats(aStack); - return (tStats != null) && tStats.isGrafter() ? Math.min(100.0F, (1 + this.getHarvestLevel(aStack, "")) * 20.0F) : 0.0F; - } - - @Override - public boolean canWhack(final EntityPlayer aPlayer, final ItemStack aStack, final int aX, final int aY, final int aZ) { - if (!this.isItemStackUsable(aStack)) { - return false; - } - final IToolStats tStats = this.getToolStats(aStack); - return (tStats != null) && tStats.isCrowbar(); - } - - @Override - public void onWhack(final EntityPlayer aPlayer, final ItemStack aStack, final int aX, final int aY, final int aZ) { - final IToolStats tStats = this.getToolStats(aStack); - if (tStats != null) { - this.doDamage(aStack, tStats.getToolDamagePerEntityAttack()); - } - } - - public boolean canWrench(final EntityPlayer player, final int x, final int y, final int z) { - System.out.println("canWrench"); - if(player==null) { - return false; - } - if(player.getCurrentEquippedItem()==null) { - return false; - } - if (!this.isItemStackUsable(player.getCurrentEquippedItem())) { - return false; - } - final Interface_ToolStats tStats = this.getToolStats(player.getCurrentEquippedItem()); - return (tStats != null) && tStats.isWrench(); - } - - public void wrenchUsed(final EntityPlayer player, final int x, final int y, final int z) { - if(player==null) { - return; - } - if(player.getCurrentEquippedItem()==null) { - return; - } - final IToolStats tStats = this.getToolStats(player.getCurrentEquippedItem()); - if (tStats != null) { - this.doDamage(player.getCurrentEquippedItem(), tStats.getToolDamagePerEntityAttack()); - } - } - - public boolean canUse(final ItemStack stack, final EntityPlayer player, final int x, final int y, final int z){ - return this.canWrench(player, x, y, z); - } - - public void used(final ItemStack stack, final EntityPlayer player, final int x, final int y, final int z){ - this.wrenchUsed(player, x, y, z); - } - - public boolean shouldHideFacades(final ItemStack stack, final EntityPlayer player) { - if(player==null) { - return false; - } - if(player.getCurrentEquippedItem()==null) { - return false; - } - if (!this.isItemStackUsable(player.getCurrentEquippedItem())) { - return false; - } - final Interface_ToolStats tStats = this.getToolStats(player.getCurrentEquippedItem()); - return tStats.isWrench(); - } - - @Override - public boolean canLink(final EntityPlayer aPlayer, final ItemStack aStack, final EntityMinecart cart) { - if (!this.isItemStackUsable(aStack)) { - return false; - } - final IToolStats tStats = this.getToolStats(aStack); - return (tStats != null) && tStats.isCrowbar(); - } - - @Override - public void onLink(final EntityPlayer aPlayer, final ItemStack aStack, final EntityMinecart cart) { - final IToolStats tStats = this.getToolStats(aStack); - if (tStats != null) { - this.doDamage(aStack, tStats.getToolDamagePerEntityAttack()); - } - } - - @Override - public boolean canBoost(final EntityPlayer aPlayer, final ItemStack aStack, final EntityMinecart cart) { - if (!this.isItemStackUsable(aStack)) { - return false; - } - final IToolStats tStats = this.getToolStats(aStack); - return (tStats != null) && tStats.isCrowbar(); - } - - @Override - public void onBoost(final EntityPlayer aPlayer, final ItemStack aStack, final EntityMinecart cart) { - final IToolStats tStats = this.getToolStats(aStack); - if (tStats != null) { - this.doDamage(aStack, tStats.getToolDamagePerEntityAttack()); - } - } - - @Override - public void onCreated(final ItemStack aStack, final World aWorld, final EntityPlayer aPlayer) { - final IToolStats tStats = this.getToolStats(aStack); - if ((tStats != null) && (aPlayer != null)) { - tStats.onToolCrafted(aStack, aPlayer); - } - super.onCreated(aStack, aWorld, aPlayer); - } - - @Override - public boolean isFull3D() { - return true; - } - - @Override - public boolean isItemStackUsable(final ItemStack aStack) { - final IToolStats tStats = this.getToolStatsInternal(aStack); - if (((aStack.getItemDamage() % 2) == 1) || (tStats == null)) { - final NBTTagCompound aNBT = aStack.getTagCompound(); - if (aNBT != null) { - aNBT.removeTag("ench"); - } - return false; - } - final Materials aMaterial = getPrimaryMaterial(aStack); - final HashMap<Integer, Integer> tMap = new HashMap<>(), tResult = new HashMap<>(); - if (aMaterial.mEnchantmentTools != null) { - tMap.put(aMaterial.mEnchantmentTools.effectId, (int) aMaterial.mEnchantmentToolsLevel); - if (aMaterial.mEnchantmentTools == Enchantment.fortune) { - tMap.put(Enchantment.looting.effectId, (int) aMaterial.mEnchantmentToolsLevel); - } - if (aMaterial.mEnchantmentTools == Enchantment.knockback) { - tMap.put(Enchantment.power.effectId, (int) aMaterial.mEnchantmentToolsLevel); - } - if (aMaterial.mEnchantmentTools == Enchantment.fireAspect) { - tMap.put(Enchantment.flame.effectId, (int) aMaterial.mEnchantmentToolsLevel); - } - } - final Enchantment[] tEnchants = tStats.getEnchantments(aStack); - final int[] tLevels = tStats.getEnchantmentLevels(aStack); - for (int i = 0; i < tEnchants.length; i++) { - if (tLevels[i] > 0) { - final Integer tLevel = tMap.get(tEnchants[i].effectId); - tMap.put(tEnchants[i].effectId, tLevel == null ? tLevels[i] : tLevel == tLevels[i] ? tLevel + 1 : Math.max(tLevel, tLevels[i])); - } - } - for (final Entry<Integer, Integer> tEntry : tMap.entrySet()) { - if ((tEntry.getKey() == 33) || ((tEntry.getKey() == 20) && (tEntry.getValue() > 2)) || (tEntry.getKey() == Enchantment_Radioactivity.INSTANCE.effectId)) { - tResult.put(tEntry.getKey(), tEntry.getValue()); - } else { - switch (Enchantment.enchantmentsList[tEntry.getKey()].type) { - case weapon: - if (tStats.isWeapon()) { - tResult.put(tEntry.getKey(), tEntry.getValue()); - } - break; - case all: - tResult.put(tEntry.getKey(), tEntry.getValue()); - break; - case armor: - case armor_feet: - case armor_head: - case armor_legs: - case armor_torso: - break; - case bow: - if (tStats.isRangedWeapon()) { - tResult.put(tEntry.getKey(), tEntry.getValue()); - } - break; - case breakable: - break; - case fishing_rod: - break; - case digger: - if (tStats.isMiningTool()) { - tResult.put(tEntry.getKey(), tEntry.getValue()); - } - break; - } - } - } - EnchantmentHelper.setEnchantments(tResult, aStack); - return true; - } - - @Override - public short getChargedMetaData(final ItemStack aStack) { - return (short) (aStack.getItemDamage() - (aStack.getItemDamage() % 2)); - } - - @Override - public short getEmptyMetaData(final ItemStack aStack) { - final NBTTagCompound aNBT = aStack.getTagCompound(); - if (aNBT != null) { - aNBT.removeTag("ench"); - } - return (short) ((aStack.getItemDamage() + 1) - (aStack.getItemDamage() % 2)); - } - - @Override - public int getItemEnchantability() { - return 0; - } - - @Override - public boolean isBookEnchantable(final ItemStack aStack, final ItemStack aBook) { - return false; - } - - @Override - public boolean getIsRepairable(final ItemStack aStack, final ItemStack aMaterial) { - return false; - } -}
\ No newline at end of file + /** + * All instances of this Item Class are listed here. + * This gets used to register the Renderer to all Items of this Type, if useStandardMetaItemRenderer() returns true. + * <p/> + * You can also use the unlocalized Name gotten from getUnlocalizedName() as Key if you want to get a specific Item. + */ + public static final HashMap<String, GT_MetaGenTool> sInstances = new HashMap<>(); + + /* ---------- CONSTRUCTOR AND MEMBER VARIABLES ---------- */ + + public final HashMap<Short, IToolStats> mToolStats = new HashMap<>(); + + /** + * Creates the Item using these Parameters. + * + * @param aUnlocalized The Unlocalized Name of this Item. + */ + public GT_MetaGenTool(final String aUnlocalized) { + super(aUnlocalized); + GT_ModHandler.registerBoxableItemToToolBox(this); + this.setCreativeTab(GregTech_API.TAB_GREGTECH); + this.setMaxStackSize(1); + sInstances.put(this.getUnlocalizedName(), this); + } + + /* ---------- FOR ADDING CUSTOM ITEMS INTO THE REMAINING 766 RANGE ---------- */ + + public static final Materials getPrimaryMaterialEx(final ItemStack aStack) { + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag("GT.ToolStats"); + if (aNBT != null) { + return Materials.getRealMaterial(aNBT.getString("PrimaryMaterial")); + } + } + return Materials._NULL; + } + + public static final Materials getSecondaryMaterialEx(final ItemStack aStack) { + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag("GT.ToolStats"); + if (aNBT != null) { + return Materials.getRealMaterial(aNBT.getString("SecondaryMaterial")); + } + } + return Materials._NULL; + } + + /** + * This adds a Custom Item to the ending Range. + * + * @param aID The Id of the assigned Tool Class [0 - 32765] (only even Numbers allowed! Uneven ID's are empty electric Items) + * @param aEnglish The Default Localized Name of the created Item + * @param aToolTip The Default ToolTip of the created Item, you can also insert null for having no ToolTip + * @param aToolStats The Food Value of this Item. Can be null as well. + * @param aOreDictNamesAndAspects The OreDict Names you want to give the Item. Also used to assign Thaumcraft Aspects. + * @return An ItemStack containing the newly created Item, but without specific Stats. + */ + public final ItemStack addToolEx( + final int aID, + final String aEnglish, + String aToolTip, + final IToolStats aToolStats, + final Object... aOreDictNamesAndAspects) { + if (aToolTip == null) { + aToolTip = ""; + } + if ((aID >= 0) && (aID < 32766) && ((aID % 2) == 0)) { + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + "." + aID + ".name", aEnglish); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + "." + aID + ".tooltip", aToolTip); + GT_LanguageManager.addStringLocalization( + this.getUnlocalizedName() + "." + (aID + 1) + ".name", aEnglish + " (Empty)"); + GT_LanguageManager.addStringLocalization( + this.getUnlocalizedName() + "." + (aID + 1) + ".tooltip", "You need to recharge it"); + this.mToolStats.put((short) aID, aToolStats); + this.mToolStats.put((short) (aID + 1), aToolStats); + aToolStats.onStatsAddedToTool(this, aID); + final ItemStack rStack = new ItemStack(this, 1, aID); + final List<TC_AspectStack> tAspects = new ArrayList<>(); + for (final Object tOreDictNameOrAspect : aOreDictNamesAndAspects) { + if (tOreDictNameOrAspect instanceof TC_AspectStack) { + ((TC_AspectStack) tOreDictNameOrAspect).addToAspectList(tAspects); + } else { + GT_OreDictUnificator.registerOre(tOreDictNameOrAspect, rStack); + } + } + if (GregTech_API.sThaumcraftCompat != null) { + GregTech_API.sThaumcraftCompat.registerThaumcraftAspectsToItem(rStack, tAspects, false); + } + return rStack; + } + return null; + } + + /** + * This Function gets an ItemStack Version of this Tool + * + * @param aToolID the ID of the Tool Class + * @param aAmount Amount of Items (well normally you only need 1) + * @param aPrimaryMaterial Primary Material of this Tool + * @param aSecondaryMaterial Secondary (Rod/Handle) Material of this Tool + * @param aElectricArray The Electric Stats of this Tool (or null if not electric) + */ + public final ItemStack getToolWithStatsEx( + final int aToolID, + final int aAmount, + final Materials aPrimaryMaterial, + final Materials aSecondaryMaterial, + final long[] aElectricArray) { + final ItemStack rStack = new ItemStack(this, aAmount, aToolID); + final IToolStats tToolStats = this.getToolStats(rStack); + if (tToolStats != null) { + final NBTTagCompound tMainNBT = new NBTTagCompound(), tToolNBT = new NBTTagCompound(); + if (aPrimaryMaterial != null) { + tToolNBT.setString("PrimaryMaterial", aPrimaryMaterial.toString()); + tToolNBT.setLong( + "MaxDamage", + 100L * (long) (aPrimaryMaterial.mDurability * tToolStats.getMaxDurabilityMultiplier())); + } + if (aSecondaryMaterial != null) { + tToolNBT.setString("SecondaryMaterial", aSecondaryMaterial.toString()); + } + + if (aElectricArray != null) { + tToolNBT.setBoolean("Electric", true); + tToolNBT.setLong("MaxCharge", aElectricArray[0]); + tToolNBT.setLong("Voltage", aElectricArray[1]); + tToolNBT.setLong("Tier", aElectricArray[2]); + tToolNBT.setLong("SpecialData", aElectricArray[3]); + } + + tMainNBT.setTag("GT.ToolStats", tToolNBT); + rStack.setTagCompound(tMainNBT); + } + this.isItemStackUsable(rStack); + return rStack; + } + + /** + * Called by the Block Harvesting Event within the GT_Proxy + */ + @Override + public void onHarvestBlockEvent( + final ArrayList<ItemStack> aDrops, + final ItemStack aStack, + final EntityPlayer aPlayer, + final Block aBlock, + final int aX, + final int aY, + final int aZ, + final byte aMetaData, + final int aFortune, + final boolean aSilkTouch, + final BlockEvent.HarvestDropsEvent aEvent) { + final IToolStats tStats = this.getToolStats(aStack); + if (this.isItemStackUsable(aStack) && (this.getDigSpeed(aStack, aBlock, aMetaData) > 0.0F)) { + this.doDamage( + aStack, + tStats.convertBlockDrops( + aDrops, + aStack, + aPlayer, + aBlock, + aX, + aY, + aZ, + aMetaData, + aFortune, + aSilkTouch, + aEvent) + * tStats.getToolDamagePerDropConversion()); + } + } + + @Override + public boolean onLeftClickEntity(final ItemStack aStack, final EntityPlayer aPlayer, final Entity aEntity) { + final IToolStats tStats = this.getToolStats(aStack); + if ((tStats == null) || !this.isItemStackUsable(aStack)) { + return true; + } + GT_Utility.doSoundAtClient(tStats.getEntityHitSound(), 1, 1.0F); + if (super.onLeftClickEntity(aStack, aPlayer, aEntity)) { + return true; + } + if (aEntity.canAttackWithItem() && !aEntity.hitByEntity(aPlayer)) { + final float tMagicDamage = tStats.getMagicDamageAgainstEntity( + aEntity instanceof EntityLivingBase + ? EnchantmentHelper.getEnchantmentModifierLiving(aPlayer, (EntityLivingBase) aEntity) + : 0.0F, + aEntity, + aStack, + aPlayer); + float tDamage = tStats.getNormalDamageAgainstEntity( + (float) aPlayer.getEntityAttribute(SharedMonsterAttributes.attackDamage) + .getAttributeValue() + + this.getToolCombatDamage(aStack), + aEntity, + aStack, + aPlayer); + if ((tDamage + tMagicDamage) > 0.0F) { + final boolean tCriticalHit = (aPlayer.fallDistance > 0.0F) + && !aPlayer.onGround + && !aPlayer.isOnLadder() + && !aPlayer.isInWater() + && !aPlayer.isPotionActive(Potion.blindness) + && (aPlayer.ridingEntity == null) + && (aEntity instanceof EntityLivingBase); + if (tCriticalHit && (tDamage > 0.0F)) { + tDamage *= 1.5F; + } + tDamage += tMagicDamage; + if (aEntity.attackEntityFrom(tStats.getDamageSource(aPlayer, aEntity), tDamage)) { + if (aEntity instanceof EntityLivingBase) { + aEntity.setFire(EnchantmentHelper.getFireAspectModifier(aPlayer) * 4); + } + final int tKnockcack = (aPlayer.isSprinting() ? 1 : 0) + + (aEntity instanceof EntityLivingBase + ? EnchantmentHelper.getKnockbackModifier(aPlayer, (EntityLivingBase) aEntity) + : 0); + if (tKnockcack > 0) { + aEntity.addVelocity( + -MathHelper.sin((aPlayer.rotationYaw * (float) Math.PI) / 180.0F) * tKnockcack * 0.5F, + 0.1D, + MathHelper.cos((aPlayer.rotationYaw * (float) Math.PI) / 180.0F) * tKnockcack * 0.5F); + aPlayer.motionX *= 0.6D; + aPlayer.motionZ *= 0.6D; + aPlayer.setSprinting(false); + } + if (tCriticalHit) { + aPlayer.onCriticalHit(aEntity); + } + if (tMagicDamage > 0.0F) { + aPlayer.onEnchantmentCritical(aEntity); + } + if (tDamage >= 18.0F) { + aPlayer.triggerAchievement(AchievementList.overkill); + } + aPlayer.setLastAttacker(aEntity); + if (aEntity instanceof EntityLivingBase) { + EnchantmentHelper.func_151384_a((EntityLivingBase) aEntity, aPlayer); + } + EnchantmentHelper.func_151385_b(aPlayer, aEntity); + if (aEntity instanceof EntityLivingBase) { + aPlayer.addStat(StatList.damageDealtStat, Math.round(tDamage * 10.0F)); + } + aEntity.hurtResistantTime = + Math.max(1, tStats.getHurtResistanceTime(aEntity.hurtResistantTime, aEntity)); + aPlayer.addExhaustion(0.3F); + this.doDamage(aStack, tStats.getToolDamagePerEntityAttack()); + } + } + } + if (aStack.stackSize <= 0) { + aPlayer.destroyCurrentEquippedItem(); + } + return true; + } + + @Override + public ItemStack onItemRightClick(final ItemStack aStack, final World aWorld, final EntityPlayer aPlayer) { + final IToolStats tStats = this.getToolStats(aStack); + if ((tStats != null) && tStats.canBlock()) { + aPlayer.setItemInUse(aStack, 72000); + } + return super.onItemRightClick(aStack, aWorld, aPlayer); + } + + @Override + public Long[] getFluidContainerStats(final ItemStack aStack) { + return null; + } + + @Override + public Long[] getElectricStats(final ItemStack aStack) { + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag("GT.ToolStats"); + if ((aNBT != null) && aNBT.getBoolean("Electric")) { + return new Long[] { + aNBT.getLong("MaxCharge"), + aNBT.getLong("Voltage"), + aNBT.getLong("Tier"), + aNBT.getLong("SpecialData") + }; + } + } + return null; + } + + @Override + public float getToolCombatDamage(final ItemStack aStack) { + final IToolStats tStats = this.getToolStats(aStack); + if (tStats == null) { + return 0; + } + return tStats.getBaseDamage() + getPrimaryMaterial(aStack).mToolQuality; + } + + @Override + public float getDigSpeed(final ItemStack aStack, final Block aBlock, final int aMetaData) { + if (!this.isItemStackUsable(aStack)) { + return 0.0F; + } + final IToolStats tStats = this.getToolStats(aStack); + if ((tStats == null) || (Math.max(0, this.getHarvestLevel(aStack, "")) < aBlock.getHarvestLevel(aMetaData))) { + return 0.0F; + } + return tStats.isMinableBlock(aBlock, (byte) aMetaData) + ? Math.max(Float.MIN_NORMAL, tStats.getSpeedMultiplier() * getPrimaryMaterial(aStack).mToolSpeed) + : 0.0F; + } + + @Override + public boolean onBlockDestroyed( + final ItemStack aStack, + final World aWorld, + final Block aBlock, + final int aX, + final int aY, + final int aZ, + final EntityLivingBase aPlayer) { + if (!this.isItemStackUsable(aStack)) { + return false; + } + final IToolStats tStats = this.getToolStats(aStack); + if (tStats == null) { + return false; + } + GT_Utility.doSoundAtClient(tStats.getMiningSound(), 1, 1.0F); + this.doDamage(aStack, (int) + Math.max(1, aBlock.getBlockHardness(aWorld, aX, aY, aZ) * tStats.getToolDamagePerBlockBreak())); + return this.getDigSpeed(aStack, aBlock, aWorld.getBlockMetadata(aX, aY, aZ)) > 0.0F; + } + + private ItemStack getContainerItem(ItemStack aStack, final boolean playSound) { + if (!this.isItemStackUsable(aStack)) { + return null; + } + aStack = GT_Utility.copyAmount(1, aStack); + final IToolStats tStats = this.getToolStats(aStack); + if (tStats == null) { + return null; + } + this.doDamage(aStack, tStats.getToolDamagePerContainerCraft()); + aStack = aStack.stackSize > 0 ? aStack : null; + if (playSound) { + // String sound = (aStack == null) ? tStats.getBreakingSound() : tStats.getCraftingSound(); + // GT_Utility.doSoundAtClient(sound, 1, 1.0F); + } + return aStack; + } + + @Override + public Interface_ToolStats getToolStats(final ItemStack aStack) { + this.isItemStackUsable(aStack); + return this.getToolStatsInternal(aStack); + } + + private Interface_ToolStats getToolStatsInternal(final ItemStack aStack) { + return (Interface_ToolStats) (aStack == null ? null : this.mToolStats.get((short) aStack.getItemDamage())); + } + + @Override + public float getSaplingModifier( + final ItemStack aStack, + final World aWorld, + final EntityPlayer aPlayer, + final int aX, + final int aY, + final int aZ) { + final IToolStats tStats = this.getToolStats(aStack); + return (tStats != null) && tStats.isGrafter() + ? Math.min(100.0F, (1 + this.getHarvestLevel(aStack, "")) * 20.0F) + : 0.0F; + } + + @Override + public boolean canWhack( + final EntityPlayer aPlayer, final ItemStack aStack, final int aX, final int aY, final int aZ) { + if (!this.isItemStackUsable(aStack)) { + return false; + } + final IToolStats tStats = this.getToolStats(aStack); + return (tStats != null) && tStats.isCrowbar(); + } + + @Override + public void onWhack(final EntityPlayer aPlayer, final ItemStack aStack, final int aX, final int aY, final int aZ) { + final IToolStats tStats = this.getToolStats(aStack); + if (tStats != null) { + this.doDamage(aStack, tStats.getToolDamagePerEntityAttack()); + } + } + + public boolean canWrench(final EntityPlayer player, final int x, final int y, final int z) { + System.out.println("canWrench"); + if (player == null) { + return false; + } + if (player.getCurrentEquippedItem() == null) { + return false; + } + if (!this.isItemStackUsable(player.getCurrentEquippedItem())) { + return false; + } + final Interface_ToolStats tStats = this.getToolStats(player.getCurrentEquippedItem()); + return (tStats != null) && tStats.isWrench(); + } + + public void wrenchUsed(final EntityPlayer player, final int x, final int y, final int z) { + if (player == null) { + return; + } + if (player.getCurrentEquippedItem() == null) { + return; + } + final IToolStats tStats = this.getToolStats(player.getCurrentEquippedItem()); + if (tStats != null) { + this.doDamage(player.getCurrentEquippedItem(), tStats.getToolDamagePerEntityAttack()); + } + } + + public boolean canUse(final ItemStack stack, final EntityPlayer player, final int x, final int y, final int z) { + return this.canWrench(player, x, y, z); + } + + public void used(final ItemStack stack, final EntityPlayer player, final int x, final int y, final int z) { + this.wrenchUsed(player, x, y, z); + } + + public boolean shouldHideFacades(final ItemStack stack, final EntityPlayer player) { + if (player == null) { + return false; + } + if (player.getCurrentEquippedItem() == null) { + return false; + } + if (!this.isItemStackUsable(player.getCurrentEquippedItem())) { + return false; + } + final Interface_ToolStats tStats = this.getToolStats(player.getCurrentEquippedItem()); + return tStats.isWrench(); + } + + @Override + public boolean canLink(final EntityPlayer aPlayer, final ItemStack aStack, final EntityMinecart cart) { + if (!this.isItemStackUsable(aStack)) { + return false; + } + final IToolStats tStats = this.getToolStats(aStack); + return (tStats != null) && tStats.isCrowbar(); + } + + @Override + public void onLink(final EntityPlayer aPlayer, final ItemStack aStack, final EntityMinecart cart) { + final IToolStats tStats = this.getToolStats(aStack); + if (tStats != null) { + this.doDamage(aStack, tStats.getToolDamagePerEntityAttack()); + } + } + + @Override + public boolean canBoost(final EntityPlayer aPlayer, final ItemStack aStack, final EntityMinecart cart) { + if (!this.isItemStackUsable(aStack)) { + return false; + } + final IToolStats tStats = this.getToolStats(aStack); + return (tStats != null) && tStats.isCrowbar(); + } + + @Override + public void onBoost(final EntityPlayer aPlayer, final ItemStack aStack, final EntityMinecart cart) { + final IToolStats tStats = this.getToolStats(aStack); + if (tStats != null) { + this.doDamage(aStack, tStats.getToolDamagePerEntityAttack()); + } + } + + @Override + public void onCreated(final ItemStack aStack, final World aWorld, final EntityPlayer aPlayer) { + final IToolStats tStats = this.getToolStats(aStack); + if ((tStats != null) && (aPlayer != null)) { + tStats.onToolCrafted(aStack, aPlayer); + } + super.onCreated(aStack, aWorld, aPlayer); + } + + @Override + public boolean isFull3D() { + return true; + } + + @Override + public boolean isItemStackUsable(final ItemStack aStack) { + final IToolStats tStats = this.getToolStatsInternal(aStack); + if (((aStack.getItemDamage() % 2) == 1) || (tStats == null)) { + final NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT.removeTag("ench"); + } + return false; + } + final Materials aMaterial = getPrimaryMaterial(aStack); + final HashMap<Integer, Integer> tMap = new HashMap<>(), tResult = new HashMap<>(); + if (aMaterial.mEnchantmentTools != null) { + tMap.put(aMaterial.mEnchantmentTools.effectId, (int) aMaterial.mEnchantmentToolsLevel); + if (aMaterial.mEnchantmentTools == Enchantment.fortune) { + tMap.put(Enchantment.looting.effectId, (int) aMaterial.mEnchantmentToolsLevel); + } + if (aMaterial.mEnchantmentTools == Enchantment.knockback) { + tMap.put(Enchantment.power.effectId, (int) aMaterial.mEnchantmentToolsLevel); + } + if (aMaterial.mEnchantmentTools == Enchantment.fireAspect) { + tMap.put(Enchantment.flame.effectId, (int) aMaterial.mEnchantmentToolsLevel); + } + } + final Enchantment[] tEnchants = tStats.getEnchantments(aStack); + final int[] tLevels = tStats.getEnchantmentLevels(aStack); + for (int i = 0; i < tEnchants.length; i++) { + if (tLevels[i] > 0) { + final Integer tLevel = tMap.get(tEnchants[i].effectId); + tMap.put( + tEnchants[i].effectId, + tLevel == null ? tLevels[i] : tLevel == tLevels[i] ? tLevel + 1 : Math.max(tLevel, tLevels[i])); + } + } + for (final Entry<Integer, Integer> tEntry : tMap.entrySet()) { + if ((tEntry.getKey() == 33) + || ((tEntry.getKey() == 20) && (tEntry.getValue() > 2)) + || (tEntry.getKey() == Enchantment_Radioactivity.INSTANCE.effectId)) { + tResult.put(tEntry.getKey(), tEntry.getValue()); + } else { + switch (Enchantment.enchantmentsList[tEntry.getKey()].type) { + case weapon: + if (tStats.isWeapon()) { + tResult.put(tEntry.getKey(), tEntry.getValue()); + } + break; + case all: + tResult.put(tEntry.getKey(), tEntry.getValue()); + break; + case armor: + case armor_feet: + case armor_head: + case armor_legs: + case armor_torso: + break; + case bow: + if (tStats.isRangedWeapon()) { + tResult.put(tEntry.getKey(), tEntry.getValue()); + } + break; + case breakable: + break; + case fishing_rod: + break; + case digger: + if (tStats.isMiningTool()) { + tResult.put(tEntry.getKey(), tEntry.getValue()); + } + break; + } + } + } + EnchantmentHelper.setEnchantments(tResult, aStack); + return true; + } + + @Override + public short getChargedMetaData(final ItemStack aStack) { + return (short) (aStack.getItemDamage() - (aStack.getItemDamage() % 2)); + } + + @Override + public short getEmptyMetaData(final ItemStack aStack) { + final NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT.removeTag("ench"); + } + return (short) ((aStack.getItemDamage() + 1) - (aStack.getItemDamage() % 2)); + } + + @Override + public int getItemEnchantability() { + return 0; + } + + @Override + public boolean isBookEnchantable(final ItemStack aStack, final ItemStack aBook) { + return false; + } + + @Override + public boolean getIsRepairable(final ItemStack aStack, final ItemStack aMaterial) { + return false; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/items/types/ToolType_Base.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/items/types/ToolType_Base.java index cefd72332b..e57f2009e7 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/items/types/ToolType_Base.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/items/types/ToolType_Base.java @@ -1,7 +1,9 @@ package gtPlusPlus.xmod.gregtech.api.items.types; +import gregtech.api.enums.SubTag; +import gtPlusPlus.xmod.gregtech.api.interfaces.internal.Interface_ItemBehaviour; +import gtPlusPlus.xmod.gregtech.api.items.Gregtech_MetaItem_Base; import java.util.List; - import net.minecraft.block.BlockDispenser; import net.minecraft.dispenser.BehaviorDefaultDispenseItem; import net.minecraft.dispenser.IBlockSource; @@ -14,72 +16,118 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.EnumFacing; import net.minecraft.world.World; -import gregtech.api.enums.SubTag; - -import gtPlusPlus.xmod.gregtech.api.interfaces.internal.Interface_ItemBehaviour; -import gtPlusPlus.xmod.gregtech.api.items.Gregtech_MetaItem_Base; - public class ToolType_Base implements Interface_ItemBehaviour<Gregtech_MetaItem_Base> { - @Override - public boolean onLeftClickEntity(final Gregtech_MetaItem_Base aItem, final ItemStack aStack, final EntityPlayer aPlayer, final Entity aEntity) { - return false; - } - - @Override - public boolean onItemUse(final Gregtech_MetaItem_Base aItem, final ItemStack aStack, final EntityPlayer aPlayer, final World aWorld, final int aX, final int aY, final int aZ, final int aSide, final float hitX, final float hitY, final float hitZ) { - return false; - } - - @Override - public boolean onItemUseFirst(final Gregtech_MetaItem_Base aItem, final ItemStack aStack, final EntityPlayer aPlayer, final World aWorld, final int aX, final int aY, final int aZ, final int aSide, final float hitX, final float hitY, final float hitZ) { - return false; - } - - @Override - public ItemStack onItemRightClick(final Gregtech_MetaItem_Base aItem, final ItemStack aStack, final World aWorld, final EntityPlayer aPlayer) { - return aStack; - } - - @Override - public List<String> getAdditionalToolTips(final Gregtech_MetaItem_Base aItem, final List<String> aList, final ItemStack aStack) { - return aList; - } - - @Override - public void onUpdate(final Gregtech_MetaItem_Base aItem, final ItemStack aStack, final World aWorld, final Entity aPlayer, final int aTimer, final boolean aIsInHand) { - } - - @Override - public boolean isItemStackUsable(final Gregtech_MetaItem_Base aItem, final ItemStack aStack) { - return true; - } - - @Override - public boolean canDispense(final Gregtech_MetaItem_Base aItem, final IBlockSource aSource, final ItemStack aStack) { - return false; - } - - @Override - public ItemStack onDispense(final Gregtech_MetaItem_Base aItem, final IBlockSource aSource, final ItemStack aStack) { - final EnumFacing enumfacing = BlockDispenser.func_149937_b(aSource.getBlockMetadata()); - final IPosition iposition = BlockDispenser.func_149939_a(aSource); - final ItemStack itemstack1 = aStack.splitStack(1); - BehaviorDefaultDispenseItem.doDispense(aSource.getWorld(), itemstack1, 6, enumfacing, iposition); - return aStack; - } - - @Override - public boolean hasProjectile(final Gregtech_MetaItem_Base aItem, final SubTag aProjectileType, final ItemStack aStack) { - return false; - } - - @Override - public EntityArrow getProjectile(final Gregtech_MetaItem_Base aItem, final SubTag aProjectileType, final ItemStack aStack, final World aWorld, final double aX, final double aY, final double aZ) { - return null; - } - - @Override - public EntityArrow getProjectile(final Gregtech_MetaItem_Base aItem, final SubTag aProjectileType, final ItemStack aStack, final World aWorld, final EntityLivingBase aEntity, final float aSpeed) { - return null; - } + @Override + public boolean onLeftClickEntity( + final Gregtech_MetaItem_Base aItem, + final ItemStack aStack, + final EntityPlayer aPlayer, + final Entity aEntity) { + return false; + } + + @Override + public boolean onItemUse( + final Gregtech_MetaItem_Base aItem, + final ItemStack aStack, + final EntityPlayer aPlayer, + final World aWorld, + final int aX, + final int aY, + final int aZ, + final int aSide, + final float hitX, + final float hitY, + final float hitZ) { + return false; + } + + @Override + public boolean onItemUseFirst( + final Gregtech_MetaItem_Base aItem, + final ItemStack aStack, + final EntityPlayer aPlayer, + final World aWorld, + final int aX, + final int aY, + final int aZ, + final int aSide, + final float hitX, + final float hitY, + final float hitZ) { + return false; + } + + @Override + public ItemStack onItemRightClick( + final Gregtech_MetaItem_Base aItem, + final ItemStack aStack, + final World aWorld, + final EntityPlayer aPlayer) { + return aStack; + } + + @Override + public List<String> getAdditionalToolTips( + final Gregtech_MetaItem_Base aItem, final List<String> aList, final ItemStack aStack) { + return aList; + } + + @Override + public void onUpdate( + final Gregtech_MetaItem_Base aItem, + final ItemStack aStack, + final World aWorld, + final Entity aPlayer, + final int aTimer, + final boolean aIsInHand) {} + + @Override + public boolean isItemStackUsable(final Gregtech_MetaItem_Base aItem, final ItemStack aStack) { + return true; + } + + @Override + public boolean canDispense(final Gregtech_MetaItem_Base aItem, final IBlockSource aSource, final ItemStack aStack) { + return false; + } + + @Override + public ItemStack onDispense( + final Gregtech_MetaItem_Base aItem, final IBlockSource aSource, final ItemStack aStack) { + final EnumFacing enumfacing = BlockDispenser.func_149937_b(aSource.getBlockMetadata()); + final IPosition iposition = BlockDispenser.func_149939_a(aSource); + final ItemStack itemstack1 = aStack.splitStack(1); + BehaviorDefaultDispenseItem.doDispense(aSource.getWorld(), itemstack1, 6, enumfacing, iposition); + return aStack; + } + + @Override + public boolean hasProjectile( + final Gregtech_MetaItem_Base aItem, final SubTag aProjectileType, final ItemStack aStack) { + return false; + } + + @Override + public EntityArrow getProjectile( + final Gregtech_MetaItem_Base aItem, + final SubTag aProjectileType, + final ItemStack aStack, + final World aWorld, + final double aX, + final double aY, + final double aZ) { + return null; + } + + @Override + public EntityArrow getProjectile( + final Gregtech_MetaItem_Base aItem, + final SubTag aProjectileType, + final ItemStack aStack, + final World aWorld, + final EntityLivingBase aEntity, + final float aSpeed) { + return null; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/items/types/ToolType_HardHammer.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/items/types/ToolType_HardHammer.java index d4f5a87006..49063c43c2 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/items/types/ToolType_HardHammer.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/items/types/ToolType_HardHammer.java @@ -1,15 +1,5 @@ package gtPlusPlus.xmod.gregtech.api.items.types; -import java.util.List; -import java.util.Random; - -import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; - import gregtech.api.GregTech_API; import gregtech.api.enums.Materials; import gregtech.api.items.GT_MetaBase_Item; @@ -18,108 +8,141 @@ import gregtech.api.objects.ItemData; import gregtech.api.util.*; import gregtech.common.blocks.GT_Block_Ores; import gregtech.common.blocks.GT_TileEntity_Ores; - +import java.util.List; +import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.IFluidBlock; -public class ToolType_HardHammer -extends ToolType_Base { - private final int mVanillaCosts; - private final int mEUCosts; - private final String mTooltip = GT_LanguageManager.addStringLocalization("gt.behaviour.prospecting", "Usable for Prospecting"); - - public ToolType_HardHammer(final int aVanillaCosts, final int aEUCosts) { - this.mVanillaCosts = aVanillaCosts; - this.mEUCosts = aEUCosts; - } +public class ToolType_HardHammer extends ToolType_Base { + private final int mVanillaCosts; + private final int mEUCosts; + private final String mTooltip = + GT_LanguageManager.addStringLocalization("gt.behaviour.prospecting", "Usable for Prospecting"); - public boolean onItemUseFirst(final GT_MetaBase_Item aItem, final ItemStack aStack, final EntityPlayer aPlayer, final World aWorld, final int aX, final int aY, final int aZ, final int aSide, final float hitX, final float hitY, final float hitZ) { - if (aWorld.isRemote) { - return false; - } - final Block aBlock = aWorld.getBlock(aX, aY, aZ); - if (aBlock == null) { - return false; - } - final byte aMeta = (byte) aWorld.getBlockMetadata(aX, aY, aZ); + public ToolType_HardHammer(final int aVanillaCosts, final int aEUCosts) { + this.mVanillaCosts = aVanillaCosts; + this.mEUCosts = aEUCosts; + } + public boolean onItemUseFirst( + final GT_MetaBase_Item aItem, + final ItemStack aStack, + final EntityPlayer aPlayer, + final World aWorld, + final int aX, + final int aY, + final int aZ, + final int aSide, + final float hitX, + final float hitY, + final float hitZ) { + if (aWorld.isRemote) { + return false; + } + final Block aBlock = aWorld.getBlock(aX, aY, aZ); + if (aBlock == null) { + return false; + } + final byte aMeta = (byte) aWorld.getBlockMetadata(aX, aY, aZ); - ItemData tAssotiation = GT_OreDictUnificator.getAssociation(new ItemStack(aBlock, 1, aMeta)); - if ((tAssotiation != null) && (tAssotiation.mPrefix.toString().startsWith("ore"))) { - GT_Utility.sendChatToPlayer(aPlayer, "This is " + tAssotiation.mMaterial.mMaterial.mDefaultLocalName + " Ore."); - GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(Integer.valueOf(1)), 1.0F, -1.0F, aX, aY, aZ); - return true; - } - if ((aBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Blocks.stone)) || (aBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, GregTech_API.sBlockGranites)) || (aBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Blocks.netherrack)) || (aBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Blocks.end_stone))) { - if (GT_ModHandler.damageOrDechargeItem(aStack, this.mVanillaCosts, this.mEUCosts, aPlayer)) { - GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(Integer.valueOf(1)), 1.0F, -1.0F, aX, aY, aZ); - int tX = aX; - int tY = aY; - int tZ = aZ; - int tMetaID = 0; - final int tQuality = (aItem instanceof GT_MetaGenerated_Tool) ? ((GT_MetaGenerated_Tool) aItem).getHarvestLevel(aStack, "") : 0; + ItemData tAssotiation = GT_OreDictUnificator.getAssociation(new ItemStack(aBlock, 1, aMeta)); + if ((tAssotiation != null) && (tAssotiation.mPrefix.toString().startsWith("ore"))) { + GT_Utility.sendChatToPlayer( + aPlayer, "This is " + tAssotiation.mMaterial.mMaterial.mDefaultLocalName + " Ore."); + GT_Utility.sendSoundToPlayers( + aWorld, GregTech_API.sSoundList.get(Integer.valueOf(1)), 1.0F, -1.0F, aX, aY, aZ); + return true; + } + if ((aBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Blocks.stone)) + || (aBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, GregTech_API.sBlockGranites)) + || (aBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Blocks.netherrack)) + || (aBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Blocks.end_stone))) { + if (GT_ModHandler.damageOrDechargeItem(aStack, this.mVanillaCosts, this.mEUCosts, aPlayer)) { + GT_Utility.sendSoundToPlayers( + aWorld, GregTech_API.sSoundList.get(Integer.valueOf(1)), 1.0F, -1.0F, aX, aY, aZ); + int tX = aX; + int tY = aY; + int tZ = aZ; + int tMetaID = 0; + final int tQuality = (aItem instanceof GT_MetaGenerated_Tool) + ? ((GT_MetaGenerated_Tool) aItem).getHarvestLevel(aStack, "") + : 0; - int i = 0; - for (final int j = 6 + tQuality; i < j; i++) { - tX -= ForgeDirection.getOrientation(aSide).offsetX; - tY -= ForgeDirection.getOrientation(aSide).offsetY; - tZ -= ForgeDirection.getOrientation(aSide).offsetZ; + int i = 0; + for (final int j = 6 + tQuality; i < j; i++) { + tX -= ForgeDirection.getOrientation(aSide).offsetX; + tY -= ForgeDirection.getOrientation(aSide).offsetY; + tZ -= ForgeDirection.getOrientation(aSide).offsetZ; - final Block tBlock = aWorld.getBlock(tX, tY, tZ); - if ((tBlock == Blocks.lava) || (tBlock == Blocks.flowing_lava)) { - GT_Utility.sendChatToPlayer(aPlayer, "There is Lava behind this Rock."); - break; - } - if ((tBlock == Blocks.water) || (tBlock == Blocks.flowing_water) || ((tBlock instanceof IFluidBlock))) { - GT_Utility.sendChatToPlayer(aPlayer, "There is a Liquid behind this Rock."); - break; - } - if ((tBlock == Blocks.monster_egg) || (!GT_Utility.hasBlockHitBox(aWorld, tX, tY, tZ))) { - GT_Utility.sendChatToPlayer(aPlayer, "There is an Air Pocket behind this Rock."); - break; - } - if (tBlock != aBlock) { - if (i >= 4) { - break; - } - GT_Utility.sendChatToPlayer(aPlayer, "Material is changing behind this Rock."); - break; - } - } - final Random tRandom = new Random(aX ^ aY ^ aZ ^ aSide); - i = 0; - for (final int j = 9 + (2 * tQuality); i < j; i++) { - tX = (aX - 4 - tQuality) + tRandom.nextInt(j); - tY = (aY - 4 - tQuality) + tRandom.nextInt(j); - tZ = (aZ - 4 - tQuality) + tRandom.nextInt(j); - final Block tBlock = aWorld.getBlock(tX, tY, tZ); - if ((tBlock instanceof GT_Block_Ores)) { - final TileEntity tTileEntity = aWorld.getTileEntity(tX, tY, tZ); - if ((tTileEntity instanceof GT_TileEntity_Ores)) { - final Materials tMaterial = GregTech_API.sGeneratedMaterials[(((GT_TileEntity_Ores) tTileEntity).mMetaData % 1000)]; - if ((tMaterial != null) && (tMaterial != Materials._NULL)) { - GT_Utility.sendChatToPlayer(aPlayer, "Found traces of " + tMaterial.mDefaultLocalName + " Ore."); - return true; - } - } - } else { - tMetaID = aWorld.getBlockMetadata(tX, tY, tZ); - tAssotiation = GT_OreDictUnificator.getAssociation(new ItemStack(tBlock, 1, tMetaID)); - if ((tAssotiation != null) && (tAssotiation.mPrefix.toString().startsWith("ore"))) { - GT_Utility.sendChatToPlayer(aPlayer, "Found traces of " + tAssotiation.mMaterial.mMaterial.mDefaultLocalName + " Ore."); - return true; - } - } - } - GT_Utility.sendChatToPlayer(aPlayer, "No Ores found."); - } - return true; - } - return false; - } + final Block tBlock = aWorld.getBlock(tX, tY, tZ); + if ((tBlock == Blocks.lava) || (tBlock == Blocks.flowing_lava)) { + GT_Utility.sendChatToPlayer(aPlayer, "There is Lava behind this Rock."); + break; + } + if ((tBlock == Blocks.water) + || (tBlock == Blocks.flowing_water) + || ((tBlock instanceof IFluidBlock))) { + GT_Utility.sendChatToPlayer(aPlayer, "There is a Liquid behind this Rock."); + break; + } + if ((tBlock == Blocks.monster_egg) || (!GT_Utility.hasBlockHitBox(aWorld, tX, tY, tZ))) { + GT_Utility.sendChatToPlayer(aPlayer, "There is an Air Pocket behind this Rock."); + break; + } + if (tBlock != aBlock) { + if (i >= 4) { + break; + } + GT_Utility.sendChatToPlayer(aPlayer, "Material is changing behind this Rock."); + break; + } + } + final Random tRandom = new Random(aX ^ aY ^ aZ ^ aSide); + i = 0; + for (final int j = 9 + (2 * tQuality); i < j; i++) { + tX = (aX - 4 - tQuality) + tRandom.nextInt(j); + tY = (aY - 4 - tQuality) + tRandom.nextInt(j); + tZ = (aZ - 4 - tQuality) + tRandom.nextInt(j); + final Block tBlock = aWorld.getBlock(tX, tY, tZ); + if ((tBlock instanceof GT_Block_Ores)) { + final TileEntity tTileEntity = aWorld.getTileEntity(tX, tY, tZ); + if ((tTileEntity instanceof GT_TileEntity_Ores)) { + final Materials tMaterial = GregTech_API.sGeneratedMaterials[ + (((GT_TileEntity_Ores) tTileEntity).mMetaData % 1000)]; + if ((tMaterial != null) && (tMaterial != Materials._NULL)) { + GT_Utility.sendChatToPlayer( + aPlayer, "Found traces of " + tMaterial.mDefaultLocalName + " Ore."); + return true; + } + } + } else { + tMetaID = aWorld.getBlockMetadata(tX, tY, tZ); + tAssotiation = GT_OreDictUnificator.getAssociation(new ItemStack(tBlock, 1, tMetaID)); + if ((tAssotiation != null) + && (tAssotiation.mPrefix.toString().startsWith("ore"))) { + GT_Utility.sendChatToPlayer( + aPlayer, + "Found traces of " + tAssotiation.mMaterial.mMaterial.mDefaultLocalName + " Ore."); + return true; + } + } + } + GT_Utility.sendChatToPlayer(aPlayer, "No Ores found."); + } + return true; + } + return false; + } - public List<String> getAdditionalToolTips(final GT_MetaBase_Item aItem, final List<String> aList, final ItemStack aStack) { - aList.add(this.mTooltip); - return aList; - } + public List<String> getAdditionalToolTips( + final GT_MetaBase_Item aItem, final List<String> aList, final ItemStack aStack) { + aList.add(this.mTooltip); + return aList; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/items/types/ToolType_Pump.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/items/types/ToolType_Pump.java index f62d9e5cfa..f1dd3b391d 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/items/types/ToolType_Pump.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/items/types/ToolType_Pump.java @@ -1,150 +1,151 @@ package gtPlusPlus.xmod.gregtech.api.items.types; -import java.util.Arrays; +import gregtech.api.items.GT_MetaBase_Item; +import gregtech.api.util.GT_LanguageManager; +import gregtech.api.util.GT_Utility; import java.util.List; - import net.minecraft.block.Block; -import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; -import gregtech.api.GregTech_API; -import gregtech.api.items.GT_MetaBase_Item; -import gregtech.api.items.GT_MetaGenerated_Tool; -import gregtech.api.util.GT_LanguageManager; -import gregtech.api.util.GT_ModHandler; -import gregtech.api.util.GT_Utility; - -import ic2.api.tile.IWrenchable; -import net.minecraftforge.common.util.ForgeDirection; - -public class ToolType_Pump -extends ToolType_Base { - private final int mCosts; - private final String mTooltip = GT_LanguageManager.addStringLocalization("gt.behaviour.pump", "Sucks in Machine Input Fluid tank contents on Rightclick"); +public class ToolType_Pump extends ToolType_Base { + private final int mCosts; + private final String mTooltip = GT_LanguageManager.addStringLocalization( + "gt.behaviour.pump", "Sucks in Machine Input Fluid tank contents on Rightclick"); - public ToolType_Pump(final int aCosts) { - this.mCosts = aCosts; - } + public ToolType_Pump(final int aCosts) { + this.mCosts = aCosts; + } - public boolean onItemUseFirst(final GT_MetaBase_Item aItem, final ItemStack aStack, final EntityPlayer aPlayer, final World aWorld, final int aX, final int aY, final int aZ, final int aSide, final float hitX, final float hitY, final float hitZ) { - if (aWorld.isRemote) { - return false; - } - final Block aBlock = aWorld.getBlock(aX, aY, aZ); - if (aBlock == null) { - return false; - } - final byte aMeta = (byte) aWorld.getBlockMetadata(aX, aY, aZ); - final byte aTargetSide = GT_Utility.determineWrenchingSide((byte) aSide, hitX, hitY, hitZ); - final TileEntity aTileEntity = aWorld.getTileEntity(aX, aY, aZ); - /*try { - if ((aTileEntity != null) && ((aTileEntity instanceof IWrenchable))) { - if (((IWrenchable) aTileEntity).wrenchCanSetFacing(aPlayer, aTargetSide)) { - if ((aPlayer.capabilities.isCreativeMode) || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts))) { - ((IWrenchable) aTileEntity).setFacing(aTargetSide); - GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, aZ); - } - return true; - } - if (((IWrenchable) aTileEntity).wrenchCanRemove(aPlayer)) { - final int tDamage = ((IWrenchable) aTileEntity).getWrenchDropRate() < 1.0F ? 10 : 3; - if ((aPlayer.capabilities.isCreativeMode) || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, tDamage * this.mCosts))) { - ItemStack tOutput = ((IWrenchable) aTileEntity).getWrenchDrop(aPlayer); - for (final ItemStack tStack : aBlock.getDrops(aWorld, aX, aY, aZ, aMeta, 0)) { - if (tOutput == null) { - aWorld.spawnEntityInWorld(new EntityItem(aWorld, aX + 0.5D, aY + 0.5D, aZ + 0.5D, tStack)); - } else { - aWorld.spawnEntityInWorld(new EntityItem(aWorld, aX + 0.5D, aY + 0.5D, aZ + 0.5D, tOutput)); - tOutput = null; - } - } - aWorld.setBlockToAir(aX, aY, aZ); - GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, aZ); - } - return true; - } - return true; - } - } catch (final Throwable e) { - } - if ((aBlock == Blocks.log) || (aBlock == Blocks.log2) || (aBlock == Blocks.hay_block)) { - if ((aPlayer.capabilities.isCreativeMode) || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts))) { - aWorld.setBlockMetadataWithNotify(aX, aY, aZ, (aMeta + 4) % 12, 3); - GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, aZ); - } - return true; - } - if ((aBlock == Blocks.powered_repeater) || (aBlock == Blocks.unpowered_repeater)) { - if ((aPlayer.capabilities.isCreativeMode) || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts))) { - aWorld.setBlockMetadataWithNotify(aX, aY, aZ, ((aMeta / 4) * 4) + (((aMeta % 4) + 1) % 4), 3); - GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, aZ); - } - return true; - } - if ((aBlock == Blocks.powered_comparator) || (aBlock == Blocks.unpowered_comparator)) { - if ((aPlayer.capabilities.isCreativeMode) || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts))) { - aWorld.setBlockMetadataWithNotify(aX, aY, aZ, ((aMeta / 4) * 4) + (((aMeta % 4) + 1) % 4), 3); - GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, aZ); - } - return true; - } - if ((aBlock == Blocks.crafting_table) || (aBlock == Blocks.bookshelf)) { - if ((aPlayer.capabilities.isCreativeMode) || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts))) { - aWorld.spawnEntityInWorld(new EntityItem(aWorld, aX + 0.5D, aY + 0.5D, aZ + 0.5D, new ItemStack(aBlock, 1, aMeta))); - aWorld.setBlockToAir(aX, aY, aZ); - GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, aZ); - } - return true; - } - if (aMeta == aTargetSide) { - if ((aBlock == Blocks.pumpkin) || (aBlock == Blocks.lit_pumpkin) || (aBlock == Blocks.piston) || (aBlock == Blocks.sticky_piston) || (aBlock == Blocks.dispenser) || (aBlock == Blocks.dropper) || (aBlock == Blocks.furnace) || (aBlock == Blocks.lit_furnace) || (aBlock == Blocks.chest) || (aBlock == Blocks.trapped_chest) || (aBlock == Blocks.ender_chest) || (aBlock == Blocks.hopper)) { - if ((aPlayer.capabilities.isCreativeMode) || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts))) { - aWorld.spawnEntityInWorld(new EntityItem(aWorld, aX + 0.5D, aY + 0.5D, aZ + 0.5D, new ItemStack(aBlock, 1, 0))); - aWorld.setBlockToAir(aX, aY, aZ); - GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, aZ); - } - return true; - } - } else { - if ((aBlock == Blocks.piston) || (aBlock == Blocks.sticky_piston) || (aBlock == Blocks.dispenser) || (aBlock == Blocks.dropper)) { - if ((aMeta < 6) && ((aPlayer.capabilities.isCreativeMode) || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts)))) { - aWorld.setBlockMetadataWithNotify(aX, aY, aZ, aTargetSide, 3); - GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, aZ); - } - return true; - } - if ((aBlock == Blocks.pumpkin) || (aBlock == Blocks.lit_pumpkin) || (aBlock == Blocks.furnace) || (aBlock == Blocks.lit_furnace) || (aBlock == Blocks.chest) || (aBlock == Blocks.ender_chest) || (aBlock == Blocks.trapped_chest)) { - if ((aTargetSide > 1) && ((aPlayer.capabilities.isCreativeMode) || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts)))) { - aWorld.setBlockMetadataWithNotify(aX, aY, aZ, aTargetSide, 3); - GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, aZ); - } - return true; - } - if (aBlock == Blocks.hopper) { - if ((aTargetSide != 1) && ((aPlayer.capabilities.isCreativeMode) || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts)))) { - aWorld.setBlockMetadataWithNotify(aX, aY, aZ, aTargetSide, 3); - GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, aZ); - } - return true; - } - } - if ((Arrays.asList(aBlock.getValidRotations(aWorld, aX, aY, aZ)).contains(ForgeDirection.getOrientation(aTargetSide))) && - ((aPlayer.capabilities.isCreativeMode) || (!GT_ModHandler.isElectricItem(aStack)) || (GT_ModHandler.canUseElectricItem(aStack, this.mCosts))) && - (aBlock.rotateBlock(aWorld, aX, aY, aZ, ForgeDirection.getOrientation(aTargetSide)))) { - if (!aPlayer.capabilities.isCreativeMode) { - ((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts); - } - GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, aZ); - }*/ - return false; - } + public boolean onItemUseFirst( + final GT_MetaBase_Item aItem, + final ItemStack aStack, + final EntityPlayer aPlayer, + final World aWorld, + final int aX, + final int aY, + final int aZ, + final int aSide, + final float hitX, + final float hitY, + final float hitZ) { + if (aWorld.isRemote) { + return false; + } + final Block aBlock = aWorld.getBlock(aX, aY, aZ); + if (aBlock == null) { + return false; + } + final byte aMeta = (byte) aWorld.getBlockMetadata(aX, aY, aZ); + final byte aTargetSide = GT_Utility.determineWrenchingSide((byte) aSide, hitX, hitY, hitZ); + final TileEntity aTileEntity = aWorld.getTileEntity(aX, aY, aZ); + /*try { + if ((aTileEntity != null) && ((aTileEntity instanceof IWrenchable))) { + if (((IWrenchable) aTileEntity).wrenchCanSetFacing(aPlayer, aTargetSide)) { + if ((aPlayer.capabilities.isCreativeMode) || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts))) { + ((IWrenchable) aTileEntity).setFacing(aTargetSide); + GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, aZ); + } + return true; + } + if (((IWrenchable) aTileEntity).wrenchCanRemove(aPlayer)) { + final int tDamage = ((IWrenchable) aTileEntity).getWrenchDropRate() < 1.0F ? 10 : 3; + if ((aPlayer.capabilities.isCreativeMode) || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, tDamage * this.mCosts))) { + ItemStack tOutput = ((IWrenchable) aTileEntity).getWrenchDrop(aPlayer); + for (final ItemStack tStack : aBlock.getDrops(aWorld, aX, aY, aZ, aMeta, 0)) { + if (tOutput == null) { + aWorld.spawnEntityInWorld(new EntityItem(aWorld, aX + 0.5D, aY + 0.5D, aZ + 0.5D, tStack)); + } else { + aWorld.spawnEntityInWorld(new EntityItem(aWorld, aX + 0.5D, aY + 0.5D, aZ + 0.5D, tOutput)); + tOutput = null; + } + } + aWorld.setBlockToAir(aX, aY, aZ); + GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, aZ); + } + return true; + } + return true; + } + } catch (final Throwable e) { + } + if ((aBlock == Blocks.log) || (aBlock == Blocks.log2) || (aBlock == Blocks.hay_block)) { + if ((aPlayer.capabilities.isCreativeMode) || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts))) { + aWorld.setBlockMetadataWithNotify(aX, aY, aZ, (aMeta + 4) % 12, 3); + GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, aZ); + } + return true; + } + if ((aBlock == Blocks.powered_repeater) || (aBlock == Blocks.unpowered_repeater)) { + if ((aPlayer.capabilities.isCreativeMode) || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts))) { + aWorld.setBlockMetadataWithNotify(aX, aY, aZ, ((aMeta / 4) * 4) + (((aMeta % 4) + 1) % 4), 3); + GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, aZ); + } + return true; + } + if ((aBlock == Blocks.powered_comparator) || (aBlock == Blocks.unpowered_comparator)) { + if ((aPlayer.capabilities.isCreativeMode) || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts))) { + aWorld.setBlockMetadataWithNotify(aX, aY, aZ, ((aMeta / 4) * 4) + (((aMeta % 4) + 1) % 4), 3); + GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, aZ); + } + return true; + } + if ((aBlock == Blocks.crafting_table) || (aBlock == Blocks.bookshelf)) { + if ((aPlayer.capabilities.isCreativeMode) || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts))) { + aWorld.spawnEntityInWorld(new EntityItem(aWorld, aX + 0.5D, aY + 0.5D, aZ + 0.5D, new ItemStack(aBlock, 1, aMeta))); + aWorld.setBlockToAir(aX, aY, aZ); + GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, aZ); + } + return true; + } + if (aMeta == aTargetSide) { + if ((aBlock == Blocks.pumpkin) || (aBlock == Blocks.lit_pumpkin) || (aBlock == Blocks.piston) || (aBlock == Blocks.sticky_piston) || (aBlock == Blocks.dispenser) || (aBlock == Blocks.dropper) || (aBlock == Blocks.furnace) || (aBlock == Blocks.lit_furnace) || (aBlock == Blocks.chest) || (aBlock == Blocks.trapped_chest) || (aBlock == Blocks.ender_chest) || (aBlock == Blocks.hopper)) { + if ((aPlayer.capabilities.isCreativeMode) || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts))) { + aWorld.spawnEntityInWorld(new EntityItem(aWorld, aX + 0.5D, aY + 0.5D, aZ + 0.5D, new ItemStack(aBlock, 1, 0))); + aWorld.setBlockToAir(aX, aY, aZ); + GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, aZ); + } + return true; + } + } else { + if ((aBlock == Blocks.piston) || (aBlock == Blocks.sticky_piston) || (aBlock == Blocks.dispenser) || (aBlock == Blocks.dropper)) { + if ((aMeta < 6) && ((aPlayer.capabilities.isCreativeMode) || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts)))) { + aWorld.setBlockMetadataWithNotify(aX, aY, aZ, aTargetSide, 3); + GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, aZ); + } + return true; + } + if ((aBlock == Blocks.pumpkin) || (aBlock == Blocks.lit_pumpkin) || (aBlock == Blocks.furnace) || (aBlock == Blocks.lit_furnace) || (aBlock == Blocks.chest) || (aBlock == Blocks.ender_chest) || (aBlock == Blocks.trapped_chest)) { + if ((aTargetSide > 1) && ((aPlayer.capabilities.isCreativeMode) || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts)))) { + aWorld.setBlockMetadataWithNotify(aX, aY, aZ, aTargetSide, 3); + GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, aZ); + } + return true; + } + if (aBlock == Blocks.hopper) { + if ((aTargetSide != 1) && ((aPlayer.capabilities.isCreativeMode) || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts)))) { + aWorld.setBlockMetadataWithNotify(aX, aY, aZ, aTargetSide, 3); + GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, aZ); + } + return true; + } + } + if ((Arrays.asList(aBlock.getValidRotations(aWorld, aX, aY, aZ)).contains(ForgeDirection.getOrientation(aTargetSide))) && + ((aPlayer.capabilities.isCreativeMode) || (!GT_ModHandler.isElectricItem(aStack)) || (GT_ModHandler.canUseElectricItem(aStack, this.mCosts))) && + (aBlock.rotateBlock(aWorld, aX, aY, aZ, ForgeDirection.getOrientation(aTargetSide)))) { + if (!aPlayer.capabilities.isCreativeMode) { + ((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts); + } + GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, aZ); + }*/ + return false; + } - public List<String> getAdditionalToolTips(final GT_MetaBase_Item aItem, final List<String> aList, final ItemStack aStack) { - aList.add(this.mTooltip); - return aList; - } + public List<String> getAdditionalToolTips( + final GT_MetaBase_Item aItem, final List<String> aList, final ItemStack aStack) { + aList.add(this.mTooltip); + return aList; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/items/types/ToolType_Wrench.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/items/types/ToolType_Wrench.java index d0ef6a535c..6c12663bb6 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/items/types/ToolType_Wrench.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/items/types/ToolType_Wrench.java @@ -1,8 +1,14 @@ package gtPlusPlus.xmod.gregtech.api.items.types; +import gregtech.api.GregTech_API; +import gregtech.api.items.GT_MetaBase_Item; +import gregtech.api.items.GT_MetaGenerated_Tool; +import gregtech.api.util.GT_LanguageManager; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Utility; +import ic2.api.tile.IWrenchable; import java.util.Arrays; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; @@ -10,141 +16,195 @@ import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; - -import gregtech.api.GregTech_API; -import gregtech.api.items.GT_MetaBase_Item; -import gregtech.api.items.GT_MetaGenerated_Tool; -import gregtech.api.util.GT_LanguageManager; -import gregtech.api.util.GT_ModHandler; -import gregtech.api.util.GT_Utility; - -import ic2.api.tile.IWrenchable; import net.minecraftforge.common.util.ForgeDirection; -public class ToolType_Wrench -extends ToolType_Base { - private final int mCosts; - private final String mTooltip = GT_LanguageManager.addStringLocalization("gt.behaviour.wrench", "Rotates Blocks on Rightclick"); +public class ToolType_Wrench extends ToolType_Base { + private final int mCosts; + private final String mTooltip = + GT_LanguageManager.addStringLocalization("gt.behaviour.wrench", "Rotates Blocks on Rightclick"); - public ToolType_Wrench(final int aCosts) { - this.mCosts = aCosts; - } + public ToolType_Wrench(final int aCosts) { + this.mCosts = aCosts; + } - public boolean onItemUseFirst(final GT_MetaBase_Item aItem, final ItemStack aStack, final EntityPlayer aPlayer, final World aWorld, final int aX, final int aY, final int aZ, final int aSide, final float hitX, final float hitY, final float hitZ) { - if (aWorld.isRemote) { - return false; - } - final Block aBlock = aWorld.getBlock(aX, aY, aZ); - if (aBlock == null) { - return false; - } - final byte aMeta = (byte) aWorld.getBlockMetadata(aX, aY, aZ); - final byte aTargetSide = GT_Utility.determineWrenchingSide((byte) aSide, hitX, hitY, hitZ); - final TileEntity aTileEntity = aWorld.getTileEntity(aX, aY, aZ); - try { - if ((aTileEntity != null) && ((aTileEntity instanceof IWrenchable))) { - if (((IWrenchable) aTileEntity).wrenchCanSetFacing(aPlayer, aTargetSide)) { - if ((aPlayer.capabilities.isCreativeMode) || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts))) { - ((IWrenchable) aTileEntity).setFacing(aTargetSide); - GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, aZ); - } - return true; - } - if (((IWrenchable) aTileEntity).wrenchCanRemove(aPlayer)) { - final int tDamage = ((IWrenchable) aTileEntity).getWrenchDropRate() < 1.0F ? 10 : 3; - if ((aPlayer.capabilities.isCreativeMode) || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, tDamage * this.mCosts))) { - ItemStack tOutput = ((IWrenchable) aTileEntity).getWrenchDrop(aPlayer); - for (final ItemStack tStack : aBlock.getDrops(aWorld, aX, aY, aZ, aMeta, 0)) { - if (tOutput == null) { - aWorld.spawnEntityInWorld(new EntityItem(aWorld, aX + 0.5D, aY + 0.5D, aZ + 0.5D, tStack)); - } else { - aWorld.spawnEntityInWorld(new EntityItem(aWorld, aX + 0.5D, aY + 0.5D, aZ + 0.5D, tOutput)); - tOutput = null; - } - } - aWorld.setBlockToAir(aX, aY, aZ); - GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, aZ); - } - return true; - } - return true; - } - } catch (final Throwable e) { - } - if ((aBlock == Blocks.log) || (aBlock == Blocks.log2) || (aBlock == Blocks.hay_block)) { - if ((aPlayer.capabilities.isCreativeMode) || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts))) { - aWorld.setBlockMetadataWithNotify(aX, aY, aZ, (aMeta + 4) % 12, 3); - GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, aZ); - } - return true; - } - if ((aBlock == Blocks.powered_repeater) || (aBlock == Blocks.unpowered_repeater)) { - if ((aPlayer.capabilities.isCreativeMode) || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts))) { - aWorld.setBlockMetadataWithNotify(aX, aY, aZ, ((aMeta / 4) * 4) + (((aMeta % 4) + 1) % 4), 3); - GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, aZ); - } - return true; - } - if ((aBlock == Blocks.powered_comparator) || (aBlock == Blocks.unpowered_comparator)) { - if ((aPlayer.capabilities.isCreativeMode) || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts))) { - aWorld.setBlockMetadataWithNotify(aX, aY, aZ, ((aMeta / 4) * 4) + (((aMeta % 4) + 1) % 4), 3); - GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, aZ); - } - return true; - } - if ((aBlock == Blocks.crafting_table) || (aBlock == Blocks.bookshelf)) { - if ((aPlayer.capabilities.isCreativeMode) || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts))) { - aWorld.spawnEntityInWorld(new EntityItem(aWorld, aX + 0.5D, aY + 0.5D, aZ + 0.5D, new ItemStack(aBlock, 1, aMeta))); - aWorld.setBlockToAir(aX, aY, aZ); - GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, aZ); - } - return true; - } - if (aMeta == aTargetSide) { - if ((aBlock == Blocks.pumpkin) || (aBlock == Blocks.lit_pumpkin) || (aBlock == Blocks.piston) || (aBlock == Blocks.sticky_piston) || (aBlock == Blocks.dispenser) || (aBlock == Blocks.dropper) || (aBlock == Blocks.furnace) || (aBlock == Blocks.lit_furnace) || (aBlock == Blocks.chest) || (aBlock == Blocks.trapped_chest) || (aBlock == Blocks.ender_chest) || (aBlock == Blocks.hopper)) { - if ((aPlayer.capabilities.isCreativeMode) || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts))) { - aWorld.spawnEntityInWorld(new EntityItem(aWorld, aX + 0.5D, aY + 0.5D, aZ + 0.5D, new ItemStack(aBlock, 1, 0))); - aWorld.setBlockToAir(aX, aY, aZ); - GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, aZ); - } - return true; - } - } else { - if ((aBlock == Blocks.piston) || (aBlock == Blocks.sticky_piston) || (aBlock == Blocks.dispenser) || (aBlock == Blocks.dropper)) { - if ((aMeta < 6) && ((aPlayer.capabilities.isCreativeMode) || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts)))) { - aWorld.setBlockMetadataWithNotify(aX, aY, aZ, aTargetSide, 3); - GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, aZ); - } - return true; - } - if ((aBlock == Blocks.pumpkin) || (aBlock == Blocks.lit_pumpkin) || (aBlock == Blocks.furnace) || (aBlock == Blocks.lit_furnace) || (aBlock == Blocks.chest) || (aBlock == Blocks.ender_chest) || (aBlock == Blocks.trapped_chest)) { - if ((aTargetSide > 1) && ((aPlayer.capabilities.isCreativeMode) || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts)))) { - aWorld.setBlockMetadataWithNotify(aX, aY, aZ, aTargetSide, 3); - GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, aZ); - } - return true; - } - if (aBlock == Blocks.hopper) { - if ((aTargetSide != 1) && ((aPlayer.capabilities.isCreativeMode) || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts)))) { - aWorld.setBlockMetadataWithNotify(aX, aY, aZ, aTargetSide, 3); - GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, aZ); - } - return true; - } - } - if ((Arrays.asList(aBlock.getValidRotations(aWorld, aX, aY, aZ)).contains(ForgeDirection.getOrientation(aTargetSide))) && - ((aPlayer.capabilities.isCreativeMode) || (!GT_ModHandler.isElectricItem(aStack)) || (GT_ModHandler.canUseElectricItem(aStack, this.mCosts))) && - (aBlock.rotateBlock(aWorld, aX, aY, aZ, ForgeDirection.getOrientation(aTargetSide)))) { - if (!aPlayer.capabilities.isCreativeMode) { - ((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts); - } - GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, aZ); - } - return false; - } + public boolean onItemUseFirst( + final GT_MetaBase_Item aItem, + final ItemStack aStack, + final EntityPlayer aPlayer, + final World aWorld, + final int aX, + final int aY, + final int aZ, + final int aSide, + final float hitX, + final float hitY, + final float hitZ) { + if (aWorld.isRemote) { + return false; + } + final Block aBlock = aWorld.getBlock(aX, aY, aZ); + if (aBlock == null) { + return false; + } + final byte aMeta = (byte) aWorld.getBlockMetadata(aX, aY, aZ); + final byte aTargetSide = GT_Utility.determineWrenchingSide((byte) aSide, hitX, hitY, hitZ); + final TileEntity aTileEntity = aWorld.getTileEntity(aX, aY, aZ); + try { + if ((aTileEntity != null) && ((aTileEntity instanceof IWrenchable))) { + if (((IWrenchable) aTileEntity).wrenchCanSetFacing(aPlayer, aTargetSide)) { + if ((aPlayer.capabilities.isCreativeMode) + || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts))) { + ((IWrenchable) aTileEntity).setFacing(aTargetSide); + GT_Utility.sendSoundToPlayers( + aWorld, GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, aZ); + } + return true; + } + if (((IWrenchable) aTileEntity).wrenchCanRemove(aPlayer)) { + final int tDamage = ((IWrenchable) aTileEntity).getWrenchDropRate() < 1.0F ? 10 : 3; + if ((aPlayer.capabilities.isCreativeMode) + || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, tDamage * this.mCosts))) { + ItemStack tOutput = ((IWrenchable) aTileEntity).getWrenchDrop(aPlayer); + for (final ItemStack tStack : aBlock.getDrops(aWorld, aX, aY, aZ, aMeta, 0)) { + if (tOutput == null) { + aWorld.spawnEntityInWorld( + new EntityItem(aWorld, aX + 0.5D, aY + 0.5D, aZ + 0.5D, tStack)); + } else { + aWorld.spawnEntityInWorld( + new EntityItem(aWorld, aX + 0.5D, aY + 0.5D, aZ + 0.5D, tOutput)); + tOutput = null; + } + } + aWorld.setBlockToAir(aX, aY, aZ); + GT_Utility.sendSoundToPlayers( + aWorld, GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, aZ); + } + return true; + } + return true; + } + } catch (final Throwable e) { + } + if ((aBlock == Blocks.log) || (aBlock == Blocks.log2) || (aBlock == Blocks.hay_block)) { + if ((aPlayer.capabilities.isCreativeMode) + || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts))) { + aWorld.setBlockMetadataWithNotify(aX, aY, aZ, (aMeta + 4) % 12, 3); + GT_Utility.sendSoundToPlayers( + aWorld, GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, aZ); + } + return true; + } + if ((aBlock == Blocks.powered_repeater) || (aBlock == Blocks.unpowered_repeater)) { + if ((aPlayer.capabilities.isCreativeMode) + || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts))) { + aWorld.setBlockMetadataWithNotify(aX, aY, aZ, ((aMeta / 4) * 4) + (((aMeta % 4) + 1) % 4), 3); + GT_Utility.sendSoundToPlayers( + aWorld, GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, aZ); + } + return true; + } + if ((aBlock == Blocks.powered_comparator) || (aBlock == Blocks.unpowered_comparator)) { + if ((aPlayer.capabilities.isCreativeMode) + || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts))) { + aWorld.setBlockMetadataWithNotify(aX, aY, aZ, ((aMeta / 4) * 4) + (((aMeta % 4) + 1) % 4), 3); + GT_Utility.sendSoundToPlayers( + aWorld, GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, aZ); + } + return true; + } + if ((aBlock == Blocks.crafting_table) || (aBlock == Blocks.bookshelf)) { + if ((aPlayer.capabilities.isCreativeMode) + || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts))) { + aWorld.spawnEntityInWorld( + new EntityItem(aWorld, aX + 0.5D, aY + 0.5D, aZ + 0.5D, new ItemStack(aBlock, 1, aMeta))); + aWorld.setBlockToAir(aX, aY, aZ); + GT_Utility.sendSoundToPlayers( + aWorld, GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, aZ); + } + return true; + } + if (aMeta == aTargetSide) { + if ((aBlock == Blocks.pumpkin) + || (aBlock == Blocks.lit_pumpkin) + || (aBlock == Blocks.piston) + || (aBlock == Blocks.sticky_piston) + || (aBlock == Blocks.dispenser) + || (aBlock == Blocks.dropper) + || (aBlock == Blocks.furnace) + || (aBlock == Blocks.lit_furnace) + || (aBlock == Blocks.chest) + || (aBlock == Blocks.trapped_chest) + || (aBlock == Blocks.ender_chest) + || (aBlock == Blocks.hopper)) { + if ((aPlayer.capabilities.isCreativeMode) + || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts))) { + aWorld.spawnEntityInWorld( + new EntityItem(aWorld, aX + 0.5D, aY + 0.5D, aZ + 0.5D, new ItemStack(aBlock, 1, 0))); + aWorld.setBlockToAir(aX, aY, aZ); + GT_Utility.sendSoundToPlayers( + aWorld, GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, aZ); + } + return true; + } + } else { + if ((aBlock == Blocks.piston) + || (aBlock == Blocks.sticky_piston) + || (aBlock == Blocks.dispenser) + || (aBlock == Blocks.dropper)) { + if ((aMeta < 6) + && ((aPlayer.capabilities.isCreativeMode) + || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts)))) { + aWorld.setBlockMetadataWithNotify(aX, aY, aZ, aTargetSide, 3); + GT_Utility.sendSoundToPlayers( + aWorld, GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, aZ); + } + return true; + } + if ((aBlock == Blocks.pumpkin) + || (aBlock == Blocks.lit_pumpkin) + || (aBlock == Blocks.furnace) + || (aBlock == Blocks.lit_furnace) + || (aBlock == Blocks.chest) + || (aBlock == Blocks.ender_chest) + || (aBlock == Blocks.trapped_chest)) { + if ((aTargetSide > 1) + && ((aPlayer.capabilities.isCreativeMode) + || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts)))) { + aWorld.setBlockMetadataWithNotify(aX, aY, aZ, aTargetSide, 3); + GT_Utility.sendSoundToPlayers( + aWorld, GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, aZ); + } + return true; + } + if (aBlock == Blocks.hopper) { + if ((aTargetSide != 1) + && ((aPlayer.capabilities.isCreativeMode) + || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts)))) { + aWorld.setBlockMetadataWithNotify(aX, aY, aZ, aTargetSide, 3); + GT_Utility.sendSoundToPlayers( + aWorld, GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, aZ); + } + return true; + } + } + if ((Arrays.asList(aBlock.getValidRotations(aWorld, aX, aY, aZ)) + .contains(ForgeDirection.getOrientation(aTargetSide))) + && ((aPlayer.capabilities.isCreativeMode) + || (!GT_ModHandler.isElectricItem(aStack)) + || (GT_ModHandler.canUseElectricItem(aStack, this.mCosts))) + && (aBlock.rotateBlock(aWorld, aX, aY, aZ, ForgeDirection.getOrientation(aTargetSide)))) { + if (!aPlayer.capabilities.isCreativeMode) { + ((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts); + } + GT_Utility.sendSoundToPlayers( + aWorld, GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, aZ); + } + return false; + } - public List<String> getAdditionalToolTips(final GT_MetaBase_Item aItem, final List<String> aList, final ItemStack aStack) { - aList.add(this.mTooltip); - return aList; - } + public List<String> getAdditionalToolTips( + final GT_MetaBase_Item aItem, final List<String> aList, final ItemStack aStack) { + aList.add(this.mTooltip); + return aList; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/BaseCustomTileEntity.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/BaseCustomTileEntity.java index 5ccbd8cb2d..a88105f7f6 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/BaseCustomTileEntity.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/BaseCustomTileEntity.java @@ -1,10 +1,5 @@ package gtPlusPlus.xmod.gregtech.api.metatileentity; -import java.lang.reflect.Field; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Random; - import gregtech.GT_Mod; import gregtech.api.GregTech_API; import gregtech.api.enums.GT_Values; @@ -12,201 +7,202 @@ import gregtech.api.metatileentity.BaseMetaTileEntity; import gregtech.api.util.GT_Log; import gregtech.api.util.GT_Utility; import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils; import gtPlusPlus.xmod.gregtech.api.interfaces.IBaseCustomMetaTileEntity; -import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy; import gtPlusPlus.xmod.gregtech.common.StaticFields59; import ic2.api.Direction; +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.Random; import net.minecraft.entity.item.EntityItem; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; public class BaseCustomTileEntity extends BaseMetaTileEntity implements IBaseCustomMetaTileEntity { - - protected NBTTagCompound mRecipeStuff2; - private static final Field ENTITY_ITEM_HEALTH_FIELD_2; - - static { - Field f = null; - try { - f = EntityItem.class.getDeclaredField("field_70291_e"); - f.setAccessible(true); - } catch (Exception var4) { - try { - f = EntityItem.class.getDeclaredField("health"); - f.setAccessible(true); - } catch (Exception var3) { - var4.printStackTrace(); - var3.printStackTrace(); - } - } - - ENTITY_ITEM_HEALTH_FIELD_2 = f; - } - - public BaseCustomTileEntity() { - super(); - Logger.MACHINE_INFO("Created new BaseCustomTileEntity"); - } - - public boolean doesExplode() { - return true; - } - - public void writeToNBT(NBTTagCompound aNBT) { - try { - super.writeToNBT(aNBT); - } catch (Throwable arg7) { - GT_Log.err.println( - "Encountered CRITICAL ERROR while saving MetaTileEntity, the Chunk whould\'ve been corrupted by now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!"); - arg7.printStackTrace(GT_Log.err); - } - - try { - if (!aNBT.hasKey("ModVersion")) - aNBT.setString("ModVersion", CORE.VERSION); - } catch (Throwable arg6) { - GT_Log.err.println( - "Encountered CRITICAL ERROR while saving MetaTileEntity, the Chunk whould\'ve been corrupted by now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!"); - arg6.printStackTrace(GT_Log.err); - } - } - - public void doEnergyExplosion() { - if (!doesExplode()) { - Logger.INFO("Machine tried to explode, let's stop that. xo [doEnergyExplosion]"); - return; - } - if (this.getUniversalEnergyCapacity() > 0L - && this.getUniversalEnergyStored() >= this.getUniversalEnergyCapacity() / 5L) { - this.doExplosion( - this.getOutput() * (long) (this.getUniversalEnergyStored() >= this.getUniversalEnergyCapacity() ? 4 - : (this.getUniversalEnergyStored() >= this.getUniversalEnergyCapacity() / 2L ? 2 : 1))); - GT_Mod arg9999 = GT_Mod.instance; - GT_Mod.achievements.issueAchievement(this.getWorldObj().getPlayerEntityByName(this.getOwnerName()), - "electricproblems"); - } - - } - - public void doExplosion(long aAmount) { - - if (!doesExplode()) { - Logger.INFO("Machine tried to explode, let's stop that. xo [doExplosion]"); - return; - } - - if (this.canAccessData()) { - if (GregTech_API.sMachineWireFire && this.mMetaTileEntity.isElectric()) { - try { - this.mReleaseEnergy = true; - Util.emitEnergyToNetwork(GT_Values.V[5], Math.max(1L, this.getStoredEU() / GT_Values.V[5]), this); - } catch (Exception arg4) { - ; - } - } - - this.mReleaseEnergy = false; - this.mMetaTileEntity.onExplosion(); - int i; - - boolean aExplosionDropItem = false; - Object aProxyField = StaticFields59.getFieldFromGregtechProxy(false, "mExplosionItemDrop"); - if (boolean.class.isInstance(aProxyField) || Boolean.class.isInstance(aProxyField)) { - aExplosionDropItem = (boolean) aProxyField; - } - - if (aExplosionDropItem) { - for (i = 0; i < this.getSizeInventory(); ++i) { - ItemStack tItem = this.getStackInSlot(i); - if (tItem != null && tItem.stackSize > 0 && this.isValidSlot(i)) { - this.dropItems(tItem); - this.setInventorySlotContents(i, (ItemStack) null); - } - } - } - - if (this.mRecipeStuff2 != null) { - for (i = 0; i < 9; ++i) { - this.dropItems(GT_Utility.loadItem(this.mRecipeStuff2, "Ingredient." + i)); - } - } - - PollutionUtils.addPollution(this, 100000); - this.mMetaTileEntity.doExplosion(aAmount); - } - - } - - - public void dropItems(ItemStack tItem) { - if (tItem != null) { - Random tRandom = new Random(); - EntityItem tItemEntity = new EntityItem(this.worldObj, - (double) ((float) this.xCoord + tRandom.nextFloat() * 0.8F + 0.1F), - (double) ((float) this.yCoord + tRandom.nextFloat() * 0.8F + 0.1F), - (double) ((float) this.zCoord + tRandom.nextFloat() * 0.8F + 0.1F), - new ItemStack(tItem.getItem(), tItem.stackSize, tItem.getItemDamage())); - if (tItem.hasTagCompound()) { - tItemEntity.getEntityItem().setTagCompound((NBTTagCompound) tItem.getTagCompound().copy()); - } - - tItemEntity.motionX = tRandom.nextGaussian() * 0.0500000007450581D; - tItemEntity.motionY = tRandom.nextGaussian() * 0.0500000007450581D + 0.2000000029802322D; - tItemEntity.motionZ = tRandom.nextGaussian() * 0.0500000007450581D; - tItemEntity.hurtResistantTime = 999999; - tItemEntity.lifespan = 60000; - - try { - if (ENTITY_ITEM_HEALTH_FIELD_2 != null) { - ENTITY_ITEM_HEALTH_FIELD_2.setInt(tItemEntity, 99999999); - } - } catch (Exception var5) { - ; - } - - this.worldObj.spawnEntityInWorld(tItemEntity); - tItem.stackSize = 0; - } - } - - public ArrayList<ItemStack> getDrops() { - ArrayList<ItemStack> aDrops = new ArrayList<ItemStack>(); - ItemStack rStack = new ItemStack(GregTech_API.sBlockMachines, 1, this.getMetaTileID()); - // Currently not using my custom block. - // ItemStack rStack = new ItemStack(Meta_GT_Proxy.sBlockMachines, 1, - // this.getMetaTileID()); - boolean fail = true; - - ArrayList<ItemStack> aSuperDrops = super.getDrops(); - if (aSuperDrops != null && !aSuperDrops.isEmpty()) { - ItemStack aSuperStack = super.getDrops().get(0); - if (aSuperStack != null && aSuperStack.hasTagCompound()) { - NBTTagCompound aSuperNBT = aSuperStack.getTagCompound(); - if (aSuperNBT != null && !aSuperNBT.hasNoTags()) { - NBTTagCompound tNBT = (NBTTagCompound) aSuperNBT.copy(); - if (tNBT != null && !tNBT.hasNoTags()) { - if (this.hasValidMetaTileEntity()) { - this.mMetaTileEntity.setItemNBT(tNBT); - rStack.setTagCompound(tNBT); - fail = false; - aDrops.add(rStack); - } - } - } - - } - } - if (fail) { - aDrops.add(rStack); - } - return aDrops; - } - - public boolean isTeleporterCompatible(Direction aSide) { - return this.canAccessData() && this.mMetaTileEntity.isTeleporterCompatible(); - } - -}
\ No newline at end of file + + protected NBTTagCompound mRecipeStuff2; + private static final Field ENTITY_ITEM_HEALTH_FIELD_2; + + static { + Field f = null; + try { + f = EntityItem.class.getDeclaredField("field_70291_e"); + f.setAccessible(true); + } catch (Exception var4) { + try { + f = EntityItem.class.getDeclaredField("health"); + f.setAccessible(true); + } catch (Exception var3) { + var4.printStackTrace(); + var3.printStackTrace(); + } + } + + ENTITY_ITEM_HEALTH_FIELD_2 = f; + } + + public BaseCustomTileEntity() { + super(); + Logger.MACHINE_INFO("Created new BaseCustomTileEntity"); + } + + public boolean doesExplode() { + return true; + } + + public void writeToNBT(NBTTagCompound aNBT) { + try { + super.writeToNBT(aNBT); + } catch (Throwable arg7) { + GT_Log.err.println( + "Encountered CRITICAL ERROR while saving MetaTileEntity, the Chunk whould\'ve been corrupted by now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!"); + arg7.printStackTrace(GT_Log.err); + } + + try { + if (!aNBT.hasKey("ModVersion")) aNBT.setString("ModVersion", CORE.VERSION); + } catch (Throwable arg6) { + GT_Log.err.println( + "Encountered CRITICAL ERROR while saving MetaTileEntity, the Chunk whould\'ve been corrupted by now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!"); + arg6.printStackTrace(GT_Log.err); + } + } + + public void doEnergyExplosion() { + if (!doesExplode()) { + Logger.INFO("Machine tried to explode, let's stop that. xo [doEnergyExplosion]"); + return; + } + if (this.getUniversalEnergyCapacity() > 0L + && this.getUniversalEnergyStored() >= this.getUniversalEnergyCapacity() / 5L) { + this.doExplosion(this.getOutput() + * (long) + (this.getUniversalEnergyStored() >= this.getUniversalEnergyCapacity() + ? 4 + : (this.getUniversalEnergyStored() >= this.getUniversalEnergyCapacity() / 2L + ? 2 + : 1))); + GT_Mod arg9999 = GT_Mod.instance; + GT_Mod.achievements.issueAchievement( + this.getWorldObj().getPlayerEntityByName(this.getOwnerName()), "electricproblems"); + } + } + + public void doExplosion(long aAmount) { + + if (!doesExplode()) { + Logger.INFO("Machine tried to explode, let's stop that. xo [doExplosion]"); + return; + } + + if (this.canAccessData()) { + if (GregTech_API.sMachineWireFire && this.mMetaTileEntity.isElectric()) { + try { + this.mReleaseEnergy = true; + Util.emitEnergyToNetwork(GT_Values.V[5], Math.max(1L, this.getStoredEU() / GT_Values.V[5]), this); + } catch (Exception arg4) { + ; + } + } + + this.mReleaseEnergy = false; + this.mMetaTileEntity.onExplosion(); + int i; + + boolean aExplosionDropItem = false; + Object aProxyField = StaticFields59.getFieldFromGregtechProxy(false, "mExplosionItemDrop"); + if (boolean.class.isInstance(aProxyField) || Boolean.class.isInstance(aProxyField)) { + aExplosionDropItem = (boolean) aProxyField; + } + + if (aExplosionDropItem) { + for (i = 0; i < this.getSizeInventory(); ++i) { + ItemStack tItem = this.getStackInSlot(i); + if (tItem != null && tItem.stackSize > 0 && this.isValidSlot(i)) { + this.dropItems(tItem); + this.setInventorySlotContents(i, (ItemStack) null); + } + } + } + + if (this.mRecipeStuff2 != null) { + for (i = 0; i < 9; ++i) { + this.dropItems(GT_Utility.loadItem(this.mRecipeStuff2, "Ingredient." + i)); + } + } + + PollutionUtils.addPollution(this, 100000); + this.mMetaTileEntity.doExplosion(aAmount); + } + } + + public void dropItems(ItemStack tItem) { + if (tItem != null) { + Random tRandom = new Random(); + EntityItem tItemEntity = new EntityItem( + this.worldObj, + (double) ((float) this.xCoord + tRandom.nextFloat() * 0.8F + 0.1F), + (double) ((float) this.yCoord + tRandom.nextFloat() * 0.8F + 0.1F), + (double) ((float) this.zCoord + tRandom.nextFloat() * 0.8F + 0.1F), + new ItemStack(tItem.getItem(), tItem.stackSize, tItem.getItemDamage())); + if (tItem.hasTagCompound()) { + tItemEntity.getEntityItem().setTagCompound((NBTTagCompound) + tItem.getTagCompound().copy()); + } + + tItemEntity.motionX = tRandom.nextGaussian() * 0.0500000007450581D; + tItemEntity.motionY = tRandom.nextGaussian() * 0.0500000007450581D + 0.2000000029802322D; + tItemEntity.motionZ = tRandom.nextGaussian() * 0.0500000007450581D; + tItemEntity.hurtResistantTime = 999999; + tItemEntity.lifespan = 60000; + + try { + if (ENTITY_ITEM_HEALTH_FIELD_2 != null) { + ENTITY_ITEM_HEALTH_FIELD_2.setInt(tItemEntity, 99999999); + } + } catch (Exception var5) { + ; + } + + this.worldObj.spawnEntityInWorld(tItemEntity); + tItem.stackSize = 0; + } + } + + public ArrayList<ItemStack> getDrops() { + ArrayList<ItemStack> aDrops = new ArrayList<ItemStack>(); + ItemStack rStack = new ItemStack(GregTech_API.sBlockMachines, 1, this.getMetaTileID()); + // Currently not using my custom block. + // ItemStack rStack = new ItemStack(Meta_GT_Proxy.sBlockMachines, 1, + // this.getMetaTileID()); + boolean fail = true; + + ArrayList<ItemStack> aSuperDrops = super.getDrops(); + if (aSuperDrops != null && !aSuperDrops.isEmpty()) { + ItemStack aSuperStack = super.getDrops().get(0); + if (aSuperStack != null && aSuperStack.hasTagCompound()) { + NBTTagCompound aSuperNBT = aSuperStack.getTagCompound(); + if (aSuperNBT != null && !aSuperNBT.hasNoTags()) { + NBTTagCompound tNBT = (NBTTagCompound) aSuperNBT.copy(); + if (tNBT != null && !tNBT.hasNoTags()) { + if (this.hasValidMetaTileEntity()) { + this.mMetaTileEntity.setItemNBT(tNBT); + rStack.setTagCompound(tNBT); + fail = false; + aDrops.add(rStack); + } + } + } + } + } + if (fail) { + aDrops.add(rStack); + } + return aDrops; + } + + public boolean isTeleporterCompatible(Direction aSide) { + return this.canAccessData() && this.mMetaTileEntity.isTeleporterCompatible(); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/BaseCustomPower_MTE.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/BaseCustomPower_MTE.java index d600d0baca..b3d8b8aa8c 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/BaseCustomPower_MTE.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/BaseCustomPower_MTE.java @@ -8,277 +8,283 @@ import net.minecraftforge.common.util.ForgeDirection; public class BaseCustomPower_MTE extends BaseCustomTileEntity { - public BaseCustomPower_MTE() { - super(); - Logger.INFO("Created new BaseCustomPower_MTE"); - } - - public boolean doesExplode() { - return false; - } - - public long injectEnergyUnits(byte aSide, long aVoltage, long aAmperage) { - if (mMetaTileEntity == null) { - Logger.INFO("Bad Tile"); - } - if (this.canAccessData() && this.mMetaTileEntity.isElectric() && this.inputEnergyFrom(aSide) && aAmperage > 0L - && aVoltage > 0L && this.getStoredEU() < this.getEUCapacity() - && this.mMetaTileEntity.maxAmperesIn() >= this.getInputAmperage()) { - Logger.INFO("Injecting Energy Units"); - return super.injectEnergyUnits(aSide, aVoltage, aAmperage); - } else { - Logger.INFO("canAccessData(): "+canAccessData()); - Logger.INFO("isElectric(): "+this.mMetaTileEntity.isElectric()); - Logger.INFO("InputEnergyFromSide("+aSide+"): "+this.inputEnergyFrom(aSide)); - Logger.INFO("aAmperage: "+aAmperage); - Logger.INFO("aVoltage: "+aVoltage); - Logger.INFO("this.getStoredEU() < this.getEUCapacity(): "+(this.getStoredEU() < this.getEUCapacity())); - Logger.INFO("this.mMetaTileEntity.maxAmperesIn() >= this.mAcceptedAmperes: "+(this.mMetaTileEntity.maxAmperesIn() >= this.getInputAmperage())); - Logger.INFO("this.mMetaTileEntity.maxAmperesIn(): "+(this.mMetaTileEntity.maxAmperesIn())); - Logger.INFO("this.mAcceptedAmperes: "+(this.getInputAmperage())); - return 0L; - } - } - - public boolean drainEnergyUnits(byte aSide, long aVoltage, long aAmperage) { - Logger.INFO("Draining Energy Units 4"); - if (this.canAccessData() && this.mMetaTileEntity.isElectric() && this.outputsEnergyTo(aSide) - && this.getStoredEU() - aVoltage * aAmperage >= this.mMetaTileEntity.getMinimumStoredEU()) { - if (this.decreaseStoredEU(aVoltage * aAmperage, false)) { - this.mAverageEUOutput[this.mAverageEUOutputIndex] = (int) ((long) this.mAverageEUOutput[this.mAverageEUOutputIndex] - + aVoltage * aAmperage); - return true; - } else { - return false; - } - } else { - return false; - } - } - - @Override - public boolean decreaseStoredEnergyUnits(long aEnergy, boolean aIgnoreTooLessEnergy) { - Logger.INFO("Draining Energy Units 3"); - // TODO Auto-generated method stub - return super.decreaseStoredEnergyUnits(aEnergy, aIgnoreTooLessEnergy); - } - - @Override - public boolean increaseStoredEnergyUnits(long aEnergy, boolean aIgnoreTooMuchEnergy) { - // TODO Auto-generated method stub - return super.increaseStoredEnergyUnits(aEnergy, aIgnoreTooMuchEnergy); - } - - @Override - public boolean inputEnergyFrom(byte aSide) { - // TODO Auto-generated method stub - return super.inputEnergyFrom(aSide); - } - - @Override - public boolean outputsEnergyTo(byte aSide) { - Logger.INFO("Draining Energy Units 2"); - // TODO Auto-generated method stub - return super.outputsEnergyTo(aSide); - } - - @Override - public long getOutputAmperage() { - // TODO Auto-generated method stub - return super.getOutputAmperage(); - } - - @Override - public long getOutputVoltage() { - // TODO Auto-generated method stub - return super.getOutputVoltage(); - } - - @Override - public long getInputAmperage() { - // TODO Auto-generated method stub - return super.getInputAmperage(); - } - - @Override - public long getInputVoltage() { - // TODO Auto-generated method stub - return super.getInputVoltage(); - } - - @Override - public long getUniversalEnergyStored() { - // TODO Auto-generated method stub - return super.getUniversalEnergyStored(); - } - - @Override - public long getUniversalEnergyCapacity() { - // TODO Auto-generated method stub - return super.getUniversalEnergyCapacity(); - } - - @Override - public long getStoredEU() { - // TODO Auto-generated method stub - return super.getStoredEU(); - } - - @Override - public long getEUCapacity() { - // TODO Auto-generated method stub - return super.getEUCapacity(); - } - - @Override - public boolean setStoredEU(long aEnergy) { - // TODO Auto-generated method stub - return super.setStoredEU(aEnergy); - } - - @Override - public boolean decreaseStoredEU(long aEnergy, boolean aIgnoreTooLessEnergy) { - Logger.INFO("Draining Energy Units 1"); - // TODO Auto-generated method stub - return super.decreaseStoredEU(aEnergy, aIgnoreTooLessEnergy); - } - - @Override - public boolean decreaseStoredSteam(long aEnergy, boolean aIgnoreTooLessEnergy) { - // TODO Auto-generated method stub - return super.decreaseStoredSteam(aEnergy, aIgnoreTooLessEnergy); - } - - @Override - public void doEnergyExplosion() { - // TODO Auto-generated method stub - super.doEnergyExplosion(); - } - - @Override - public void doExplosion(long aAmount) { - // TODO Auto-generated method stub - super.doExplosion(aAmount); - } - - @Override - public byte getLightValue() { - // TODO Auto-generated method stub - return super.getLightValue(); - } - - @Override - public long getAverageElectricInput() { - // TODO Auto-generated method stub - return super.getAverageElectricInput(); - } - - @Override - public long getAverageElectricOutput() { - // TODO Auto-generated method stub - return super.getAverageElectricOutput(); - } - - @Override - public double getOutputEnergyUnitsPerTick() { - // TODO Auto-generated method stub - return super.getOutputEnergyUnitsPerTick(); - } - - @Override - public double demandedEnergyUnits() { - // TODO Auto-generated method stub - return super.demandedEnergyUnits(); - } - - @Override - public double injectEnergyUnits(ForgeDirection aDirection, double aAmount) { - // TODO Auto-generated method stub - return super.injectEnergyUnits(aDirection, aAmount); - } - - @Override - public boolean acceptsEnergyFrom(TileEntity aEmitter, ForgeDirection aDirection) { - // TODO Auto-generated method stub - return super.acceptsEnergyFrom(aEmitter, aDirection); - } - - @Override - public boolean emitsEnergyTo(TileEntity aReceiver, ForgeDirection aDirection) { - // TODO Auto-generated method stub - return super.emitsEnergyTo(aReceiver, aDirection); - } - - @Override - public double getOfferedEnergy() { - // TODO Auto-generated method stub - return super.getOfferedEnergy(); - } - - @Override - public void drawEnergy(double amount) { - // TODO Auto-generated method stub - super.drawEnergy(amount); - } - - @Override - public int injectEnergy(ForgeDirection aForgeDirection, int aAmount) { - // TODO Auto-generated method stub - return super.injectEnergy(aForgeDirection, aAmount); - } - - @Override - public int addEnergy(int aEnergy) { - // TODO Auto-generated method stub - return super.addEnergy(aEnergy); - } - - @Override - public boolean isAddedToEnergyNet() { - // TODO Auto-generated method stub - return super.isAddedToEnergyNet(); - } - - @Override - public int demandsEnergy() { - // TODO Auto-generated method stub - return super.demandsEnergy(); - } - - @Override - public int getMaxSafeInput() { - // TODO Auto-generated method stub - return super.getMaxSafeInput(); - } - - @Override - public int getMaxEnergyOutput() { - // TODO Auto-generated method stub - return super.getMaxEnergyOutput(); - } - - @Override - public int injectEnergy(Direction aDirection, int aAmount) { - // TODO Auto-generated method stub - return super.injectEnergy(aDirection, aAmount); - } - - @Override - public boolean acceptsEnergyFrom(TileEntity aReceiver, Direction aDirection) { - // TODO Auto-generated method stub - return super.acceptsEnergyFrom(aReceiver, aDirection); - } - - @Override - public boolean emitsEnergyTo(TileEntity aReceiver, Direction aDirection) { - // TODO Auto-generated method stub - return super.emitsEnergyTo(aReceiver, aDirection); - } - - @Override - public boolean isUniversalEnergyStored(long aEnergyAmount) { - // TODO Auto-generated method stub - return super.isUniversalEnergyStored(aEnergyAmount); - } - + public BaseCustomPower_MTE() { + super(); + Logger.INFO("Created new BaseCustomPower_MTE"); + } + + public boolean doesExplode() { + return false; + } + + public long injectEnergyUnits(byte aSide, long aVoltage, long aAmperage) { + if (mMetaTileEntity == null) { + Logger.INFO("Bad Tile"); + } + if (this.canAccessData() + && this.mMetaTileEntity.isElectric() + && this.inputEnergyFrom(aSide) + && aAmperage > 0L + && aVoltage > 0L + && this.getStoredEU() < this.getEUCapacity() + && this.mMetaTileEntity.maxAmperesIn() >= this.getInputAmperage()) { + Logger.INFO("Injecting Energy Units"); + return super.injectEnergyUnits(aSide, aVoltage, aAmperage); + } else { + Logger.INFO("canAccessData(): " + canAccessData()); + Logger.INFO("isElectric(): " + this.mMetaTileEntity.isElectric()); + Logger.INFO("InputEnergyFromSide(" + aSide + "): " + this.inputEnergyFrom(aSide)); + Logger.INFO("aAmperage: " + aAmperage); + Logger.INFO("aVoltage: " + aVoltage); + Logger.INFO("this.getStoredEU() < this.getEUCapacity(): " + (this.getStoredEU() < this.getEUCapacity())); + Logger.INFO("this.mMetaTileEntity.maxAmperesIn() >= this.mAcceptedAmperes: " + + (this.mMetaTileEntity.maxAmperesIn() >= this.getInputAmperage())); + Logger.INFO("this.mMetaTileEntity.maxAmperesIn(): " + (this.mMetaTileEntity.maxAmperesIn())); + Logger.INFO("this.mAcceptedAmperes: " + (this.getInputAmperage())); + return 0L; + } + } + + public boolean drainEnergyUnits(byte aSide, long aVoltage, long aAmperage) { + Logger.INFO("Draining Energy Units 4"); + if (this.canAccessData() + && this.mMetaTileEntity.isElectric() + && this.outputsEnergyTo(aSide) + && this.getStoredEU() - aVoltage * aAmperage >= this.mMetaTileEntity.getMinimumStoredEU()) { + if (this.decreaseStoredEU(aVoltage * aAmperage, false)) { + this.mAverageEUOutput[this.mAverageEUOutputIndex] = + (int) ((long) this.mAverageEUOutput[this.mAverageEUOutputIndex] + aVoltage * aAmperage); + return true; + } else { + return false; + } + } else { + return false; + } + } + + @Override + public boolean decreaseStoredEnergyUnits(long aEnergy, boolean aIgnoreTooLessEnergy) { + Logger.INFO("Draining Energy Units 3"); + // TODO Auto-generated method stub + return super.decreaseStoredEnergyUnits(aEnergy, aIgnoreTooLessEnergy); + } + + @Override + public boolean increaseStoredEnergyUnits(long aEnergy, boolean aIgnoreTooMuchEnergy) { + // TODO Auto-generated method stub + return super.increaseStoredEnergyUnits(aEnergy, aIgnoreTooMuchEnergy); + } + + @Override + public boolean inputEnergyFrom(byte aSide) { + // TODO Auto-generated method stub + return super.inputEnergyFrom(aSide); + } + + @Override + public boolean outputsEnergyTo(byte aSide) { + Logger.INFO("Draining Energy Units 2"); + // TODO Auto-generated method stub + return super.outputsEnergyTo(aSide); + } + + @Override + public long getOutputAmperage() { + // TODO Auto-generated method stub + return super.getOutputAmperage(); + } + + @Override + public long getOutputVoltage() { + // TODO Auto-generated method stub + return super.getOutputVoltage(); + } + + @Override + public long getInputAmperage() { + // TODO Auto-generated method stub + return super.getInputAmperage(); + } + + @Override + public long getInputVoltage() { + // TODO Auto-generated method stub + return super.getInputVoltage(); + } + + @Override + public long getUniversalEnergyStored() { + // TODO Auto-generated method stub + return super.getUniversalEnergyStored(); + } + + @Override + public long getUniversalEnergyCapacity() { + // TODO Auto-generated method stub + return super.getUniversalEnergyCapacity(); + } + + @Override + public long getStoredEU() { + // TODO Auto-generated method stub + return super.getStoredEU(); + } + + @Override + public long getEUCapacity() { + // TODO Auto-generated method stub + return super.getEUCapacity(); + } + + @Override + public boolean setStoredEU(long aEnergy) { + // TODO Auto-generated method stub + return super.setStoredEU(aEnergy); + } + + @Override + public boolean decreaseStoredEU(long aEnergy, boolean aIgnoreTooLessEnergy) { + Logger.INFO("Draining Energy Units 1"); + // TODO Auto-generated method stub + return super.decreaseStoredEU(aEnergy, aIgnoreTooLessEnergy); + } + + @Override + public boolean decreaseStoredSteam(long aEnergy, boolean aIgnoreTooLessEnergy) { + // TODO Auto-generated method stub + return super.decreaseStoredSteam(aEnergy, aIgnoreTooLessEnergy); + } + + @Override + public void doEnergyExplosion() { + // TODO Auto-generated method stub + super.doEnergyExplosion(); + } + + @Override + public void doExplosion(long aAmount) { + // TODO Auto-generated method stub + super.doExplosion(aAmount); + } + + @Override + public byte getLightValue() { + // TODO Auto-generated method stub + return super.getLightValue(); + } + + @Override + public long getAverageElectricInput() { + // TODO Auto-generated method stub + return super.getAverageElectricInput(); + } + + @Override + public long getAverageElectricOutput() { + // TODO Auto-generated method stub + return super.getAverageElectricOutput(); + } + + @Override + public double getOutputEnergyUnitsPerTick() { + // TODO Auto-generated method stub + return super.getOutputEnergyUnitsPerTick(); + } + + @Override + public double demandedEnergyUnits() { + // TODO Auto-generated method stub + return super.demandedEnergyUnits(); + } + + @Override + public double injectEnergyUnits(ForgeDirection aDirection, double aAmount) { + // TODO Auto-generated method stub + return super.injectEnergyUnits(aDirection, aAmount); + } + + @Override + public boolean acceptsEnergyFrom(TileEntity aEmitter, ForgeDirection aDirection) { + // TODO Auto-generated method stub + return super.acceptsEnergyFrom(aEmitter, aDirection); + } + + @Override + public boolean emitsEnergyTo(TileEntity aReceiver, ForgeDirection aDirection) { + // TODO Auto-generated method stub + return super.emitsEnergyTo(aReceiver, aDirection); + } + + @Override + public double getOfferedEnergy() { + // TODO Auto-generated method stub + return super.getOfferedEnergy(); + } + + @Override + public void drawEnergy(double amount) { + // TODO Auto-generated method stub + super.drawEnergy(amount); + } + + @Override + public int injectEnergy(ForgeDirection aForgeDirection, int aAmount) { + // TODO Auto-generated method stub + return super.injectEnergy(aForgeDirection, aAmount); + } + + @Override + public int addEnergy(int aEnergy) { + // TODO Auto-generated method stub + return super.addEnergy(aEnergy); + } + + @Override + public boolean isAddedToEnergyNet() { + // TODO Auto-generated method stub + return super.isAddedToEnergyNet(); + } + + @Override + public int demandsEnergy() { + // TODO Auto-generated method stub + return super.demandsEnergy(); + } + + @Override + public int getMaxSafeInput() { + // TODO Auto-generated method stub + return super.getMaxSafeInput(); + } + + @Override + public int getMaxEnergyOutput() { + // TODO Auto-generated method stub + return super.getMaxEnergyOutput(); + } + + @Override + public int injectEnergy(Direction aDirection, int aAmount) { + // TODO Auto-generated method stub + return super.injectEnergy(aDirection, aAmount); + } + + @Override + public boolean acceptsEnergyFrom(TileEntity aReceiver, Direction aDirection) { + // TODO Auto-generated method stub + return super.acceptsEnergyFrom(aReceiver, aDirection); + } + + @Override + public boolean emitsEnergyTo(TileEntity aReceiver, Direction aDirection) { + // TODO Auto-generated method stub + return super.emitsEnergyTo(aReceiver, aDirection); + } + + @Override + public boolean isUniversalEnergyStored(long aEnergyAmount) { + // TODO Auto-generated method stub + return super.isUniversalEnergyStored(aEnergyAmount); + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_BasicLosslessGenerator.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_BasicLosslessGenerator.java index e1b329c07f..332d911ac4 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_BasicLosslessGenerator.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_BasicLosslessGenerator.java @@ -5,10 +5,10 @@ import gregtech.api.enums.Textures.BlockIcons; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gregtech.api.util.GT_Utility; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils; -import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import java.util.Collection; import java.util.Iterator; import net.minecraft.entity.player.EntityPlayer; @@ -17,297 +17,317 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; public abstract class GTPP_MTE_BasicLosslessGenerator extends GTPP_MTE_BasicTank { - public GTPP_MTE_BasicLosslessGenerator(int aID, String aName, String aNameRegional, int aTier, String aDescription, - ITexture... aTextures) { - super(aID, aName, aNameRegional, aTier, 3, aDescription, aTextures); - } - - public GTPP_MTE_BasicLosslessGenerator(int aID, String aName, String aNameRegional, int aTier, - String[] aDescription, ITexture... aTextures) { - super(aID, aName, aNameRegional, aTier, 3, aDescription, aTextures); - } - - public GTPP_MTE_BasicLosslessGenerator(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { - super(aName, aTier, 3, aDescription, aTextures); - } - - public GTPP_MTE_BasicLosslessGenerator(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { - super(aName, aTier, 3, aDescription, aTextures); - } - - public ITexture[][][] getTextureSet(ITexture[] aTextures) { - ITexture[][][] rTextures = new ITexture[10][17][]; - - for (byte i = -1; i < 16; ++i) { - rTextures[0][i + 1] = this.getFront(i); - rTextures[1][i + 1] = this.getBack(i); - rTextures[2][i + 1] = this.getBottom(i); - rTextures[3][i + 1] = this.getTop(i); - rTextures[4][i + 1] = this.getSides(i); - rTextures[5][i + 1] = this.getFrontActive(i); - rTextures[6][i + 1] = this.getBackActive(i); - rTextures[7][i + 1] = this.getBottomActive(i); - rTextures[8][i + 1] = this.getTopActive(i); - rTextures[9][i + 1] = this.getSidesActive(i); - } - - return rTextures; - } - - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, - boolean aActive, boolean aRedstone) { - return this.mTextures[(aActive ? 5 : 0) + (aSide == aFacing - ? 0 - : (aSide == GT_Utility.getOppositeSide(aFacing) - ? 1 - : (aSide == 0 ? 2 : (aSide == 1 ? 3 : 4))))][aColorIndex + 1]; - } - - public String[] getDescription() { - String[] desc = new String[this.mDescriptionArray.length + 1]; - System.arraycopy(this.mDescriptionArray, 0, desc, 0, this.mDescriptionArray.length); - desc[this.mDescriptionArray.length] = "Fuel Efficiency: " + this.getEfficiency() + "%"; - return desc; - } - - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { - Logger.WARNING("Right Clicked"); - if (aBaseMetaTileEntity.isClientSide()) { - return true; - } else { - aBaseMetaTileEntity.openGUI(aPlayer); - return true; - } - } - - public ITexture[] getFront(byte aColor) { - return new ITexture[]{BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]}; - } - - public ITexture[] getBack(byte aColor) { - return new ITexture[]{BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]}; - } - - public ITexture[] getBottom(byte aColor) { - return new ITexture[]{BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]}; - } - - public ITexture[] getTop(byte aColor) { - return new ITexture[]{BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]}; - } - - public ITexture[] getSides(byte aColor) { - return new ITexture[]{BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]}; - } - - public ITexture[] getFrontActive(byte aColor) { - return this.getFront(aColor); - } - - public ITexture[] getBackActive(byte aColor) { - return this.getBack(aColor); - } - - public ITexture[] getBottomActive(byte aColor) { - return this.getBottom(aColor); - } - - public ITexture[] getTopActive(byte aColor) { - return this.getTop(aColor); - } - - public ITexture[] getSidesActive(byte aColor) { - return this.getSides(aColor); - } - - public boolean isFacingValid(byte aSide) { - return aSide > 1; - } - - public boolean isSimpleMachine() { - return false; - } - - public boolean isValidSlot(int aIndex) { - return aIndex < 2; - } - - public boolean isEnetOutput() { - return true; - } - - public boolean isOutputFacing(byte aSide) { - return true; - } - - public boolean isAccessAllowed(EntityPlayer aPlayer) { - return true; - } - - public long maxEUOutput() { - return this.getBaseMetaTileEntity().isAllowedToWork() ? GT_Values.V[this.mTier] : 0L; - } - - public long maxEUStore() { - return Math.max(this.getEUVar(), GT_Values.V[this.mTier] * 40L + this.getMinimumStoredEU()); - } - - public boolean doesFillContainers() { - return this.getBaseMetaTileEntity().isAllowedToWork(); - } - - public boolean doesEmptyContainers() { - return this.getBaseMetaTileEntity().isAllowedToWork(); - } - - public boolean canTankBeFilled() { - return this.getBaseMetaTileEntity().isAllowedToWork(); - } - - public boolean canTankBeEmptied() { - return this.getBaseMetaTileEntity().isAllowedToWork(); - } - - public boolean displaysItemStack() { - return true; - } - - public boolean displaysStackSize() { - return false; - } - - public boolean isFluidInputAllowed(FluidStack aFluid) { - int aVal = this.getFuelValue(aFluid); - Logger.WARNING("Fuel Value: "+aVal); - return aVal > 0; - } - - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.isAllowedToWork() && aTick % 10L == 0L) { - int tFuelValue; - if (this.mFluid == null) { - if (aBaseMetaTileEntity.getUniversalEnergyStored() < this.maxEUOutput() + this.getMinimumStoredEU()) { - this.mInventory[this.getStackDisplaySlot()] = null; - } else { - if (this.mInventory[this.getStackDisplaySlot()] == null) { - this.mInventory[this.getStackDisplaySlot()] = new ItemStack(Blocks.fire, 1); - } - - this.mInventory[this.getStackDisplaySlot()].setStackDisplayName("Generating: " - + (aBaseMetaTileEntity.getUniversalEnergyStored() - this.getMinimumStoredEU()) + " EU"); - } - } else { - tFuelValue = this.getFuelValue(this.mFluid); - int tConsumed = this.consumedFluidPerOperation(this.mFluid); - if (tFuelValue > 0 && tConsumed > 0 && this.mFluid.amount > tConsumed) { - long tFluidAmountToUse = Math.min((long) (this.mFluid.amount / tConsumed), - (this.maxEUStore() - aBaseMetaTileEntity.getUniversalEnergyStored()) / (long) tFuelValue); - if (tFluidAmountToUse > 0L && aBaseMetaTileEntity - .increaseStoredEnergyUnits(tFluidAmountToUse * (long) tFuelValue, true)) { - PollutionUtils.addPollution(this.getBaseMetaTileEntity(), 10 * this.getPollution()); - this.mFluid.amount = (int) ((long) this.mFluid.amount - tFluidAmountToUse * (long) tConsumed); - } - } - } - - if (this.mInventory[this.getInputSlot()] != null - && aBaseMetaTileEntity.getUniversalEnergyStored() < this.maxEUOutput() * 20L - + this.getMinimumStoredEU() - && GT_Utility.getFluidForFilledItem(this.mInventory[this.getInputSlot()], true) == null) { - tFuelValue = this.getFuelValue(this.mInventory[this.getInputSlot()]); - if (tFuelValue > 0) { - ItemStack tEmptyContainer = this.getEmptyContainer(this.mInventory[this.getInputSlot()]); - if (aBaseMetaTileEntity.addStackToSlot(this.getOutputSlot(), tEmptyContainer)) { - aBaseMetaTileEntity.increaseStoredEnergyUnits((long) tFuelValue, true); - aBaseMetaTileEntity.decrStackSize(this.getInputSlot(), 1); - PollutionUtils.addPollution(this.getBaseMetaTileEntity(), 10 * this.getPollution()); - } - } - } - } - - if (aBaseMetaTileEntity.isServerSide()) { - Logger.WARNING("Ticking Servside"); - aBaseMetaTileEntity.setActive(aBaseMetaTileEntity.isAllowedToWork() && aBaseMetaTileEntity - .getUniversalEnergyStored() >= this.maxEUOutput() + this.getMinimumStoredEU()); - } - - } - - public abstract int getPollution(); - - public abstract GT_Recipe_Map getRecipes(); - - public abstract int getEfficiency(); - - public int consumedFluidPerOperation(FluidStack aLiquid) { - return 1; - } - - public int getFuelValue(FluidStack aLiquid) { - if (aLiquid != null && this.getRecipes() != null) { - Collection<GT_Recipe> tRecipeList = this.getRecipes().mRecipeList; - if (tRecipeList != null) { - Logger.WARNING("Fuels: "+tRecipeList.size()); - Iterator<GT_Recipe> var4 = tRecipeList.iterator(); - - while (var4.hasNext()) { - GT_Recipe tFuel = (GT_Recipe) var4.next(); - FluidStack tLiquid; - if ((tLiquid = GT_Utility.getFluidForFilledItem(tFuel.getRepresentativeInput(0), true)) != null - && aLiquid.isFluidEqual(tLiquid)) { - Logger.WARNING("Fuel Ok"); - return (int) ((long) tFuel.mSpecialValue * (long) this.getEfficiency() - * (long) this.consumedFluidPerOperation(tLiquid) / 100L); - } - if ((tLiquid = tFuel.getRepresentativeFluidInput(0)) != null - && aLiquid.isFluidEqual(tLiquid)) { - Logger.WARNING("Fuel Ok"); - return (int) ((long) tFuel.mSpecialValue * (long) this.getEfficiency() - * (long) this.consumedFluidPerOperation(tLiquid) / 100L); - } - } - } - - return 0; - } else { - return 0; - } - } - - public int getFuelValue(ItemStack aStack) { - if (!GT_Utility.isStackInvalid(aStack) && this.getRecipes() != null) { - Logger.WARNING("Fuel Item OK"); - GT_Recipe tFuel = this.getRecipes().findRecipe(this.getBaseMetaTileEntity(), false, Long.MAX_VALUE, - (FluidStack[]) null, new ItemStack[]{aStack}); - return tFuel != null ? (int) ((long) tFuel.mSpecialValue * 1000L * (long) this.getEfficiency() / 100L) : 0; - } else { - return 0; - } - } - - public ItemStack getEmptyContainer(ItemStack aStack) { - if (!GT_Utility.isStackInvalid(aStack) && this.getRecipes() != null) { - GT_Recipe tFuel = this.getRecipes().findRecipe(this.getBaseMetaTileEntity(), false, Long.MAX_VALUE, - (FluidStack[]) null, new ItemStack[]{aStack}); - return tFuel != null - ? GT_Utility.copy(new Object[]{tFuel.getOutput(0)}) - : GT_Utility.getContainerItem(aStack, true); - } else { - return null; - } - } - - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack) && (this.getFuelValue(aStack) > 0 - || this.getFuelValue(GT_Utility.getFluidForFilledItem(aStack, true)) > 0); - } - - public int getCapacity() { - return 16000; - } - - public int getTankPressure() { - return -100; - } -}
\ No newline at end of file + public GTPP_MTE_BasicLosslessGenerator( + int aID, String aName, String aNameRegional, int aTier, String aDescription, ITexture... aTextures) { + super(aID, aName, aNameRegional, aTier, 3, aDescription, aTextures); + } + + public GTPP_MTE_BasicLosslessGenerator( + int aID, String aName, String aNameRegional, int aTier, String[] aDescription, ITexture... aTextures) { + super(aID, aName, aNameRegional, aTier, 3, aDescription, aTextures); + } + + public GTPP_MTE_BasicLosslessGenerator(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 3, aDescription, aTextures); + } + + public GTPP_MTE_BasicLosslessGenerator(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 3, aDescription, aTextures); + } + + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + ITexture[][][] rTextures = new ITexture[10][17][]; + + for (byte i = -1; i < 16; ++i) { + rTextures[0][i + 1] = this.getFront(i); + rTextures[1][i + 1] = this.getBack(i); + rTextures[2][i + 1] = this.getBottom(i); + rTextures[3][i + 1] = this.getTop(i); + rTextures[4][i + 1] = this.getSides(i); + rTextures[5][i + 1] = this.getFrontActive(i); + rTextures[6][i + 1] = this.getBackActive(i); + rTextures[7][i + 1] = this.getBottomActive(i); + rTextures[8][i + 1] = this.getTopActive(i); + rTextures[9][i + 1] = this.getSidesActive(i); + } + + return rTextures; + } + + public ITexture[] getTexture( + IGregTechTileEntity aBaseMetaTileEntity, + byte aSide, + byte aFacing, + byte aColorIndex, + boolean aActive, + boolean aRedstone) { + return this.mTextures[ + (aActive ? 5 : 0) + + (aSide == aFacing + ? 0 + : (aSide == GT_Utility.getOppositeSide(aFacing) + ? 1 + : (aSide == 0 ? 2 : (aSide == 1 ? 3 : 4))))][ + aColorIndex + 1]; + } + + public String[] getDescription() { + String[] desc = new String[this.mDescriptionArray.length + 1]; + System.arraycopy(this.mDescriptionArray, 0, desc, 0, this.mDescriptionArray.length); + desc[this.mDescriptionArray.length] = "Fuel Efficiency: " + this.getEfficiency() + "%"; + return desc; + } + + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + Logger.WARNING("Right Clicked"); + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } else { + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + } + + public ITexture[] getFront(byte aColor) { + return new ITexture[] {BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]}; + } + + public ITexture[] getBack(byte aColor) { + return new ITexture[] {BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]}; + } + + public ITexture[] getBottom(byte aColor) { + return new ITexture[] {BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]}; + } + + public ITexture[] getTop(byte aColor) { + return new ITexture[] {BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]}; + } + + public ITexture[] getSides(byte aColor) { + return new ITexture[] {BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]}; + } + + public ITexture[] getFrontActive(byte aColor) { + return this.getFront(aColor); + } + + public ITexture[] getBackActive(byte aColor) { + return this.getBack(aColor); + } + + public ITexture[] getBottomActive(byte aColor) { + return this.getBottom(aColor); + } + + public ITexture[] getTopActive(byte aColor) { + return this.getTop(aColor); + } + + public ITexture[] getSidesActive(byte aColor) { + return this.getSides(aColor); + } + + public boolean isFacingValid(byte aSide) { + return aSide > 1; + } + + public boolean isSimpleMachine() { + return false; + } + + public boolean isValidSlot(int aIndex) { + return aIndex < 2; + } + + public boolean isEnetOutput() { + return true; + } + + public boolean isOutputFacing(byte aSide) { + return true; + } + + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + public long maxEUOutput() { + return this.getBaseMetaTileEntity().isAllowedToWork() ? GT_Values.V[this.mTier] : 0L; + } + + public long maxEUStore() { + return Math.max(this.getEUVar(), GT_Values.V[this.mTier] * 40L + this.getMinimumStoredEU()); + } + + public boolean doesFillContainers() { + return this.getBaseMetaTileEntity().isAllowedToWork(); + } + + public boolean doesEmptyContainers() { + return this.getBaseMetaTileEntity().isAllowedToWork(); + } + + public boolean canTankBeFilled() { + return this.getBaseMetaTileEntity().isAllowedToWork(); + } + + public boolean canTankBeEmptied() { + return this.getBaseMetaTileEntity().isAllowedToWork(); + } + + public boolean displaysItemStack() { + return true; + } + + public boolean displaysStackSize() { + return false; + } + + public boolean isFluidInputAllowed(FluidStack aFluid) { + int aVal = this.getFuelValue(aFluid); + Logger.WARNING("Fuel Value: " + aVal); + return aVal > 0; + } + + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.isAllowedToWork() && aTick % 10L == 0L) { + int tFuelValue; + if (this.mFluid == null) { + if (aBaseMetaTileEntity.getUniversalEnergyStored() < this.maxEUOutput() + this.getMinimumStoredEU()) { + this.mInventory[this.getStackDisplaySlot()] = null; + } else { + if (this.mInventory[this.getStackDisplaySlot()] == null) { + this.mInventory[this.getStackDisplaySlot()] = new ItemStack(Blocks.fire, 1); + } + + this.mInventory[this.getStackDisplaySlot()].setStackDisplayName("Generating: " + + (aBaseMetaTileEntity.getUniversalEnergyStored() - this.getMinimumStoredEU()) + " EU"); + } + } else { + tFuelValue = this.getFuelValue(this.mFluid); + int tConsumed = this.consumedFluidPerOperation(this.mFluid); + if (tFuelValue > 0 && tConsumed > 0 && this.mFluid.amount > tConsumed) { + long tFluidAmountToUse = Math.min( + (long) (this.mFluid.amount / tConsumed), + (this.maxEUStore() - aBaseMetaTileEntity.getUniversalEnergyStored()) / (long) tFuelValue); + if (tFluidAmountToUse > 0L + && aBaseMetaTileEntity.increaseStoredEnergyUnits( + tFluidAmountToUse * (long) tFuelValue, true)) { + PollutionUtils.addPollution(this.getBaseMetaTileEntity(), 10 * this.getPollution()); + this.mFluid.amount = (int) ((long) this.mFluid.amount - tFluidAmountToUse * (long) tConsumed); + } + } + } + + if (this.mInventory[this.getInputSlot()] != null + && aBaseMetaTileEntity.getUniversalEnergyStored() + < this.maxEUOutput() * 20L + this.getMinimumStoredEU() + && GT_Utility.getFluidForFilledItem(this.mInventory[this.getInputSlot()], true) == null) { + tFuelValue = this.getFuelValue(this.mInventory[this.getInputSlot()]); + if (tFuelValue > 0) { + ItemStack tEmptyContainer = this.getEmptyContainer(this.mInventory[this.getInputSlot()]); + if (aBaseMetaTileEntity.addStackToSlot(this.getOutputSlot(), tEmptyContainer)) { + aBaseMetaTileEntity.increaseStoredEnergyUnits((long) tFuelValue, true); + aBaseMetaTileEntity.decrStackSize(this.getInputSlot(), 1); + PollutionUtils.addPollution(this.getBaseMetaTileEntity(), 10 * this.getPollution()); + } + } + } + } + + if (aBaseMetaTileEntity.isServerSide()) { + Logger.WARNING("Ticking Servside"); + aBaseMetaTileEntity.setActive(aBaseMetaTileEntity.isAllowedToWork() + && aBaseMetaTileEntity.getUniversalEnergyStored() + >= this.maxEUOutput() + this.getMinimumStoredEU()); + } + } + + public abstract int getPollution(); + + public abstract GT_Recipe_Map getRecipes(); + + public abstract int getEfficiency(); + + public int consumedFluidPerOperation(FluidStack aLiquid) { + return 1; + } + + public int getFuelValue(FluidStack aLiquid) { + if (aLiquid != null && this.getRecipes() != null) { + Collection<GT_Recipe> tRecipeList = this.getRecipes().mRecipeList; + if (tRecipeList != null) { + Logger.WARNING("Fuels: " + tRecipeList.size()); + Iterator<GT_Recipe> var4 = tRecipeList.iterator(); + + while (var4.hasNext()) { + GT_Recipe tFuel = (GT_Recipe) var4.next(); + FluidStack tLiquid; + if ((tLiquid = GT_Utility.getFluidForFilledItem(tFuel.getRepresentativeInput(0), true)) != null + && aLiquid.isFluidEqual(tLiquid)) { + Logger.WARNING("Fuel Ok"); + return (int) ((long) tFuel.mSpecialValue + * (long) this.getEfficiency() + * (long) this.consumedFluidPerOperation(tLiquid) + / 100L); + } + if ((tLiquid = tFuel.getRepresentativeFluidInput(0)) != null && aLiquid.isFluidEqual(tLiquid)) { + Logger.WARNING("Fuel Ok"); + return (int) ((long) tFuel.mSpecialValue + * (long) this.getEfficiency() + * (long) this.consumedFluidPerOperation(tLiquid) + / 100L); + } + } + } + + return 0; + } else { + return 0; + } + } + + public int getFuelValue(ItemStack aStack) { + if (!GT_Utility.isStackInvalid(aStack) && this.getRecipes() != null) { + Logger.WARNING("Fuel Item OK"); + GT_Recipe tFuel = this.getRecipes() + .findRecipe( + this.getBaseMetaTileEntity(), false, Long.MAX_VALUE, (FluidStack[]) null, new ItemStack[] { + aStack + }); + return tFuel != null ? (int) ((long) tFuel.mSpecialValue * 1000L * (long) this.getEfficiency() / 100L) : 0; + } else { + return 0; + } + } + + public ItemStack getEmptyContainer(ItemStack aStack) { + if (!GT_Utility.isStackInvalid(aStack) && this.getRecipes() != null) { + GT_Recipe tFuel = this.getRecipes() + .findRecipe( + this.getBaseMetaTileEntity(), false, Long.MAX_VALUE, (FluidStack[]) null, new ItemStack[] { + aStack + }); + return tFuel != null + ? GT_Utility.copy(new Object[] {tFuel.getOutput(0)}) + : GT_Utility.getContainerItem(aStack, true); + } else { + return null; + } + } + + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack) + && (this.getFuelValue(aStack) > 0 + || this.getFuelValue(GT_Utility.getFluidForFilledItem(aStack, true)) > 0); + } + + public int getCapacity() { + return 16000; + } + + public int getTankPressure() { + return -100; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_BasicMachine.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_BasicMachine.java index 2eb1d36791..f6cf2391b3 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_BasicMachine.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_BasicMachine.java @@ -1,6 +1,7 @@ package gtPlusPlus.xmod.gregtech.api.metatileentity.custom.power; -import gregtech.GT_Mod; +import static gregtech.api.enums.GT_Values.V; + import gregtech.api.GregTech_API; import gregtech.api.enums.ItemList; import gregtech.api.enums.Textures; @@ -16,6 +17,7 @@ import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gregtech.api.util.GT_Utility; import gtPlusPlus.api.objects.random.XSTR; +import java.util.Arrays; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; @@ -26,10 +28,6 @@ import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidHandler; -import java.util.Arrays; - -import static gregtech.api.enums.GT_Values.V; - /** * NEVER INCLUDE THIS FILE IN YOUR MOD!!! * <p/> @@ -40,14 +38,20 @@ public abstract class GTPP_MTE_BasicMachine extends GTPP_MTE_BasicTank { /** * return values for checkRecipe() */ - protected static final int - DID_NOT_FIND_RECIPE = 0, + protected static final int DID_NOT_FIND_RECIPE = 0, FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS = 1, FOUND_AND_SUCCESSFULLY_USED_RECIPE = 2; + public static final int OTHER_SLOT_COUNT = 4; public final ItemStack[] mOutputItems; public final int mInputSlotCount, mAmperage; - public boolean mAllowInputFromOutputSide = false, mFluidTransfer = false, mItemTransfer = false, mHasBeenUpdated = false, mStuttering = false, mCharge = false, mDecharge = false; + public boolean mAllowInputFromOutputSide = false, + mFluidTransfer = false, + mItemTransfer = false, + mHasBeenUpdated = false, + mStuttering = false, + mCharge = false, + mDecharge = false; public int mMainFacing = -1, mProgresstime = 0, mMaxProgresstime = 0, mEUt = 0, mOutputBlocked = 0; public FluidStack mOutputFluid; public String mGUIName = "", mNEIName = ""; @@ -56,6 +60,7 @@ public abstract class GTPP_MTE_BasicMachine extends GTPP_MTE_BasicTank { * Contains the Recipe which has been previously used, or null if there was no previous Recipe, which could have been buffered */ protected GT_Recipe mLastRecipe = null; + private FluidStack mFluidOut; /** @@ -75,8 +80,26 @@ public abstract class GTPP_MTE_BasicMachine extends GTPP_MTE_BasicTank { * 12 = SideFacingPipeActive * 13 = SideFacingPipeInactive */ - public GTPP_MTE_BasicMachine(int aID, String aName, String aNameRegional, int aTier, int aAmperage, String aDescription, int aInputSlotCount, int aOutputSlotCount, String aGUIName, String aNEIName, ITexture... aOverlays) { - super(aID, aName, aNameRegional, aTier, OTHER_SLOT_COUNT + aInputSlotCount + aOutputSlotCount + 1, aDescription, aOverlays); + public GTPP_MTE_BasicMachine( + int aID, + String aName, + String aNameRegional, + int aTier, + int aAmperage, + String aDescription, + int aInputSlotCount, + int aOutputSlotCount, + String aGUIName, + String aNEIName, + ITexture... aOverlays) { + super( + aID, + aName, + aNameRegional, + aTier, + OTHER_SLOT_COUNT + aInputSlotCount + aOutputSlotCount + 1, + aDescription, + aOverlays); mInputSlotCount = Math.max(0, aInputSlotCount); mOutputItems = new ItemStack[Math.max(0, aOutputSlotCount)]; mAmperage = aAmperage; @@ -84,8 +107,26 @@ public abstract class GTPP_MTE_BasicMachine extends GTPP_MTE_BasicTank { mNEIName = aNEIName; } - public GTPP_MTE_BasicMachine(int aID, String aName, String aNameRegional, int aTier, int aAmperage, String[] aDescription, int aInputSlotCount, int aOutputSlotCount, String aGUIName, String aNEIName, ITexture... aOverlays) { - super(aID, aName, aNameRegional, aTier, OTHER_SLOT_COUNT + aInputSlotCount + aOutputSlotCount + 1, aDescription, aOverlays); + public GTPP_MTE_BasicMachine( + int aID, + String aName, + String aNameRegional, + int aTier, + int aAmperage, + String[] aDescription, + int aInputSlotCount, + int aOutputSlotCount, + String aGUIName, + String aNEIName, + ITexture... aOverlays) { + super( + aID, + aName, + aNameRegional, + aTier, + OTHER_SLOT_COUNT + aInputSlotCount + aOutputSlotCount + 1, + aDescription, + aOverlays); mInputSlotCount = Math.max(0, aInputSlotCount); mOutputItems = new ItemStack[Math.max(0, aOutputSlotCount)]; mAmperage = aAmperage; @@ -93,7 +134,16 @@ public abstract class GTPP_MTE_BasicMachine extends GTPP_MTE_BasicTank { mNEIName = aNEIName; } - public GTPP_MTE_BasicMachine(String aName, int aTier, int aAmperage, String aDescription, ITexture[][][] aTextures, int aInputSlotCount, int aOutputSlotCount, String aGUIName, String aNEIName) { + public GTPP_MTE_BasicMachine( + String aName, + int aTier, + int aAmperage, + String aDescription, + ITexture[][][] aTextures, + int aInputSlotCount, + int aOutputSlotCount, + String aGUIName, + String aNEIName) { super(aName, aTier, OTHER_SLOT_COUNT + aInputSlotCount + aOutputSlotCount + 1, aDescription, aTextures); mInputSlotCount = Math.max(0, aInputSlotCount); mOutputItems = new ItemStack[Math.max(0, aOutputSlotCount)]; @@ -101,8 +151,17 @@ public abstract class GTPP_MTE_BasicMachine extends GTPP_MTE_BasicTank { mGUIName = aGUIName; mNEIName = aNEIName; } - - public GTPP_MTE_BasicMachine(String aName, int aTier, int aAmperage, String[] aDescription, ITexture[][][] aTextures, int aInputSlotCount, int aOutputSlotCount, String aGUIName, String aNEIName) { + + public GTPP_MTE_BasicMachine( + String aName, + int aTier, + int aAmperage, + String[] aDescription, + ITexture[][][] aTextures, + int aInputSlotCount, + int aOutputSlotCount, + String aGUIName, + String aNEIName) { super(aName, aTier, OTHER_SLOT_COUNT + aInputSlotCount + aOutputSlotCount + 1, aDescription, aTextures); mInputSlotCount = Math.max(0, aInputSlotCount); mOutputItems = new ItemStack[Math.max(0, aOutputSlotCount)]; @@ -112,18 +171,18 @@ public abstract class GTPP_MTE_BasicMachine extends GTPP_MTE_BasicTank { } protected boolean isValidMainFacing(byte aSide) { - return aSide > 1; - } - - public boolean setMainFacing(byte aSide){ - if (!isValidMainFacing(aSide)) return false; - mMainFacing = aSide; - if(getBaseMetaTileEntity().getFrontFacing() == mMainFacing){ - getBaseMetaTileEntity().setFrontFacing(GT_Utility.getOppositeSide(aSide)); - } + return aSide > 1; + } + + public boolean setMainFacing(byte aSide) { + if (!isValidMainFacing(aSide)) return false; + mMainFacing = aSide; + if (getBaseMetaTileEntity().getFrontFacing() == mMainFacing) { + getBaseMetaTileEntity().setFrontFacing(GT_Utility.getOppositeSide(aSide)); + } onFacingChange(); onMachineBlockUpdate(); - return true; + return true; } @Override @@ -132,10 +191,12 @@ public abstract class GTPP_MTE_BasicMachine extends GTPP_MTE_BasicTank { aTextures = Arrays.copyOf(aTextures, 14); for (int i = 0; i < aTextures.length; i++) - if (aTextures[i] != null) for (byte c = -1; c < 16; c++) { - if (rTextures[i][c + 1] == null) - rTextures[i][c + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][c + 1], aTextures[i]}; - } + if (aTextures[i] != null) + for (byte c = -1; c < 16; c++) { + if (rTextures[i][c + 1] == null) + rTextures[i][c + 1] = + new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][c + 1], aTextures[i]}; + } for (byte c = -1; c < 16; c++) { if (rTextures[0][c + 1] == null) rTextures[0][c + 1] = getSideFacingActive(c); @@ -157,8 +218,28 @@ public abstract class GTPP_MTE_BasicMachine extends GTPP_MTE_BasicTank { } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - return mTextures[mMainFacing < 2 ? aSide == aFacing ? aActive ? 2 : 3 : aSide == 0 ? aActive ? 6 : 7 : aSide == 1 ? aActive ? 4 : 5 : aActive ? 0 : 1 : aSide == mMainFacing ? aActive ? 2 : 3 : (showPipeFacing() && aSide == aFacing) ? aSide == 0 ? aActive ? 8 : 9 : aSide == 1 ? aActive ? 10 : 11 : aActive ? 12 : 13 : aSide == 0 ? aActive ? 6 : 7 : aSide == 1 ? aActive ? 4 : 5 : aActive ? 0 : 1][aColorIndex + 1]; + public ITexture[] getTexture( + IGregTechTileEntity aBaseMetaTileEntity, + byte aSide, + byte aFacing, + byte aColorIndex, + boolean aActive, + boolean aRedstone) { + return mTextures[ + mMainFacing < 2 + ? aSide == aFacing + ? aActive ? 2 : 3 + : aSide == 0 ? aActive ? 6 : 7 : aSide == 1 ? aActive ? 4 : 5 : aActive ? 0 : 1 + : aSide == mMainFacing + ? aActive ? 2 : 3 + : (showPipeFacing() && aSide == aFacing) + ? aSide == 0 + ? aActive ? 8 : 9 + : aSide == 1 ? aActive ? 10 : 11 : aActive ? 12 : 13 + : aSide == 0 + ? aActive ? 6 : 7 + : aSide == 1 ? aActive ? 4 : 5 : aActive ? 0 : 1][ + aColorIndex + 1]; } @Override @@ -183,7 +264,9 @@ public abstract class GTPP_MTE_BasicMachine extends GTPP_MTE_BasicTank { @Override public boolean isValidSlot(int aIndex) { - return aIndex > 0 && super.isValidSlot(aIndex) && aIndex != OTHER_SLOT_COUNT + mInputSlotCount + mOutputItems.length; + return aIndex > 0 + && super.isValidSlot(aIndex) + && aIndex != OTHER_SLOT_COUNT + mInputSlotCount + mOutputItems.length; } @Override @@ -213,7 +296,9 @@ public abstract class GTPP_MTE_BasicMachine extends GTPP_MTE_BasicTank { @Override public boolean isLiquidInput(byte aSide) { - return aSide != mMainFacing && (mAllowInputFromOutputSide || aSide != getBaseMetaTileEntity().getFrontFacing()); + return aSide != mMainFacing + && (mAllowInputFromOutputSide + || aSide != getBaseMetaTileEntity().getFrontFacing()); } @Override @@ -304,7 +389,8 @@ public abstract class GTPP_MTE_BasicMachine extends GTPP_MTE_BasicTank { @Override public boolean isFluidInputAllowed(FluidStack aFluid) { - return getFillableStack() != null || (getRecipeList() != null && getRecipeList().containsInput(aFluid)); + return getFillableStack() != null + || (getRecipeList() != null && getRecipeList().containsInput(aFluid)); } @Override @@ -372,7 +458,14 @@ public abstract class GTPP_MTE_BasicMachine extends GTPP_MTE_BasicTank { @Override public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_BasicMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), mGUIName, GT_Utility.isStringValid(mNEIName) ? mNEIName : getRecipeList() != null ? getRecipeList().mUnlocalizedName : ""); + return new GT_GUIContainer_BasicMachine( + aPlayerInventory, + aBaseMetaTileEntity, + getLocalName(), + mGUIName, + GT_Utility.isStringValid(mNEIName) + ? mNEIName + : getRecipeList() != null ? getRecipeList().mUnlocalizedName : ""); } @Override @@ -434,8 +527,8 @@ public abstract class GTPP_MTE_BasicMachine extends GTPP_MTE_BasicTank { if (++mProgresstime >= mMaxProgresstime) { for (int i = 0; i < mOutputItems.length; i++) for (int j = 0; j < mOutputItems.length; j++) - if (aBaseMetaTileEntity.addStackToSlot(getOutputSlot() + ((j + i) % mOutputItems.length), mOutputItems[i])) - break; + if (aBaseMetaTileEntity.addStackToSlot( + getOutputSlot() + ((j + i) % mOutputItems.length), mOutputItems[i])) break; if (mOutputFluid != null) if (getDrainableStack() == null) setDrainableStack(mOutputFluid.copy()); else if (mOutputFluid.isFluidEqual(getDrainableStack())) @@ -451,8 +544,11 @@ public abstract class GTPP_MTE_BasicMachine extends GTPP_MTE_BasicTank { } if (mProgresstime > 5) mStuttering = false; XSTR aXSTR = new XSTR(); - //Dumb April Fools Shit - // if(GT_Mod.gregtechproxy.mAprilFool && aXSTR.nextInt(5000)==0)GT_Utility.sendSoundToPlayers(aBaseMetaTileEntity.getWorld(), GregTech_API.sSoundList.get(5), 10.0F, -1.0F, aBaseMetaTileEntity.getXCoord(), aBaseMetaTileEntity.getYCoord(),aBaseMetaTileEntity.getZCoord()); + // Dumb April Fools Shit + // if(GT_Mod.gregtechproxy.mAprilFool && + // aXSTR.nextInt(5000)==0)GT_Utility.sendSoundToPlayers(aBaseMetaTileEntity.getWorld(), + // GregTech_API.sSoundList.get(5), 10.0F, -1.0F, aBaseMetaTileEntity.getXCoord(), + // aBaseMetaTileEntity.getYCoord(),aBaseMetaTileEntity.getZCoord()); } else { if (!mStuttering) { stutterProcess(); @@ -466,32 +562,65 @@ public abstract class GTPP_MTE_BasicMachine extends GTPP_MTE_BasicTank { boolean tRemovedOutputFluid = false; - if (doesAutoOutputFluids() && getDrainableStack() != null && aBaseMetaTileEntity.getFrontFacing() != mMainFacing && (tSucceeded || aTick % 20 == 0)) { + if (doesAutoOutputFluids() + && getDrainableStack() != null + && aBaseMetaTileEntity.getFrontFacing() != mMainFacing + && (tSucceeded || aTick % 20 == 0)) { IFluidHandler tTank = aBaseMetaTileEntity.getITankContainerAtSide(aBaseMetaTileEntity.getFrontFacing()); if (tTank != null) { FluidStack tDrained = drain(1000, false); if (tDrained != null) { - int tFilledAmount = tTank.fill(ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()), tDrained, false); + int tFilledAmount = tTank.fill( + ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()), tDrained, false); if (tFilledAmount > 0) - tTank.fill(ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()), drain(tFilledAmount, true), true); + tTank.fill( + ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()), + drain(tFilledAmount, true), + true); } } if (getDrainableStack() == null) tRemovedOutputFluid = true; } - if (doesAutoOutput() && !isOutputEmpty() && aBaseMetaTileEntity.getFrontFacing() != mMainFacing && (tSucceeded || mOutputBlocked % 300 == 1 || aBaseMetaTileEntity.hasInventoryBeenModified() || aTick % 600 == 0)) { + if (doesAutoOutput() + && !isOutputEmpty() + && aBaseMetaTileEntity.getFrontFacing() != mMainFacing + && (tSucceeded + || mOutputBlocked % 300 == 1 + || aBaseMetaTileEntity.hasInventoryBeenModified() + || aTick % 600 == 0)) { TileEntity tTileEntity2 = aBaseMetaTileEntity.getTileEntityAtSide(aBaseMetaTileEntity.getFrontFacing()); - for (int i = 0, tCosts = 1; i < mOutputItems.length && tCosts > 0 && aBaseMetaTileEntity.isUniversalEnergyStored(128); i++) { - tCosts = GT_Utility.moveOneItemStack(aBaseMetaTileEntity, tTileEntity2, aBaseMetaTileEntity.getFrontFacing(), aBaseMetaTileEntity.getBackFacing(), null, false, (byte) 64, (byte) 1, (byte) 64, (byte) 1); + for (int i = 0, tCosts = 1; + i < mOutputItems.length && tCosts > 0 && aBaseMetaTileEntity.isUniversalEnergyStored(128); + i++) { + tCosts = GT_Utility.moveOneItemStack( + aBaseMetaTileEntity, + tTileEntity2, + aBaseMetaTileEntity.getFrontFacing(), + aBaseMetaTileEntity.getBackFacing(), + null, + false, + (byte) 64, + (byte) 1, + (byte) 64, + (byte) 1); if (tCosts > 0) aBaseMetaTileEntity.decreaseStoredEnergyUnits(tCosts, true); } } - if (mOutputBlocked != 0) if (isOutputEmpty()) mOutputBlocked = 0; - else mOutputBlocked++; + if (mOutputBlocked != 0) + if (isOutputEmpty()) mOutputBlocked = 0; + else mOutputBlocked++; if (allowToCheckRecipe()) { - if (mMaxProgresstime <= 0 && aBaseMetaTileEntity.isAllowedToWork() && (tRemovedOutputFluid || tSucceeded || aBaseMetaTileEntity.hasInventoryBeenModified() || aTick % 600 == 0 || aBaseMetaTileEntity.hasWorkJustBeenEnabled()) && hasEnoughEnergyToCheckRecipe()) { + if (mMaxProgresstime <= 0 + && aBaseMetaTileEntity.isAllowedToWork() + && (tRemovedOutputFluid + || tSucceeded + || aBaseMetaTileEntity.hasInventoryBeenModified() + || aTick % 600 == 0 + || aBaseMetaTileEntity.hasWorkJustBeenEnabled()) + && hasEnoughEnergyToCheckRecipe()) { if (checkRecipe() == 2) { if (mInventory[3] != null && mInventory[3].stackSize <= 0) mInventory[3] = null; for (int i = getInputSlot(), j = i + mInputSlotCount; i < j; i++) @@ -538,7 +667,8 @@ public abstract class GTPP_MTE_BasicMachine extends GTPP_MTE_BasicTank { if (ItemList.Display_Fluid.isStackEqual(mInventory[tDisplayStackSlot], true, true)) mInventory[tDisplayStackSlot] = null; } else { - mInventory[tDisplayStackSlot] = GT_Utility.getFluidDisplayStack(getFillableStack(), displaysStackSize()); + mInventory[tDisplayStackSlot] = + GT_Utility.getFluidDisplayStack(getFillableStack(), displaysStackSize()); } } } @@ -584,14 +714,20 @@ public abstract class GTPP_MTE_BasicMachine extends GTPP_MTE_BasicTank { } protected boolean canOutput(GT_Recipe aRecipe) { - return aRecipe != null && (aRecipe.mNeedsEmptyOutput ? isOutputEmpty() && getDrainableStack() == null : canOutput(aRecipe.getFluidOutput(0)) && canOutput(aRecipe.mOutputs)); + return aRecipe != null + && (aRecipe.mNeedsEmptyOutput + ? isOutputEmpty() && getDrainableStack() == null + : canOutput(aRecipe.getFluidOutput(0)) && canOutput(aRecipe.mOutputs)); } protected boolean canOutput(ItemStack... aOutputs) { if (aOutputs == null) return true; ItemStack[] tOutputSlots = getAllOutputs(); for (int i = 0; i < tOutputSlots.length && i < aOutputs.length; i++) - if (tOutputSlots[i] != null && aOutputs[i] != null && (!GT_Utility.areStacksEqual(tOutputSlots[i], aOutputs[i], false) || tOutputSlots[i].stackSize + aOutputs[i].stackSize > tOutputSlots[i].getMaxStackSize())) { + if (tOutputSlots[i] != null + && aOutputs[i] != null + && (!GT_Utility.areStacksEqual(tOutputSlots[i], aOutputs[i], false) + || tOutputSlots[i].stackSize + aOutputs[i].stackSize > tOutputSlots[i].getMaxStackSize())) { mOutputBlocked++; return false; } @@ -599,7 +735,11 @@ public abstract class GTPP_MTE_BasicMachine extends GTPP_MTE_BasicTank { } protected boolean canOutput(FluidStack aOutput) { - return getDrainableStack() == null || aOutput == null || (getDrainableStack().isFluidEqual(aOutput) && (getDrainableStack().amount <= 0 || getDrainableStack().amount + aOutput.amount <= getCapacity())); + return getDrainableStack() == null + || aOutput == null + || (getDrainableStack().isFluidEqual(aOutput) + && (getDrainableStack().amount <= 0 + || getDrainableStack().amount + aOutput.amount <= getCapacity())); } protected ItemStack getInputAt(int aIndex) { @@ -699,13 +839,15 @@ public abstract class GTPP_MTE_BasicMachine extends GTPP_MTE_BasicTank { @Override public String[] getInfoData() { - return new String[]{ - mNEIName, - "Progress:", (mProgresstime / 20) + " secs", - (mMaxProgresstime / 20) + " secs", - "Stored Energy:", - getBaseMetaTileEntity().getStoredEU() + "EU", - getBaseMetaTileEntity().getEUCapacity() + "EU"}; + return new String[] { + mNEIName, + "Progress:", + (mProgresstime / 20) + " secs", + (mMaxProgresstime / 20) + " secs", + "Stored Energy:", + getBaseMetaTileEntity().getStoredEU() + "EU", + getBaseMetaTileEntity().getEUCapacity() + "EU" + }; } @Override @@ -717,13 +859,17 @@ public abstract class GTPP_MTE_BasicMachine extends GTPP_MTE_BasicTank { public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { if (aSide == getBaseMetaTileEntity().getFrontFacing() || aSide == mMainFacing) { mAllowInputFromOutputSide = !mAllowInputFromOutputSide; - GT_Utility.sendChatToPlayer(aPlayer, mAllowInputFromOutputSide ? "Input from Output Side allowed" : "Input from Output Side forbidden"); + GT_Utility.sendChatToPlayer( + aPlayer, + mAllowInputFromOutputSide ? "Input from Output Side allowed" : "Input from Output Side forbidden"); } } @Override public boolean allowCoverOnSide(byte aSide, GT_ItemStack aCoverID) { - return (aSide != mMainFacing || GregTech_API.getCoverBehavior(aCoverID.toStack()).isGUIClickable(aSide, GT_Utility.stackToInt(aCoverID.toStack()), 0, getBaseMetaTileEntity())); + return (aSide != mMainFacing + || GregTech_API.getCoverBehavior(aCoverID.toStack()) + .isGUIClickable(aSide, GT_Utility.stackToInt(aCoverID.toStack()), 0, getBaseMetaTileEntity())); } @Override @@ -733,8 +879,10 @@ public abstract class GTPP_MTE_BasicMachine extends GTPP_MTE_BasicTank { @Override public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - if (aSide == mMainFacing || aIndex < getInputSlot() || aIndex >= getInputSlot() + mInputSlotCount || (!mAllowInputFromOutputSide && aSide == aBaseMetaTileEntity.getFrontFacing())) - return false; + if (aSide == mMainFacing + || aIndex < getInputSlot() + || aIndex >= getInputSlot() + mInputSlotCount + || (!mAllowInputFromOutputSide && aSide == aBaseMetaTileEntity.getFrontFacing())) return false; for (int i = getInputSlot(), j = i + mInputSlotCount; i < j; i++) if (GT_Utility.areStacksEqual(GT_OreDictUnificator.get(aStack), mInventory[i])) return i == aIndex; return true; @@ -760,25 +908,31 @@ public abstract class GTPP_MTE_BasicMachine extends GTPP_MTE_BasicTank { return checkRecipe(false); } - public static boolean isValidForLowGravity(GT_Recipe tRecipe, int dimId){ - return //TODO check or get a better solution - DimensionManager.getProvider(dimId).getClass().getName().contains("Orbit") || - DimensionManager.getProvider(dimId).getClass().getName().endsWith("Space") || - DimensionManager.getProvider(dimId).getClass().getName().endsWith("Asteroids") || - DimensionManager.getProvider(dimId).getClass().getName().endsWith("SS") || - DimensionManager.getProvider(dimId).getClass().getName().contains("SpaceStation"); + public static boolean isValidForLowGravity(GT_Recipe tRecipe, int dimId) { + return // TODO check or get a better solution + DimensionManager.getProvider(dimId).getClass().getName().contains("Orbit") + || DimensionManager.getProvider(dimId).getClass().getName().endsWith("Space") + || DimensionManager.getProvider(dimId).getClass().getName().endsWith("Asteroids") + || DimensionManager.getProvider(dimId).getClass().getName().endsWith("SS") + || DimensionManager.getProvider(dimId).getClass().getName().contains("SpaceStation"); } - /** * * @param skipOC disables OverclockedNess calculation and check - if you do you must implement your own method... * @return */ - public int checkRecipe(boolean skipOC){ + public int checkRecipe(boolean skipOC) { GT_Recipe_Map tMap = getRecipeList(); if (tMap == null) return DID_NOT_FIND_RECIPE; - GT_Recipe tRecipe = tMap.findRecipe(getBaseMetaTileEntity(), mLastRecipe, false, V[mTier], new FluidStack[]{getFillableStack()}, getSpecialSlot(), getAllInputs()); + GT_Recipe tRecipe = tMap.findRecipe( + getBaseMetaTileEntity(), + mLastRecipe, + false, + V[mTier], + new FluidStack[] {getFillableStack()}, + getSpecialSlot(), + getAllInputs()); if (tRecipe == null) return DID_NOT_FIND_RECIPE; if (tRecipe.mCanBeBuffered) mLastRecipe = tRecipe; @@ -788,7 +942,7 @@ public abstract class GTPP_MTE_BasicMachine extends GTPP_MTE_BasicTank { } if (tRecipe.mSpecialValue == -200 && (mCleanroom == null || mCleanroom.mEfficiency == 0)) return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; - if (!tRecipe.isRecipeInputEqual(true, new FluidStack[]{getFillableStack()}, getAllInputs())) + if (!tRecipe.isRecipeInputEqual(true, new FluidStack[] {getFillableStack()}, getAllInputs())) return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; for (int i = 0; i < mOutputItems.length; i++) if (getBaseMetaTileEntity().getRandomNumber(10000) < tRecipe.getOutputChance(i)) @@ -803,58 +957,76 @@ public abstract class GTPP_MTE_BasicMachine extends GTPP_MTE_BasicTank { } public ITexture[] getSideFacingActive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; } public ITexture[] getSideFacingInactive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; } public ITexture[] getFrontFacingActive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; } public ITexture[] getFrontFacingInactive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; } public ITexture[] getTopFacingActive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; } public ITexture[] getTopFacingInactive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; } public ITexture[] getBottomFacingActive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; } public ITexture[] getBottomFacingInactive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; } public ITexture[] getBottomFacingPipeActive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT) + }; } public ITexture[] getBottomFacingPipeInactive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT) + }; } public ITexture[] getTopFacingPipeActive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT) + }; } public ITexture[] getTopFacingPipeInactive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT) + }; } public ITexture[] getSideFacingPipeActive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT) + }; } public ITexture[] getSideFacingPipeInactive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT) + }; } -}
\ No newline at end of file +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_BasicTank.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_BasicTank.java index 9c6840e33c..bbc2206784 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_BasicTank.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_BasicTank.java @@ -1,8 +1,6 @@ package gtPlusPlus.xmod.gregtech.api.metatileentity.custom.power; import gregtech.api.enums.ItemList; -import gregtech.api.gui.GT_Container_BasicTank; -import gregtech.api.gui.GT_GUIContainer_BasicTank; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.util.GT_Utility; @@ -25,19 +23,35 @@ public abstract class GTPP_MTE_BasicTank extends GTPP_MTE_TieredMachineBlock { /** * @param aInvSlotCount should be 3 */ - public GTPP_MTE_BasicTank(int aID, String aName, String aNameRegional, int aTier, int aInvSlotCount, String aDescription, ITexture... aTextures) { + public GTPP_MTE_BasicTank( + int aID, + String aName, + String aNameRegional, + int aTier, + int aInvSlotCount, + String aDescription, + ITexture... aTextures) { super(aID, aName, aNameRegional, aTier, aInvSlotCount, aDescription, aTextures); } - public GTPP_MTE_BasicTank(int aID, String aName, String aNameRegional, int aTier, int aInvSlotCount, String[] aDescription, ITexture... aTextures) { + public GTPP_MTE_BasicTank( + int aID, + String aName, + String aNameRegional, + int aTier, + int aInvSlotCount, + String[] aDescription, + ITexture... aTextures) { super(aID, aName, aNameRegional, aTier, aInvSlotCount, aDescription, aTextures); } - public GTPP_MTE_BasicTank(String aName, int aTier, int aInvSlotCount, String aDescription, ITexture[][][] aTextures) { + public GTPP_MTE_BasicTank( + String aName, int aTier, int aInvSlotCount, String aDescription, ITexture[][][] aTextures) { super(aName, aTier, aInvSlotCount, aDescription, aTextures); } - - public GTPP_MTE_BasicTank(String aName, int aTier, int aInvSlotCount, String[] aDescription, ITexture[][][] aTextures) { + + public GTPP_MTE_BasicTank( + String aName, int aTier, int aInvSlotCount, String[] aDescription, ITexture[][][] aTextures) { super(aName, aTier, aInvSlotCount, aDescription, aTextures); } @@ -136,7 +150,8 @@ public abstract class GTPP_MTE_BasicTank extends GTPP_MTE_TieredMachineBlock { if (ItemList.Display_Fluid.isStackEqual(mInventory[getStackDisplaySlot()], true, true)) mInventory[getStackDisplaySlot()] = null; } else { - mInventory[getStackDisplaySlot()] = GT_Utility.getFluidDisplayStack(getDisplayedFluid(), displaysStackSize()); + mInventory[getStackDisplaySlot()] = + GT_Utility.getFluidDisplayStack(getDisplayedFluid(), displaysStackSize()); } } @@ -145,15 +160,22 @@ public abstract class GTPP_MTE_BasicTank extends GTPP_MTE_TieredMachineBlock { if (tFluid != null && isFluidInputAllowed(tFluid)) { if (getFillableStack() == null) { if (isFluidInputAllowed(tFluid) && tFluid.amount <= getCapacity()) { - if (aBaseMetaTileEntity.addStackToSlot(getOutputSlot(), GT_Utility.getContainerItem(mInventory[getInputSlot()], true), 1)) { + if (aBaseMetaTileEntity.addStackToSlot( + getOutputSlot(), + GT_Utility.getContainerItem(mInventory[getInputSlot()], true), + 1)) { setFillableStack(tFluid.copy()); this.onEmptyingContainerWhenEmpty(); aBaseMetaTileEntity.decrStackSize(getInputSlot(), 1); } } } else { - if (tFluid.isFluidEqual(getFillableStack()) && tFluid.amount + getFillableStack().amount <= getCapacity()) { - if (aBaseMetaTileEntity.addStackToSlot(getOutputSlot(), GT_Utility.getContainerItem(mInventory[getInputSlot()], true), 1)) { + if (tFluid.isFluidEqual(getFillableStack()) + && tFluid.amount + getFillableStack().amount <= getCapacity()) { + if (aBaseMetaTileEntity.addStackToSlot( + getOutputSlot(), + GT_Utility.getContainerItem(mInventory[getInputSlot()], true), + 1)) { getFillableStack().amount += tFluid.amount; aBaseMetaTileEntity.decrStackSize(getInputSlot(), 1); } @@ -163,7 +185,8 @@ public abstract class GTPP_MTE_BasicTank extends GTPP_MTE_TieredMachineBlock { } if (doesFillContainers()) { - ItemStack tOutput = GT_Utility.fillFluidContainer(getDrainableStack(), mInventory[getInputSlot()], false, true); + ItemStack tOutput = + GT_Utility.fillFluidContainer(getDrainableStack(), mInventory[getInputSlot()], false, true); if (tOutput != null && aBaseMetaTileEntity.addStackToSlot(getOutputSlot(), tOutput, 1)) { FluidStack tFluid = GT_Utility.getFluidForFilledItem(tOutput, true); aBaseMetaTileEntity.decrStackSize(getInputSlot(), 1); @@ -186,8 +209,11 @@ public abstract class GTPP_MTE_BasicTank extends GTPP_MTE_TieredMachineBlock { @Override public int fill(FluidStack aFluid, boolean doFill) { - if (aFluid == null || aFluid.getFluid().getID() <= 0 || aFluid.amount <= 0 || !canTankBeFilled() || !isFluidInputAllowed(aFluid)) - return 0; + if (aFluid == null + || aFluid.getFluid().getID() <= 0 + || aFluid.amount <= 0 + || !canTankBeFilled() + || !isFluidInputAllowed(aFluid)) return 0; if (getFillableStack() == null || getFillableStack().getFluid().getID() <= 0) { if (aFluid.amount <= getCapacity()) { @@ -205,8 +231,7 @@ public abstract class GTPP_MTE_BasicTank extends GTPP_MTE_TieredMachineBlock { return getCapacity(); } - if (!getFillableStack().isFluidEqual(aFluid)) - return 0; + if (!getFillableStack().isFluidEqual(aFluid)) return 0; int space = getCapacity() - getFillableStack().amount; if (aFluid.amount <= space) { @@ -216,8 +241,7 @@ public abstract class GTPP_MTE_BasicTank extends GTPP_MTE_TieredMachineBlock { } return aFluid.amount; } - if (doFill) - getFillableStack().amount = getCapacity(); + if (doFill) getFillableStack().amount = getCapacity(); return space; } @@ -231,8 +255,7 @@ public abstract class GTPP_MTE_BasicTank extends GTPP_MTE_TieredMachineBlock { } int used = maxDrain; - if (getDrainableStack().amount < used) - used = getDrainableStack().amount; + if (getDrainableStack().amount < used) used = getDrainableStack().amount; if (doDrain) { getDrainableStack().amount -= used; @@ -259,8 +282,8 @@ public abstract class GTPP_MTE_BasicTank extends GTPP_MTE_TieredMachineBlock { public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { return aIndex == getInputSlot(); } - - protected void onEmptyingContainerWhenEmpty(){ - //Do nothing + + protected void onEmptyingContainerWhenEmpty() { + // Do nothing } -}
\ No newline at end of file +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_TieredMachineBlock.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_TieredMachineBlock.java index 8110037c46..e45588e126 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_TieredMachineBlock.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_TieredMachineBlock.java @@ -4,7 +4,6 @@ import static gregtech.api.enums.GT_Values.GT; import gregtech.api.interfaces.ITexture; import gtPlusPlus.api.objects.data.AutoMap; -import gtPlusPlus.core.lib.CORE; public abstract class GTPP_MTE_TieredMachineBlock extends MetaTileEntityCustomPower { /** @@ -25,17 +24,31 @@ public abstract class GTPP_MTE_TieredMachineBlock extends MetaTileEntityCustomPo */ public final ITexture[][][] mTextures; - public GTPP_MTE_TieredMachineBlock(int aID, String aName, String aNameRegional, int aTier, int aInvSlotCount, String aDescription, ITexture... aTextures) { + public GTPP_MTE_TieredMachineBlock( + int aID, + String aName, + String aNameRegional, + int aTier, + int aInvSlotCount, + String aDescription, + ITexture... aTextures) { super(aID, aName, aNameRegional, aInvSlotCount); mTier = (byte) Math.max(0, Math.min(aTier, 9)); - mDescriptionArray = aDescription == null ? new String[0] : new String[]{aDescription}; + mDescriptionArray = aDescription == null ? new String[0] : new String[] {aDescription}; mDescription = mDescriptionArray.length > 0 ? mDescriptionArray[0] : ""; // must always be the last call! if (GT.isClientSide()) mTextures = getTextureSet(aTextures); else mTextures = null; } - public GTPP_MTE_TieredMachineBlock(int aID, String aName, String aNameRegional, int aTier, int aInvSlotCount, String[] aDescription, ITexture... aTextures) { + public GTPP_MTE_TieredMachineBlock( + int aID, + String aName, + String aNameRegional, + int aTier, + int aInvSlotCount, + String[] aDescription, + ITexture... aTextures) { super(aID, aName, aNameRegional, aInvSlotCount); mTier = (byte) Math.max(0, Math.min(aTier, 9)); mDescriptionArray = aDescription == null ? new String[0] : aDescription; @@ -46,15 +59,17 @@ public abstract class GTPP_MTE_TieredMachineBlock extends MetaTileEntityCustomPo else mTextures = null; } - public GTPP_MTE_TieredMachineBlock(String aName, int aTier, int aInvSlotCount, String aDescription, ITexture[][][] aTextures) { + public GTPP_MTE_TieredMachineBlock( + String aName, int aTier, int aInvSlotCount, String aDescription, ITexture[][][] aTextures) { super(aName, aInvSlotCount); mTier = (byte) aTier; - mDescriptionArray = aDescription == null ? new String[0] : new String[]{aDescription}; + mDescriptionArray = aDescription == null ? new String[0] : new String[] {aDescription}; mDescription = mDescriptionArray.length > 0 ? mDescriptionArray[0] : ""; mTextures = aTextures; } - public GTPP_MTE_TieredMachineBlock(String aName, int aTier, int aInvSlotCount, String[] aDescription, ITexture[][][] aTextures) { + public GTPP_MTE_TieredMachineBlock( + String aName, int aTier, int aInvSlotCount, String[] aDescription, ITexture[][][] aTextures) { super(aName, aInvSlotCount); mTier = (byte) aTier; mDescriptionArray = aDescription == null ? new String[0] : aDescription; @@ -79,14 +94,14 @@ public abstract class GTPP_MTE_TieredMachineBlock extends MetaTileEntityCustomPo @Override public String[] getDescription() { - AutoMap<String> aTooltip = new AutoMap<String>(); - String []s1 = null; - s1 = new String[aTooltip.size()]; - int u = 0; - for (String s : aTooltip) { - s1[u] = s; - } - return s1; + AutoMap<String> aTooltip = new AutoMap<String>(); + String[] s1 = null; + s1 = new String[aTooltip.size()]; + int u = 0; + for (String s : aTooltip) { + s1[u] = s; + } + return s1; } /** @@ -96,4 +111,4 @@ public abstract class GTPP_MTE_TieredMachineBlock extends MetaTileEntityCustomPo * @param aTextures is the optional Array you can give to the Constructor. */ public abstract ITexture[][][] getTextureSet(ITexture[] aTextures); -}
\ No newline at end of file +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/MetaTileEntityCustomPower.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/MetaTileEntityCustomPower.java index 31d24ff343..36185b638b 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/MetaTileEntityCustomPower.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/MetaTileEntityCustomPower.java @@ -12,83 +12,79 @@ import net.minecraft.world.World; public abstract class MetaTileEntityCustomPower extends CustomMetaTileBase { - public MetaTileEntityCustomPower(int aID, String aBasicName, String aRegionalName, int aInvSlotCount) { - super(aID, aBasicName, aRegionalName, aInvSlotCount); - this.setBaseMetaTileEntity(Meta_GT_Proxy.constructBaseMetaTileEntityCustomPower()); - this.getBaseMetaTileEntity().setMetaTileID((short) aID); - } - - public MetaTileEntityCustomPower(String aStack, int aInvSlotCount) { - super(aStack, aInvSlotCount); - } - - public long getMinimumStoredEU() { - return 0L; - } - - public boolean doesExplode() { - return this.getBaseCustomMetaTileEntity().doesExplode(); - } - - + public MetaTileEntityCustomPower(int aID, String aBasicName, String aRegionalName, int aInvSlotCount) { + super(aID, aBasicName, aRegionalName, aInvSlotCount); + this.setBaseMetaTileEntity(Meta_GT_Proxy.constructBaseMetaTileEntityCustomPower()); + this.getBaseMetaTileEntity().setMetaTileID((short) aID); + } - public void doExplosion(long aExplosionPower) { - - if (!doesExplode()) { - Logger.INFO("Machine tried to explode, let's stop that. xo [doExplosion]"); - return; - } - - float tStrength = aExplosionPower < GT_Values.V[0] - ? 1.0F - : (aExplosionPower < GT_Values.V[1] - ? 2.0F - : (aExplosionPower < GT_Values.V[2] - ? 3.0F - : (aExplosionPower < GT_Values.V[3] - ? 4.0F - : (aExplosionPower < GT_Values.V[4] - ? 5.0F - : (aExplosionPower < GT_Values.V[4] * 2L - ? 6.0F - : (aExplosionPower < GT_Values.V[5] - ? 7.0F - : (aExplosionPower < GT_Values.V[6] - ? 8.0F - : (aExplosionPower < GT_Values.V[7] - ? 9.0F - : 10.0F)))))))); - int tX = this.getBaseMetaTileEntity().getXCoord(); - short tY = this.getBaseMetaTileEntity().getYCoord(); - int tZ = this.getBaseMetaTileEntity().getZCoord(); - World tWorld = this.getBaseMetaTileEntity().getWorld(); - GT_Utility.sendSoundToPlayers(tWorld, (String) GregTech_API.sSoundList.get(Integer.valueOf(209)), 1.0F, -1.0F, - tX, tY, tZ); - tWorld.setBlock(tX, tY, tZ, Blocks.air); - if (GregTech_API.sMachineExplosions) { - tWorld.createExplosion((Entity) null, (double) tX + 0.5D, (double) tY + 0.5D, (double) tZ + 0.5D, tStrength, - true); - } + public MetaTileEntityCustomPower(String aStack, int aInvSlotCount) { + super(aStack, aInvSlotCount); + } - } + public long getMinimumStoredEU() { + return 0L; + } - @Override - public void onExplosion() { - if (!doesExplode()) { - Logger.INFO("Machine tried to explode, let's stop that. xo [onExplosion]"); - return; - } - super.onExplosion(); - } + public boolean doesExplode() { + return this.getBaseCustomMetaTileEntity().doesExplode(); + } - @Override - public boolean isElectric() { - return true; - } + public void doExplosion(long aExplosionPower) { - @Override - public long getEUVar() { - return super.getEUVar(); - } + if (!doesExplode()) { + Logger.INFO("Machine tried to explode, let's stop that. xo [doExplosion]"); + return; + } + float tStrength = aExplosionPower < GT_Values.V[0] + ? 1.0F + : (aExplosionPower < GT_Values.V[1] + ? 2.0F + : (aExplosionPower < GT_Values.V[2] + ? 3.0F + : (aExplosionPower < GT_Values.V[3] + ? 4.0F + : (aExplosionPower < GT_Values.V[4] + ? 5.0F + : (aExplosionPower < GT_Values.V[4] * 2L + ? 6.0F + : (aExplosionPower < GT_Values.V[5] + ? 7.0F + : (aExplosionPower < GT_Values.V[6] + ? 8.0F + : (aExplosionPower < GT_Values.V[7] + ? 9.0F + : 10.0F)))))))); + int tX = this.getBaseMetaTileEntity().getXCoord(); + short tY = this.getBaseMetaTileEntity().getYCoord(); + int tZ = this.getBaseMetaTileEntity().getZCoord(); + World tWorld = this.getBaseMetaTileEntity().getWorld(); + GT_Utility.sendSoundToPlayers( + tWorld, (String) GregTech_API.sSoundList.get(Integer.valueOf(209)), 1.0F, -1.0F, tX, tY, tZ); + tWorld.setBlock(tX, tY, tZ, Blocks.air); + if (GregTech_API.sMachineExplosions) { + tWorld.createExplosion( + (Entity) null, (double) tX + 0.5D, (double) tY + 0.5D, (double) tZ + 0.5D, tStrength, true); + } + } + + @Override + public void onExplosion() { + if (!doesExplode()) { + Logger.INFO("Machine tried to explode, let's stop that. xo [onExplosion]"); + return; + } + super.onExplosion(); + } + + @Override + public boolean isElectric() { + return true; + } + + @Override + public long getEUVar() { + return super.getEUVar(); + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicBreaker.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicBreaker.java index 3821b2a95c..ac069be52d 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicBreaker.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicBreaker.java @@ -21,265 +21,282 @@ import net.minecraft.util.EnumChatFormatting; public class GT_MetaTileEntity_BasicBreaker extends GTPP_MTE_TieredMachineBlock { - public boolean mCharge = false; - public boolean mDecharge = false; - public int mBatteryCount = 0; - public int mChargeableCount = 0; - private long count = 0L; - private long mStored = 0L; - private long mMax = 0L; - - public GT_MetaTileEntity_BasicBreaker(int aID, String aName, String aNameRegional, int aTier, String aDescription, int aSlotCount) { - super(aID, aName, aNameRegional, aTier, aSlotCount, aDescription, new ITexture[0]); - } - - public GT_MetaTileEntity_BasicBreaker(String aName, int aTier, String aDescription, ITexture[][][] aTextures, int aSlotCount) { - super(aName, aTier, aSlotCount, aDescription, aTextures); - } - - public GT_MetaTileEntity_BasicBreaker(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures, int aSlotCount) { - super(aName, aTier, aSlotCount, aDescription, aTextures); - } - - public String[] getDescription() { - final String[] desc = new String[6]; - int tTier = this.mTier; - desc[0] = "" + EnumChatFormatting.BOLD + "16 Fuse Slots"; - desc[1] = "Per each fuse, you may insert " + EnumChatFormatting.YELLOW + (GT_Values.V[tTier]) + EnumChatFormatting.GRAY + " EU/t"; - desc[2] = "However this " + EnumChatFormatting.ITALIC + EnumChatFormatting.RED + "MUST" + EnumChatFormatting.GRAY + " be in a single Amp"; - desc[3] = "This machine can accept upto a single amp of " + GT_Values.VN[Math.min(tTier + 2, 15)] + " as a result"; - desc[4] = "Breaker Loss: " + EnumChatFormatting.RED + "" + (GT_Values.V[tTier] / 16) + EnumChatFormatting.GRAY + " EU/t"; - desc[5] = CORE.GT_Tooltip; - return desc; - } - - public ITexture[][][] getTextureSet(ITexture[] aTextures) { - ITexture[][][] rTextures = new ITexture[2][17][]; - - for (byte i = -1; i < 16; ++i) { - rTextures[0][i + 1] = new ITexture[]{BlockIcons.MACHINE_CASINGS[this.mTier][i - + 1], this.mInventory.length > 4 ? BlockIcons.OVERLAYS_ENERGY_IN_MULTI[Math.min(12, mTier)] : BlockIcons.OVERLAYS_ENERGY_IN[Math.min(12, mTier)]}; - - rTextures[1][i + 1] = new ITexture[]{BlockIcons.MACHINE_CASINGS[this.mTier][i - + 1], this.mInventory.length > 4 ? BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier] : BlockIcons.OVERLAYS_ENERGY_OUT[this.mTier]}; - } - - return rTextures; - } - - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - return this.mTextures[aSide == aFacing ? 1 : 0][aColorIndex + 1]; - } - - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_BasicBreaker(this.mName, this.mTier, this.mDescriptionArray, this.mTextures, this.mInventory.length); - } - - public boolean isSimpleMachine() { - return false; - } - - public boolean isElectric() { - return true; - } - - public boolean isValidSlot(int aIndex) { - return true; - } - - public boolean isFacingValid(byte aFacing) { - return true; - } - - public boolean isEnetInput() { - return true; - } - - public boolean isEnetOutput() { - return true; - } - - public boolean isInputFacing(byte aSide) { - return aSide != this.getBaseMetaTileEntity().getFrontFacing(); - } - - public boolean isOutputFacing(byte aSide) { - return aSide == this.getBaseMetaTileEntity().getFrontFacing(); - } - - public boolean isTeleporterCompatible() { - return false; - } - - public long getMinimumStoredEU() { - return GT_Values.V[this.mTier] * 16L * 16; - } - - public long maxEUStore() { - return GT_Values.V[this.mTier] * 64L * 16; - } - - public long maxEUInput() { - return GT_Values.V[this.mTier] * 16; - } - - public long maxEUOutput() { - return GT_Values.V[this.mTier]; - } - - public long maxAmperesIn() { - return 16; - } - - public long maxAmperesOut() { - return 16; - } - - public int rechargerSlotStartIndex() { - return 0; - } - - public int dechargerSlotStartIndex() { - return 0; - } - - public int rechargerSlotCount() { - return 0; - } - - public int dechargerSlotCount() { - return 0; - } - - public int getProgresstime() { - return (int) this.getBaseMetaTileEntity().getUniversalEnergyStored(); - } - - public int maxProgresstime() { - return (int) this.getBaseMetaTileEntity().getUniversalEnergyCapacity(); - } - - public boolean isAccessAllowed(EntityPlayer aPlayer) { - return true; - } - - public void saveNBTData(NBTTagCompound aNBT) { - } - - public void loadNBTData(NBTTagCompound aNBT) { - } - - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) { - return true; - } - else { - aBaseMetaTileEntity.openGUI(aPlayer); - return true; - } - } - - public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_Container_4by4(aPlayerInventory, aBaseMetaTileEntity); - } - - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_4by4(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName()); - } - - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - super.onPostTick(aBaseMetaTileEntity, aTick); - if (aBaseMetaTileEntity.isServerSide()) { - /*this.mCharge = aBaseMetaTileEntity.getStoredEU() / 2L > aBaseMetaTileEntity.getEUCapacity() / 3L; - this.mDecharge = aBaseMetaTileEntity.getStoredEU() < aBaseMetaTileEntity.getEUCapacity() / 3L; - this.mBatteryCount = 0; - this.mChargeableCount = 0; - ItemStack[] arg3 = this.mInventory; - int arg4 = arg3.length; - - for (int arg5 = 0; arg5 < arg4; ++arg5) { - ItemStack tStack = arg3[arg5]; - if (GT_ModHandler.isElectricItem(tStack, this.mTier)) { - if (GT_ModHandler.isChargerItem(tStack)) { - ++this.mBatteryCount; - } - - ++this.mChargeableCount; - } - }*/ - } - - } - - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return false; - } - - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return true; - } - - public int getInventoryStackLimit() { - return 1; - } - - public long[] getStoredEnergy() { - boolean scaleOverflow = false; - boolean storedOverflow = false; - long tScale = this.getBaseMetaTileEntity().getEUCapacity(); - long tStored = this.getBaseMetaTileEntity().getStoredEU(); - long tStep = 0L; - if (this.mInventory != null) { - ItemStack[] arg8 = this.mInventory; - int arg9 = arg8.length; - - for (int arg10 = 0; arg10 < arg9; ++arg10) { - ItemStack aStack = arg8[arg10]; - if (GT_ModHandler.isElectricItem(aStack)) { - if (aStack.getItem() instanceof GT_MetaBase_Item) { - Long[] stats = ((GT_MetaBase_Item) aStack.getItem()).getElectricStats(aStack); - if (stats != null) { - if (stats[0].longValue() > 4611686018427387903L) { - scaleOverflow = true; - } - - tScale += stats[0].longValue(); - tStep = ((GT_MetaBase_Item) aStack.getItem()).getRealCharge(aStack); - if (tStep > 4611686018427387903L) { - storedOverflow = true; - } - - tStored += tStep; - } - } - else if (aStack.getItem() instanceof IElectricItem) { - tStored += (long) ElectricItem.manager.getCharge(aStack); - tScale += (long) ((IElectricItem) aStack.getItem()).getMaxCharge(aStack); - } - } - } - } - - if (scaleOverflow) { - tScale = Long.MAX_VALUE; - } - - if (storedOverflow) { - tStored = Long.MAX_VALUE; - } - - return new long[]{tStored, tScale}; - } - - public String[] getInfoData() { - return new String[]{"Tile Type: " + this.getTileEntityBaseType()}; - } - - public boolean isGivingInformation() { - return true; - } - - public boolean doesExplode() { - return true; - } + public boolean mCharge = false; + public boolean mDecharge = false; + public int mBatteryCount = 0; + public int mChargeableCount = 0; + private long count = 0L; + private long mStored = 0L; + private long mMax = 0L; + + public GT_MetaTileEntity_BasicBreaker( + int aID, String aName, String aNameRegional, int aTier, String aDescription, int aSlotCount) { + super(aID, aName, aNameRegional, aTier, aSlotCount, aDescription, new ITexture[0]); + } + + public GT_MetaTileEntity_BasicBreaker( + String aName, int aTier, String aDescription, ITexture[][][] aTextures, int aSlotCount) { + super(aName, aTier, aSlotCount, aDescription, aTextures); + } + + public GT_MetaTileEntity_BasicBreaker( + String aName, int aTier, String[] aDescription, ITexture[][][] aTextures, int aSlotCount) { + super(aName, aTier, aSlotCount, aDescription, aTextures); + } + + public String[] getDescription() { + final String[] desc = new String[6]; + int tTier = this.mTier; + desc[0] = "" + EnumChatFormatting.BOLD + "16 Fuse Slots"; + desc[1] = "Per each fuse, you may insert " + EnumChatFormatting.YELLOW + (GT_Values.V[tTier]) + + EnumChatFormatting.GRAY + " EU/t"; + desc[2] = "However this " + EnumChatFormatting.ITALIC + EnumChatFormatting.RED + "MUST" + + EnumChatFormatting.GRAY + " be in a single Amp"; + desc[3] = "This machine can accept upto a single amp of " + GT_Values.VN[Math.min(tTier + 2, 15)] + + " as a result"; + desc[4] = "Breaker Loss: " + EnumChatFormatting.RED + "" + (GT_Values.V[tTier] / 16) + EnumChatFormatting.GRAY + + " EU/t"; + desc[5] = CORE.GT_Tooltip; + return desc; + } + + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + ITexture[][][] rTextures = new ITexture[2][17][]; + + for (byte i = -1; i < 16; ++i) { + rTextures[0][i + 1] = new ITexture[] { + BlockIcons.MACHINE_CASINGS[this.mTier][i + 1], + this.mInventory.length > 4 + ? BlockIcons.OVERLAYS_ENERGY_IN_MULTI[Math.min(12, mTier)] + : BlockIcons.OVERLAYS_ENERGY_IN[Math.min(12, mTier)] + }; + + rTextures[1][i + 1] = new ITexture[] { + BlockIcons.MACHINE_CASINGS[this.mTier][i + 1], + this.mInventory.length > 4 + ? BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier] + : BlockIcons.OVERLAYS_ENERGY_OUT[this.mTier] + }; + } + + return rTextures; + } + + public ITexture[] getTexture( + IGregTechTileEntity aBaseMetaTileEntity, + byte aSide, + byte aFacing, + byte aColorIndex, + boolean aActive, + boolean aRedstone) { + return this.mTextures[aSide == aFacing ? 1 : 0][aColorIndex + 1]; + } + + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_BasicBreaker( + this.mName, this.mTier, this.mDescriptionArray, this.mTextures, this.mInventory.length); + } + + public boolean isSimpleMachine() { + return false; + } + + public boolean isElectric() { + return true; + } + + public boolean isValidSlot(int aIndex) { + return true; + } + + public boolean isFacingValid(byte aFacing) { + return true; + } + + public boolean isEnetInput() { + return true; + } + + public boolean isEnetOutput() { + return true; + } + + public boolean isInputFacing(byte aSide) { + return aSide != this.getBaseMetaTileEntity().getFrontFacing(); + } + + public boolean isOutputFacing(byte aSide) { + return aSide == this.getBaseMetaTileEntity().getFrontFacing(); + } + + public boolean isTeleporterCompatible() { + return false; + } + + public long getMinimumStoredEU() { + return GT_Values.V[this.mTier] * 16L * 16; + } + + public long maxEUStore() { + return GT_Values.V[this.mTier] * 64L * 16; + } + + public long maxEUInput() { + return GT_Values.V[this.mTier] * 16; + } + + public long maxEUOutput() { + return GT_Values.V[this.mTier]; + } + + public long maxAmperesIn() { + return 16; + } + + public long maxAmperesOut() { + return 16; + } + + public int rechargerSlotStartIndex() { + return 0; + } + + public int dechargerSlotStartIndex() { + return 0; + } + + public int rechargerSlotCount() { + return 0; + } + + public int dechargerSlotCount() { + return 0; + } + + public int getProgresstime() { + return (int) this.getBaseMetaTileEntity().getUniversalEnergyStored(); + } + + public int maxProgresstime() { + return (int) this.getBaseMetaTileEntity().getUniversalEnergyCapacity(); + } + + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + public void saveNBTData(NBTTagCompound aNBT) {} + + public void loadNBTData(NBTTagCompound aNBT) {} + + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } else { + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + } + + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_Container_4by4(aPlayerInventory, aBaseMetaTileEntity); + } + + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_4by4(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName()); + } + + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + if (aBaseMetaTileEntity.isServerSide()) { + /*this.mCharge = aBaseMetaTileEntity.getStoredEU() / 2L > aBaseMetaTileEntity.getEUCapacity() / 3L; + this.mDecharge = aBaseMetaTileEntity.getStoredEU() < aBaseMetaTileEntity.getEUCapacity() / 3L; + this.mBatteryCount = 0; + this.mChargeableCount = 0; + ItemStack[] arg3 = this.mInventory; + int arg4 = arg3.length; + + for (int arg5 = 0; arg5 < arg4; ++arg5) { + ItemStack tStack = arg3[arg5]; + if (GT_ModHandler.isElectricItem(tStack, this.mTier)) { + if (GT_ModHandler.isChargerItem(tStack)) { + ++this.mBatteryCount; + } + + ++this.mChargeableCount; + } + }*/ + } + } + + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return false; + } + + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return true; + } + + public int getInventoryStackLimit() { + return 1; + } + + public long[] getStoredEnergy() { + boolean scaleOverflow = false; + boolean storedOverflow = false; + long tScale = this.getBaseMetaTileEntity().getEUCapacity(); + long tStored = this.getBaseMetaTileEntity().getStoredEU(); + long tStep = 0L; + if (this.mInventory != null) { + ItemStack[] arg8 = this.mInventory; + int arg9 = arg8.length; + + for (int arg10 = 0; arg10 < arg9; ++arg10) { + ItemStack aStack = arg8[arg10]; + if (GT_ModHandler.isElectricItem(aStack)) { + if (aStack.getItem() instanceof GT_MetaBase_Item) { + Long[] stats = ((GT_MetaBase_Item) aStack.getItem()).getElectricStats(aStack); + if (stats != null) { + if (stats[0].longValue() > 4611686018427387903L) { + scaleOverflow = true; + } + + tScale += stats[0].longValue(); + tStep = ((GT_MetaBase_Item) aStack.getItem()).getRealCharge(aStack); + if (tStep > 4611686018427387903L) { + storedOverflow = true; + } + + tStored += tStep; + } + } else if (aStack.getItem() instanceof IElectricItem) { + tStored += (long) ElectricItem.manager.getCharge(aStack); + tScale += (long) ((IElectricItem) aStack.getItem()).getMaxCharge(aStack); + } + } + } + } + + if (scaleOverflow) { + tScale = Long.MAX_VALUE; + } + + if (storedOverflow) { + tStored = Long.MAX_VALUE; + } + + return new long[] {tStored, tScale}; + } + + public String[] getInfoData() { + return new String[] {"Tile Type: " + this.getTileEntityBaseType()}; + } + + public boolean isGivingInformation() { + return true; + } + + public boolean doesExplode() { + return true; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GTPP_Recipe.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GTPP_Recipe.java index 18665538d0..cf92bdc0ba 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GTPP_Recipe.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GTPP_Recipe.java @@ -5,34 +5,120 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachin import gregtech.api.util.GT_Recipe.GT_Recipe_Map; public class GT_MetaTileEntity_BasicMachine_GTPP_Recipe extends GT_MetaTileEntity_BasicMachine_GT_Recipe { - - public GT_MetaTileEntity_BasicMachine_GTPP_Recipe(int aID, String aName, String aNameRegional, int aTier, - String aDescription, GT_Recipe_Map aRecipes, int aInputSlots, int aOutputSlots, int aTankCapacity, - int aGUIParameterA, int aGUIParameterB, String aGUIName, String aSound, boolean aSharedTank, - boolean aRequiresFluidForFiltering, int aSpecialEffect, String aOverlays, Object[] aRecipe) { - super(aID, aName, aNameRegional, aTier, aDescription, aRecipes, aInputSlots, aOutputSlots, aTankCapacity, - aGUIParameterA, aGUIParameterB, aGUIName, aSound, aSharedTank, aRequiresFluidForFiltering, aSpecialEffect, - aOverlays, aRecipe); - } - public GT_MetaTileEntity_BasicMachine_GTPP_Recipe(String aName, int aTier, String aDescription, - GT_Recipe_Map aRecipes, int aInputSlots, int aOutputSlots, int aTankCapacity, int aAmperage, - int aGUIParameterA, int aGUIParameterB, ITexture[][][] aTextures, String aGUIName, String aNEIName, - String aSound, boolean aSharedTank, boolean aRequiresFluidForFiltering, int aSpecialEffect) { - super(aName, aTier, aDescription, aRecipes, aInputSlots, aOutputSlots, aTankCapacity, aAmperage, aGUIParameterA, - aGUIParameterB, aTextures, aGUIName, aNEIName, aSound, aSharedTank, aRequiresFluidForFiltering, aSpecialEffect); - } - - public GT_MetaTileEntity_BasicMachine_GTPP_Recipe(String aName, int aTier, String[] aDescription, - GT_Recipe_Map aRecipes, int aInputSlots, int aOutputSlots, int aTankCapacity, int aAmperage, - int aGUIParameterA, int aGUIParameterB, ITexture[][][] aTextures, String aGUIName, String aNEIName, - String aSound, boolean aSharedTank, boolean aRequiresFluidForFiltering, int aSpecialEffect) { - super(aName, aTier, aDescription[0], aRecipes, aInputSlots, aOutputSlots, aTankCapacity, aAmperage, aGUIParameterA, - aGUIParameterB, aTextures, aGUIName, aNEIName, aSound, aSharedTank, aRequiresFluidForFiltering, aSpecialEffect); - } + public GT_MetaTileEntity_BasicMachine_GTPP_Recipe( + int aID, + String aName, + String aNameRegional, + int aTier, + String aDescription, + GT_Recipe_Map aRecipes, + int aInputSlots, + int aOutputSlots, + int aTankCapacity, + int aGUIParameterA, + int aGUIParameterB, + String aGUIName, + String aSound, + boolean aSharedTank, + boolean aRequiresFluidForFiltering, + int aSpecialEffect, + String aOverlays, + Object[] aRecipe) { + super( + aID, + aName, + aNameRegional, + aTier, + aDescription, + aRecipes, + aInputSlots, + aOutputSlots, + aTankCapacity, + aGUIParameterA, + aGUIParameterB, + aGUIName, + aSound, + aSharedTank, + aRequiresFluidForFiltering, + aSpecialEffect, + aOverlays, + aRecipe); + } - - - + public GT_MetaTileEntity_BasicMachine_GTPP_Recipe( + String aName, + int aTier, + String aDescription, + GT_Recipe_Map aRecipes, + int aInputSlots, + int aOutputSlots, + int aTankCapacity, + int aAmperage, + int aGUIParameterA, + int aGUIParameterB, + ITexture[][][] aTextures, + String aGUIName, + String aNEIName, + String aSound, + boolean aSharedTank, + boolean aRequiresFluidForFiltering, + int aSpecialEffect) { + super( + aName, + aTier, + aDescription, + aRecipes, + aInputSlots, + aOutputSlots, + aTankCapacity, + aAmperage, + aGUIParameterA, + aGUIParameterB, + aTextures, + aGUIName, + aNEIName, + aSound, + aSharedTank, + aRequiresFluidForFiltering, + aSpecialEffect); + } + public GT_MetaTileEntity_BasicMachine_GTPP_Recipe( + String aName, + int aTier, + String[] aDescription, + GT_Recipe_Map aRecipes, + int aInputSlots, + int aOutputSlots, + int aTankCapacity, + int aAmperage, + int aGUIParameterA, + int aGUIParameterB, + ITexture[][][] aTextures, + String aGUIName, + String aNEIName, + String aSound, + boolean aSharedTank, + boolean aRequiresFluidForFiltering, + int aSpecialEffect) { + super( + aName, + aTier, + aDescription[0], + aRecipes, + aInputSlots, + aOutputSlots, + aTankCapacity, + aAmperage, + aGUIParameterA, + aGUIParameterB, + aTextures, + aGUIName, + aNEIName, + aSound, + aSharedTank, + aRequiresFluidForFiltering, + aSpecialEffect); + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Dehydrator.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Dehydrator.java index aebf188fc0..02f0a3ff40 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Dehydrator.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Dehydrator.java @@ -19,51 +19,105 @@ import gtPlusPlus.core.lib.CORE; @SuppressWarnings("deprecation") public class GT_MetaTileEntity_Dehydrator extends GT_MetaTileEntity_BasicMachine_GT_Recipe { - private static final CustomIcon[] sDehydratorOverlays = new CustomIcon[10]; - static { - sDehydratorOverlays[0] = new CustomIcon("basicmachines/microwave/OVERLAY_FRONT"); - sDehydratorOverlays[2] = new CustomIcon("basicmachines/plasma_arc_furnace/OVERLAY_BOTTOM"); - sDehydratorOverlays[3] = new CustomIcon("basicmachines/fluid_heater/OVERLAY_SIDE"); - sDehydratorOverlays[4] = new CustomIcon("basicmachines/chemical_bath/OVERLAY_FRONT"); - sDehydratorOverlays[5] = new CustomIcon("basicmachines/microwave/OVERLAY_FRONT_ACTIVE"); - sDehydratorOverlays[7] = new CustomIcon("basicmachines/plasma_arc_furnace/OVERLAY_BOTTOM_ACTIVE"); - sDehydratorOverlays[8] = new CustomIcon("basicmachines/fluid_heater/OVERLAY_SIDE_ACTIVE"); - sDehydratorOverlays[9] = new CustomIcon("basicmachines/chemical_bath/OVERLAY_FRONT_ACTIVE"); - //3 8 - } - + private static final CustomIcon[] sDehydratorOverlays = new CustomIcon[10]; + + static { + sDehydratorOverlays[0] = new CustomIcon("basicmachines/microwave/OVERLAY_FRONT"); + sDehydratorOverlays[2] = new CustomIcon("basicmachines/plasma_arc_furnace/OVERLAY_BOTTOM"); + sDehydratorOverlays[3] = new CustomIcon("basicmachines/fluid_heater/OVERLAY_SIDE"); + sDehydratorOverlays[4] = new CustomIcon("basicmachines/chemical_bath/OVERLAY_FRONT"); + sDehydratorOverlays[5] = new CustomIcon("basicmachines/microwave/OVERLAY_FRONT_ACTIVE"); + sDehydratorOverlays[7] = new CustomIcon("basicmachines/plasma_arc_furnace/OVERLAY_BOTTOM_ACTIVE"); + sDehydratorOverlays[8] = new CustomIcon("basicmachines/fluid_heater/OVERLAY_SIDE_ACTIVE"); + sDehydratorOverlays[9] = new CustomIcon("basicmachines/chemical_bath/OVERLAY_FRONT_ACTIVE"); + // 3 8 + } + private GT_Recipe_Map xRecipes; - private int xTankCapacity; + private int xTankCapacity; + + public GT_MetaTileEntity_Dehydrator( + int aID, String aName, String aNameRegional, int aTier, String aDescription, int aTankCapacity) { + super( + aID, + aName, + aNameRegional, + aTier, + aDescription, + GTPP_Recipe.GTPP_Recipe_Map.sChemicalDehydratorRecipes, + 2, + 9, + aTankCapacity, + 2, + 5, + "Dehydrator.png", + "UNBOXINATOR", + false, + false, + 0, + "", + null); + xRecipes = GTPP_Recipe.GTPP_Recipe_Map.sChemicalDehydratorRecipes; + xTankCapacity = aTankCapacity; + } - public GT_MetaTileEntity_Dehydrator(int aID, String aName, String aNameRegional, int aTier, String aDescription, int aTankCapacity) { - super(aID, aName, aNameRegional, aTier, aDescription, GTPP_Recipe.GTPP_Recipe_Map.sChemicalDehydratorRecipes, 2, 9, aTankCapacity, 2, 5, "Dehydrator.png", "UNBOXINATOR", false, false, 0, "", null); - xRecipes = GTPP_Recipe.GTPP_Recipe_Map.sChemicalDehydratorRecipes; - xTankCapacity = aTankCapacity; - } + public GT_MetaTileEntity_Dehydrator( + String aName, + int aTier, + String[] aDescription, + GT_Recipe.GT_Recipe_Map aRecipes, + int aTankCapacity, + int aAmperage, + ITexture[][][] aTextures, + String aGUIName, + String aNEIName) { + super( + aName, + aTier, + aDescription, + aRecipes, + 2, + 9, + aTankCapacity, + aAmperage, + 2, + 5, + aTextures, + aGUIName, + aNEIName, + "", + false, + false, + 0); + } - public GT_MetaTileEntity_Dehydrator(String aName, int aTier, String[] aDescription, GT_Recipe.GT_Recipe_Map aRecipes, int aTankCapacity, int aAmperage, ITexture[][][] aTextures, String aGUIName, String aNEIName) { - super(aName, aTier, aDescription, aRecipes, 2, 9, aTankCapacity, aAmperage, 2, 5, aTextures, aGUIName, aNEIName, "", false, false, 0); - + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_Dehydrator( + this.mName, + this.mTier, + this.mDescriptionArray, + this.xRecipes, + this.xTankCapacity, + this.mAmperage, + this.mTextures, + this.mGUIName, + this.mNEIName); } @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_Dehydrator(this.mName, this.mTier, this.mDescriptionArray, this.xRecipes, this.xTankCapacity, this.mAmperage, this.mTextures, this.mGUIName, this.mNEIName); + public String[] getDescription() { + String[] S = super.getDescription(); + final String[] desc = new String[S.length + 1]; + System.arraycopy(S, 0, desc, 0, S.length); + desc[S.length] = CORE.GT_Tooltip; + return desc; } - - @Override - public String[] getDescription() { - String[] S = super.getDescription(); - final String[] desc = new String[S.length + 1]; - System.arraycopy(S, 0, desc, 0, S.length); - desc[S.length] = CORE.GT_Tooltip; - return desc; - } - @Override - public ITexture[][][] getTextureSet(final ITexture[] aTextures) { - final ITexture[][][] rTextures = new ITexture[15][17][]; - for (byte i = -1; i < 16; i++) { + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + final ITexture[][][] rTextures = new ITexture[15][17][]; + for (byte i = -1; i < 16; i++) { rTextures[0][i + 1] = getSideFacingActive(i); rTextures[1][i + 1] = getSideFacingInactive(i); rTextures[2][i + 1] = getFrontFacingActive(i); @@ -71,93 +125,113 @@ public class GT_MetaTileEntity_Dehydrator extends GT_MetaTileEntity_BasicMachine rTextures[4][i + 1] = getTopFacingActive(i); rTextures[5][i + 1] = getTopFacingInactive(i); rTextures[6][i + 1] = getBottomFacingActive(i); - rTextures[7][i + 1] = getBottomFacingInactive(i); + rTextures[7][i + 1] = getBottomFacingInactive(i); rTextures[8][i + 1] = getBottomFacingPipeActive(i); rTextures[9][i + 1] = getBottomFacingPipeInactive(i); rTextures[10][i + 1] = getTopFacingPipeActive(i); rTextures[11][i + 1] = getTopFacingPipeInactive(i); rTextures[12][i + 1] = getSideFacingPipeActive(i); rTextures[13][i + 1] = getSideFacingPipeInactive(i); - } - return rTextures; - } - - - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { - return super.getTexture(aBaseMetaTileEntity, aSide, aFacing, aColorIndex, aActive, aRedstone); - //return this.mTextures[(aActive ? 5 : 0) + (aSide == aFacing ? 0 : aSide == GT_Utility.getOppositeSide(aFacing) ? 1 : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][aColorIndex + 1]; - } - - @Override - public ITexture[] getFrontFacingInactive(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(sDehydratorOverlays[0])}; - } - - @Override - public ITexture[] getBottomFacingInactive(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(sDehydratorOverlays[2])}; - } - - @Override - public ITexture[] getTopFacingInactive(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(sDehydratorOverlays[3])}; - } - - @Override - public ITexture[] getSideFacingInactive(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(sDehydratorOverlays[4])}; - } - - @Override - public ITexture[] getFrontFacingActive(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(sDehydratorOverlays[5])}; - } - - @Override - public ITexture[] getBottomFacingActive(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(sDehydratorOverlays[7])}; - } - - @Override - public ITexture[] getTopFacingActive(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(sDehydratorOverlays[8])}; - } - - @Override - public ITexture[] getSideFacingActive(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(sDehydratorOverlays[9])}; - } - - @Override + } + return rTextures; + } + + @Override + public ITexture[] getTexture( + final IGregTechTileEntity aBaseMetaTileEntity, + final byte aSide, + final byte aFacing, + final byte aColorIndex, + final boolean aActive, + final boolean aRedstone) { + return super.getTexture(aBaseMetaTileEntity, aSide, aFacing, aColorIndex, aActive, aRedstone); + // return this.mTextures[(aActive ? 5 : 0) + (aSide == aFacing ? 0 : aSide == + // GT_Utility.getOppositeSide(aFacing) ? 1 : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][aColorIndex + 1]; + } + + @Override + public ITexture[] getFrontFacingInactive(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(sDehydratorOverlays[0]) + }; + } + + @Override + public ITexture[] getBottomFacingInactive(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(sDehydratorOverlays[2]) + }; + } + + @Override + public ITexture[] getTopFacingInactive(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(sDehydratorOverlays[3]) + }; + } + + @Override + public ITexture[] getSideFacingInactive(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(sDehydratorOverlays[4]) + }; + } + + @Override + public ITexture[] getFrontFacingActive(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(sDehydratorOverlays[5]) + }; + } + + @Override + public ITexture[] getBottomFacingActive(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(sDehydratorOverlays[7]) + }; + } + + @Override + public ITexture[] getTopFacingActive(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(sDehydratorOverlays[8]) + }; + } + + @Override + public ITexture[] getSideFacingActive(final byte aColor) { + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(sDehydratorOverlays[9]) + }; + } + + @Override public ITexture[] getBottomFacingPipeActive(byte aColor) { - return new ITexture[]{MACHINE_CASINGS[mTier][aColor + 1], TextureFactory.of(OVERLAY_PIPE_OUT)}; + return new ITexture[] {MACHINE_CASINGS[mTier][aColor + 1], TextureFactory.of(OVERLAY_PIPE_OUT)}; } - @Override + @Override public ITexture[] getBottomFacingPipeInactive(byte aColor) { - return new ITexture[]{MACHINE_CASINGS[mTier][aColor + 1], TextureFactory.of(OVERLAY_PIPE_OUT)}; + return new ITexture[] {MACHINE_CASINGS[mTier][aColor + 1], TextureFactory.of(OVERLAY_PIPE_OUT)}; } - @Override + @Override public ITexture[] getTopFacingPipeActive(byte aColor) { - return new ITexture[]{MACHINE_CASINGS[mTier][aColor + 1], TextureFactory.of(OVERLAY_PIPE_OUT)}; + return new ITexture[] {MACHINE_CASINGS[mTier][aColor + 1], TextureFactory.of(OVERLAY_PIPE_OUT)}; } - @Override + @Override public ITexture[] getTopFacingPipeInactive(byte aColor) { - return new ITexture[]{MACHINE_CASINGS[mTier][aColor + 1], TextureFactory.of(OVERLAY_PIPE_OUT)}; + return new ITexture[] {MACHINE_CASINGS[mTier][aColor + 1], TextureFactory.of(OVERLAY_PIPE_OUT)}; } - @Override + @Override public ITexture[] getSideFacingPipeActive(byte aColor) { - return new ITexture[]{MACHINE_CASINGS[mTier][aColor + 1], TextureFactory.of(OVERLAY_PIPE_OUT)}; + return new ITexture[] {MACHINE_CASINGS[mTier][aColor + 1], TextureFactory.of(OVERLAY_PIPE_OUT)}; } - @Override + @Override public ITexture[] getSideFacingPipeInactive(byte aColor) { - return new ITexture[]{MACHINE_CASINGS[mTier][aColor + 1], TextureFactory.of(OVERLAY_PIPE_OUT)}; - } - + return new ITexture[] {MACHINE_CASINGS[mTier][aColor + 1], TextureFactory.of(OVERLAY_PIPE_OUT)}; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_DeluxeMachine.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_DeluxeMachine.java index 79238240d2..007e6a1761 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_DeluxeMachine.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_DeluxeMachine.java @@ -2,14 +2,6 @@ package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; import static gregtech.api.enums.GT_Values.V; -import java.util.Arrays; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; - import gregtech.api.GregTech_API; import gregtech.api.enums.ItemList; import gregtech.api.enums.Textures; @@ -23,9 +15,14 @@ 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 gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.random.XSTR; +import java.util.Arrays; +import net.minecraft.entity.player.EntityPlayer; +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.DimensionManager; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; @@ -41,14 +38,20 @@ public abstract class GT_MetaTileEntity_DeluxeMachine extends GT_MetaTileEntity_ /** * return values for checkRecipe() */ - protected static final int - DID_NOT_FIND_RECIPE = 0, + protected static final int DID_NOT_FIND_RECIPE = 0, FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS = 1, FOUND_AND_SUCCESSFULLY_USED_RECIPE = 2; + public static final int OTHER_SLOT_COUNT = 4; public final ItemStack[] mOutputItems; public final int mInputSlotCount, mAmperage; - public boolean mAllowInputFromOutputSide = false, mFluidTransfer = false, mItemTransfer = false, mHasBeenUpdated = false, mStuttering = false, mCharge = false, mDecharge = false; + public boolean mAllowInputFromOutputSide = false, + mFluidTransfer = false, + mItemTransfer = false, + mHasBeenUpdated = false, + mStuttering = false, + mCharge = false, + mDecharge = false; public int mMainFacing = -1, mProgresstime = 0, mMaxProgresstime = 0, mEUt = 0, mOutputBlocked = 0; public FluidStack mOutputFluid; public String mGUIName = "", mNEIName = ""; @@ -56,6 +59,7 @@ public abstract class GT_MetaTileEntity_DeluxeMachine extends GT_MetaTileEntity_ * Contains the Recipe which has been previously used, or null if there was no previous Recipe, which could have been buffered */ protected GT_Recipe mLastRecipe = null; + private FluidStack mFluidOut; /** @@ -75,8 +79,26 @@ public abstract class GT_MetaTileEntity_DeluxeMachine extends GT_MetaTileEntity_ * 12 = SideFacingPipeActive * 13 = SideFacingPipeInactive */ - public GT_MetaTileEntity_DeluxeMachine(int aID, String aName, String aNameRegional, int aTier, int aAmperage, String aDescription, int aInputSlotCount, int aOutputSlotCount, String aGUIName, String aNEIName, ITexture... aOverlays) { - super(aID, aName, aNameRegional, aTier, OTHER_SLOT_COUNT + aInputSlotCount + aOutputSlotCount + 1, aDescription, aOverlays); + public GT_MetaTileEntity_DeluxeMachine( + int aID, + String aName, + String aNameRegional, + int aTier, + int aAmperage, + String aDescription, + int aInputSlotCount, + int aOutputSlotCount, + String aGUIName, + String aNEIName, + ITexture... aOverlays) { + super( + aID, + aName, + aNameRegional, + aTier, + OTHER_SLOT_COUNT + aInputSlotCount + aOutputSlotCount + 1, + aDescription, + aOverlays); mInputSlotCount = Math.max(0, aInputSlotCount); mOutputItems = new ItemStack[Math.max(0, aOutputSlotCount)]; mAmperage = aAmperage; @@ -84,7 +106,16 @@ public abstract class GT_MetaTileEntity_DeluxeMachine extends GT_MetaTileEntity_ mNEIName = aNEIName; } - public GT_MetaTileEntity_DeluxeMachine(String aName, int aTier, int aAmperage, String aDescription, ITexture[][][] aTextures, int aInputSlotCount, int aOutputSlotCount, String aGUIName, String aNEIName) { + public GT_MetaTileEntity_DeluxeMachine( + String aName, + int aTier, + int aAmperage, + String aDescription, + ITexture[][][] aTextures, + int aInputSlotCount, + int aOutputSlotCount, + String aGUIName, + String aNEIName) { super(aName, aTier, OTHER_SLOT_COUNT + aInputSlotCount + aOutputSlotCount + 1, aDescription, aTextures); mInputSlotCount = Math.max(0, aInputSlotCount); mOutputItems = new ItemStack[Math.max(0, aOutputSlotCount)]; @@ -92,15 +123,15 @@ public abstract class GT_MetaTileEntity_DeluxeMachine extends GT_MetaTileEntity_ mGUIName = aGUIName; mNEIName = aNEIName; } - - public boolean setMainFacing(byte aDirection){ - mMainFacing = aDirection; - if(getBaseMetaTileEntity().getFrontFacing() == mMainFacing){ - getBaseMetaTileEntity().setFrontFacing(GT_Utility.getOppositeSide(aDirection)); - } + + public boolean setMainFacing(byte aDirection) { + mMainFacing = aDirection; + if (getBaseMetaTileEntity().getFrontFacing() == mMainFacing) { + getBaseMetaTileEntity().setFrontFacing(GT_Utility.getOppositeSide(aDirection)); + } onFacingChange(); onMachineBlockUpdate(); - return true; + return true; } @Override @@ -109,10 +140,12 @@ public abstract class GT_MetaTileEntity_DeluxeMachine extends GT_MetaTileEntity_ aTextures = Arrays.copyOf(aTextures, 14); for (int i = 0; i < aTextures.length; i++) - if (aTextures[i] != null) for (byte c = -1; c < 16; c++) { - if (rTextures[i][c + 1] == null) - rTextures[i][c + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][c + 1], aTextures[i]}; - } + if (aTextures[i] != null) + for (byte c = -1; c < 16; c++) { + if (rTextures[i][c + 1] == null) + rTextures[i][c + 1] = + new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][c + 1], aTextures[i]}; + } for (byte c = -1; c < 16; c++) { if (rTextures[0][c + 1] == null) rTextures[0][c + 1] = getSideFacingActive(c); @@ -134,8 +167,28 @@ public abstract class GT_MetaTileEntity_DeluxeMachine extends GT_MetaTileEntity_ } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - return mTextures[mMainFacing < 2 ? aSide == aFacing ? aActive ? 2 : 3 : aSide == 0 ? aActive ? 6 : 7 : aSide == 1 ? aActive ? 4 : 5 : aActive ? 0 : 1 : aSide == mMainFacing ? aActive ? 2 : 3 : (showPipeFacing() && aSide == aFacing) ? aSide == 0 ? aActive ? 8 : 9 : aSide == 1 ? aActive ? 10 : 11 : aActive ? 12 : 13 : aSide == 0 ? aActive ? 6 : 7 : aSide == 1 ? aActive ? 4 : 5 : aActive ? 0 : 1][aColorIndex + 1]; + public ITexture[] getTexture( + IGregTechTileEntity aBaseMetaTileEntity, + byte aSide, + byte aFacing, + byte aColorIndex, + boolean aActive, + boolean aRedstone) { + return mTextures[ + mMainFacing < 2 + ? aSide == aFacing + ? aActive ? 2 : 3 + : aSide == 0 ? aActive ? 6 : 7 : aSide == 1 ? aActive ? 4 : 5 : aActive ? 0 : 1 + : aSide == mMainFacing + ? aActive ? 2 : 3 + : (showPipeFacing() && aSide == aFacing) + ? aSide == 0 + ? aActive ? 8 : 9 + : aSide == 1 ? aActive ? 10 : 11 : aActive ? 12 : 13 + : aSide == 0 + ? aActive ? 6 : 7 + : aSide == 1 ? aActive ? 4 : 5 : aActive ? 0 : 1][ + aColorIndex + 1]; } @Override @@ -160,7 +213,9 @@ public abstract class GT_MetaTileEntity_DeluxeMachine extends GT_MetaTileEntity_ @Override public boolean isValidSlot(int aIndex) { - return aIndex > 0 && super.isValidSlot(aIndex) && aIndex != OTHER_SLOT_COUNT + mInputSlotCount + mOutputItems.length; + return aIndex > 0 + && super.isValidSlot(aIndex) + && aIndex != OTHER_SLOT_COUNT + mInputSlotCount + mOutputItems.length; } @Override @@ -190,7 +245,9 @@ public abstract class GT_MetaTileEntity_DeluxeMachine extends GT_MetaTileEntity_ @Override public boolean isLiquidInput(byte aSide) { - return aSide != mMainFacing && (mAllowInputFromOutputSide || aSide != getBaseMetaTileEntity().getFrontFacing()); + return aSide != mMainFacing + && (mAllowInputFromOutputSide + || aSide != getBaseMetaTileEntity().getFrontFacing()); } @Override @@ -281,7 +338,8 @@ public abstract class GT_MetaTileEntity_DeluxeMachine extends GT_MetaTileEntity_ @Override public boolean isFluidInputAllowed(FluidStack aFluid) { - return getFillableStack() != null || (getRecipeList() != null && getRecipeList().containsInput(aFluid)); + return getFillableStack() != null + || (getRecipeList() != null && getRecipeList().containsInput(aFluid)); } @Override @@ -338,17 +396,17 @@ public abstract class GT_MetaTileEntity_DeluxeMachine extends GT_MetaTileEntity_ @Override public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { if (aBaseMetaTileEntity.isClientSide()) return true; - if(!false) { - aBaseMetaTileEntity.openGUI(aPlayer); - return true; + if (!false) { + aBaseMetaTileEntity.openGUI(aPlayer); + return true; } - for(byte i=0;i < 6; i++){ - if(aBaseMetaTileEntity.getAirAtSide(i)){ - aBaseMetaTileEntity.openGUI(aPlayer); - return true; - } + for (byte i = 0; i < 6; i++) { + if (aBaseMetaTileEntity.getAirAtSide(i)) { + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } } - GT_Utility.sendChatToPlayer(aPlayer,"No free Side!"); + GT_Utility.sendChatToPlayer(aPlayer, "No free Side!"); return true; } @@ -359,7 +417,14 @@ public abstract class GT_MetaTileEntity_DeluxeMachine extends GT_MetaTileEntity_ @Override public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_BasicMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), mGUIName, GT_Utility.isStringValid(mNEIName) ? mNEIName : getRecipeList() != null ? getRecipeList().mUnlocalizedName : ""); + return new GT_GUIContainer_BasicMachine( + aPlayerInventory, + aBaseMetaTileEntity, + getLocalName(), + mGUIName, + GT_Utility.isStringValid(mNEIName) + ? mNEIName + : getRecipeList() != null ? getRecipeList().mUnlocalizedName : ""); } @Override @@ -408,8 +473,8 @@ public abstract class GT_MetaTileEntity_DeluxeMachine extends GT_MetaTileEntity_ super.onPostTick(aBaseMetaTileEntity, aTick); if (aBaseMetaTileEntity.isServerSide()) { - - //Utils.LOG_WARNING("Ticking Tank."); + + // Utils.LOG_WARNING("Ticking Tank."); mCharge = aBaseMetaTileEntity.getStoredEU() / 2 > aBaseMetaTileEntity.getEUCapacity() / 3; mDecharge = aBaseMetaTileEntity.getStoredEU() < aBaseMetaTileEntity.getEUCapacity() / 3; @@ -423,8 +488,8 @@ public abstract class GT_MetaTileEntity_DeluxeMachine extends GT_MetaTileEntity_ if (++mProgresstime >= mMaxProgresstime) { for (int i = 0; i < mOutputItems.length; i++) for (int j = 0; j < mOutputItems.length; j++) - if (aBaseMetaTileEntity.addStackToSlot(getOutputSlot() + ((j + i) % mOutputItems.length), mOutputItems[i])) - break; + if (aBaseMetaTileEntity.addStackToSlot( + getOutputSlot() + ((j + i) % mOutputItems.length), mOutputItems[i])) break; if (mOutputFluid != null) if (getDrainableStack() == null) setDrainableStack(mOutputFluid.copy()); else if (mOutputFluid.isFluidEqual(getDrainableStack())) @@ -440,7 +505,15 @@ public abstract class GT_MetaTileEntity_DeluxeMachine extends GT_MetaTileEntity_ } if (mProgresstime > 5) mStuttering = false; XSTR aXSTR = new XSTR(); - if(false && aXSTR.nextInt(5000)==0)GT_Utility.sendSoundToPlayers(aBaseMetaTileEntity.getWorld(), GregTech_API.sSoundList.get(5), 10.0F, -1.0F, aBaseMetaTileEntity.getXCoord(), aBaseMetaTileEntity.getYCoord(),aBaseMetaTileEntity.getZCoord()); + if (false && aXSTR.nextInt(5000) == 0) + GT_Utility.sendSoundToPlayers( + aBaseMetaTileEntity.getWorld(), + GregTech_API.sSoundList.get(5), + 10.0F, + -1.0F, + aBaseMetaTileEntity.getXCoord(), + aBaseMetaTileEntity.getYCoord(), + aBaseMetaTileEntity.getZCoord()); } else { if (!mStuttering) { stutterProcess(); @@ -455,46 +528,80 @@ public abstract class GT_MetaTileEntity_DeluxeMachine extends GT_MetaTileEntity_ boolean tRemovedOutputFluid = false; Logger.WARNING("R0"); - if (doesAutoOutputFluids() && getDrainableStack() != null && aBaseMetaTileEntity.getFrontFacing() != mMainFacing && (tSucceeded || aTick % 20 == 0)) { + if (doesAutoOutputFluids() + && getDrainableStack() != null + && aBaseMetaTileEntity.getFrontFacing() != mMainFacing + && (tSucceeded || aTick % 20 == 0)) { IFluidHandler tTank = aBaseMetaTileEntity.getITankContainerAtSide(aBaseMetaTileEntity.getFrontFacing()); if (tTank != null) { FluidStack tDrained = drain(1000, false); if (tDrained != null) { - int tFilledAmount = tTank.fill(ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()), tDrained, false); + int tFilledAmount = tTank.fill( + ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()), tDrained, false); if (tFilledAmount > 0) - tTank.fill(ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()), drain(tFilledAmount, true), true); + tTank.fill( + ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()), + drain(tFilledAmount, true), + true); } } if (getDrainableStack() == null) tRemovedOutputFluid = true; } - if (doesAutoOutput() && !isOutputEmpty() && aBaseMetaTileEntity.getFrontFacing() != mMainFacing && (tSucceeded || mOutputBlocked % 300 == 1 || aBaseMetaTileEntity.hasInventoryBeenModified() || aTick % 600 == 0)) { + if (doesAutoOutput() + && !isOutputEmpty() + && aBaseMetaTileEntity.getFrontFacing() != mMainFacing + && (tSucceeded + || mOutputBlocked % 300 == 1 + || aBaseMetaTileEntity.hasInventoryBeenModified() + || aTick % 600 == 0)) { TileEntity tTileEntity2 = aBaseMetaTileEntity.getTileEntityAtSide(aBaseMetaTileEntity.getFrontFacing()); - for (int i = 0, tCosts = 1; i < mOutputItems.length && tCosts > 0 && aBaseMetaTileEntity.isUniversalEnergyStored(128); i++) { - tCosts = GT_Utility.moveOneItemStack(aBaseMetaTileEntity, tTileEntity2, aBaseMetaTileEntity.getFrontFacing(), aBaseMetaTileEntity.getBackFacing(), null, false, (byte) 64, (byte) 1, (byte) 64, (byte) 1); + for (int i = 0, tCosts = 1; + i < mOutputItems.length && tCosts > 0 && aBaseMetaTileEntity.isUniversalEnergyStored(128); + i++) { + tCosts = GT_Utility.moveOneItemStack( + aBaseMetaTileEntity, + tTileEntity2, + aBaseMetaTileEntity.getFrontFacing(), + aBaseMetaTileEntity.getBackFacing(), + null, + false, + (byte) 64, + (byte) 1, + (byte) 64, + (byte) 1); if (tCosts > 0) aBaseMetaTileEntity.decreaseStoredEnergyUnits(tCosts, true); } } - if (mOutputBlocked != 0) if (isOutputEmpty()) mOutputBlocked = 0; - else mOutputBlocked++; + if (mOutputBlocked != 0) + if (isOutputEmpty()) mOutputBlocked = 0; + else mOutputBlocked++; Logger.WARNING("R1"); if (allowToCheckRecipe()) { Logger.WARNING("R2--------------------------------------------------"); - Logger.WARNING("R2: (mMaxProgresstime <= 0 && aBaseMetaTileEntity.isAllowedToWork() && (tRemovedOutputFluid || tSucceeded || aBaseMetaTileEntity.hasInventoryBeenModified() || aTick % 600 == 0 || aBaseMetaTileEntity.hasWorkJustBeenEnabled()) && hasEnoughEnergyToCheckRecipe())"); + Logger.WARNING( + "R2: (mMaxProgresstime <= 0 && aBaseMetaTileEntity.isAllowedToWork() && (tRemovedOutputFluid || tSucceeded || aBaseMetaTileEntity.hasInventoryBeenModified() || aTick % 600 == 0 || aBaseMetaTileEntity.hasWorkJustBeenEnabled()) && hasEnoughEnergyToCheckRecipe())"); Logger.WARNING("R2--------------------------------------------------"); - Logger.WARNING("R2-mMaxProgresstime: "+mMaxProgresstime); - Logger.WARNING("R2-isAllowedToWork(): "+aBaseMetaTileEntity.isAllowedToWork()); + Logger.WARNING("R2-mMaxProgresstime: " + mMaxProgresstime); + Logger.WARNING("R2-isAllowedToWork(): " + aBaseMetaTileEntity.isAllowedToWork()); Logger.WARNING("R2--------------------------------------------------"); - Logger.WARNING("R2-tRemovedOutputFluid: "+tRemovedOutputFluid); - Logger.WARNING("R2-tSucceeded: "+tSucceeded); - Logger.WARNING("R2-hasInventoryBeenModified(): "+aBaseMetaTileEntity.hasInventoryBeenModified()); - Logger.WARNING("R2-(aTick % 600 == 0): "+(aTick % 600 == 0)); - Logger.WARNING("R2-hasWorkJustBeenEnabled(): "+aBaseMetaTileEntity.hasWorkJustBeenEnabled()); + Logger.WARNING("R2-tRemovedOutputFluid: " + tRemovedOutputFluid); + Logger.WARNING("R2-tSucceeded: " + tSucceeded); + Logger.WARNING("R2-hasInventoryBeenModified(): " + aBaseMetaTileEntity.hasInventoryBeenModified()); + Logger.WARNING("R2-(aTick % 600 == 0): " + (aTick % 600 == 0)); + Logger.WARNING("R2-hasWorkJustBeenEnabled(): " + aBaseMetaTileEntity.hasWorkJustBeenEnabled()); Logger.WARNING("R2--------------------------------------------------"); - Logger.WARNING("R2-hasEnoughEnergyToCheckRecipe(): "+hasEnoughEnergyToCheckRecipe()); + Logger.WARNING("R2-hasEnoughEnergyToCheckRecipe(): " + hasEnoughEnergyToCheckRecipe()); Logger.WARNING("R2--------------------------------------------------"); - if (mMaxProgresstime <= 0 && aBaseMetaTileEntity.isAllowedToWork() && (tRemovedOutputFluid || tSucceeded || aBaseMetaTileEntity.hasInventoryBeenModified() || aTick % 600 == 0 || aBaseMetaTileEntity.hasWorkJustBeenEnabled()) && hasEnoughEnergyToCheckRecipe()) { + if (mMaxProgresstime <= 0 + && aBaseMetaTileEntity.isAllowedToWork() + && (tRemovedOutputFluid + || tSucceeded + || aBaseMetaTileEntity.hasInventoryBeenModified() + || aTick % 600 == 0 + || aBaseMetaTileEntity.hasWorkJustBeenEnabled()) + && hasEnoughEnergyToCheckRecipe()) { Logger.WARNING("R3"); if (checkRecipe() == 2) { if (mInventory[3] != null && mInventory[3].stackSize <= 0) mInventory[3] = null; @@ -534,7 +641,7 @@ public abstract class GT_MetaTileEntity_DeluxeMachine extends GT_MetaTileEntity_ } if (mMainFacing >= 2 && !mHasBeenUpdated) { mHasBeenUpdated = true; - //getBaseMetaTileEntity().setFrontFacing(getBaseMetaTileEntity().getBackFacing()); + // getBaseMetaTileEntity().setFrontFacing(getBaseMetaTileEntity().getBackFacing()); } if (displaysInputFluid()) { @@ -543,7 +650,8 @@ public abstract class GT_MetaTileEntity_DeluxeMachine extends GT_MetaTileEntity_ if (ItemList.Display_Fluid.isStackEqual(mInventory[tDisplayStackSlot], true, true)) mInventory[tDisplayStackSlot] = null; } else { - mInventory[tDisplayStackSlot] = GT_Utility.getFluidDisplayStack(getFillableStack(), displaysStackSize()); + mInventory[tDisplayStackSlot] = + GT_Utility.getFluidDisplayStack(getFillableStack(), displaysStackSize()); } } } @@ -589,14 +697,20 @@ public abstract class GT_MetaTileEntity_DeluxeMachine extends GT_MetaTileEntity_ } protected boolean canOutput(GT_Recipe aRecipe) { - return aRecipe != null && (aRecipe.mNeedsEmptyOutput ? isOutputEmpty() && getDrainableStack() == null : canOutput(aRecipe.getFluidOutput(0)) && canOutput(aRecipe.mOutputs)); + return aRecipe != null + && (aRecipe.mNeedsEmptyOutput + ? isOutputEmpty() && getDrainableStack() == null + : canOutput(aRecipe.getFluidOutput(0)) && canOutput(aRecipe.mOutputs)); } protected boolean canOutput(ItemStack... aOutputs) { if (aOutputs == null) return true; ItemStack[] tOutputSlots = getAllOutputs(); for (int i = 0; i < tOutputSlots.length && i < aOutputs.length; i++) - if (tOutputSlots[i] != null && aOutputs[i] != null && (!GT_Utility.areStacksEqual(tOutputSlots[i], aOutputs[i], false) || tOutputSlots[i].stackSize + aOutputs[i].stackSize > tOutputSlots[i].getMaxStackSize())) { + if (tOutputSlots[i] != null + && aOutputs[i] != null + && (!GT_Utility.areStacksEqual(tOutputSlots[i], aOutputs[i], false) + || tOutputSlots[i].stackSize + aOutputs[i].stackSize > tOutputSlots[i].getMaxStackSize())) { mOutputBlocked++; return false; } @@ -604,7 +718,11 @@ public abstract class GT_MetaTileEntity_DeluxeMachine extends GT_MetaTileEntity_ } protected boolean canOutput(FluidStack aOutput) { - return getDrainableStack() == null || aOutput == null || (getDrainableStack().isFluidEqual(aOutput) && (getDrainableStack().amount <= 0 || getDrainableStack().amount + aOutput.amount <= getCapacity())); + return getDrainableStack() == null + || aOutput == null + || (getDrainableStack().isFluidEqual(aOutput) + && (getDrainableStack().amount <= 0 + || getDrainableStack().amount + aOutput.amount <= getCapacity())); } protected ItemStack getInputAt(int aIndex) { @@ -704,13 +822,15 @@ public abstract class GT_MetaTileEntity_DeluxeMachine extends GT_MetaTileEntity_ @Override public String[] getInfoData() { - return new String[]{ - mNEIName, - "Progress:", (mProgresstime / 20) + " secs", - (mMaxProgresstime / 20) + " secs", - "Stored Energy:", - getBaseMetaTileEntity().getStoredEU() + "EU", - getBaseMetaTileEntity().getEUCapacity() + "EU"}; + return new String[] { + mNEIName, + "Progress:", + (mProgresstime / 20) + " secs", + (mMaxProgresstime / 20) + " secs", + "Stored Energy:", + getBaseMetaTileEntity().getStoredEU() + "EU", + getBaseMetaTileEntity().getEUCapacity() + "EU" + }; } @Override @@ -722,13 +842,19 @@ public abstract class GT_MetaTileEntity_DeluxeMachine extends GT_MetaTileEntity_ public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { if (aSide == getBaseMetaTileEntity().getFrontFacing() || aSide == mMainFacing) { mAllowInputFromOutputSide = !mAllowInputFromOutputSide; - GT_Utility.sendChatToPlayer(aPlayer, mAllowInputFromOutputSide ? ("Input from Output Side allowed") : ("Input from Output Side forbidden")); + GT_Utility.sendChatToPlayer( + aPlayer, + mAllowInputFromOutputSide + ? ("Input from Output Side allowed") + : ("Input from Output Side forbidden")); } } @Override public boolean allowCoverOnSide(byte aSide, GT_ItemStack aCoverID) { - return (aSide != mMainFacing || GregTech_API.getCoverBehavior(aCoverID.toStack()).isGUIClickable(aSide, GT_Utility.stackToInt(aCoverID.toStack()), 0, getBaseMetaTileEntity())); + return (aSide != mMainFacing + || GregTech_API.getCoverBehavior(aCoverID.toStack()) + .isGUIClickable(aSide, GT_Utility.stackToInt(aCoverID.toStack()), 0, getBaseMetaTileEntity())); } @Override @@ -738,8 +864,10 @@ public abstract class GT_MetaTileEntity_DeluxeMachine extends GT_MetaTileEntity_ @Override public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - if (aSide == mMainFacing || aIndex < getInputSlot() || aIndex >= getInputSlot() + mInputSlotCount || (!mAllowInputFromOutputSide && aSide == aBaseMetaTileEntity.getFrontFacing())) - return false; + if (aSide == mMainFacing + || aIndex < getInputSlot() + || aIndex >= getInputSlot() + mInputSlotCount + || (!mAllowInputFromOutputSide && aSide == aBaseMetaTileEntity.getFrontFacing())) return false; for (int i = getInputSlot(), j = i + mInputSlotCount; i < j; i++) if (GT_Utility.areStacksEqual(GT_OreDictUnificator.get(aStack), mInventory[i])) return i == aIndex; return true; @@ -765,98 +893,123 @@ public abstract class GT_MetaTileEntity_DeluxeMachine extends GT_MetaTileEntity_ return checkRecipe(false); } - public static boolean isValidForLowGravity(GT_Recipe tRecipe, int dimId){ - return //TODO check or get a better solution - DimensionManager.getProvider(dimId).getClass().getName().contains("Orbit") || - DimensionManager.getProvider(dimId).getClass().getName().endsWith("Space") || - DimensionManager.getProvider(dimId).getClass().getName().endsWith("Asteroids") || - DimensionManager.getProvider(dimId).getClass().getName().endsWith("SS") || - DimensionManager.getProvider(dimId).getClass().getName().contains("SpaceStation"); + public static boolean isValidForLowGravity(GT_Recipe tRecipe, int dimId) { + return // TODO check or get a better solution + DimensionManager.getProvider(dimId).getClass().getName().contains("Orbit") + || DimensionManager.getProvider(dimId).getClass().getName().endsWith("Space") + || DimensionManager.getProvider(dimId).getClass().getName().endsWith("Asteroids") + || DimensionManager.getProvider(dimId).getClass().getName().endsWith("SS") + || DimensionManager.getProvider(dimId).getClass().getName().contains("SpaceStation"); } - /** * * @param skipOC disables OverclockedNess calculation and check - if you do you must implement your own method... * @return */ - public int checkRecipe(boolean skipOC){ + public int checkRecipe(boolean skipOC) { GT_Recipe_Map tMap = getRecipeList(); if (tMap == null) return DID_NOT_FIND_RECIPE; - GT_Recipe tRecipe = tMap.findRecipe(getBaseMetaTileEntity(), mLastRecipe, false, V[mTier], new FluidStack[]{getFillableStack()}, getSpecialSlot(), getAllInputs()); + GT_Recipe tRecipe = tMap.findRecipe( + getBaseMetaTileEntity(), + mLastRecipe, + false, + V[mTier], + new FluidStack[] {getFillableStack()}, + getSpecialSlot(), + getAllInputs()); if (tRecipe == null) return DID_NOT_FIND_RECIPE; - if (false && tRecipe.mSpecialValue == -100 && - !isValidForLowGravity(tRecipe,getBaseMetaTileEntity().getWorld().provider.dimensionId)) + if (false + && tRecipe.mSpecialValue == -100 + && !isValidForLowGravity(tRecipe, getBaseMetaTileEntity().getWorld().provider.dimensionId)) return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; if (tRecipe.mCanBeBuffered) mLastRecipe = tRecipe; if (!canOutput(tRecipe)) { mOutputBlocked++; return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; } - if (!tRecipe.isRecipeInputEqual(true, new FluidStack[]{getFillableStack()}, getAllInputs())) + if (!tRecipe.isRecipeInputEqual(true, new FluidStack[] {getFillableStack()}, getAllInputs())) return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; for (int i = 0; i < mOutputItems.length; i++) if (getBaseMetaTileEntity().getRandomNumber(10000) < tRecipe.getOutputChance(i)) - mOutputItems[i] = tRecipe.getOutput(i); + mOutputItems[i] = tRecipe.getOutput(i); mOutputFluid = tRecipe.getFluidOutput(0); calculateOverclockedNess(tRecipe); return FOUND_AND_SUCCESSFULLY_USED_RECIPE; } public ITexture[] getSideFacingActive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; } public ITexture[] getSideFacingInactive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; } public ITexture[] getFrontFacingActive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; } public ITexture[] getFrontFacingInactive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; } public ITexture[] getTopFacingActive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; } public ITexture[] getTopFacingInactive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; } public ITexture[] getBottomFacingActive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; } public ITexture[] getBottomFacingInactive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; } public ITexture[] getBottomFacingPipeActive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT) + }; } public ITexture[] getBottomFacingPipeInactive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT) + }; } public ITexture[] getTopFacingPipeActive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT) + }; } public ITexture[] getTopFacingPipeInactive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT) + }; } public ITexture[] getSideFacingPipeActive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT) + }; } public ITexture[] getSideFacingPipeInactive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + return new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT) + }; } -}
\ No newline at end of file +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_DeluxeTank.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_DeluxeTank.java index 1e367d4f15..4bd4e30f30 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_DeluxeTank.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_DeluxeTank.java @@ -1,18 +1,16 @@ package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; - import gregtech.api.enums.ItemList; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicTank; import gregtech.api.util.GT_Utility; - import gtPlusPlus.api.objects.Logger; import gtPlusPlus.xmod.gregtech.api.gui.CONTAINER_DeluxeTank; import gtPlusPlus.xmod.gregtech.api.gui.GUI_DeluxeTank; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.fluids.FluidStack; /** @@ -22,324 +20,367 @@ import net.minecraftforge.fluids.FluidStack; */ public abstract class GT_MetaTileEntity_DeluxeTank extends GT_MetaTileEntity_BasicTank { - public FluidStack mFluid2; - - /** - * @param aInvSlotCount should be 3 - */ - public GT_MetaTileEntity_DeluxeTank(final int aID, final String aName, final String aNameRegional, final int aTier, final int aInvSlotCount, final String aDescription, final ITexture... aTextures) { - super(aID, aName, aNameRegional, aTier, aInvSlotCount, aDescription, aTextures); - } - - public GT_MetaTileEntity_DeluxeTank(final String aName, final int aTier, final int aInvSlotCount, final String aDescription, final ITexture[][][] aTextures) { - super(aName, aTier, aInvSlotCount, aDescription, aTextures); - } - - @Override - public boolean isSimpleMachine() { - return false; - } - - @Override - public boolean isValidSlot(final int aIndex) { - return aIndex != this.getStackDisplaySlot(); - } - - @Override - public void saveNBTData(final NBTTagCompound aNBT) { - if (this.mFluid != null) { - aNBT.setTag("mFluid", this.mFluid.writeToNBT(new NBTTagCompound())); - } - if (this.mFluid2 != null) { - aNBT.setTag("mFluid2", this.mFluid2.writeToNBT(new NBTTagCompound())); - } - } - - @Override - public void loadNBTData(final NBTTagCompound aNBT) { - this.mFluid = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mFluid")); - this.mFluid2 = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mFluid2")); - } - - @Override - public abstract boolean doesFillContainers(); - - @Override - public abstract boolean doesEmptyContainers(); - - @Override - public abstract boolean canTankBeFilled(); - - @Override - public abstract boolean canTankBeEmptied(); - - @Override - public abstract boolean displaysItemStack(); - - @Override - public abstract boolean displaysStackSize(); - - @Override - public int getInputSlot() { - return 0; - } - - @Override - public int getOutputSlot() { - return 1; - } - - @Override - public int getStackDisplaySlot() { - return 2; - } - - public int getStackDisplaySlot2() { - return 3; - } - - @Override - public boolean isFluidInputAllowed(final FluidStack aFluid) { - return true; - } - - @Override - public boolean isFluidChangingAllowed() { - return true; - } - - @Override - public FluidStack getFillableStack() { - return this.getFillableStackEx(1); - } - - public FluidStack getFillableStackEx(final int stackID) { - if (stackID <= 1){ - return this.mFluid; - } - return this.mFluid2; - } - - @Override - public FluidStack setFillableStack(final FluidStack aFluid) { - this.mFluid = aFluid; - return this.mFluid; - } - - public FluidStack setFillableStack2(final FluidStack aFluid) { - this.mFluid2 = aFluid; - return this.mFluid2; - } - - @Override - public FluidStack getDrainableStack() { - return this.getDrainableStackEx(1); - } - - public FluidStack getDrainableStackEx(final int stackID) { - if (stackID <= 1){ - return this.mFluid; - } - return this.mFluid2; - } - - @Override - public FluidStack setDrainableStack(final FluidStack aFluid) { - this.mFluid = aFluid; - return this.mFluid; - } - - @Override - public FluidStack getDisplayedFluid() { - return this.getDrainableStack(); - } - - @Override - public Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { - return new CONTAINER_DeluxeTank(aPlayerInventory, aBaseMetaTileEntity); - } - - @Override - public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { - return new GUI_DeluxeTank(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName()); - } - - @Override - public void onPreTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { - if (aBaseMetaTileEntity.isServerSide()) { - if (this.isFluidChangingAllowed() && (this.getFillableStack() != null) && (this.getFillableStack().amount <= 0)) { - this.setFillableStack(null); - } - - if (this.displaysItemStack() && (this.getStackDisplaySlot() >= 0) && (this.getStackDisplaySlot() < this.mInventory.length)) { - if (this.getDisplayedFluid() == null) { - if (ItemList.Display_Fluid.isStackEqual(this.mInventory[this.getStackDisplaySlot()], true, true)) { - this.mInventory[this.getStackDisplaySlot()] = null; - } - } else { - this.mInventory[this.getStackDisplaySlot()] = GT_Utility.getFluidDisplayStack(this.getDisplayedFluid(), this.displaysStackSize()); - } - } - - if (this.displaysItemStack() && (this.getStackDisplaySlot2() >= 0) && (this.getStackDisplaySlot2() < this.mInventory.length)) { - if (this.getDrainableStackEx(2) == null) { - if (ItemList.Display_Fluid.isStackEqual(this.mInventory[this.getStackDisplaySlot2()], true, true)) { - this.mInventory[this.getStackDisplaySlot2()] = null; - } - } else { - this.mInventory[this.getStackDisplaySlot2()] = GT_Utility.getFluidDisplayStack(this.getDrainableStackEx(2), this.displaysStackSize()); - } - } - - if (this.doesEmptyContainers()) { - final FluidStack tFluid = GT_Utility.getFluidForFilledItem(this.mInventory[this.getInputSlot()], true); - if ((tFluid != null) && this.isFluidInputAllowed(tFluid)) { - - if (tFluid.isFluidEqual(this.getDrainableStackEx(1)) || (this.getDrainableStackEx(1) == null)){ - if (this.getFillableStackEx(1) == null) { - if (this.isFluidInputAllowed(tFluid) && (tFluid.amount <= this.getCapacity())) { - if (aBaseMetaTileEntity.addStackToSlot(this.getOutputSlot(), GT_Utility.getContainerItem(this.mInventory[this.getInputSlot()], true), 1)) { - this.setFillableStack(tFluid.copy()); - aBaseMetaTileEntity.decrStackSize(this.getInputSlot(), 1); - } - } - } else { - if (tFluid.isFluidEqual(this.getFillableStack()) && ((tFluid.amount + this.getFillableStack().amount) <= this.getCapacity())) { - if (aBaseMetaTileEntity.addStackToSlot(this.getOutputSlot(), GT_Utility.getContainerItem(this.mInventory[this.getInputSlot()], true), 1)) { - this.getFillableStack().amount += tFluid.amount; - aBaseMetaTileEntity.decrStackSize(this.getInputSlot(), 1); - } - } - } - } - else if (tFluid.isFluidEqual(this.getDrainableStackEx(2)) || (this.getDrainableStackEx(2) == null)){ - if (this.getFillableStackEx(2) == null) { - if (this.isFluidInputAllowed(tFluid) && (tFluid.amount <= this.getCapacity())) { - if (aBaseMetaTileEntity.addStackToSlot(this.getOutputSlot(), GT_Utility.getContainerItem(this.mInventory[this.getInputSlot()], true), 1)) { - this.setFillableStack2(tFluid.copy()); - aBaseMetaTileEntity.decrStackSize(this.getInputSlot(), 1); - } - } - } else { - if (tFluid.isFluidEqual(this.getFillableStackEx(2)) && ((tFluid.amount + this.getFillableStackEx(2).amount) <= this.getCapacity())) { - if (aBaseMetaTileEntity.addStackToSlot(this.getOutputSlot(), GT_Utility.getContainerItem(this.mInventory[this.getInputSlot()], true), 1)) { - this.getFillableStackEx(2).amount += tFluid.amount; - aBaseMetaTileEntity.decrStackSize(this.getInputSlot(), 1); - } - } - } - } - else { - Logger.INFO("Something broke when trying to empty cells between two fluid tank areas."); - } - } - } - - if (this.doesFillContainers()) { - final ItemStack tOutput = GT_Utility.fillFluidContainer(this.getDrainableStack(), this.mInventory[this.getInputSlot()], false, true); - if ((tOutput != null) && aBaseMetaTileEntity.addStackToSlot(this.getOutputSlot(), tOutput, 1)) { - final FluidStack tFluid = GT_Utility.getFluidForFilledItem(tOutput, true); - aBaseMetaTileEntity.decrStackSize(this.getInputSlot(), 1); - if (tFluid != null) { - this.getDrainableStack().amount -= tFluid.amount; - } - if ((this.getDrainableStack().amount <= 0) && this.isFluidChangingAllowed()) { - this.setDrainableStack(null); - } - } - } - } - } - - @Override - public FluidStack getFluid() { - return this.getDrainableStack(); - } - - @Override - public int getFluidAmount() { - return this.getDrainableStack() != null ? this.getDrainableStack().amount : 0; - } - - @Override - public int fill(final FluidStack aFluid, final boolean doFill) { - if ((aFluid == null) || (aFluid.getFluid().getID() <= 0) || (aFluid.amount <= 0) || !this.canTankBeFilled() || !this.isFluidInputAllowed(aFluid)) { - return 0; - } - - if ((this.getFillableStack() == null) || (this.getFillableStack().getFluid().getID() <= 0)) { - if (aFluid.amount <= this.getCapacity()) { - if (doFill) { - this.setFillableStack(aFluid.copy()); - this.getBaseMetaTileEntity().markDirty(); - } - return aFluid.amount; - } - if (doFill) { - this.setFillableStack(aFluid.copy()); - this.getFillableStack().amount = this.getCapacity(); - this.getBaseMetaTileEntity().markDirty(); - } - return this.getCapacity(); - } - - if (!this.getFillableStack().isFluidEqual(aFluid)) { - return 0; - } - - final int space = this.getCapacity() - this.getFillableStack().amount; - if (aFluid.amount <= space) { - if (doFill) { - this.getFillableStack().amount += aFluid.amount; - this.getBaseMetaTileEntity().markDirty(); - } - return aFluid.amount; - } - if (doFill) { - this.getFillableStack().amount = this.getCapacity(); - } - return space; - } - - @Override - public FluidStack drain(final int maxDrain, final boolean doDrain) { - if ((this.getDrainableStack() == null) || !this.canTankBeEmptied()) { - return null; - } - if ((this.getDrainableStack().amount <= 0) && this.isFluidChangingAllowed()) { - this.setDrainableStack(null); - this.getBaseMetaTileEntity().markDirty(); - return null; - } - - int used = maxDrain; - if (this.getDrainableStack().amount < used) { - used = this.getDrainableStack().amount; - } - - if (doDrain) { - this.getDrainableStack().amount -= used; - this.getBaseMetaTileEntity().markDirty(); - } - - final FluidStack drained = this.getDrainableStack().copy(); - drained.amount = used; - - if ((this.getDrainableStack().amount <= 0) && this.isFluidChangingAllowed()) { - this.setDrainableStack(null); - this.getBaseMetaTileEntity().markDirty(); - } - - return drained; - } - - @Override - public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { - return aIndex == this.getOutputSlot(); - } - - @Override - public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { - return aIndex == this.getInputSlot(); - } -}
\ No newline at end of file + public FluidStack mFluid2; + + /** + * @param aInvSlotCount should be 3 + */ + public GT_MetaTileEntity_DeluxeTank( + final int aID, + final String aName, + final String aNameRegional, + final int aTier, + final int aInvSlotCount, + final String aDescription, + final ITexture... aTextures) { + super(aID, aName, aNameRegional, aTier, aInvSlotCount, aDescription, aTextures); + } + + public GT_MetaTileEntity_DeluxeTank( + final String aName, + final int aTier, + final int aInvSlotCount, + final String aDescription, + final ITexture[][][] aTextures) { + super(aName, aTier, aInvSlotCount, aDescription, aTextures); + } + + @Override + public boolean isSimpleMachine() { + return false; + } + + @Override + public boolean isValidSlot(final int aIndex) { + return aIndex != this.getStackDisplaySlot(); + } + + @Override + public void saveNBTData(final NBTTagCompound aNBT) { + if (this.mFluid != null) { + aNBT.setTag("mFluid", this.mFluid.writeToNBT(new NBTTagCompound())); + } + if (this.mFluid2 != null) { + aNBT.setTag("mFluid2", this.mFluid2.writeToNBT(new NBTTagCompound())); + } + } + + @Override + public void loadNBTData(final NBTTagCompound aNBT) { + this.mFluid = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mFluid")); + this.mFluid2 = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mFluid2")); + } + + @Override + public abstract boolean doesFillContainers(); + + @Override + public abstract boolean doesEmptyContainers(); + + @Override + public abstract boolean canTankBeFilled(); + + @Override + public abstract boolean canTankBeEmptied(); + + @Override + public abstract boolean displaysItemStack(); + + @Override + public abstract boolean displaysStackSize(); + + @Override + public int getInputSlot() { + return 0; + } + + @Override + public int getOutputSlot() { + return 1; + } + + @Override + public int getStackDisplaySlot() { + return 2; + } + + public int getStackDisplaySlot2() { + return 3; + } + + @Override + public boolean isFluidInputAllowed(final FluidStack aFluid) { + return true; + } + + @Override + public boolean isFluidChangingAllowed() { + return true; + } + + @Override + public FluidStack getFillableStack() { + return this.getFillableStackEx(1); + } + + public FluidStack getFillableStackEx(final int stackID) { + if (stackID <= 1) { + return this.mFluid; + } + return this.mFluid2; + } + + @Override + public FluidStack setFillableStack(final FluidStack aFluid) { + this.mFluid = aFluid; + return this.mFluid; + } + + public FluidStack setFillableStack2(final FluidStack aFluid) { + this.mFluid2 = aFluid; + return this.mFluid2; + } + + @Override + public FluidStack getDrainableStack() { + return this.getDrainableStackEx(1); + } + + public FluidStack getDrainableStackEx(final int stackID) { + if (stackID <= 1) { + return this.mFluid; + } + return this.mFluid2; + } + + @Override + public FluidStack setDrainableStack(final FluidStack aFluid) { + this.mFluid = aFluid; + return this.mFluid; + } + + @Override + public FluidStack getDisplayedFluid() { + return this.getDrainableStack(); + } + + @Override + public Object getServerGUI( + final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + return new CONTAINER_DeluxeTank(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public Object getClientGUI( + final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_DeluxeTank(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName()); + } + + @Override + public void onPreTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { + if (aBaseMetaTileEntity.isServerSide()) { + if (this.isFluidChangingAllowed() + && (this.getFillableStack() != null) + && (this.getFillableStack().amount <= 0)) { + this.setFillableStack(null); + } + + if (this.displaysItemStack() + && (this.getStackDisplaySlot() >= 0) + && (this.getStackDisplaySlot() < this.mInventory.length)) { + if (this.getDisplayedFluid() == null) { + if (ItemList.Display_Fluid.isStackEqual(this.mInventory[this.getStackDisplaySlot()], true, true)) { + this.mInventory[this.getStackDisplaySlot()] = null; + } + } else { + this.mInventory[this.getStackDisplaySlot()] = + GT_Utility.getFluidDisplayStack(this.getDisplayedFluid(), this.displaysStackSize()); + } + } + + if (this.displaysItemStack() + && (this.getStackDisplaySlot2() >= 0) + && (this.getStackDisplaySlot2() < this.mInventory.length)) { + if (this.getDrainableStackEx(2) == null) { + if (ItemList.Display_Fluid.isStackEqual(this.mInventory[this.getStackDisplaySlot2()], true, true)) { + this.mInventory[this.getStackDisplaySlot2()] = null; + } + } else { + this.mInventory[this.getStackDisplaySlot2()] = + GT_Utility.getFluidDisplayStack(this.getDrainableStackEx(2), this.displaysStackSize()); + } + } + + if (this.doesEmptyContainers()) { + final FluidStack tFluid = GT_Utility.getFluidForFilledItem(this.mInventory[this.getInputSlot()], true); + if ((tFluid != null) && this.isFluidInputAllowed(tFluid)) { + + if (tFluid.isFluidEqual(this.getDrainableStackEx(1)) || (this.getDrainableStackEx(1) == null)) { + if (this.getFillableStackEx(1) == null) { + if (this.isFluidInputAllowed(tFluid) && (tFluid.amount <= this.getCapacity())) { + if (aBaseMetaTileEntity.addStackToSlot( + this.getOutputSlot(), + GT_Utility.getContainerItem(this.mInventory[this.getInputSlot()], true), + 1)) { + this.setFillableStack(tFluid.copy()); + aBaseMetaTileEntity.decrStackSize(this.getInputSlot(), 1); + } + } + } else { + if (tFluid.isFluidEqual(this.getFillableStack()) + && ((tFluid.amount + this.getFillableStack().amount) <= this.getCapacity())) { + if (aBaseMetaTileEntity.addStackToSlot( + this.getOutputSlot(), + GT_Utility.getContainerItem(this.mInventory[this.getInputSlot()], true), + 1)) { + this.getFillableStack().amount += tFluid.amount; + aBaseMetaTileEntity.decrStackSize(this.getInputSlot(), 1); + } + } + } + } else if (tFluid.isFluidEqual(this.getDrainableStackEx(2)) + || (this.getDrainableStackEx(2) == null)) { + if (this.getFillableStackEx(2) == null) { + if (this.isFluidInputAllowed(tFluid) && (tFluid.amount <= this.getCapacity())) { + if (aBaseMetaTileEntity.addStackToSlot( + this.getOutputSlot(), + GT_Utility.getContainerItem(this.mInventory[this.getInputSlot()], true), + 1)) { + this.setFillableStack2(tFluid.copy()); + aBaseMetaTileEntity.decrStackSize(this.getInputSlot(), 1); + } + } + } else { + if (tFluid.isFluidEqual(this.getFillableStackEx(2)) + && ((tFluid.amount + this.getFillableStackEx(2).amount) <= this.getCapacity())) { + if (aBaseMetaTileEntity.addStackToSlot( + this.getOutputSlot(), + GT_Utility.getContainerItem(this.mInventory[this.getInputSlot()], true), + 1)) { + this.getFillableStackEx(2).amount += tFluid.amount; + aBaseMetaTileEntity.decrStackSize(this.getInputSlot(), 1); + } + } + } + } else { + Logger.INFO("Something broke when trying to empty cells between two fluid tank areas."); + } + } + } + + if (this.doesFillContainers()) { + final ItemStack tOutput = GT_Utility.fillFluidContainer( + this.getDrainableStack(), this.mInventory[this.getInputSlot()], false, true); + if ((tOutput != null) && aBaseMetaTileEntity.addStackToSlot(this.getOutputSlot(), tOutput, 1)) { + final FluidStack tFluid = GT_Utility.getFluidForFilledItem(tOutput, true); + aBaseMetaTileEntity.decrStackSize(this.getInputSlot(), 1); + if (tFluid != null) { + this.getDrainableStack().amount -= tFluid.amount; + } + if ((this.getDrainableStack().amount <= 0) && this.isFluidChangingAllowed()) { + this.setDrainableStack(null); + } + } + } + } + } + + @Override + public FluidStack getFluid() { + return this.getDrainableStack(); + } + + @Override + public int getFluidAmount() { + return this.getDrainableStack() != null ? this.getDrainableStack().amount : 0; + } + + @Override + public int fill(final FluidStack aFluid, final boolean doFill) { + if ((aFluid == null) + || (aFluid.getFluid().getID() <= 0) + || (aFluid.amount <= 0) + || !this.canTankBeFilled() + || !this.isFluidInputAllowed(aFluid)) { + return 0; + } + + if ((this.getFillableStack() == null) + || (this.getFillableStack().getFluid().getID() <= 0)) { + if (aFluid.amount <= this.getCapacity()) { + if (doFill) { + this.setFillableStack(aFluid.copy()); + this.getBaseMetaTileEntity().markDirty(); + } + return aFluid.amount; + } + if (doFill) { + this.setFillableStack(aFluid.copy()); + this.getFillableStack().amount = this.getCapacity(); + this.getBaseMetaTileEntity().markDirty(); + } + return this.getCapacity(); + } + + if (!this.getFillableStack().isFluidEqual(aFluid)) { + return 0; + } + + final int space = this.getCapacity() - this.getFillableStack().amount; + if (aFluid.amount <= space) { + if (doFill) { + this.getFillableStack().amount += aFluid.amount; + this.getBaseMetaTileEntity().markDirty(); + } + return aFluid.amount; + } + if (doFill) { + this.getFillableStack().amount = this.getCapacity(); + } + return space; + } + + @Override + public FluidStack drain(final int maxDrain, final boolean doDrain) { + if ((this.getDrainableStack() == null) || !this.canTankBeEmptied()) { + return null; + } + if ((this.getDrainableStack().amount <= 0) && this.isFluidChangingAllowed()) { + this.setDrainableStack(null); + this.getBaseMetaTileEntity().markDirty(); + return null; + } + + int used = maxDrain; + if (this.getDrainableStack().amount < used) { + used = this.getDrainableStack().amount; + } + + if (doDrain) { + this.getDrainableStack().amount -= used; + this.getBaseMetaTileEntity().markDirty(); + } + + final FluidStack drained = this.getDrainableStack().copy(); + drained.amount = used; + + if ((this.getDrainableStack().amount <= 0) && this.isFluidChangingAllowed()) { + this.setDrainableStack(null); + this.getBaseMetaTileEntity().markDirty(); + } + + return drained; + } + + @Override + public boolean allowPullStack( + final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return aIndex == this.getOutputSlot(); + } + + @Override + public boolean allowPutStack( + final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return aIndex == this.getInputSlot(); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_AirIntake.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_AirIntake.java index 02b7a03f3b..6a49e9b84d 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_AirIntake.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_AirIntake.java @@ -11,100 +11,112 @@ import net.minecraftforge.fluids.Fluid; public class GT_MetaTileEntity_Hatch_AirIntake extends GT_MetaTileEntity_Hatch_FluidGenerator { - public GT_MetaTileEntity_Hatch_AirIntake(final int aID, final String aName, final String aNameRegional, final int aTier) { - super(aID, aName, aNameRegional, aTier); - } - - public GT_MetaTileEntity_Hatch_AirIntake(final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures) { - super(aName, aTier, aDescription, aTextures); - } - - - public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_Hatch_AirIntake(this.mName, this.mTier, this.mDescription, this.mTextures); - } - - @Override - public String[] getCustomTooltip() { - String[] aTooltip = new String[3]; - aTooltip[0] = "DO NOT OBSTRUCT THE INPUT!"; - aTooltip[1] = "Draws in Air from the surrounding environment"; - aTooltip[2] = "Creates "+getAmountOfFluidToGenerate()+"L of Air every "+getMaxTickTime()+" ticks"; - return aTooltip; - } - - @Override - public Fluid getFluidToGenerate() { - return FluidUtils.getAir(1).getFluid(); - } - - @Override - public int getAmountOfFluidToGenerate() { - return 1000; - } - - @Override - public int getMaxTickTime() { - return 4; - } - - @Override - public int getCapacity() { - return 128000; - } - - @Override - public boolean doesHatchMeetConditionsToGenerate() { - return this.getBaseMetaTileEntity().getAirAtSide(this.getBaseMetaTileEntity().getFrontFacing()); - } - - @Override - public void generateParticles(World aWorld, String name) { - if (this.getBaseMetaTileEntity().isServerSide()) { - return; - } - final float ran1 = GT_MetaTileEntity_Hatch_AirIntake.floatGen.nextFloat(); - float ran2 = 0.0f; - float ran3 = 0.0f; - ran2 = GT_MetaTileEntity_Hatch_AirIntake.floatGen.nextFloat(); - ran3 = GT_MetaTileEntity_Hatch_AirIntake.floatGen.nextFloat(); - - final IGregTechTileEntity aMuffler = this.getBaseMetaTileEntity(); - final ForgeDirection aDir = ForgeDirection.getOrientation((int) aMuffler.getFrontFacing()); - final float xPos = aDir.offsetX * 0.76f + aMuffler.getXCoord() + 0.25f; - float yPos = aDir.offsetY * 0.76f + aMuffler.getYCoord() + 0.65f; - final float zPos = aDir.offsetZ * 0.76f + aMuffler.getZCoord() + 0.25f; - float ySpd = aDir.offsetY * 0.1f + 0.2f + 0.1f * GT_MetaTileEntity_Hatch_AirIntake.floatGen.nextFloat(); - float xSpd; - float zSpd; - if (aDir.offsetY == -1) { - //Logger.INFO("Y = -1"); - final float temp = GT_MetaTileEntity_Hatch_AirIntake.floatGen.nextFloat() * 2.0f * CORE.PI; - xSpd = (float) Math.sin(temp) * 0.1f; - zSpd = (float) Math.cos(temp) * 0.1f; - ySpd = -ySpd; - yPos = yPos - 0.8f; - } - else { - xSpd = aDir.offsetX * (0.1f + 0.2f * GT_MetaTileEntity_Hatch_AirIntake.floatGen.nextFloat()); - zSpd = aDir.offsetZ * (0.1f + 0.2f * GT_MetaTileEntity_Hatch_AirIntake.floatGen.nextFloat()); - - xSpd = -xSpd; - zSpd = -zSpd; - } - - aWorld.spawnParticle(name, (double) (xPos + ran1 * 0.5f), - (double) (yPos + GT_MetaTileEntity_Hatch_AirIntake.floatGen.nextFloat() * 0.5f), - (double) (zPos + GT_MetaTileEntity_Hatch_AirIntake.floatGen.nextFloat() * 0.5f), (double) xSpd, - (double) -ySpd, (double) zSpd); - aWorld.spawnParticle(name, (double) (xPos + ran2 * 0.5f), - (double) (yPos + GT_MetaTileEntity_Hatch_AirIntake.floatGen.nextFloat() * 0.5f), - (double) (zPos + GT_MetaTileEntity_Hatch_AirIntake.floatGen.nextFloat() * 0.5f), (double) xSpd, - (double) -ySpd, (double) zSpd); - aWorld.spawnParticle(name, (double) (xPos + ran3 * 0.5f), - (double) (yPos + GT_MetaTileEntity_Hatch_AirIntake.floatGen.nextFloat() * 0.5f), - (double) (zPos + GT_MetaTileEntity_Hatch_AirIntake.floatGen.nextFloat() * 0.5f), (double) xSpd, - (double) -ySpd, (double) zSpd); - } - + public GT_MetaTileEntity_Hatch_AirIntake( + final int aID, final String aName, final String aNameRegional, final int aTier) { + super(aID, aName, aNameRegional, aTier); + } + + public GT_MetaTileEntity_Hatch_AirIntake( + final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_Hatch_AirIntake(this.mName, this.mTier, this.mDescription, this.mTextures); + } + + @Override + public String[] getCustomTooltip() { + String[] aTooltip = new String[3]; + aTooltip[0] = "DO NOT OBSTRUCT THE INPUT!"; + aTooltip[1] = "Draws in Air from the surrounding environment"; + aTooltip[2] = "Creates " + getAmountOfFluidToGenerate() + "L of Air every " + getMaxTickTime() + " ticks"; + return aTooltip; + } + + @Override + public Fluid getFluidToGenerate() { + return FluidUtils.getAir(1).getFluid(); + } + + @Override + public int getAmountOfFluidToGenerate() { + return 1000; + } + + @Override + public int getMaxTickTime() { + return 4; + } + + @Override + public int getCapacity() { + return 128000; + } + + @Override + public boolean doesHatchMeetConditionsToGenerate() { + return this.getBaseMetaTileEntity() + .getAirAtSide(this.getBaseMetaTileEntity().getFrontFacing()); + } + + @Override + public void generateParticles(World aWorld, String name) { + if (this.getBaseMetaTileEntity().isServerSide()) { + return; + } + final float ran1 = GT_MetaTileEntity_Hatch_AirIntake.floatGen.nextFloat(); + float ran2 = 0.0f; + float ran3 = 0.0f; + ran2 = GT_MetaTileEntity_Hatch_AirIntake.floatGen.nextFloat(); + ran3 = GT_MetaTileEntity_Hatch_AirIntake.floatGen.nextFloat(); + + final IGregTechTileEntity aMuffler = this.getBaseMetaTileEntity(); + final ForgeDirection aDir = ForgeDirection.getOrientation((int) aMuffler.getFrontFacing()); + final float xPos = aDir.offsetX * 0.76f + aMuffler.getXCoord() + 0.25f; + float yPos = aDir.offsetY * 0.76f + aMuffler.getYCoord() + 0.65f; + final float zPos = aDir.offsetZ * 0.76f + aMuffler.getZCoord() + 0.25f; + float ySpd = aDir.offsetY * 0.1f + 0.2f + 0.1f * GT_MetaTileEntity_Hatch_AirIntake.floatGen.nextFloat(); + float xSpd; + float zSpd; + if (aDir.offsetY == -1) { + // Logger.INFO("Y = -1"); + final float temp = GT_MetaTileEntity_Hatch_AirIntake.floatGen.nextFloat() * 2.0f * CORE.PI; + xSpd = (float) Math.sin(temp) * 0.1f; + zSpd = (float) Math.cos(temp) * 0.1f; + ySpd = -ySpd; + yPos = yPos - 0.8f; + } else { + xSpd = aDir.offsetX * (0.1f + 0.2f * GT_MetaTileEntity_Hatch_AirIntake.floatGen.nextFloat()); + zSpd = aDir.offsetZ * (0.1f + 0.2f * GT_MetaTileEntity_Hatch_AirIntake.floatGen.nextFloat()); + + xSpd = -xSpd; + zSpd = -zSpd; + } + + aWorld.spawnParticle( + name, + (double) (xPos + ran1 * 0.5f), + (double) (yPos + GT_MetaTileEntity_Hatch_AirIntake.floatGen.nextFloat() * 0.5f), + (double) (zPos + GT_MetaTileEntity_Hatch_AirIntake.floatGen.nextFloat() * 0.5f), + (double) xSpd, + (double) -ySpd, + (double) zSpd); + aWorld.spawnParticle( + name, + (double) (xPos + ran2 * 0.5f), + (double) (yPos + GT_MetaTileEntity_Hatch_AirIntake.floatGen.nextFloat() * 0.5f), + (double) (zPos + GT_MetaTileEntity_Hatch_AirIntake.floatGen.nextFloat() * 0.5f), + (double) xSpd, + (double) -ySpd, + (double) zSpd); + aWorld.spawnParticle( + name, + (double) (xPos + ran3 * 0.5f), + (double) (yPos + GT_MetaTileEntity_Hatch_AirIntake.floatGen.nextFloat() * 0.5f), + (double) (zPos + GT_MetaTileEntity_Hatch_AirIntake.floatGen.nextFloat() * 0.5f), + (double) xSpd, + (double) -ySpd, + (double) zSpd); + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_AirIntake_Extreme.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_AirIntake_Extreme.java index 45611d9e05..ca640b7a1d 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_AirIntake_Extreme.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_AirIntake_Extreme.java @@ -6,27 +6,27 @@ import gregtech.api.metatileentity.MetaTileEntity; public class GT_MetaTileEntity_Hatch_AirIntake_Extreme extends GT_MetaTileEntity_Hatch_AirIntake { - public GT_MetaTileEntity_Hatch_AirIntake_Extreme(final int aID, final String aName, final String aNameRegional, final int aTier) { - super(aID, aName, aNameRegional, aTier); - } - - public GT_MetaTileEntity_Hatch_AirIntake_Extreme(final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures) { - super(aName, aTier, aDescription, aTextures); - } - - - public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_Hatch_AirIntake_Extreme(this.mName, this.mTier, this.mDescription, this.mTextures); - } - - @Override - public int getAmountOfFluidToGenerate() { - return 8000; - } - - @Override - public int getCapacity() { - return 256000; - } - + public GT_MetaTileEntity_Hatch_AirIntake_Extreme( + final int aID, final String aName, final String aNameRegional, final int aTier) { + super(aID, aName, aNameRegional, aTier); + } + + public GT_MetaTileEntity_Hatch_AirIntake_Extreme( + final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_Hatch_AirIntake_Extreme(this.mName, this.mTier, this.mDescription, this.mTextures); + } + + @Override + public int getAmountOfFluidToGenerate() { + return 8000; + } + + @Override + public int getCapacity() { + return 256000; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_ControlCore.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_ControlCore.java index 5347b2e4f7..b2ea5a62ec 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_ControlCore.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_ControlCore.java @@ -19,38 +19,43 @@ import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; public class GT_MetaTileEntity_Hatch_ControlCore extends GT_MetaTileEntity_Hatch { - + public GT_Recipe_Map mRecipeMap = null; - + public BlockPos mControllerLocation; public GT_MetaTileEntity_Hatch_ControlCore(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, getSlots(aTier), "Core determines maximum tier machine will operate at"); + super( + aID, + aName, + aNameRegional, + aTier, + getSlots(aTier), + "Core determines maximum tier machine will operate at"); } public GT_MetaTileEntity_Hatch_ControlCore(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { super(aName, aTier, aTier < 1 ? 1 : aTier == 1 ? 4 : aTier == 2 ? 9 : 16, aDescription, aTextures); } - - public GT_MetaTileEntity_Hatch_ControlCore(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + + public GT_MetaTileEntity_Hatch_ControlCore( + String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { super(aName, aTier, aTier < 1 ? 1 : aTier == 1 ? 4 : aTier == 2 ? 9 : 16, aDescription[0], aTextures); } - - @Override - public String[] getDescription() { - return new String[]{ - this.mDescription, - CORE.GT_Tooltip}; - } + + @Override + public String[] getDescription() { + return new String[] {this.mDescription, CORE.GT_Tooltip}; + } @Override public ITexture[] getTexturesActive(ITexture aBaseTexture) { - return new ITexture[]{aBaseTexture, new GT_RenderedTexture(TexturesGtBlock.Overlay_Hatch_Control_Core)}; + return new ITexture[] {aBaseTexture, new GT_RenderedTexture(TexturesGtBlock.Overlay_Hatch_Control_Core)}; } @Override public ITexture[] getTexturesInactive(ITexture aBaseTexture) { - return new ITexture[]{aBaseTexture, new GT_RenderedTexture(TexturesGtBlock.Overlay_Hatch_Control_Core)}; + return new ITexture[] {aBaseTexture, new GT_RenderedTexture(TexturesGtBlock.Overlay_Hatch_Control_Core)}; } @Override @@ -75,7 +80,8 @@ public class GT_MetaTileEntity_Hatch_ControlCore extends GT_MetaTileEntity_Hatch @Override public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_Hatch_ControlCore(mName, mTier, StaticFields59.getDescriptionArray(this), mTextures); + return new GT_MetaTileEntity_Hatch_ControlCore( + mName, mTier, StaticFields59.getDescriptionArray(this), mTextures); } @Override @@ -87,12 +93,12 @@ public class GT_MetaTileEntity_Hatch_ControlCore extends GT_MetaTileEntity_Hatch @Override public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_Container_1by1(aPlayerInventory, aBaseMetaTileEntity); + return new GT_Container_1by1(aPlayerInventory, aBaseMetaTileEntity); } @Override public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_1by1(aPlayerInventory, aBaseMetaTileEntity, "Control Core Module"); + return new GT_GUIContainer_1by1(aPlayerInventory, aBaseMetaTileEntity, "Control Core Module"); } @Override @@ -111,8 +117,17 @@ public class GT_MetaTileEntity_Hatch_ControlCore extends GT_MetaTileEntity_Hatch protected void fillStacksIntoFirstSlots() { for (int i = 0; i < mInventory.length; i++) for (int j = i + 1; j < mInventory.length; j++) - if (mInventory[j] != null && (mInventory[i] == null || GT_Utility.areStacksEqual(mInventory[i], mInventory[j]))) { - GT_Utility.moveStackFromSlotAToSlotB(getBaseMetaTileEntity(), getBaseMetaTileEntity(), j, i, (byte) 64, (byte) 1, (byte) 64, (byte) 1); + if (mInventory[j] != null + && (mInventory[i] == null || GT_Utility.areStacksEqual(mInventory[i], mInventory[j]))) { + GT_Utility.moveStackFromSlotAToSlotB( + getBaseMetaTileEntity(), + getBaseMetaTileEntity(), + j, + i, + (byte) 64, + (byte) 1, + (byte) 64, + (byte) 1); } } @@ -123,26 +138,25 @@ public class GT_MetaTileEntity_Hatch_ControlCore extends GT_MetaTileEntity_Hatch @Override public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return aSide == getBaseMetaTileEntity().getFrontFacing() && (aStack != null && aStack.getItem() instanceof ItemControlCore); - } - - public boolean setOwner(TileEntity aTileEntity) { - if (mControllerLocation != null) { - return false; - } - else { - mControllerLocation = new BlockPos(aTileEntity); - return true; - } - } - - public boolean setOwner(IGregTechTileEntity aTileEntity) { - if (mControllerLocation != null) { - return false; - } - else { - mControllerLocation = new BlockPos(aTileEntity); - return true; - } - } + return aSide == getBaseMetaTileEntity().getFrontFacing() + && (aStack != null && aStack.getItem() instanceof ItemControlCore); + } + + public boolean setOwner(TileEntity aTileEntity) { + if (mControllerLocation != null) { + return false; + } else { + mControllerLocation = new BlockPos(aTileEntity); + return true; + } + } + + public boolean setOwner(IGregTechTileEntity aTileEntity) { + if (mControllerLocation != null) { + return false; + } else { + mControllerLocation = new BlockPos(aTileEntity); + return true; + } + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_DynamoBuffer.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_DynamoBuffer.java index 39f477b173..8405e2b09c 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_DynamoBuffer.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_DynamoBuffer.java @@ -1,84 +1,85 @@ package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; +import gregtech.api.enums.GT_Values; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Dynamo; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.enums.GT_Values; -import gregtech.api.interfaces.ITexture; - public class GT_MetaTileEntity_Hatch_DynamoBuffer extends GT_MetaTileEntity_Hatch_Dynamo { - public GT_MetaTileEntity_Hatch_DynamoBuffer(final int aID, final String aName, final String aNameRegional, - final int aTier) { - super(aID, aName, aNameRegional, aTier); - } + public GT_MetaTileEntity_Hatch_DynamoBuffer( + final int aID, final String aName, final String aNameRegional, final int aTier) { + super(aID, aName, aNameRegional, aTier); + } + + public GT_MetaTileEntity_Hatch_DynamoBuffer( + final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } - public GT_MetaTileEntity_Hatch_DynamoBuffer(final String aName, final int aTier, final String aDescription, - final ITexture[][][] aTextures) { - super(aName, aTier, aDescription, aTextures); - } + /*public GT_MetaTileEntity_Hatch_DynamoBuffer(final String aName, final int aTier, final String[] aDescription, + final ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + }*/ - /*public GT_MetaTileEntity_Hatch_DynamoBuffer(final String aName, final int aTier, final String[] aDescription, - final ITexture[][][] aTextures) { - super(aName, aTier, aDescription, aTextures); - }*/ + public ITexture[] getTexturesActive(final ITexture aBaseTexture) { + return new ITexture[] {aBaseTexture, TexturesGtBlock.OVERLAYS_ENERGY_OUT_MULTI_BUFFER[this.mTier]}; + } - public ITexture[] getTexturesActive(final ITexture aBaseTexture) { - return new ITexture[]{aBaseTexture, TexturesGtBlock.OVERLAYS_ENERGY_OUT_MULTI_BUFFER[this.mTier]}; - } + public ITexture[] getTexturesInactive(final ITexture aBaseTexture) { + return new ITexture[] {aBaseTexture, TexturesGtBlock.OVERLAYS_ENERGY_OUT_MULTI_BUFFER[this.mTier]}; + } - public ITexture[] getTexturesInactive(final ITexture aBaseTexture) { - return new ITexture[]{aBaseTexture, TexturesGtBlock.OVERLAYS_ENERGY_OUT_MULTI_BUFFER[this.mTier]}; - } + @Override + public long getMinimumStoredEU() { + return 0L; + } - @Override - public long getMinimumStoredEU() { - return 0L; - } + @Override + public long maxEUStore() { + return 512L + GT_Values.V[this.mTier + 1] * 2048L; + } - @Override - public long maxEUStore() { - return 512L + GT_Values.V[this.mTier + 1] * 2048L; - } + @Override + public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return (MetaTileEntity) + new GT_MetaTileEntity_Hatch_DynamoBuffer(this.mName, this.mTier, this.mDescription, this.mTextures); + } - @Override - public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return (MetaTileEntity) new GT_MetaTileEntity_Hatch_DynamoBuffer(this.mName, this.mTier, this.mDescription, this.mTextures); - } + @Override + public String[] getDescription() { + String[] g; + if (CORE.GTNH || (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK && Utils.getGregtechVersionAsInt() >= 50932)) { + g = new String[] { + "Dynamo with internal storage and additional Amp capacity", + "Does not accept more than " + (this.maxEUOutput() * this.maxAmperesIn()) + "EU/t as input", + CORE.GT_Tooltip + }; - @Override - public String[] getDescription() { - String[] g; - if (CORE.GTNH || (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK && Utils.getGregtechVersionAsInt() >= 50932)) { - g = new String[]{ - "Dynamo with internal storage and additional Amp capacity", - "Does not accept more than "+(this.maxEUOutput() * this.maxAmperesIn())+"EU/t as input", - CORE.GT_Tooltip}; - - } - else { - g = new String[]{ - "Dynamo with internal storage and additional Amp capacity", - "Stores "+maxEUStore()+"EU", - "Amperage In: 4", - "Amperage Out: 4", - "Does not accept more than "+(this.maxEUOutput() * this.maxAmperesIn())+"EU/t as input", - "Large Turbines only supply 1A to this, other Multiblocks can inject more amps", - CORE.GT_Tooltip}; - } - return g; - } + } else { + g = new String[] { + "Dynamo with internal storage and additional Amp capacity", + "Stores " + maxEUStore() + "EU", + "Amperage In: 4", + "Amperage Out: 4", + "Does not accept more than " + (this.maxEUOutput() * this.maxAmperesIn()) + "EU/t as input", + "Large Turbines only supply 1A to this, other Multiblocks can inject more amps", + CORE.GT_Tooltip + }; + } + return g; + } - @Override - public long maxAmperesIn() { - return 4; - } + @Override + public long maxAmperesIn() { + return 4; + } - @Override - public long maxAmperesOut() { - return 4; - } -}
\ No newline at end of file + @Override + public long maxAmperesOut() { + return 4; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_ElementalDataOrbHolder.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_ElementalDataOrbHolder.java index 67a6fc7aeb..500f1945bc 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_ElementalDataOrbHolder.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_ElementalDataOrbHolder.java @@ -1,7 +1,5 @@ package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; -import java.util.ArrayList; - import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; @@ -15,166 +13,172 @@ import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.xmod.gregtech.api.gui.CONTAINER_DataHatch; import gtPlusPlus.xmod.gregtech.api.gui.GUI_DataHatch; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import java.util.ArrayList; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; public class GT_MetaTileEntity_Hatch_ElementalDataOrbHolder extends GT_MetaTileEntity_Hatch { - public GT_Recipe_Map mRecipeMap = null; - - public GT_MetaTileEntity_Hatch_ElementalDataOrbHolder(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, 17, new String[]{ - "Holds Data Orbs for the Elemental Duplicator", - "Can insert/extract the circuit slot", - "Use Circuit to select a slot (1-16)", - CORE.GT_Tooltip - }); - } - - public GT_MetaTileEntity_Hatch_ElementalDataOrbHolder(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { - super(aName, aTier, 17, aDescription, aTextures); - } - - public GT_MetaTileEntity_Hatch_ElementalDataOrbHolder(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { - super(aName, aTier, 17, aDescription, aTextures); - } - - @Override - public ITexture[] getTexturesActive(ITexture aBaseTexture) { - return new ITexture[]{aBaseTexture, new GT_RenderedTexture(TexturesGtBlock.Overlay_Hatch_Data_Orb)}; - } - - @Override - public ITexture[] getTexturesInactive(ITexture aBaseTexture) { - return new ITexture[]{aBaseTexture, new GT_RenderedTexture(TexturesGtBlock.Overlay_Hatch_Data_Orb)}; - } - - @Override - public boolean isSimpleMachine() { - return true; - } - - @Override - public boolean isFacingValid(byte aFacing) { - return true; - } - - @Override - public boolean isAccessAllowed(EntityPlayer aPlayer) { - return true; - } - - @Override - public boolean isValidSlot(int aIndex) { - return true; - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_Hatch_ElementalDataOrbHolder(mName, mTier, mDescriptionArray, mTextures); - } - - @Override - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) return true; - aBaseMetaTileEntity.openGUI(aPlayer); - return true; - } - - @Override - public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new CONTAINER_DataHatch(aPlayerInventory, aBaseMetaTileEntity); - } - - @Override - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GUI_DataHatch(aPlayerInventory, aBaseMetaTileEntity, "Data Orb Repository"); - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { - if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.hasInventoryBeenModified()) { - fillStacksIntoFirstSlots(); - } - } - - public void updateSlots() { - for (int i = 0; i < mInventory.length-1; i++) - if (mInventory[i] != null && mInventory[i].stackSize <= 0) mInventory[i] = null; - fillStacksIntoFirstSlots(); - } - - protected void fillStacksIntoFirstSlots() { - for (int i = 0; i < mInventory.length-1; i++) { - if (mInventory[i] != null && mInventory[i].stackSize <= 0) { - mInventory[i] = null; - } - } - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - } - - @Override - public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - - } - - public String trans(String aKey, String aEnglish) { - return GT_LanguageManager.addStringLocalization("Interaction_DESCRIPTION_Index_" + aKey, aEnglish, false); - } - - @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - Logger.INFO("Checking if we can pull "+aStack.getDisplayName()+" from slot "+aIndex); - if (aIndex == mInventory.length-1 && ItemUtils.isControlCircuit(aStack) && aSide == getBaseMetaTileEntity().getFrontFacing()) { - return true; - } - return false; - } - - @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - Logger.INFO("Checking if we can put "+aStack.getDisplayName()+" into slot "+aIndex); - if (aIndex == mInventory.length-1 && ItemUtils.isControlCircuit(aStack) && aSide == getBaseMetaTileEntity().getFrontFacing()) { - return true; - } - return false; - } - - public ArrayList<ItemStack> getInventory(){ - ArrayList<ItemStack> aContents = new ArrayList<ItemStack>(); - for (int i = getBaseMetaTileEntity().getSizeInventory() - 2; i >= 0; i--) { + public GT_Recipe_Map mRecipeMap = null; + + public GT_MetaTileEntity_Hatch_ElementalDataOrbHolder(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, 17, new String[] { + "Holds Data Orbs for the Elemental Duplicator", + "Can insert/extract the circuit slot", + "Use Circuit to select a slot (1-16)", + CORE.GT_Tooltip + }); + } + + public GT_MetaTileEntity_Hatch_ElementalDataOrbHolder( + String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 17, aDescription, aTextures); + } + + public GT_MetaTileEntity_Hatch_ElementalDataOrbHolder( + String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 17, aDescription, aTextures); + } + + @Override + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + return new ITexture[] {aBaseTexture, new GT_RenderedTexture(TexturesGtBlock.Overlay_Hatch_Data_Orb)}; + } + + @Override + public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + return new ITexture[] {aBaseTexture, new GT_RenderedTexture(TexturesGtBlock.Overlay_Hatch_Data_Orb)}; + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return true; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean isValidSlot(int aIndex) { + return true; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_Hatch_ElementalDataOrbHolder(mName, mTier, mDescriptionArray, mTextures); + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) return true; + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + + @Override + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new CONTAINER_DataHatch(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_DataHatch(aPlayerInventory, aBaseMetaTileEntity, "Data Orb Repository"); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { + if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.hasInventoryBeenModified()) { + fillStacksIntoFirstSlots(); + } + } + + public void updateSlots() { + for (int i = 0; i < mInventory.length - 1; i++) + if (mInventory[i] != null && mInventory[i].stackSize <= 0) mInventory[i] = null; + fillStacksIntoFirstSlots(); + } + + protected void fillStacksIntoFirstSlots() { + for (int i = 0; i < mInventory.length - 1; i++) { + if (mInventory[i] != null && mInventory[i].stackSize <= 0) { + mInventory[i] = null; + } + } + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + } + + @Override + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) {} + + public String trans(String aKey, String aEnglish) { + return GT_LanguageManager.addStringLocalization("Interaction_DESCRIPTION_Index_" + aKey, aEnglish, false); + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + Logger.INFO("Checking if we can pull " + aStack.getDisplayName() + " from slot " + aIndex); + if (aIndex == mInventory.length - 1 + && ItemUtils.isControlCircuit(aStack) + && aSide == getBaseMetaTileEntity().getFrontFacing()) { + return true; + } + return false; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + Logger.INFO("Checking if we can put " + aStack.getDisplayName() + " into slot " + aIndex); + if (aIndex == mInventory.length - 1 + && ItemUtils.isControlCircuit(aStack) + && aSide == getBaseMetaTileEntity().getFrontFacing()) { + return true; + } + return false; + } + + public ArrayList<ItemStack> getInventory() { + ArrayList<ItemStack> aContents = new ArrayList<ItemStack>(); + for (int i = getBaseMetaTileEntity().getSizeInventory() - 2; i >= 0; i--) { if (getBaseMetaTileEntity().getStackInSlot(i) != null) - aContents.add(getBaseMetaTileEntity().getStackInSlot(i)); - } - return aContents; - } - - @Override - public boolean canInsertItem(int aIndex, ItemStack aStack, int aSide) { - if (aIndex == mInventory.length-1 && ItemUtils.isControlCircuit(aStack) && aSide == getBaseMetaTileEntity().getFrontFacing()) { - Logger.INFO("Putting "+aStack.getDisplayName()+" into slot "+aIndex); - return true; - } - return false; - } - - @Override - public boolean canExtractItem(int aIndex, ItemStack aStack, int aSide) { - if (aIndex == mInventory.length-1 && ItemUtils.isControlCircuit(aStack)) { - Logger.INFO("Pulling "+aStack.getDisplayName()+" from slot "+aIndex); - return true; - } - return false; - } - + aContents.add(getBaseMetaTileEntity().getStackInSlot(i)); + } + return aContents; + } + + @Override + public boolean canInsertItem(int aIndex, ItemStack aStack, int aSide) { + if (aIndex == mInventory.length - 1 + && ItemUtils.isControlCircuit(aStack) + && aSide == getBaseMetaTileEntity().getFrontFacing()) { + Logger.INFO("Putting " + aStack.getDisplayName() + " into slot " + aIndex); + return true; + } + return false; + } + + @Override + public boolean canExtractItem(int aIndex, ItemStack aStack, int aSide) { + if (aIndex == mInventory.length - 1 && ItemUtils.isControlCircuit(aStack)) { + Logger.INFO("Pulling " + aStack.getDisplayName() + " from slot " + aIndex); + return true; + } + return false; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Energy_RTG.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Energy_RTG.java index 8646e7e0a7..d70a84949f 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Energy_RTG.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Energy_RTG.java @@ -2,10 +2,6 @@ package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; import static gregtech.api.enums.GT_Values.V; -import java.lang.reflect.Field; -import java.lang.reflect.Modifier; -import java.util.HashMap; - import gregtech.api.gui.GT_Container_3by3; import gregtech.api.gui.GT_GUIContainer_3by3; import gregtech.api.interfaces.ITexture; @@ -17,6 +13,9 @@ import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.minecraft.InventoryUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; +import java.util.HashMap; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.Item; @@ -25,269 +24,277 @@ import net.minecraft.nbt.NBTTagCompound; public class GT_MetaTileEntity_Hatch_Energy_RTG extends GT_MetaTileEntity_Hatch_Energy { - public GT_MetaTileEntity_Hatch_Energy_RTG(int aID, String aName, String aNameRegional, int aTier, int aInvSlotCount) { - super(aID, aName, aNameRegional, aTier); - setInventoryContent(aInvSlotCount); - } - - public GT_MetaTileEntity_Hatch_Energy_RTG(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { - super(aName, aTier, aDescription, aTextures); - } - - public GT_MetaTileEntity_Hatch_Energy_RTG(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures, int aInvSlotCount) { - super(aName, aTier, aDescription, aTextures); - setInventoryContent(aInvSlotCount); - } - - @Override - public String[] getDescription() { - String[] S = super.getDescription(); - final String[] desc = new String[S.length + 1]; - System.arraycopy(S, 0, desc, 0, S.length); - desc[S.length] = CORE.GT_Tooltip; - return desc; - } - - @Override - public ITexture[] getTexturesActive(ITexture aBaseTexture) { - return new ITexture[]{aBaseTexture, TexturesGtBlock.getTextureFromIcon(TexturesGtBlock.Overlay_Hatch_RTG_On, new short[] {220, 220, 220, 0})}; - } - - @Override - public ITexture[] getTexturesInactive(ITexture aBaseTexture) { - return new ITexture[]{aBaseTexture, TexturesGtBlock.getTextureFromIcon(TexturesGtBlock.Overlay_Hatch_RTG_Off, new short[] {220, 220, 220, 0})}; - } - - @Override - public boolean isSimpleMachine() { - return true; - } - - @Override - public boolean isFacingValid(byte aFacing) { - return true; - } - - @Override - public boolean isAccessAllowed(EntityPlayer aPlayer) { - return true; - } - - @Override - public boolean isEnetInput() { - return false; - } - - @Override - public boolean isInputFacing(byte aSide) { - return aSide == getBaseMetaTileEntity().getFrontFacing(); - } - - @Override - public boolean isValidSlot(int aIndex) { - return true; - } - - @Override - public long getMinimumStoredEU() { - return 0; - } - - @Override - public long maxEUInput() { - return V[mTier]; - } - - @Override - public long maxEUStore() { - return Long.MAX_VALUE / (Short.MAX_VALUE * Byte.MAX_VALUE) ; - } - - @Override - public long maxAmperesIn() { - return 0; - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_Hatch_Energy_RTG(mName, mTier, mDescriptionArray, mTextures, 9); - } - - @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return false; - } - - @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return true; - } - - @Override - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) return true; - aBaseMetaTileEntity.openGUI(aPlayer); - return true; - } - - @Override - public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_Container_3by3(aPlayerInventory, aBaseMetaTileEntity); - } - - @Override - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_3by3(aPlayerInventory, aBaseMetaTileEntity, "RTG Power Unit"); - } - - private static class Dat { - - protected final String mUniqueDataTag; - private final ItemStack mStack; - private final NBTTagCompound mNBT; - - public Dat(ItemStack aStack) { - mStack = aStack; - mNBT = (aStack.getTagCompound() != null ? aStack.getTagCompound() : new NBTTagCompound()); - mUniqueDataTag = ""+Item.getIdFromItem(aStack.getItem())+""+aStack.getItemDamage()+""+1+""+mNBT.getId(); - } - - public int getKey() { - return Item.getIdFromItem(mStack.getItem())+mStack.getItemDamage(); - } - - } - - private static final HashMap<String, ItemStack> mFuelInstanceMap = new HashMap<String, ItemStack>(); - private static final HashMap<String, Long> mFuelValueMap = new HashMap<String, Long>(); - private static final HashMap<String, Integer> mFuelTypeMap = new HashMap<String, Integer>(); - private static final HashMap<Integer, String> mFuelTypeMapReverse = new HashMap<Integer, String>(); - - public static boolean registerPelletForHatch(ItemStack aStack, long aFuelValue) { - if (!ItemUtils.checkForInvalidItems(aStack)) { - return false; - } - ItemStack aTemp = aStack.copy(); - aTemp.stackSize = 1; - Dat aDat = new Dat(aTemp); - String aKey = aDat.mUniqueDataTag; - mFuelInstanceMap.put(aKey, aTemp); - mFuelValueMap.put(aKey, aFuelValue); - mFuelTypeMap.put(aKey, aDat.getKey()); - mFuelTypeMapReverse.put(aDat.getKey(), aKey); - Logger.INFO("RTG Hatch: Registered Fuel Pellet: "+ItemUtils.getItemName(aTemp)+", Fuel Value: "+aFuelValue+", Key: "+aKey+", Key2: "+aDat.getKey()); - return true; - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { - if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.hasInventoryBeenModified()) { - InventoryUtils.sortInventoryItems(this); - } - if (aTimer % 100 == 0 && aBaseMetaTileEntity.isServerSide()) { - if (hasPellet(this)) { - Logger.INFO("Has Pellet"); - tryConsumePellet(this); - } - } - } - - private static void tryConsumePellet(GT_MetaTileEntity_Hatch_Energy_RTG aTile) { - ItemStack aPellet = getPelletToConsume(aTile); - if (aPellet != null) { - Logger.INFO("Found Pellet"); - long aFuel = getFuelValueOfPellet(aPellet); - if (aFuel > 0) { - Logger.INFO("Has Fuel Value: "+aFuel); - if (hasSpaceForEnergy(aTile, aFuel)) { - Logger.INFO("Can buffer"); - aPellet.stackSize = 0; - Logger.INFO("Stack set to 0"); - aPellet = null; - Logger.INFO("null stack"); - addEnergyToInternalStorage(aTile, aFuel); - Logger.INFO("Consumed"); - } - } - } - aTile.updateSlots(); - Logger.INFO("updating slots"); - } - - private static void addEnergyToInternalStorage(GT_MetaTileEntity_Hatch_Energy_RTG aTile, long aFuel) { - aTile.getBaseMetaTileEntity().increaseStoredEnergyUnits(aFuel, true); - } - - public static boolean hasSpaceForEnergy(GT_MetaTileEntity_Hatch_Energy_RTG aTile, long aAmount) { - long aMax = aTile.maxEUStore(); - long aCurrent = aTile.getEUVar(); - if ((aMax - aCurrent) >= aAmount) { - return true; - } - return false; - } - - public void updateSlots() { - for (int i = 0; i < mInventory.length; i++) { - if (mInventory[i] != null && mInventory[i].stackSize <= 0) { - mInventory[i] = null; - } - } - InventoryUtils.sortInventoryItems(this); - } - - public static boolean hasPellet(GT_MetaTileEntity_Hatch_Energy_RTG aTile) { - for (ItemStack o : aTile.mInventory) { - if (o != null ) { - for (ItemStack i : mFuelInstanceMap.values()) { - if (ItemUtils.areItemsEqual(o, i)) { - return true; - } - } - } - } - return false; - } - - public static String getPelletType(ItemStack o) { - if (o == null) { - return "error"; - } - Dat aDat = new Dat(o); - return mFuelTypeMapReverse.get(aDat.getKey()); - } - - public static long getFuelValueOfPellet(ItemStack aPellet) { - String aType = getPelletType(aPellet); - if (mFuelValueMap.containsKey(aType)) { - return mFuelValueMap.get(aType); - } - return 0; - } - - public static ItemStack getPelletToConsume(GT_MetaTileEntity_Hatch_Energy_RTG aTile) { - for (ItemStack o : aTile.mInventory) { - if (o != null ) { - for (ItemStack i : mFuelInstanceMap.values()) { - if (ItemUtils.areItemsEqual(o, i)) { - return o; - } - } - } - } - return null; - } - - private void setInventoryContent(int aInvSlotCount) { - try { - Field fieldInventory = MetaTileEntity.class.getDeclaredField("mInventory"); - Field modifiersField = Field.class.getDeclaredField("modifiers"); - modifiersField.setAccessible(true); - modifiersField.setInt(fieldInventory, fieldInventory.getModifiers() & ~Modifier.PRIVATE & ~Modifier.FINAL); - fieldInventory.set(this, new ItemStack[aInvSlotCount]); - } catch (Exception e) { - e.printStackTrace(); - } - } - -}
\ No newline at end of file + public GT_MetaTileEntity_Hatch_Energy_RTG( + int aID, String aName, String aNameRegional, int aTier, int aInvSlotCount) { + super(aID, aName, aNameRegional, aTier); + setInventoryContent(aInvSlotCount); + } + + public GT_MetaTileEntity_Hatch_Energy_RTG(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + public GT_MetaTileEntity_Hatch_Energy_RTG( + String aName, int aTier, String[] aDescription, ITexture[][][] aTextures, int aInvSlotCount) { + super(aName, aTier, aDescription, aTextures); + setInventoryContent(aInvSlotCount); + } + + @Override + public String[] getDescription() { + String[] S = super.getDescription(); + final String[] desc = new String[S.length + 1]; + System.arraycopy(S, 0, desc, 0, S.length); + desc[S.length] = CORE.GT_Tooltip; + return desc; + } + + @Override + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + return new ITexture[] { + aBaseTexture, + TexturesGtBlock.getTextureFromIcon(TexturesGtBlock.Overlay_Hatch_RTG_On, new short[] {220, 220, 220, 0}) + }; + } + + @Override + public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + return new ITexture[] { + aBaseTexture, + TexturesGtBlock.getTextureFromIcon(TexturesGtBlock.Overlay_Hatch_RTG_Off, new short[] {220, 220, 220, 0}) + }; + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return true; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean isEnetInput() { + return false; + } + + @Override + public boolean isInputFacing(byte aSide) { + return aSide == getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public boolean isValidSlot(int aIndex) { + return true; + } + + @Override + public long getMinimumStoredEU() { + return 0; + } + + @Override + public long maxEUInput() { + return V[mTier]; + } + + @Override + public long maxEUStore() { + return Long.MAX_VALUE / (Short.MAX_VALUE * Byte.MAX_VALUE); + } + + @Override + public long maxAmperesIn() { + return 0; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_Hatch_Energy_RTG(mName, mTier, mDescriptionArray, mTextures, 9); + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return true; + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) return true; + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + + @Override + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_Container_3by3(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_3by3(aPlayerInventory, aBaseMetaTileEntity, "RTG Power Unit"); + } + + private static class Dat { + + protected final String mUniqueDataTag; + private final ItemStack mStack; + private final NBTTagCompound mNBT; + + public Dat(ItemStack aStack) { + mStack = aStack; + mNBT = (aStack.getTagCompound() != null ? aStack.getTagCompound() : new NBTTagCompound()); + mUniqueDataTag = "" + Item.getIdFromItem(aStack.getItem()) + "" + aStack.getItemDamage() + "" + 1 + "" + + mNBT.getId(); + } + + public int getKey() { + return Item.getIdFromItem(mStack.getItem()) + mStack.getItemDamage(); + } + } + + private static final HashMap<String, ItemStack> mFuelInstanceMap = new HashMap<String, ItemStack>(); + private static final HashMap<String, Long> mFuelValueMap = new HashMap<String, Long>(); + private static final HashMap<String, Integer> mFuelTypeMap = new HashMap<String, Integer>(); + private static final HashMap<Integer, String> mFuelTypeMapReverse = new HashMap<Integer, String>(); + + public static boolean registerPelletForHatch(ItemStack aStack, long aFuelValue) { + if (!ItemUtils.checkForInvalidItems(aStack)) { + return false; + } + ItemStack aTemp = aStack.copy(); + aTemp.stackSize = 1; + Dat aDat = new Dat(aTemp); + String aKey = aDat.mUniqueDataTag; + mFuelInstanceMap.put(aKey, aTemp); + mFuelValueMap.put(aKey, aFuelValue); + mFuelTypeMap.put(aKey, aDat.getKey()); + mFuelTypeMapReverse.put(aDat.getKey(), aKey); + Logger.INFO("RTG Hatch: Registered Fuel Pellet: " + ItemUtils.getItemName(aTemp) + ", Fuel Value: " + aFuelValue + + ", Key: " + aKey + ", Key2: " + aDat.getKey()); + return true; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { + if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.hasInventoryBeenModified()) { + InventoryUtils.sortInventoryItems(this); + } + if (aTimer % 100 == 0 && aBaseMetaTileEntity.isServerSide()) { + if (hasPellet(this)) { + Logger.INFO("Has Pellet"); + tryConsumePellet(this); + } + } + } + + private static void tryConsumePellet(GT_MetaTileEntity_Hatch_Energy_RTG aTile) { + ItemStack aPellet = getPelletToConsume(aTile); + if (aPellet != null) { + Logger.INFO("Found Pellet"); + long aFuel = getFuelValueOfPellet(aPellet); + if (aFuel > 0) { + Logger.INFO("Has Fuel Value: " + aFuel); + if (hasSpaceForEnergy(aTile, aFuel)) { + Logger.INFO("Can buffer"); + aPellet.stackSize = 0; + Logger.INFO("Stack set to 0"); + aPellet = null; + Logger.INFO("null stack"); + addEnergyToInternalStorage(aTile, aFuel); + Logger.INFO("Consumed"); + } + } + } + aTile.updateSlots(); + Logger.INFO("updating slots"); + } + + private static void addEnergyToInternalStorage(GT_MetaTileEntity_Hatch_Energy_RTG aTile, long aFuel) { + aTile.getBaseMetaTileEntity().increaseStoredEnergyUnits(aFuel, true); + } + + public static boolean hasSpaceForEnergy(GT_MetaTileEntity_Hatch_Energy_RTG aTile, long aAmount) { + long aMax = aTile.maxEUStore(); + long aCurrent = aTile.getEUVar(); + if ((aMax - aCurrent) >= aAmount) { + return true; + } + return false; + } + + public void updateSlots() { + for (int i = 0; i < mInventory.length; i++) { + if (mInventory[i] != null && mInventory[i].stackSize <= 0) { + mInventory[i] = null; + } + } + InventoryUtils.sortInventoryItems(this); + } + + public static boolean hasPellet(GT_MetaTileEntity_Hatch_Energy_RTG aTile) { + for (ItemStack o : aTile.mInventory) { + if (o != null) { + for (ItemStack i : mFuelInstanceMap.values()) { + if (ItemUtils.areItemsEqual(o, i)) { + return true; + } + } + } + } + return false; + } + + public static String getPelletType(ItemStack o) { + if (o == null) { + return "error"; + } + Dat aDat = new Dat(o); + return mFuelTypeMapReverse.get(aDat.getKey()); + } + + public static long getFuelValueOfPellet(ItemStack aPellet) { + String aType = getPelletType(aPellet); + if (mFuelValueMap.containsKey(aType)) { + return mFuelValueMap.get(aType); + } + return 0; + } + + public static ItemStack getPelletToConsume(GT_MetaTileEntity_Hatch_Energy_RTG aTile) { + for (ItemStack o : aTile.mInventory) { + if (o != null) { + for (ItemStack i : mFuelInstanceMap.values()) { + if (ItemUtils.areItemsEqual(o, i)) { + return o; + } + } + } + } + return null; + } + + private void setInventoryContent(int aInvSlotCount) { + try { + Field fieldInventory = MetaTileEntity.class.getDeclaredField("mInventory"); + Field modifiersField = Field.class.getDeclaredField("modifiers"); + modifiersField.setAccessible(true); + modifiersField.setInt(fieldInventory, fieldInventory.getModifiers() & ~Modifier.PRIVATE & ~Modifier.FINAL); + fieldInventory.set(this, new ItemStack[aInvSlotCount]); + } catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_FluidGenerator.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_FluidGenerator.java index c7e07b7534..b11b3bc78e 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_FluidGenerator.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_FluidGenerator.java @@ -1,7 +1,5 @@ package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; -import java.lang.reflect.Field; - import gregtech.api.enums.Textures; import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.ITexture; @@ -14,6 +12,7 @@ import gtPlusPlus.api.objects.random.XSTR; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.minecraft.FluidUtils; import gtPlusPlus.core.util.reflect.ReflectionUtils; +import java.lang.reflect.Field; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -23,133 +22,130 @@ import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; public abstract class GT_MetaTileEntity_Hatch_FluidGenerator extends GT_MetaTileEntity_Hatch_Input { - - protected static XSTR floatGen = new XSTR(); + + protected static XSTR floatGen = new XSTR(); public int mProgresstime = 0, mMaxProgresstime = 0; - public GT_MetaTileEntity_Hatch_FluidGenerator(final int aID, final String aName, final String aNameRegional, final int aTier) { - super(aID, aName, aNameRegional, aTier); - } - - public GT_MetaTileEntity_Hatch_FluidGenerator(final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures) { - super(aName, aTier, aDescription, aTextures); - } - - private static String[] S; - private static Field F; - - public abstract String[] getCustomTooltip(); - - public abstract Fluid getFluidToGenerate(); - - public abstract int getAmountOfFluidToGenerate(); - - public abstract int getMaxTickTime(); - - public synchronized String[] getDescription() { - try { - if (F == null || S == null) { - Field t = ReflectionUtils.getField(this.getClass(), "mDescriptionArray"); - if (t != null) { - F = t; - } - else { - F = ReflectionUtils.getField(this.getClass(), "mDescription"); - } - if (S == null && F != null) { - Object o = F.get(this); - if (o instanceof String[]) { - S = (String[]) o; - } - else if (o instanceof String) { - S = new String[] {(String) o}; - } - } - - } - } - catch (Throwable t) { - Logger.INFO("1"); - t.printStackTrace(); - } - try { - if (S != null) { - String[] aCustomTips = getCustomTooltip(); - final String[] desc = new String[S.length + aCustomTips.length + 1]; - System.arraycopy(S, 0, desc, 0, S.length); - for (int i=0;i<aCustomTips.length;i++) { - desc[S.length + i] = aCustomTips[i]; - } - desc[S.length + aCustomTips.length] = CORE.GT_Tooltip; - return desc; - } - } - catch (Throwable t) { - Logger.INFO("2"); - t.printStackTrace(); - } - - return new String[] {"Broken Tooltip - Report on Github"}; - - } - - public ITexture[] getTexturesActive(final ITexture aBaseTexture) { - return new ITexture[]{aBaseTexture, - new GT_RenderedTexture((IIconContainer) Textures.BlockIcons.OVERLAY_MUFFLER)}; - } - - public ITexture[] getTexturesInactive(final ITexture aBaseTexture) { - return new ITexture[]{aBaseTexture, - new GT_RenderedTexture((IIconContainer) Textures.BlockIcons.OVERLAY_MUFFLER)}; - } - - public boolean isSimpleMachine() { - return true; - } - - public boolean isFacingValid(final byte aFacing) { - return true; - } - - public boolean isAccessAllowed(final EntityPlayer aPlayer) { - return true; - } - - public boolean isValidSlot(final int aIndex) { - return false; - } - - public abstract MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity); - - public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, - final ItemStack aStack) { - return false; - } - - public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, - final ItemStack aStack) { - return false; - } - - public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { - super.onPostTick(aBaseMetaTileEntity, aTick); - if (!aBaseMetaTileEntity.isAllowedToWork()) { - aBaseMetaTileEntity.setActive(false); - mProgresstime = 0; - mMaxProgresstime = 0; - } - else { - aBaseMetaTileEntity.setActive(true); - mMaxProgresstime = getMaxTickTime(); - if (++mProgresstime >= mMaxProgresstime) { - if (this.canTankBeFilled()) { - addFluidToHatch(aTick); - } - mProgresstime = 0; - } - } - } - + public GT_MetaTileEntity_Hatch_FluidGenerator( + final int aID, final String aName, final String aNameRegional, final int aTier) { + super(aID, aName, aNameRegional, aTier); + } + + public GT_MetaTileEntity_Hatch_FluidGenerator( + final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + private static String[] S; + private static Field F; + + public abstract String[] getCustomTooltip(); + + public abstract Fluid getFluidToGenerate(); + + public abstract int getAmountOfFluidToGenerate(); + + public abstract int getMaxTickTime(); + + public synchronized String[] getDescription() { + try { + if (F == null || S == null) { + Field t = ReflectionUtils.getField(this.getClass(), "mDescriptionArray"); + if (t != null) { + F = t; + } else { + F = ReflectionUtils.getField(this.getClass(), "mDescription"); + } + if (S == null && F != null) { + Object o = F.get(this); + if (o instanceof String[]) { + S = (String[]) o; + } else if (o instanceof String) { + S = new String[] {(String) o}; + } + } + } + } catch (Throwable t) { + Logger.INFO("1"); + t.printStackTrace(); + } + try { + if (S != null) { + String[] aCustomTips = getCustomTooltip(); + final String[] desc = new String[S.length + aCustomTips.length + 1]; + System.arraycopy(S, 0, desc, 0, S.length); + for (int i = 0; i < aCustomTips.length; i++) { + desc[S.length + i] = aCustomTips[i]; + } + desc[S.length + aCustomTips.length] = CORE.GT_Tooltip; + return desc; + } + } catch (Throwable t) { + Logger.INFO("2"); + t.printStackTrace(); + } + + return new String[] {"Broken Tooltip - Report on Github"}; + } + + public ITexture[] getTexturesActive(final ITexture aBaseTexture) { + return new ITexture[] { + aBaseTexture, new GT_RenderedTexture((IIconContainer) Textures.BlockIcons.OVERLAY_MUFFLER) + }; + } + + public ITexture[] getTexturesInactive(final ITexture aBaseTexture) { + return new ITexture[] { + aBaseTexture, new GT_RenderedTexture((IIconContainer) Textures.BlockIcons.OVERLAY_MUFFLER) + }; + } + + public boolean isSimpleMachine() { + return true; + } + + public boolean isFacingValid(final byte aFacing) { + return true; + } + + public boolean isAccessAllowed(final EntityPlayer aPlayer) { + return true; + } + + public boolean isValidSlot(final int aIndex) { + return false; + } + + public abstract MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity); + + public boolean allowPullStack( + final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return false; + } + + public boolean allowPutStack( + final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return false; + } + + public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + if (!aBaseMetaTileEntity.isAllowedToWork()) { + aBaseMetaTileEntity.setActive(false); + mProgresstime = 0; + mMaxProgresstime = 0; + } else { + aBaseMetaTileEntity.setActive(true); + mMaxProgresstime = getMaxTickTime(); + if (++mProgresstime >= mMaxProgresstime) { + if (this.canTankBeFilled()) { + addFluidToHatch(aTick); + } + mProgresstime = 0; + } + } + } + @Override public int getProgresstime() { return mProgresstime; @@ -166,62 +162,68 @@ public abstract class GT_MetaTileEntity_Hatch_FluidGenerator extends GT_MetaTile return mMaxProgresstime - mProgresstime; } - public abstract void generateParticles(final World aWorld, final String name); - - public int getTankPressure() { - return 100; - } - - public abstract int getCapacity(); - - @Override - public boolean canTankBeEmptied() { - return true; - } - - public abstract boolean doesHatchMeetConditionsToGenerate(); - - public boolean addFluidToHatch(long aTick) { - if (!doesHatchMeetConditionsToGenerate()) { - return false; - } - int aFillAmount = this.fill(FluidUtils.getFluidStack(getFluidToGenerate(), getAmountOfFluidToGenerate()), true); - if (aFillAmount > 0) { - if (this.getBaseMetaTileEntity().isClientSide()) { - generateParticles(this.getBaseMetaTileEntity().getWorld(), "cloud"); - } - } - return aFillAmount > 0; - } - - @Override - public boolean canTankBeFilled() { - if (this.getCapacity()-this.getFluidAmount() > 0) { - //Logger.INFO("Total Space: "+this.getCapacity()); - //Logger.INFO("Current amount: "+this.getFluidAmount()); - //Logger.INFO("To add: "+this.getAmountOfFluidToGenerate()); - //Logger.INFO("Space Free: "+(this.getCapacity()-this.getFluidAmount())); - } - if (this.mFluid == null || (this.mFluid != null && (this.getCapacity() - this.getFluidAmount() >= this.getAmountOfFluidToGenerate()))) { - return true; - } - return false; - } - - @Override - public boolean doesEmptyContainers() { - return false; - } - - @Override - public boolean doesFillContainers() { - return true; - } - - @Override - public int fill(FluidStack aFluid, boolean doFill) { - if (aFluid == null || aFluid.getFluid().getID() <= 0 || aFluid.amount <= 0 || aFluid.getFluid() != getFluidToGenerate() || !canTankBeFilled()) { - return 0; + public abstract void generateParticles(final World aWorld, final String name); + + public int getTankPressure() { + return 100; + } + + public abstract int getCapacity(); + + @Override + public boolean canTankBeEmptied() { + return true; + } + + public abstract boolean doesHatchMeetConditionsToGenerate(); + + public boolean addFluidToHatch(long aTick) { + if (!doesHatchMeetConditionsToGenerate()) { + return false; + } + int aFillAmount = this.fill(FluidUtils.getFluidStack(getFluidToGenerate(), getAmountOfFluidToGenerate()), true); + if (aFillAmount > 0) { + if (this.getBaseMetaTileEntity().isClientSide()) { + generateParticles(this.getBaseMetaTileEntity().getWorld(), "cloud"); + } + } + return aFillAmount > 0; + } + + @Override + public boolean canTankBeFilled() { + if (this.getCapacity() - this.getFluidAmount() > 0) { + // Logger.INFO("Total Space: "+this.getCapacity()); + // Logger.INFO("Current amount: "+this.getFluidAmount()); + // Logger.INFO("To add: "+this.getAmountOfFluidToGenerate()); + // Logger.INFO("Space Free: "+(this.getCapacity()-this.getFluidAmount())); + } + if (this.mFluid == null + || (this.mFluid != null + && (this.getCapacity() - this.getFluidAmount() >= this.getAmountOfFluidToGenerate()))) { + return true; + } + return false; + } + + @Override + public boolean doesEmptyContainers() { + return false; + } + + @Override + public boolean doesFillContainers() { + return true; + } + + @Override + public int fill(FluidStack aFluid, boolean doFill) { + if (aFluid == null + || aFluid.getFluid().getID() <= 0 + || aFluid.amount <= 0 + || aFluid.getFluid() != getFluidToGenerate() + || !canTankBeFilled()) { + return 0; } if (getFillableStack() == null || getFillableStack().getFluid().getID() <= 0) { @@ -240,8 +242,7 @@ public abstract class GT_MetaTileEntity_Hatch_FluidGenerator extends GT_MetaTile return getCapacity(); } - if (!getFillableStack().isFluidEqual(aFluid)) - return 0; + if (!getFillableStack().isFluidEqual(aFluid)) return 0; int space = getCapacity() - getFillableStack().amount; if (aFluid.amount <= space) { @@ -251,37 +252,36 @@ public abstract class GT_MetaTileEntity_Hatch_FluidGenerator extends GT_MetaTile } return aFluid.amount; } - if (doFill) - getFillableStack().amount = getCapacity(); + if (doFill) getFillableStack().amount = getCapacity(); return space; } - @Override - public boolean canFill(ForgeDirection aSide, Fluid aFluid) { - return false; - } - - @Override - public int fill(ForgeDirection arg0, FluidStack arg1, boolean arg2) { - return 0; - } - - @Override - public int fill_default(ForgeDirection aSide, FluidStack aFluid, boolean doFill) { - return 0; - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { + @Override + public boolean canFill(ForgeDirection aSide, Fluid aFluid) { + return false; + } + + @Override + public int fill(ForgeDirection arg0, FluidStack arg1, boolean arg2) { + return 0; + } + + @Override + public int fill_default(ForgeDirection aSide, FluidStack aFluid, boolean doFill) { + return 0; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { aNBT.setInteger("mProgresstime", mProgresstime); aNBT.setInteger("mMaxProgresstime", mMaxProgresstime); - super.saveNBTData(aNBT); - } + super.saveNBTData(aNBT); + } - @Override - public void loadNBTData(NBTTagCompound aNBT) { + @Override + public void loadNBTData(NBTTagCompound aNBT) { mProgresstime = aNBT.getInteger("mProgresstime"); mMaxProgresstime = aNBT.getInteger("mMaxProgresstime"); - super.loadNBTData(aNBT); - } + super.loadNBTData(aNBT); + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBattery.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBattery.java index 57f8b722c3..d56a95d60f 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBattery.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBattery.java @@ -2,10 +2,6 @@ package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; import static gregtech.api.enums.GT_Values.V; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.item.ItemStack; - import gregtech.api.enums.GT_Values; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -15,57 +11,48 @@ import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gregtech.api.util.GT_Utility; - import gtPlusPlus.core.lib.CORE; import gtPlusPlus.xmod.gregtech.api.gui.hatches.charge.*; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; -public class GT_MetaTileEntity_Hatch_InputBattery -extends -GT_MetaTileEntity_Hatch { - public final GT_Recipe_Map mRecipeMap = null; +public class GT_MetaTileEntity_Hatch_InputBattery extends GT_MetaTileEntity_Hatch { + public final GT_Recipe_Map mRecipeMap = null; - public GT_MetaTileEntity_Hatch_InputBattery(int aID, String aName, - String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, getSlots(aTier), "Chargeable Item Bus for Multiblocks"); - } + public GT_MetaTileEntity_Hatch_InputBattery(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, getSlots(aTier), "Chargeable Item Bus for Multiblocks"); + } - public GT_MetaTileEntity_Hatch_InputBattery(String aName, int aTier, - String aDescription, ITexture[][][] aTextures) { - super(aName, aTier, - aTier < 1 ? 1 : aTier == 1 ? 4 : aTier == 2 ? 4 : 16, - aDescription, aTextures); - } + public GT_MetaTileEntity_Hatch_InputBattery( + String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aTier < 1 ? 1 : aTier == 1 ? 4 : aTier == 2 ? 4 : 16, aDescription, aTextures); + } - @Override - public String[] getDescription() { - int mSlots = 0; - if (this.mTier == 2) { - mSlots = 4; - } - else if (this.mTier == 4) { - mSlots = 16; - } - else { - mSlots = 16; - } - return new String[]{ - this.mDescription, - "Capacity: " + mSlots + " slots", - CORE.GT_Tooltip}; - } + @Override + public String[] getDescription() { + int mSlots = 0; + if (this.mTier == 2) { + mSlots = 4; + } else if (this.mTier == 4) { + mSlots = 16; + } else { + mSlots = 16; + } + return new String[] {this.mDescription, "Capacity: " + mSlots + " slots", CORE.GT_Tooltip}; + } - @Override + @Override public boolean isEnetInput() { return true; } - @Override + @Override public boolean isInputFacing(byte aSide) { return aSide == getBaseMetaTileEntity().getFrontFacing(); } - @Override public long getMinimumStoredEU() { return 0; @@ -85,174 +72,171 @@ GT_MetaTileEntity_Hatch { public long maxAmperesIn() { return 4; } - - @Override - public ITexture[] getTexturesActive(ITexture aBaseTexture) { - return new ITexture[]{aBaseTexture, - new GT_RenderedTexture(TexturesGtBlock.Overlay_Hatch_Charger)}; - } - @Override - public ITexture[] getTexturesInactive(ITexture aBaseTexture) { - return new ITexture[]{aBaseTexture, - new GT_RenderedTexture(TexturesGtBlock.Overlay_Hatch_Charger)}; - } + @Override + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + return new ITexture[] {aBaseTexture, new GT_RenderedTexture(TexturesGtBlock.Overlay_Hatch_Charger)}; + } - @Override - public boolean isSimpleMachine() { - return true; - } + @Override + public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + return new ITexture[] {aBaseTexture, new GT_RenderedTexture(TexturesGtBlock.Overlay_Hatch_Charger)}; + } - @Override - public boolean isFacingValid(byte aFacing) { - return true; - } + @Override + public boolean isSimpleMachine() { + return true; + } - @Override - public boolean isAccessAllowed(EntityPlayer aPlayer) { - return true; - } + @Override + public boolean isFacingValid(byte aFacing) { + return true; + } - @Override - public boolean isValidSlot(int aIndex) { - return true; - } + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean isValidSlot(int aIndex) { + return true; + } - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_Hatch_InputBattery(mName, mTier, - mDescription, mTextures); - } + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_Hatch_InputBattery(mName, mTier, mDescription, mTextures); + } - @Override - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, - EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) - return true; - aBaseMetaTileEntity.openGUI(aPlayer); - return true; - } + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) return true; + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } - @Override - public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, - IGregTechTileEntity aBaseMetaTileEntity) { - switch (mTier) { - case 2 : - return new CONTAINER_Electric_2by2(aPlayerInventory, - aBaseMetaTileEntity); - case 4 : - return new CONTAINER_Electric_4by4(aPlayerInventory, - aBaseMetaTileEntity); - default : - return new CONTAINER_Electric_4by4(aPlayerInventory, - aBaseMetaTileEntity); - } - } + @Override + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + switch (mTier) { + case 2: + return new CONTAINER_Electric_2by2(aPlayerInventory, aBaseMetaTileEntity); + case 4: + return new CONTAINER_Electric_4by4(aPlayerInventory, aBaseMetaTileEntity); + default: + return new CONTAINER_Electric_4by4(aPlayerInventory, aBaseMetaTileEntity); + } + } - @Override - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, - IGregTechTileEntity aBaseMetaTileEntity) { - switch (mTier) { - case 2 : - return new GUI_Electric_2by2(aPlayerInventory, - aBaseMetaTileEntity, "Charging Bus"); - case 4 : - return new GUI_Electric_4by4(aPlayerInventory, - aBaseMetaTileEntity, "Charging Bus"); - default : - return new GUI_Electric_4by4(aPlayerInventory, - aBaseMetaTileEntity, "Charging Bus"); - } - } + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + switch (mTier) { + case 2: + return new GUI_Electric_2by2(aPlayerInventory, aBaseMetaTileEntity, "Charging Bus"); + case 4: + return new GUI_Electric_4by4(aPlayerInventory, aBaseMetaTileEntity, "Charging Bus"); + default: + return new GUI_Electric_4by4(aPlayerInventory, aBaseMetaTileEntity, "Charging Bus"); + } + } - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { - if (aBaseMetaTileEntity.isServerSide() - && aBaseMetaTileEntity.hasInventoryBeenModified()) { - fillStacksIntoFirstSlots(); - } - if (aBaseMetaTileEntity.isServerSide()){ - if (aBaseMetaTileEntity.getMetaTileEntity() instanceof MetaTileEntity) { - MetaTileEntity mMetaTileEntity = (MetaTileEntity) aBaseMetaTileEntity.getMetaTileEntity(); - if (mMetaTileEntity.rechargerSlotCount() > 0 && aBaseMetaTileEntity.getStoredEU() > 0) { - for (int i = mMetaTileEntity.rechargerSlotStartIndex(), k = mMetaTileEntity.rechargerSlotCount() + i; i < k; i++) { - if (aBaseMetaTileEntity.getStoredEU() > 0 && mMetaTileEntity.mInventory[i] != null) { - for (int u=0;u<10;u++){ - aBaseMetaTileEntity.decreaseStoredEnergyUnits(GT_ModHandler.chargeElectricItem(mMetaTileEntity.mInventory[i], (int) Math.min(V[this.mTier] * 15, aBaseMetaTileEntity.getStoredEU()), (int) Math.min(Integer.MAX_VALUE, GT_Values.V[u]), false, false), true); - if (mMetaTileEntity.mInventory[i].stackSize <= 0){ - mMetaTileEntity.mInventory[i] = null; - } - } - } - } - } - else { - //Utils.LOG_INFO("reCharger Slot Count = "+mMetaTileEntity.rechargerSlotCount()); - //Utils.LOG_INFO("getStoredEU = "+aBaseMetaTileEntity.getStoredEU()); - //Utils.LOG_INFO("getEUVar = "+mMetaTileEntity.getEUVar()); - } - } - } - super.onPostTick(aBaseMetaTileEntity, aTimer); - } + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { + if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.hasInventoryBeenModified()) { + fillStacksIntoFirstSlots(); + } + if (aBaseMetaTileEntity.isServerSide()) { + if (aBaseMetaTileEntity.getMetaTileEntity() instanceof MetaTileEntity) { + MetaTileEntity mMetaTileEntity = (MetaTileEntity) aBaseMetaTileEntity.getMetaTileEntity(); + if (mMetaTileEntity.rechargerSlotCount() > 0 && aBaseMetaTileEntity.getStoredEU() > 0) { + for (int i = mMetaTileEntity.rechargerSlotStartIndex(), + k = mMetaTileEntity.rechargerSlotCount() + i; + i < k; + i++) { + if (aBaseMetaTileEntity.getStoredEU() > 0 && mMetaTileEntity.mInventory[i] != null) { + for (int u = 0; u < 10; u++) { + aBaseMetaTileEntity.decreaseStoredEnergyUnits( + GT_ModHandler.chargeElectricItem( + mMetaTileEntity.mInventory[i], + (int) Math.min(V[this.mTier] * 15, aBaseMetaTileEntity.getStoredEU()), + (int) Math.min(Integer.MAX_VALUE, GT_Values.V[u]), + false, + false), + true); + if (mMetaTileEntity.mInventory[i].stackSize <= 0) { + mMetaTileEntity.mInventory[i] = null; + } + } + } + } + } else { + // Utils.LOG_INFO("reCharger Slot Count = "+mMetaTileEntity.rechargerSlotCount()); + // Utils.LOG_INFO("getStoredEU = "+aBaseMetaTileEntity.getStoredEU()); + // Utils.LOG_INFO("getEUVar = "+mMetaTileEntity.getEUVar()); + } + } + } + super.onPostTick(aBaseMetaTileEntity, aTimer); + } - public void updateSlots() { - for (int i = 0; i < mInventory.length; i++) - if (mInventory[i] != null && mInventory[i].stackSize <= 0) - mInventory[i] = null; - fillStacksIntoFirstSlots(); - } + public void updateSlots() { + for (int i = 0; i < mInventory.length; i++) + if (mInventory[i] != null && mInventory[i].stackSize <= 0) mInventory[i] = null; + fillStacksIntoFirstSlots(); + } - protected void fillStacksIntoFirstSlots() { - for (int i = 0; i < mInventory.length; i++) - for (int j = i + 1; j < mInventory.length; j++) - if (mInventory[j] != null - && (mInventory[i] == null || GT_Utility.areStacksEqual( - mInventory[i], mInventory[j]))) { - GT_Utility.moveStackFromSlotAToSlotB( - getBaseMetaTileEntity(), getBaseMetaTileEntity(), j, - i, (byte) 64, (byte) 1, (byte) 64, (byte) 1); - } - } + protected void fillStacksIntoFirstSlots() { + for (int i = 0; i < mInventory.length; i++) + for (int j = i + 1; j < mInventory.length; j++) + if (mInventory[j] != null + && (mInventory[i] == null || GT_Utility.areStacksEqual(mInventory[i], mInventory[j]))) { + GT_Utility.moveStackFromSlotAToSlotB( + getBaseMetaTileEntity(), + getBaseMetaTileEntity(), + j, + i, + (byte) 64, + (byte) 1, + (byte) 64, + (byte) 1); + } + } - @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, - int aIndex, byte aSide, ItemStack aStack) { - return aSide == getBaseMetaTileEntity().getFrontFacing() - && (mRecipeMap == null || mRecipeMap.containsInput(aStack)); - } + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return aSide == getBaseMetaTileEntity().getFrontFacing() + && (mRecipeMap == null || mRecipeMap.containsInput(aStack)); + } - @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, - int aIndex, byte aSide, ItemStack aStack) { - return aSide == getBaseMetaTileEntity().getFrontFacing() - && (mRecipeMap == null || mRecipeMap.containsInput(aStack)); - } + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return aSide == getBaseMetaTileEntity().getFrontFacing() + && (mRecipeMap == null || mRecipeMap.containsInput(aStack)); + } - @Override - public int rechargerSlotStartIndex() { - return 0; - } + @Override + public int rechargerSlotStartIndex() { + return 0; + } - @Override - public int rechargerSlotCount() { - switch (mTier) { - case 2 : - return 4; - case 4 : - return 16; - default : - return 16; - } - } + @Override + public int rechargerSlotCount() { + switch (mTier) { + case 2: + return 4; + case 4: + return 16; + default: + return 16; + } + } - @Override - public int dechargerSlotStartIndex() { - return 0; - } + @Override + public int dechargerSlotStartIndex() { + return 0; + } - @Override - public int dechargerSlotCount() { - return 0; - } + @Override + public int dechargerSlotCount() { + return 0; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler_Adv.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler_Adv.java index ba4e394114..94b927c80d 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler_Adv.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler_Adv.java @@ -24,306 +24,314 @@ import net.minecraftforge.common.util.ForgeDirection; public class GT_MetaTileEntity_Hatch_Muffler_Adv extends GT_MetaTileEntity_Hatch_Muffler { - protected int SLOT_FILTER = 0; - - @Override - public void onConfigLoad(GT_Config aConfig) { - super.onConfigLoad(aConfig); - if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK || CORE.GTNH) { - try { - Integer a1 = (int) StaticFields59.getFieldFromGregtechProxy("mPollutionSmogLimit"); - if (a1 != null && a1 > 0) { - mPollutionSmogLimit = a1; - } - } - catch (Throwable t) { - mPollutionSmogLimit = 500000; - } - } - } - - private int mPollutionSmogLimit = 500000; - - public GT_MetaTileEntity_Hatch_Muffler_Adv(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier); - ReflectionUtils.setField(this, "mInventory", new ItemStack[1]); - } - - public GT_MetaTileEntity_Hatch_Muffler_Adv(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { - super(aName, aTier, aDescription, aTextures); - ReflectionUtils.setField(this, "mInventory", new ItemStack[1]); - } - - public GT_MetaTileEntity_Hatch_Muffler_Adv(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { - super(aName, aTier, aDescription[0], aTextures); - ReflectionUtils.setField(this, "mInventory", new ItemStack[1]); - } - - public String[] getDescription() { - if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { - String[] mDescArray = StaticFields59.getDescriptionArray(this); - String[] desc = new String[mDescArray.length + 7]; - System.arraycopy(mDescArray, 0, desc, 0, mDescArray.length); - desc[mDescArray.length] = "DO NOT OBSTRUCT THE OUTPUT!"; - desc[mDescArray.length + 1] = "Requires 3 Air on the exhaust face"; - desc[mDescArray.length + 2] = "Requires Air Filters"; - desc[mDescArray.length + 3] = "Mufflers require T2 Filters from IV-"+GT_Values.VN[9]; - desc[mDescArray.length + 4] = "Reduces Pollution to " + this.calculatePollutionReductionForTooltip(100) + "%"; - desc[mDescArray.length + 5] = "Recovers " + (105 - this.calculatePollutionReductionForTooltip(100)) + "% of CO2/CO/SO2"; - desc[mDescArray.length + 6] = CORE.GT_Tooltip; - return desc; - } - else { - return new String[] {}; - } - } - - public ITexture[] getTexturesActive(ITexture aBaseTexture) { - return new ITexture[]{aBaseTexture, new GT_RenderedTexture(TexturesGtBlock.Overlay_Hatch_Muffler_Adv)}; - } - - public ITexture[] getTexturesInactive(ITexture aBaseTexture) { - return new ITexture[]{aBaseTexture, new GT_RenderedTexture(TexturesGtBlock.Overlay_Hatch_Muffler_Adv)}; - } - - public boolean isValidSlot(int aIndex) { - return aIndex == SLOT_FILTER; - } - - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_Hatch_Muffler_Adv(this.mName, this.mTier, StaticFields59.getDescriptionArray(this), this.mTextures); - } - - @Override - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, - EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) - return true; - aBaseMetaTileEntity.openGUI(aPlayer); - return true; - } - - - - public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new CONTAINER_Hatch_Muffler_Advanced(aPlayerInventory, aBaseMetaTileEntity); - } - - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GUI_Hatch_Muffler_Advanced(aPlayerInventory, aBaseMetaTileEntity, "Advanced Muffler", "machine_Charger.png"); - } - - private boolean airCheck() { - if ( - this.getBaseMetaTileEntity().getAirAtSide(this.getBaseMetaTileEntity().getFrontFacing()) && - this.getBaseMetaTileEntity().getAirAtSideAndDistance(this.getBaseMetaTileEntity().getFrontFacing(), 1) && - this.getBaseMetaTileEntity().getAirAtSideAndDistance(this.getBaseMetaTileEntity().getFrontFacing(), 2) - ) { - return true; - } - return false; - } - - public boolean polluteEnvironment() { - if (airCheck() && damageAirFilter()) { - int aEmission = this.calculatePollutionReduction(10000); - PollutionUtils.addPollution(this.getBaseMetaTileEntity(), aEmission); - //Logger.INFO("Outputting "+aEmission+"gbl"); - return true; - } else { - //Logger.INFO("Failed to output pollution"); - return false; - } - } - - - public int calculatePollutionReductionForTooltip(int aPollution) { - return (int) (aPollution * Math.pow(0.64D, (double) (this.mTier - 1))); - } - - public int calculatePollutionReduction(int aPollution) { - double aVal1 = aPollution * Math.pow(0.64D, (double) (this.mTier - 1)); - int aVal2 = (int) aVal1; - if (!hasValidFilter()) { - aVal2 = (int) ((double) aPollution * Math.pow(0.7D, (double) (this.mTier - 1)));; - } - return aVal2; - } - - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - if (aIndex == this.SLOT_FILTER) { - if (isAirFilter(aStack)) { - return true; - } - } - return false; - } - - private ItemStack getInventoryStack() { - if (this.mInventory != null && this.mInventory.length > 0) { - if (this.mInventory.length-1 >= this.SLOT_FILTER) { - return this.mInventory[this.SLOT_FILTER]; - } - } - return null; - } - - private void breakAirFilter() { - if (this.mInventory != null && this.mInventory.length > 0) { - if (this.mInventory.length-1 >= this.SLOT_FILTER) { - Logger.INFO("Breaking Filter"); - this.mInventory[this.SLOT_FILTER] = null; - } - } - } - - public boolean hasValidFilter() { - return isAirFilter(getInventoryStack()); - } - - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - - //Logger.INFO("A1"); - - super.onPostTick(aBaseMetaTileEntity, aTick); - - //Logger.INFO("A2"); - - String aParticleName; - if ((aTick % 2) == 0){ - aParticleName = "cloud"; - } - else { - aParticleName = "smoke"; - } - - //Logger.INFO("A3"); - - if (aBaseMetaTileEntity.isClientSide()) { - //Logger.INFO("B1"); - if (this.getBaseMetaTileEntity().isActive()) { - //Logger.INFO("C1"); - this.pollutionParticles(this.getBaseMetaTileEntity().getWorld(), aParticleName); - } - //return; - } - else { - //Logger.INFO("B2"); - if (this.getInventoryStack() == null) { - //Logger.INFO("D1"); - //Logger.INFO("Empty - "+this.mInventory.length); - } - else { - //Logger.INFO("D2"); - } - } - //Logger.INFO("A4"); - - - - } - - public boolean isAirFilter(ItemStack filter){ - if (filter == null) { - return false; - } - if (filter.getItem() instanceof ItemAirFilter){ - - if (this.mTier < 5) { - return true; - } - else { - if (filter.getItemDamage() == 1) { - return true; - } - } - } - return false; - } - - public boolean damageAirFilter(){ - ItemStack filter = getInventoryStack(); - if (filter == null) { - return false; - } - - if (isAirFilter(filter)){ - long currentUse = ItemAirFilter.getFilterDamage(filter); - Logger.INFO("Filter Damage: "+currentUse); - //Remove broken Filter - if ((filter.getItemDamage() == 0 && currentUse >= 50-1) || (filter.getItemDamage() == 1 && currentUse >= 2500-1)){ - breakAirFilter(); - return true; - } - else { - //Do Damage - ItemAirFilter.setFilterDamage(filter, currentUse+1); - Logger.INFO("Filter Damage now: "+currentUse); - return true; - } - } - return false; - } - - public void pollutionParticles(World aWorld, String name) { - float ran1 = CORE.RANDOM.nextFloat(); - float ran2 = 0.0F; - float ran3 = 0.0F; - boolean chk1 = ran1 * 100.0F < (float) this.calculatePollutionReduction(100); - boolean chk2; - boolean chk3; - int aPollutionAmount = PollutionUtils.getPollution(getBaseMetaTileEntity()); - if (aPollutionAmount >= mPollutionSmogLimit) { - ran2 = CORE.RANDOM.nextFloat(); - ran3 = CORE.RANDOM.nextFloat(); - chk2 = ran2 * 100.0F < (float) this.calculatePollutionReduction(100); - chk3 = ran3 * 100.0F < (float) this.calculatePollutionReduction(100); - if (!chk1 && !chk2 && !chk3) { - return; - } - } else { - if (!chk1) { - return; - } - - chk3 = false; - chk2 = false; - } - - IGregTechTileEntity aMuffler = this.getBaseMetaTileEntity(); - ForgeDirection aDir = ForgeDirection.getOrientation(aMuffler.getFrontFacing()); - float xPos = (float) aDir.offsetX * 0.76F + (float) aMuffler.getXCoord() + 0.25F; - float yPos = (float) aDir.offsetY * 0.76F + (float) aMuffler.getYCoord() + 0.25F; - float zPos = (float) aDir.offsetZ * 0.76F + (float) aMuffler.getZCoord() + 0.25F; - float ySpd = (float) aDir.offsetY * 0.1F + 0.2F + 0.1F * CORE.RANDOM.nextFloat(); - float xSpd; - float zSpd; - if (aDir.offsetY == -1) { - float temp = CORE.RANDOM.nextFloat() * 2.0F * CORE.PI; - xSpd = (float) Math.sin((double) temp) * 0.1F; - zSpd = (float) Math.cos((double) temp) * 0.1F; - } else { - xSpd = (float) aDir.offsetX * (0.1F + 0.2F * CORE.RANDOM.nextFloat()); - zSpd = (float) aDir.offsetZ * (0.1F + 0.2F * CORE.RANDOM.nextFloat()); - } - - if (chk1) { - aWorld.spawnParticle(name, (double) (xPos + ran1 * 0.5F), (double) (yPos + CORE.RANDOM.nextFloat() * 0.5F), - (double) (zPos + CORE.RANDOM.nextFloat() * 0.5F), (double) xSpd, (double) ySpd, (double) zSpd); - } - - if (chk2) { - aWorld.spawnParticle(name, (double) (xPos + ran2 * 0.5F), (double) (yPos + CORE.RANDOM.nextFloat() * 0.5F), - (double) (zPos + CORE.RANDOM.nextFloat() * 0.5F), (double) xSpd, (double) ySpd, (double) zSpd); - } - - if (chk3) { - aWorld.spawnParticle(name, (double) (xPos + ran3 * 0.5F), (double) (yPos + CORE.RANDOM.nextFloat() * 0.5F), - (double) (zPos + CORE.RANDOM.nextFloat() * 0.5F), (double) xSpd, (double) ySpd, (double) zSpd); - } - - } - - - -}
\ No newline at end of file + protected int SLOT_FILTER = 0; + + @Override + public void onConfigLoad(GT_Config aConfig) { + super.onConfigLoad(aConfig); + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK || CORE.GTNH) { + try { + Integer a1 = (int) StaticFields59.getFieldFromGregtechProxy("mPollutionSmogLimit"); + if (a1 != null && a1 > 0) { + mPollutionSmogLimit = a1; + } + } catch (Throwable t) { + mPollutionSmogLimit = 500000; + } + } + } + + private int mPollutionSmogLimit = 500000; + + public GT_MetaTileEntity_Hatch_Muffler_Adv(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier); + ReflectionUtils.setField(this, "mInventory", new ItemStack[1]); + } + + public GT_MetaTileEntity_Hatch_Muffler_Adv(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + ReflectionUtils.setField(this, "mInventory", new ItemStack[1]); + } + + public GT_MetaTileEntity_Hatch_Muffler_Adv( + String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription[0], aTextures); + ReflectionUtils.setField(this, "mInventory", new ItemStack[1]); + } + + public String[] getDescription() { + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { + String[] mDescArray = StaticFields59.getDescriptionArray(this); + String[] desc = new String[mDescArray.length + 7]; + System.arraycopy(mDescArray, 0, desc, 0, mDescArray.length); + desc[mDescArray.length] = "DO NOT OBSTRUCT THE OUTPUT!"; + desc[mDescArray.length + 1] = "Requires 3 Air on the exhaust face"; + desc[mDescArray.length + 2] = "Requires Air Filters"; + desc[mDescArray.length + 3] = "Mufflers require T2 Filters from IV-" + GT_Values.VN[9]; + desc[mDescArray.length + 4] = + "Reduces Pollution to " + this.calculatePollutionReductionForTooltip(100) + "%"; + desc[mDescArray.length + 5] = + "Recovers " + (105 - this.calculatePollutionReductionForTooltip(100)) + "% of CO2/CO/SO2"; + desc[mDescArray.length + 6] = CORE.GT_Tooltip; + return desc; + } else { + return new String[] {}; + } + } + + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + return new ITexture[] {aBaseTexture, new GT_RenderedTexture(TexturesGtBlock.Overlay_Hatch_Muffler_Adv)}; + } + + public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + return new ITexture[] {aBaseTexture, new GT_RenderedTexture(TexturesGtBlock.Overlay_Hatch_Muffler_Adv)}; + } + + public boolean isValidSlot(int aIndex) { + return aIndex == SLOT_FILTER; + } + + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_Hatch_Muffler_Adv( + this.mName, this.mTier, StaticFields59.getDescriptionArray(this), this.mTextures); + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) return true; + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new CONTAINER_Hatch_Muffler_Advanced(aPlayerInventory, aBaseMetaTileEntity); + } + + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_Hatch_Muffler_Advanced( + aPlayerInventory, aBaseMetaTileEntity, "Advanced Muffler", "machine_Charger.png"); + } + + private boolean airCheck() { + if (this.getBaseMetaTileEntity() + .getAirAtSide(this.getBaseMetaTileEntity().getFrontFacing()) + && this.getBaseMetaTileEntity() + .getAirAtSideAndDistance(this.getBaseMetaTileEntity().getFrontFacing(), 1) + && this.getBaseMetaTileEntity() + .getAirAtSideAndDistance(this.getBaseMetaTileEntity().getFrontFacing(), 2)) { + return true; + } + return false; + } + + public boolean polluteEnvironment() { + if (airCheck() && damageAirFilter()) { + int aEmission = this.calculatePollutionReduction(10000); + PollutionUtils.addPollution(this.getBaseMetaTileEntity(), aEmission); + // Logger.INFO("Outputting "+aEmission+"gbl"); + return true; + } else { + // Logger.INFO("Failed to output pollution"); + return false; + } + } + + public int calculatePollutionReductionForTooltip(int aPollution) { + return (int) (aPollution * Math.pow(0.64D, (double) (this.mTier - 1))); + } + + public int calculatePollutionReduction(int aPollution) { + double aVal1 = aPollution * Math.pow(0.64D, (double) (this.mTier - 1)); + int aVal2 = (int) aVal1; + if (!hasValidFilter()) { + aVal2 = (int) ((double) aPollution * Math.pow(0.7D, (double) (this.mTier - 1))); + ; + } + return aVal2; + } + + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + if (aIndex == this.SLOT_FILTER) { + if (isAirFilter(aStack)) { + return true; + } + } + return false; + } + + private ItemStack getInventoryStack() { + if (this.mInventory != null && this.mInventory.length > 0) { + if (this.mInventory.length - 1 >= this.SLOT_FILTER) { + return this.mInventory[this.SLOT_FILTER]; + } + } + return null; + } + + private void breakAirFilter() { + if (this.mInventory != null && this.mInventory.length > 0) { + if (this.mInventory.length - 1 >= this.SLOT_FILTER) { + Logger.INFO("Breaking Filter"); + this.mInventory[this.SLOT_FILTER] = null; + } + } + } + + public boolean hasValidFilter() { + return isAirFilter(getInventoryStack()); + } + + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + + // Logger.INFO("A1"); + + super.onPostTick(aBaseMetaTileEntity, aTick); + + // Logger.INFO("A2"); + + String aParticleName; + if ((aTick % 2) == 0) { + aParticleName = "cloud"; + } else { + aParticleName = "smoke"; + } + + // Logger.INFO("A3"); + + if (aBaseMetaTileEntity.isClientSide()) { + // Logger.INFO("B1"); + if (this.getBaseMetaTileEntity().isActive()) { + // Logger.INFO("C1"); + this.pollutionParticles(this.getBaseMetaTileEntity().getWorld(), aParticleName); + } + // return; + } else { + // Logger.INFO("B2"); + if (this.getInventoryStack() == null) { + // Logger.INFO("D1"); + // Logger.INFO("Empty - "+this.mInventory.length); + } else { + // Logger.INFO("D2"); + } + } + // Logger.INFO("A4"); + + } + + public boolean isAirFilter(ItemStack filter) { + if (filter == null) { + return false; + } + if (filter.getItem() instanceof ItemAirFilter) { + + if (this.mTier < 5) { + return true; + } else { + if (filter.getItemDamage() == 1) { + return true; + } + } + } + return false; + } + + public boolean damageAirFilter() { + ItemStack filter = getInventoryStack(); + if (filter == null) { + return false; + } + + if (isAirFilter(filter)) { + long currentUse = ItemAirFilter.getFilterDamage(filter); + Logger.INFO("Filter Damage: " + currentUse); + // Remove broken Filter + if ((filter.getItemDamage() == 0 && currentUse >= 50 - 1) + || (filter.getItemDamage() == 1 && currentUse >= 2500 - 1)) { + breakAirFilter(); + return true; + } else { + // Do Damage + ItemAirFilter.setFilterDamage(filter, currentUse + 1); + Logger.INFO("Filter Damage now: " + currentUse); + return true; + } + } + return false; + } + + public void pollutionParticles(World aWorld, String name) { + float ran1 = CORE.RANDOM.nextFloat(); + float ran2 = 0.0F; + float ran3 = 0.0F; + boolean chk1 = ran1 * 100.0F < (float) this.calculatePollutionReduction(100); + boolean chk2; + boolean chk3; + int aPollutionAmount = PollutionUtils.getPollution(getBaseMetaTileEntity()); + if (aPollutionAmount >= mPollutionSmogLimit) { + ran2 = CORE.RANDOM.nextFloat(); + ran3 = CORE.RANDOM.nextFloat(); + chk2 = ran2 * 100.0F < (float) this.calculatePollutionReduction(100); + chk3 = ran3 * 100.0F < (float) this.calculatePollutionReduction(100); + if (!chk1 && !chk2 && !chk3) { + return; + } + } else { + if (!chk1) { + return; + } + + chk3 = false; + chk2 = false; + } + + IGregTechTileEntity aMuffler = this.getBaseMetaTileEntity(); + ForgeDirection aDir = ForgeDirection.getOrientation(aMuffler.getFrontFacing()); + float xPos = (float) aDir.offsetX * 0.76F + (float) aMuffler.getXCoord() + 0.25F; + float yPos = (float) aDir.offsetY * 0.76F + (float) aMuffler.getYCoord() + 0.25F; + float zPos = (float) aDir.offsetZ * 0.76F + (float) aMuffler.getZCoord() + 0.25F; + float ySpd = (float) aDir.offsetY * 0.1F + 0.2F + 0.1F * CORE.RANDOM.nextFloat(); + float xSpd; + float zSpd; + if (aDir.offsetY == -1) { + float temp = CORE.RANDOM.nextFloat() * 2.0F * CORE.PI; + xSpd = (float) Math.sin((double) temp) * 0.1F; + zSpd = (float) Math.cos((double) temp) * 0.1F; + } else { + xSpd = (float) aDir.offsetX * (0.1F + 0.2F * CORE.RANDOM.nextFloat()); + zSpd = (float) aDir.offsetZ * (0.1F + 0.2F * CORE.RANDOM.nextFloat()); + } + + if (chk1) { + aWorld.spawnParticle( + name, + (double) (xPos + ran1 * 0.5F), + (double) (yPos + CORE.RANDOM.nextFloat() * 0.5F), + (double) (zPos + CORE.RANDOM.nextFloat() * 0.5F), + (double) xSpd, + (double) ySpd, + (double) zSpd); + } + + if (chk2) { + aWorld.spawnParticle( + name, + (double) (xPos + ran2 * 0.5F), + (double) (yPos + CORE.RANDOM.nextFloat() * 0.5F), + (double) (zPos + CORE.RANDOM.nextFloat() * 0.5F), + (double) xSpd, + (double) ySpd, + (double) zSpd); + } + + if (chk3) { + aWorld.spawnParticle( + name, + (double) (xPos + ran3 * 0.5F), + (double) (yPos + CORE.RANDOM.nextFloat() * 0.5F), + (double) (zPos + CORE.RANDOM.nextFloat() * 0.5F), + (double) xSpd, + (double) ySpd, + (double) zSpd); + } + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Naquadah.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Naquadah.java index d0f1d8e03f..350b7a788a 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Naquadah.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Naquadah.java @@ -1,7 +1,5 @@ package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; -import java.lang.reflect.Field; - import gregtech.api.enums.Materials; import gregtech.api.enums.Textures; import gregtech.api.enums.Textures.BlockIcons; @@ -15,194 +13,209 @@ import gregtech.api.util.GT_Utility; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.gregtech.common.StaticFields59; +import java.lang.reflect.Field; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.fluids.FluidStack; public class GT_MetaTileEntity_Hatch_Naquadah extends GT_MetaTileEntity_Hatch_Input { - public final FluidStack[] mFluidsToUse = new FluidStack[3]; - public final int mFluidCapacity; - - public GT_MetaTileEntity_Hatch_Naquadah(final int aID, final String aName, final String aNameRegional) { - super(aID, aName, aNameRegional, 6); - mFluidCapacity = 32000; - initHatch(); - } - - public GT_MetaTileEntity_Hatch_Naquadah(final String aName, final String aDescription, - final ITexture[][][] aTextures) { - super(aName, 6, aDescription, aTextures); - mFluidCapacity = 32000; - initHatch(); - } - - public GT_MetaTileEntity_Hatch_Naquadah(final String aName, final String[] aDescription, - final ITexture[][][] aTextures) { - super(aName, 6, aDescription[0], aTextures); - mFluidCapacity = 32000; - initHatch(); - } - - private void initHatch() { - if (mFluidsToUse[0] == null) { - mFluidsToUse[0] = Materials.Naquadah.getMolten(1); - } - if (mFluidsToUse[1] == null) { - mFluidsToUse[1] = Materials.NaquadahEnriched.getMolten(1); - } - if (mFluidsToUse[2] == null) { - mFluidsToUse[2] = Materials.Naquadria.getMolten(1); - } - } - - public ITexture[] getTexturesActive(final ITexture aBaseTexture) { - return new ITexture[] { aBaseTexture, new GT_RenderedTexture((IIconContainer) Textures.BlockIcons.NAQUADAH_REACTOR_FLUID_SIDE_ACTIVE) }; - } - - public ITexture[] getTexturesInactive(final ITexture aBaseTexture) { - return new ITexture[] { aBaseTexture, new GT_RenderedTexture((IIconContainer) Textures.BlockIcons.NAQUADAH_REACTOR_FLUID_SIDE) }; - } - - public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, - final ItemStack aStack) { - if (aSide == aBaseMetaTileEntity.getFrontFacing() && aIndex == 0) { - for (FluidStack f : mFluidsToUse) { - if (f != null) { - if (GT_Utility.getFluidForFilledItem(aStack, true).getFluid() == f.getFluid()) { - return true; - } - } - } - } - return false; - } - - public boolean isFluidInputAllowed(final FluidStack aFluid) { - for (FluidStack f : mFluidsToUse) { - if (f != null) { - if (aFluid.getFluid() == f.getFluid()) { - return true; - } - } - } - return false; - } - - public int getCapacity() { - return this.mFluidCapacity; - } - - public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return (MetaTileEntity) new GT_MetaTileEntity_Hatch_Naquadah(this.mName, this.mDescription, this.mTextures); - } - - @Override - public String[] getDescription() { - if (aDescCache[0] == null || aDescCache[0].contains(".name") || aDescCache[0].contains("fluid.")) { - aDescCache[0] = formatFluidString(this.mFluidsToUse[0]); - } - if (aDescCache[1] == null || aDescCache[1].contains(".name") || aDescCache[1].contains("fluid.")) { - aDescCache[1] = formatFluidString(this.mFluidsToUse[1]); - } - if (aDescCache[2] == null || aDescCache[2].contains(".name") || aDescCache[2].contains("fluid.")) { - aDescCache[2] = formatFluidString(this.mFluidsToUse[2]); - } - String aNaq = aDescCache[0]; - String aEnrNaq = aDescCache[1]; - String aNaquad = aDescCache[2]; - String[] s2 = new String[]{ - "Fluid Input for Multiblocks", - "Capacity: " + getCapacity()+"L", - "Accepted Fluid: " + aNaq, - "Accepted Fluid: " + aEnrNaq, - "Accepted Fluid: " + aNaquad, - CORE.GT_Tooltip - }; - return s2; - } - - private static String[] aDescCache = new String[3]; - private String formatFluidString(FluidStack f) { - FluidStack mLockedStack = f; - Integer mLockedTemp = 0;; - String mTempMod = ""+EnumChatFormatting.RESET; - mLockedTemp = mLockedStack.getFluid().getTemperature(); - if (mLockedTemp != null) { - if (mLockedTemp <= -3000) { - mTempMod = ""+EnumChatFormatting.DARK_PURPLE; - } - else if (mLockedTemp >= -2999 && mLockedTemp <= -500) { - mTempMod = ""+EnumChatFormatting.DARK_BLUE; - } - else if (mLockedTemp >= -499 && mLockedTemp <= -50) { - mTempMod = ""+EnumChatFormatting.BLUE; - } - else if (mLockedTemp >= 30 && mLockedTemp <= 300) { - mTempMod = ""+EnumChatFormatting.AQUA; - } - else if (mLockedTemp >= 301 && mLockedTemp <= 800) { - mTempMod = ""+EnumChatFormatting.YELLOW; - } - else if (mLockedTemp >= 801 && mLockedTemp <= 1500) { - mTempMod = ""+EnumChatFormatting.GOLD; - } - else if (mLockedTemp >= 1501) { - mTempMod = ""+EnumChatFormatting.RED; - } - } - return mTempMod + mLockedStack.getLocalizedName(); - } - - @Override - public boolean doesFillContainers() { - return false; - } - - @Override - public ITexture[][][] getTextureSet(ITexture[] aTextures) { - // TODO Auto-generated method stub - return super.getTextureSet(aTextures); - } - - private Field F1, F2; - - - @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - byte a1 = 0, a2 = 0; - try { - if (F1 == null) { - F1 = ReflectionUtils.getField(getClass(), "actualTexture"); - } - if (F2 == null) { - F2 = ReflectionUtils.getField(getClass(), "mTexturePage"); - } - - if (F1 != null) { - a1 = F1.getByte(this); - } - if (F2 != null) { - a2 = F2.getByte(this); - } - } - catch (IllegalArgumentException | IllegalAccessException n) {} - - int textureIndex = a1 | a2 << 7; - byte texturePointer = (byte) (a1 & 127); - - - - if (aSide == 1 || aSide == 0) { - ITexture g = textureIndex > 0 ? StaticFields59.getCasingTexturePages(a2, texturePointer) : BlockIcons.MACHINE_CASINGS[this.mTier][aColorIndex + 1]; - - return new ITexture[] {g, new GT_RenderedTexture((IIconContainer) Textures.BlockIcons.NAQUADAH_REACTOR_FLUID_TOP_ACTIVE) }; - } - - return aSide != aFacing ? - (textureIndex > 0 ? new ITexture[] { StaticFields59.getCasingTexturePages(a2, texturePointer) } : new ITexture[] { BlockIcons.MACHINE_CASINGS[this.mTier][aColorIndex + 1] }) - : (textureIndex > 0 ? (aActive ? this.getTexturesActive(StaticFields59.getCasingTexturePages(a2, texturePointer)) : this.getTexturesInactive(StaticFields59.getCasingTexturePages(a2, texturePointer))) - : (aActive ? this.getTexturesActive(BlockIcons.MACHINE_CASINGS[this.mTier][aColorIndex + 1]) : this.getTexturesInactive(BlockIcons.MACHINE_CASINGS[this.mTier][aColorIndex + 1]))); - } - + public final FluidStack[] mFluidsToUse = new FluidStack[3]; + public final int mFluidCapacity; + + public GT_MetaTileEntity_Hatch_Naquadah(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional, 6); + mFluidCapacity = 32000; + initHatch(); + } + + public GT_MetaTileEntity_Hatch_Naquadah( + final String aName, final String aDescription, final ITexture[][][] aTextures) { + super(aName, 6, aDescription, aTextures); + mFluidCapacity = 32000; + initHatch(); + } + + public GT_MetaTileEntity_Hatch_Naquadah( + final String aName, final String[] aDescription, final ITexture[][][] aTextures) { + super(aName, 6, aDescription[0], aTextures); + mFluidCapacity = 32000; + initHatch(); + } + + private void initHatch() { + if (mFluidsToUse[0] == null) { + mFluidsToUse[0] = Materials.Naquadah.getMolten(1); + } + if (mFluidsToUse[1] == null) { + mFluidsToUse[1] = Materials.NaquadahEnriched.getMolten(1); + } + if (mFluidsToUse[2] == null) { + mFluidsToUse[2] = Materials.Naquadria.getMolten(1); + } + } + + public ITexture[] getTexturesActive(final ITexture aBaseTexture) { + return new ITexture[] { + aBaseTexture, + new GT_RenderedTexture((IIconContainer) Textures.BlockIcons.NAQUADAH_REACTOR_FLUID_SIDE_ACTIVE) + }; + } + + public ITexture[] getTexturesInactive(final ITexture aBaseTexture) { + return new ITexture[] { + aBaseTexture, new GT_RenderedTexture((IIconContainer) Textures.BlockIcons.NAQUADAH_REACTOR_FLUID_SIDE) + }; + } + + public boolean allowPutStack( + final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + if (aSide == aBaseMetaTileEntity.getFrontFacing() && aIndex == 0) { + for (FluidStack f : mFluidsToUse) { + if (f != null) { + if (GT_Utility.getFluidForFilledItem(aStack, true).getFluid() == f.getFluid()) { + return true; + } + } + } + } + return false; + } + + public boolean isFluidInputAllowed(final FluidStack aFluid) { + for (FluidStack f : mFluidsToUse) { + if (f != null) { + if (aFluid.getFluid() == f.getFluid()) { + return true; + } + } + } + return false; + } + + public int getCapacity() { + return this.mFluidCapacity; + } + + public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return (MetaTileEntity) new GT_MetaTileEntity_Hatch_Naquadah(this.mName, this.mDescription, this.mTextures); + } + + @Override + public String[] getDescription() { + if (aDescCache[0] == null || aDescCache[0].contains(".name") || aDescCache[0].contains("fluid.")) { + aDescCache[0] = formatFluidString(this.mFluidsToUse[0]); + } + if (aDescCache[1] == null || aDescCache[1].contains(".name") || aDescCache[1].contains("fluid.")) { + aDescCache[1] = formatFluidString(this.mFluidsToUse[1]); + } + if (aDescCache[2] == null || aDescCache[2].contains(".name") || aDescCache[2].contains("fluid.")) { + aDescCache[2] = formatFluidString(this.mFluidsToUse[2]); + } + String aNaq = aDescCache[0]; + String aEnrNaq = aDescCache[1]; + String aNaquad = aDescCache[2]; + String[] s2 = new String[] { + "Fluid Input for Multiblocks", + "Capacity: " + getCapacity() + "L", + "Accepted Fluid: " + aNaq, + "Accepted Fluid: " + aEnrNaq, + "Accepted Fluid: " + aNaquad, + CORE.GT_Tooltip + }; + return s2; + } + + private static String[] aDescCache = new String[3]; + + private String formatFluidString(FluidStack f) { + FluidStack mLockedStack = f; + Integer mLockedTemp = 0; + ; + String mTempMod = "" + EnumChatFormatting.RESET; + mLockedTemp = mLockedStack.getFluid().getTemperature(); + if (mLockedTemp != null) { + if (mLockedTemp <= -3000) { + mTempMod = "" + EnumChatFormatting.DARK_PURPLE; + } else if (mLockedTemp >= -2999 && mLockedTemp <= -500) { + mTempMod = "" + EnumChatFormatting.DARK_BLUE; + } else if (mLockedTemp >= -499 && mLockedTemp <= -50) { + mTempMod = "" + EnumChatFormatting.BLUE; + } else if (mLockedTemp >= 30 && mLockedTemp <= 300) { + mTempMod = "" + EnumChatFormatting.AQUA; + } else if (mLockedTemp >= 301 && mLockedTemp <= 800) { + mTempMod = "" + EnumChatFormatting.YELLOW; + } else if (mLockedTemp >= 801 && mLockedTemp <= 1500) { + mTempMod = "" + EnumChatFormatting.GOLD; + } else if (mLockedTemp >= 1501) { + mTempMod = "" + EnumChatFormatting.RED; + } + } + return mTempMod + mLockedStack.getLocalizedName(); + } + + @Override + public boolean doesFillContainers() { + return false; + } + + @Override + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + // TODO Auto-generated method stub + return super.getTextureSet(aTextures); + } + + private Field F1, F2; + + @Override + public ITexture[] getTexture( + IGregTechTileEntity aBaseMetaTileEntity, + byte aSide, + byte aFacing, + byte aColorIndex, + boolean aActive, + boolean aRedstone) { + byte a1 = 0, a2 = 0; + try { + if (F1 == null) { + F1 = ReflectionUtils.getField(getClass(), "actualTexture"); + } + if (F2 == null) { + F2 = ReflectionUtils.getField(getClass(), "mTexturePage"); + } + + if (F1 != null) { + a1 = F1.getByte(this); + } + if (F2 != null) { + a2 = F2.getByte(this); + } + } catch (IllegalArgumentException | IllegalAccessException n) { + } + + int textureIndex = a1 | a2 << 7; + byte texturePointer = (byte) (a1 & 127); + + if (aSide == 1 || aSide == 0) { + ITexture g = textureIndex > 0 + ? StaticFields59.getCasingTexturePages(a2, texturePointer) + : BlockIcons.MACHINE_CASINGS[this.mTier][aColorIndex + 1]; + + return new ITexture[] { + g, new GT_RenderedTexture((IIconContainer) Textures.BlockIcons.NAQUADAH_REACTOR_FLUID_TOP_ACTIVE) + }; + } + + return aSide != aFacing + ? (textureIndex > 0 + ? new ITexture[] {StaticFields59.getCasingTexturePages(a2, texturePointer)} + : new ITexture[] {BlockIcons.MACHINE_CASINGS[this.mTier][aColorIndex + 1]}) + : (textureIndex > 0 + ? (aActive + ? this.getTexturesActive(StaticFields59.getCasingTexturePages(a2, texturePointer)) + : this.getTexturesInactive(StaticFields59.getCasingTexturePages(a2, texturePointer))) + : (aActive + ? this.getTexturesActive(BlockIcons.MACHINE_CASINGS[this.mTier][aColorIndex + 1]) + : this.getTexturesInactive(BlockIcons.MACHINE_CASINGS[this.mTier][aColorIndex + 1]))); + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBattery.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBattery.java index ba97cc38eb..d6b0a570ac 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBattery.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBattery.java @@ -2,10 +2,6 @@ package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; import static gregtech.api.enums.GT_Values.V; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.item.ItemStack; - import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; @@ -13,224 +9,215 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Utility; - import gtPlusPlus.core.lib.CORE; import gtPlusPlus.xmod.gregtech.api.gui.hatches.charge.*; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; -public class GT_MetaTileEntity_Hatch_OutputBattery -extends -GT_MetaTileEntity_Hatch { - public GT_MetaTileEntity_Hatch_OutputBattery(int aID, String aName, - String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, getSlots(aTier), - "Dischargeable Item Bus for Multiblocks"); - } - - public GT_MetaTileEntity_Hatch_OutputBattery(String aName, int aTier, - String aDescription, ITexture[][][] aTextures) { - super(aName, aTier, - aTier < 1 ? 1 : aTier == 1 ? 4 : aTier == 2 ? 9 : 16, - aDescription, aTextures); - } - - - @Override - public String[] getDescription() { - int mSlots = 0; - if (this.mTier == 2) { - mSlots = 4; - } - else if (this.mTier == 4) { - mSlots = 16; - } - else { - mSlots = 16; - } - return new String[]{ - this.mDescription, - "Capacity: " + mSlots + " slots", - CORE.GT_Tooltip}; - } - - @Override - public boolean isEnetOutput() { - return true; - } - - @Override - public boolean isOutputFacing(byte aSide) { - return aSide == getBaseMetaTileEntity().getFrontFacing(); - } - - @Override - public long getMinimumStoredEU() { - return 0; - } - - @Override - public long maxEUOutput() { - return V[mTier]; - } - - @Override - public long maxEUStore() { - return 512 + V[mTier + 1] * 8; - } - - @Override - public ITexture[] getTexturesActive(ITexture aBaseTexture) { - return new ITexture[]{aBaseTexture, - new GT_RenderedTexture(TexturesGtBlock.Overlay_Hatch_Discharger)}; - } - - @Override - public ITexture[] getTexturesInactive(ITexture aBaseTexture) { - return new ITexture[]{aBaseTexture, - new GT_RenderedTexture(TexturesGtBlock.Overlay_Hatch_Discharger)}; - } - - @Override - public boolean isSimpleMachine() { - return true; - } - - @Override - public boolean isFacingValid(byte aFacing) { - return true; - } - - @Override - public boolean isAccessAllowed(EntityPlayer aPlayer) { - return true; - } - - @Override - public boolean isValidSlot(int aIndex) { - return true; - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_Hatch_OutputBattery(mName, mTier, - mDescription, mTextures); - } - - @Override - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, - EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) - return true; - aBaseMetaTileEntity.openGUI(aPlayer); - return true; - } - - @Override - public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, - IGregTechTileEntity aBaseMetaTileEntity) { - switch (mTier) { - case 2 : - return new CONTAINER_Electric_2by2(aPlayerInventory, - aBaseMetaTileEntity); - case 4 : - return new CONTAINER_Electric_4by4(aPlayerInventory, - aBaseMetaTileEntity); - default : - return new CONTAINER_Electric_4by4(aPlayerInventory, - aBaseMetaTileEntity); - } - } - - @Override - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, - IGregTechTileEntity aBaseMetaTileEntity) { - switch (mTier) { - case 2 : - return new GUI_Electric_2by2(aPlayerInventory, - aBaseMetaTileEntity, "Discharging Bus"); - case 4 : - return new GUI_Electric_4by4(aPlayerInventory, - aBaseMetaTileEntity, "Discharging Bus"); - default : - return new GUI_Electric_4by4(aPlayerInventory, - aBaseMetaTileEntity, "Discharging Bus"); - } - } - - @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, - int aIndex, byte aSide, ItemStack aStack) { - return aSide == aBaseMetaTileEntity.getFrontFacing(); - } - - @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, - int aIndex, byte aSide, ItemStack aStack) { - return aSide == aBaseMetaTileEntity.getFrontFacing(); - } - - public void updateSlots() { - for (int i = 0; i < mInventory.length; i++) - if (mInventory[i] != null && mInventory[i].stackSize <= 0) - mInventory[i] = null; - fillStacksIntoFirstSlots(); - } - - protected void fillStacksIntoFirstSlots() { - for (int i = 0; i < mInventory.length; i++) - for (int j = i + 1; j < mInventory.length; j++) - if (mInventory[j] != null - && (mInventory[i] == null || GT_Utility.areStacksEqual( - mInventory[i], mInventory[j]))) { - GT_Utility.moveStackFromSlotAToSlotB( - getBaseMetaTileEntity(), getBaseMetaTileEntity(), j, - i, (byte) 64, (byte) 1, (byte) 64, (byte) 1); - } - } - - @Override - public int rechargerSlotStartIndex() { - return 0; - } - - @Override - public int rechargerSlotCount() { - return 0; - } - - @Override - public int dechargerSlotStartIndex() { - return 0; - } - - @Override - public int dechargerSlotCount() { - return mTier == 2 ? 4 : 16; - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { - if (aBaseMetaTileEntity.isServerSide() - && aBaseMetaTileEntity.hasInventoryBeenModified()) { - fillStacksIntoFirstSlots(); - } - - if (aBaseMetaTileEntity.isServerSide()){ - if (aBaseMetaTileEntity.getMetaTileEntity() instanceof MetaTileEntity) { - MetaTileEntity mMetaTileEntity = (MetaTileEntity) aBaseMetaTileEntity.getMetaTileEntity(); - if (mMetaTileEntity.dechargerSlotCount() > 0 && mMetaTileEntity.getEUVar() < aBaseMetaTileEntity.getEUCapacity()) { - for (int i = mMetaTileEntity.dechargerSlotStartIndex(), k = mMetaTileEntity.dechargerSlotCount() + i; i < k; i++) { - if (mMetaTileEntity.mInventory[i] != null && mMetaTileEntity.getEUVar() < aBaseMetaTileEntity.getEUCapacity()) { - aBaseMetaTileEntity.increaseStoredEnergyUnits(GT_ModHandler.dischargeElectricItem(mMetaTileEntity.mInventory[i], (int) Math.min(V[mTier] * 15, aBaseMetaTileEntity.getEUCapacity() - aBaseMetaTileEntity.getStoredEU()), (int) Math.min(Integer.MAX_VALUE, mMetaTileEntity.getInputTier()), true, false, false), true); - if (mMetaTileEntity.mInventory[i].stackSize <= 0) - mMetaTileEntity.mInventory[i] = null; - } - } - } - } - } - super.onPostTick(aBaseMetaTileEntity, aTimer); - } - - +public class GT_MetaTileEntity_Hatch_OutputBattery extends GT_MetaTileEntity_Hatch { + public GT_MetaTileEntity_Hatch_OutputBattery(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, getSlots(aTier), "Dischargeable Item Bus for Multiblocks"); + } + + public GT_MetaTileEntity_Hatch_OutputBattery( + String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aTier < 1 ? 1 : aTier == 1 ? 4 : aTier == 2 ? 9 : 16, aDescription, aTextures); + } + + @Override + public String[] getDescription() { + int mSlots = 0; + if (this.mTier == 2) { + mSlots = 4; + } else if (this.mTier == 4) { + mSlots = 16; + } else { + mSlots = 16; + } + return new String[] {this.mDescription, "Capacity: " + mSlots + " slots", CORE.GT_Tooltip}; + } + + @Override + public boolean isEnetOutput() { + return true; + } + + @Override + public boolean isOutputFacing(byte aSide) { + return aSide == getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public long getMinimumStoredEU() { + return 0; + } + + @Override + public long maxEUOutput() { + return V[mTier]; + } + + @Override + public long maxEUStore() { + return 512 + V[mTier + 1] * 8; + } + + @Override + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + return new ITexture[] {aBaseTexture, new GT_RenderedTexture(TexturesGtBlock.Overlay_Hatch_Discharger)}; + } + + @Override + public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + return new ITexture[] {aBaseTexture, new GT_RenderedTexture(TexturesGtBlock.Overlay_Hatch_Discharger)}; + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return true; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean isValidSlot(int aIndex) { + return true; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_Hatch_OutputBattery(mName, mTier, mDescription, mTextures); + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) return true; + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + + @Override + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + switch (mTier) { + case 2: + return new CONTAINER_Electric_2by2(aPlayerInventory, aBaseMetaTileEntity); + case 4: + return new CONTAINER_Electric_4by4(aPlayerInventory, aBaseMetaTileEntity); + default: + return new CONTAINER_Electric_4by4(aPlayerInventory, aBaseMetaTileEntity); + } + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + switch (mTier) { + case 2: + return new GUI_Electric_2by2(aPlayerInventory, aBaseMetaTileEntity, "Discharging Bus"); + case 4: + return new GUI_Electric_4by4(aPlayerInventory, aBaseMetaTileEntity, "Discharging Bus"); + default: + return new GUI_Electric_4by4(aPlayerInventory, aBaseMetaTileEntity, "Discharging Bus"); + } + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return aSide == aBaseMetaTileEntity.getFrontFacing(); + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return aSide == aBaseMetaTileEntity.getFrontFacing(); + } + + public void updateSlots() { + for (int i = 0; i < mInventory.length; i++) + if (mInventory[i] != null && mInventory[i].stackSize <= 0) mInventory[i] = null; + fillStacksIntoFirstSlots(); + } + + protected void fillStacksIntoFirstSlots() { + for (int i = 0; i < mInventory.length; i++) + for (int j = i + 1; j < mInventory.length; j++) + if (mInventory[j] != null + && (mInventory[i] == null || GT_Utility.areStacksEqual(mInventory[i], mInventory[j]))) { + GT_Utility.moveStackFromSlotAToSlotB( + getBaseMetaTileEntity(), + getBaseMetaTileEntity(), + j, + i, + (byte) 64, + (byte) 1, + (byte) 64, + (byte) 1); + } + } + + @Override + public int rechargerSlotStartIndex() { + return 0; + } + + @Override + public int rechargerSlotCount() { + return 0; + } + + @Override + public int dechargerSlotStartIndex() { + return 0; + } + + @Override + public int dechargerSlotCount() { + return mTier == 2 ? 4 : 16; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { + if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.hasInventoryBeenModified()) { + fillStacksIntoFirstSlots(); + } + + if (aBaseMetaTileEntity.isServerSide()) { + if (aBaseMetaTileEntity.getMetaTileEntity() instanceof MetaTileEntity) { + MetaTileEntity mMetaTileEntity = (MetaTileEntity) aBaseMetaTileEntity.getMetaTileEntity(); + if (mMetaTileEntity.dechargerSlotCount() > 0 + && mMetaTileEntity.getEUVar() < aBaseMetaTileEntity.getEUCapacity()) { + for (int i = mMetaTileEntity.dechargerSlotStartIndex(), + k = mMetaTileEntity.dechargerSlotCount() + i; + i < k; + i++) { + if (mMetaTileEntity.mInventory[i] != null + && mMetaTileEntity.getEUVar() < aBaseMetaTileEntity.getEUCapacity()) { + aBaseMetaTileEntity.increaseStoredEnergyUnits( + GT_ModHandler.dischargeElectricItem( + mMetaTileEntity.mInventory[i], + (int) Math.min( + V[mTier] * 15, + aBaseMetaTileEntity.getEUCapacity() + - aBaseMetaTileEntity.getStoredEU()), + (int) Math.min(Integer.MAX_VALUE, mMetaTileEntity.getInputTier()), + true, + false, + false), + true); + if (mMetaTileEntity.mInventory[i].stackSize <= 0) mMetaTileEntity.mInventory[i] = null; + } + } + } + } + } + super.onPostTick(aBaseMetaTileEntity, aTimer); + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Plasma.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Plasma.java index 1251c42ae3..7f09abf177 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Plasma.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Plasma.java @@ -1,9 +1,6 @@ package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; -import java.lang.reflect.Field; - import com.google.common.collect.BiMap; - import gregtech.api.enums.Textures.BlockIcons; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -14,6 +11,7 @@ import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.gregtech.common.StaticFields59; +import java.lang.reflect.Field; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.fluids.Fluid; @@ -22,198 +20,201 @@ import net.minecraftforge.fluids.FluidStack; public class GT_MetaTileEntity_Hatch_Plasma extends GT_MetaTileEntity_Hatch_Output { - public final AutoMap<Fluid> mFluidsToUse = new AutoMap<Fluid>(); - public final int mFluidCapacity; - private int mTotalPlasmaSupported = -1; - - public GT_MetaTileEntity_Hatch_Plasma(final int aID, final String aName, final String aNameRegional) { - super(aID, aName, aNameRegional, 6); - mFluidCapacity = 256000; - initHatch(); - } - - public GT_MetaTileEntity_Hatch_Plasma(final String aName, final String aDescription, - final ITexture[][][] aTextures) { - super(aName, 6, aDescription, aTextures); - mFluidCapacity = 256000; - initHatch(); - } - - public GT_MetaTileEntity_Hatch_Plasma(final String aName, final String[] aDescription, - final ITexture[][][] aTextures) { - super(aName, 6, aDescription[0], aTextures); - mFluidCapacity = 256000; - initHatch(); - } - - private void initHatch() { - - //Get all Plasmas, but the easiest way to do this is to just ask the Fluid Registry what exists and filter through them lazily. - Field fluidNameCache; - - fluidNameCache = ReflectionUtils.getField(FluidRegistry.class, "fluidNames"); - - AutoMap<String> mValidPlasmaNameCache = new AutoMap<String>(); - if (fluidNameCache != null) { - try { - Object fluidNames = fluidNameCache.get(null); - if (fluidNames != null) { - try { - @SuppressWarnings("unchecked") - BiMap<Integer, String> fluidNamesMap = (BiMap<Integer, String>) fluidNames; - if (fluidNamesMap != null) { - for (String g : fluidNamesMap.values()) { - if (g.toLowerCase().contains("plasma")) { - mValidPlasmaNameCache.put(g); - } - } - } - } catch (ClassCastException e) { - } - } - } catch (IllegalArgumentException | IllegalAccessException e) { - } - } - - AutoMap<Fluid> mPlasmaCache = new AutoMap<Fluid>(); - if (!mValidPlasmaNameCache.isEmpty()) { - for (String y : mValidPlasmaNameCache) { - Fluid t = FluidRegistry.getFluid(y); - if (t != null) { - if (t.getTemperature() > 1000) { - mPlasmaCache.put(t); - } - } - } - } - - if (!mPlasmaCache.isEmpty()) { - for (Fluid w : mPlasmaCache) { - mFluidsToUse.put(w); - } - } - - - - - - } - - public ITexture[] getTexturesActive(final ITexture aBaseTexture) { - return new ITexture[] { aBaseTexture }; - } - - public ITexture[] getTexturesInactive(final ITexture aBaseTexture) { - return new ITexture[] { aBaseTexture }; - } - - public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, - final ItemStack aStack) { - if (aSide == aBaseMetaTileEntity.getFrontFacing() && aIndex == 0) { - for (Fluid f : mFluidsToUse) { - if (f != null) { - if (GT_Utility.getFluidForFilledItem(aStack, true).getFluid() == f) { - return true; - } - } - } - } - return false; - } - - public boolean isFluidInputAllowed(final FluidStack aFluid) { - for (Fluid f : mFluidsToUse) { - if (f != null) { - if (aFluid.getFluid() == f) { - return true; - } - } - } - return false; - } - - public int getCapacity() { - return this.mFluidCapacity; - } - - public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return (MetaTileEntity) new GT_MetaTileEntity_Hatch_Plasma(this.mName, this.mDescription, this.mTextures); - } - - @Override - public String[] getDescription() { - - if (mTotalPlasmaSupported < 0) { - if (mFluidsToUse.isEmpty()) { - mTotalPlasmaSupported = 0; - } - else { - mTotalPlasmaSupported = mFluidsToUse.size(); - } - } - - String aX = EnumChatFormatting.GRAY+""; - String a1 = EnumChatFormatting.GOLD+"Refined containment"+aX; - String a2 = EnumChatFormatting.GOLD+"Capacity: "+EnumChatFormatting.DARK_AQUA+getCapacity()+"L"+aX; - String a3 = EnumChatFormatting.GOLD+"Supports "+EnumChatFormatting.DARK_RED+mTotalPlasmaSupported+EnumChatFormatting.GOLD+" types of plasma"+aX; - - - - String[] s2 = new String[]{ - a1, a2, a3, CORE.GT_Tooltip - }; - return s2; - } - - @Override - public boolean doesFillContainers() { - return true; - } - - @Override - public ITexture[][][] getTextureSet(ITexture[] aTextures) { - // TODO Auto-generated method stub - return super.getTextureSet(aTextures); - } - - private Field F1, F2; - - - @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - byte a1 = 0, a2 = 0; - try { - if (F1 == null) { - F1 = ReflectionUtils.getField(getClass(), "actualTexture"); - } - if (F2 == null) { - F2 = ReflectionUtils.getField(getClass(), "mTexturePage"); - } - - if (F1 != null) { - a1 = F1.getByte(this); - } - if (F2 != null) { - a2 = F2.getByte(this); - } - } - catch (IllegalArgumentException | IllegalAccessException n) {} - - int textureIndex = a1 | a2 << 7; - byte texturePointer = (byte) (a1 & 127); - - - - if (aSide == 1 || aSide == 0) { - ITexture g = textureIndex > 0 ? StaticFields59.getCasingTexturePages(a2, texturePointer) : BlockIcons.MACHINE_CASINGS[this.mTier][aColorIndex + 1]; - - return new ITexture[] {g}; - } - - return aSide != aFacing ? - (textureIndex > 0 ? new ITexture[] { StaticFields59.getCasingTexturePages(a2, texturePointer) } : new ITexture[] { BlockIcons.MACHINE_CASINGS[this.mTier][aColorIndex + 1] }) - : (textureIndex > 0 ? (aActive ? this.getTexturesActive(StaticFields59.getCasingTexturePages(a2, texturePointer)) : this.getTexturesInactive(StaticFields59.getCasingTexturePages(a2, texturePointer))) - : (aActive ? this.getTexturesActive(BlockIcons.MACHINE_CASINGS[this.mTier][aColorIndex + 1]) : this.getTexturesInactive(BlockIcons.MACHINE_CASINGS[this.mTier][aColorIndex + 1]))); - } - + public final AutoMap<Fluid> mFluidsToUse = new AutoMap<Fluid>(); + public final int mFluidCapacity; + private int mTotalPlasmaSupported = -1; + + public GT_MetaTileEntity_Hatch_Plasma(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional, 6); + mFluidCapacity = 256000; + initHatch(); + } + + public GT_MetaTileEntity_Hatch_Plasma( + final String aName, final String aDescription, final ITexture[][][] aTextures) { + super(aName, 6, aDescription, aTextures); + mFluidCapacity = 256000; + initHatch(); + } + + public GT_MetaTileEntity_Hatch_Plasma( + final String aName, final String[] aDescription, final ITexture[][][] aTextures) { + super(aName, 6, aDescription[0], aTextures); + mFluidCapacity = 256000; + initHatch(); + } + + private void initHatch() { + + // Get all Plasmas, but the easiest way to do this is to just ask the Fluid Registry what exists and filter + // through them lazily. + Field fluidNameCache; + + fluidNameCache = ReflectionUtils.getField(FluidRegistry.class, "fluidNames"); + + AutoMap<String> mValidPlasmaNameCache = new AutoMap<String>(); + if (fluidNameCache != null) { + try { + Object fluidNames = fluidNameCache.get(null); + if (fluidNames != null) { + try { + @SuppressWarnings("unchecked") + BiMap<Integer, String> fluidNamesMap = (BiMap<Integer, String>) fluidNames; + if (fluidNamesMap != null) { + for (String g : fluidNamesMap.values()) { + if (g.toLowerCase().contains("plasma")) { + mValidPlasmaNameCache.put(g); + } + } + } + } catch (ClassCastException e) { + } + } + } catch (IllegalArgumentException | IllegalAccessException e) { + } + } + + AutoMap<Fluid> mPlasmaCache = new AutoMap<Fluid>(); + if (!mValidPlasmaNameCache.isEmpty()) { + for (String y : mValidPlasmaNameCache) { + Fluid t = FluidRegistry.getFluid(y); + if (t != null) { + if (t.getTemperature() > 1000) { + mPlasmaCache.put(t); + } + } + } + } + + if (!mPlasmaCache.isEmpty()) { + for (Fluid w : mPlasmaCache) { + mFluidsToUse.put(w); + } + } + } + + public ITexture[] getTexturesActive(final ITexture aBaseTexture) { + return new ITexture[] {aBaseTexture}; + } + + public ITexture[] getTexturesInactive(final ITexture aBaseTexture) { + return new ITexture[] {aBaseTexture}; + } + + public boolean allowPutStack( + final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + if (aSide == aBaseMetaTileEntity.getFrontFacing() && aIndex == 0) { + for (Fluid f : mFluidsToUse) { + if (f != null) { + if (GT_Utility.getFluidForFilledItem(aStack, true).getFluid() == f) { + return true; + } + } + } + } + return false; + } + + public boolean isFluidInputAllowed(final FluidStack aFluid) { + for (Fluid f : mFluidsToUse) { + if (f != null) { + if (aFluid.getFluid() == f) { + return true; + } + } + } + return false; + } + + public int getCapacity() { + return this.mFluidCapacity; + } + + public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return (MetaTileEntity) new GT_MetaTileEntity_Hatch_Plasma(this.mName, this.mDescription, this.mTextures); + } + + @Override + public String[] getDescription() { + + if (mTotalPlasmaSupported < 0) { + if (mFluidsToUse.isEmpty()) { + mTotalPlasmaSupported = 0; + } else { + mTotalPlasmaSupported = mFluidsToUse.size(); + } + } + + String aX = EnumChatFormatting.GRAY + ""; + String a1 = EnumChatFormatting.GOLD + "Refined containment" + aX; + String a2 = EnumChatFormatting.GOLD + "Capacity: " + EnumChatFormatting.DARK_AQUA + getCapacity() + "L" + aX; + String a3 = EnumChatFormatting.GOLD + "Supports " + EnumChatFormatting.DARK_RED + mTotalPlasmaSupported + + EnumChatFormatting.GOLD + " types of plasma" + aX; + + String[] s2 = new String[] {a1, a2, a3, CORE.GT_Tooltip}; + return s2; + } + + @Override + public boolean doesFillContainers() { + return true; + } + + @Override + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + // TODO Auto-generated method stub + return super.getTextureSet(aTextures); + } + + private Field F1, F2; + + @Override + public ITexture[] getTexture( + IGregTechTileEntity aBaseMetaTileEntity, + byte aSide, + byte aFacing, + byte aColorIndex, + boolean aActive, + boolean aRedstone) { + byte a1 = 0, a2 = 0; + try { + if (F1 == null) { + F1 = ReflectionUtils.getField(getClass(), "actualTexture"); + } + if (F2 == null) { + F2 = ReflectionUtils.getField(getClass(), "mTexturePage"); + } + + if (F1 != null) { + a1 = F1.getByte(this); + } + if (F2 != null) { + a2 = F2.getByte(this); + } + } catch (IllegalArgumentException | IllegalAccessException n) { + } + + int textureIndex = a1 | a2 << 7; + byte texturePointer = (byte) (a1 & 127); + + if (aSide == 1 || aSide == 0) { + ITexture g = textureIndex > 0 + ? StaticFields59.getCasingTexturePages(a2, texturePointer) + : BlockIcons.MACHINE_CASINGS[this.mTier][aColorIndex + 1]; + + return new ITexture[] {g}; + } + + return aSide != aFacing + ? (textureIndex > 0 + ? new ITexture[] {StaticFields59.getCasingTexturePages(a2, texturePointer)} + : new ITexture[] {BlockIcons.MACHINE_CASINGS[this.mTier][aColorIndex + 1]}) + : (textureIndex > 0 + ? (aActive + ? this.getTexturesActive(StaticFields59.getCasingTexturePages(a2, texturePointer)) + : this.getTexturesInactive(StaticFields59.getCasingTexturePages(a2, texturePointer))) + : (aActive + ? this.getTexturesActive(BlockIcons.MACHINE_CASINGS[this.mTier][aColorIndex + 1]) + : this.getTexturesInactive(BlockIcons.MACHINE_CASINGS[this.mTier][aColorIndex + 1]))); + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Reservoir.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Reservoir.java index 75c5dbb9ee..0a2ccdb8e5 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Reservoir.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Reservoir.java @@ -18,106 +18,109 @@ import net.minecraftforge.fluids.IFluidHandler; public class GT_MetaTileEntity_Hatch_Reservoir extends GT_MetaTileEntity_Hatch_FluidGenerator { - private static Block sBlock_EIO; - private static Block sBlock_RIO; - - public GT_MetaTileEntity_Hatch_Reservoir(final int aID, final String aName, final String aNameRegional, final int aTier) { - super(aID, aName, aNameRegional, aTier); - } - - public GT_MetaTileEntity_Hatch_Reservoir(final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures) { - super(aName, aTier, aDescription, aTextures); - } - - - public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_Hatch_Reservoir(this.mName, this.mTier, this.mDescription, this.mTextures); - } - - @Override - public String[] getCustomTooltip() { - String[] aTooltip = new String[3]; - aTooltip[0] = "Requires a Block of water facing the intake"; - aTooltip[1] = "Infinite water supply hatch"; - aTooltip[2] = "Creates 8000L of Water every 4 ticks"; - return aTooltip; - } - - @Override - public Fluid getFluidToGenerate() { - return FluidRegistry.WATER; - } - - @Override - public int getAmountOfFluidToGenerate() { - return 8000; - } - - @Override - public int getMaxTickTime() { - return 4; - } - - @Override - public int getCapacity() { - return 256000; - } - - private static void setCrossModData() { - if (LoadedMods.EnderIO && sBlock_EIO == null) { - sBlock_EIO = GameRegistry.findBlock("EnderIO", "blockReservoir"); - } - if (LoadedMods.RemoteIO && sBlock_RIO == null) { - sBlock_RIO = GameRegistry.findBlock("RIO", "machine"); - } - } - - public static boolean isTileValid(TileEntity aTile) { - if (aTile != null) { - if (aTile instanceof IFluidHandler) { - IFluidHandler aFluidHandler = (IFluidHandler) aTile; - return aFluidHandler.canDrain(ForgeDirection.UNKNOWN, FluidRegistry.WATER); - } - } - return false; - } - - @Override - public boolean doesHatchMeetConditionsToGenerate() { - Block aWater = this.getBaseMetaTileEntity().getBlockAtSide(this.getBaseMetaTileEntity().getFrontFacing()); - if (aWater != null && aWater != Blocks.air) { - if (!this.canTankBeFilled()) { - return false; - } - setCrossModData(); - if (LoadedMods.EnderIO) { - if (aWater == sBlock_EIO) { - return isTileValid(this.getBaseMetaTileEntity().getTileEntityAtSide(this.getBaseMetaTileEntity().getFrontFacing())); - } - } - if (LoadedMods.RemoteIO) { - if (aWater == sBlock_RIO && this.getBaseMetaTileEntity().getMetaIDAtSide(this.getBaseMetaTileEntity().getFrontFacing()) == 0) { - return isTileValid(this.getBaseMetaTileEntity().getTileEntityAtSide(this.getBaseMetaTileEntity().getFrontFacing())); - } - } - return aWater == Blocks.water || aWater == Blocks.flowing_water; - } - return false; - } - - @Override - public void generateParticles(World aWorld, String name) { - - } - - public ITexture[] getTexturesActive(final ITexture aBaseTexture) { - return new ITexture[]{aBaseTexture, - new GT_RenderedTexture(TexturesGtBlock.Overlay_Water)}; - } - - public ITexture[] getTexturesInactive(final ITexture aBaseTexture) { - return new ITexture[]{aBaseTexture, - new GT_RenderedTexture(TexturesGtBlock.Overlay_Water)}; - } + private static Block sBlock_EIO; + private static Block sBlock_RIO; + public GT_MetaTileEntity_Hatch_Reservoir( + final int aID, final String aName, final String aNameRegional, final int aTier) { + super(aID, aName, aNameRegional, aTier); + } + + public GT_MetaTileEntity_Hatch_Reservoir( + final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_Hatch_Reservoir(this.mName, this.mTier, this.mDescription, this.mTextures); + } + + @Override + public String[] getCustomTooltip() { + String[] aTooltip = new String[3]; + aTooltip[0] = "Requires a Block of water facing the intake"; + aTooltip[1] = "Infinite water supply hatch"; + aTooltip[2] = "Creates 8000L of Water every 4 ticks"; + return aTooltip; + } + + @Override + public Fluid getFluidToGenerate() { + return FluidRegistry.WATER; + } + + @Override + public int getAmountOfFluidToGenerate() { + return 8000; + } + + @Override + public int getMaxTickTime() { + return 4; + } + + @Override + public int getCapacity() { + return 256000; + } + + private static void setCrossModData() { + if (LoadedMods.EnderIO && sBlock_EIO == null) { + sBlock_EIO = GameRegistry.findBlock("EnderIO", "blockReservoir"); + } + if (LoadedMods.RemoteIO && sBlock_RIO == null) { + sBlock_RIO = GameRegistry.findBlock("RIO", "machine"); + } + } + + public static boolean isTileValid(TileEntity aTile) { + if (aTile != null) { + if (aTile instanceof IFluidHandler) { + IFluidHandler aFluidHandler = (IFluidHandler) aTile; + return aFluidHandler.canDrain(ForgeDirection.UNKNOWN, FluidRegistry.WATER); + } + } + return false; + } + + @Override + public boolean doesHatchMeetConditionsToGenerate() { + Block aWater = this.getBaseMetaTileEntity() + .getBlockAtSide(this.getBaseMetaTileEntity().getFrontFacing()); + if (aWater != null && aWater != Blocks.air) { + if (!this.canTankBeFilled()) { + return false; + } + setCrossModData(); + if (LoadedMods.EnderIO) { + if (aWater == sBlock_EIO) { + return isTileValid(this.getBaseMetaTileEntity() + .getTileEntityAtSide(this.getBaseMetaTileEntity().getFrontFacing())); + } + } + if (LoadedMods.RemoteIO) { + if (aWater == sBlock_RIO + && this.getBaseMetaTileEntity() + .getMetaIDAtSide( + this.getBaseMetaTileEntity().getFrontFacing()) + == 0) { + return isTileValid(this.getBaseMetaTileEntity() + .getTileEntityAtSide(this.getBaseMetaTileEntity().getFrontFacing())); + } + } + return aWater == Blocks.water || aWater == Blocks.flowing_water; + } + return false; + } + + @Override + public void generateParticles(World aWorld, String name) {} + + public ITexture[] getTexturesActive(final ITexture aBaseTexture) { + return new ITexture[] {aBaseTexture, new GT_RenderedTexture(TexturesGtBlock.Overlay_Water)}; + } + + public ITexture[] getTexturesInactive(final ITexture aBaseTexture) { + return new ITexture[] {aBaseTexture, new GT_RenderedTexture(TexturesGtBlock.Overlay_Water)}; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Steam_BusInput.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Steam_BusInput.java index f1dd131a67..2f3574ed5d 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Steam_BusInput.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Steam_BusInput.java @@ -10,225 +10,302 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_LanguageManager; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; -import gtPlusPlus.core.lib.CORE; import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.lib.CORE; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; public class GT_MetaTileEntity_Hatch_Steam_BusInput extends GT_MetaTileEntity_Hatch { - public GT_Recipe_Map mRecipeMap = null; - public boolean disableSort; - - public GT_MetaTileEntity_Hatch_Steam_BusInput(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, getSlots(aTier), new String[]{ - "Item Input for Steam Multiblocks", - "Shift + right click with screwdriver to toggle automatic item shuffling", - "Capacity: 4 stacks", - "Does not work with non-steam multiblocks", - CORE.GT_Tooltip}); - } - - public GT_MetaTileEntity_Hatch_Steam_BusInput(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { - super(aName, aTier, 4, aDescription, aTextures); - } - - public GT_MetaTileEntity_Hatch_Steam_BusInput(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { - super(aName, aTier, 4, aDescription, aTextures); - } - - @Override - public ITexture[] getTexturesActive(ITexture aBaseTexture) { - return new ITexture[]{aBaseTexture, new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_IN)}; - } - - @Override - public ITexture[] getTexturesInactive(ITexture aBaseTexture) { - return new ITexture[]{aBaseTexture, new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_IN)}; - } - - @Override - public boolean isSimpleMachine() { - return true; - } - - @Override - public boolean isFacingValid(byte aFacing) { - return true; - } - - @Override - public boolean isAccessAllowed(EntityPlayer aPlayer) { - return true; - } - - @Override - public boolean isValidSlot(int aIndex) { - return true; - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_Hatch_Steam_BusInput(mName, mTier, mDescriptionArray, mTextures); - } - - @Override - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) return true; - aBaseMetaTileEntity.openGUI(aPlayer); - return true; - } - - @Override - public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_Container_2by2(aPlayerInventory, aBaseMetaTileEntity); - } - - @Override - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_2by2(aPlayerInventory, aBaseMetaTileEntity, "Steam Input Bus"); - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { - if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.hasInventoryBeenModified()) { - fillStacksIntoFirstSlots(); - } - } - - public void updateSlots() { - for (int i = 0; i < mInventory.length; i++) - if (mInventory[i] != null && mInventory[i].stackSize <= 0) mInventory[i] = null; - fillStacksIntoFirstSlots(); - } - - protected void fillStacksIntoFirstSlots() { - if (disableSort) { - for (int i = 0; i < mInventory.length; i++) - if (mInventory[i] != null && mInventory[i].stackSize <= 0) - mInventory[i] = null; - } else { - for (int i = 0; i < mInventory.length; i++) - for (int j = i + 1; j < mInventory.length; j++) - if (mInventory[j] != null && (mInventory[i] == null || GT_Utility.areStacksEqual(mInventory[i], mInventory[j]))) - GT_Utility.moveStackFromSlotAToSlotB(getBaseMetaTileEntity(), getBaseMetaTileEntity(), j, i, (byte) 64, (byte) 1, (byte) 64, (byte) 1); - } - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - aNBT.setBoolean("disableSort", disableSort); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - disableSort = aNBT.getBoolean("disableSort"); - } - - @Override - public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - if (aPlayer.isSneaking()) { - disableSort = !disableSort; - GT_Utility.sendChatToPlayer(aPlayer, trans("200", "Automatic Item Shuffling: " + (disableSort ? "Disabled" : "Enabled"))); - } - } - - public String trans(String aKey, String aEnglish) { - return GT_LanguageManager.addStringLocalization("Interaction_DESCRIPTION_Index_" + aKey, aEnglish, false); - } - - @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return false; - } - - @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return aSide == getBaseMetaTileEntity().getFrontFacing() && (mRecipeMap == null || mRecipeMap.containsInput(aStack)); - } - - - - @Override - public ITexture[][][] getTextureSet(ITexture[] aTextures) { - ITexture[][][] rTextures = new ITexture[14][17][]; - for (byte c = -1; c < 16; c++) { - if (rTextures[0][c + 1] == null) rTextures[0][c + 1] = getSideFacingActive(c); - if (rTextures[1][c + 1] == null) rTextures[1][c + 1] = getSideFacingInactive(c); - if (rTextures[2][c + 1] == null) rTextures[2][c + 1] = getFrontFacingActive(c); - if (rTextures[3][c + 1] == null) rTextures[3][c + 1] = getFrontFacingInactive(c); - if (rTextures[4][c + 1] == null) rTextures[4][c + 1] = getTopFacingActive(c); - if (rTextures[5][c + 1] == null) rTextures[5][c + 1] = getTopFacingInactive(c); - if (rTextures[6][c + 1] == null) rTextures[6][c + 1] = getBottomFacingActive(c); - if (rTextures[7][c + 1] == null) rTextures[7][c + 1] = getBottomFacingInactive(c); - if (rTextures[8][c + 1] == null) rTextures[8][c + 1] = getBottomFacingPipeActive(c); - if (rTextures[9][c + 1] == null) rTextures[9][c + 1] = getBottomFacingPipeInactive(c); - if (rTextures[10][c + 1] == null) rTextures[10][c + 1] = getTopFacingPipeActive(c); - if (rTextures[11][c + 1] == null) rTextures[11][c + 1] = getTopFacingPipeInactive(c); - if (rTextures[12][c + 1] == null) rTextures[12][c + 1] = getSideFacingPipeActive(c); - if (rTextures[13][c + 1] == null) rTextures[13][c + 1] = getSideFacingPipeInactive(c); - } - return rTextures; - } - - public ITexture[] getSideFacingActive(byte aColor) { - return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_SIDE : Textures.BlockIcons.MACHINE_BRONZE_SIDE)}; - } - - public ITexture[] getSideFacingInactive(byte aColor) { - return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_SIDE : Textures.BlockIcons.MACHINE_BRONZE_SIDE)}; - } - - public ITexture[] getFrontFacingActive(byte aColor) { - return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_SIDE : Textures.BlockIcons.MACHINE_BRONZE_SIDE)}; - } - - public ITexture[] getFrontFacingInactive(byte aColor) { - return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_SIDE : Textures.BlockIcons.MACHINE_BRONZE_SIDE)}; - } - - public ITexture[] getTopFacingActive(byte aColor) { - return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_TOP : Textures.BlockIcons.MACHINE_BRONZE_TOP)}; - } - - public ITexture[] getTopFacingInactive(byte aColor) { - return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_TOP : Textures.BlockIcons.MACHINE_BRONZE_TOP)}; - } - - public ITexture[] getBottomFacingActive(byte aColor) { - return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_BOTTOM : Textures.BlockIcons.MACHINE_BRONZE_BOTTOM)}; - } - - public ITexture[] getBottomFacingInactive(byte aColor) { - return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_BOTTOM : Textures.BlockIcons.MACHINE_BRONZE_BOTTOM)}; - } - - public ITexture[] getBottomFacingPipeActive(byte aColor) { - return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_BOTTOM : Textures.BlockIcons.MACHINE_BRONZE_BOTTOM), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; - } - - public ITexture[] getBottomFacingPipeInactive(byte aColor) { - return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_BOTTOM : Textures.BlockIcons.MACHINE_BRONZE_BOTTOM), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; - } - - public ITexture[] getTopFacingPipeActive(byte aColor) { - return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_TOP : Textures.BlockIcons.MACHINE_BRONZE_TOP), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; - } - - public ITexture[] getTopFacingPipeInactive(byte aColor) { - return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_TOP : Textures.BlockIcons.MACHINE_BRONZE_TOP), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; - } - - public ITexture[] getSideFacingPipeActive(byte aColor) { - return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_SIDE : Textures.BlockIcons.MACHINE_BRONZE_SIDE), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; - } - - public ITexture[] getSideFacingPipeInactive(byte aColor) { - return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_SIDE : Textures.BlockIcons.MACHINE_BRONZE_SIDE), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; - } - - + public GT_Recipe_Map mRecipeMap = null; + public boolean disableSort; + + public GT_MetaTileEntity_Hatch_Steam_BusInput(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, getSlots(aTier), new String[] { + "Item Input for Steam Multiblocks", + "Shift + right click with screwdriver to toggle automatic item shuffling", + "Capacity: 4 stacks", + "Does not work with non-steam multiblocks", + CORE.GT_Tooltip + }); + } + + public GT_MetaTileEntity_Hatch_Steam_BusInput( + String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 4, aDescription, aTextures); + } + + public GT_MetaTileEntity_Hatch_Steam_BusInput( + String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 4, aDescription, aTextures); + } + + @Override + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + return new ITexture[] {aBaseTexture, new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_IN)}; + } + + @Override + public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + return new ITexture[] {aBaseTexture, new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_IN)}; + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return true; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean isValidSlot(int aIndex) { + return true; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_Hatch_Steam_BusInput(mName, mTier, mDescriptionArray, mTextures); + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) return true; + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + + @Override + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_Container_2by2(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_2by2(aPlayerInventory, aBaseMetaTileEntity, "Steam Input Bus"); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { + if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.hasInventoryBeenModified()) { + fillStacksIntoFirstSlots(); + } + } + + public void updateSlots() { + for (int i = 0; i < mInventory.length; i++) + if (mInventory[i] != null && mInventory[i].stackSize <= 0) mInventory[i] = null; + fillStacksIntoFirstSlots(); + } + + protected void fillStacksIntoFirstSlots() { + if (disableSort) { + for (int i = 0; i < mInventory.length; i++) + if (mInventory[i] != null && mInventory[i].stackSize <= 0) mInventory[i] = null; + } else { + for (int i = 0; i < mInventory.length; i++) + for (int j = i + 1; j < mInventory.length; j++) + if (mInventory[j] != null + && (mInventory[i] == null || GT_Utility.areStacksEqual(mInventory[i], mInventory[j]))) + GT_Utility.moveStackFromSlotAToSlotB( + getBaseMetaTileEntity(), + getBaseMetaTileEntity(), + j, + i, + (byte) 64, + (byte) 1, + (byte) 64, + (byte) 1); + } + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setBoolean("disableSort", disableSort); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + disableSort = aNBT.getBoolean("disableSort"); + } + + @Override + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (aPlayer.isSneaking()) { + disableSort = !disableSort; + GT_Utility.sendChatToPlayer( + aPlayer, trans("200", "Automatic Item Shuffling: " + (disableSort ? "Disabled" : "Enabled"))); + } + } + + public String trans(String aKey, String aEnglish) { + return GT_LanguageManager.addStringLocalization("Interaction_DESCRIPTION_Index_" + aKey, aEnglish, false); + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return aSide == getBaseMetaTileEntity().getFrontFacing() + && (mRecipeMap == null || mRecipeMap.containsInput(aStack)); + } + + @Override + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + ITexture[][][] rTextures = new ITexture[14][17][]; + for (byte c = -1; c < 16; c++) { + if (rTextures[0][c + 1] == null) rTextures[0][c + 1] = getSideFacingActive(c); + if (rTextures[1][c + 1] == null) rTextures[1][c + 1] = getSideFacingInactive(c); + if (rTextures[2][c + 1] == null) rTextures[2][c + 1] = getFrontFacingActive(c); + if (rTextures[3][c + 1] == null) rTextures[3][c + 1] = getFrontFacingInactive(c); + if (rTextures[4][c + 1] == null) rTextures[4][c + 1] = getTopFacingActive(c); + if (rTextures[5][c + 1] == null) rTextures[5][c + 1] = getTopFacingInactive(c); + if (rTextures[6][c + 1] == null) rTextures[6][c + 1] = getBottomFacingActive(c); + if (rTextures[7][c + 1] == null) rTextures[7][c + 1] = getBottomFacingInactive(c); + if (rTextures[8][c + 1] == null) rTextures[8][c + 1] = getBottomFacingPipeActive(c); + if (rTextures[9][c + 1] == null) rTextures[9][c + 1] = getBottomFacingPipeInactive(c); + if (rTextures[10][c + 1] == null) rTextures[10][c + 1] = getTopFacingPipeActive(c); + if (rTextures[11][c + 1] == null) rTextures[11][c + 1] = getTopFacingPipeInactive(c); + if (rTextures[12][c + 1] == null) rTextures[12][c + 1] = getSideFacingPipeActive(c); + if (rTextures[13][c + 1] == null) rTextures[13][c + 1] = getSideFacingPipeInactive(c); + } + return rTextures; + } + + public ITexture[] getSideFacingActive(byte aColor) { + return new ITexture[] { + new GT_RenderedTexture( + mTier == 1 + ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_SIDE + : Textures.BlockIcons.MACHINE_BRONZE_SIDE) + }; + } + + public ITexture[] getSideFacingInactive(byte aColor) { + return new ITexture[] { + new GT_RenderedTexture( + mTier == 1 + ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_SIDE + : Textures.BlockIcons.MACHINE_BRONZE_SIDE) + }; + } + + public ITexture[] getFrontFacingActive(byte aColor) { + return new ITexture[] { + new GT_RenderedTexture( + mTier == 1 + ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_SIDE + : Textures.BlockIcons.MACHINE_BRONZE_SIDE) + }; + } + + public ITexture[] getFrontFacingInactive(byte aColor) { + return new ITexture[] { + new GT_RenderedTexture( + mTier == 1 + ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_SIDE + : Textures.BlockIcons.MACHINE_BRONZE_SIDE) + }; + } + + public ITexture[] getTopFacingActive(byte aColor) { + return new ITexture[] { + new GT_RenderedTexture( + mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_TOP : Textures.BlockIcons.MACHINE_BRONZE_TOP) + }; + } + + public ITexture[] getTopFacingInactive(byte aColor) { + return new ITexture[] { + new GT_RenderedTexture( + mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_TOP : Textures.BlockIcons.MACHINE_BRONZE_TOP) + }; + } + + public ITexture[] getBottomFacingActive(byte aColor) { + return new ITexture[] { + new GT_RenderedTexture( + mTier == 1 + ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_BOTTOM + : Textures.BlockIcons.MACHINE_BRONZE_BOTTOM) + }; + } + + public ITexture[] getBottomFacingInactive(byte aColor) { + return new ITexture[] { + new GT_RenderedTexture( + mTier == 1 + ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_BOTTOM + : Textures.BlockIcons.MACHINE_BRONZE_BOTTOM) + }; + } + + public ITexture[] getBottomFacingPipeActive(byte aColor) { + return new ITexture[] { + new GT_RenderedTexture( + mTier == 1 + ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_BOTTOM + : Textures.BlockIcons.MACHINE_BRONZE_BOTTOM), + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT) + }; + } + + public ITexture[] getBottomFacingPipeInactive(byte aColor) { + return new ITexture[] { + new GT_RenderedTexture( + mTier == 1 + ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_BOTTOM + : Textures.BlockIcons.MACHINE_BRONZE_BOTTOM), + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT) + }; + } + + public ITexture[] getTopFacingPipeActive(byte aColor) { + return new ITexture[] { + new GT_RenderedTexture( + mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_TOP : Textures.BlockIcons.MACHINE_BRONZE_TOP), + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT) + }; + } + + public ITexture[] getTopFacingPipeInactive(byte aColor) { + return new ITexture[] { + new GT_RenderedTexture( + mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_TOP : Textures.BlockIcons.MACHINE_BRONZE_TOP), + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT) + }; + } + + public ITexture[] getSideFacingPipeActive(byte aColor) { + return new ITexture[] { + new GT_RenderedTexture( + mTier == 1 + ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_SIDE + : Textures.BlockIcons.MACHINE_BRONZE_SIDE), + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT) + }; + } + + public ITexture[] getSideFacingPipeInactive(byte aColor) { + return new ITexture[] { + new GT_RenderedTexture( + mTier == 1 + ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_SIDE + : Textures.BlockIcons.MACHINE_BRONZE_SIDE), + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT) + }; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Steam_BusOutput.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Steam_BusOutput.java index 2fb3fea084..fa5cf4bd5b 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Steam_BusOutput.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Steam_BusOutput.java @@ -15,28 +15,32 @@ import net.minecraft.item.ItemStack; public class GT_MetaTileEntity_Hatch_Steam_BusOutput extends GT_MetaTileEntity_Hatch { public GT_MetaTileEntity_Hatch_Steam_BusOutput(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, 4, new String[]{"Item Output for Steam Multiblocks", - "Capacity: 4 stacks", - "Does not work with non-steam multiblocks", - CORE.GT_Tooltip}); + super(aID, aName, aNameRegional, aTier, 4, new String[] { + "Item Output for Steam Multiblocks", + "Capacity: 4 stacks", + "Does not work with non-steam multiblocks", + CORE.GT_Tooltip + }); } - public GT_MetaTileEntity_Hatch_Steam_BusOutput(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + public GT_MetaTileEntity_Hatch_Steam_BusOutput( + String aName, int aTier, String aDescription, ITexture[][][] aTextures) { super(aName, aTier, 4, aDescription, aTextures); } - public GT_MetaTileEntity_Hatch_Steam_BusOutput(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + public GT_MetaTileEntity_Hatch_Steam_BusOutput( + String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { super(aName, aTier, 4, aDescription, aTextures); } @Override public ITexture[] getTexturesActive(ITexture aBaseTexture) { - return new ITexture[]{aBaseTexture, new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + return new ITexture[] {aBaseTexture, new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; } @Override public ITexture[] getTexturesInactive(ITexture aBaseTexture) { - return new ITexture[]{aBaseTexture, new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + return new ITexture[] {aBaseTexture, new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; } @Override @@ -73,12 +77,12 @@ public class GT_MetaTileEntity_Hatch_Steam_BusOutput extends GT_MetaTileEntity_H @Override public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_Container_2by2(aPlayerInventory, aBaseMetaTileEntity); + return new GT_Container_2by2(aPlayerInventory, aBaseMetaTileEntity); } @Override public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_2by2(aPlayerInventory, aBaseMetaTileEntity, "Steam Output Bus"); + return new GT_GUIContainer_2by2(aPlayerInventory, aBaseMetaTileEntity, "Steam Output Bus"); } @Override @@ -90,8 +94,6 @@ public class GT_MetaTileEntity_Hatch_Steam_BusOutput extends GT_MetaTileEntity_H public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { return false; } - - @Override public ITexture[][][] getTextureSet(ITexture[] aTextures) { @@ -114,62 +116,128 @@ public class GT_MetaTileEntity_Hatch_Steam_BusOutput extends GT_MetaTileEntity_H } return rTextures; } - - public ITexture[] getSideFacingActive(byte aColor) { - return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_SIDE : Textures.BlockIcons.MACHINE_BRONZE_SIDE)}; + return new ITexture[] { + new GT_RenderedTexture( + mTier == 1 + ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_SIDE + : Textures.BlockIcons.MACHINE_BRONZE_SIDE) + }; } public ITexture[] getSideFacingInactive(byte aColor) { - return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_SIDE : Textures.BlockIcons.MACHINE_BRONZE_SIDE)}; + return new ITexture[] { + new GT_RenderedTexture( + mTier == 1 + ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_SIDE + : Textures.BlockIcons.MACHINE_BRONZE_SIDE) + }; } public ITexture[] getFrontFacingActive(byte aColor) { - return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_SIDE : Textures.BlockIcons.MACHINE_BRONZE_SIDE)}; + return new ITexture[] { + new GT_RenderedTexture( + mTier == 1 + ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_SIDE + : Textures.BlockIcons.MACHINE_BRONZE_SIDE) + }; } public ITexture[] getFrontFacingInactive(byte aColor) { - return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_SIDE : Textures.BlockIcons.MACHINE_BRONZE_SIDE)}; + return new ITexture[] { + new GT_RenderedTexture( + mTier == 1 + ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_SIDE + : Textures.BlockIcons.MACHINE_BRONZE_SIDE) + }; } public ITexture[] getTopFacingActive(byte aColor) { - return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_TOP : Textures.BlockIcons.MACHINE_BRONZE_TOP)}; + return new ITexture[] { + new GT_RenderedTexture( + mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_TOP : Textures.BlockIcons.MACHINE_BRONZE_TOP) + }; } public ITexture[] getTopFacingInactive(byte aColor) { - return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_TOP : Textures.BlockIcons.MACHINE_BRONZE_TOP)}; + return new ITexture[] { + new GT_RenderedTexture( + mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_TOP : Textures.BlockIcons.MACHINE_BRONZE_TOP) + }; } public ITexture[] getBottomFacingActive(byte aColor) { - return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_BOTTOM : Textures.BlockIcons.MACHINE_BRONZE_BOTTOM)}; + return new ITexture[] { + new GT_RenderedTexture( + mTier == 1 + ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_BOTTOM + : Textures.BlockIcons.MACHINE_BRONZE_BOTTOM) + }; } public ITexture[] getBottomFacingInactive(byte aColor) { - return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_BOTTOM : Textures.BlockIcons.MACHINE_BRONZE_BOTTOM)}; + return new ITexture[] { + new GT_RenderedTexture( + mTier == 1 + ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_BOTTOM + : Textures.BlockIcons.MACHINE_BRONZE_BOTTOM) + }; } public ITexture[] getBottomFacingPipeActive(byte aColor) { - return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_BOTTOM : Textures.BlockIcons.MACHINE_BRONZE_BOTTOM), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + return new ITexture[] { + new GT_RenderedTexture( + mTier == 1 + ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_BOTTOM + : Textures.BlockIcons.MACHINE_BRONZE_BOTTOM), + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT) + }; } public ITexture[] getBottomFacingPipeInactive(byte aColor) { - return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_BOTTOM : Textures.BlockIcons.MACHINE_BRONZE_BOTTOM), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + return new ITexture[] { + new GT_RenderedTexture( + mTier == 1 + ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_BOTTOM + : Textures.BlockIcons.MACHINE_BRONZE_BOTTOM), + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT) + }; } public ITexture[] getTopFacingPipeActive(byte aColor) { - return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_TOP : Textures.BlockIcons.MACHINE_BRONZE_TOP), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + return new ITexture[] { + new GT_RenderedTexture( + mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_TOP : Textures.BlockIcons.MACHINE_BRONZE_TOP), + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT) + }; } public ITexture[] getTopFacingPipeInactive(byte aColor) { - return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_TOP : Textures.BlockIcons.MACHINE_BRONZE_TOP), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + return new ITexture[] { + new GT_RenderedTexture( + mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_TOP : Textures.BlockIcons.MACHINE_BRONZE_TOP), + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT) + }; } public ITexture[] getSideFacingPipeActive(byte aColor) { - return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_SIDE : Textures.BlockIcons.MACHINE_BRONZE_SIDE), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + return new ITexture[] { + new GT_RenderedTexture( + mTier == 1 + ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_SIDE + : Textures.BlockIcons.MACHINE_BRONZE_SIDE), + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT) + }; } public ITexture[] getSideFacingPipeInactive(byte aColor) { - return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_SIDE : Textures.BlockIcons.MACHINE_BRONZE_SIDE), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + return new ITexture[] { + new GT_RenderedTexture( + mTier == 1 + ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_SIDE + : Textures.BlockIcons.MACHINE_BRONZE_SIDE), + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT) + }; } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Turbine.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Turbine.java index 69f7f98606..5973d21fc5 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Turbine.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Turbine.java @@ -30,376 +30,389 @@ import net.minecraft.nbt.NBTTagCompound; @SuppressWarnings("deprecation") public class GT_MetaTileEntity_Hatch_Turbine extends GT_MetaTileEntity_Hatch { - public boolean mHasController = false; - public boolean mUsingAnimation = true; - private String mControllerLocation; - public int mEUt = 0; - - public GT_MetaTileEntity_Hatch_Turbine(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, 16, "Turbine Rotor holder for XL Turbines"); - } - - public GT_MetaTileEntity_Hatch_Turbine(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { - super(aName, aTier, 1, aDescription, aTextures); - } - - public GT_MetaTileEntity_Hatch_Turbine(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { - super(aName, aTier, 1, aDescription[0], aTextures); - } - - @Override - public String[] getDescription() { - return new String[]{ - this.mDescription, - "Right Click with a soldering iron to reset controller link", - "Right Click with a wrench to remove turbine", - "Right Click with a screwdriver for technical information", - "Sneak + Right Click with a wrench to rotate", - "Sneak + Right Click with a screwdriver to disable animations", - CORE.GT_Tooltip}; - } - - @Override - public ITexture[] getTexturesActive(ITexture aBaseTexture) { - return new ITexture[]{aBaseTexture, getFrontFacingTurbineTexture()}; - } - - @Override - public ITexture[] getTexturesInactive(ITexture aBaseTexture) { - return new ITexture[]{aBaseTexture, getFrontFacingTurbineTexture()}; - } - - public int getEU() { - return this.mEUt; - } - - public void setEU(int aEU) { - this.mEUt = aEU; - } - - @Override - public boolean isSimpleMachine() { - return true; - } - - @Override - public boolean isFacingValid(byte aFacing) { - return aFacing > 1; - } - - @Override - public boolean isAccessAllowed(EntityPlayer aPlayer) { - return true; - } - - @Override - public boolean isValidSlot(int aIndex) { - return false; - } - - public boolean hasTurbine() { - ItemStack aStack = this.mInventory[0]; - boolean aIsValid = GregtechMetaTileEntity_LargerTurbineBase.isValidTurbine(aStack); - return aIsValid; - } - - public ItemStack getTurbine() { - if (hasTurbine()) { - return this.mInventory[0]; - } - return null; - } - - public boolean canWork() { - return hasTurbine(); - } - - public boolean insertTurbine(ItemStack aTurbine) { - if (GregtechMetaTileEntity_LargerTurbineBase.isValidTurbine(aTurbine)) { - this.mInventory[0] = aTurbine; - return true; - } - return false; - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_Hatch_Turbine(mName, mTier, StaticFields59.getDescriptionArray(this), mTextures); - } - - @Override - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) { - return true; - } - else { - aBaseMetaTileEntity.openGUI(aPlayer); - } - return true; - } - - @Override - public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new CONTAINER_1by1_Turbine(aPlayerInventory, aBaseMetaTileEntity); - } - - @Override - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GUI_1by1_Turbine(aPlayerInventory, aBaseMetaTileEntity, "Turbine Rotor Hatch"); - } - - @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return false; - } - - @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return false; - } - - @Override - public int getInventoryStackLimit() { - return 1; - } - - public void damageTurbine(int aEUt, int damageFactorLow, float damageFactorHigh) { - if (hasTurbine() && MathUtils.randInt(0, 1) == 0) { - ItemStack aTurbine = getTurbine(); - ((GT_MetaGenerated_Tool) aTurbine.getItem()).doDamage(aTurbine, (long)getDamageToComponent(aTurbine) * (long) Math.min(aEUt / damageFactorLow, Math.pow(aEUt, damageFactorHigh))); - } - } - - private final int getDamageToComponent(ItemStack aStack) { - return 1; - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - aNBT.setBoolean("mHasController", mHasController); - aNBT.setBoolean("mUsingAnimation", mUsingAnimation); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - mHasController = aNBT.getBoolean("mHasController"); - mUsingAnimation = aNBT.getBoolean("mUsingAnimation"); - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - super.onPostTick(aBaseMetaTileEntity, aTick); - if (this.mHasController) { - if (aTick % 20 == 0) { - if (isControllerActive()) { - this.getBaseMetaTileEntity().setActive(true); - } - else { - this.getBaseMetaTileEntity().setActive(false); - } - } - } - else if (!this.mHasController && this.mControllerLocation != null) { - //Weird Invalid State - if (setController(BlockPos.generateBlockPos(mControllerLocation))) { - //Valid - } - } - else { - //No Controller - } - if (this.mInventory[0] != null && this.mInventory[0].stackSize <= 0) - this.mInventory[0] = null; - } - - public boolean isControllerActive() { - GregtechMetaTileEntity_LargerTurbineBase x = getController(); - if (x != null) { - //Logger.INFO("Checking Status of Controller. Running? "+(x.mEUt > 0)); - return x.mEUt > 0; - } - //Logger.INFO("Status of Controller failed, controller is null."); - return false; - } - - public GregtechMetaTileEntity_LargerTurbineBase getController() { - if (this.mHasController && this.mControllerLocation != null && this.mControllerLocation.length() > 0) { - BlockPos p = BlockPos.generateBlockPos(mControllerLocation); - if (p != null) { - //Logger.INFO(p.getLocationString()); - IGregTechTileEntity tTileEntity = getBaseMetaTileEntity().getIGregTechTileEntity(p.xPos, p.yPos, - p.zPos); - if (tTileEntity != null && tTileEntity.getMetaTileEntity() instanceof GregtechMetaTileEntity_LargerTurbineBase) { - return (GregtechMetaTileEntity_LargerTurbineBase) tTileEntity.getMetaTileEntity(); - } - else { - if (tTileEntity == null) { - Logger.INFO("Controller MTE is null, somehow?"); - } - else { - Logger.INFO("Controller is a different MTE to expected"); - } - } - } - } - //Logger.INFO("Failed to Get Controller."); - return null; - } - - public boolean canSetNewController() { - if ((mControllerLocation != null && mControllerLocation.length() > 0) || this.mHasController) { - return false; - } - return true; - } - - public boolean setController(BlockPos aPos) { - clearController(); - if (canSetNewController()) { - mControllerLocation = aPos.getUniqueIdentifier(); - mHasController = true; - Logger.INFO("Successfully injected controller into this Turbine Assembly Hatch."); - } - return mHasController; - } - - public void clearController() { - this.mControllerLocation = null; - this.mHasController = false; - } - - public boolean usingAnimations() { - return mUsingAnimation; - } - - private ITexture getFrontFacingTurbineTexture() { - if (!mHasController) { - return this.getBaseMetaTileEntity().isActive() ? new GT_RenderedTexture(LargeTurbineTextureHandler.OVERLAY_LP_TURBINE_ACTIVE[4] ) : new GT_RenderedTexture(LargeTurbineTextureHandler.OVERLAY_LP_TURBINE[4] ); - } - else { - if (usingAnimations()) { - if (isControllerActive()) { - return getController().frontFaceActive; - } - } - return getController().frontFace; - } - } - - @Override - public long getMinimumStoredEU() { - return 0; - } - - @Override - public boolean isItemValidForSlot(int aIndex, ItemStack aStack) { - return false; - } - - @Override - public int[] getAccessibleSlotsFromSide(int aSide) { - return new int[] {}; - } - - @Override - public boolean canInsertItem(int aIndex, ItemStack aStack, int aSide) { - return false; - } - - public void setActive(boolean b) { - this.getBaseMetaTileEntity().setActive(b); - } - - @Override - public boolean allowCoverOnSide(byte aSide, GT_ItemStack aStack) { - return false; - } - - @Override - public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - if (!aPlayer.isSneaking()) { - PlayerUtils.messagePlayer(aPlayer, "Using Animations? "+usingAnimations()); - PlayerUtils.messagePlayer(aPlayer, "Has Controller? "+this.mHasController); - if (mHasController) { - PlayerUtils.messagePlayer(aPlayer, "Controller Location: "+BlockPos.generateBlockPos(mControllerLocation).getLocationString()); - PlayerUtils.messagePlayer(aPlayer, "Controller Active? "+this.isControllerActive()); - } - PlayerUtils.messagePlayer(aPlayer, "Active? "+this.getBaseMetaTileEntity().isActive()); - PlayerUtils.messagePlayer(aPlayer, "Has Turbine inserted? "+this.hasTurbine()); - if (this.hasTurbine()) { - Materials aMat = GT_MetaGenerated_Tool.getPrimaryMaterial(getTurbine()); - String aSize = GregtechMetaTileEntity_LargerTurbineBase.getTurbineSizeString(GregtechMetaTileEntity_LargerTurbineBase.getTurbineSize(getTurbine())); - PlayerUtils.messagePlayer(aPlayer, "Using: "+aMat.mLocalizedName+" "+aSize); - } - } - else { - this.mUsingAnimation = Utils.invertBoolean(mUsingAnimation); - if (this.mUsingAnimation) { - PlayerUtils.messagePlayer(aPlayer, "Using Animated Turbine Texture."); - } - else { - PlayerUtils.messagePlayer(aPlayer, "Using Static Turbine Texture."); - } - } - } - - @Override - public boolean onWrenchRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - if (this.getBaseMetaTileEntity().isServerSide() && !aPlayer.isSneaking()) { - ItemStack tCurrentItem = aPlayer.inventory.getCurrentItem(); - if (tCurrentItem != null) { - if (tCurrentItem.getItem() instanceof GT_MetaGenerated_Tool) { - return onToolClick(tCurrentItem, aPlayer, aWrenchingSide); - } - } - } - return super.onWrenchRightClick(aSide, aWrenchingSide, aPlayer, aX, aY, aZ); - } - - @Override - public boolean onSolderingToolRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - if (this.getBaseMetaTileEntity().isServerSide()) { - ItemStack tCurrentItem = aPlayer.inventory.getCurrentItem(); - if (tCurrentItem != null) { - if (tCurrentItem.getItem() instanceof GT_MetaGenerated_Tool) { - return onToolClick(tCurrentItem, aPlayer, aWrenchingSide); - } - } - } - return false; - } - - public boolean onToolClick(ItemStack tCurrentItem, EntityPlayer aPlayer, byte aSide) { - if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sWrenchList)) { - boolean aHasTurbine = this.hasTurbine(); - if (aPlayer.inventory.getFirstEmptyStack() >= 0 && aHasTurbine) { - if (PlayerUtils.isCreative(aPlayer) || GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 1000, aPlayer)) { - aPlayer.inventory.addItemStackToInventory((this.getTurbine())); - this.mInventory[0] = null; - GT_Utility.sendChatToPlayer(aPlayer, "Removed turbine with wrench."); - return true; - } - } - else { - GT_Utility.sendChatToPlayer(aPlayer, aHasTurbine ? "Cannot remove turbine, no free inventory space." : "No turbine to remove."); - } - } - else if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sSolderingToolList)) { - if (mControllerLocation != null && mControllerLocation.length() > 0) { - if (setController(BlockPos.generateBlockPos(mControllerLocation))) { - if (PlayerUtils.isCreative(aPlayer) || GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 1000, aPlayer)) { - String tChat = "Trying to Reset linked Controller"; - IGregTechTileEntity g = this.getBaseMetaTileEntity(); - GT_Utility.sendChatToPlayer(aPlayer, tChat); - GT_Utility.sendSoundToPlayers(g.getWorld(), GregTech_API.sSoundList.get(101), 1.0F, -1, g.getXCoord(), g.getYCoord(), g.getZCoord()); - return true; - } - } - } - } - return false; - } - + public boolean mHasController = false; + public boolean mUsingAnimation = true; + private String mControllerLocation; + public int mEUt = 0; + + public GT_MetaTileEntity_Hatch_Turbine(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, 16, "Turbine Rotor holder for XL Turbines"); + } + + public GT_MetaTileEntity_Hatch_Turbine(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 1, aDescription, aTextures); + } + + public GT_MetaTileEntity_Hatch_Turbine(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 1, aDescription[0], aTextures); + } + + @Override + public String[] getDescription() { + return new String[] { + this.mDescription, + "Right Click with a soldering iron to reset controller link", + "Right Click with a wrench to remove turbine", + "Right Click with a screwdriver for technical information", + "Sneak + Right Click with a wrench to rotate", + "Sneak + Right Click with a screwdriver to disable animations", + CORE.GT_Tooltip + }; + } + + @Override + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + return new ITexture[] {aBaseTexture, getFrontFacingTurbineTexture()}; + } + + @Override + public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + return new ITexture[] {aBaseTexture, getFrontFacingTurbineTexture()}; + } + + public int getEU() { + return this.mEUt; + } + + public void setEU(int aEU) { + this.mEUt = aEU; + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return aFacing > 1; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean isValidSlot(int aIndex) { + return false; + } + + public boolean hasTurbine() { + ItemStack aStack = this.mInventory[0]; + boolean aIsValid = GregtechMetaTileEntity_LargerTurbineBase.isValidTurbine(aStack); + return aIsValid; + } + + public ItemStack getTurbine() { + if (hasTurbine()) { + return this.mInventory[0]; + } + return null; + } + + public boolean canWork() { + return hasTurbine(); + } + + public boolean insertTurbine(ItemStack aTurbine) { + if (GregtechMetaTileEntity_LargerTurbineBase.isValidTurbine(aTurbine)) { + this.mInventory[0] = aTurbine; + return true; + } + return false; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_Hatch_Turbine(mName, mTier, StaticFields59.getDescriptionArray(this), mTextures); + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } else { + aBaseMetaTileEntity.openGUI(aPlayer); + } + return true; + } + + @Override + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new CONTAINER_1by1_Turbine(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_1by1_Turbine(aPlayerInventory, aBaseMetaTileEntity, "Turbine Rotor Hatch"); + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return false; + } + + @Override + public int getInventoryStackLimit() { + return 1; + } + + public void damageTurbine(int aEUt, int damageFactorLow, float damageFactorHigh) { + if (hasTurbine() && MathUtils.randInt(0, 1) == 0) { + ItemStack aTurbine = getTurbine(); + ((GT_MetaGenerated_Tool) aTurbine.getItem()) + .doDamage( + aTurbine, + (long) getDamageToComponent(aTurbine) + * (long) Math.min(aEUt / damageFactorLow, Math.pow(aEUt, damageFactorHigh))); + } + } + + private final int getDamageToComponent(ItemStack aStack) { + return 1; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setBoolean("mHasController", mHasController); + aNBT.setBoolean("mUsingAnimation", mUsingAnimation); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + mHasController = aNBT.getBoolean("mHasController"); + mUsingAnimation = aNBT.getBoolean("mUsingAnimation"); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + if (this.mHasController) { + if (aTick % 20 == 0) { + if (isControllerActive()) { + this.getBaseMetaTileEntity().setActive(true); + } else { + this.getBaseMetaTileEntity().setActive(false); + } + } + } else if (!this.mHasController && this.mControllerLocation != null) { + // Weird Invalid State + if (setController(BlockPos.generateBlockPos(mControllerLocation))) { + // Valid + } + } else { + // No Controller + } + if (this.mInventory[0] != null && this.mInventory[0].stackSize <= 0) this.mInventory[0] = null; + } + + public boolean isControllerActive() { + GregtechMetaTileEntity_LargerTurbineBase x = getController(); + if (x != null) { + // Logger.INFO("Checking Status of Controller. Running? "+(x.mEUt > 0)); + return x.mEUt > 0; + } + // Logger.INFO("Status of Controller failed, controller is null."); + return false; + } + + public GregtechMetaTileEntity_LargerTurbineBase getController() { + if (this.mHasController && this.mControllerLocation != null && this.mControllerLocation.length() > 0) { + BlockPos p = BlockPos.generateBlockPos(mControllerLocation); + if (p != null) { + // Logger.INFO(p.getLocationString()); + IGregTechTileEntity tTileEntity = + getBaseMetaTileEntity().getIGregTechTileEntity(p.xPos, p.yPos, p.zPos); + if (tTileEntity != null + && tTileEntity.getMetaTileEntity() instanceof GregtechMetaTileEntity_LargerTurbineBase) { + return (GregtechMetaTileEntity_LargerTurbineBase) tTileEntity.getMetaTileEntity(); + } else { + if (tTileEntity == null) { + Logger.INFO("Controller MTE is null, somehow?"); + } else { + Logger.INFO("Controller is a different MTE to expected"); + } + } + } + } + // Logger.INFO("Failed to Get Controller."); + return null; + } + + public boolean canSetNewController() { + if ((mControllerLocation != null && mControllerLocation.length() > 0) || this.mHasController) { + return false; + } + return true; + } + + public boolean setController(BlockPos aPos) { + clearController(); + if (canSetNewController()) { + mControllerLocation = aPos.getUniqueIdentifier(); + mHasController = true; + Logger.INFO("Successfully injected controller into this Turbine Assembly Hatch."); + } + return mHasController; + } + + public void clearController() { + this.mControllerLocation = null; + this.mHasController = false; + } + + public boolean usingAnimations() { + return mUsingAnimation; + } + + private ITexture getFrontFacingTurbineTexture() { + if (!mHasController) { + return this.getBaseMetaTileEntity().isActive() + ? new GT_RenderedTexture(LargeTurbineTextureHandler.OVERLAY_LP_TURBINE_ACTIVE[4]) + : new GT_RenderedTexture(LargeTurbineTextureHandler.OVERLAY_LP_TURBINE[4]); + } else { + if (usingAnimations()) { + if (isControllerActive()) { + return getController().frontFaceActive; + } + } + return getController().frontFace; + } + } + + @Override + public long getMinimumStoredEU() { + return 0; + } + + @Override + public boolean isItemValidForSlot(int aIndex, ItemStack aStack) { + return false; + } + + @Override + public int[] getAccessibleSlotsFromSide(int aSide) { + return new int[] {}; + } + + @Override + public boolean canInsertItem(int aIndex, ItemStack aStack, int aSide) { + return false; + } + + public void setActive(boolean b) { + this.getBaseMetaTileEntity().setActive(b); + } + + @Override + public boolean allowCoverOnSide(byte aSide, GT_ItemStack aStack) { + return false; + } + + @Override + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (!aPlayer.isSneaking()) { + PlayerUtils.messagePlayer(aPlayer, "Using Animations? " + usingAnimations()); + PlayerUtils.messagePlayer(aPlayer, "Has Controller? " + this.mHasController); + if (mHasController) { + PlayerUtils.messagePlayer( + aPlayer, + "Controller Location: " + + BlockPos.generateBlockPos(mControllerLocation).getLocationString()); + PlayerUtils.messagePlayer(aPlayer, "Controller Active? " + this.isControllerActive()); + } + PlayerUtils.messagePlayer( + aPlayer, "Active? " + this.getBaseMetaTileEntity().isActive()); + PlayerUtils.messagePlayer(aPlayer, "Has Turbine inserted? " + this.hasTurbine()); + if (this.hasTurbine()) { + Materials aMat = GT_MetaGenerated_Tool.getPrimaryMaterial(getTurbine()); + String aSize = GregtechMetaTileEntity_LargerTurbineBase.getTurbineSizeString( + GregtechMetaTileEntity_LargerTurbineBase.getTurbineSize(getTurbine())); + PlayerUtils.messagePlayer(aPlayer, "Using: " + aMat.mLocalizedName + " " + aSize); + } + } else { + this.mUsingAnimation = Utils.invertBoolean(mUsingAnimation); + if (this.mUsingAnimation) { + PlayerUtils.messagePlayer(aPlayer, "Using Animated Turbine Texture."); + } else { + PlayerUtils.messagePlayer(aPlayer, "Using Static Turbine Texture."); + } + } + } + + @Override + public boolean onWrenchRightClick( + byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (this.getBaseMetaTileEntity().isServerSide() && !aPlayer.isSneaking()) { + ItemStack tCurrentItem = aPlayer.inventory.getCurrentItem(); + if (tCurrentItem != null) { + if (tCurrentItem.getItem() instanceof GT_MetaGenerated_Tool) { + return onToolClick(tCurrentItem, aPlayer, aWrenchingSide); + } + } + } + return super.onWrenchRightClick(aSide, aWrenchingSide, aPlayer, aX, aY, aZ); + } + + @Override + public boolean onSolderingToolRightClick( + byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (this.getBaseMetaTileEntity().isServerSide()) { + ItemStack tCurrentItem = aPlayer.inventory.getCurrentItem(); + if (tCurrentItem != null) { + if (tCurrentItem.getItem() instanceof GT_MetaGenerated_Tool) { + return onToolClick(tCurrentItem, aPlayer, aWrenchingSide); + } + } + } + return false; + } + + public boolean onToolClick(ItemStack tCurrentItem, EntityPlayer aPlayer, byte aSide) { + if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sWrenchList)) { + boolean aHasTurbine = this.hasTurbine(); + if (aPlayer.inventory.getFirstEmptyStack() >= 0 && aHasTurbine) { + if (PlayerUtils.isCreative(aPlayer) + || GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 1000, aPlayer)) { + aPlayer.inventory.addItemStackToInventory((this.getTurbine())); + this.mInventory[0] = null; + GT_Utility.sendChatToPlayer(aPlayer, "Removed turbine with wrench."); + return true; + } + } else { + GT_Utility.sendChatToPlayer( + aPlayer, + aHasTurbine ? "Cannot remove turbine, no free inventory space." : "No turbine to remove."); + } + } else if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sSolderingToolList)) { + if (mControllerLocation != null && mControllerLocation.length() > 0) { + if (setController(BlockPos.generateBlockPos(mControllerLocation))) { + if (PlayerUtils.isCreative(aPlayer) + || GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 1000, aPlayer)) { + String tChat = "Trying to Reset linked Controller"; + IGregTechTileEntity g = this.getBaseMetaTileEntity(); + GT_Utility.sendChatToPlayer(aPlayer, tChat); + GT_Utility.sendSoundToPlayers( + g.getWorld(), + GregTech_API.sSoundList.get(101), + 1.0F, + -1, + g.getXCoord(), + g.getYCoord(), + g.getZCoord()); + return true; + } + } + } + } + return false; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_TurbineProvider.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_TurbineProvider.java index 0b84f676f4..85b921b1ed 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_TurbineProvider.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_TurbineProvider.java @@ -23,198 +23,194 @@ import net.minecraft.world.chunk.Chunk; public class GT_MetaTileEntity_Hatch_TurbineProvider extends GT_MetaTileEntity_Hatch_InputBus { - public GT_MetaTileEntity_Hatch_TurbineProvider(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier); - } - - public GT_MetaTileEntity_Hatch_TurbineProvider(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { - super(aName, aTier, aDescription, aTextures); - } - - public GT_MetaTileEntity_Hatch_TurbineProvider(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { - super(aName, aTier, aDescription[0], aTextures); - } - - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_Hatch_TurbineProvider(this.mName, this.mTier, this.mDescription, this.mTextures); - } - - public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new CONTAINER_1by1_Turbine(aPlayerInventory, aBaseMetaTileEntity); - } - - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GUI_1by1_Turbine(aPlayerInventory, aBaseMetaTileEntity, "Turbine Housing"); - } - - @Override - public String[] getDescription() { - return new String[]{ - "An automation port for Large Turbines", - "Will attempt once per 1200 ticks to fill the turbine slot of it's parent turbine", - "You may adjust this with a screwdriver", - "Hold shift to adjust in finer amounts", - "Hold control to adjust direction", - "Left Click with Screwdriver to reset", - "This module assumes the entire turbine is in the same Chunk", - CORE.GT_Tooltip}; - } - - - private GT_MetaTileEntity_LargeTurbine mParent = null; - - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { - super.onPostTick(aBaseMetaTileEntity, aTimer); - if (aTimer % mRefreshTime == 0 && this.getBaseMetaTileEntity().isServerSide()) { - tryRefillTurbine(); - } - } - - private final void tryFindParentTurbine() { - Logger.INFO("This turbine housing has no parent, searching world."); - IGregTechTileEntity T = this.getBaseMetaTileEntity(); - World W = T.getWorld(); - Chunk C = W.getChunkFromBlockCoords(T.getXCoord(), T.getZCoord()); - for (Object o : C.chunkTileEntityMap.values()) { - if (o instanceof IGregTechTileEntity) { - IGregTechTileEntity G = (IGregTechTileEntity) o; - final IMetaTileEntity aMetaTileEntity = G.getMetaTileEntity(); - if (aMetaTileEntity == null) { - continue; - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_LargeTurbine) { - GT_MetaTileEntity_LargeTurbine aTurb = (GT_MetaTileEntity_LargeTurbine) aMetaTileEntity; - for (GT_MetaTileEntity_Hatch_InputBus ee : aTurb.mInputBusses) { - if (ee.equals(this)) { - mParent = aTurb; - Logger.INFO("Found a Parent to attach to this housing."); - return; - } - } - } - } - } - } - - private final void tryRefillTurbine() { - if (mParent == null) { - tryFindParentTurbine(); - } - if (mParent != null && mParent.mInventory[1] == null) { - for (ItemStack aStack : this.mInventory) { - if (isItemStackTurbine(aStack)) { - setGUIItemStack(aStack); - } - } - } - } - - protected boolean setGUIItemStack(ItemStack aNewGuiSlotContents) { - boolean result = false; - if (mParent.mInventory[1] == null) { - mParent.mInventory[1] = aNewGuiSlotContents != null ? aNewGuiSlotContents.copy() : null; - mParent.depleteInput(aNewGuiSlotContents); - mParent.updateSlots(); - this.updateSlots(); - result = true; - } - return result; - } - - public boolean isItemStackTurbine(ItemStack aStack) { - if (aStack.getItem() instanceof GT_MetaGenerated_Tool) { - if (aStack.getItemDamage() >= 170 && aStack.getItemDamage() <= 176) { - return true; - } - } - return false; - } - - public boolean isItemStackScrewdriver(ItemStack aStack) { - if (aStack.getItem() instanceof GT_MetaGenerated_Tool) { - if (aStack.getItemDamage() == 22 || aStack.getItemDamage() == 150) { - return true; - } - } - return false; - } - - - @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return false; - } - - @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return isItemStackTurbine(aStack); - } - - private int mRefreshTime = 1200; - private boolean mDescending = true; - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - aNBT.setInteger("mRefreshTime", mRefreshTime); - aNBT.setBoolean("mDescending", mDescending); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - mRefreshTime = aNBT.getInteger("mRefreshTime"); - mDescending = aNBT.getBoolean("mDescending"); - } - - @Override - public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - if (aPlayer != null) { - if (KeyboardUtils.isCtrlKeyDown()) { - mDescending = Utils.invertBoolean(mDescending); - PlayerUtils.messagePlayer(aPlayer, "Direction: "+(mDescending ? "DOWN" : "UP")); - } - else { - int aAmount = 0; - if (KeyboardUtils.isShiftKeyDown()) { - aAmount = 10; - } - else { - aAmount = 100; - } - if (mDescending) { - mRefreshTime -= aAmount; - if (mRefreshTime < 0) { - mRefreshTime = 1200; - } - } - else { - mRefreshTime += aAmount; - if (mRefreshTime > 1200) { - mRefreshTime = 0; - } - } - PlayerUtils.messagePlayer(aPlayer, "Set check time to be every "+mRefreshTime+" ticks."); - } - } - } - - @Override - public void onLeftclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { - boolean aDidScrewdriver = false; - if (aPlayer != null) { - if (aPlayer.getHeldItem() != null) { - if (isItemStackScrewdriver(aPlayer.getHeldItem())) { - aDidScrewdriver = true; - mRefreshTime = 1200; - PlayerUtils.messagePlayer(aPlayer, "Reset check time to "+mRefreshTime+" ticks."); - } - } - } - if (!aDidScrewdriver) { - super.onLeftclick(aBaseMetaTileEntity, aPlayer); - } - } - + public GT_MetaTileEntity_Hatch_TurbineProvider(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier); + } + public GT_MetaTileEntity_Hatch_TurbineProvider( + String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + public GT_MetaTileEntity_Hatch_TurbineProvider( + String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription[0], aTextures); + } + + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_Hatch_TurbineProvider(this.mName, this.mTier, this.mDescription, this.mTextures); + } + + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new CONTAINER_1by1_Turbine(aPlayerInventory, aBaseMetaTileEntity); + } + + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_1by1_Turbine(aPlayerInventory, aBaseMetaTileEntity, "Turbine Housing"); + } + + @Override + public String[] getDescription() { + return new String[] { + "An automation port for Large Turbines", + "Will attempt once per 1200 ticks to fill the turbine slot of it's parent turbine", + "You may adjust this with a screwdriver", + "Hold shift to adjust in finer amounts", + "Hold control to adjust direction", + "Left Click with Screwdriver to reset", + "This module assumes the entire turbine is in the same Chunk", + CORE.GT_Tooltip + }; + } + + private GT_MetaTileEntity_LargeTurbine mParent = null; + + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { + super.onPostTick(aBaseMetaTileEntity, aTimer); + if (aTimer % mRefreshTime == 0 && this.getBaseMetaTileEntity().isServerSide()) { + tryRefillTurbine(); + } + } + + private final void tryFindParentTurbine() { + Logger.INFO("This turbine housing has no parent, searching world."); + IGregTechTileEntity T = this.getBaseMetaTileEntity(); + World W = T.getWorld(); + Chunk C = W.getChunkFromBlockCoords(T.getXCoord(), T.getZCoord()); + for (Object o : C.chunkTileEntityMap.values()) { + if (o instanceof IGregTechTileEntity) { + IGregTechTileEntity G = (IGregTechTileEntity) o; + final IMetaTileEntity aMetaTileEntity = G.getMetaTileEntity(); + if (aMetaTileEntity == null) { + continue; + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_LargeTurbine) { + GT_MetaTileEntity_LargeTurbine aTurb = (GT_MetaTileEntity_LargeTurbine) aMetaTileEntity; + for (GT_MetaTileEntity_Hatch_InputBus ee : aTurb.mInputBusses) { + if (ee.equals(this)) { + mParent = aTurb; + Logger.INFO("Found a Parent to attach to this housing."); + return; + } + } + } + } + } + } + + private final void tryRefillTurbine() { + if (mParent == null) { + tryFindParentTurbine(); + } + if (mParent != null && mParent.mInventory[1] == null) { + for (ItemStack aStack : this.mInventory) { + if (isItemStackTurbine(aStack)) { + setGUIItemStack(aStack); + } + } + } + } + + protected boolean setGUIItemStack(ItemStack aNewGuiSlotContents) { + boolean result = false; + if (mParent.mInventory[1] == null) { + mParent.mInventory[1] = aNewGuiSlotContents != null ? aNewGuiSlotContents.copy() : null; + mParent.depleteInput(aNewGuiSlotContents); + mParent.updateSlots(); + this.updateSlots(); + result = true; + } + return result; + } + + public boolean isItemStackTurbine(ItemStack aStack) { + if (aStack.getItem() instanceof GT_MetaGenerated_Tool) { + if (aStack.getItemDamage() >= 170 && aStack.getItemDamage() <= 176) { + return true; + } + } + return false; + } + + public boolean isItemStackScrewdriver(ItemStack aStack) { + if (aStack.getItem() instanceof GT_MetaGenerated_Tool) { + if (aStack.getItemDamage() == 22 || aStack.getItemDamage() == 150) { + return true; + } + } + return false; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return isItemStackTurbine(aStack); + } + + private int mRefreshTime = 1200; + private boolean mDescending = true; + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setInteger("mRefreshTime", mRefreshTime); + aNBT.setBoolean("mDescending", mDescending); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + mRefreshTime = aNBT.getInteger("mRefreshTime"); + mDescending = aNBT.getBoolean("mDescending"); + } + + @Override + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (aPlayer != null) { + if (KeyboardUtils.isCtrlKeyDown()) { + mDescending = Utils.invertBoolean(mDescending); + PlayerUtils.messagePlayer(aPlayer, "Direction: " + (mDescending ? "DOWN" : "UP")); + } else { + int aAmount = 0; + if (KeyboardUtils.isShiftKeyDown()) { + aAmount = 10; + } else { + aAmount = 100; + } + if (mDescending) { + mRefreshTime -= aAmount; + if (mRefreshTime < 0) { + mRefreshTime = 1200; + } + } else { + mRefreshTime += aAmount; + if (mRefreshTime > 1200) { + mRefreshTime = 0; + } + } + PlayerUtils.messagePlayer(aPlayer, "Set check time to be every " + mRefreshTime + " ticks."); + } + } + } + + @Override + public void onLeftclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + boolean aDidScrewdriver = false; + if (aPlayer != null) { + if (aPlayer.getHeldItem() != null) { + if (isItemStackScrewdriver(aPlayer.getHeldItem())) { + aDidScrewdriver = true; + mRefreshTime = 1200; + PlayerUtils.messagePlayer(aPlayer, "Reset check time to " + mRefreshTime + " ticks."); + } + } + } + if (!aDidScrewdriver) { + super.onLeftclick(aBaseMetaTileEntity, aPlayer); + } + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Input.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Input.java index d0682b85e8..f144076131 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Input.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Input.java @@ -15,134 +15,130 @@ import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; public class GT_MetaTileEntity_SuperBus_Input extends GT_MetaTileEntity_Hatch_InputBus { - public GT_MetaTileEntity_SuperBus_Input(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, getSlots(aTier)); - } - - public GT_MetaTileEntity_SuperBus_Input(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { - super(aName, aTier, getSlots(aTier), aDescription, aTextures); - } - - /** - * Returns a factor of 16 based on tier. - * - * @param aTier The tier of this bus. - * @return (1 + aTier) * 16 - */ - public static int getSlots(int aTier) { - return (1 + aTier) * 16; - } - - public ITexture[] getTexturesActive(ITexture aBaseTexture) { - return new ITexture[]{aBaseTexture, new GT_RenderedTexture(BlockIcons.OVERLAY_PIPE_IN)}; - } - - public ITexture[] getTexturesInactive(ITexture aBaseTexture) { - return new ITexture[]{aBaseTexture, new GT_RenderedTexture(BlockIcons.OVERLAY_PIPE_IN)}; - } - - public boolean isSimpleMachine() { - return true; - } - - public boolean isFacingValid(byte aFacing) { - return true; - } - - public boolean isAccessAllowed(EntityPlayer aPlayer) { - return true; - } - - public boolean isValidSlot(int aIndex) { - return true; - } - - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_SuperBus_Input(this.mName, this.mTier, ArrayExt.of(this.mDescription), this.mTextures); - } - - public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return null; - } - - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return null; - } - - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return aSide == this.getBaseMetaTileEntity().getFrontFacing(); - } - - @Override - public String[] getDescription() { - String[] aDesc = new String[] { - "Item Input for Multiblocks", - "This bus has no GUI, but can have items extracted", - ""+getSlots(this.mTier)+" Slots", - CORE.GT_Tooltip - }; - return aDesc; - } - - @Override - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, byte aSide, float aX, - float aY, float aZ) { - return super.onRightclick(aBaseMetaTileEntity, aPlayer, aSide, aX, aY, aZ); - } - - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) { - return true; - } else { - //Logger.INFO("Trying to display Super Input Bus contents."); - displayBusContents(aPlayer); - return true; - } - } - - public void displayBusContents(EntityPlayer aPlayer) { - String STRIP = "Item Array: "; - String aNameString = ItemUtils.getArrayStackNames(getRealInventory()); - aNameString = aNameString.replace(STRIP, ""); - - String[] aNames; - if (aNameString.length() < 1) { - aNames = null; - } - else { - aNames = aNameString.split(","); - } - - if (aNames == null || aNames.length <= 0) { - PlayerUtils.messagePlayer(aPlayer, "This Super Bus (I) is Empty. Total Slots: "+getSlots(this.mTier)); - return; - } - - PlayerUtils.messagePlayer(aPlayer, "This Super Bus (I) contains: ["+getRealInventory().length+"]"); - - if (aNames.length <= 12) { - for (String s : aNames) { - if (s.startsWith(" ")) { - s = s.substring(1); - } - //Logger.INFO("Trying to display Super Input Bus contents. "+s); - PlayerUtils.messagePlayer(aPlayer, s); - } - } - else { - - String superString = ""; - - for (String s : aNames) { - if (s.startsWith(" ")) { - s = s.substring(1); - } - superString += (s+", "); - } - PlayerUtils.messagePlayer(aPlayer, superString); - } - - - } - -}
\ No newline at end of file + public GT_MetaTileEntity_SuperBus_Input(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, getSlots(aTier)); + } + + public GT_MetaTileEntity_SuperBus_Input(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, getSlots(aTier), aDescription, aTextures); + } + + /** + * Returns a factor of 16 based on tier. + * + * @param aTier The tier of this bus. + * @return (1 + aTier) * 16 + */ + public static int getSlots(int aTier) { + return (1 + aTier) * 16; + } + + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + return new ITexture[] {aBaseTexture, new GT_RenderedTexture(BlockIcons.OVERLAY_PIPE_IN)}; + } + + public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + return new ITexture[] {aBaseTexture, new GT_RenderedTexture(BlockIcons.OVERLAY_PIPE_IN)}; + } + + public boolean isSimpleMachine() { + return true; + } + + public boolean isFacingValid(byte aFacing) { + return true; + } + + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + public boolean isValidSlot(int aIndex) { + return true; + } + + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_SuperBus_Input( + this.mName, this.mTier, ArrayExt.of(this.mDescription), this.mTextures); + } + + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return null; + } + + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return null; + } + + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return aSide == this.getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public String[] getDescription() { + String[] aDesc = new String[] { + "Item Input for Multiblocks", + "This bus has no GUI, but can have items extracted", + "" + getSlots(this.mTier) + " Slots", + CORE.GT_Tooltip + }; + return aDesc; + } + + @Override + public boolean onRightclick( + IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, byte aSide, float aX, float aY, float aZ) { + return super.onRightclick(aBaseMetaTileEntity, aPlayer, aSide, aX, aY, aZ); + } + + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } else { + // Logger.INFO("Trying to display Super Input Bus contents."); + displayBusContents(aPlayer); + return true; + } + } + + public void displayBusContents(EntityPlayer aPlayer) { + String STRIP = "Item Array: "; + String aNameString = ItemUtils.getArrayStackNames(getRealInventory()); + aNameString = aNameString.replace(STRIP, ""); + + String[] aNames; + if (aNameString.length() < 1) { + aNames = null; + } else { + aNames = aNameString.split(","); + } + + if (aNames == null || aNames.length <= 0) { + PlayerUtils.messagePlayer(aPlayer, "This Super Bus (I) is Empty. Total Slots: " + getSlots(this.mTier)); + return; + } + + PlayerUtils.messagePlayer(aPlayer, "This Super Bus (I) contains: [" + getRealInventory().length + "]"); + + if (aNames.length <= 12) { + for (String s : aNames) { + if (s.startsWith(" ")) { + s = s.substring(1); + } + // Logger.INFO("Trying to display Super Input Bus contents. "+s); + PlayerUtils.messagePlayer(aPlayer, s); + } + } else { + + String superString = ""; + + for (String s : aNames) { + if (s.startsWith(" ")) { + s = s.substring(1); + } + superString += (s + ", "); + } + PlayerUtils.messagePlayer(aPlayer, superString); + } + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Output.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Output.java index 37aa57298a..7fecabd5d7 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Output.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Output.java @@ -17,164 +17,170 @@ import net.minecraft.nbt.NBTTagCompound; public class GT_MetaTileEntity_SuperBus_Output extends GT_MetaTileEntity_Hatch_OutputBus { - public GT_MetaTileEntity_SuperBus_Output(int id, String name, String nameRegional, int tier) { - super(id, name, nameRegional, tier, getSlots(tier)); - } - - public GT_MetaTileEntity_SuperBus_Output(String name, int tier, String[] description, ITexture[][][] textures) { - super(name, tier, getSlots(tier), description, textures); - } - - /** - * Returns a factor of 16 based on tier. - * - * @param aTier The tier of this bus. - * @return (1 + aTier) * 16 - */ - public static int getSlots(int aTier) { - return (1 + aTier) * 16; - } - - public boolean isValidSlot(int aIndex) { - return true; - } - - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_SuperBus_Output(this.mName, this.mTier, ArrayExt.of(this.mDescription), this.mTextures); - } - - public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return null; - } - - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return null; - } - - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { - if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.hasInventoryBeenModified()) { - this.fillStacksIntoFirstSlots(); - } + public GT_MetaTileEntity_SuperBus_Output(int id, String name, String nameRegional, int tier) { + super(id, name, nameRegional, tier, getSlots(tier)); + } + + public GT_MetaTileEntity_SuperBus_Output(String name, int tier, String[] description, ITexture[][][] textures) { + super(name, tier, getSlots(tier), description, textures); + } + + /** + * Returns a factor of 16 based on tier. + * + * @param aTier The tier of this bus. + * @return (1 + aTier) * 16 + */ + public static int getSlots(int aTier) { + return (1 + aTier) * 16; + } + + public boolean isValidSlot(int aIndex) { + return true; + } + + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_SuperBus_Output( + this.mName, this.mTier, ArrayExt.of(this.mDescription), this.mTextures); + } + + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return null; + } + + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return null; + } + + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { + if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.hasInventoryBeenModified()) { + this.fillStacksIntoFirstSlots(); + } super.onPostTick(aBaseMetaTileEntity, aTimer); - } - - public void updateSlots() { - for (int i = 0; i < this.mInventory.length; ++i) { - if (this.mInventory[i] != null && this.mInventory[i].stackSize <= 0) { - this.mInventory[i] = null; - } - } - this.fillStacksIntoFirstSlots(); - } - - protected void fillStacksIntoFirstSlots() { - for (int i = 0; i < this.mInventory.length; ++i) { - for (int j = i + 1; j < this.mInventory.length; ++j) { - if (this.mInventory[j] != null && (this.mInventory[i] == null - || GT_Utility.areStacksEqual(this.mInventory[i], this.mInventory[j]))) { - GT_Utility.moveStackFromSlotAToSlotB((IInventory) this.getBaseMetaTileEntity(), (IInventory) this.getBaseMetaTileEntity(), j, i, (byte) 64, (byte) 1, (byte) 64, (byte) 1); - } - } - } - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - } - - @Override - public String[] getDescription() { - String[] aDesc = new String[] { - "Item Output for Multiblocks", - "This bus has no GUI", - ""+getSlots(this.mTier)+" Slots", - CORE.GT_Tooltip - }; - return aDesc; - } - - @Override - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, byte aSide, float aX, - float aY, float aZ) { - return super.onRightclick(aBaseMetaTileEntity, aPlayer, aSide, aX, aY, aZ); - } - - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) { - return true; - } else { - displayBusContents(aPlayer); - return true; - } - } - - public void displayBusContents(EntityPlayer aPlayer) { - String STRIP = "Item Array: "; - String aNameString = ItemUtils.getArrayStackNames(getRealInventory()); - aNameString = aNameString.replace(STRIP, ""); - - String[] aNames; - if (aNameString.length() < 1) { - aNames = null; - } - else { - aNames = aNameString.split(","); - } - - if (aNames == null || aNames.length <= 0) { - PlayerUtils.messagePlayer(aPlayer, "This Super Bus (O) is Empty. Total Slots: "+getSlots(this.mTier)); - return; - } - - PlayerUtils.messagePlayer(aPlayer, "This Super Bus (O) contains:"); - for (String s : aNames) { - if (s.startsWith(" ")) { - s = s.substring(1); - } - //Logger.INFO("Trying to display Super Output Bus contents. "+s); - PlayerUtils.messagePlayer(aPlayer, s); - } - } - - @Override - public int getMaxItemCount() { - // TODO Auto-generated method stub - return super.getMaxItemCount(); - } - - @Override - public int getSizeInventory() { - // TODO Auto-generated method stub - return super.getSizeInventory(); - } - - @Override - public ItemStack getStackInSlot(int aIndex) { - // TODO Auto-generated method stub - return super.getStackInSlot(aIndex); - } - - @Override - public boolean canInsertItem(int aIndex, ItemStack aStack, int aSide) { - // TODO Auto-generated method stub - return super.canInsertItem(aIndex, aStack, aSide); - } - - @Override - public boolean canExtractItem(int aIndex, ItemStack aStack, int aSide) { - // TODO Auto-generated method stub - return super.canExtractItem(aIndex, aStack, aSide); - } - - @Override - public ItemStack[] getRealInventory() { - // TODO Auto-generated method stub - return super.getRealInventory(); - } -}
\ No newline at end of file + } + + public void updateSlots() { + for (int i = 0; i < this.mInventory.length; ++i) { + if (this.mInventory[i] != null && this.mInventory[i].stackSize <= 0) { + this.mInventory[i] = null; + } + } + this.fillStacksIntoFirstSlots(); + } + + protected void fillStacksIntoFirstSlots() { + for (int i = 0; i < this.mInventory.length; ++i) { + for (int j = i + 1; j < this.mInventory.length; ++j) { + if (this.mInventory[j] != null + && (this.mInventory[i] == null + || GT_Utility.areStacksEqual(this.mInventory[i], this.mInventory[j]))) { + GT_Utility.moveStackFromSlotAToSlotB( + (IInventory) this.getBaseMetaTileEntity(), + (IInventory) this.getBaseMetaTileEntity(), + j, + i, + (byte) 64, + (byte) 1, + (byte) 64, + (byte) 1); + } + } + } + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + } + + @Override + public String[] getDescription() { + String[] aDesc = new String[] { + "Item Output for Multiblocks", "This bus has no GUI", "" + getSlots(this.mTier) + " Slots", CORE.GT_Tooltip + }; + return aDesc; + } + + @Override + public boolean onRightclick( + IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, byte aSide, float aX, float aY, float aZ) { + return super.onRightclick(aBaseMetaTileEntity, aPlayer, aSide, aX, aY, aZ); + } + + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } else { + displayBusContents(aPlayer); + return true; + } + } + + public void displayBusContents(EntityPlayer aPlayer) { + String STRIP = "Item Array: "; + String aNameString = ItemUtils.getArrayStackNames(getRealInventory()); + aNameString = aNameString.replace(STRIP, ""); + + String[] aNames; + if (aNameString.length() < 1) { + aNames = null; + } else { + aNames = aNameString.split(","); + } + + if (aNames == null || aNames.length <= 0) { + PlayerUtils.messagePlayer(aPlayer, "This Super Bus (O) is Empty. Total Slots: " + getSlots(this.mTier)); + return; + } + + PlayerUtils.messagePlayer(aPlayer, "This Super Bus (O) contains:"); + for (String s : aNames) { + if (s.startsWith(" ")) { + s = s.substring(1); + } + // Logger.INFO("Trying to display Super Output Bus contents. "+s); + PlayerUtils.messagePlayer(aPlayer, s); + } + } + + @Override + public int getMaxItemCount() { + // TODO Auto-generated method stub + return super.getMaxItemCount(); + } + + @Override + public int getSizeInventory() { + // TODO Auto-generated method stub + return super.getSizeInventory(); + } + + @Override + public ItemStack getStackInSlot(int aIndex) { + // TODO Auto-generated method stub + return super.getStackInSlot(aIndex); + } + + @Override + public boolean canInsertItem(int aIndex, ItemStack aStack, int aSide) { + // TODO Auto-generated method stub + return super.canInsertItem(aIndex, aStack, aSide); + } + + @Override + public boolean canExtractItem(int aIndex, ItemStack aStack, int aSide) { + // TODO Auto-generated method stub + return super.canExtractItem(aIndex, aStack, aSide); + } + + @Override + public ItemStack[] getRealInventory() { + // TODO Auto-generated method stub + return super.getRealInventory(); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaPipeEntityFluid.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaPipeEntityFluid.java index f6e778f989..8f7fd8d4d3 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaPipeEntityFluid.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaPipeEntityFluid.java @@ -13,107 +13,167 @@ import gtPlusPlus.xmod.gregtech.common.StaticFields59; import net.minecraft.util.EnumChatFormatting; public class GregtechMetaPipeEntityFluid extends GT_MetaPipeEntity_Fluid { - - - public static final boolean mGt6Pipe; - - static { - mGt6Pipe = StaticFields59.mGT6StylePipes; - } - - public final GT_Materials mMaterial; - private boolean mCheckConnections; - - - public GregtechMetaPipeEntityFluid(int aID, String aName, String aNameRegional, float aThickNess, GT_Materials aMaterial, - int aCapacity, int aHeatResistance, boolean aGasProof) { - this(aID, aName, aNameRegional, aThickNess, aMaterial, aCapacity, aHeatResistance, aGasProof, 1); - } - - public GregtechMetaPipeEntityFluid(final String aName, final float aThickNess, final GT_Materials aMaterial, final int aCapacity, final int aHeatResistance, final boolean aGasProof) { - this(aName, aThickNess, aMaterial, aCapacity, aHeatResistance, aGasProof, 1); - } - public GregtechMetaPipeEntityFluid(int aID, String aName, String aNameRegional, float aThickNess, GT_Materials aMaterial, - int aCapacity, int aHeatResistance, boolean aGasProof, int aFluidTypes) { - super(aID, aName, aNameRegional, aThickNess, null, aCapacity, aHeatResistance, aGasProof); - this.mLastReceivedFrom = 0; - this.oLastReceivedFrom = 0; - this.mCheckConnections = !mGt6Pipe; - this.mMaterial = aMaterial; - } - + public static final boolean mGt6Pipe; + static { + mGt6Pipe = StaticFields59.mGT6StylePipes; + } - public GregtechMetaPipeEntityFluid(String aName, float aThickNess, GT_Materials aMaterial, int aCapacity, - int aHeatResistance, boolean aGasProof, int aFluidTypes) { - super(aName, aThickNess, null, aCapacity, aHeatResistance, aGasProof); - this.mLastReceivedFrom = 0; - this.oLastReceivedFrom = 0; - this.mCheckConnections = !mGt6Pipe; - this.mMaterial = aMaterial; - } + public final GT_Materials mMaterial; + private boolean mCheckConnections; + public GregtechMetaPipeEntityFluid( + int aID, + String aName, + String aNameRegional, + float aThickNess, + GT_Materials aMaterial, + int aCapacity, + int aHeatResistance, + boolean aGasProof) { + this(aID, aName, aNameRegional, aThickNess, aMaterial, aCapacity, aHeatResistance, aGasProof, 1); + } - @Override - public byte getTileEntityBaseType() { - return this.mMaterial == null ? 4 : (byte) ((this.mMaterial.contains(SubTag.WOOD) ? 12 : 4) + Math.max(0, Math.min(3, this.mMaterial.mToolQuality))); - } + public GregtechMetaPipeEntityFluid( + final String aName, + final float aThickNess, + final GT_Materials aMaterial, + final int aCapacity, + final int aHeatResistance, + final boolean aGasProof) { + this(aName, aThickNess, aMaterial, aCapacity, aHeatResistance, aGasProof, 1); + } - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaPipeEntityFluid(this.mName, this.mThickNess, this.mMaterial, this.mCapacity, this.mHeatResistance, this.mGasProof); - } + public GregtechMetaPipeEntityFluid( + int aID, + String aName, + String aNameRegional, + float aThickNess, + GT_Materials aMaterial, + int aCapacity, + int aHeatResistance, + boolean aGasProof, + int aFluidTypes) { + super(aID, aName, aNameRegional, aThickNess, null, aCapacity, aHeatResistance, aGasProof); + this.mLastReceivedFrom = 0; + this.oLastReceivedFrom = 0; + this.mCheckConnections = !mGt6Pipe; + this.mMaterial = aMaterial; + } - @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aConnections, byte aColorIndex, boolean aConnected, boolean aRedstone) { - float tThickNess = getThickNess(); - if (mDisableInput == 0) - return new ITexture[]{aConnected ? getBaseTexture(tThickNess, mPipeAmount, mMaterial, aColorIndex) : TextureFactory.of(mMaterial.mIconSet.mTextures[OrePrefixes.pipe.mTextureIndex], Dyes.getModulation(aColorIndex, mMaterial.mRGBa))}; - byte tMask = 0; - byte[][] sRestrictionArray = { - {2, 3, 5, 4}, - {2, 3, 4, 5}, - {1, 0, 4, 5}, - {1, 0, 4, 5}, - {1, 0, 2, 3}, - {1, 0, 2, 3} - }; - if (aSide >= 0 && aSide < 6) { - for (byte i = 0; i < 4; i++) if (isInputDisabledAtSide(sRestrictionArray[aSide][i])) tMask |= 1 << i; - //Full block size renderer flips side 5 and 2 textures, flip restrictor textures to compensate - if (aSide == 5 || aSide == 2) - if (tMask > 3 && tMask < 12) - tMask = (byte) (tMask ^ 12); - } - return new ITexture[]{aConnected ? getBaseTexture(tThickNess, mPipeAmount, mMaterial, aColorIndex) : TextureFactory.of(mMaterial.mIconSet.mTextures[OrePrefixes.pipe.mTextureIndex], Dyes.getModulation(aColorIndex, mMaterial.mRGBa)), getRestrictorTexture(tMask)}; - } + public GregtechMetaPipeEntityFluid( + String aName, + float aThickNess, + GT_Materials aMaterial, + int aCapacity, + int aHeatResistance, + boolean aGasProof, + int aFluidTypes) { + super(aName, aThickNess, null, aCapacity, aHeatResistance, aGasProof); + this.mLastReceivedFrom = 0; + this.oLastReceivedFrom = 0; + this.mCheckConnections = !mGt6Pipe; + this.mMaterial = aMaterial; + } - protected static ITexture getBaseTexture(float aThickNess, int aPipeAmount, GT_Materials aMaterial, byte aColorIndex) { - if (aPipeAmount >= 9) - return TextureFactory.of(aMaterial.mIconSet.mTextures[OrePrefixes.pipeNonuple.mTextureIndex], Dyes.getModulation(aColorIndex, aMaterial.mRGBa)); - if (aPipeAmount >= 4) - return TextureFactory.of(aMaterial.mIconSet.mTextures[OrePrefixes.pipeQuadruple.mTextureIndex], Dyes.getModulation(aColorIndex, aMaterial.mRGBa)); - if (aThickNess < 0.124F) - return TextureFactory.of(aMaterial.mIconSet.mTextures[OrePrefixes.pipe.mTextureIndex], Dyes.getModulation(aColorIndex, aMaterial.mRGBa)); - if (aThickNess < 0.374F) - return TextureFactory.of(aMaterial.mIconSet.mTextures[OrePrefixes.pipeTiny.mTextureIndex], Dyes.getModulation(aColorIndex, aMaterial.mRGBa)); - if (aThickNess < 0.499F) - return TextureFactory.of(aMaterial.mIconSet.mTextures[OrePrefixes.pipeSmall.mTextureIndex], Dyes.getModulation(aColorIndex, aMaterial.mRGBa)); - if (aThickNess < 0.749F) - return TextureFactory.of(aMaterial.mIconSet.mTextures[OrePrefixes.pipeMedium.mTextureIndex], Dyes.getModulation(aColorIndex, aMaterial.mRGBa)); - if (aThickNess < 0.874F) - return TextureFactory.of(aMaterial.mIconSet.mTextures[OrePrefixes.pipeLarge.mTextureIndex], Dyes.getModulation(aColorIndex, aMaterial.mRGBa)); - return TextureFactory.of(aMaterial.mIconSet.mTextures[OrePrefixes.pipeHuge.mTextureIndex], Dyes.getModulation(aColorIndex, aMaterial.mRGBa)); - } + @Override + public byte getTileEntityBaseType() { + return this.mMaterial == null + ? 4 + : (byte) ((this.mMaterial.contains(SubTag.WOOD) ? 12 : 4) + + Math.max(0, Math.min(3, this.mMaterial.mToolQuality))); + } - @Override - public String[] getDescription() { - return new String[]{ - EnumChatFormatting.BLUE + "Fluid Capacity: %%%" + (mCapacity * 20) + "%%% L/sec" + EnumChatFormatting.GRAY, - EnumChatFormatting.RED + "Heat Limit: %%%" + mHeatResistance + "%%% K" + EnumChatFormatting.GRAY, - EnumChatFormatting.DARK_GREEN + "Gas Proof: " + (this.mGasProof) + EnumChatFormatting.GRAY, - //CORE.GT_Tooltip - }; - } -}
\ No newline at end of file + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaPipeEntityFluid( + this.mName, this.mThickNess, this.mMaterial, this.mCapacity, this.mHeatResistance, this.mGasProof); + } + + @Override + public ITexture[] getTexture( + IGregTechTileEntity aBaseMetaTileEntity, + byte aSide, + byte aConnections, + byte aColorIndex, + boolean aConnected, + boolean aRedstone) { + float tThickNess = getThickNess(); + if (mDisableInput == 0) + return new ITexture[] { + aConnected + ? getBaseTexture(tThickNess, mPipeAmount, mMaterial, aColorIndex) + : TextureFactory.of( + mMaterial.mIconSet.mTextures[OrePrefixes.pipe.mTextureIndex], + Dyes.getModulation(aColorIndex, mMaterial.mRGBa)) + }; + byte tMask = 0; + byte[][] sRestrictionArray = { + {2, 3, 5, 4}, + {2, 3, 4, 5}, + {1, 0, 4, 5}, + {1, 0, 4, 5}, + {1, 0, 2, 3}, + {1, 0, 2, 3} + }; + if (aSide >= 0 && aSide < 6) { + for (byte i = 0; i < 4; i++) if (isInputDisabledAtSide(sRestrictionArray[aSide][i])) tMask |= 1 << i; + // Full block size renderer flips side 5 and 2 textures, flip restrictor textures to compensate + if (aSide == 5 || aSide == 2) if (tMask > 3 && tMask < 12) tMask = (byte) (tMask ^ 12); + } + return new ITexture[] { + aConnected + ? getBaseTexture(tThickNess, mPipeAmount, mMaterial, aColorIndex) + : TextureFactory.of( + mMaterial.mIconSet.mTextures[OrePrefixes.pipe.mTextureIndex], + Dyes.getModulation(aColorIndex, mMaterial.mRGBa)), + getRestrictorTexture(tMask) + }; + } + + protected static ITexture getBaseTexture( + float aThickNess, int aPipeAmount, GT_Materials aMaterial, byte aColorIndex) { + if (aPipeAmount >= 9) + return TextureFactory.of( + aMaterial.mIconSet.mTextures[OrePrefixes.pipeNonuple.mTextureIndex], + Dyes.getModulation(aColorIndex, aMaterial.mRGBa)); + if (aPipeAmount >= 4) + return TextureFactory.of( + aMaterial.mIconSet.mTextures[OrePrefixes.pipeQuadruple.mTextureIndex], + Dyes.getModulation(aColorIndex, aMaterial.mRGBa)); + if (aThickNess < 0.124F) + return TextureFactory.of( + aMaterial.mIconSet.mTextures[OrePrefixes.pipe.mTextureIndex], + Dyes.getModulation(aColorIndex, aMaterial.mRGBa)); + if (aThickNess < 0.374F) + return TextureFactory.of( + aMaterial.mIconSet.mTextures[OrePrefixes.pipeTiny.mTextureIndex], + Dyes.getModulation(aColorIndex, aMaterial.mRGBa)); + if (aThickNess < 0.499F) + return TextureFactory.of( + aMaterial.mIconSet.mTextures[OrePrefixes.pipeSmall.mTextureIndex], + Dyes.getModulation(aColorIndex, aMaterial.mRGBa)); + if (aThickNess < 0.749F) + return TextureFactory.of( + aMaterial.mIconSet.mTextures[OrePrefixes.pipeMedium.mTextureIndex], + Dyes.getModulation(aColorIndex, aMaterial.mRGBa)); + if (aThickNess < 0.874F) + return TextureFactory.of( + aMaterial.mIconSet.mTextures[OrePrefixes.pipeLarge.mTextureIndex], + Dyes.getModulation(aColorIndex, aMaterial.mRGBa)); + return TextureFactory.of( + aMaterial.mIconSet.mTextures[OrePrefixes.pipeHuge.mTextureIndex], + Dyes.getModulation(aColorIndex, aMaterial.mRGBa)); + } + + @Override + public String[] getDescription() { + return new String[] { + EnumChatFormatting.BLUE + "Fluid Capacity: %%%" + (mCapacity * 20) + "%%% L/sec" + EnumChatFormatting.GRAY, + EnumChatFormatting.RED + "Heat Limit: %%%" + mHeatResistance + "%%% K" + EnumChatFormatting.GRAY, + EnumChatFormatting.DARK_GREEN + "Gas Proof: " + (this.mGasProof) + EnumChatFormatting.GRAY, + // CORE.GT_Tooltip + }; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaPipeEntity_Cable.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaPipeEntity_Cable.java index c2ffcbce46..eff2413102 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaPipeEntity_Cable.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaPipeEntity_Cable.java @@ -1,10 +1,7 @@ package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; -import static gregtech.api.enums.GT_Values.VN; import static gtPlusPlus.core.lib.CORE.GTNH; -import net.minecraft.util.EnumChatFormatting; - import gregtech.api.enums.*; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; @@ -14,142 +11,285 @@ import gregtech.api.metatileentity.implementations.GT_MetaPipeEntity_Cable; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Utility; -import gtPlusPlus.core.lib.CORE; - public class GregtechMetaPipeEntity_Cable extends GT_MetaPipeEntity_Cable implements IMetaTileEntityCable { - private static Textures.BlockIcons INSULATION_MEDIUM_PLUS; - static{ - if(GTNH) { - try { - INSULATION_MEDIUM_PLUS = (Textures.BlockIcons) GT_Utility.getField(Textures.BlockIcons.class, "INSULATION_MEDIUM_PLUS").get(null); - } catch (IllegalAccessException | NullPointerException e) { - throw new Error(e); - } - } - } - - private short[] vRGB = null; - - public GregtechMetaPipeEntity_Cable(final int aID, final String aName, final String aNameRegional, final float aThickNess, final Materials aMaterial, final long aCableLossPerMeter, final long aAmperage, final long aVoltage, final boolean aInsulated, final boolean aCanShock, final short[] aRGB) { - super(aID, aName, aNameRegional, aThickNess, aMaterial, aCableLossPerMeter, aAmperage, aVoltage, aInsulated, aCanShock); - this.vRGB = aRGB==null || aRGB.length!=4?Materials.Iron.mRGBa:aRGB; - } - - public GregtechMetaPipeEntity_Cable(final String aName, final float aThickNess, final Materials aMaterial, final long aCableLossPerMeter, final long aAmperage, final long aVoltage, final boolean aInsulated, final boolean aCanShock, final short[] aRGB) { - super(aName, aThickNess, aMaterial, aCableLossPerMeter, aAmperage, aVoltage, aInsulated, aCanShock); - this.vRGB = aRGB==null || aRGB.length!=4?Materials.Iron.mRGBa:aRGB; - } - - public GregtechMetaPipeEntity_Cable(final int aID, final String aName, final String aNameRegional, final float aThickNess, final long aCableLossPerMeter, final long aAmperage, final long aVoltage, final boolean aInsulated, final boolean aCanShock, final short[] aRGB) { - this(aID, aName, aNameRegional, aThickNess, null, aCableLossPerMeter, aAmperage, aVoltage, aInsulated, aCanShock,aRGB); - } - - public GregtechMetaPipeEntity_Cable(final String aName, final float aThickNess, final long aCableLossPerMeter, final long aAmperage, final long aVoltage, final boolean aInsulated, final boolean aCanShock, final short[] aRGB) { - this(aName, aThickNess, null, aCableLossPerMeter, aAmperage, aVoltage, aInsulated, aCanShock,aRGB); - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaPipeEntity_Cable(this.mName, this.mThickNess, this.mMaterial, this.mCableLossPerMeter, this.mAmperage, this.mVoltage, this.mInsulated, this.mCanShock, this.vRGB); - } - - @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aConnections, byte aColorIndex, boolean aConnected, boolean aRedstone) { - return GTNH? - getTextureGTNH(aBaseMetaTileEntity,aSide,aConnections,aColorIndex,aConnected,aRedstone): - getTexturePure(aBaseMetaTileEntity,aSide,aConnections,aColorIndex,aConnected,aRedstone); - } - - private ITexture[] getTextureGTNH(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aConnections, - byte aColorIndex, boolean aConnected, boolean aRedstone) { - - Materials wireMaterial=mMaterial; - if (wireMaterial == null){ - wireMaterial = Materials.Iron; - } - - if (!mInsulated) - return new ITexture[]{new GT_RenderedTexture(wireMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], Dyes.getModulation(aColorIndex, vRGB) )}; - if (aConnected) { - float tThickNess = getThickNess(); - if (tThickNess < 0.124F) - return new ITexture[]{new GT_RenderedTexture(Textures.BlockIcons.INSULATION_FULL, Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))}; - if (tThickNess < 0.374F)//0.375 x1 - return new ITexture[]{new GT_RenderedTexture(wireMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], vRGB), new GT_RenderedTexture(Textures.BlockIcons.INSULATION_TINY, Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))}; - if (tThickNess < 0.499F)//0.500 x2 - return new ITexture[]{new GT_RenderedTexture(wireMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], vRGB), new GT_RenderedTexture(Textures.BlockIcons.INSULATION_SMALL, Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))}; - if (tThickNess < 0.624F)//0.625 x4 - return new ITexture[]{new GT_RenderedTexture(wireMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], vRGB), new GT_RenderedTexture(Textures.BlockIcons.INSULATION_MEDIUM, Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))}; - if (tThickNess < 0.749F)//0.750 x8 - return new ITexture[]{new GT_RenderedTexture(wireMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], vRGB), new GT_RenderedTexture(INSULATION_MEDIUM_PLUS, Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))}; - if (tThickNess < 0.874F)//0.825 x12 - return new ITexture[]{new GT_RenderedTexture(wireMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], vRGB), new GT_RenderedTexture(Textures.BlockIcons.INSULATION_LARGE, Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))}; - return new ITexture[]{new GT_RenderedTexture(wireMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], vRGB), new GT_RenderedTexture(Textures.BlockIcons.INSULATION_HUGE, Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))}; - } - return new ITexture[]{new GT_RenderedTexture(Textures.BlockIcons.INSULATION_FULL, Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))}; - } - - private ITexture[] getTexturePure(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aConnections, - byte aColorIndex, boolean aConnected, boolean aRedstone) { - - //if (this.vRGB == null || this.vRGB.length < 3 || this.vRGB.length > 4){ - // this.vRGB = new short[]{200, 0, 200, 0}; - //} - //if (this.vRGB.length != 4){ - // short[] tempRGB = this.vRGB; - // this.vRGB = new short[]{tempRGB[0], tempRGB[1], tempRGB[2], 0}; - //} - // - //Materials wireMaterial = this.mMaterial; - // - //if (wireMaterial == null){ - // wireMaterial = Materials.Iron; - //} - - //With the code in constructors it should work - Materials wireMaterial=mMaterial; - if (wireMaterial == null){ - wireMaterial = Materials.Iron; - } - - if (!(this.mInsulated)) - return new ITexture[] { new GT_RenderedTexture(wireMaterial.mIconSet.mTextures[69], - Dyes.getModulation(aColorIndex, this.vRGB)) }; - if (aConnected) { - float tThickNess = getThickNess(); - if (tThickNess < 0.124F) - return new ITexture[] { new GT_RenderedTexture(Textures.BlockIcons.INSULATION_FULL, - Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa)) }; - if (tThickNess < 0.374F) - return new ITexture[] { - new GT_RenderedTexture(wireMaterial.mIconSet.mTextures[69], this.vRGB), - new GT_RenderedTexture(Textures.BlockIcons.INSULATION_TINY, - Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa)) }; - if (tThickNess < 0.499F) - return new ITexture[] { - new GT_RenderedTexture(wireMaterial.mIconSet.mTextures[69], this.vRGB), - new GT_RenderedTexture(Textures.BlockIcons.INSULATION_SMALL, - Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa)) }; - if (tThickNess < 0.624F) - return new ITexture[] { - new GT_RenderedTexture(wireMaterial.mIconSet.mTextures[69], this.vRGB), - new GT_RenderedTexture(Textures.BlockIcons.INSULATION_MEDIUM, - Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa)) }; - if (tThickNess < 0.749F) - return new ITexture[] { - new GT_RenderedTexture(wireMaterial.mIconSet.mTextures[69], this.vRGB), - new GT_RenderedTexture(Textures.BlockIcons.INSULATION_LARGE, - Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa)) }; - if (tThickNess < 0.874F) - return new ITexture[] { - new GT_RenderedTexture(wireMaterial.mIconSet.mTextures[69], this.vRGB), - new GT_RenderedTexture(Textures.BlockIcons.INSULATION_HUGE, - Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa)) }; - return new ITexture[] { new GT_RenderedTexture(wireMaterial.mIconSet.mTextures[69], this.vRGB), - new GT_RenderedTexture(Textures.BlockIcons.INSULATION_FULL, - Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa)) }; - } - return new ITexture[] { new GT_RenderedTexture(Textures.BlockIcons.INSULATION_FULL, - Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa)) }; - } -}
\ No newline at end of file + private static Textures.BlockIcons INSULATION_MEDIUM_PLUS; + + static { + if (GTNH) { + try { + INSULATION_MEDIUM_PLUS = + (Textures.BlockIcons) GT_Utility.getField(Textures.BlockIcons.class, "INSULATION_MEDIUM_PLUS") + .get(null); + } catch (IllegalAccessException | NullPointerException e) { + throw new Error(e); + } + } + } + + private short[] vRGB = null; + + public GregtechMetaPipeEntity_Cable( + final int aID, + final String aName, + final String aNameRegional, + final float aThickNess, + final Materials aMaterial, + final long aCableLossPerMeter, + final long aAmperage, + final long aVoltage, + final boolean aInsulated, + final boolean aCanShock, + final short[] aRGB) { + super( + aID, + aName, + aNameRegional, + aThickNess, + aMaterial, + aCableLossPerMeter, + aAmperage, + aVoltage, + aInsulated, + aCanShock); + this.vRGB = aRGB == null || aRGB.length != 4 ? Materials.Iron.mRGBa : aRGB; + } + + public GregtechMetaPipeEntity_Cable( + final String aName, + final float aThickNess, + final Materials aMaterial, + final long aCableLossPerMeter, + final long aAmperage, + final long aVoltage, + final boolean aInsulated, + final boolean aCanShock, + final short[] aRGB) { + super(aName, aThickNess, aMaterial, aCableLossPerMeter, aAmperage, aVoltage, aInsulated, aCanShock); + this.vRGB = aRGB == null || aRGB.length != 4 ? Materials.Iron.mRGBa : aRGB; + } + + public GregtechMetaPipeEntity_Cable( + final int aID, + final String aName, + final String aNameRegional, + final float aThickNess, + final long aCableLossPerMeter, + final long aAmperage, + final long aVoltage, + final boolean aInsulated, + final boolean aCanShock, + final short[] aRGB) { + this( + aID, + aName, + aNameRegional, + aThickNess, + null, + aCableLossPerMeter, + aAmperage, + aVoltage, + aInsulated, + aCanShock, + aRGB); + } + + public GregtechMetaPipeEntity_Cable( + final String aName, + final float aThickNess, + final long aCableLossPerMeter, + final long aAmperage, + final long aVoltage, + final boolean aInsulated, + final boolean aCanShock, + final short[] aRGB) { + this(aName, aThickNess, null, aCableLossPerMeter, aAmperage, aVoltage, aInsulated, aCanShock, aRGB); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaPipeEntity_Cable( + this.mName, + this.mThickNess, + this.mMaterial, + this.mCableLossPerMeter, + this.mAmperage, + this.mVoltage, + this.mInsulated, + this.mCanShock, + this.vRGB); + } + + @Override + public ITexture[] getTexture( + IGregTechTileEntity aBaseMetaTileEntity, + byte aSide, + byte aConnections, + byte aColorIndex, + boolean aConnected, + boolean aRedstone) { + return GTNH + ? getTextureGTNH(aBaseMetaTileEntity, aSide, aConnections, aColorIndex, aConnected, aRedstone) + : getTexturePure(aBaseMetaTileEntity, aSide, aConnections, aColorIndex, aConnected, aRedstone); + } + + private ITexture[] getTextureGTNH( + IGregTechTileEntity aBaseMetaTileEntity, + byte aSide, + byte aConnections, + byte aColorIndex, + boolean aConnected, + boolean aRedstone) { + + Materials wireMaterial = mMaterial; + if (wireMaterial == null) { + wireMaterial = Materials.Iron; + } + + if (!mInsulated) + return new ITexture[] { + new GT_RenderedTexture( + wireMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], Dyes.getModulation(aColorIndex, vRGB)) + }; + if (aConnected) { + float tThickNess = getThickNess(); + if (tThickNess < 0.124F) + return new ITexture[] { + new GT_RenderedTexture( + Textures.BlockIcons.INSULATION_FULL, + Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa)) + }; + if (tThickNess < 0.374F) // 0.375 x1 + return new ITexture[] { + new GT_RenderedTexture(wireMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], vRGB), + new GT_RenderedTexture( + Textures.BlockIcons.INSULATION_TINY, + Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa)) + }; + if (tThickNess < 0.499F) // 0.500 x2 + return new ITexture[] { + new GT_RenderedTexture(wireMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], vRGB), + new GT_RenderedTexture( + Textures.BlockIcons.INSULATION_SMALL, + Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa)) + }; + if (tThickNess < 0.624F) // 0.625 x4 + return new ITexture[] { + new GT_RenderedTexture(wireMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], vRGB), + new GT_RenderedTexture( + Textures.BlockIcons.INSULATION_MEDIUM, + Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa)) + }; + if (tThickNess < 0.749F) // 0.750 x8 + return new ITexture[] { + new GT_RenderedTexture(wireMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], vRGB), + new GT_RenderedTexture( + INSULATION_MEDIUM_PLUS, Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa)) + }; + if (tThickNess < 0.874F) // 0.825 x12 + return new ITexture[] { + new GT_RenderedTexture(wireMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], vRGB), + new GT_RenderedTexture( + Textures.BlockIcons.INSULATION_LARGE, + Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa)) + }; + return new ITexture[] { + new GT_RenderedTexture(wireMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], vRGB), + new GT_RenderedTexture( + Textures.BlockIcons.INSULATION_HUGE, + Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa)) + }; + } + return new ITexture[] { + new GT_RenderedTexture( + Textures.BlockIcons.INSULATION_FULL, Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa)) + }; + } + + private ITexture[] getTexturePure( + IGregTechTileEntity aBaseMetaTileEntity, + byte aSide, + byte aConnections, + byte aColorIndex, + boolean aConnected, + boolean aRedstone) { + + // if (this.vRGB == null || this.vRGB.length < 3 || this.vRGB.length > 4){ + // this.vRGB = new short[]{200, 0, 200, 0}; + // } + // if (this.vRGB.length != 4){ + // short[] tempRGB = this.vRGB; + // this.vRGB = new short[]{tempRGB[0], tempRGB[1], tempRGB[2], 0}; + // } + // + // Materials wireMaterial = this.mMaterial; + // + // if (wireMaterial == null){ + // wireMaterial = Materials.Iron; + // } + + // With the code in constructors it should work + Materials wireMaterial = mMaterial; + if (wireMaterial == null) { + wireMaterial = Materials.Iron; + } + + if (!(this.mInsulated)) + return new ITexture[] { + new GT_RenderedTexture(wireMaterial.mIconSet.mTextures[69], Dyes.getModulation(aColorIndex, this.vRGB)) + }; + if (aConnected) { + float tThickNess = getThickNess(); + if (tThickNess < 0.124F) + return new ITexture[] { + new GT_RenderedTexture( + Textures.BlockIcons.INSULATION_FULL, + Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa)) + }; + if (tThickNess < 0.374F) + return new ITexture[] { + new GT_RenderedTexture(wireMaterial.mIconSet.mTextures[69], this.vRGB), + new GT_RenderedTexture( + Textures.BlockIcons.INSULATION_TINY, + Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa)) + }; + if (tThickNess < 0.499F) + return new ITexture[] { + new GT_RenderedTexture(wireMaterial.mIconSet.mTextures[69], this.vRGB), + new GT_RenderedTexture( + Textures.BlockIcons.INSULATION_SMALL, + Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa)) + }; + if (tThickNess < 0.624F) + return new ITexture[] { + new GT_RenderedTexture(wireMaterial.mIconSet.mTextures[69], this.vRGB), + new GT_RenderedTexture( + Textures.BlockIcons.INSULATION_MEDIUM, + Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa)) + }; + if (tThickNess < 0.749F) + return new ITexture[] { + new GT_RenderedTexture(wireMaterial.mIconSet.mTextures[69], this.vRGB), + new GT_RenderedTexture( + Textures.BlockIcons.INSULATION_LARGE, + Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa)) + }; + if (tThickNess < 0.874F) + return new ITexture[] { + new GT_RenderedTexture(wireMaterial.mIconSet.mTextures[69], this.vRGB), + new GT_RenderedTexture( + Textures.BlockIcons.INSULATION_HUGE, + Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa)) + }; + return new ITexture[] { + new GT_RenderedTexture(wireMaterial.mIconSet.mTextures[69], this.vRGB), + new GT_RenderedTexture( + Textures.BlockIcons.INSULATION_FULL, + Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa)) + }; + } + return new ITexture[] { + new GT_RenderedTexture( + Textures.BlockIcons.INSULATION_FULL, Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa)) + }; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaTreeFarmerStructural.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaTreeFarmerStructural.java index d05a254bf7..14399e525d 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaTreeFarmerStructural.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaTreeFarmerStructural.java @@ -1,56 +1,63 @@ package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; -import net.minecraft.nbt.NBTTagCompound; - 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 gtPlusPlus.core.lib.CORE; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.machines.GregtechMetaTreeFarmerBase; +import net.minecraft.nbt.NBTTagCompound; -public class GregtechMetaTreeFarmerStructural -extends GregtechMetaTreeFarmerBase { - - @Override - public String[] getDescription() { - return new String[] {this.mDescription}; - } - - public GregtechMetaTreeFarmerStructural(final int aID, final String aName, final String aNameRegional, final int aTier) { - super(aID, aName, aNameRegional, aTier, 0, "Structural Blocks for the Tree Farmer."); - } - - public GregtechMetaTreeFarmerStructural(final int aID, final String aName, final String aNameRegional, final int aTier, final int aInvSlotCount, final String aDescription) { - super(aID, aName, aNameRegional, aTier, aInvSlotCount, aDescription); - } - - public GregtechMetaTreeFarmerStructural(final String aName, final int aTier, final int aInvSlotCount, final String aDescription, final ITexture[][][] aTextures) { - super(aName, aTier, aInvSlotCount, aDescription, aTextures); - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTreeFarmerStructural(this.mName, this.mTier, this.mInventory.length, this.mDescription, this.mTextures); - } - - @Override - public ITexture getOverlayIcon() { - return new GT_RenderedTexture(Textures.BlockIcons.VOID); - } - - @Override - public boolean isValidSlot(final int aIndex) { - return false; - } - - @Override - public void saveNBTData(final NBTTagCompound paramNBTTagCompound) { - } - - @Override - public void loadNBTData(final NBTTagCompound paramNBTTagCompound) { - } +public class GregtechMetaTreeFarmerStructural extends GregtechMetaTreeFarmerBase { + + @Override + public String[] getDescription() { + return new String[] {this.mDescription}; + } + + public GregtechMetaTreeFarmerStructural( + final int aID, final String aName, final String aNameRegional, final int aTier) { + super(aID, aName, aNameRegional, aTier, 0, "Structural Blocks for the Tree Farmer."); + } + + public GregtechMetaTreeFarmerStructural( + final int aID, + final String aName, + final String aNameRegional, + final int aTier, + final int aInvSlotCount, + final String aDescription) { + super(aID, aName, aNameRegional, aTier, aInvSlotCount, aDescription); + } + + public GregtechMetaTreeFarmerStructural( + final String aName, + final int aTier, + final int aInvSlotCount, + final String aDescription, + final ITexture[][][] aTextures) { + super(aName, aTier, aInvSlotCount, aDescription, aTextures); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTreeFarmerStructural( + this.mName, this.mTier, this.mInventory.length, this.mDescription, this.mTextures); + } + + @Override + public ITexture getOverlayIcon() { + return new GT_RenderedTexture(Textures.BlockIcons.VOID); + } + + @Override + public boolean isValidSlot(final int aIndex) { + return false; + } + + @Override + public void saveNBTData(final NBTTagCompound paramNBTTagCompound) {} + + @Override + public void loadNBTData(final NBTTagCompound paramNBTTagCompound) {} } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/CustomMetaTileBase.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/CustomMetaTileBase.java index fdc8a7777b..cd4d0c0edd 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/CustomMetaTileBase.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/CustomMetaTileBase.java @@ -1,67 +1,70 @@ package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base; -import java.util.Locale; - import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.util.GT_LanguageManager; import gtPlusPlus.xmod.gregtech.api.interfaces.IBaseCustomMetaTileEntity; import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy; +import java.util.Locale; import net.minecraft.item.ItemStack; public abstract class CustomMetaTileBase extends MetaTileEntity { + private IBaseCustomMetaTileEntity mBaseCustomMetaTileEntity2; - private IBaseCustomMetaTileEntity mBaseCustomMetaTileEntity2; - /** * accessibility to this Field is no longer given, see below */ private IGregTechTileEntity mBaseCustomMetaTileEntity; - - public CustomMetaTileBase(int aID, String aBasicName, String aRegionalName, int aInvSlotCount) { - super(aID, aBasicName, aRegionalName, aInvSlotCount); - GT_LanguageManager.addStringLocalization("gtpp.blockmachines." + aBasicName.replaceAll(" ", "_").toLowerCase(Locale.ENGLISH) + ".name", aRegionalName); - this.setBaseMetaTileEntity(Meta_GT_Proxy.constructBaseMetaTileEntity()); - this.getBaseMetaTileEntity().setMetaTileID((short) aID); - mBaseCustomMetaTileEntity2 = (IBaseCustomMetaTileEntity) getBaseMetaTileEntity(); - } - + + public CustomMetaTileBase(int aID, String aBasicName, String aRegionalName, int aInvSlotCount) { + super(aID, aBasicName, aRegionalName, aInvSlotCount); + GT_LanguageManager.addStringLocalization( + "gtpp.blockmachines." + aBasicName.replaceAll(" ", "_").toLowerCase(Locale.ENGLISH) + ".name", + aRegionalName); + this.setBaseMetaTileEntity(Meta_GT_Proxy.constructBaseMetaTileEntity()); + this.getBaseMetaTileEntity().setMetaTileID((short) aID); + mBaseCustomMetaTileEntity2 = (IBaseCustomMetaTileEntity) getBaseMetaTileEntity(); + } + @Override public IGregTechTileEntity getBaseMetaTileEntity() { return mBaseCustomMetaTileEntity; } - + public IBaseCustomMetaTileEntity getBaseCustomMetaTileEntity() { return mBaseCustomMetaTileEntity2; } @Override public void setBaseMetaTileEntity(IGregTechTileEntity aBaseMetaTileEntity) { - super.setBaseMetaTileEntity(aBaseMetaTileEntity); + super.setBaseMetaTileEntity(aBaseMetaTileEntity); if (mBaseCustomMetaTileEntity != null && aBaseMetaTileEntity == null) { - mBaseCustomMetaTileEntity.getMetaTileEntity().inValidate(); - mBaseCustomMetaTileEntity.setMetaTileEntity(null); + mBaseCustomMetaTileEntity.getMetaTileEntity().inValidate(); + mBaseCustomMetaTileEntity.setMetaTileEntity(null); } mBaseCustomMetaTileEntity = aBaseMetaTileEntity; if (mBaseCustomMetaTileEntity != null) { - mBaseCustomMetaTileEntity.setMetaTileEntity(this); + mBaseCustomMetaTileEntity.setMetaTileEntity(this); } } - public CustomMetaTileBase(String aName, int aInvSlotCount) { - super(aName, aInvSlotCount); - } + public CustomMetaTileBase(String aName, int aInvSlotCount) { + super(aName, aInvSlotCount); + } + + public ItemStack getStackForm(long aAmount) { + return new ItemStack( + Meta_GT_Proxy.sBlockMachines, + (int) aAmount, + this.getBaseMetaTileEntity().getMetaTileID()); + } - public ItemStack getStackForm(long aAmount) { - return new ItemStack(Meta_GT_Proxy.sBlockMachines, (int) aAmount, this.getBaseMetaTileEntity().getMetaTileID()); - } + public String getLocalName() { + return GT_LanguageManager.getTranslation("gtpp.blockmachines." + this.mName + ".name"); + } - public String getLocalName() { - return GT_LanguageManager.getTranslation("gtpp.blockmachines." + this.mName + ".name"); - } - - /** + /** * This determines the BaseMetaTileEntity belonging to this MetaTileEntity by using the Meta ID of the Block itself. * <p/> * 0 = BaseMetaTileEntity, Wrench lvl 0 to dismantlee @@ -76,17 +79,16 @@ public abstract class CustomMetaTileBase extends MetaTileEntity { * 9 = BaseMetaPipeEntity, Cutter lvl 1 to dismantle * 10 = BaseMetaPipeEntity, Cutter lvl 2 to dismantle * 11 = BaseMetaPipeEntity, Cutter lvl 3 to dismantle - * + * * == Reserved for Alk now - * + * * 12 = BaseMetaPipeEntity, Wrench lvl 0 to dismantle * 13 = BaseMetaPipeEntity, Wrench lvl 1 to dismantle * 14 = BaseMetaPipeEntity, Wrench lvl 2 to dismantle * 15 = BaseMetaPipeEntity, Wrench lvl 3 to dismantle */ - @Override + @Override public byte getTileEntityBaseType() { - return 12; - } - -}
\ No newline at end of file + return 12; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GT_MetaTileEntity_Hatch_CustomFluidBase.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GT_MetaTileEntity_Hatch_CustomFluidBase.java index ba9e618539..f00901c45b 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GT_MetaTileEntity_Hatch_CustomFluidBase.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GT_MetaTileEntity_Hatch_CustomFluidBase.java @@ -1,5 +1,8 @@ package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base; +import static gregtech.api.enums.Textures.BlockIcons.FLUID_IN_SIGN; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_PIPE_IN; + import gregtech.GT_Mod; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -15,185 +18,182 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; - -import static gregtech.api.enums.Textures.BlockIcons.FLUID_IN_SIGN; -import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_PIPE_IN; - public class GT_MetaTileEntity_Hatch_CustomFluidBase extends GT_MetaTileEntity_Hatch { - public final Fluid mLockedFluid; - public final int mFluidCapacity; - protected FluidStack mLockedStack = null; - protected String mTempMod = null; - - public GT_MetaTileEntity_Hatch_CustomFluidBase(Fluid aFluid, int aAmount, final int aID, final String aName, final String aNameRegional) { - super(aID, aName, aNameRegional, 6, 3, new String[]{ - "Fluid Input for Multiblocks", - "Capacity: " + GT_Utility.formatNumbers(aAmount) + "L"}); - this.mLockedFluid = aFluid; - this.mFluidCapacity = aAmount; - } - - public GT_MetaTileEntity_Hatch_CustomFluidBase(Fluid aFluid, int aAmount, final String aName, final String aDescription, - final ITexture[][][] aTextures) { - super(aName, 6, 3, aDescription, aTextures); - this.mLockedFluid = aFluid; - this.mFluidCapacity = aAmount; - } - - public GT_MetaTileEntity_Hatch_CustomFluidBase(Fluid aFluid, int aAmount, final String aName, final String[] aDescription, final ITexture[][][] aTextures) { - super(aName, 6, 3, aDescription[0], aTextures); - this.mLockedFluid = aFluid; - this.mFluidCapacity = aAmount; - } - - public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, - final ItemStack aStack) { - if (aSide == aBaseMetaTileEntity.getFrontFacing() && aIndex == 0) { + public final Fluid mLockedFluid; + public final int mFluidCapacity; + protected FluidStack mLockedStack = null; + protected String mTempMod = null; + + public GT_MetaTileEntity_Hatch_CustomFluidBase( + Fluid aFluid, int aAmount, final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional, 6, 3, new String[] { + "Fluid Input for Multiblocks", "Capacity: " + GT_Utility.formatNumbers(aAmount) + "L" + }); + this.mLockedFluid = aFluid; + this.mFluidCapacity = aAmount; + } + + public GT_MetaTileEntity_Hatch_CustomFluidBase( + Fluid aFluid, int aAmount, final String aName, final String aDescription, final ITexture[][][] aTextures) { + super(aName, 6, 3, aDescription, aTextures); + this.mLockedFluid = aFluid; + this.mFluidCapacity = aAmount; + } + + public GT_MetaTileEntity_Hatch_CustomFluidBase( + Fluid aFluid, + int aAmount, + final String aName, + final String[] aDescription, + final ITexture[][][] aTextures) { + super(aName, 6, 3, aDescription[0], aTextures); + this.mLockedFluid = aFluid; + this.mFluidCapacity = aAmount; + } + + public boolean allowPutStack( + final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + if (aSide == aBaseMetaTileEntity.getFrontFacing() && aIndex == 0) { FluidStack fs = GT_Utility.getFluidForFilledItem(aStack, true); - return fs != null && fs.getFluid() == this.mLockedFluid; + return fs != null && fs.getFluid() == this.mLockedFluid; } return false; - } - - @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return aSide == aBaseMetaTileEntity.getFrontFacing() && aIndex == 1; - } - - @Override - public ITexture[] getTexturesActive(ITexture aBaseTexture) { - return GT_Mod.gregtechproxy.mRenderIndicatorsOnHatch ? - new ITexture[]{aBaseTexture, TextureFactory.of(OVERLAY_PIPE_IN), TextureFactory.of(FLUID_IN_SIGN)} : - new ITexture[]{aBaseTexture, TextureFactory.of(OVERLAY_PIPE_IN)}; - } - - @Override - public ITexture[] getTexturesInactive(ITexture aBaseTexture) { - return GT_Mod.gregtechproxy.mRenderIndicatorsOnHatch ? - new ITexture[]{aBaseTexture, TextureFactory.of(OVERLAY_PIPE_IN), TextureFactory.of(FLUID_IN_SIGN)} : - new ITexture[]{aBaseTexture, TextureFactory.of(OVERLAY_PIPE_IN)}; - } - - @Override - public boolean isSimpleMachine() { - return true; - } - - @Override - public boolean isFacingValid(byte aFacing) { - return true; - } - - @Override - public boolean isAccessAllowed(EntityPlayer aPlayer) { - return true; - } - - @Override - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) return true; - aBaseMetaTileEntity.openGUI(aPlayer); - return true; - } - - @Override - public boolean doesFillContainers() { - //return true; - return false; - } - - @Override - public boolean doesEmptyContainers() { - return true; - } - - @Override - public boolean canTankBeFilled() { - return true; - } - - @Override - public boolean canTankBeEmptied() { - return true; - } - - @Override - public boolean displaysItemStack() { - return true; - } - - @Override - public boolean displaysStackSize() { - return false; - } - - public void updateSlots() { - if (mInventory[getInputSlot()] != null && mInventory[getInputSlot()].stackSize <= 0) - mInventory[getInputSlot()] = null; - } - - @Override - public int getTankPressure() { - return -100; - } - - public int getCapacity() { - return this.mFluidCapacity; - } - - @Override - public String[] getDescription() { - if (mLockedStack == null) { - mLockedStack = FluidUtils.getFluidStack(mLockedFluid, 1); - } - int aFluidTemp = 0; - boolean isSteam = false; - if (mLockedFluid != null) { - aFluidTemp = mLockedFluid.getTemperature(); - mTempMod = mLockedFluid.getName(); - } - if (mTempMod.equalsIgnoreCase("steam")) { - isSteam = true; - } - - - EnumChatFormatting aColour = EnumChatFormatting.BLUE; - if (aFluidTemp <= -3000) { - aColour = EnumChatFormatting.DARK_PURPLE; - } - else if (aFluidTemp >= -2999 && aFluidTemp <= -500) { - aColour = EnumChatFormatting.DARK_BLUE; - } - else if (aFluidTemp >= -499 && aFluidTemp <= -50) { - aColour = EnumChatFormatting.BLUE; - } - else if (aFluidTemp >= 30 && aFluidTemp <= 300) { - aColour = EnumChatFormatting.AQUA; - } - else if (aFluidTemp >= 301 && aFluidTemp <= 800) { - aColour = EnumChatFormatting.YELLOW; - } - else if (aFluidTemp >= 801 && aFluidTemp <= 1500) { - aColour = EnumChatFormatting.GOLD; - } - else if (aFluidTemp >= 1501) { - aColour = EnumChatFormatting.RED; - } - String aFluidName = "Accepted Fluid: " + aColour + (mLockedStack != null ? mLockedStack.getLocalizedName() : "Empty") + EnumChatFormatting.RESET; - return new String[]{ - "Fluid Input for "+(isSteam ? "Steam " : "")+"Multiblocks", - "Capacity: " + getCapacity()+"L", - aFluidName, - CORE.GT_Tooltip - }; - } - - public boolean isFluidInputAllowed(final FluidStack aFluid) { - return aFluid.getFluid() == this.mLockedFluid; - } - - public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_Hatch_CustomFluidBase(this.mLockedFluid, this.mFluidCapacity, this.mName, this.mDescription, this.mTextures); - } -}
\ No newline at end of file + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return aSide == aBaseMetaTileEntity.getFrontFacing() && aIndex == 1; + } + + @Override + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + return GT_Mod.gregtechproxy.mRenderIndicatorsOnHatch + ? new ITexture[] {aBaseTexture, TextureFactory.of(OVERLAY_PIPE_IN), TextureFactory.of(FLUID_IN_SIGN)} + : new ITexture[] {aBaseTexture, TextureFactory.of(OVERLAY_PIPE_IN)}; + } + + @Override + public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + return GT_Mod.gregtechproxy.mRenderIndicatorsOnHatch + ? new ITexture[] {aBaseTexture, TextureFactory.of(OVERLAY_PIPE_IN), TextureFactory.of(FLUID_IN_SIGN)} + : new ITexture[] {aBaseTexture, TextureFactory.of(OVERLAY_PIPE_IN)}; + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return true; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) return true; + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + + @Override + public boolean doesFillContainers() { + // return true; + return false; + } + + @Override + public boolean doesEmptyContainers() { + return true; + } + + @Override + public boolean canTankBeFilled() { + return true; + } + + @Override + public boolean canTankBeEmptied() { + return true; + } + + @Override + public boolean displaysItemStack() { + return true; + } + + @Override + public boolean displaysStackSize() { + return false; + } + + public void updateSlots() { + if (mInventory[getInputSlot()] != null && mInventory[getInputSlot()].stackSize <= 0) + mInventory[getInputSlot()] = null; + } + + @Override + public int getTankPressure() { + return -100; + } + + public int getCapacity() { + return this.mFluidCapacity; + } + + @Override + public String[] getDescription() { + if (mLockedStack == null) { + mLockedStack = FluidUtils.getFluidStack(mLockedFluid, 1); + } + int aFluidTemp = 0; + boolean isSteam = false; + if (mLockedFluid != null) { + aFluidTemp = mLockedFluid.getTemperature(); + mTempMod = mLockedFluid.getName(); + } + if (mTempMod.equalsIgnoreCase("steam")) { + isSteam = true; + } + + EnumChatFormatting aColour = EnumChatFormatting.BLUE; + if (aFluidTemp <= -3000) { + aColour = EnumChatFormatting.DARK_PURPLE; + } else if (aFluidTemp >= -2999 && aFluidTemp <= -500) { + aColour = EnumChatFormatting.DARK_BLUE; + } else if (aFluidTemp >= -499 && aFluidTemp <= -50) { + aColour = EnumChatFormatting.BLUE; + } else if (aFluidTemp >= 30 && aFluidTemp <= 300) { + aColour = EnumChatFormatting.AQUA; + } else if (aFluidTemp >= 301 && aFluidTemp <= 800) { + aColour = EnumChatFormatting.YELLOW; + } else if (aFluidTemp >= 801 && aFluidTemp <= 1500) { + aColour = EnumChatFormatting.GOLD; + } else if (aFluidTemp >= 1501) { + aColour = EnumChatFormatting.RED; + } + String aFluidName = "Accepted Fluid: " + aColour + + (mLockedStack != null ? mLockedStack.getLocalizedName() : "Empty") + EnumChatFormatting.RESET; + return new String[] { + "Fluid Input for " + (isSteam ? "Steam " : "") + "Multiblocks", + "Capacity: " + getCapacity() + "L", + aFluidName, + CORE.GT_Tooltip + }; + } + + public boolean isFluidInputAllowed(final FluidStack aFluid) { + return aFluid.getFluid() == this.mLockedFluid; + } + + public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_Hatch_CustomFluidBase( + this.mLockedFluid, this.mFluidCapacity, this.mName, this.mDescription, this.mTextures); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMetaPipeEntityBase_Cable.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMetaPipeEntityBase_Cable.java index 4dd5bf25d6..efc2d008bb 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMetaPipeEntityBase_Cable.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMetaPipeEntityBase_Cable.java @@ -2,21 +2,7 @@ package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base; import static gregtech.api.enums.GT_Values.VN; -import java.lang.reflect.Field; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; - import cofh.api.energy.IEnergyReceiver; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.world.World; - import gregtech.GT_Mod; import gregtech.api.GregTech_API; import gregtech.api.enums.Dyes; @@ -33,436 +19,534 @@ import gregtech.api.metatileentity.MetaPipeEntity; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Utility; import gregtech.common.GT_Proxy; - import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes.GT_Materials; import ic2.api.energy.tile.IEnergySink; +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; public class GregtechMetaPipeEntityBase_Cable extends MetaPipeEntity implements IMetaTileEntityCable { - public final float mThickNess; - public final GT_Materials mMaterial; - public final long mCableLossPerMeter, mAmperage, mVoltage; - public final boolean mInsulated, mCanShock; - public long mTransferredAmperage = 0, mTransferredAmperageLast20 = 0, mTransferredVoltageLast20 = 0; - public long mRestRF; - public short mOverheat; - public final int mWireHeatingTicks; - - public GregtechMetaPipeEntityBase_Cable(final int aID, final String aName, final String aNameRegional, - final float aThickNess, final GT_Materials aMaterial, final long aCableLossPerMeter, final long aAmperage, - final long aVoltage, final boolean aInsulated, final boolean aCanShock) { - super(aID, aName, aNameRegional, 0); - this.mThickNess = aThickNess; - this.mMaterial = aMaterial; - this.mAmperage = aAmperage; - this.mVoltage = aVoltage; - this.mInsulated = aInsulated; - this.mCanShock = aCanShock; - this.mCableLossPerMeter = aCableLossPerMeter; - this.mWireHeatingTicks = this.getGT5Var(); - } - - public GregtechMetaPipeEntityBase_Cable(final String aName, final float aThickNess, final GT_Materials aMaterial, - final long aCableLossPerMeter, final long aAmperage, final long aVoltage, final boolean aInsulated, - final boolean aCanShock) { - super(aName, 0); - this.mThickNess = aThickNess; - this.mMaterial = aMaterial; - this.mAmperage = aAmperage; - this.mVoltage = aVoltage; - this.mInsulated = aInsulated; - this.mCanShock = aCanShock; - this.mCableLossPerMeter = aCableLossPerMeter; - this.mWireHeatingTicks = this.getGT5Var(); - } - - private int getGT5Var() { - final Class<? extends GT_Proxy> clazz = GT_Mod.gregtechproxy.getClass(); - final String lookingForValue = "mWireHeatingTicks"; - int temp = 4; - Field field; - if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { - try { - field = clazz.getClass().getField(lookingForValue); - final Class<?> clazzType = field.getType(); - if (clazzType.toString().equals("int")) { - temp = (field.getInt(clazz)); - } else { - temp = 4; - } - } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) { - // Utils.LOG_INFO("FATAL ERROR - REFLECTION FAILED FOR GT CABLES - // - PLEASE REPORT THIS."); - Logger.WARNING("FATAL ERROR - REFLECTION FAILED FOR GT CABLES - PLEASE REPORT THIS."); - Logger.ERROR("FATAL ERROR - REFLECTION FAILED FOR GT CABLES - PLEASE REPORT THIS."); - temp = 4; - } - } - return temp; - } - - @Override - public byte getTileEntityBaseType() { - return (byte) (this.mInsulated ? 9 : 8); - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaPipeEntityBase_Cable(this.mName, this.mThickNess, this.mMaterial, - this.mCableLossPerMeter, this.mAmperage, this.mVoltage, this.mInsulated, this.mCanShock); - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, - final byte aConnections, final byte aColorIndex, final boolean aConnected, final boolean aRedstone) { - if (!this.mInsulated) { - return new ITexture[] { new GT_RenderedTexture(this.mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], - this.mMaterial.mRGBa) }; - } - if (aConnected) { - final float tThickNess = this.getThickNess(); - if (tThickNess < 0.37F) { - return new ITexture[] { - new GT_RenderedTexture(this.mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], - this.mMaterial.mRGBa), - new GT_RenderedTexture(Textures.BlockIcons.INSULATION_TINY, - Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa)) }; - } - if (tThickNess < 0.49F) { - return new ITexture[] { - new GT_RenderedTexture(this.mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], - this.mMaterial.mRGBa), - new GT_RenderedTexture(Textures.BlockIcons.INSULATION_SMALL, - Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa)) }; - } - if (tThickNess < 0.74F) { - return new ITexture[] { - new GT_RenderedTexture(this.mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], - this.mMaterial.mRGBa), - new GT_RenderedTexture(Textures.BlockIcons.INSULATION_MEDIUM, - Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa)) }; - } - if (tThickNess < 0.99F) { - return new ITexture[] { - new GT_RenderedTexture(this.mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], - this.mMaterial.mRGBa), - new GT_RenderedTexture(Textures.BlockIcons.INSULATION_LARGE, - Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa)) }; - } - return new ITexture[] { - new GT_RenderedTexture(this.mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], - this.mMaterial.mRGBa), - new GT_RenderedTexture(Textures.BlockIcons.INSULATION_HUGE, - Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa)) }; - } - return new ITexture[] { new GT_RenderedTexture(Textures.BlockIcons.INSULATION_FULL, - Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa)) }; - } - - @Override - public void onEntityCollidedWithBlock(final World aWorld, final int aX, final int aY, final int aZ, - final Entity aEntity) { - if (this.mCanShock && ((((BaseMetaPipeEntity) this.getBaseMetaTileEntity()).mConnections & -128) == 0) - && (aEntity instanceof EntityLivingBase)) { - GT_Utility.applyElectricityDamage((EntityLivingBase) aEntity, this.mTransferredVoltageLast20, - this.mTransferredAmperageLast20); - } - } - - @Override - public AxisAlignedBB getCollisionBoundingBoxFromPool(final World aWorld, final int aX, final int aY, final int aZ) { - if (!this.mCanShock) { - return super.getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ); - } - return AxisAlignedBB.getBoundingBox(aX + 0.125D, aY + 0.125D, aZ + 0.125D, aX + 0.875D, aY + 0.875D, - aZ + 0.875D); - } - - @Override - public boolean isSimpleMachine() { - return true; - } - - @Override - public boolean isFacingValid(final byte aFacing) { - return false; - } - - @Override - public boolean isValidSlot(final int aIndex) { - return true; - } - - @Override - public final boolean renderInside(final byte aSide) { - return false; - } - - @Override - public int getProgresstime() { - return (int) this.mTransferredAmperage * 64; - } - - @Override - public int maxProgresstime() { - return (int) this.mAmperage * 64; - } - - @Override - public long injectEnergyUnits(final byte aSide, final long aVoltage, final long aAmperage) { - if (!this.getBaseMetaTileEntity().getCoverBehaviorAtSide(aSide).letsEnergyIn(aSide, - this.getBaseMetaTileEntity().getCoverIDAtSide(aSide), - this.getBaseMetaTileEntity().getCoverDataAtSide(aSide), this.getBaseMetaTileEntity())) { - return 0; - } - return this.transferElectricity(aSide, aVoltage, aAmperage, - new ArrayList<>(Arrays.asList((TileEntity) this.getBaseMetaTileEntity()))); - } - - - /** - * Adds support for the newer function added by https://github.com/Blood-Asp/GT5-Unofficial/commit/73ee102b63efd92c0f164a7ed7a79ebcd2619617#diff-3051838621d8ae87aa5ccd1345e1f07d - */ - public long transferElectricity(byte arg0, long arg1, long arg2, HashSet<TileEntity> arg3) { - ArrayList<TileEntity> aTiles = new ArrayList<TileEntity>(); - for (TileEntity y : arg3) { - aTiles.add(y); - } - return transferElectricity(arg0, arg1, arg2, aTiles); - } - - @Override - public long transferElectricity(final byte aSide, long aVoltage, final long aAmperage, - final ArrayList<TileEntity> aAlreadyPassedTileEntityList) { - long rUsedAmperes = 0; - aVoltage -= this.mCableLossPerMeter; - if (aVoltage > 0) { - for (byte i = 0; (i < 6) && (aAmperage > rUsedAmperes); i++) { - if ((i != aSide) && ((this.mConnections & (1 << i)) != 0) - && this.getBaseMetaTileEntity().getCoverBehaviorAtSide(i).letsEnergyOut(i, - this.getBaseMetaTileEntity().getCoverIDAtSide(i), - this.getBaseMetaTileEntity().getCoverDataAtSide(i), this.getBaseMetaTileEntity())) { - final TileEntity tTileEntity = this.getBaseMetaTileEntity().getTileEntityAtSide(i); - if (!aAlreadyPassedTileEntityList.contains(tTileEntity)) { - aAlreadyPassedTileEntityList.add(tTileEntity); - if (tTileEntity instanceof IEnergyConnected) { - if (this.getBaseMetaTileEntity().getColorization() >= 0) { - final byte tColor = ((IEnergyConnected) tTileEntity).getColorization(); - if ((tColor >= 0) && (tColor != this.getBaseMetaTileEntity().getColorization())) { - continue; - } - } - if ((tTileEntity instanceof IGregTechTileEntity) - && (((IGregTechTileEntity) tTileEntity) - .getMetaTileEntity() instanceof IMetaTileEntityCable) - && ((IGregTechTileEntity) tTileEntity) - .getCoverBehaviorAtSide(GT_Utility.getOppositeSide(i)) - .letsEnergyIn(GT_Utility.getOppositeSide(i), - ((IGregTechTileEntity) tTileEntity) - .getCoverIDAtSide(GT_Utility.getOppositeSide(i)), - ((IGregTechTileEntity) tTileEntity) - .getCoverDataAtSide(GT_Utility.getOppositeSide(i)), - ((IGregTechTileEntity) tTileEntity))) { - if (((IGregTechTileEntity) tTileEntity).getTimer() > 50) { - rUsedAmperes += ((IMetaTileEntityCable) ((IGregTechTileEntity) tTileEntity) - .getMetaTileEntity()).transferElectricity(GT_Utility.getOppositeSide(i), - aVoltage, aAmperage - rUsedAmperes, aAlreadyPassedTileEntityList); - } - } else { - rUsedAmperes += ((IEnergyConnected) tTileEntity).injectEnergyUnits( - GT_Utility.getOppositeSide(i), aVoltage, aAmperage - rUsedAmperes); - } - // } else if (tTileEntity instanceof IEnergySink) { - // ForgeDirection tDirection = - // ForgeDirection.getOrientation(i).getOpposite(); - // if - // (((IEnergySink)tTileEntity).acceptsEnergyFrom((TileEntity)getBaseMetaTileEntity(), - // tDirection)) { - // if - // (((IEnergySink)tTileEntity).demandedEnergyUnits() - // > 0 && - // ((IEnergySink)tTileEntity).injectEnergyUnits(tDirection, - // aVoltage) < aVoltage) rUsedAmperes++; - // } - } else if (tTileEntity instanceof IEnergySink) { - final ForgeDirection tDirection = ForgeDirection.getOrientation(i).getOpposite(); - if (((IEnergySink) tTileEntity).acceptsEnergyFrom((TileEntity) this.getBaseMetaTileEntity(), - tDirection)) { - if ((((IEnergySink) tTileEntity).getDemandedEnergy() > 0) - && (((IEnergySink) tTileEntity).injectEnergy(tDirection, aVoltage, - aVoltage) < aVoltage)) { - rUsedAmperes++; - } - } - } else if (GregTech_API.mOutputRF && (tTileEntity instanceof IEnergyReceiver)) { - final ForgeDirection tDirection = ForgeDirection.getOrientation(i).getOpposite(); - final int rfOut = (int) ((aVoltage * GregTech_API.mEUtoRF) / 100); - if (((IEnergyReceiver) tTileEntity).receiveEnergy(tDirection, rfOut, true) == rfOut) { - ((IEnergyReceiver) tTileEntity).receiveEnergy(tDirection, rfOut, false); - rUsedAmperes++; - } else if (((IEnergyReceiver) tTileEntity).receiveEnergy(tDirection, rfOut, true) > 0) { - if (this.mRestRF == 0) { - final int RFtrans = ((IEnergyReceiver) tTileEntity).receiveEnergy(tDirection, rfOut, - false); - rUsedAmperes++; - this.mRestRF = rfOut - RFtrans; - } else { - final int RFtrans = ((IEnergyReceiver) tTileEntity).receiveEnergy(tDirection, - (int) this.mRestRF, false); - this.mRestRF = this.mRestRF - RFtrans; - } - } - if (GregTech_API.mRFExplosions && (((IEnergyReceiver) tTileEntity) - .getMaxEnergyStored(tDirection) < (rfOut * 600))) { - if (rfOut > ((32 * GregTech_API.mEUtoRF) / 100)) { - this.doExplosion(rfOut); - } - } - } - } - } - } - } - - this.mTransferredAmperage += rUsedAmperes; - this.mTransferredVoltageLast20 = Math.max(this.mTransferredVoltageLast20, aVoltage); - this.mTransferredAmperageLast20 = Math.max(this.mTransferredAmperageLast20, this.mTransferredAmperage); - - if ((aVoltage > this.mVoltage) || (this.mTransferredAmperage > this.mAmperage)) { - // GT 5.09 - if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { - if (this.mOverheat > (this.mWireHeatingTicks * 100)) { - this.getBaseMetaTileEntity().setToFire(); - } else { - this.mOverheat += 100; - } - return aAmperage; - } - // GT 5.08 - else { - this.getBaseMetaTileEntity().setToFire(); - return aAmperage; - } - } - - return rUsedAmperes; - } - - @Override - public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { - if (aBaseMetaTileEntity.isServerSide()) { - this.mTransferredAmperage = 0; - if (this.mOverheat > 0) { - this.mOverheat--; - } - - if ((aTick % 20) == 0) { - this.mTransferredVoltageLast20 = 0; - this.mTransferredAmperageLast20 = 0; - this.mConnections = 0; - for (byte i = 0, j = 0; i < 6; i++) { - j = GT_Utility.getOppositeSide(i); - if (aBaseMetaTileEntity.getCoverBehaviorAtSide(i).alwaysLookConnected(i, - aBaseMetaTileEntity.getCoverIDAtSide(i), aBaseMetaTileEntity.getCoverDataAtSide(i), - aBaseMetaTileEntity) - || aBaseMetaTileEntity.getCoverBehaviorAtSide(i).letsEnergyIn(i, - aBaseMetaTileEntity.getCoverIDAtSide(i), aBaseMetaTileEntity.getCoverDataAtSide(i), - aBaseMetaTileEntity) - || aBaseMetaTileEntity.getCoverBehaviorAtSide(i).letsEnergyOut(i, - aBaseMetaTileEntity.getCoverIDAtSide(i), aBaseMetaTileEntity.getCoverDataAtSide(i), - aBaseMetaTileEntity)) { - final TileEntity tTileEntity = aBaseMetaTileEntity.getTileEntityAtSide(i); - if (tTileEntity instanceof IColoredTileEntity) { - if (aBaseMetaTileEntity.getColorization() >= 0) { - final byte tColor = ((IColoredTileEntity) tTileEntity).getColorization(); - if ((tColor >= 0) && (tColor != aBaseMetaTileEntity.getColorization())) { - continue; - } - } - } - if ((tTileEntity instanceof IEnergyConnected) - && (((IEnergyConnected) tTileEntity).inputEnergyFrom(j) - || ((IEnergyConnected) tTileEntity).outputsEnergyTo(j))) { - this.mConnections |= (1 << i); - continue; - } - if ((tTileEntity instanceof IGregTechTileEntity) && (((IGregTechTileEntity) tTileEntity) - .getMetaTileEntity() instanceof IMetaTileEntityCable)) { - if (((IGregTechTileEntity) tTileEntity).getCoverBehaviorAtSide(j).alwaysLookConnected(j, - ((IGregTechTileEntity) tTileEntity).getCoverIDAtSide(j), - ((IGregTechTileEntity) tTileEntity).getCoverDataAtSide(j), - ((IGregTechTileEntity) tTileEntity)) - || ((IGregTechTileEntity) tTileEntity).getCoverBehaviorAtSide(j).letsEnergyIn(j, - ((IGregTechTileEntity) tTileEntity).getCoverIDAtSide(j), - ((IGregTechTileEntity) tTileEntity).getCoverDataAtSide(j), - ((IGregTechTileEntity) tTileEntity)) - || ((IGregTechTileEntity) tTileEntity).getCoverBehaviorAtSide(j).letsEnergyOut(j, - ((IGregTechTileEntity) tTileEntity).getCoverIDAtSide(j), - ((IGregTechTileEntity) tTileEntity).getCoverDataAtSide(j), - ((IGregTechTileEntity) tTileEntity))) { - this.mConnections |= (1 << i); - continue; - } - } - if ((tTileEntity instanceof IEnergySink) && ((IEnergySink) tTileEntity).acceptsEnergyFrom( - (TileEntity) aBaseMetaTileEntity, ForgeDirection.getOrientation(j))) { - this.mConnections |= (1 << i); - continue; - } - if (GregTech_API.mOutputRF && (tTileEntity instanceof IEnergyReceiver) - && ((IEnergyReceiver) tTileEntity).canConnectEnergy(ForgeDirection.getOrientation(j))) { - this.mConnections |= (1 << i); - continue; - } - /* - * if (tTileEntity instanceof IEnergyEmitter && - * ((IEnergyEmitter)tTileEntity).emitsEnergyTo(( - * TileEntity)aBaseMetaTileEntity, - * ForgeDirection.getOrientation(j))) { mConnections |= - * (1<<i); continue; } - */ - } - } - } - } - } - - @Override - public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, - final ItemStack aStack) { - return false; - } - - @Override - public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, - final ItemStack aStack) { - return false; - } - - @Override - public String[] getDescription() { - return new String[] { - "Max Voltage: " + EnumChatFormatting.GREEN + this.mVoltage + " (" - + VN[GT_Utility.getTier(this.mVoltage)] + ")" + EnumChatFormatting.GRAY, - "Max Amperage: " + EnumChatFormatting.YELLOW + this.mAmperage + EnumChatFormatting.GRAY, - "Loss/Meter/Ampere: " + EnumChatFormatting.RED + this.mCableLossPerMeter + EnumChatFormatting.GRAY - + " EU-Volt" }; - } - - @Override - public float getThickNess() { - return this.mThickNess; - } - - @Override - public void saveNBTData(final NBTTagCompound aNBT) { - // - } - - @Override - public void loadNBTData(final NBTTagCompound aNBT) { - // - } -}
\ No newline at end of file + public final float mThickNess; + public final GT_Materials mMaterial; + public final long mCableLossPerMeter, mAmperage, mVoltage; + public final boolean mInsulated, mCanShock; + public long mTransferredAmperage = 0, mTransferredAmperageLast20 = 0, mTransferredVoltageLast20 = 0; + public long mRestRF; + public short mOverheat; + public final int mWireHeatingTicks; + + public GregtechMetaPipeEntityBase_Cable( + final int aID, + final String aName, + final String aNameRegional, + final float aThickNess, + final GT_Materials aMaterial, + final long aCableLossPerMeter, + final long aAmperage, + final long aVoltage, + final boolean aInsulated, + final boolean aCanShock) { + super(aID, aName, aNameRegional, 0); + this.mThickNess = aThickNess; + this.mMaterial = aMaterial; + this.mAmperage = aAmperage; + this.mVoltage = aVoltage; + this.mInsulated = aInsulated; + this.mCanShock = aCanShock; + this.mCableLossPerMeter = aCableLossPerMeter; + this.mWireHeatingTicks = this.getGT5Var(); + } + + public GregtechMetaPipeEntityBase_Cable( + final String aName, + final float aThickNess, + final GT_Materials aMaterial, + final long aCableLossPerMeter, + final long aAmperage, + final long aVoltage, + final boolean aInsulated, + final boolean aCanShock) { + super(aName, 0); + this.mThickNess = aThickNess; + this.mMaterial = aMaterial; + this.mAmperage = aAmperage; + this.mVoltage = aVoltage; + this.mInsulated = aInsulated; + this.mCanShock = aCanShock; + this.mCableLossPerMeter = aCableLossPerMeter; + this.mWireHeatingTicks = this.getGT5Var(); + } + + private int getGT5Var() { + final Class<? extends GT_Proxy> clazz = GT_Mod.gregtechproxy.getClass(); + final String lookingForValue = "mWireHeatingTicks"; + int temp = 4; + Field field; + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { + try { + field = clazz.getClass().getField(lookingForValue); + final Class<?> clazzType = field.getType(); + if (clazzType.toString().equals("int")) { + temp = (field.getInt(clazz)); + } else { + temp = 4; + } + } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) { + // Utils.LOG_INFO("FATAL ERROR - REFLECTION FAILED FOR GT CABLES + // - PLEASE REPORT THIS."); + Logger.WARNING("FATAL ERROR - REFLECTION FAILED FOR GT CABLES - PLEASE REPORT THIS."); + Logger.ERROR("FATAL ERROR - REFLECTION FAILED FOR GT CABLES - PLEASE REPORT THIS."); + temp = 4; + } + } + return temp; + } + + @Override + public byte getTileEntityBaseType() { + return (byte) (this.mInsulated ? 9 : 8); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaPipeEntityBase_Cable( + this.mName, + this.mThickNess, + this.mMaterial, + this.mCableLossPerMeter, + this.mAmperage, + this.mVoltage, + this.mInsulated, + this.mCanShock); + } + + @Override + public ITexture[] getTexture( + final IGregTechTileEntity aBaseMetaTileEntity, + final byte aSide, + final byte aConnections, + final byte aColorIndex, + final boolean aConnected, + final boolean aRedstone) { + if (!this.mInsulated) { + return new ITexture[] { + new GT_RenderedTexture(this.mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], this.mMaterial.mRGBa) + }; + } + if (aConnected) { + final float tThickNess = this.getThickNess(); + if (tThickNess < 0.37F) { + return new ITexture[] { + new GT_RenderedTexture( + this.mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], this.mMaterial.mRGBa), + new GT_RenderedTexture( + Textures.BlockIcons.INSULATION_TINY, + Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa)) + }; + } + if (tThickNess < 0.49F) { + return new ITexture[] { + new GT_RenderedTexture( + this.mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], this.mMaterial.mRGBa), + new GT_RenderedTexture( + Textures.BlockIcons.INSULATION_SMALL, + Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa)) + }; + } + if (tThickNess < 0.74F) { + return new ITexture[] { + new GT_RenderedTexture( + this.mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], this.mMaterial.mRGBa), + new GT_RenderedTexture( + Textures.BlockIcons.INSULATION_MEDIUM, + Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa)) + }; + } + if (tThickNess < 0.99F) { + return new ITexture[] { + new GT_RenderedTexture( + this.mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], this.mMaterial.mRGBa), + new GT_RenderedTexture( + Textures.BlockIcons.INSULATION_LARGE, + Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa)) + }; + } + return new ITexture[] { + new GT_RenderedTexture(this.mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], this.mMaterial.mRGBa), + new GT_RenderedTexture( + Textures.BlockIcons.INSULATION_HUGE, + Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa)) + }; + } + return new ITexture[] { + new GT_RenderedTexture( + Textures.BlockIcons.INSULATION_FULL, Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa)) + }; + } + + @Override + public void onEntityCollidedWithBlock( + final World aWorld, final int aX, final int aY, final int aZ, final Entity aEntity) { + if (this.mCanShock + && ((((BaseMetaPipeEntity) this.getBaseMetaTileEntity()).mConnections & -128) == 0) + && (aEntity instanceof EntityLivingBase)) { + GT_Utility.applyElectricityDamage( + (EntityLivingBase) aEntity, this.mTransferredVoltageLast20, this.mTransferredAmperageLast20); + } + } + + @Override + public AxisAlignedBB getCollisionBoundingBoxFromPool(final World aWorld, final int aX, final int aY, final int aZ) { + if (!this.mCanShock) { + return super.getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ); + } + return AxisAlignedBB.getBoundingBox( + aX + 0.125D, aY + 0.125D, aZ + 0.125D, aX + 0.875D, aY + 0.875D, aZ + 0.875D); + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean isFacingValid(final byte aFacing) { + return false; + } + + @Override + public boolean isValidSlot(final int aIndex) { + return true; + } + + @Override + public final boolean renderInside(final byte aSide) { + return false; + } + + @Override + public int getProgresstime() { + return (int) this.mTransferredAmperage * 64; + } + + @Override + public int maxProgresstime() { + return (int) this.mAmperage * 64; + } + + @Override + public long injectEnergyUnits(final byte aSide, final long aVoltage, final long aAmperage) { + if (!this.getBaseMetaTileEntity() + .getCoverBehaviorAtSide(aSide) + .letsEnergyIn( + aSide, + this.getBaseMetaTileEntity().getCoverIDAtSide(aSide), + this.getBaseMetaTileEntity().getCoverDataAtSide(aSide), + this.getBaseMetaTileEntity())) { + return 0; + } + return this.transferElectricity( + aSide, aVoltage, aAmperage, new ArrayList<>(Arrays.asList((TileEntity) this.getBaseMetaTileEntity()))); + } + + /** + * Adds support for the newer function added by https://github.com/Blood-Asp/GT5-Unofficial/commit/73ee102b63efd92c0f164a7ed7a79ebcd2619617#diff-3051838621d8ae87aa5ccd1345e1f07d + */ + public long transferElectricity(byte arg0, long arg1, long arg2, HashSet<TileEntity> arg3) { + ArrayList<TileEntity> aTiles = new ArrayList<TileEntity>(); + for (TileEntity y : arg3) { + aTiles.add(y); + } + return transferElectricity(arg0, arg1, arg2, aTiles); + } + + @Override + public long transferElectricity( + final byte aSide, + long aVoltage, + final long aAmperage, + final ArrayList<TileEntity> aAlreadyPassedTileEntityList) { + long rUsedAmperes = 0; + aVoltage -= this.mCableLossPerMeter; + if (aVoltage > 0) { + for (byte i = 0; (i < 6) && (aAmperage > rUsedAmperes); i++) { + if ((i != aSide) + && ((this.mConnections & (1 << i)) != 0) + && this.getBaseMetaTileEntity() + .getCoverBehaviorAtSide(i) + .letsEnergyOut( + i, + this.getBaseMetaTileEntity().getCoverIDAtSide(i), + this.getBaseMetaTileEntity().getCoverDataAtSide(i), + this.getBaseMetaTileEntity())) { + final TileEntity tTileEntity = this.getBaseMetaTileEntity().getTileEntityAtSide(i); + if (!aAlreadyPassedTileEntityList.contains(tTileEntity)) { + aAlreadyPassedTileEntityList.add(tTileEntity); + if (tTileEntity instanceof IEnergyConnected) { + if (this.getBaseMetaTileEntity().getColorization() >= 0) { + final byte tColor = ((IEnergyConnected) tTileEntity).getColorization(); + if ((tColor >= 0) + && (tColor + != this.getBaseMetaTileEntity().getColorization())) { + continue; + } + } + if ((tTileEntity instanceof IGregTechTileEntity) + && (((IGregTechTileEntity) tTileEntity).getMetaTileEntity() + instanceof IMetaTileEntityCable) + && ((IGregTechTileEntity) tTileEntity) + .getCoverBehaviorAtSide(GT_Utility.getOppositeSide(i)) + .letsEnergyIn( + GT_Utility.getOppositeSide(i), + ((IGregTechTileEntity) tTileEntity) + .getCoverIDAtSide(GT_Utility.getOppositeSide(i)), + ((IGregTechTileEntity) tTileEntity) + .getCoverDataAtSide(GT_Utility.getOppositeSide(i)), + ((IGregTechTileEntity) tTileEntity))) { + if (((IGregTechTileEntity) tTileEntity).getTimer() > 50) { + rUsedAmperes += ((IMetaTileEntityCable) + ((IGregTechTileEntity) tTileEntity).getMetaTileEntity()) + .transferElectricity( + GT_Utility.getOppositeSide(i), + aVoltage, + aAmperage - rUsedAmperes, + aAlreadyPassedTileEntityList); + } + } else { + rUsedAmperes += ((IEnergyConnected) tTileEntity) + .injectEnergyUnits( + GT_Utility.getOppositeSide(i), aVoltage, aAmperage - rUsedAmperes); + } + // } else if (tTileEntity instanceof IEnergySink) { + // ForgeDirection tDirection = + // ForgeDirection.getOrientation(i).getOpposite(); + // if + // (((IEnergySink)tTileEntity).acceptsEnergyFrom((TileEntity)getBaseMetaTileEntity(), + // tDirection)) { + // if + // (((IEnergySink)tTileEntity).demandedEnergyUnits() + // > 0 && + // ((IEnergySink)tTileEntity).injectEnergyUnits(tDirection, + // aVoltage) < aVoltage) rUsedAmperes++; + // } + } else if (tTileEntity instanceof IEnergySink) { + final ForgeDirection tDirection = + ForgeDirection.getOrientation(i).getOpposite(); + if (((IEnergySink) tTileEntity) + .acceptsEnergyFrom((TileEntity) this.getBaseMetaTileEntity(), tDirection)) { + if ((((IEnergySink) tTileEntity).getDemandedEnergy() > 0) + && (((IEnergySink) tTileEntity).injectEnergy(tDirection, aVoltage, aVoltage) + < aVoltage)) { + rUsedAmperes++; + } + } + } else if (GregTech_API.mOutputRF && (tTileEntity instanceof IEnergyReceiver)) { + final ForgeDirection tDirection = + ForgeDirection.getOrientation(i).getOpposite(); + final int rfOut = (int) ((aVoltage * GregTech_API.mEUtoRF) / 100); + if (((IEnergyReceiver) tTileEntity).receiveEnergy(tDirection, rfOut, true) == rfOut) { + ((IEnergyReceiver) tTileEntity).receiveEnergy(tDirection, rfOut, false); + rUsedAmperes++; + } else if (((IEnergyReceiver) tTileEntity).receiveEnergy(tDirection, rfOut, true) > 0) { + if (this.mRestRF == 0) { + final int RFtrans = + ((IEnergyReceiver) tTileEntity).receiveEnergy(tDirection, rfOut, false); + rUsedAmperes++; + this.mRestRF = rfOut - RFtrans; + } else { + final int RFtrans = ((IEnergyReceiver) tTileEntity) + .receiveEnergy(tDirection, (int) this.mRestRF, false); + this.mRestRF = this.mRestRF - RFtrans; + } + } + if (GregTech_API.mRFExplosions + && (((IEnergyReceiver) tTileEntity).getMaxEnergyStored(tDirection) + < (rfOut * 600))) { + if (rfOut > ((32 * GregTech_API.mEUtoRF) / 100)) { + this.doExplosion(rfOut); + } + } + } + } + } + } + } + + this.mTransferredAmperage += rUsedAmperes; + this.mTransferredVoltageLast20 = Math.max(this.mTransferredVoltageLast20, aVoltage); + this.mTransferredAmperageLast20 = Math.max(this.mTransferredAmperageLast20, this.mTransferredAmperage); + + if ((aVoltage > this.mVoltage) || (this.mTransferredAmperage > this.mAmperage)) { + // GT 5.09 + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { + if (this.mOverheat > (this.mWireHeatingTicks * 100)) { + this.getBaseMetaTileEntity().setToFire(); + } else { + this.mOverheat += 100; + } + return aAmperage; + } + // GT 5.08 + else { + this.getBaseMetaTileEntity().setToFire(); + return aAmperage; + } + } + + return rUsedAmperes; + } + + @Override + public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { + if (aBaseMetaTileEntity.isServerSide()) { + this.mTransferredAmperage = 0; + if (this.mOverheat > 0) { + this.mOverheat--; + } + + if ((aTick % 20) == 0) { + this.mTransferredVoltageLast20 = 0; + this.mTransferredAmperageLast20 = 0; + this.mConnections = 0; + for (byte i = 0, j = 0; i < 6; i++) { + j = GT_Utility.getOppositeSide(i); + if (aBaseMetaTileEntity + .getCoverBehaviorAtSide(i) + .alwaysLookConnected( + i, + aBaseMetaTileEntity.getCoverIDAtSide(i), + aBaseMetaTileEntity.getCoverDataAtSide(i), + aBaseMetaTileEntity) + || aBaseMetaTileEntity + .getCoverBehaviorAtSide(i) + .letsEnergyIn( + i, + aBaseMetaTileEntity.getCoverIDAtSide(i), + aBaseMetaTileEntity.getCoverDataAtSide(i), + aBaseMetaTileEntity) + || aBaseMetaTileEntity + .getCoverBehaviorAtSide(i) + .letsEnergyOut( + i, + aBaseMetaTileEntity.getCoverIDAtSide(i), + aBaseMetaTileEntity.getCoverDataAtSide(i), + aBaseMetaTileEntity)) { + final TileEntity tTileEntity = aBaseMetaTileEntity.getTileEntityAtSide(i); + if (tTileEntity instanceof IColoredTileEntity) { + if (aBaseMetaTileEntity.getColorization() >= 0) { + final byte tColor = ((IColoredTileEntity) tTileEntity).getColorization(); + if ((tColor >= 0) && (tColor != aBaseMetaTileEntity.getColorization())) { + continue; + } + } + } + if ((tTileEntity instanceof IEnergyConnected) + && (((IEnergyConnected) tTileEntity).inputEnergyFrom(j) + || ((IEnergyConnected) tTileEntity).outputsEnergyTo(j))) { + this.mConnections |= (1 << i); + continue; + } + if ((tTileEntity instanceof IGregTechTileEntity) + && (((IGregTechTileEntity) tTileEntity).getMetaTileEntity() + instanceof IMetaTileEntityCable)) { + if (((IGregTechTileEntity) tTileEntity) + .getCoverBehaviorAtSide(j) + .alwaysLookConnected( + j, + ((IGregTechTileEntity) tTileEntity).getCoverIDAtSide(j), + ((IGregTechTileEntity) tTileEntity).getCoverDataAtSide(j), + ((IGregTechTileEntity) tTileEntity)) + || ((IGregTechTileEntity) tTileEntity) + .getCoverBehaviorAtSide(j) + .letsEnergyIn( + j, + ((IGregTechTileEntity) tTileEntity).getCoverIDAtSide(j), + ((IGregTechTileEntity) tTileEntity).getCoverDataAtSide(j), + ((IGregTechTileEntity) tTileEntity)) + || ((IGregTechTileEntity) tTileEntity) + .getCoverBehaviorAtSide(j) + .letsEnergyOut( + j, + ((IGregTechTileEntity) tTileEntity).getCoverIDAtSide(j), + ((IGregTechTileEntity) tTileEntity).getCoverDataAtSide(j), + ((IGregTechTileEntity) tTileEntity))) { + this.mConnections |= (1 << i); + continue; + } + } + if ((tTileEntity instanceof IEnergySink) + && ((IEnergySink) tTileEntity) + .acceptsEnergyFrom( + (TileEntity) aBaseMetaTileEntity, ForgeDirection.getOrientation(j))) { + this.mConnections |= (1 << i); + continue; + } + if (GregTech_API.mOutputRF + && (tTileEntity instanceof IEnergyReceiver) + && ((IEnergyReceiver) tTileEntity).canConnectEnergy(ForgeDirection.getOrientation(j))) { + this.mConnections |= (1 << i); + continue; + } + /* + * if (tTileEntity instanceof IEnergyEmitter && + * ((IEnergyEmitter)tTileEntity).emitsEnergyTo(( + * TileEntity)aBaseMetaTileEntity, + * ForgeDirection.getOrientation(j))) { mConnections |= + * (1<<i); continue; } + */ + } + } + } + } + } + + @Override + public boolean allowPullStack( + final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack( + final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return false; + } + + @Override + public String[] getDescription() { + return new String[] { + "Max Voltage: " + EnumChatFormatting.GREEN + this.mVoltage + " (" + VN[GT_Utility.getTier(this.mVoltage)] + + ")" + EnumChatFormatting.GRAY, + "Max Amperage: " + EnumChatFormatting.YELLOW + this.mAmperage + EnumChatFormatting.GRAY, + "Loss/Meter/Ampere: " + EnumChatFormatting.RED + this.mCableLossPerMeter + EnumChatFormatting.GRAY + + " EU-Volt" + }; + } + + @Override + public float getThickNess() { + return this.mThickNess; + } + + @Override + public void saveNBTData(final NBTTagCompound aNBT) { + // + } + + @Override + public void loadNBTData(final NBTTagCompound aNBT) { + // + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMetaTileEntity.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMetaTileEntity.java index c9201471a4..41f434f7e6 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMetaTileEntity.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMetaTileEntity.java @@ -5,73 +5,80 @@ import static gregtech.api.enums.GT_Values.GT; import gregtech.api.interfaces.ITexture; import gregtech.api.metatileentity.MetaTileEntity; -import gtPlusPlus.core.lib.CORE; - public abstract class GregtechMetaTileEntity extends MetaTileEntity { - /** - * Value between [0 - 9] to describe the Tier of this Machine. - */ - protected byte mTier; - - /** - * A simple Description. - */ - protected final String mDescription; + /** + * Value between [0 - 9] to describe the Tier of this Machine. + */ + protected byte mTier; - /** - * Contains all Textures used by this Block. - */ - public final ITexture[][][] mTextures; + /** + * A simple Description. + */ + protected final String mDescription; - public GregtechMetaTileEntity(final int aID, final String aName, final String aNameRegional, final int aTier, - final int aInvSlotCount, final String aDescription, final ITexture... aTextures) { - super(aID, aName, aNameRegional, aInvSlotCount); - this.mTier = (byte) Math.max(0, Math.min(aTier, 9)); - this.mDescription = aDescription; + /** + * Contains all Textures used by this Block. + */ + public final ITexture[][][] mTextures; - // must always be the last call! - if (GT.isClientSide()) { - this.mTextures = this.getTextureSet(aTextures); - } else { - this.mTextures = null; - } - } + public GregtechMetaTileEntity( + final int aID, + final String aName, + final String aNameRegional, + final int aTier, + final int aInvSlotCount, + final String aDescription, + final ITexture... aTextures) { + super(aID, aName, aNameRegional, aInvSlotCount); + this.mTier = (byte) Math.max(0, Math.min(aTier, 9)); + this.mDescription = aDescription; - public GregtechMetaTileEntity(final String aName, final int aTier, final int aInvSlotCount, - final String aDescription, final ITexture[][][] aTextures) { - super(aName, aInvSlotCount); - this.mTier = (byte) aTier; - this.mDescription = aDescription; - this.mTextures = aTextures; + // must always be the last call! + if (GT.isClientSide()) { + this.mTextures = this.getTextureSet(aTextures); + } else { + this.mTextures = null; + } + } - } + public GregtechMetaTileEntity( + final String aName, + final int aTier, + final int aInvSlotCount, + final String aDescription, + final ITexture[][][] aTextures) { + super(aName, aInvSlotCount); + this.mTier = (byte) aTier; + this.mDescription = aDescription; + this.mTextures = aTextures; + } - @Override - public byte getTileEntityBaseType() { - return (byte) (Math.min(3, this.mTier <= 0 ? 0 : 1 + ((this.mTier - 1) / 4))); - } + @Override + public byte getTileEntityBaseType() { + return (byte) (Math.min(3, this.mTier <= 0 ? 0 : 1 + ((this.mTier - 1) / 4))); + } - @Override - public long getInputTier() { - return this.mTier; - } + @Override + public long getInputTier() { + return this.mTier; + } - @Override - public long getOutputTier() { - return this.mTier; - } + @Override + public long getOutputTier() { + return this.mTier; + } - @Override - public String[] getDescription() { - return new String[] { this.mDescription }; - } + @Override + public String[] getDescription() { + return new String[] {this.mDescription}; + } - /** - * Used Client Side to get a Texture Set for this Block. Called after - * setting the Tier and the Description so that those two are accessible. - * - * @param aTextures - * is the optional Array you can give to the Constructor. - */ - public abstract ITexture[][][] getTextureSet(ITexture[] aTextures); -}
\ No newline at end of file + /** + * Used Client Side to get a Texture Set for this Block. Called after + * setting the Tier and the Description so that those two are accessible. + * + * @param aTextures + * is the optional Array you can give to the Constructor. + */ + public abstract ITexture[][][] getTextureSet(ITexture[] aTextures); +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMetaTransformerHiAmp.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMetaTransformerHiAmp.java index d0021f8358..e900aac944 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMetaTransformerHiAmp.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMetaTransformerHiAmp.java @@ -1,116 +1,131 @@ package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; - 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_Transformer; - import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.minecraft.PlayerUtils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; public class GregtechMetaTransformerHiAmp extends GT_MetaTileEntity_Transformer { - private boolean mHalfMode = false; - - public GregtechMetaTransformerHiAmp(int aID, String aName, String aNameRegional, int aTier, String aDescription) { - super(aID, aName, aNameRegional, aTier, aDescription); - } - - public GregtechMetaTransformerHiAmp(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { - super(aName, aTier, aDescription, aTextures); - } - - @Override - public long maxEUStore() { - return ((512L + gregtech.api.enums.GT_Values.V[(this.mTier + 1)] * 2L) * 8); - } - - @Override - public long maxAmperesOut() { - if (this.mHalfMode) { - return ((getBaseMetaTileEntity().isAllowedToWork()) ? 8L : 2L); - } - return ((getBaseMetaTileEntity().isAllowedToWork()) ? 16L : 4L); - } - - @Override - public long maxAmperesIn() { - if (this.mHalfMode) { - return ((getBaseMetaTileEntity().isAllowedToWork()) ? 2L : 8L); - } - return ((getBaseMetaTileEntity().isAllowedToWork()) ? 4L : 16L); - } - - @Override - public ITexture[][][] getTextureSet(ITexture[] aTextures) { - ITexture[][][] rTextures = new ITexture[12][17][]; - for (byte i = -1; i < 16; i++) { - rTextures[0][i + 1] = new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], - Textures.BlockIcons.OVERLAYS_ENERGY_OUT[mTier] }; - rTextures[1][i + 1] = new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], - Textures.BlockIcons.OVERLAYS_ENERGY_OUT[mTier] }; - rTextures[2][i + 1] = new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], - Textures.BlockIcons.OVERLAYS_ENERGY_OUT[mTier] }; - rTextures[3][i + 1] = new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], - Textures.BlockIcons.OVERLAYS_ENERGY_IN_MULTI[mTier + 1] }; - rTextures[4][i + 1] = new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], - Textures.BlockIcons.OVERLAYS_ENERGY_IN_MULTI[mTier + 1] }; - rTextures[5][i + 1] = new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], - Textures.BlockIcons.OVERLAYS_ENERGY_IN_MULTI[mTier + 1] }; - rTextures[6][i + 1] = new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], - Textures.BlockIcons.OVERLAYS_ENERGY_IN[mTier] }; - rTextures[7][i + 1] = new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], - Textures.BlockIcons.OVERLAYS_ENERGY_IN[mTier] }; - rTextures[8][i + 1] = new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], - Textures.BlockIcons.OVERLAYS_ENERGY_IN[mTier] }; - rTextures[9][i + 1] = new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], - Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[mTier + 1] }; - rTextures[10][i + 1] = new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], - Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[mTier + 1] }; - rTextures[11][i + 1] = new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], - Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[mTier + 1] }; - } - return rTextures; - } - - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GregtechMetaTransformerHiAmp(this.mName, this.mTier, this.mDescription, this.mTextures); - } - - @Override - public String[] getDescription() { - return new String[] { this.mDescription, - "Accepts 4A and outputs 16A", - "Toggle 2A/8A half-mode with Screwdriver", - CORE.GT_Tooltip}; - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - aNBT.setBoolean("mHalfMode", this.mHalfMode); - super.saveNBTData(aNBT); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - this.mHalfMode = aNBT.getBoolean("mHalfMode"); - super.loadNBTData(aNBT); - } - - @Override - public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - this.mHalfMode = Utils.invertBoolean(mHalfMode); - if (this.mHalfMode) { - PlayerUtils.messagePlayer(aPlayer, "Transformer is now running at 2A:8A in/out Ratio."); - } else { - - PlayerUtils.messagePlayer(aPlayer, "Transformer is now running at 4A:16A in/out Ratio."); - } - } -}
\ No newline at end of file + private boolean mHalfMode = false; + + public GregtechMetaTransformerHiAmp(int aID, String aName, String aNameRegional, int aTier, String aDescription) { + super(aID, aName, aNameRegional, aTier, aDescription); + } + + public GregtechMetaTransformerHiAmp(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + @Override + public long maxEUStore() { + return ((512L + gregtech.api.enums.GT_Values.V[(this.mTier + 1)] * 2L) * 8); + } + + @Override + public long maxAmperesOut() { + if (this.mHalfMode) { + return ((getBaseMetaTileEntity().isAllowedToWork()) ? 8L : 2L); + } + return ((getBaseMetaTileEntity().isAllowedToWork()) ? 16L : 4L); + } + + @Override + public long maxAmperesIn() { + if (this.mHalfMode) { + return ((getBaseMetaTileEntity().isAllowedToWork()) ? 2L : 8L); + } + return ((getBaseMetaTileEntity().isAllowedToWork()) ? 4L : 16L); + } + + @Override + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + ITexture[][][] rTextures = new ITexture[12][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], Textures.BlockIcons.OVERLAYS_ENERGY_OUT[mTier] + }; + rTextures[1][i + 1] = new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], Textures.BlockIcons.OVERLAYS_ENERGY_OUT[mTier] + }; + rTextures[2][i + 1] = new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], Textures.BlockIcons.OVERLAYS_ENERGY_OUT[mTier] + }; + rTextures[3][i + 1] = new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], + Textures.BlockIcons.OVERLAYS_ENERGY_IN_MULTI[mTier + 1] + }; + rTextures[4][i + 1] = new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], + Textures.BlockIcons.OVERLAYS_ENERGY_IN_MULTI[mTier + 1] + }; + rTextures[5][i + 1] = new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], + Textures.BlockIcons.OVERLAYS_ENERGY_IN_MULTI[mTier + 1] + }; + rTextures[6][i + 1] = new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], Textures.BlockIcons.OVERLAYS_ENERGY_IN[mTier] + }; + rTextures[7][i + 1] = new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], Textures.BlockIcons.OVERLAYS_ENERGY_IN[mTier] + }; + rTextures[8][i + 1] = new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], Textures.BlockIcons.OVERLAYS_ENERGY_IN[mTier] + }; + rTextures[9][i + 1] = new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], + Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[mTier + 1] + }; + rTextures[10][i + 1] = new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], + Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[mTier + 1] + }; + rTextures[11][i + 1] = new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], + Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[mTier + 1] + }; + } + return rTextures; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTransformerHiAmp(this.mName, this.mTier, this.mDescription, this.mTextures); + } + + @Override + public String[] getDescription() { + return new String[] { + this.mDescription, "Accepts 4A and outputs 16A", "Toggle 2A/8A half-mode with Screwdriver", CORE.GT_Tooltip + }; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setBoolean("mHalfMode", this.mHalfMode); + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + this.mHalfMode = aNBT.getBoolean("mHalfMode"); + super.loadNBTData(aNBT); + } + + @Override + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + this.mHalfMode = Utils.invertBoolean(mHalfMode); + if (this.mHalfMode) { + PlayerUtils.messagePlayer(aPlayer, "Transformer is now running at 2A:8A in/out Ratio."); + } else { + + PlayerUtils.messagePlayer(aPlayer, "Transformer is now running at 4A:16A in/out Ratio."); + } + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java index f6d4d3946c..4bd18819c6 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java @@ -1,5 +1,7 @@ package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base; +import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; + import com.gtnewhorizon.structurelib.StructureLibAPI; import com.gtnewhorizon.structurelib.structure.IItemSource; import com.gtnewhorizon.structurelib.structure.IStructureElement; @@ -44,6 +46,15 @@ import gtPlusPlus.preloader.CORE_Preloader; import gtPlusPlus.preloader.asm.AsmConfig; import gtPlusPlus.xmod.gregtech.api.gui.*; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.*; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.*; +import java.util.concurrent.TimeUnit; +import java.util.function.BiConsumer; +import java.util.function.BiPredicate; +import java.util.function.Consumer; +import java.util.function.Function; +import java.util.stream.Collectors; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; @@ -61,1562 +72,1590 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.oredict.OreDictionary; import org.apache.commons.lang3.ArrayUtils; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.*; -import java.util.concurrent.TimeUnit; -import java.util.function.BiConsumer; -import java.util.function.BiPredicate; -import java.util.function.Consumer; -import java.util.function.Function; -import java.util.stream.Collectors; +// Glee8e - 11/12/21 - 2:15pm +// Yeah, now I see what's wrong. Someone inherited from GregtechMeta_MultiBlockBase instead of +// GregtechMeta_MultiBlockBase<GregtechMetaTileEntity_IndustrialDehydrator> as it should have been +// so any method in GregtechMetaTileEntity_IndustrialDehydrator would see generic field declared in +// GregtechMeta_MultiBlockBase without generic parameter + +public abstract class GregtechMeta_MultiBlockBase<T extends GT_MetaTileEntity_EnhancedMultiBlockBase<T>> + extends GT_MetaTileEntity_EnhancedMultiBlockBase<T> { + + public static final boolean DEBUG_DISABLE_CORES_TEMPORARILY = true; + + static { + Method a08 = findRecipe08 = ReflectionUtils.getMethod( + GT_Recipe_Map.class, + "findRecipe", + IHasWorldObjectAndCoords.class, + GT_Recipe.class, + boolean.class, + long.class, + FluidStack[].class, + ItemStack.class, + ItemStack[].class); + Method a09 = findRecipe09 = ReflectionUtils.getMethod( + GT_Recipe_Map.class, + "findRecipe", + IHasWorldObjectAndCoords.class, + GT_Recipe.class, + boolean.class, + boolean.class, + long.class, + FluidStack[].class, + ItemStack.class, + ItemStack[].class); + Logger.MACHINE_INFO("Found .08 findRecipe method? " + (a08 != null)); + Logger.MACHINE_INFO("Found .09 findRecipe method? " + (a09 != null)); + + try { + calculatePollutionReduction = + GT_MetaTileEntity_Hatch_Muffler.class.getDeclaredMethod("calculatePollutionReduction", int.class); + } catch (NoSuchMethodException | SecurityException e) { + } + } + // Find Recipe Methods + private static final Method findRecipe08; + private static final Method findRecipe09; + + public GT_Recipe mLastRecipe; + private boolean mInternalCircuit = false; + protected long mTotalRunTime = 0; + protected boolean mVoidExcess = false; + + public ArrayList<GT_MetaTileEntity_Hatch_ControlCore> mControlCoreBus = + new ArrayList<GT_MetaTileEntity_Hatch_ControlCore>(); + /** + * Don't use this for recipe input check, otherwise you'll get duplicated fluids + */ + public ArrayList<GT_MetaTileEntity_Hatch_AirIntake> mAirIntakes = + new ArrayList<GT_MetaTileEntity_Hatch_AirIntake>(); + + public ArrayList<GT_MetaTileEntity_Hatch_InputBattery> mChargeHatches = + new ArrayList<GT_MetaTileEntity_Hatch_InputBattery>(); + public ArrayList<GT_MetaTileEntity_Hatch_OutputBattery> mDischargeHatches = + new ArrayList<GT_MetaTileEntity_Hatch_OutputBattery>(); + public ArrayList<GT_MetaTileEntity_Hatch> mAllEnergyHatches = new ArrayList<GT_MetaTileEntity_Hatch>(); + public ArrayList<GT_MetaTileEntity_Hatch> mAllDynamoHatches = new ArrayList<GT_MetaTileEntity_Hatch>(); + + // Custom Behaviour Map + private static final HashMap<String, SpecialMultiBehaviour> mCustomBehviours = + new HashMap<String, SpecialMultiBehaviour>(); + + public GregtechMeta_MultiBlockBase(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } -import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; + public GregtechMeta_MultiBlockBase(final String aName) { + super(aName); + } -// Glee8e - 11/12/21 - 2:15pm -// Yeah, now I see what's wrong. Someone inherited from GregtechMeta_MultiBlockBase instead of GregtechMeta_MultiBlockBase<GregtechMetaTileEntity_IndustrialDehydrator> as it should have been -// so any method in GregtechMetaTileEntity_IndustrialDehydrator would see generic field declared in GregtechMeta_MultiBlockBase without generic parameter - -public abstract class GregtechMeta_MultiBlockBase<T extends GT_MetaTileEntity_EnhancedMultiBlockBase<T>> extends GT_MetaTileEntity_EnhancedMultiBlockBase<T> { - - public static final boolean DEBUG_DISABLE_CORES_TEMPORARILY = true; - - static { - - Method a08 = findRecipe08 = ReflectionUtils.getMethod(GT_Recipe_Map.class, "findRecipe", IHasWorldObjectAndCoords.class, GT_Recipe.class, boolean.class, long.class, FluidStack[].class, ItemStack.class, ItemStack[].class); - Method a09 = findRecipe09 = ReflectionUtils.getMethod(GT_Recipe_Map.class, "findRecipe", IHasWorldObjectAndCoords.class, GT_Recipe.class, boolean.class, boolean.class, long.class, FluidStack[].class, ItemStack.class, ItemStack[].class); - Logger.MACHINE_INFO("Found .08 findRecipe method? "+(a08 != null)); - Logger.MACHINE_INFO("Found .09 findRecipe method? "+(a09 != null)); - - try { - calculatePollutionReduction = GT_MetaTileEntity_Hatch_Muffler.class.getDeclaredMethod("calculatePollutionReduction", int.class); - } - catch (NoSuchMethodException | SecurityException e) {} - - } - - //Find Recipe Methods - private static final Method findRecipe08; - private static final Method findRecipe09; - - public GT_Recipe mLastRecipe; - private boolean mInternalCircuit = false; - protected long mTotalRunTime = 0; - protected boolean mVoidExcess = false; - - public ArrayList<GT_MetaTileEntity_Hatch_ControlCore> mControlCoreBus = new ArrayList<GT_MetaTileEntity_Hatch_ControlCore>(); - /** - * Don't use this for recipe input check, otherwise you'll get duplicated fluids - */ - public ArrayList<GT_MetaTileEntity_Hatch_AirIntake> mAirIntakes = new ArrayList<GT_MetaTileEntity_Hatch_AirIntake>(); - public ArrayList<GT_MetaTileEntity_Hatch_InputBattery> mChargeHatches = new ArrayList<GT_MetaTileEntity_Hatch_InputBattery>(); - public ArrayList<GT_MetaTileEntity_Hatch_OutputBattery> mDischargeHatches = new ArrayList<GT_MetaTileEntity_Hatch_OutputBattery>(); - public ArrayList<GT_MetaTileEntity_Hatch> mAllEnergyHatches = new ArrayList<GT_MetaTileEntity_Hatch>(); - public ArrayList<GT_MetaTileEntity_Hatch> mAllDynamoHatches = new ArrayList<GT_MetaTileEntity_Hatch>(); - - // Custom Behaviour Map - private static final HashMap<String, SpecialMultiBehaviour> mCustomBehviours = new HashMap<String, SpecialMultiBehaviour>(); - - - public GregtechMeta_MultiBlockBase(final int aID, final String aName, - final String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMeta_MultiBlockBase(final String aName) { - super(aName); - } - - public static boolean isValidMetaTileEntity( - final MetaTileEntity aMetaTileEntity) { - return (aMetaTileEntity.getBaseMetaTileEntity() != null) - && (aMetaTileEntity.getBaseMetaTileEntity() - .getMetaTileEntity() == aMetaTileEntity) - && !aMetaTileEntity.getBaseMetaTileEntity().isDead(); - } - - public abstract boolean hasSlotInGUI(); - - public long getTotalRuntimeInTicks() { - return this.mTotalRunTime; - } - - @Override - public Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { - if (hasSlotInGUI()) { - return new GT_Container_MultiMachine(aPlayerInventory, aBaseMetaTileEntity); - } - else { - String aCustomGUI = getCustomGUIResourceName(); - if (aCustomGUI == null) { - return new CONTAINER_MultiMachine_NoPlayerInventory(aPlayerInventory, aBaseMetaTileEntity); - } - else { - return new CONTAINER_MultiMachine(aPlayerInventory, aBaseMetaTileEntity); - } - } - } - - public abstract String getCustomGUIResourceName(); - - public boolean requiresVanillaGtGUI() { - return false; - } - - @Override - public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { - String aCustomGUI = getCustomGUIResourceName(); - aCustomGUI = aCustomGUI != null ? aCustomGUI : hasSlotInGUI() ? "MultiblockDisplay" : "MultiblockDisplay_Generic"; - aCustomGUI = aCustomGUI + ".png"; - if (hasSlotInGUI()) { - if (!requiresVanillaGtGUI()) { - return new GUI_Multi_Basic_Slotted(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), aCustomGUI); - } - else { - return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), aCustomGUI); - } - } - else { - if (getCustomGUIResourceName() == null && !hasSlotInGUI()) { - return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), aCustomGUI); - } - else { - return new GUI_MultiMachine_Default(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), aCustomGUI); - } - } - } - - public abstract String getMachineType(); - - public String getMachineTooltip() { - return "Machine Type: " + EnumChatFormatting.YELLOW + getMachineType() + EnumChatFormatting.RESET; - } - - public String[] getExtraInfoData() { - return new String[0]; - }; - - @Override - public final String[] getInfoData() { - ArrayList<String> mInfo = new ArrayList<String>(); - try { - if (!this.getMetaName().equals("")) { - mInfo.add(this.getMetaName()); - } - - String[] extra = getExtraInfoData(); - - if (extra == null) { - extra = new String[0]; - } - if (extra.length > 0) { - for (String s : extra) { - mInfo.add(s); - } - } - - long seconds = (this.mTotalRunTime/20); - int weeks = (int) (TimeUnit.SECONDS.toDays(seconds) / 7); - int days = (int) (TimeUnit.SECONDS.toDays(seconds) - 7 * weeks); - long hours = TimeUnit.SECONDS.toHours(seconds) - TimeUnit.DAYS.toHours(days) - TimeUnit.DAYS.toHours(7*weeks); - long minutes = TimeUnit.SECONDS.toMinutes(seconds) - (TimeUnit.SECONDS.toHours(seconds) * 60); - long second = TimeUnit.SECONDS.toSeconds(seconds) - (TimeUnit.SECONDS.toMinutes(seconds) *60); - - mInfo.add(getMachineTooltip()); - - //Lets borrow the GTNH handling - - mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.progress")+": "+ - EnumChatFormatting.GREEN + Integer.toString(mProgresstime/20) + EnumChatFormatting.RESET +" s / "+ - EnumChatFormatting.YELLOW + Integer.toString(mMaxProgresstime/20) + EnumChatFormatting.RESET +" s"); - - - if (!this.mAllEnergyHatches.isEmpty()) { - long storedEnergy = getStoredEnergyInAllEnergyHatches(); - long maxEnergy = getMaxEnergyStorageOfAllEnergyHatches(); - mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.energy")+":"); - mInfo.add(StatCollector.translateToLocal(""+EnumChatFormatting.GREEN + Long.toString(storedEnergy) + EnumChatFormatting.RESET +" EU / "+ - EnumChatFormatting.YELLOW + Long.toString(maxEnergy) + EnumChatFormatting.RESET +" EU")); - - mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.mei")+":"); - mInfo.add(StatCollector.translateToLocal(""+EnumChatFormatting.YELLOW+Long.toString(getMaxInputVoltage())+EnumChatFormatting.RESET+ " EU/t(*2A) "+StatCollector.translateToLocal("GTPP.machines.tier")+": "+ - EnumChatFormatting.YELLOW+GT_Values.VN[GT_Utility.getTier(getMaxInputVoltage())]+ EnumChatFormatting.RESET)); - ; - } - if (!this.mAllDynamoHatches.isEmpty()) { - long storedEnergy = getStoredEnergyInAllDynamoHatches(); - long maxEnergy = getMaxEnergyStorageOfAllDynamoHatches(); - mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.energy")+" In Dynamos:"); - mInfo.add(StatCollector.translateToLocal(""+EnumChatFormatting.GREEN + Long.toString(storedEnergy) + EnumChatFormatting.RESET +" EU / "+ - EnumChatFormatting.YELLOW + Long.toString(maxEnergy) + EnumChatFormatting.RESET +" EU")); - } - - if (-mEUt > 0) { - mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.usage")+":"); - mInfo.add(StatCollector.translateToLocal(""+EnumChatFormatting.RED + Integer.toString(-mEUt) + EnumChatFormatting.RESET + " EU/t")); - } - else { - mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.generation")+":"); - mInfo.add(StatCollector.translateToLocal(""+EnumChatFormatting.GREEN + Integer.toString(mEUt) + EnumChatFormatting.RESET + " EU/t")); - } - - mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.problems")+": "+ - EnumChatFormatting.RED+ (getIdealStatus() - getRepairStatus())+EnumChatFormatting.RESET+ - " "+StatCollector.translateToLocal("GTPP.multiblock.efficiency")+": "+ - EnumChatFormatting.YELLOW+Float.toString(mEfficiency / 100.0F)+EnumChatFormatting.RESET + " %"); - - if (this.getPollutionPerSecond(null) > 0) { - int mPollutionReduction = getPollutionReductionForAllMufflers(); - mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.pollution")+": "+ EnumChatFormatting.RED + this.getPollutionPerSecond(null)+ EnumChatFormatting.RESET+"/sec"); - mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.pollutionreduced")+": "+ EnumChatFormatting.GREEN + mPollutionReduction+ EnumChatFormatting.RESET+" %"); - } - - if (this.mControlCoreBus.size() > 0) { - int tTier = this.getControlCoreTier(); - mInfo.add(StatCollector.translateToLocal("GTPP.CC.machinetier")+": "+ - EnumChatFormatting.GREEN+tTier+EnumChatFormatting.RESET); - } - - mInfo.add(StatCollector.translateToLocal("GTPP.CC.discount")+": "+ - EnumChatFormatting.GREEN+(getEuDiscountForParallelism())+EnumChatFormatting.RESET + "%"); - - mInfo.add(StatCollector.translateToLocal("GTPP.CC.parallel")+": "+EnumChatFormatting.GREEN+(getMaxParallelRecipes())+EnumChatFormatting.RESET); - - - mInfo.add("Total Time Since Built: " + EnumChatFormatting.DARK_GREEN + Integer.toString(weeks)+EnumChatFormatting.RESET+" Weeks, " + EnumChatFormatting.DARK_GREEN+ Integer.toString(days) +EnumChatFormatting.RESET+ " Days, "); - mInfo.add(EnumChatFormatting.DARK_GREEN + Long.toString(hours) +EnumChatFormatting.RESET + " Hours, " + EnumChatFormatting.DARK_GREEN+ Long.toString(minutes) +EnumChatFormatting.RESET+ " Minutes, " + EnumChatFormatting.DARK_GREEN+ Long.toString(second) +EnumChatFormatting.RESET+ " Seconds."); - mInfo.add("Total Time in ticks: " + EnumChatFormatting.DARK_GREEN + Long.toString(this.mTotalRunTime)); - - - String[] mInfo2 = mInfo.toArray(new String[mInfo.size()]); - return mInfo2; - } - catch (Throwable t) { - t.printStackTrace(); - } - return new String[] {}; - - - } - - public int getPollutionReductionForAllMufflers() { - int mPollutionReduction=0; - for (GT_MetaTileEntity_Hatch_Muffler tHatch : mMufflerHatches) { - if (isValidMetaTileEntity(tHatch)) { - mPollutionReduction=Math.max(calculatePollutionReductionForHatch(tHatch, 100),mPollutionReduction); - } - } - return mPollutionReduction; - } - - public long getStoredEnergyInAllEnergyHatches() { - long storedEnergy=0; - for(GT_MetaTileEntity_Hatch tHatch : mAllEnergyHatches) { - if (isValidMetaTileEntity(tHatch)) { - storedEnergy+=tHatch.getBaseMetaTileEntity().getStoredEU(); - } - } - return storedEnergy; - } - - public long getMaxEnergyStorageOfAllEnergyHatches() { - long maxEnergy=0; - for(GT_MetaTileEntity_Hatch tHatch : mAllEnergyHatches) { - if (isValidMetaTileEntity(tHatch)) { - maxEnergy+=tHatch.getBaseMetaTileEntity().getEUCapacity(); - } - } - return maxEnergy; - } - - public long getStoredEnergyInAllDynamoHatches() { - long storedEnergy=0; - for(GT_MetaTileEntity_Hatch tHatch : mAllDynamoHatches) { - if (isValidMetaTileEntity(tHatch)) { - storedEnergy+=tHatch.getBaseMetaTileEntity().getStoredEU(); - } - } - return storedEnergy; - } - - public long getMaxEnergyStorageOfAllDynamoHatches() { - long maxEnergy=0; - for(GT_MetaTileEntity_Hatch tHatch : mAllDynamoHatches) { - if (isValidMetaTileEntity(tHatch)) { - maxEnergy+=tHatch.getBaseMetaTileEntity().getEUCapacity(); - } - } - return maxEnergy; - } - - @Override - public boolean isGivingInformation() { - return true; - } - - private String[] aCachedToolTip; - - /*private final String aRequiresMuffler = "1x Muffler Hatch"; - private final String aRequiresCoreModule = "1x Core Module"; - private final String aRequiresMaint = "1x Maintanence Hatch";*/ - - public final static String TAG_HIDE_HATCHES = "TAG_HIDE_HATCHES"; - public final static String TAG_HIDE_MAINT = "TAG_HIDE_MAINT"; - public final static String TAG_HIDE_POLLUTION = "TAG_HIDE_POLLUTION"; - public final static String TAG_HIDE_MACHINE_TYPE = "TAG_HIDE_MACHINE_TYPE"; - - public int getAmountOfOutputs() { - return 1; - } - - public abstract int getMaxParallelRecipes(); - public abstract int getEuDiscountForParallelism(); - - @Override - public boolean isCorrectMachinePart(final ItemStack paramItemStack) { - return true; - } - - @Override - public int getDamageToComponent(final ItemStack paramItemStack) { - return 0; - } - - @Override - public boolean explodesOnComponentBreak(ItemStack p0) { - return false; - } - - @Override - public void startSoundLoop(final byte aIndex, final double aX, final double aY, final double aZ) { - super.startSoundLoop(aIndex, aX, aY, aZ); - if (aIndex == 1) { - GT_Utility.doSoundAtClient(getSound(), 10, 1.0F, aX, aY, aZ); - } - } - - public void startProcess() { - if(GT_Utility.isStringValid(getSound())) this.sendLoopStart((byte) 1); - } - - public String getSound() { return ""; } - - - public int canBufferOutputs(final GT_Recipe aRecipe, int aParallelRecipes) { - return canBufferOutputs(aRecipe, aParallelRecipes, true); - } - - public int canBufferOutputs(final GT_Recipe aRecipe, int aParallelRecipes, boolean aAllow16SlotWithoutCheck) { - // Null recipe or a recipe with lots of outputs? - // E.G. Gendustry custom comb with a billion centrifuge outputs? - // Do it anyway, provided the multi allows it. Default behaviour is aAllow16SlotWithoutCheck = true. - if (aRecipe == null || aRecipe.mOutputs.length > 16) { - if (aRecipe == null) { - return 0; - } - else if (aRecipe.mOutputs.length > 16) { - if (aAllow16SlotWithoutCheck) { - return aParallelRecipes; - } - else { - // Do nothing, we want to check this recipe properly. - } - } - } - return canBufferOutputs(aRecipe.mOutputs, aRecipe.mFluidOutputs, aParallelRecipes); - } - - public int canBufferOutputs(ItemStack[] aItemOutputs, FluidStack[] aFluidOutputs, int aParallelRecipes) { - if (mVoidExcess) return aParallelRecipes; - log("Determining if we have space to buffer outputs. Parallel: "+aParallelRecipes); - - // Do we even need to check for item outputs? - boolean aDoesOutputItems = aItemOutputs.length > 0; - // Do we even need to check for fluid outputs? - boolean aDoesOutputFluids = aFluidOutputs.length > 0; - - - - /* ======================================== - * Item Management - * ======================================== - */ - - if (aDoesOutputItems) { - log("We have items to output."); - - // How many slots are free across all the output buses? - int aInputBusSlotsFree = 0; - - /* - * Create Variables for Item Output - */ - - AutoMap<FlexiblePair<ItemStack, Integer>> aItemMap = new AutoMap<FlexiblePair<ItemStack, Integer>>(); - AutoMap<ItemStack> aOutputs = new AutoMap<ItemStack>(aItemOutputs); - - for (final GT_MetaTileEntity_Hatch_OutputBus tBus : this.mOutputBusses) { - if (!isValidMetaTileEntity(tBus)) { - continue; - } - final IInventory tBusInv = tBus.getBaseMetaTileEntity(); - for (int i = 0; i < tBusInv.getSizeInventory(); i++) { - if (tBus.getStackInSlot(i) == null) { - aInputBusSlotsFree++; - } - else { - ItemStack aT = tBus.getStackInSlot(i); - int aSize = aT.stackSize; - aT = aT.copy(); - aT.stackSize = 0; - aItemMap.put(new FlexiblePair<ItemStack, Integer>(aT, aSize)); - } - } - } - - // A map to hold the items we will be 'inputting' into the output buses. These itemstacks are actually the recipe outputs. - ConcurrentSet<FlexiblePair<ItemStack, Integer>> aInputMap = new ConcurrentHashSet<FlexiblePair<ItemStack, Integer>>(); - - // Iterate over the outputs, calculating require stack spacing they will require. - for (int i=0;i<aOutputs.size();i++) { - ItemStack aY = aOutputs.get(i); - if (aY == null) { - continue; - } - else { - int aStackSize = aY.stackSize * aParallelRecipes; - - int aSlotsNeedsForThisStack = (int) Math.ceil((float) aStackSize / aY.getMaxStackSize()); - // Should round up and add as many stacks as required nicely. - for (int o=0;o<aSlotsNeedsForThisStack;o++) { - if (aStackSize < 1) break; - int aStackToRemove = Math.min(aStackSize, aY.getMaxStackSize()); - aStackSize -= aStackToRemove; - aY = aY.copy(); - aY.stackSize = 0; - aInputMap.add(new FlexiblePair<ItemStack, Integer>(aY, aStackToRemove)); - } - } - } - - // We have items to add to the output buses. See if any are not full stacks and see if we can make them full. - if (aInputMap.size() > 0) { - // Iterate over the current stored items in the Output busses, if any match and are not full, we can try account for merging. - busItems: for (FlexiblePair<ItemStack, Integer> y : aItemMap) { - // Iterate over the 'inputs', we can safely remove these as we go. - outputItems: for (FlexiblePair<ItemStack, Integer> u : aInputMap) { - // Create local vars for readability. - ItemStack aOutputBusStack = y.getKey(); - ItemStack aOutputStack = u.getKey(); - // Stacks match, including NBT. - if (GT_Utility.areStacksEqual(aOutputBusStack, aOutputStack, false)) { - // Stack Matches, but it's full, continue. - if (aOutputBusStack.stackSize >= 64) { - // This stack is full, no point checking it. - continue busItems; - } - else { - // We can merge these two stacks without any hassle. - if ((aOutputBusStack.stackSize + aOutputStack.stackSize) <= 64) { - // Update the stack size in the bus storage map. - y.setValue(aOutputBusStack.stackSize + aOutputStack.stackSize); - // Remove the 'input' stack from the recipe outputs, so we don't try count it again. - aInputMap.remove(u); - continue outputItems; - } - // Stack merging is too much, so we fill this stack, leave the remainder. - else { - int aRemainder = (aOutputBusStack.stackSize + aOutputStack.stackSize) - 64; - // Update the stack size in the bus storage map. - y.setValue(64); - // Create a new object to iterate over later, with the remainder data; - FlexiblePair<ItemStack, Integer> t = new FlexiblePair<ItemStack, Integer>(u.getKey(), aRemainder); - // Remove the 'input' stack from the recipe outputs, so we don't try count it again. - aInputMap.remove(u); - // Add the remainder stack. - aInputMap.add(t); - continue outputItems; - } - } - } - else { - continue outputItems; - } - } - } - } - - // We have stacks that did not merge, do we have space for them? - if (aInputMap.size() > 0) { - if (aInputMap.size() > aInputBusSlotsFree) { - aParallelRecipes = (int) Math.floor((double) aInputBusSlotsFree/aInputMap.size() * aParallelRecipes); - // We do not have enough free slots in total to accommodate the remaining managed stacks. - log(" Free: "+aInputBusSlotsFree+", Required: "+aInputMap.size()); - if(aParallelRecipes == 0) { - log("Failed to find enough space for all item outputs."); - return 0; - } - - } - } - - /* - * End Item Management - */ - - } - - - - - - /* ======================================== - * Fluid Management - * ======================================== - */ - - - - if (aDoesOutputFluids) { - log("We have Fluids to output."); - // How many slots are free across all the output buses? - int aFluidHatches = 0; - int aEmptyFluidHatches = 0; - int aFullFluidHatches = 0; - // Create Map for Fluid Output - ArrayList<Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer>> aOutputHatches = new ArrayList<Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer>>(); - for (final GT_MetaTileEntity_Hatch_Output tBus : this.mOutputHatches) { - if (!isValidMetaTileEntity(tBus)) { - continue; - } - aFluidHatches++; - // Map the Hatch with the space left for easy checking later. - if (tBus.getFluid() == null) { - aOutputHatches.add(new Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer>(tBus, null, tBus.getCapacity())); - } - else { - int aSpaceLeft = tBus.getCapacity() - tBus.getFluidAmount(); - aOutputHatches.add(new Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer>(tBus, tBus.getFluid(), aSpaceLeft)); - } - } - // Create a map of all the fluids we would like to output, we can iterate over this and see how many we can merge into existing hatch stacks. - ArrayList<FluidStack> aOutputFluids = new ArrayList<FluidStack>(); - // Ugly ass boxing - aOutputFluids.addAll(new AutoMap<FluidStack>(aFluidOutputs)); - // Iterate the Hatches, updating their 'stored' data. - //for (Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer> aHatchData : aOutputHatches) { - for (int i = 0;i<aOutputHatches.size();i++) { - // The Hatch Itself - GT_MetaTileEntity_Hatch_Output aHatch = aOutputHatches.get(i).getValue_1(); - // Fluid in the Hatch - FluidStack aHatchStack = aOutputHatches.get(i).getValue_2(); - // Fluid that the hatch is locked to - String aHatchLockedFluid = aOutputHatches.get(i).getValue_1().getLockedFluidName(); - // Space left in Hatch - int aSpaceLeftInHatch = aHatch.getCapacity() - aHatch.getFluidAmount(); - // Hatch is full, - if (aSpaceLeftInHatch <= 0) { - aFullFluidHatches++; - aOutputHatches.remove(aOutputHatches.get(i)); - i--; - continue; - } - // Hatch has space - else { - // Check if any fluids match - //aFluidMatch: for (FluidStack aOutputStack : aOutputFluids) { - for(int j = 0;j<aOutputFluids.size();j++) { - //log(" aHatchStack "+aHatchStack.getLocalizedName()+" aOutput stack "+aOutputStack.getLocalizedName()); - if (GT_Utility.areFluidsEqual(aHatchStack, aOutputFluids.get(j)) && (aHatchLockedFluid == null || aHatchLockedFluid.equals(aOutputFluids.get(j).getFluid().getName()))) { - int aFluidToPutIntoHatch = aOutputFluids.get(j).amount * aParallelRecipes; - // Not Enough space to insert all of the fluid. - // We fill this hatch and add a smaller Fluidstack back to the iterator. - if (aSpaceLeftInHatch < aFluidToPutIntoHatch) { - // Copy existing Hatch Stack - FluidStack aNewHatchStack = aHatchStack.copy(); - aNewHatchStack.amount = 0; - // Copy existing Hatch Stack again - FluidStack aNewOutputStack = aHatchStack.copy(); - aNewOutputStack.amount = 0; - // How much fluid do we have left after we fill the hatch? - int aFluidLeftAfterInsert = aFluidToPutIntoHatch - aSpaceLeftInHatch; - // Set new stacks to appropriate values - aNewHatchStack.amount = aHatch.getCapacity(); - aNewOutputStack.amount = aFluidLeftAfterInsert; - // Remove fluid from output list, merge success - aOutputFluids.remove(aOutputFluids.get(j)); - j--; - // Remove hatch from hatch list, data is now invalid. - aOutputHatches.remove(aOutputHatches.get(i)); - i--; - // Add remaining Fluid to Output list - aOutputFluids.add(aNewOutputStack); - // Re-add hatch to hatch list, with new data. - //Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer> aNewHatchData = new Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer>(aHatch, aNewHatchStack, aNewHatchStack.amount); - //aOutputHatches.add(aNewHatchData); - break; - } - // We can fill this hatch perfectly (rare case), may as well add it directly to the full list. - else if (aSpaceLeftInHatch == aFluidToPutIntoHatch) { - // Copy Old Stack - FluidStack aNewHatchStack = aHatchStack.copy(); - // Add in amount from output stack - aNewHatchStack.amount += aFluidToPutIntoHatch; - // Remove fluid from output list, merge success - aOutputFluids.remove(aOutputFluids.get(j)); - j--; - // Remove hatch from hatch list, data is now invalid. - aOutputHatches.remove(aOutputHatches.get(i)); - i--; - // Re-add hatch to hatch list, with new data. - Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer> aNewHatchData = new Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer>(aHatch, aNewHatchStack, aNewHatchStack.amount); - aOutputHatches.add(aNewHatchData); - break; - } - // We have more space than we need to merge, so we remove the stack from the output list and update the hatch list. - else { - // Copy Old Stack - FluidStack aNewHatchStack = aHatchStack.copy(); - // Add in amount from output stack - aNewHatchStack.amount += aFluidToPutIntoHatch; - // Remove fluid from output list, merge success - aOutputFluids.remove(aOutputFluids.get(j)); - j--; - // Remove hatch from hatch list, data is now invalid. - aOutputHatches.remove(aOutputHatches.get(i)); - i--; - // Re-add hatch to hatch list, with new data. - Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer> aNewHatchData = new Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer>(aHatch, aNewHatchStack, aNewHatchStack.amount); - aOutputHatches.add(aNewHatchData); - // Check next fluid - continue; - } - - } - else if (aHatchLockedFluid == null || aHatchLockedFluid.equals(aOutputFluids.get(j).getFluid().getName())) { - aEmptyFluidHatches++; - } - else { - continue; - } - } - } - } - - for (Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer> aFreeHatchCheck : aOutputHatches) { - // Free Hatch - if ((aFreeHatchCheck.getValue_2() == null || aFreeHatchCheck.getValue_3() == 0 || aFreeHatchCheck.getValue_1().getFluid() == null) && !aFreeHatchCheck.getValue_1().isFluidLocked()) { - aEmptyFluidHatches++; - } - } - - // We have Fluid Stacks we did not merge. Do we have space? - log("fluids to output "+aOutputFluids.size()+" empty hatches "+aEmptyFluidHatches); - if (aOutputFluids.size() > 0) { - // Not enough space to add fluids. - if (aOutputFluids.size() > aEmptyFluidHatches) { - aParallelRecipes = (int) Math.floor((double) aEmptyFluidHatches/aOutputFluids.size() * aParallelRecipes); - log("Failed to find enough space for all fluid outputs. Free: "+aEmptyFluidHatches+", Required: "+aOutputFluids.size()); - return 0; - - } - } - - /* - * End Fluid Management - */ - } - - return aParallelRecipes; - } - - /** - * A Static {@link Method} object which holds the current status of logging. - */ - public static Method aLogger = null; - - public void log(String s) { - if (!AsmConfig.disableAllLogging) { - if (CORE_Preloader.DEBUG_MODE) { - Logger.INFO(s); - } else { - Logger.MACHINE_INFO(s); - } - } - } - - public boolean checkRecipeGeneric() { - return checkRecipeGeneric(1, 100, 0); - } - - public boolean checkRecipeGeneric(int aMaxParallelRecipes, long aEUPercent, int aSpeedBonusPercent) { - return checkRecipeGeneric(aMaxParallelRecipes, aEUPercent, aSpeedBonusPercent, 10000); - } - - public boolean checkRecipeGeneric(int aMaxParallelRecipes, long aEUPercent, int aSpeedBonusPercent, int aOutputChanceRoll) { - ArrayList<ItemStack> tItems = getStoredInputs(); - ArrayList<FluidStack> tFluids = getStoredFluids(); - ItemStack[] tItemInputs = tItems.toArray(new ItemStack[tItems.size()]); - FluidStack[] tFluidInputs = tFluids.toArray(new FluidStack[tFluids.size()]); - return checkRecipeGeneric(tItemInputs, tFluidInputs, aMaxParallelRecipes, aEUPercent, aSpeedBonusPercent, aOutputChanceRoll); - } - - public boolean checkRecipeGeneric(GT_Recipe aRecipe, - int aMaxParallelRecipes, long aEUPercent, - int aSpeedBonusPercent, int aOutputChanceRoll) { - if (aRecipe == null) { - return false; - } - ArrayList<ItemStack> tItems = getStoredInputs(); - ArrayList<FluidStack> tFluids = getStoredFluids(); - ItemStack[] tItemInputs = tItems.toArray(new ItemStack[tItems.size()]); - FluidStack[] tFluidInputs = tFluids.toArray(new FluidStack[tFluids.size()]); - return checkRecipeGeneric(tItemInputs, tFluidInputs, aMaxParallelRecipes, aEUPercent, aSpeedBonusPercent, aOutputChanceRoll, aRecipe); - } - - public boolean checkRecipeGeneric( - ItemStack[] aItemInputs, FluidStack[] aFluidInputs, - int aMaxParallelRecipes, long aEUPercent, - int aSpeedBonusPercent, int aOutputChanceRoll) { - return checkRecipeGeneric(aItemInputs, aFluidInputs, aMaxParallelRecipes, aEUPercent, aSpeedBonusPercent, aOutputChanceRoll, null); - } - - - /* - * public boolean checkRecipeGeneric( ItemStack[] aItemInputs, FluidStack[] - * aFluidInputs, int aMaxParallelRecipes, int aEUPercent, int - * aSpeedBonusPercent, int aOutputChanceRoll, GT_Recipe aRecipe) { // Based on - * the Processing Array. A bit overkill, but very flexible. - * - * - * if (this.doesMachineBoostOutput()) { log("Boosting."); return - * checkRecipeBoostedOutputs(aItemInputs, aFluidInputs, aMaxParallelRecipes, - * aEUPercent, aSpeedBonusPercent, aOutputChanceRoll, aRecipe); } - * - * - * //Control Core to control the Multiblocks behaviour. int aControlCoreTier = - * getControlCoreTier(); - * - * //If no core, return false; if (aControlCoreTier > 0) { - * log("Control core found."); } - * - * - * // Reset outputs and progress stats this.mEUt = 0; this.mMaxProgresstime = 0; - * this.mOutputItems = new ItemStack[]{}; this.mOutputFluids = new - * FluidStack[]{}; - * - * long tVoltage = getMaxInputVoltage(); byte tTier = (byte) Math.max(1, - * GT_Utility.getTier(tVoltage)); log("Running checkRecipeGeneric(0)"); - * - * //Check to see if Voltage Tier > Control Core Tier if (tTier > - * aControlCoreTier) { - * log("Control core found is lower tier than power tier. OK"); tTier = (byte) - * aControlCoreTier; } - * - * tTier = (byte) MathUtils.getValueWithinRange(tTier, 0, 9); - * - * GT_Recipe tRecipe = aRecipe != null ? aRecipe : findRecipe( - * getBaseMetaTileEntity(), mLastRecipe, false, - * gregtech.api.enums.GT_Values.V[tTier], aFluidInputs, aItemInputs); - * - * log("Running checkRecipeGeneric(1)"); // Remember last recipe - an - * optimization for findRecipe() this.mLastRecipe = tRecipe; - * - * if (tRecipe == null) { log("BAD RETURN - 1"); return false; } - * - * if (!this.canBufferOutputs(tRecipe, aMaxParallelRecipes)) { - * log("BAD RETURN - 2"); return false; } - * - * // EU discount float tRecipeEUt = (tRecipe.mEUt * aEUPercent) / 100.0f; float - * tTotalEUt = 0.0f; - * - * int parallelRecipes = 0; - * - * log("parallelRecipes: "+parallelRecipes); - * log("aMaxParallelRecipes: "+aMaxParallelRecipes); - * log("tTotalEUt: "+tTotalEUt); log("tVoltage: "+tVoltage); - * log("tRecipeEUt: "+tRecipeEUt); log("EU1: "+tRecipeEUt); // Count - * recipes to do in parallel, consuming input items and fluids and considering - * input voltage limits for (; parallelRecipes < aMaxParallelRecipes && - * tTotalEUt < (tVoltage - tRecipeEUt); parallelRecipes++) { if - * (!tRecipe.isRecipeInputEqual(true, aFluidInputs, aItemInputs)) { - * log("Broke at "+parallelRecipes+"."); break; } - * log("Bumped EU from "+tTotalEUt+" to "+(tTotalEUt+tRecipeEUt)+"."); tTotalEUt - * += tRecipeEUt; log("EU2: "+tTotalEUt); } - * - * if (parallelRecipes == 0) { log("BAD RETURN - 3"); return false; } - * - * log("EU3: "+tTotalEUt); - * - * // -- Try not to fail after this point - inputs have already been consumed! - * -- - * - * - * // Convert speed bonus to duration multiplier // e.g. 100% speed bonus = 200% - * speed = 100%/200% = 50% recipe duration. aSpeedBonusPercent = Math.max(-99, - * aSpeedBonusPercent); float tTimeFactor = 100.0f / (100.0f + - * aSpeedBonusPercent); this.mMaxProgresstime = (int)(tRecipe.mDuration * - * tTimeFactor * 10000); - * - * int aTempEu = (int) Math.floor(tTotalEUt); log("EU4: "+aTempEu); - * this.mEUt = (int) aTempEu; - * - * - * this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - * this.mEfficiencyIncrease = 10000; - * - * // Overclock if (this.mEUt <= 16) { this.mEUt = (this.mEUt * (1 << tTier - 1) - * * (1 << tTier - 1)); this.mMaxProgresstime = (this.mMaxProgresstime / (1 << - * tTier - 1)); } else { while (this.mEUt <= - * gregtech.api.enums.GT_Values.V[(tTier - 1)]) { this.mEUt *= 4; - * this.mMaxProgresstime /= 2; } } - * - * if (this.mEUt > 0) { this.mEUt = (-this.mEUt); } - * - * this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - * - * // Collect fluid outputs FluidStack[] tOutputFluids = new - * FluidStack[tRecipe.mFluidOutputs.length]; for (int h = 0; h < - * tRecipe.mFluidOutputs.length; h++) { if (tRecipe.getFluidOutput(h) != null) { - * tOutputFluids[h] = tRecipe.getFluidOutput(h).copy(); tOutputFluids[h].amount - * *= parallelRecipes; } } - * - * // 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 < parallelRecipes; 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(); - * - * log("GOOD RETURN - 1"); return true; } - */ - - public long getMaxInputEnergy() { - long rEnergy = 0; - if (mEnergyHatches.size() == 1) // so it only takes 1 amp is only 1 hatch is present so it works like most gt multies - return mEnergyHatches.get(0).getBaseMetaTileEntity().getInputVoltage(); + public static boolean isValidMetaTileEntity(final MetaTileEntity aMetaTileEntity) { + return (aMetaTileEntity.getBaseMetaTileEntity() != null) + && (aMetaTileEntity.getBaseMetaTileEntity().getMetaTileEntity() == aMetaTileEntity) + && !aMetaTileEntity.getBaseMetaTileEntity().isDead(); + } + + public abstract boolean hasSlotInGUI(); + + public long getTotalRuntimeInTicks() { + return this.mTotalRunTime; + } + + @Override + public Object getServerGUI( + final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + if (hasSlotInGUI()) { + return new GT_Container_MultiMachine(aPlayerInventory, aBaseMetaTileEntity); + } else { + String aCustomGUI = getCustomGUIResourceName(); + if (aCustomGUI == null) { + return new CONTAINER_MultiMachine_NoPlayerInventory(aPlayerInventory, aBaseMetaTileEntity); + } else { + return new CONTAINER_MultiMachine(aPlayerInventory, aBaseMetaTileEntity); + } + } + } + + public abstract String getCustomGUIResourceName(); + + public boolean requiresVanillaGtGUI() { + return false; + } + + @Override + public Object getClientGUI( + final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + String aCustomGUI = getCustomGUIResourceName(); + aCustomGUI = + aCustomGUI != null ? aCustomGUI : hasSlotInGUI() ? "MultiblockDisplay" : "MultiblockDisplay_Generic"; + aCustomGUI = aCustomGUI + ".png"; + if (hasSlotInGUI()) { + if (!requiresVanillaGtGUI()) { + return new GUI_Multi_Basic_Slotted( + aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), aCustomGUI); + } else { + return new GT_GUIContainer_MultiMachine( + aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), aCustomGUI); + } + } else { + if (getCustomGUIResourceName() == null && !hasSlotInGUI()) { + return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), aCustomGUI); + } else { + return new GUI_MultiMachine_Default( + aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), aCustomGUI); + } + } + } + + public abstract String getMachineType(); + + public String getMachineTooltip() { + return "Machine Type: " + EnumChatFormatting.YELLOW + getMachineType() + EnumChatFormatting.RESET; + } + + public String[] getExtraInfoData() { + return new String[0]; + } + ; + + @Override + public final String[] getInfoData() { + ArrayList<String> mInfo = new ArrayList<String>(); + try { + if (!this.getMetaName().equals("")) { + mInfo.add(this.getMetaName()); + } + + String[] extra = getExtraInfoData(); + + if (extra == null) { + extra = new String[0]; + } + if (extra.length > 0) { + for (String s : extra) { + mInfo.add(s); + } + } + + long seconds = (this.mTotalRunTime / 20); + int weeks = (int) (TimeUnit.SECONDS.toDays(seconds) / 7); + int days = (int) (TimeUnit.SECONDS.toDays(seconds) - 7 * weeks); + long hours = + TimeUnit.SECONDS.toHours(seconds) - TimeUnit.DAYS.toHours(days) - TimeUnit.DAYS.toHours(7 * weeks); + long minutes = TimeUnit.SECONDS.toMinutes(seconds) - (TimeUnit.SECONDS.toHours(seconds) * 60); + long second = TimeUnit.SECONDS.toSeconds(seconds) - (TimeUnit.SECONDS.toMinutes(seconds) * 60); + + mInfo.add(getMachineTooltip()); + + // Lets borrow the GTNH handling + + mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.progress") + ": " + EnumChatFormatting.GREEN + + Integer.toString(mProgresstime / 20) + EnumChatFormatting.RESET + " s / " + + EnumChatFormatting.YELLOW + + Integer.toString(mMaxProgresstime / 20) + EnumChatFormatting.RESET + " s"); + + if (!this.mAllEnergyHatches.isEmpty()) { + long storedEnergy = getStoredEnergyInAllEnergyHatches(); + long maxEnergy = getMaxEnergyStorageOfAllEnergyHatches(); + mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.energy") + ":"); + mInfo.add(StatCollector.translateToLocal("" + EnumChatFormatting.GREEN + Long.toString(storedEnergy) + + EnumChatFormatting.RESET + " EU / " + EnumChatFormatting.YELLOW + Long.toString(maxEnergy) + + EnumChatFormatting.RESET + " EU")); + + mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.mei") + ":"); + mInfo.add(StatCollector.translateToLocal("" + EnumChatFormatting.YELLOW + + Long.toString(getMaxInputVoltage()) + EnumChatFormatting.RESET + " EU/t(*2A) " + + StatCollector.translateToLocal("GTPP.machines.tier") + ": " + EnumChatFormatting.YELLOW + + GT_Values.VN[GT_Utility.getTier(getMaxInputVoltage())] + EnumChatFormatting.RESET)); + ; + } + if (!this.mAllDynamoHatches.isEmpty()) { + long storedEnergy = getStoredEnergyInAllDynamoHatches(); + long maxEnergy = getMaxEnergyStorageOfAllDynamoHatches(); + mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.energy") + " In Dynamos:"); + mInfo.add(StatCollector.translateToLocal("" + EnumChatFormatting.GREEN + Long.toString(storedEnergy) + + EnumChatFormatting.RESET + " EU / " + EnumChatFormatting.YELLOW + Long.toString(maxEnergy) + + EnumChatFormatting.RESET + " EU")); + } + + if (-mEUt > 0) { + mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.usage") + ":"); + mInfo.add(StatCollector.translateToLocal( + "" + EnumChatFormatting.RED + Integer.toString(-mEUt) + EnumChatFormatting.RESET + " EU/t")); + } else { + mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.generation") + ":"); + mInfo.add(StatCollector.translateToLocal( + "" + EnumChatFormatting.GREEN + Integer.toString(mEUt) + EnumChatFormatting.RESET + " EU/t")); + } + + mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.problems") + ": " + EnumChatFormatting.RED + + (getIdealStatus() - getRepairStatus()) + EnumChatFormatting.RESET + " " + + StatCollector.translateToLocal("GTPP.multiblock.efficiency") + ": " + EnumChatFormatting.YELLOW + + Float.toString(mEfficiency / 100.0F) + EnumChatFormatting.RESET + " %"); + + if (this.getPollutionPerSecond(null) > 0) { + int mPollutionReduction = getPollutionReductionForAllMufflers(); + mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.pollution") + ": " + EnumChatFormatting.RED + + this.getPollutionPerSecond(null) + EnumChatFormatting.RESET + "/sec"); + mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.pollutionreduced") + ": " + + EnumChatFormatting.GREEN + mPollutionReduction + EnumChatFormatting.RESET + " %"); + } + + if (this.mControlCoreBus.size() > 0) { + int tTier = this.getControlCoreTier(); + mInfo.add(StatCollector.translateToLocal("GTPP.CC.machinetier") + ": " + EnumChatFormatting.GREEN + + tTier + EnumChatFormatting.RESET); + } + + mInfo.add(StatCollector.translateToLocal("GTPP.CC.discount") + ": " + EnumChatFormatting.GREEN + + (getEuDiscountForParallelism()) + EnumChatFormatting.RESET + "%"); + + mInfo.add(StatCollector.translateToLocal("GTPP.CC.parallel") + ": " + EnumChatFormatting.GREEN + + (getMaxParallelRecipes()) + EnumChatFormatting.RESET); + + mInfo.add("Total Time Since Built: " + EnumChatFormatting.DARK_GREEN + Integer.toString(weeks) + + EnumChatFormatting.RESET + " Weeks, " + EnumChatFormatting.DARK_GREEN + Integer.toString(days) + + EnumChatFormatting.RESET + " Days, "); + mInfo.add(EnumChatFormatting.DARK_GREEN + Long.toString(hours) + EnumChatFormatting.RESET + " Hours, " + + EnumChatFormatting.DARK_GREEN + Long.toString(minutes) + EnumChatFormatting.RESET + " Minutes, " + + EnumChatFormatting.DARK_GREEN + Long.toString(second) + EnumChatFormatting.RESET + " Seconds."); + mInfo.add("Total Time in ticks: " + EnumChatFormatting.DARK_GREEN + Long.toString(this.mTotalRunTime)); + + String[] mInfo2 = mInfo.toArray(new String[mInfo.size()]); + return mInfo2; + } catch (Throwable t) { + t.printStackTrace(); + } + return new String[] {}; + } + + public int getPollutionReductionForAllMufflers() { + int mPollutionReduction = 0; + for (GT_MetaTileEntity_Hatch_Muffler tHatch : mMufflerHatches) { + if (isValidMetaTileEntity(tHatch)) { + mPollutionReduction = Math.max(calculatePollutionReductionForHatch(tHatch, 100), mPollutionReduction); + } + } + return mPollutionReduction; + } + + public long getStoredEnergyInAllEnergyHatches() { + long storedEnergy = 0; + for (GT_MetaTileEntity_Hatch tHatch : mAllEnergyHatches) { + if (isValidMetaTileEntity(tHatch)) { + storedEnergy += tHatch.getBaseMetaTileEntity().getStoredEU(); + } + } + return storedEnergy; + } + + public long getMaxEnergyStorageOfAllEnergyHatches() { + long maxEnergy = 0; + for (GT_MetaTileEntity_Hatch tHatch : mAllEnergyHatches) { + if (isValidMetaTileEntity(tHatch)) { + maxEnergy += tHatch.getBaseMetaTileEntity().getEUCapacity(); + } + } + return maxEnergy; + } + + public long getStoredEnergyInAllDynamoHatches() { + long storedEnergy = 0; + for (GT_MetaTileEntity_Hatch tHatch : mAllDynamoHatches) { + if (isValidMetaTileEntity(tHatch)) { + storedEnergy += tHatch.getBaseMetaTileEntity().getStoredEU(); + } + } + return storedEnergy; + } + + public long getMaxEnergyStorageOfAllDynamoHatches() { + long maxEnergy = 0; + for (GT_MetaTileEntity_Hatch tHatch : mAllDynamoHatches) { + if (isValidMetaTileEntity(tHatch)) { + maxEnergy += tHatch.getBaseMetaTileEntity().getEUCapacity(); + } + } + return maxEnergy; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + private String[] aCachedToolTip; + + /*private final String aRequiresMuffler = "1x Muffler Hatch"; + private final String aRequiresCoreModule = "1x Core Module"; + private final String aRequiresMaint = "1x Maintanence Hatch";*/ + + public static final String TAG_HIDE_HATCHES = "TAG_HIDE_HATCHES"; + public static final String TAG_HIDE_MAINT = "TAG_HIDE_MAINT"; + public static final String TAG_HIDE_POLLUTION = "TAG_HIDE_POLLUTION"; + public static final String TAG_HIDE_MACHINE_TYPE = "TAG_HIDE_MACHINE_TYPE"; + + public int getAmountOfOutputs() { + return 1; + } + + public abstract int getMaxParallelRecipes(); + + public abstract int getEuDiscountForParallelism(); + + @Override + public boolean isCorrectMachinePart(final ItemStack paramItemStack) { + return true; + } + + @Override + public int getDamageToComponent(final ItemStack paramItemStack) { + return 0; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack p0) { + return false; + } + + @Override + public void startSoundLoop(final byte aIndex, final double aX, final double aY, final double aZ) { + super.startSoundLoop(aIndex, aX, aY, aZ); + if (aIndex == 1) { + GT_Utility.doSoundAtClient(getSound(), 10, 1.0F, aX, aY, aZ); + } + } + + public void startProcess() { + if (GT_Utility.isStringValid(getSound())) this.sendLoopStart((byte) 1); + } + + public String getSound() { + return ""; + } + + public int canBufferOutputs(final GT_Recipe aRecipe, int aParallelRecipes) { + return canBufferOutputs(aRecipe, aParallelRecipes, true); + } + + public int canBufferOutputs(final GT_Recipe aRecipe, int aParallelRecipes, boolean aAllow16SlotWithoutCheck) { + // Null recipe or a recipe with lots of outputs? + // E.G. Gendustry custom comb with a billion centrifuge outputs? + // Do it anyway, provided the multi allows it. Default behaviour is aAllow16SlotWithoutCheck = true. + if (aRecipe == null || aRecipe.mOutputs.length > 16) { + if (aRecipe == null) { + return 0; + } else if (aRecipe.mOutputs.length > 16) { + if (aAllow16SlotWithoutCheck) { + return aParallelRecipes; + } else { + // Do nothing, we want to check this recipe properly. + } + } + } + return canBufferOutputs(aRecipe.mOutputs, aRecipe.mFluidOutputs, aParallelRecipes); + } + + public int canBufferOutputs(ItemStack[] aItemOutputs, FluidStack[] aFluidOutputs, int aParallelRecipes) { + if (mVoidExcess) return aParallelRecipes; + log("Determining if we have space to buffer outputs. Parallel: " + aParallelRecipes); + + // Do we even need to check for item outputs? + boolean aDoesOutputItems = aItemOutputs.length > 0; + // Do we even need to check for fluid outputs? + boolean aDoesOutputFluids = aFluidOutputs.length > 0; + + /* ======================================== + * Item Management + * ======================================== + */ + + if (aDoesOutputItems) { + log("We have items to output."); + + // How many slots are free across all the output buses? + int aInputBusSlotsFree = 0; + + /* + * Create Variables for Item Output + */ + + AutoMap<FlexiblePair<ItemStack, Integer>> aItemMap = new AutoMap<FlexiblePair<ItemStack, Integer>>(); + AutoMap<ItemStack> aOutputs = new AutoMap<ItemStack>(aItemOutputs); + + for (final GT_MetaTileEntity_Hatch_OutputBus tBus : this.mOutputBusses) { + if (!isValidMetaTileEntity(tBus)) { + continue; + } + final IInventory tBusInv = tBus.getBaseMetaTileEntity(); + for (int i = 0; i < tBusInv.getSizeInventory(); i++) { + if (tBus.getStackInSlot(i) == null) { + aInputBusSlotsFree++; + } else { + ItemStack aT = tBus.getStackInSlot(i); + int aSize = aT.stackSize; + aT = aT.copy(); + aT.stackSize = 0; + aItemMap.put(new FlexiblePair<ItemStack, Integer>(aT, aSize)); + } + } + } + + // A map to hold the items we will be 'inputting' into the output buses. These itemstacks are actually the + // recipe outputs. + ConcurrentSet<FlexiblePair<ItemStack, Integer>> aInputMap = + new ConcurrentHashSet<FlexiblePair<ItemStack, Integer>>(); + + // Iterate over the outputs, calculating require stack spacing they will require. + for (int i = 0; i < aOutputs.size(); i++) { + ItemStack aY = aOutputs.get(i); + if (aY == null) { + continue; + } else { + int aStackSize = aY.stackSize * aParallelRecipes; + + int aSlotsNeedsForThisStack = (int) Math.ceil((float) aStackSize / aY.getMaxStackSize()); + // Should round up and add as many stacks as required nicely. + for (int o = 0; o < aSlotsNeedsForThisStack; o++) { + if (aStackSize < 1) break; + int aStackToRemove = Math.min(aStackSize, aY.getMaxStackSize()); + aStackSize -= aStackToRemove; + aY = aY.copy(); + aY.stackSize = 0; + aInputMap.add(new FlexiblePair<ItemStack, Integer>(aY, aStackToRemove)); + } + } + } + + // We have items to add to the output buses. See if any are not full stacks and see if we can make them + // full. + if (aInputMap.size() > 0) { + // Iterate over the current stored items in the Output busses, if any match and are not full, we can try + // account for merging. + busItems: + for (FlexiblePair<ItemStack, Integer> y : aItemMap) { + // Iterate over the 'inputs', we can safely remove these as we go. + outputItems: + for (FlexiblePair<ItemStack, Integer> u : aInputMap) { + // Create local vars for readability. + ItemStack aOutputBusStack = y.getKey(); + ItemStack aOutputStack = u.getKey(); + // Stacks match, including NBT. + if (GT_Utility.areStacksEqual(aOutputBusStack, aOutputStack, false)) { + // Stack Matches, but it's full, continue. + if (aOutputBusStack.stackSize >= 64) { + // This stack is full, no point checking it. + continue busItems; + } else { + // We can merge these two stacks without any hassle. + if ((aOutputBusStack.stackSize + aOutputStack.stackSize) <= 64) { + // Update the stack size in the bus storage map. + y.setValue(aOutputBusStack.stackSize + aOutputStack.stackSize); + // Remove the 'input' stack from the recipe outputs, so we don't try count it again. + aInputMap.remove(u); + continue outputItems; + } + // Stack merging is too much, so we fill this stack, leave the remainder. + else { + int aRemainder = (aOutputBusStack.stackSize + aOutputStack.stackSize) - 64; + // Update the stack size in the bus storage map. + y.setValue(64); + // Create a new object to iterate over later, with the remainder data; + FlexiblePair<ItemStack, Integer> t = + new FlexiblePair<ItemStack, Integer>(u.getKey(), aRemainder); + // Remove the 'input' stack from the recipe outputs, so we don't try count it again. + aInputMap.remove(u); + // Add the remainder stack. + aInputMap.add(t); + continue outputItems; + } + } + } else { + continue outputItems; + } + } + } + } + + // We have stacks that did not merge, do we have space for them? + if (aInputMap.size() > 0) { + if (aInputMap.size() > aInputBusSlotsFree) { + aParallelRecipes = + (int) Math.floor((double) aInputBusSlotsFree / aInputMap.size() * aParallelRecipes); + // We do not have enough free slots in total to accommodate the remaining managed stacks. + log(" Free: " + aInputBusSlotsFree + ", Required: " + aInputMap.size()); + if (aParallelRecipes == 0) { + log("Failed to find enough space for all item outputs."); + return 0; + } + } + } + + /* + * End Item Management + */ + + } + + /* ======================================== + * Fluid Management + * ======================================== + */ + + if (aDoesOutputFluids) { + log("We have Fluids to output."); + // How many slots are free across all the output buses? + int aFluidHatches = 0; + int aEmptyFluidHatches = 0; + int aFullFluidHatches = 0; + // Create Map for Fluid Output + ArrayList<Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer>> aOutputHatches = + new ArrayList<Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer>>(); + for (final GT_MetaTileEntity_Hatch_Output tBus : this.mOutputHatches) { + if (!isValidMetaTileEntity(tBus)) { + continue; + } + aFluidHatches++; + // Map the Hatch with the space left for easy checking later. + if (tBus.getFluid() == null) { + aOutputHatches.add(new Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer>( + tBus, null, tBus.getCapacity())); + } else { + int aSpaceLeft = tBus.getCapacity() - tBus.getFluidAmount(); + aOutputHatches.add(new Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer>( + tBus, tBus.getFluid(), aSpaceLeft)); + } + } + // Create a map of all the fluids we would like to output, we can iterate over this and see how many we can + // merge into existing hatch stacks. + ArrayList<FluidStack> aOutputFluids = new ArrayList<FluidStack>(); + // Ugly ass boxing + aOutputFluids.addAll(new AutoMap<FluidStack>(aFluidOutputs)); + // Iterate the Hatches, updating their 'stored' data. + // for (Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer> aHatchData : aOutputHatches) { + for (int i = 0; i < aOutputHatches.size(); i++) { + // The Hatch Itself + GT_MetaTileEntity_Hatch_Output aHatch = aOutputHatches.get(i).getValue_1(); + // Fluid in the Hatch + FluidStack aHatchStack = aOutputHatches.get(i).getValue_2(); + // Fluid that the hatch is locked to + String aHatchLockedFluid = aOutputHatches.get(i).getValue_1().getLockedFluidName(); + // Space left in Hatch + int aSpaceLeftInHatch = aHatch.getCapacity() - aHatch.getFluidAmount(); + // Hatch is full, + if (aSpaceLeftInHatch <= 0) { + aFullFluidHatches++; + aOutputHatches.remove(aOutputHatches.get(i)); + i--; + continue; + } + // Hatch has space + else { + // Check if any fluids match + // aFluidMatch: for (FluidStack aOutputStack : aOutputFluids) { + for (int j = 0; j < aOutputFluids.size(); j++) { + // log(" aHatchStack "+aHatchStack.getLocalizedName()+" aOutput stack + // "+aOutputStack.getLocalizedName()); + if (GT_Utility.areFluidsEqual(aHatchStack, aOutputFluids.get(j)) + && (aHatchLockedFluid == null + || aHatchLockedFluid.equals( + aOutputFluids.get(j).getFluid().getName()))) { + int aFluidToPutIntoHatch = aOutputFluids.get(j).amount * aParallelRecipes; + // Not Enough space to insert all of the fluid. + // We fill this hatch and add a smaller Fluidstack back to the iterator. + if (aSpaceLeftInHatch < aFluidToPutIntoHatch) { + // Copy existing Hatch Stack + FluidStack aNewHatchStack = aHatchStack.copy(); + aNewHatchStack.amount = 0; + // Copy existing Hatch Stack again + FluidStack aNewOutputStack = aHatchStack.copy(); + aNewOutputStack.amount = 0; + // How much fluid do we have left after we fill the hatch? + int aFluidLeftAfterInsert = aFluidToPutIntoHatch - aSpaceLeftInHatch; + // Set new stacks to appropriate values + aNewHatchStack.amount = aHatch.getCapacity(); + aNewOutputStack.amount = aFluidLeftAfterInsert; + // Remove fluid from output list, merge success + aOutputFluids.remove(aOutputFluids.get(j)); + j--; + // Remove hatch from hatch list, data is now invalid. + aOutputHatches.remove(aOutputHatches.get(i)); + i--; + // Add remaining Fluid to Output list + aOutputFluids.add(aNewOutputStack); + // Re-add hatch to hatch list, with new data. + // Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer> aNewHatchData = new + // Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer>(aHatch, aNewHatchStack, + // aNewHatchStack.amount); + // aOutputHatches.add(aNewHatchData); + break; + } + // We can fill this hatch perfectly (rare case), may as well add it directly to the full + // list. + else if (aSpaceLeftInHatch == aFluidToPutIntoHatch) { + // Copy Old Stack + FluidStack aNewHatchStack = aHatchStack.copy(); + // Add in amount from output stack + aNewHatchStack.amount += aFluidToPutIntoHatch; + // Remove fluid from output list, merge success + aOutputFluids.remove(aOutputFluids.get(j)); + j--; + // Remove hatch from hatch list, data is now invalid. + aOutputHatches.remove(aOutputHatches.get(i)); + i--; + // Re-add hatch to hatch list, with new data. + Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer> aNewHatchData = + new Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer>( + aHatch, aNewHatchStack, aNewHatchStack.amount); + aOutputHatches.add(aNewHatchData); + break; + } + // We have more space than we need to merge, so we remove the stack from the output list and + // update the hatch list. + else { + // Copy Old Stack + FluidStack aNewHatchStack = aHatchStack.copy(); + // Add in amount from output stack + aNewHatchStack.amount += aFluidToPutIntoHatch; + // Remove fluid from output list, merge success + aOutputFluids.remove(aOutputFluids.get(j)); + j--; + // Remove hatch from hatch list, data is now invalid. + aOutputHatches.remove(aOutputHatches.get(i)); + i--; + // Re-add hatch to hatch list, with new data. + Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer> aNewHatchData = + new Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer>( + aHatch, aNewHatchStack, aNewHatchStack.amount); + aOutputHatches.add(aNewHatchData); + // Check next fluid + continue; + } + + } else if (aHatchLockedFluid == null + || aHatchLockedFluid.equals( + aOutputFluids.get(j).getFluid().getName())) { + aEmptyFluidHatches++; + } else { + continue; + } + } + } + } + + for (Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer> aFreeHatchCheck : aOutputHatches) { + // Free Hatch + if ((aFreeHatchCheck.getValue_2() == null + || aFreeHatchCheck.getValue_3() == 0 + || aFreeHatchCheck.getValue_1().getFluid() == null) + && !aFreeHatchCheck.getValue_1().isFluidLocked()) { + aEmptyFluidHatches++; + } + } + + // We have Fluid Stacks we did not merge. Do we have space? + log("fluids to output " + aOutputFluids.size() + " empty hatches " + aEmptyFluidHatches); + if (aOutputFluids.size() > 0) { + // Not enough space to add fluids. + if (aOutputFluids.size() > aEmptyFluidHatches) { + aParallelRecipes = + (int) Math.floor((double) aEmptyFluidHatches / aOutputFluids.size() * aParallelRecipes); + log("Failed to find enough space for all fluid outputs. Free: " + aEmptyFluidHatches + + ", Required: " + aOutputFluids.size()); + return 0; + } + } + + /* + * End Fluid Management + */ + } + + return aParallelRecipes; + } + + /** + * A Static {@link Method} object which holds the current status of logging. + */ + public static Method aLogger = null; + + public void log(String s) { + if (!AsmConfig.disableAllLogging) { + if (CORE_Preloader.DEBUG_MODE) { + Logger.INFO(s); + } else { + Logger.MACHINE_INFO(s); + } + } + } + + public boolean checkRecipeGeneric() { + return checkRecipeGeneric(1, 100, 0); + } + + public boolean checkRecipeGeneric(int aMaxParallelRecipes, long aEUPercent, int aSpeedBonusPercent) { + return checkRecipeGeneric(aMaxParallelRecipes, aEUPercent, aSpeedBonusPercent, 10000); + } + + public boolean checkRecipeGeneric( + int aMaxParallelRecipes, long aEUPercent, int aSpeedBonusPercent, int aOutputChanceRoll) { + ArrayList<ItemStack> tItems = getStoredInputs(); + ArrayList<FluidStack> tFluids = getStoredFluids(); + ItemStack[] tItemInputs = tItems.toArray(new ItemStack[tItems.size()]); + FluidStack[] tFluidInputs = tFluids.toArray(new FluidStack[tFluids.size()]); + return checkRecipeGeneric( + tItemInputs, tFluidInputs, aMaxParallelRecipes, aEUPercent, aSpeedBonusPercent, aOutputChanceRoll); + } + + public boolean checkRecipeGeneric( + GT_Recipe aRecipe, + int aMaxParallelRecipes, + long aEUPercent, + int aSpeedBonusPercent, + int aOutputChanceRoll) { + if (aRecipe == null) { + return false; + } + ArrayList<ItemStack> tItems = getStoredInputs(); + ArrayList<FluidStack> tFluids = getStoredFluids(); + ItemStack[] tItemInputs = tItems.toArray(new ItemStack[tItems.size()]); + FluidStack[] tFluidInputs = tFluids.toArray(new FluidStack[tFluids.size()]); + return checkRecipeGeneric( + tItemInputs, + tFluidInputs, + aMaxParallelRecipes, + aEUPercent, + aSpeedBonusPercent, + aOutputChanceRoll, + aRecipe); + } + + public boolean checkRecipeGeneric( + ItemStack[] aItemInputs, + FluidStack[] aFluidInputs, + int aMaxParallelRecipes, + long aEUPercent, + int aSpeedBonusPercent, + int aOutputChanceRoll) { + return checkRecipeGeneric( + aItemInputs, + aFluidInputs, + aMaxParallelRecipes, + aEUPercent, + aSpeedBonusPercent, + aOutputChanceRoll, + null); + } + + /* + * public boolean checkRecipeGeneric( ItemStack[] aItemInputs, FluidStack[] + * aFluidInputs, int aMaxParallelRecipes, int aEUPercent, int + * aSpeedBonusPercent, int aOutputChanceRoll, GT_Recipe aRecipe) { // Based on + * the Processing Array. A bit overkill, but very flexible. + * + * + * if (this.doesMachineBoostOutput()) { log("Boosting."); return + * checkRecipeBoostedOutputs(aItemInputs, aFluidInputs, aMaxParallelRecipes, + * aEUPercent, aSpeedBonusPercent, aOutputChanceRoll, aRecipe); } + * + * + * //Control Core to control the Multiblocks behaviour. int aControlCoreTier = + * getControlCoreTier(); + * + * //If no core, return false; if (aControlCoreTier > 0) { + * log("Control core found."); } + * + * + * // Reset outputs and progress stats this.mEUt = 0; this.mMaxProgresstime = 0; + * this.mOutputItems = new ItemStack[]{}; this.mOutputFluids = new + * FluidStack[]{}; + * + * long tVoltage = getMaxInputVoltage(); byte tTier = (byte) Math.max(1, + * GT_Utility.getTier(tVoltage)); log("Running checkRecipeGeneric(0)"); + * + * //Check to see if Voltage Tier > Control Core Tier if (tTier > + * aControlCoreTier) { + * log("Control core found is lower tier than power tier. OK"); tTier = (byte) + * aControlCoreTier; } + * + * tTier = (byte) MathUtils.getValueWithinRange(tTier, 0, 9); + * + * GT_Recipe tRecipe = aRecipe != null ? aRecipe : findRecipe( + * getBaseMetaTileEntity(), mLastRecipe, false, + * gregtech.api.enums.GT_Values.V[tTier], aFluidInputs, aItemInputs); + * + * log("Running checkRecipeGeneric(1)"); // Remember last recipe - an + * optimization for findRecipe() this.mLastRecipe = tRecipe; + * + * if (tRecipe == null) { log("BAD RETURN - 1"); return false; } + * + * if (!this.canBufferOutputs(tRecipe, aMaxParallelRecipes)) { + * log("BAD RETURN - 2"); return false; } + * + * // EU discount float tRecipeEUt = (tRecipe.mEUt * aEUPercent) / 100.0f; float + * tTotalEUt = 0.0f; + * + * int parallelRecipes = 0; + * + * log("parallelRecipes: "+parallelRecipes); + * log("aMaxParallelRecipes: "+aMaxParallelRecipes); + * log("tTotalEUt: "+tTotalEUt); log("tVoltage: "+tVoltage); + * log("tRecipeEUt: "+tRecipeEUt); log("EU1: "+tRecipeEUt); // Count + * recipes to do in parallel, consuming input items and fluids and considering + * input voltage limits for (; parallelRecipes < aMaxParallelRecipes && + * tTotalEUt < (tVoltage - tRecipeEUt); parallelRecipes++) { if + * (!tRecipe.isRecipeInputEqual(true, aFluidInputs, aItemInputs)) { + * log("Broke at "+parallelRecipes+"."); break; } + * log("Bumped EU from "+tTotalEUt+" to "+(tTotalEUt+tRecipeEUt)+"."); tTotalEUt + * += tRecipeEUt; log("EU2: "+tTotalEUt); } + * + * if (parallelRecipes == 0) { log("BAD RETURN - 3"); return false; } + * + * log("EU3: "+tTotalEUt); + * + * // -- Try not to fail after this point - inputs have already been consumed! + * -- + * + * + * // Convert speed bonus to duration multiplier // e.g. 100% speed bonus = 200% + * speed = 100%/200% = 50% recipe duration. aSpeedBonusPercent = Math.max(-99, + * aSpeedBonusPercent); float tTimeFactor = 100.0f / (100.0f + + * aSpeedBonusPercent); this.mMaxProgresstime = (int)(tRecipe.mDuration * + * tTimeFactor * 10000); + * + * int aTempEu = (int) Math.floor(tTotalEUt); log("EU4: "+aTempEu); + * this.mEUt = (int) aTempEu; + * + * + * this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + * this.mEfficiencyIncrease = 10000; + * + * // Overclock if (this.mEUt <= 16) { this.mEUt = (this.mEUt * (1 << tTier - 1) + * * (1 << tTier - 1)); this.mMaxProgresstime = (this.mMaxProgresstime / (1 << + * tTier - 1)); } else { while (this.mEUt <= + * gregtech.api.enums.GT_Values.V[(tTier - 1)]) { this.mEUt *= 4; + * this.mMaxProgresstime /= 2; } } + * + * if (this.mEUt > 0) { this.mEUt = (-this.mEUt); } + * + * this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + * + * // Collect fluid outputs FluidStack[] tOutputFluids = new + * FluidStack[tRecipe.mFluidOutputs.length]; for (int h = 0; h < + * tRecipe.mFluidOutputs.length; h++) { if (tRecipe.getFluidOutput(h) != null) { + * tOutputFluids[h] = tRecipe.getFluidOutput(h).copy(); tOutputFluids[h].amount + * *= parallelRecipes; } } + * + * // 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 < parallelRecipes; 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(); + * + * log("GOOD RETURN - 1"); return true; } + */ + + public long getMaxInputEnergy() { + long rEnergy = 0; + if (mEnergyHatches.size() + == 1) // so it only takes 1 amp is only 1 hatch is present so it works like most gt multies + return mEnergyHatches.get(0).getBaseMetaTileEntity().getInputVoltage(); for (GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches) - if (isValidMetaTileEntity(tHatch)) rEnergy += tHatch.getBaseMetaTileEntity().getInputVoltage() * tHatch.getBaseMetaTileEntity().getInputAmperage(); + if (isValidMetaTileEntity(tHatch)) + rEnergy += tHatch.getBaseMetaTileEntity().getInputVoltage() + * tHatch.getBaseMetaTileEntity().getInputAmperage(); return rEnergy; - } - - public boolean hasPerfectOverclock() { - return false; - } - - public boolean checkRecipeGeneric( - ItemStack[] aItemInputs, FluidStack[] aFluidInputs, - int aMaxParallelRecipes, long aEUPercent, - int aSpeedBonusPercent, int aOutputChanceRoll, GT_Recipe aRecipe) { - // Based on the Processing Array. A bit overkill, but very flexible. - - // Reset outputs and progress stats - this.mEUt = 0; - this.mMaxProgresstime = 0; - this.mOutputItems = new ItemStack[]{}; - this.mOutputFluids = new FluidStack[]{}; - - long tVoltage = getMaxInputVoltage(); - byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - long tEnergy = getMaxInputEnergy(); - log("Running checkRecipeGeneric(0)"); - - GT_Recipe tRecipe = findRecipe( - getBaseMetaTileEntity(), mLastRecipe, false, false, - gregtech.api.enums.GT_Values.V[tTier], aFluidInputs, aItemInputs); - - log("Running checkRecipeGeneric(1)"); - // Remember last recipe - an optimization for findRecipe() - this.mLastRecipe = tRecipe; - - if (tRecipe == null) { - log("BAD RETURN - 1"); - return false; - } - - - /* - * Check for Special Behaviours - */ - - // First populate the map if we need to. - if (mCustomBehviours.isEmpty()) { - mCustomBehviours.putAll(Multiblock_API.getSpecialBehaviourItemMap()); - } - - // We have a special slot object in the recipe - if (tRecipe.mSpecialItems != null) { - // The special slot is an item - if (tRecipe.mSpecialItems instanceof ItemStack) { - // Make an Itemstack instance of this. - ItemStack aSpecialStack = (ItemStack) tRecipe.mSpecialItems; - // Check if this item is in an input bus. - boolean aDidFindMatch = false; - for (ItemStack aInputItemsToCheck : aItemInputs) { - // If we find a matching stack, continue. - if (GT_Utility.areStacksEqual(aSpecialStack, aInputItemsToCheck, false)) { - // Iterate all special behaviour items, to see if we need to utilise one. - aDidFindMatch = true; - break; - } - } - // Try prevent needless iteration loops if we don't have the required inputs at all. - if (aDidFindMatch) { - // Iterate all special behaviour items, to see if we need to utilise one. - for (SpecialMultiBehaviour aBehaviours : mCustomBehviours.values()) { - // Found a match, let's adjust this recipe now. - if (aBehaviours.isTriggerItem(aSpecialStack)) { - // Adjust this recipe to suit special item - aMaxParallelRecipes = aBehaviours.getMaxParallelRecipes(); - aEUPercent = aBehaviours.getEUPercent(); - aSpeedBonusPercent = aBehaviours.getSpeedBonusPercent(); - aOutputChanceRoll = aBehaviours.getOutputChanceRoll(); - break; - } - } - } - } - } - - aMaxParallelRecipes = this.canBufferOutputs(tRecipe, aMaxParallelRecipes); - if (aMaxParallelRecipes == 0) { - log("BAD RETURN - 2"); - return false; - } - - // EU discount - float tRecipeEUt = (tRecipe.mEUt * aEUPercent) / 100.0f; - float tTotalEUt = 0.0f; - - int parallelRecipes = 0; - - log("parallelRecipes: "+parallelRecipes); - log("aMaxParallelRecipes: "+aMaxParallelRecipes); - log("tTotalEUt: "+tTotalEUt); - log("tVoltage: "+tVoltage); - log("tRecipeEUt: "+tRecipeEUt); - // Count recipes to do in parallel, consuming input items and fluids and considering input voltage limits - for (; parallelRecipes < aMaxParallelRecipes && tTotalEUt < (tEnergy - tRecipeEUt); parallelRecipes++) { - if (!tRecipe.isRecipeInputEqual(true, aFluidInputs, aItemInputs)) { - log("Broke at "+parallelRecipes+"."); - break; - } - log("Bumped EU from "+tTotalEUt+" to "+(tTotalEUt+tRecipeEUt)+"."); - tTotalEUt += tRecipeEUt; - } - - if (parallelRecipes == 0) { - log("BAD RETURN - 3"); - return false; - } - - // -- Try not to fail after this point - inputs have already been consumed! -- - - - - // Convert speed bonus to duration multiplier - // e.g. 100% speed bonus = 200% speed = 100%/200% = 50% recipe duration. - aSpeedBonusPercent = Math.max(-99, aSpeedBonusPercent); - float tTimeFactor = 100.0f / (100.0f + aSpeedBonusPercent); - this.mMaxProgresstime = (int)(tRecipe.mDuration * tTimeFactor); - - this.mEUt = (int)Math.ceil(tTotalEUt); - - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - - // Overclock - if (this.mEUt <= 16) { - this.mEUt = (this.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); - this.mMaxProgresstime = (this.mMaxProgresstime / (1 << tTier - 1)); - } else { - while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { - this.mEUt *= 4; - if (hasPerfectOverclock()) { - this.mMaxProgresstime /= 4; - } - else { - this.mMaxProgresstime /= 2; - } - } - } - - if (this.mEUt > 0) { - this.mEUt = (-this.mEUt); - } - - this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - - // Collect fluid outputs - FluidStack[] tOutputFluids = new FluidStack[tRecipe.mFluidOutputs.length]; - for (int h = 0; h < tRecipe.mFluidOutputs.length; h++) { - if (tRecipe.getFluidOutput(h) != null) { - tOutputFluids[h] = tRecipe.getFluidOutput(h).copy(); - tOutputFluids[h].amount *= parallelRecipes; - } - } - - // 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 < parallelRecipes; 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(); - - log("GOOD RETURN - 1"); - return true; - } - - - - - - /* - * Here we handle recipe boosting, which grants additional output %'s to recipes that do not have 100%. - */ - - private boolean mHasBoostedCurrentRecipe = false; - private GT_Recipe mBoostedRecipe = null; - private ItemStack[] mInputVerificationForBoosting = null; - - /** - * Does this machine boost it's output? - * @return - if true, gives additional % to output chances. - */ - protected boolean doesMachineBoostOutput() { - return false; - } - - - - private int boostOutput(int aAmount) { - if (aAmount <= 0) { - return 10000; - } - if (aAmount <= 250) { - aAmount += MathUtils.randInt(Math.max(aAmount/2, 1), aAmount*2); - } - else if (aAmount <= 500) { - aAmount += MathUtils.randInt(Math.max(aAmount/2, 1), aAmount*2); - } - else if (aAmount <= 750) { - aAmount += MathUtils.randInt(Math.max(aAmount/2, 1), aAmount*2); - } - else if (aAmount <= 1000) { - aAmount = (aAmount*2); - } - else if (aAmount <= 1500) { - aAmount = (aAmount*2); - } - else if (aAmount <= 2000) { - aAmount = (int) (aAmount*1.5); - } - else if (aAmount <= 3000) { - aAmount = (int) (aAmount*1.5); - } - else if (aAmount <= 4000) { - aAmount = (int) (aAmount*1.2); - } - else if (aAmount <= 5000) { - aAmount = (int) (aAmount*1.2); - } - else if (aAmount <= 7000) { - aAmount = (int) (aAmount*1.2); - } - else if (aAmount <= 9000) { - aAmount = (int) (aAmount*1.1); - } - return Math.min(10000, aAmount); - } - - public GT_Recipe generateAdditionalOutputForRecipe(GT_Recipe aRecipe) { - AutoMap<Integer> aNewChances = new AutoMap<Integer>(); - for (int chance : aRecipe.mChances) { - aNewChances.put(boostOutput(chance)); - } - GT_Recipe aClone = aRecipe.copy(); - int[] aTemp = new int[aNewChances.size()]; - int slot = 0; - for (int g : aNewChances) { - aTemp[slot] = g; - slot++; - } - aClone.mChances = aTemp; - return aClone; - } - - - /** - * Processes recipes but provides a bonus to the output % of items if they are < 100%. - * - * @param aItemInputs - * @param aFluidInputs - * @param aMaxParallelRecipes - * @param aEUPercent - * @param aSpeedBonusPercent - * @param aOutputChanceRoll - * @param aRecipe - * @return - */ - public boolean checkRecipeBoostedOutputs( - ItemStack[] aItemInputs, FluidStack[] aFluidInputs, - int aMaxParallelRecipes, long aEUPercent, - int aSpeedBonusPercent, int aOutputChanceRoll, GT_Recipe aRecipe) { - - long tVoltage = getMaxInputVoltage(); - byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - long tEnergy = getMaxInputEnergy(); - log("Running checkRecipeGeneric(0)"); - - GT_Recipe tRecipe = aRecipe != null ? aRecipe : findRecipe( - getBaseMetaTileEntity(), mLastRecipe, false, - gregtech.api.enums.GT_Values.V[tTier], aFluidInputs, aItemInputs); - - log("Running checkRecipeGeneric(1)"); - - //First we check whether or not we have an input cached for boosting. - //If not, we set it to the current recipe. - //If we do, we compare it against the current recipe, if thy are the same, we try return a boosted recipe, if not, we boost a new recipe. - boolean isRecipeInputTheSame = false; - - //No cached recipe inputs, assume first run. - if (mInputVerificationForBoosting == null) { - mInputVerificationForBoosting = tRecipe.mInputs; - isRecipeInputTheSame = true; - } - //If the inputs match, we are good. - else { - if (tRecipe.mInputs == mInputVerificationForBoosting) { - isRecipeInputTheSame = true; - } - else { - isRecipeInputTheSame = false; - } - } - - //Inputs are the same, let's see if there's a boosted version. - if (isRecipeInputTheSame) { - //Yes, let's just set that as the recipe - if (mHasBoostedCurrentRecipe && mBoostedRecipe != null) { - tRecipe = mBoostedRecipe; - } - //We have yet to generate a new boosted recipe - else { - GT_Recipe aBoostedRecipe = this.generateAdditionalOutputForRecipe(tRecipe); - if (aBoostedRecipe != null) { - mBoostedRecipe = aBoostedRecipe; - mHasBoostedCurrentRecipe = true; - tRecipe = mBoostedRecipe; - } - //Bad boost - else { - mBoostedRecipe = null; - mHasBoostedCurrentRecipe = false; - } - } - } - //We have changed inputs, so we should generate a new boosted recipe - else { - GT_Recipe aBoostedRecipe = this.generateAdditionalOutputForRecipe(tRecipe); - if (aBoostedRecipe != null) { - mBoostedRecipe = aBoostedRecipe; - mHasBoostedCurrentRecipe = true; - tRecipe = mBoostedRecipe; - } - //Bad boost - else { - mBoostedRecipe = null; - mHasBoostedCurrentRecipe = false; - } - } - - //Bad modify, let's just use the original recipe. - if (!mHasBoostedCurrentRecipe || mBoostedRecipe == null) { - tRecipe = aRecipe != null ? aRecipe : findRecipe( - getBaseMetaTileEntity(), mLastRecipe, false, false, - gregtech.api.enums.GT_Values.V[tTier], aFluidInputs, aItemInputs); - } - - // Remember last recipe - an optimization for findRecipe() - this.mLastRecipe = tRecipe; - - if (tRecipe == null) { - log("BAD RETURN - 1"); - return false; - } - - aMaxParallelRecipes = this.canBufferOutputs(tRecipe, aMaxParallelRecipes); - if (aMaxParallelRecipes == 0) { - log("BAD RETURN - 2"); - return false; - } - - // EU discount - float tRecipeEUt = (tRecipe.mEUt * aEUPercent) / 100.0f; - float tTotalEUt = 0.0f; - - int parallelRecipes = 0; - - log("parallelRecipes: "+parallelRecipes); - log("aMaxParallelRecipes: "+aMaxParallelRecipes); - log("tTotalEUt: "+tTotalEUt); - log("tVoltage: "+tVoltage); - log("tRecipeEUt: "+tRecipeEUt); - // Count recipes to do in parallel, consuming input items and fluids and considering input voltage limits - for (; parallelRecipes < aMaxParallelRecipes && tTotalEUt < (tEnergy - tRecipeEUt); parallelRecipes++) { - if (!tRecipe.isRecipeInputEqual(true, aFluidInputs, aItemInputs)) { - log("Broke at "+parallelRecipes+"."); - break; - } - log("Bumped EU from "+tTotalEUt+" to "+(tTotalEUt+tRecipeEUt)+"."); - tTotalEUt += tRecipeEUt; - } - - if (parallelRecipes == 0) { - log("BAD RETURN - 3"); - return false; - } - - // -- Try not to fail after this point - inputs have already been consumed! -- - - - // Convert speed bonus to duration multiplier - // e.g. 100% speed bonus = 200% speed = 100%/200% = 50% recipe duration. - aSpeedBonusPercent = Math.max(-99, aSpeedBonusPercent); - float tTimeFactor = 100.0f / (100.0f + aSpeedBonusPercent); - this.mMaxProgresstime = (int)(tRecipe.mDuration * tTimeFactor); - - this.mEUt = (int)Math.ceil(tTotalEUt); - - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - - // Overclock - if (this.mEUt <= 16) { - this.mEUt = (this.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); - this.mMaxProgresstime = (this.mMaxProgresstime / (1 << tTier - 1)); - } else { - while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { - this.mEUt *= 4; - this.mMaxProgresstime /= 2; - } - } + } - if (this.mEUt > 0) { - this.mEUt = (-this.mEUt); - } + public boolean hasPerfectOverclock() { + return false; + } - this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + public boolean checkRecipeGeneric( + ItemStack[] aItemInputs, + FluidStack[] aFluidInputs, + int aMaxParallelRecipes, + long aEUPercent, + int aSpeedBonusPercent, + int aOutputChanceRoll, + GT_Recipe aRecipe) { + // Based on the Processing Array. A bit overkill, but very flexible. + + // Reset outputs and progress stats + this.mEUt = 0; + this.mMaxProgresstime = 0; + this.mOutputItems = new ItemStack[] {}; + this.mOutputFluids = new FluidStack[] {}; + + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + long tEnergy = getMaxInputEnergy(); + log("Running checkRecipeGeneric(0)"); + + GT_Recipe tRecipe = findRecipe( + getBaseMetaTileEntity(), + mLastRecipe, + false, + false, + gregtech.api.enums.GT_Values.V[tTier], + aFluidInputs, + aItemInputs); + + log("Running checkRecipeGeneric(1)"); + // Remember last recipe - an optimization for findRecipe() + this.mLastRecipe = tRecipe; + + if (tRecipe == null) { + log("BAD RETURN - 1"); + return false; + } - // 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 *= parallelRecipes; - } - } + /* + * Check for Special Behaviours + */ - // 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; - } - } + // First populate the map if we need to. + if (mCustomBehviours.isEmpty()) { + mCustomBehviours.putAll(Multiblock_API.getSpecialBehaviourItemMap()); + } - // 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 < parallelRecipes; g++) { - if (getBaseMetaTileEntity().getRandomNumber(aOutputChanceRoll) < tRecipe.getOutputChance(f)) - tOutputItems[f].stackSize += tRecipe.mOutputs[f].stackSize; - } - } - } + // We have a special slot object in the recipe + if (tRecipe.mSpecialItems != null) { + // The special slot is an item + if (tRecipe.mSpecialItems instanceof ItemStack) { + // Make an Itemstack instance of this. + ItemStack aSpecialStack = (ItemStack) tRecipe.mSpecialItems; + // Check if this item is in an input bus. + boolean aDidFindMatch = false; + for (ItemStack aInputItemsToCheck : aItemInputs) { + // If we find a matching stack, continue. + if (GT_Utility.areStacksEqual(aSpecialStack, aInputItemsToCheck, false)) { + // Iterate all special behaviour items, to see if we need to utilise one. + aDidFindMatch = true; + break; + } + } + // Try prevent needless iteration loops if we don't have the required inputs at all. + if (aDidFindMatch) { + // Iterate all special behaviour items, to see if we need to utilise one. + for (SpecialMultiBehaviour aBehaviours : mCustomBehviours.values()) { + // Found a match, let's adjust this recipe now. + if (aBehaviours.isTriggerItem(aSpecialStack)) { + // Adjust this recipe to suit special item + aMaxParallelRecipes = aBehaviours.getMaxParallelRecipes(); + aEUPercent = aBehaviours.getEUPercent(); + aSpeedBonusPercent = aBehaviours.getSpeedBonusPercent(); + aOutputChanceRoll = aBehaviours.getOutputChanceRoll(); + break; + } + } + } + } + } - tOutputItems = removeNulls(tOutputItems); + aMaxParallelRecipes = this.canBufferOutputs(tRecipe, aMaxParallelRecipes); + if (aMaxParallelRecipes == 0) { + log("BAD RETURN - 2"); + return false; + } - // 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); - } - } + // EU discount + float tRecipeEUt = (tRecipe.mEUt * aEUPercent) / 100.0f; + float tTotalEUt = 0.0f; + + int parallelRecipes = 0; + + log("parallelRecipes: " + parallelRecipes); + log("aMaxParallelRecipes: " + aMaxParallelRecipes); + log("tTotalEUt: " + tTotalEUt); + log("tVoltage: " + tVoltage); + log("tRecipeEUt: " + tRecipeEUt); + // Count recipes to do in parallel, consuming input items and fluids and considering input voltage limits + for (; parallelRecipes < aMaxParallelRecipes && tTotalEUt < (tEnergy - tRecipeEUt); parallelRecipes++) { + if (!tRecipe.isRecipeInputEqual(true, aFluidInputs, aItemInputs)) { + log("Broke at " + parallelRecipes + "."); + break; + } + log("Bumped EU from " + tTotalEUt + " to " + (tTotalEUt + tRecipeEUt) + "."); + tTotalEUt += tRecipeEUt; + } - if (splitStacks.size() > 0) { - ItemStack[] tmp = new ItemStack[splitStacks.size()]; - tmp = splitStacks.toArray(tmp); - tOutputItems = ArrayUtils.addAll(tOutputItems, tmp); - } + if (parallelRecipes == 0) { + log("BAD RETURN - 3"); + return false; + } - // 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()]); + // -- Try not to fail after this point - inputs have already been consumed! -- + + // Convert speed bonus to duration multiplier + // e.g. 100% speed bonus = 200% speed = 100%/200% = 50% recipe duration. + aSpeedBonusPercent = Math.max(-99, aSpeedBonusPercent); + float tTimeFactor = 100.0f / (100.0f + aSpeedBonusPercent); + this.mMaxProgresstime = (int) (tRecipe.mDuration * tTimeFactor); + + this.mEUt = (int) Math.ceil(tTotalEUt); + + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + + // Overclock + if (this.mEUt <= 16) { + this.mEUt = (this.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); + this.mMaxProgresstime = (this.mMaxProgresstime / (1 << tTier - 1)); + } else { + while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { + this.mEUt *= 4; + if (hasPerfectOverclock()) { + this.mMaxProgresstime /= 4; + } else { + this.mMaxProgresstime /= 2; + } + } + } - // Commit outputs - this.mOutputItems = tOutputItems; - this.mOutputFluids = tOutputFluids; - updateSlots(); + if (this.mEUt > 0) { + this.mEUt = (-this.mEUt); + } - // Play sounds (GT++ addition - GT multiblocks play no sounds) - startProcess(); + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - log("GOOD RETURN - 1"); - return true; - } + // 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 *= parallelRecipes; + } + } + // 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 < parallelRecipes; 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(); + log("GOOD RETURN - 1"); + return true; + } + /* + * Here we handle recipe boosting, which grants additional output %'s to recipes that do not have 100%. + */ + private boolean mHasBoostedCurrentRecipe = false; + private GT_Recipe mBoostedRecipe = null; + private ItemStack[] mInputVerificationForBoosting = null; + /** + * Does this machine boost it's output? + * @return - if true, gives additional % to output chances. + */ + protected boolean doesMachineBoostOutput() { + return false; + } + private int boostOutput(int aAmount) { + if (aAmount <= 0) { + return 10000; + } + if (aAmount <= 250) { + aAmount += MathUtils.randInt(Math.max(aAmount / 2, 1), aAmount * 2); + } else if (aAmount <= 500) { + aAmount += MathUtils.randInt(Math.max(aAmount / 2, 1), aAmount * 2); + } else if (aAmount <= 750) { + aAmount += MathUtils.randInt(Math.max(aAmount / 2, 1), aAmount * 2); + } else if (aAmount <= 1000) { + aAmount = (aAmount * 2); + } else if (aAmount <= 1500) { + aAmount = (aAmount * 2); + } else if (aAmount <= 2000) { + aAmount = (int) (aAmount * 1.5); + } else if (aAmount <= 3000) { + aAmount = (int) (aAmount * 1.5); + } else if (aAmount <= 4000) { + aAmount = (int) (aAmount * 1.2); + } else if (aAmount <= 5000) { + aAmount = (int) (aAmount * 1.2); + } else if (aAmount <= 7000) { + aAmount = (int) (aAmount * 1.2); + } else if (aAmount <= 9000) { + aAmount = (int) (aAmount * 1.1); + } + return Math.min(10000, aAmount); + } + public GT_Recipe generateAdditionalOutputForRecipe(GT_Recipe aRecipe) { + AutoMap<Integer> aNewChances = new AutoMap<Integer>(); + for (int chance : aRecipe.mChances) { + aNewChances.put(boostOutput(chance)); + } + GT_Recipe aClone = aRecipe.copy(); + int[] aTemp = new int[aNewChances.size()]; + int slot = 0; + for (int g : aNewChances) { + aTemp[slot] = g; + slot++; + } + aClone.mChances = aTemp; + return aClone; + } + /** + * Processes recipes but provides a bonus to the output % of items if they are < 100%. + * + * @param aItemInputs + * @param aFluidInputs + * @param aMaxParallelRecipes + * @param aEUPercent + * @param aSpeedBonusPercent + * @param aOutputChanceRoll + * @param aRecipe + * @return + */ + public boolean checkRecipeBoostedOutputs( + ItemStack[] aItemInputs, + FluidStack[] aFluidInputs, + int aMaxParallelRecipes, + long aEUPercent, + int aSpeedBonusPercent, + int aOutputChanceRoll, + GT_Recipe aRecipe) { + + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + long tEnergy = getMaxInputEnergy(); + log("Running checkRecipeGeneric(0)"); + + GT_Recipe tRecipe = aRecipe != null + ? aRecipe + : findRecipe( + getBaseMetaTileEntity(), + mLastRecipe, + false, + gregtech.api.enums.GT_Values.V[tTier], + aFluidInputs, + aItemInputs); + + log("Running checkRecipeGeneric(1)"); + + // First we check whether or not we have an input cached for boosting. + // If not, we set it to the current recipe. + // If we do, we compare it against the current recipe, if thy are the same, we try return a boosted recipe, if + // not, we boost a new recipe. + boolean isRecipeInputTheSame = false; + + // No cached recipe inputs, assume first run. + if (mInputVerificationForBoosting == null) { + mInputVerificationForBoosting = tRecipe.mInputs; + isRecipeInputTheSame = true; + } + // If the inputs match, we are good. + else { + if (tRecipe.mInputs == mInputVerificationForBoosting) { + isRecipeInputTheSame = true; + } else { + isRecipeInputTheSame = false; + } + } + // Inputs are the same, let's see if there's a boosted version. + if (isRecipeInputTheSame) { + // Yes, let's just set that as the recipe + if (mHasBoostedCurrentRecipe && mBoostedRecipe != null) { + tRecipe = mBoostedRecipe; + } + // We have yet to generate a new boosted recipe + else { + GT_Recipe aBoostedRecipe = this.generateAdditionalOutputForRecipe(tRecipe); + if (aBoostedRecipe != null) { + mBoostedRecipe = aBoostedRecipe; + mHasBoostedCurrentRecipe = true; + tRecipe = mBoostedRecipe; + } + // Bad boost + else { + mBoostedRecipe = null; + mHasBoostedCurrentRecipe = false; + } + } + } + // We have changed inputs, so we should generate a new boosted recipe + else { + GT_Recipe aBoostedRecipe = this.generateAdditionalOutputForRecipe(tRecipe); + if (aBoostedRecipe != null) { + mBoostedRecipe = aBoostedRecipe; + mHasBoostedCurrentRecipe = true; + tRecipe = mBoostedRecipe; + } + // Bad boost + else { + mBoostedRecipe = null; + mHasBoostedCurrentRecipe = false; + } + } + + // Bad modify, let's just use the original recipe. + if (!mHasBoostedCurrentRecipe || mBoostedRecipe == null) { + tRecipe = aRecipe != null + ? aRecipe + : findRecipe( + getBaseMetaTileEntity(), + mLastRecipe, + false, + false, + gregtech.api.enums.GT_Values.V[tTier], + aFluidInputs, + aItemInputs); + } + + // Remember last recipe - an optimization for findRecipe() + this.mLastRecipe = tRecipe; + + if (tRecipe == null) { + log("BAD RETURN - 1"); + return false; + } + + aMaxParallelRecipes = this.canBufferOutputs(tRecipe, aMaxParallelRecipes); + if (aMaxParallelRecipes == 0) { + log("BAD RETURN - 2"); + return false; + } + + // EU discount + float tRecipeEUt = (tRecipe.mEUt * aEUPercent) / 100.0f; + float tTotalEUt = 0.0f; + + int parallelRecipes = 0; + + log("parallelRecipes: " + parallelRecipes); + log("aMaxParallelRecipes: " + aMaxParallelRecipes); + log("tTotalEUt: " + tTotalEUt); + log("tVoltage: " + tVoltage); + log("tRecipeEUt: " + tRecipeEUt); + // Count recipes to do in parallel, consuming input items and fluids and considering input voltage limits + for (; parallelRecipes < aMaxParallelRecipes && tTotalEUt < (tEnergy - tRecipeEUt); parallelRecipes++) { + if (!tRecipe.isRecipeInputEqual(true, aFluidInputs, aItemInputs)) { + log("Broke at " + parallelRecipes + "."); + break; + } + log("Bumped EU from " + tTotalEUt + " to " + (tTotalEUt + tRecipeEUt) + "."); + tTotalEUt += tRecipeEUt; + } + + if (parallelRecipes == 0) { + log("BAD RETURN - 3"); + return false; + } + + // -- Try not to fail after this point - inputs have already been consumed! -- + + // Convert speed bonus to duration multiplier + // e.g. 100% speed bonus = 200% speed = 100%/200% = 50% recipe duration. + aSpeedBonusPercent = Math.max(-99, aSpeedBonusPercent); + float tTimeFactor = 100.0f / (100.0f + aSpeedBonusPercent); + this.mMaxProgresstime = (int) (tRecipe.mDuration * tTimeFactor); + + this.mEUt = (int) Math.ceil(tTotalEUt); + + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + + // Overclock + if (this.mEUt <= 16) { + this.mEUt = (this.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); + this.mMaxProgresstime = (this.mMaxProgresstime / (1 << tTier - 1)); + } else { + while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { + this.mEUt *= 4; + this.mMaxProgresstime /= 2; + } + } + + if (this.mEUt > 0) { + this.mEUt = (-this.mEUt); + } + + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + + // Collect fluid outputs + FluidStack[] tOutputFluids = new FluidStack[tRecipe.mFluidOutputs.length]; + for (int h = 0; h < tRecipe.mFluidOutputs.length; h++) { + if (tRecipe.getFluidOutput(h) != null) { + tOutputFluids[h] = tRecipe.getFluidOutput(h).copy(); + tOutputFluids[h].amount *= parallelRecipes; + } + } + + // 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 < parallelRecipes; 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(); + log("GOOD RETURN - 1"); + return true; + } + public boolean isMachineRunning() { + boolean aRunning = this.getBaseMetaTileEntity().isActive(); + // log("Queried Multiblock is currently running: "+aRunning); + return aRunning; + } + @Override + public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { + // Time Counter + if (aBaseMetaTileEntity.isServerSide()) { + this.mTotalRunTime++; + } - public boolean isMachineRunning() { - boolean aRunning = this.getBaseMetaTileEntity().isActive(); - //log("Queried Multiblock is currently running: "+aRunning); - return aRunning; - } + if (aBaseMetaTileEntity.isServerSide()) { + if (this.mUpdate == 1 || this.mStartUpCheck == 1) { + this.mChargeHatches.clear(); + this.mDischargeHatches.clear(); + this.mControlCoreBus.clear(); + this.mAirIntakes.clear(); + this.mTecTechEnergyHatches.clear(); + this.mTecTechDynamoHatches.clear(); + this.mAllEnergyHatches.clear(); + this.mAllDynamoHatches.clear(); + } + } - @Override - public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, - final long aTick) { - - //Time Counter - if (aBaseMetaTileEntity.isServerSide()){ - this.mTotalRunTime++; - } + super.onPostTick(aBaseMetaTileEntity, aTick); + } - if (aBaseMetaTileEntity.isServerSide()) { - if (this.mUpdate == 1 || this.mStartUpCheck == 1) { - this.mChargeHatches.clear(); - this.mDischargeHatches.clear(); - this.mControlCoreBus.clear(); - this.mAirIntakes.clear(); - this.mTecTechEnergyHatches.clear(); - this.mTecTechDynamoHatches.clear(); - this.mAllEnergyHatches.clear(); - this.mAllDynamoHatches.clear(); - } - } + @Override + public void explodeMultiblock() { + MetaTileEntity tTileEntity; + for (final Iterator<GT_MetaTileEntity_Hatch_InputBattery> localIterator = this.mChargeHatches.iterator(); + localIterator.hasNext(); + tTileEntity.getBaseMetaTileEntity().doExplosion(gregtech.api.enums.GT_Values.V[8])) { + tTileEntity = localIterator.next(); + } + tTileEntity = null; + for (final Iterator<GT_MetaTileEntity_Hatch_OutputBattery> localIterator = this.mDischargeHatches.iterator(); + localIterator.hasNext(); + tTileEntity.getBaseMetaTileEntity().doExplosion(gregtech.api.enums.GT_Values.V[8])) { + tTileEntity = localIterator.next(); + } + tTileEntity = null; + for (final Iterator<GT_MetaTileEntity_Hatch> localIterator = this.mTecTechDynamoHatches.iterator(); + localIterator.hasNext(); + tTileEntity.getBaseMetaTileEntity().doExplosion(gregtech.api.enums.GT_Values.V[8])) { + tTileEntity = localIterator.next(); + } + tTileEntity = null; + for (final Iterator<GT_MetaTileEntity_Hatch> localIterator = this.mTecTechEnergyHatches.iterator(); + localIterator.hasNext(); + tTileEntity.getBaseMetaTileEntity().doExplosion(gregtech.api.enums.GT_Values.V[8])) { + tTileEntity = localIterator.next(); + } + super.explodeMultiblock(); + } - super.onPostTick(aBaseMetaTileEntity, aTick); - } + protected int getGUICircuit(ItemStack[] t) { + Item g = CI.getNumberedCircuit(0).getItem(); + ItemStack guiSlot = this.mInventory[1]; + int mMode = -1; + if (guiSlot != null && guiSlot.getItem() == g) { + this.mInternalCircuit = true; + return guiSlot.getItemDamage(); + } else { + this.mInternalCircuit = false; + } - @Override - public void explodeMultiblock() { - MetaTileEntity tTileEntity; - for (final Iterator<GT_MetaTileEntity_Hatch_InputBattery> localIterator = this.mChargeHatches - .iterator(); localIterator.hasNext(); tTileEntity - .getBaseMetaTileEntity() - .doExplosion(gregtech.api.enums.GT_Values.V[8])) { - tTileEntity = localIterator.next(); - } - tTileEntity = null; - for (final Iterator<GT_MetaTileEntity_Hatch_OutputBattery> localIterator = this.mDischargeHatches - .iterator(); localIterator.hasNext(); tTileEntity - .getBaseMetaTileEntity() - .doExplosion(gregtech.api.enums.GT_Values.V[8])) { - tTileEntity = localIterator.next(); - } - tTileEntity = null; - for (final Iterator<GT_MetaTileEntity_Hatch> localIterator = this.mTecTechDynamoHatches - .iterator(); localIterator.hasNext(); tTileEntity - .getBaseMetaTileEntity() - .doExplosion(gregtech.api.enums.GT_Values.V[8])) { - tTileEntity = localIterator.next(); - } - tTileEntity = null; - for (final Iterator<GT_MetaTileEntity_Hatch> localIterator = this.mTecTechEnergyHatches - .iterator(); localIterator.hasNext(); tTileEntity - .getBaseMetaTileEntity() - .doExplosion(gregtech.api.enums.GT_Values.V[8])) { - tTileEntity = localIterator.next(); - } + if (!this.mInternalCircuit) { + for (ItemStack j : t) { + if (j.getItem() == g) { + mMode = j.getItemDamage(); + break; + } + } + } + return mMode; + } + protected ItemStack getGUIItemStack() { + ItemStack guiSlot = this.mInventory[1]; + return guiSlot; + } + + protected boolean setGUIItemStack(ItemStack aNewGuiSlotContents) { + boolean result = false; + if (this.mInventory[1] == null) { + this.mInventory[1] = aNewGuiSlotContents != null ? aNewGuiSlotContents.copy() : null; + this.depleteInput(aNewGuiSlotContents); + this.updateSlots(); + result = true; + } + return result; + } + protected boolean clearGUIItemSlot() { + return setGUIItemStack(null); + } - super.explodeMultiblock(); - } + public ItemStack findItemInInventory(Item aSearchStack) { + return findItemInInventory(aSearchStack, 0); + } - protected int getGUICircuit(ItemStack[] t) { - Item g = CI.getNumberedCircuit(0).getItem(); - ItemStack guiSlot = this.mInventory[1]; - int mMode = -1; - if (guiSlot != null && guiSlot.getItem() == g) { - this.mInternalCircuit = true; - return guiSlot.getItemDamage(); - } - else { - this.mInternalCircuit = false; - } + public ItemStack findItemInInventory(Item aSearchStack, int aMeta) { + return findItemInInventory(ItemUtils.simpleMetaStack(aSearchStack, aMeta, 1)); + } - if (!this.mInternalCircuit) { - for (ItemStack j : t) { - if (j.getItem() == g) { - mMode = j.getItemDamage(); - break; - } - } - } - return mMode; - } - - protected ItemStack getGUIItemStack() { - ItemStack guiSlot = this.mInventory[1]; - return guiSlot; - } - - protected boolean setGUIItemStack(ItemStack aNewGuiSlotContents) { - boolean result = false; - if (this.mInventory[1] == null) { - this.mInventory[1] = aNewGuiSlotContents != null ? aNewGuiSlotContents.copy() : null; - this.depleteInput(aNewGuiSlotContents); - this.updateSlots(); - result = true; - } - return result; - } - - protected boolean clearGUIItemSlot() { - return setGUIItemStack(null); - } - - - public ItemStack findItemInInventory(Item aSearchStack) { - return findItemInInventory(aSearchStack, 0); - } - - public ItemStack findItemInInventory(Item aSearchStack, int aMeta) { - return findItemInInventory(ItemUtils.simpleMetaStack(aSearchStack, aMeta, 1)); - } - - public ItemStack findItemInInventory(ItemStack aSearchStack) { - if (aSearchStack != null && this.mInputBusses.size() > 0) { - for (GT_MetaTileEntity_Hatch_InputBus bus : this.mInputBusses) { - if (bus != null) { - for (ItemStack uStack : bus.mInventory) { - if (uStack != null) { - if (aSearchStack.getClass().isInstance(uStack.getItem())) { - return uStack; - } - } - } - } - } - } - return null; - } - - /** - * Deplete fluid input from a set of restricted hatches. This assumes these hatches can store nothing else but your - * expected fluid - */ - protected boolean depleteInputFromRestrictedHatches(Collection<GT_MetaTileEntity_Hatch_CustomFluidBase> aHatches, int aAmount) { + public ItemStack findItemInInventory(ItemStack aSearchStack) { + if (aSearchStack != null && this.mInputBusses.size() > 0) { + for (GT_MetaTileEntity_Hatch_InputBus bus : this.mInputBusses) { + if (bus != null) { + for (ItemStack uStack : bus.mInventory) { + if (uStack != null) { + if (aSearchStack.getClass().isInstance(uStack.getItem())) { + return uStack; + } + } + } + } + } + } + return null; + } + + /** + * Deplete fluid input from a set of restricted hatches. This assumes these hatches can store nothing else but your + * expected fluid + */ + protected boolean depleteInputFromRestrictedHatches( + Collection<GT_MetaTileEntity_Hatch_CustomFluidBase> aHatches, int aAmount) { for (final GT_MetaTileEntity_Hatch_CustomFluidBase tHatch : aHatches) { if (isValidMetaTileEntity(tHatch)) { FluidStack tLiquid = tHatch.getFluid(); @@ -1634,1181 +1673,1254 @@ public abstract class GregtechMeta_MultiBlockBase<T extends GT_MetaTileEntity_En } @Override - public void updateSlots() { - for (final GT_MetaTileEntity_Hatch_InputBattery tHatch : this.mChargeHatches) { - if (isValidMetaTileEntity(tHatch)) { - tHatch.updateSlots(); - } - } - for (final GT_MetaTileEntity_Hatch_OutputBattery tHatch : this.mDischargeHatches) { - if (isValidMetaTileEntity(tHatch)) { - tHatch.updateSlots(); - } - } - super.updateSlots(); - } - - public boolean isToolCreative(ItemStack mStack){ - Materials t1 = GT_MetaGenerated_Tool.getPrimaryMaterial(mStack); - Materials t2 = GT_MetaGenerated_Tool.getSecondaryMaterial(mStack); - if (t1 == Materials._NULL && t2 == Materials._NULL){ - return true; - } - return false; - } - - /** - * Causes a Random Maint. Issue. - * @return {@link boolean} - Returns whether or not an issue was caused, should always be true. - */ - public boolean causeMaintenanceIssue() { - boolean b = false; - switch (this.getBaseMetaTileEntity().getRandomNumber(6)) { - case 0 : { - this.mWrench = false; - b = true; - break; - } - case 1 : { - this.mScrewdriver = false; - b = true; - break; - } - case 2 : { - this.mSoftHammer = false; - b = true; - break; - } - case 3 : { - this.mHardHammer = false; - b = true; - break; - } - case 4 : { - this.mSolderingTool = false; - b = true; - break; - } - case 5 : { - this.mCrowbar = false; - b = true; - break; - } - } - return b; - } - - public void fixAllMaintenanceIssue() { - this.mCrowbar = true; - this.mWrench = true; - this.mHardHammer = true; - this.mSoftHammer = true; - this.mSolderingTool = true; - this.mScrewdriver = true; - } - - public boolean checkHatch() { - return mMaintenanceHatches.size() <= 1 && (this.getPollutionPerSecond(null) > 0 ? !mMufflerHatches.isEmpty() : true); - } - - public <E> boolean addToMachineListInternal(ArrayList<E> aList, final IGregTechTileEntity aTileEntity, final int aBaseCasingIndex) { - return addToMachineListInternal(aList, getMetaTileEntity(aTileEntity), aBaseCasingIndex); - } - - public <E> boolean addToMachineListInternal(ArrayList<E> aList, final IMetaTileEntity aTileEntity, final int aBaseCasingIndex) { - if (aTileEntity == null) { - return false; - } - - //Check type - /* - * Class <?> aHatchType = ReflectionUtils.getTypeOfGenericObject(aList); if - * (!aHatchType.isInstance(aTileEntity)) { return false; } - */ - - // Try setRecipeMap - - try { - if (aTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { - resetRecipeMapForHatch((GT_MetaTileEntity_Hatch) aTileEntity, getRecipeMap()); - } - if (aTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus) { - resetRecipeMapForHatch((GT_MetaTileEntity_Hatch) aTileEntity, getRecipeMap()); - } - } - catch (Throwable t) { - t.printStackTrace(); - } - - if (aList.isEmpty()) { - if (aTileEntity instanceof GT_MetaTileEntity_Hatch) { - if (GTplusplus.CURRENT_LOAD_PHASE == INIT_PHASE.STARTED) { - log("Adding " + aTileEntity.getInventoryName() + " at " + new BlockPos(aTileEntity.getBaseMetaTileEntity()).getLocationString()); - } - updateTexture(aTileEntity, aBaseCasingIndex); - return aList.add((E) aTileEntity); - } - } - else { - IGregTechTileEntity aCur = aTileEntity.getBaseMetaTileEntity(); - if (aList.contains(aTileEntity)) { - log("Found Duplicate "+aTileEntity.getInventoryName()+" @ " + new BlockPos(aCur).getLocationString()); - return false; - } - BlockPos aCurPos = new BlockPos(aCur); - boolean aExists = false; - for (E m : aList) { - IGregTechTileEntity b = ((IMetaTileEntity) m).getBaseMetaTileEntity(); - if (b != null) { - BlockPos aPos = new BlockPos(b); - if (aPos != null) { - if (aCurPos.equals(aPos)) { - if (GTplusplus.CURRENT_LOAD_PHASE == INIT_PHASE.STARTED) { - log("Found Duplicate "+b.getInventoryName()+" at " + aPos.getLocationString()); - } - return false; - } - } - } - } - if (aTileEntity instanceof GT_MetaTileEntity_Hatch) { - if (GTplusplus.CURRENT_LOAD_PHASE == INIT_PHASE.STARTED) { - log("Adding " + aCur.getInventoryName() + " at " + aCurPos.getLocationString()); - } - updateTexture(aTileEntity, aBaseCasingIndex); - return aList.add((E) aTileEntity); - } - } - return false; - } - - public int getControlCoreTier() { - - //Always return best tier if config is off. - /*boolean aCoresConfig = gtPlusPlus.core.lib.CORE.ConfigSwitches.requireControlCores; - if (!aCoresConfig) { - return 10; - }*/ - - if (mControlCoreBus.isEmpty()) { - log("No Control Core Modules Found."); - return 0; - } - GT_MetaTileEntity_Hatch_ControlCore i = getControlCoreBus(); - if (i != null) { - ItemStack x = i.mInventory[0]; - if (x != null) { - return x.getItemDamage(); - } - } - log("Control Core Module was null."); - return 0; - } - - public GT_MetaTileEntity_Hatch_ControlCore getControlCoreBus() { - if (this.mControlCoreBus == null || this.mControlCoreBus.isEmpty()) { - return null; - } - GT_MetaTileEntity_Hatch_ControlCore x = this.mControlCoreBus.get(0); - if (x != null) { - log("getControlCore(ok)"); - return x; - } - log("getControlCore(bad)"); - return null; - } - - //mControlCoreBus - public boolean addControlCoreToMachineList(final IGregTechTileEntity aTileEntity, final int aBaseCasingIndex) { - if (!mControlCoreBus.isEmpty()) { - log("Tried to add a secondary control core module."); - return false; - } - GT_MetaTileEntity_Hatch_ControlCore Module = (GT_MetaTileEntity_Hatch_ControlCore) getMetaTileEntity(aTileEntity); - if (Module != null) { - if (Module.setOwner(aTileEntity)) { - log("Adding control core module."); - return addToMachineListInternal(mControlCoreBus, Module, aBaseCasingIndex); - } - } - return false; - } - - private IMetaTileEntity getMetaTileEntity(final IGregTechTileEntity aTileEntity) { - if (aTileEntity == null) { - return null; - } - final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - return aMetaTileEntity; - } - - - @Override - public boolean addToMachineList(final IGregTechTileEntity aTileEntity, final int aBaseCasingIndex) { - return addToMachineList(getMetaTileEntity(aTileEntity), aBaseCasingIndex); - } - - public boolean addToMachineList(final IMetaTileEntity aMetaTileEntity, final int aBaseCasingIndex) { - if (aMetaTileEntity == null) { - return false; - } - - //Use this to determine the correct value, then update the hatch texture after. - boolean aDidAdd = false; - - //Handle Custom Hatches - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_ControlCore) { - log("Found GT_MetaTileEntity_Hatch_ControlCore"); - if (!mControlCoreBus.isEmpty()) { - log("Tried to add a secondary control core module."); - return false; - } - aDidAdd = addToMachineListInternal(this.mControlCoreBus, aMetaTileEntity, aBaseCasingIndex); - } - else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBattery) { - log("Found GT_MetaTileEntity_Hatch_InputBattery"); - aDidAdd = addToMachineListInternal(mChargeHatches, aMetaTileEntity, aBaseCasingIndex); - } - else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBattery) { - log("Found GT_MetaTileEntity_Hatch_OutputBattery"); - aDidAdd = addToMachineListInternal(mDischargeHatches, aMetaTileEntity, aBaseCasingIndex); - } - else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_AirIntake) { - aDidAdd = addToMachineListInternal(mAirIntakes, aMetaTileEntity, aBaseCasingIndex) && addToMachineListInternal(mInputHatches, aMetaTileEntity, aBaseCasingIndex); - } - - //Handle TT Multi-A Energy Hatches - else if (LoadedMods.TecTech && isThisHatchMultiEnergy(aMetaTileEntity)) { - log("Found isThisHatchMultiEnergy"); - aDidAdd = addToMachineListInternal(mTecTechEnergyHatches, aMetaTileEntity, aBaseCasingIndex); - updateMasterEnergyHatchList(aMetaTileEntity); - } - - //Handle TT Multi-A Dynamos - else if (LoadedMods.TecTech && isThisHatchMultiDynamo(aMetaTileEntity)) { - log("Found isThisHatchMultiDynamo"); - aDidAdd = addToMachineListInternal(mTecTechDynamoHatches, aMetaTileEntity, aBaseCasingIndex); - updateMasterDynamoHatchList(aMetaTileEntity); - } - - //Handle Fluid Hatches using seperate logic - else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) - aDidAdd = addToMachineListInternal(mInputHatches, aMetaTileEntity, aBaseCasingIndex); - else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) - aDidAdd = addToMachineListInternal(mOutputHatches, aMetaTileEntity, aBaseCasingIndex); - - //Process Remaining hatches using Vanilla GT Logic - else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus) - aDidAdd = addToMachineListInternal(mInputBusses, aMetaTileEntity, aBaseCasingIndex); - else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) - aDidAdd = addToMachineListInternal(mOutputBusses, aMetaTileEntity, aBaseCasingIndex); - else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy) { - aDidAdd = addToMachineListInternal(mEnergyHatches, aMetaTileEntity, aBaseCasingIndex); - updateMasterEnergyHatchList(aMetaTileEntity); - } - else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Dynamo) { - aDidAdd = addToMachineListInternal(mDynamoHatches, aMetaTileEntity, aBaseCasingIndex); - updateMasterDynamoHatchList(aMetaTileEntity); - } - else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance) - aDidAdd = addToMachineListInternal(mMaintenanceHatches, aMetaTileEntity, aBaseCasingIndex); - else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) - aDidAdd = addToMachineListInternal(mMufflerHatches, aMetaTileEntity, aBaseCasingIndex); - - //return super.addToMachineList(aTileEntity, aBaseCasingIndex); - return aDidAdd; - } - - - - @Override - public boolean addMaintenanceToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - IMetaTileEntity aMetaTileEntity = getMetaTileEntity(aTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance) { - return addToMachineList(aMetaTileEntity, aBaseCasingIndex); - } - return false; - } - - @Override - public boolean addMufflerToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - IMetaTileEntity aMetaTileEntity = getMetaTileEntity(aTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) { - return addToMachineList(aMetaTileEntity, aBaseCasingIndex); - } - return false; - } - - @Override - public boolean addInputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - IMetaTileEntity aMetaTileEntity = getMetaTileEntity(aTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input || aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus) { - return addToMachineList(aMetaTileEntity, aBaseCasingIndex); - } - return false; - } - - @Override - public boolean addOutputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - IMetaTileEntity aMetaTileEntity = getMetaTileEntity(aTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output || aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) { - return addToMachineList(aMetaTileEntity, aBaseCasingIndex); - } - return false; - } - - public boolean addAirIntakeToMachineList(final IGregTechTileEntity aMetaTileEntity, final int aBaseCasingIndex) { - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_AirIntake) { - return addToMachineList(aMetaTileEntity, aBaseCasingIndex); - } - return false; - } - - public boolean addFluidInputToMachineList(final IGregTechTileEntity aTileEntity, final int aBaseCasingIndex) { - return addFluidInputToMachineList(getMetaTileEntity(aTileEntity), aBaseCasingIndex); - } - - public boolean addFluidInputToMachineList(final IMetaTileEntity aMetaTileEntity, final int aBaseCasingIndex) { - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { - return addToMachineList(aMetaTileEntity, aBaseCasingIndex); - } - return false; - } - - public boolean clearRecipeMapForAllInputHatches() { - return resetRecipeMapForAllInputHatches(null); - } - - public boolean resetRecipeMapForAllInputHatches() { - return resetRecipeMapForAllInputHatches(this.getRecipeMap()); - } - - public boolean resetRecipeMapForAllInputHatches(GT_Recipe_Map aMap) { - int cleared = 0; - for (GT_MetaTileEntity_Hatch_Input g : this.mInputHatches) { - if (resetRecipeMapForHatch(g, aMap)) { - cleared++; - } - } - for (GT_MetaTileEntity_Hatch_InputBus g : this.mInputBusses) { - if (resetRecipeMapForHatch(g, aMap)) { - cleared++; - } - } - return cleared > 0; - } - public boolean resetRecipeMapForHatch(IGregTechTileEntity aTileEntity, GT_Recipe_Map aMap) { - try { - final IMetaTileEntity aMetaTileEntity = getMetaTileEntity(aTileEntity); - if (aMetaTileEntity == null) { - return false; - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input || aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus || aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Steam_BusInput) { - return resetRecipeMapForHatch((GT_MetaTileEntity_Hatch)aMetaTileEntity, aMap); - } - else { - return false; - } - } - catch (Throwable t) { - t.printStackTrace(); - return false; - } - } - - public boolean resetRecipeMapForHatch(GT_MetaTileEntity_Hatch aTileEntity, GT_Recipe_Map aMap) { - if (aTileEntity == null) { - return false; - } - final IMetaTileEntity aMetaTileEntity = aTileEntity; - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input || aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus || aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Steam_BusInput) { - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input){ - ((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity).mRecipeMap = null; - ((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity).mRecipeMap = aMap; - if (aMap != null && aMap.mNEIName != null) { - log("Remapped Input Hatch to "+aMap.mNEIName+"."); - } - else { - log("Cleared Input Hatch."); - } - } - else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus) { - ((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity).mRecipeMap = null; - ((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity).mRecipeMap = aMap; - if (aMap != null && aMap.mNEIName != null) { - log("Remapped Input Bus to "+aMap.mNEIName+"."); - } - else { - log("Cleared Input Bus."); - } - } - else { - ((GT_MetaTileEntity_Hatch_Steam_BusInput) aMetaTileEntity).mRecipeMap = null; - ((GT_MetaTileEntity_Hatch_Steam_BusInput) aMetaTileEntity).mRecipeMap = aMap; - if (aMap != null && aMap.mNEIName != null) { - log("Remapped Input Bus to "+aMap.mNEIName+"."); - } - else { - log("Cleared Input Bus."); - } - } - return true; - } - else { - return false; - } - } - - @Override - public final void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); - clearRecipeMapForAllInputHatches(); - onModeChangeByScrewdriver(aSide, aPlayer, aX, aY, aZ); - resetRecipeMapForAllInputHatches(); - } - - public void onModeChangeByScrewdriver(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - - } - - - - - - /** - * Enable Texture Casing Support if found in GT 5.09 - */ - - public boolean updateTexture(final IGregTechTileEntity aTileEntity, int aCasingID){ - return updateTexture(getMetaTileEntity(aTileEntity), aCasingID); - } - - /** - * Enable Texture Casing Support if found in GT 5.09 - */ - - @SuppressWarnings("deprecation") - public boolean updateTexture(final IMetaTileEntity aTileEntity, int aCasingID){ - try { //gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch.updateTexture(int) - - final IMetaTileEntity aMetaTileEntity = aTileEntity; - if (aMetaTileEntity == null) { - return false; - } - Method mProper = ReflectionUtils.getMethod(GT_MetaTileEntity_Hatch.class, "updateTexture", int.class); - if (mProper != null){ - if (GT_MetaTileEntity_Hatch.class.isInstance(aMetaTileEntity)){ - mProper.setAccessible(true); - mProper.invoke(aMetaTileEntity, aCasingID); - //log("Good Method Call for updateTexture."); - return true; - } - } - else { - log("Bad Method Call for updateTexture."); - if (GT_MetaTileEntity_Hatch.class.isInstance(aMetaTileEntity)){ - if (aCasingID <= Byte.MAX_VALUE) { - ((GT_MetaTileEntity_Hatch) aTileEntity).mMachineBlock = (byte) aCasingID; - log("Good Method Call for updateTexture. Used fallback method of setting mMachineBlock as casing id was <= 128."); - return true; - } - else { - log("updateTexture returning false. 1.2"); - } - } - else { - log("updateTexture returning false. 1.3"); - } - } - log("updateTexture returning false. 1"); - return false; - } - catch (SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - log("updateTexture returning false."); - log("updateTexture returning false. 2"); - e.printStackTrace(); - return false; - } - - } - - - - - - - - - - /** - * TecTech Support - */ - - - /** - * This is the array Used to Store the Tectech Multi-Amp Dynamo hatches. - */ - - public ArrayList<GT_MetaTileEntity_Hatch> mTecTechDynamoHatches = new ArrayList<GT_MetaTileEntity_Hatch>(); - - /** - * This is the array Used to Store the Tectech Multi-Amp Energy hatches. - */ - - public ArrayList<GT_MetaTileEntity_Hatch> mTecTechEnergyHatches = new ArrayList<GT_MetaTileEntity_Hatch>(); - - /** - * TecTech Multi-Amp Dynamo Support - * @param aTileEntity - The Dynamo Hatch - * @param aBaseCasingIndex - Casing Texture - * @return - */ - - public boolean addMultiAmpDynamoToMachineList(final IGregTechTileEntity aTileEntity, final int aBaseCasingIndex){ - final IMetaTileEntity aMetaTileEntity = getMetaTileEntity(aTileEntity); - if (aMetaTileEntity == null) { - return false; - } - if (isThisHatchMultiDynamo(aTileEntity)) { - return addToMachineListInternal(mTecTechDynamoHatches, aMetaTileEntity, aBaseCasingIndex); - } - return false; - } - - public boolean isThisHatchMultiDynamo(IGregTechTileEntity aTileEntity){ - return isThisHatchMultiDynamo(getMetaTileEntity(aTileEntity)); - } - - public boolean isThisHatchMultiDynamo(IMetaTileEntity aMetaTileEntity){ - Class<?> mDynamoClass; - mDynamoClass = ReflectionUtils.getClass("com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_DynamoMulti"); - if (mDynamoClass != null){ - if (mDynamoClass.isInstance(aMetaTileEntity)){ - return true; - } - } - return false; - } - - @Override - public boolean addDynamoToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - IMetaTileEntity aMetaTileEntity = getMetaTileEntity(aTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Dynamo || isThisHatchMultiDynamo(aMetaTileEntity)) { - return addToMachineList(aMetaTileEntity, aBaseCasingIndex); - } - return false; - } - - private boolean updateMasterDynamoHatchList(IMetaTileEntity aMetaTileEntity) { - if (aMetaTileEntity == null) { - return false; - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch) { - GT_MetaTileEntity_Hatch aHatch = (GT_MetaTileEntity_Hatch) aMetaTileEntity; - return mAllDynamoHatches.add(aHatch); - } - return false; - } - - - /** - * TecTech Multi-Amp Energy Hatch Support - * @param aTileEntity - The Energy Hatch - * @param aBaseCasingIndex - Casing Texture - * @return - */ - - public boolean addMultiAmpEnergyToMachineList(final IGregTechTileEntity aTileEntity, final int aBaseCasingIndex){ - final IMetaTileEntity aMetaTileEntity = getMetaTileEntity(aTileEntity); - if (aMetaTileEntity == null) { - return false; - } - if (isThisHatchMultiEnergy(aMetaTileEntity)) { - return addToMachineListInternal(mTecTechEnergyHatches, aMetaTileEntity, aBaseCasingIndex); - } - return false; - } - - public boolean isThisHatchMultiEnergy(IGregTechTileEntity aTileEntity){ - return isThisHatchMultiEnergy(getMetaTileEntity(aTileEntity)); - } - - public boolean isThisHatchMultiEnergy(IMetaTileEntity aMetaTileEntity){ - Class<?> mDynamoClass; - mDynamoClass = ReflectionUtils.getClass("com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_EnergyMulti"); - if (mDynamoClass != null){ - if (mDynamoClass.isInstance(aMetaTileEntity)){ - return true; - } - } - return false; - } - - @Override - public boolean addEnergyInputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - IMetaTileEntity aMetaTileEntity = getMetaTileEntity(aTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy || isThisHatchMultiEnergy(aMetaTileEntity)) { - return addToMachineList(aMetaTileEntity, aBaseCasingIndex); - } - return false; - } - - private boolean updateMasterEnergyHatchList(IMetaTileEntity aMetaTileEntity) { - if (aMetaTileEntity == null) { - return false; - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch) { - GT_MetaTileEntity_Hatch aHatch = (GT_MetaTileEntity_Hatch) aMetaTileEntity; - return mAllEnergyHatches.add(aHatch); - } - return false; - } - - - /** - * Pollution Management - */ - - private static Method calculatePollutionReduction = null; - public int calculatePollutionReductionForHatch(GT_MetaTileEntity_Hatch_Muffler i , int g) { - if (calculatePollutionReduction != null) { - try { - return (int) calculatePollutionReduction.invoke(i, g); - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - - } - } - return 0; - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - aNBT.setLong("mTotalRunTime", this.mTotalRunTime); - aNBT.setBoolean("mVoidExcess", this.mVoidExcess); - super.saveNBTData(aNBT); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - this.mTotalRunTime = aNBT.getLong("mTotalRunTime"); - this.mVoidExcess = aNBT.getBoolean("mVoidExcess"); - super.loadNBTData(aNBT); - } - - - - - - - - - - - - - - /** - * Custom Find Recipe with Debugging - */ - - - public GT_Recipe findRecipe(final IHasWorldObjectAndCoords aTileEntity, final boolean aNotUnificated, - final boolean aDontCheckStackSizes, final long aVoltage, final FluidStack[] aFluids, - final ItemStack... aInputs) { - return this.findRecipe(aTileEntity, null, aNotUnificated, aDontCheckStackSizes, aVoltage, aFluids, - (ItemStack) null, aInputs); - } - - public GT_Recipe findRecipe(final IHasWorldObjectAndCoords aTileEntity, final boolean aNotUnificated, - final long aVoltage, final FluidStack[] aFluids, final ItemStack... aInputs) { - return this.findRecipe(aTileEntity, null, aNotUnificated, aVoltage, aFluids, (ItemStack) null, aInputs); - } - - public GT_Recipe findRecipe(final IHasWorldObjectAndCoords aTileEntity, final GT_Recipe aRecipe, - final boolean aNotUnificated, final boolean aDontCheckStackSizes, final long aVoltage, - final FluidStack[] aFluids, final ItemStack... aInputs) { - return this.findRecipe(aTileEntity, aRecipe, aNotUnificated, aDontCheckStackSizes, aVoltage, aFluids, - (ItemStack) null, aInputs); - } - - public GT_Recipe findRecipe(final IHasWorldObjectAndCoords aTileEntity, final GT_Recipe aRecipe, - final boolean aNotUnificated, final long aVoltage, final FluidStack[] aFluids, - final ItemStack... aInputs) { - return this.findRecipe(aTileEntity, aRecipe, aNotUnificated, aVoltage, aFluids, (ItemStack) null, aInputs); - } - - public GT_Recipe findRecipe(final IHasWorldObjectAndCoords aTileEntity, final GT_Recipe aRecipe, - final boolean aNotUnificated, final long aVoltage, final FluidStack[] aFluids, - final ItemStack aSpecialSlot, final ItemStack... aInputs) { - return this.findRecipe(aTileEntity, aRecipe, aNotUnificated, true, aVoltage, aFluids, aSpecialSlot, - aInputs); - } - - public GT_Recipe findRecipe(final IHasWorldObjectAndCoords aTileEntity, final GT_Recipe aRecipe, - final boolean aNotUnificated, final boolean aDontCheckStackSizes, final long aVoltage, - final FluidStack[] aFluids, final ItemStack aSpecialSlot, ItemStack... aInputs) { - if (this.getRecipeMap().mRecipeList.isEmpty()) { - log("No Recipes in Map to search through."); - return null; - } - GT_Recipe mRecipeResult = null; - try { - if (GregTech_API.sPostloadFinished) { - if (this.getRecipeMap().mMinimalInputFluids > 0) { - if (aFluids == null) { - log("aFluids == null && minFluids > 0"); - return null; - } - int tAmount = 0; - for (final FluidStack aFluid : aFluids) { - if (aFluid != null) { - ++tAmount; - } - } - if (tAmount < this.getRecipeMap().mMinimalInputFluids) { - log("Not enough fluids?"); - return null; - } - } - if (this.getRecipeMap().mMinimalInputItems > 0) { - if (aInputs == null) { - log("No inputs and minItems > 0"); - return null; - } - int tAmount = 0; - for (final ItemStack aInput : aInputs) { - if (aInput != null) { - ++tAmount; - } - } - if (tAmount < this.getRecipeMap().mMinimalInputItems) { - log("Not enough items?"); - return null; - } - } - } - else { - log("Game Not Loaded properly for recipe lookup."); - } - if (aNotUnificated) { - aInputs = GT_OreDictUnificator.getStackArray(true, (Object[]) aInputs); - } - if (aRecipe != null && !aRecipe.mFakeRecipe && aRecipe.mCanBeBuffered - && aRecipe.isRecipeInputEqual(false, aDontCheckStackSizes, aFluids, aInputs)) { - mRecipeResult = (aRecipe.mEnabled/* && aVoltage * this.getRecipeMap().mAmperage >= aRecipe.mEUt*/) ? aRecipe : null; - log("x) Found Recipe? "+(mRecipeResult != null ? "true" : "false")); - if (mRecipeResult != null) { - return mRecipeResult; - } - } - if (mRecipeResult == null && this.getRecipeMap().mUsualInputCount >= 0 && aInputs != null && aInputs.length > 0) { - for (final ItemStack tStack : aInputs) { - if (tStack != null) { - Collection<GT_Recipe> tRecipes = this.getRecipeMap().mRecipeItemMap.get(new GT_ItemStack(tStack)); - if (tRecipes != null) { - for (final GT_Recipe tRecipe : tRecipes) { - if (!tRecipe.mFakeRecipe && tRecipe.isRecipeInputEqual(false, aDontCheckStackSizes, aFluids, aInputs)) { - mRecipeResult = (tRecipe.mEnabled/* && aVoltage * this.getRecipeMap().mAmperage >= tRecipe.mEUt*/) - ? tRecipe - : null; - log("1) Found Recipe? "+(mRecipeResult != null ? "true" : "false")); - //return mRecipeResult; - } - } - } - - //TODO - Investigate if this requires to be in it's own block - tRecipes = this.getRecipeMap().mRecipeItemMap - .get(new GT_ItemStack(GT_Utility.copyMetaData(32767L, new Object[]{tStack}))); - if (tRecipes != null) { - for (final GT_Recipe tRecipe : tRecipes) { - if (!tRecipe.mFakeRecipe - && tRecipe.isRecipeInputEqual(false, aDontCheckStackSizes, aFluids, aInputs)) { - mRecipeResult = (tRecipe.mEnabled /*&& aVoltage * this.getRecipeMap().mAmperage >= tRecipe.mEUt*/) - ? tRecipe - : null; - log("2) Found Recipe? "+(mRecipeResult != null ? "true" : "false")); - //return mRecipeResult; - } - } - } - } - } - } - if (mRecipeResult == null && this.getRecipeMap().mMinimalInputItems == 0 && aFluids != null && aFluids.length > 0) { - for (final FluidStack aFluid2 : aFluids) { - if (aFluid2 != null) { - final Collection<GT_Recipe> tRecipes = this.getRecipeMap().mRecipeFluidMap.get(aFluid2.getFluid()); - if (tRecipes != null) { - for (final GT_Recipe tRecipe : tRecipes) { - if (!tRecipe.mFakeRecipe - && tRecipe.isRecipeInputEqual(false, aDontCheckStackSizes, aFluids, aInputs)) { - mRecipeResult = (tRecipe.mEnabled/* && aVoltage * this.getRecipeMap().mAmperage >= tRecipe.mEUt*/) - ? tRecipe - : null; - log("3) Found Recipe? "+(mRecipeResult != null ? "true" : "false")); - //return mRecipeResult; - } - } - } - } - } - } - } - catch (Throwable t) { - log("Invalid recipe lookup."); - } - - - if (mRecipeResult == null) { - log("Invalid recipe, Fallback lookup. "+this.getRecipeMap().mRecipeList.size()+" | "+this.getRecipeMap().mNEIName); - if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { - try { - return (GT_Recipe) findRecipe08.invoke(getRecipeMap(), aTileEntity, aRecipe, aNotUnificated, aVoltage, aFluids, aSpecialSlot, aInputs); - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - e.printStackTrace(); - return null; - } - } - else { - try { - return (GT_Recipe) findRecipe09.invoke(getRecipeMap(), aTileEntity, aRecipe, aNotUnificated, aDontCheckStackSizes, aVoltage, aFluids, aSpecialSlot, aInputs); - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - e.printStackTrace(); - return null; - } - } - } - else { - return mRecipeResult; - } - - - - - } - - - - - /** - * Custom Tool Handling - */ - - @Override - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, byte aSide, float aX, - float aY, float aZ) { - // Do Things - if (this.getBaseMetaTileEntity().isServerSide()) { - //Logger.INFO("Right Clicked Controller."); - ItemStack tCurrentItem = aPlayer.inventory.getCurrentItem(); - if (tCurrentItem != null) { - //Logger.INFO("Holding Item."); - if (tCurrentItem.getItem() instanceof GT_MetaGenerated_Tool) { - //Logger.INFO("Is GT_MetaGenerated_Tool."); - int[] aOreID = OreDictionary.getOreIDs(tCurrentItem); - for (int id : aOreID) { - // Plunger - if (OreDictionary.getOreName(id).equals("craftingToolPlunger")) { - //Logger.INFO("Is Plunger."); - return onPlungerRightClick(aPlayer, aSide, aX, aY, aZ); - } - } - } - } - } - //Do Super - boolean aSuper = super.onRightclick(aBaseMetaTileEntity, aPlayer, aSide, aX, aY, aZ); - return aSuper; - } - - public boolean onPlungerRightClick(EntityPlayer aPlayer, byte aSide, float aX, float aY, float aZ) { - int aHatchIndex = 0; - PlayerUtils.messagePlayer(aPlayer, "Trying to clear "+mOutputHatches.size()+" output hatches."); - for (GT_MetaTileEntity_Hatch_Output hatch : this.mOutputHatches) { - if (hatch.mFluid != null) { - PlayerUtils.messagePlayer(aPlayer, "Clearing "+hatch.mFluid.amount+"L of "+hatch.mFluid.getLocalizedName()+" from hatch "+aHatchIndex+"."); - hatch.mFluid = null; - } - aHatchIndex++; - } - return aHatchIndex > 0; - } - - @Override - public boolean onSolderingToolRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - boolean tSuper = super.onSolderingToolRightClick(aSide, aWrenchingSide, aPlayer, aX, aY, aZ); - if (aPlayer.isSneaking()) - return tSuper; - mVoidExcess = !mVoidExcess; - aPlayer.addChatMessage(new ChatComponentTranslation(mVoidExcess ? "interaction.voidexcess.enabled" : "interaction.voidexcess.disabled")); - return true; - } - - public boolean isValidBlockForStructure(IGregTechTileEntity aBaseMetaTileEntity, int aCasingID, boolean canBeHatch, - Block aFoundBlock, int aFoundMeta, Block aExpectedBlock, int aExpectedMeta) { - boolean isHatch = false; - if (aBaseMetaTileEntity != null) { - - // Unsure why this check exists? - /*if (aCasingID < 64) { - aCasingID = TAE.GTPP_INDEX(aCasingID); - }*/ - - isHatch = this.addToMachineList(aBaseMetaTileEntity, aCasingID); - if (isHatch) { - return true; - } - else { - int aMetaTileID = aBaseMetaTileEntity.getMetaTileID(); - //Found a controller - if (aMetaTileID >= 750 && aMetaTileID < 1000 && aFoundBlock == GregTech_API.sBlockMachines) { - return true; - } - //Vanilla Hatches/Busses - else if (aMetaTileID >= 10 && aMetaTileID <= 99 && aFoundBlock == GregTech_API.sBlockMachines) { - return true; - } - //Adv Mufflers - else if (aMetaTileID >= 30001 && aMetaTileID <= 30009 && aFoundBlock == GregTech_API.sBlockMachines) { - return true; - } - //Control Core, Super IO - else if (aMetaTileID >= 30020 && aMetaTileID <= 30040 && aFoundBlock == GregTech_API.sBlockMachines) { - return true; - } - //Auto maint - else if (aMetaTileID == 111 && aFoundBlock == GregTech_API.sBlockMachines) { - return true; - } - //Data Ports - else if ((aMetaTileID == 131 || aMetaTileID == 132) && aFoundBlock == GregTech_API.sBlockMachines) { - return true; - } - else { - log("Found meta Tile: "+aMetaTileID); - } - } - } - if (!isHatch) { - if (aFoundBlock == aExpectedBlock && aFoundMeta == aExpectedMeta) { - return true; - } - 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())); - } - return false; - } - else if (aFoundMeta != aExpectedMeta) { - log("A2"); - return false; - } - - } - log("A3"); - return false; - } - - @Override - public void onServerStart() { - super.onServerStart(); - tryTickWaitTimerDown(); - } - - @Override - public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { - super.onFirstTick(aBaseMetaTileEntity); - tryTickWaitTimerDown(); - } - - @Override - public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - super.onPreTick(aBaseMetaTileEntity, aTick); - tryTickWaitTimerDown(); - } - - @Override - public void onCreated(ItemStack aStack, World aWorld, EntityPlayer aPlayer) { - super.onCreated(aStack, aWorld, aPlayer); - tryTickWaitTimerDown(); - } - - private final void tryTickWaitTimerDown() { - /*if (mStartUpCheck > 10) { - mStartUpCheck = 10; - }*/ - } - - //Only support to use meta to tier - - /** - * accept meta [0, maxMeta) - * @param maxMeta exclusive - */ - public static <T> IStructureElement<T> addTieredBlock(Block aBlock, BiConsumer<T, Integer> aSetTheFuckingMeta, Function<T, Integer> aGetTheFuckingMeta, int maxMeta) { - return addTieredBlock(aBlock, (t, i) -> { - aSetTheFuckingMeta.accept(t, i); - return true; - }, aGetTheFuckingMeta, 0, maxMeta - ); - } - - /** - * - * @param minMeta inclusive - * @param maxMeta exclusive - */ - public static <T> IStructureElement<T> addTieredBlock(Block aBlock, BiConsumer<T, Integer> aSetTheFuckingMeta, Function<T, Integer> aGetTheFuckingMeta, int minMeta, int maxMeta) { - return addTieredBlock(aBlock, (t, i) -> { - aSetTheFuckingMeta.accept(t, i); - return true; - }, aGetTheFuckingMeta, minMeta, maxMeta - ); - } - - /** - * - * @param minMeta inclusive - * @param maxMeta exclusive - */ - public static <T> IStructureElement<T> addTieredBlock(Block aBlock, BiPredicate<T, Integer> aSetTheFuckingMeta, Function<T, Integer> aGetTheFuckingMeta, int minMeta, int maxMeta) { - - return new IStructureElement<T>() { - @Override - public boolean check(T t, World world, int x, int y, int z) { - Block tBlock = world.getBlock(x, y, z); - if (aBlock == tBlock) { - Integer currentMeta = aGetTheFuckingMeta.apply(t); - int newMeta = tBlock.getDamageValue(world, x, y, z) + 1; - if (newMeta > maxMeta || newMeta < minMeta + 1) return false; - if (currentMeta == 0) { - return aSetTheFuckingMeta.test(t, newMeta); - } else { - return currentMeta == newMeta; - } - } - return false; - } - - @Override - public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { - StructureLibAPI.hintParticle(world, x, y, z, aBlock, getMeta(trigger)); - return true; - } - - @Override - public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { - return world.setBlock(x, y, z, aBlock, getMeta(trigger), 3); - } - - private int getMeta(ItemStack trigger) { - int meta = trigger.stackSize; - if (meta <= 0) meta = minMeta; - if (meta + minMeta >= maxMeta) meta = maxMeta - 1 - minMeta; - return meta + minMeta; - } - - @Override - public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, EntityPlayerMP actor, Consumer<IChatComponent> chatter) { - if (world.getBlock(x, y, z) == aBlock) { - if (world.getBlockMetadata(x, y, z) == getMeta(trigger)) { - return PlaceResult.SKIP; - } - return PlaceResult.REJECT; - } - return StructureUtility.survivalPlaceBlock(aBlock, getMeta(trigger), world, x, y, z, s, actor, chatter); - } - }; - } - - @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - if (aSide == aFacing) { - if (aActive) - return new ITexture[]{getCasingTexture(), - TextureFactory.builder().addIcon(getActiveOverlay()).extFacing().build()}; - return new ITexture[]{getCasingTexture(), - TextureFactory.builder().addIcon(getInactiveOverlay()).extFacing().build()}; - } - return new ITexture[]{getCasingTexture()}; - } - - protected IIconContainer getActiveOverlay() { - return null; - } - - protected IIconContainer getInactiveOverlay() { - return null; - } - - protected ITexture getCasingTexture() { - return Textures.BlockIcons.getCasingTextureForId(getCasingTextureId()); - } - - protected int getCasingTextureId() { - return 0; - } - - public enum GTPPHatchElement implements IHatchElement<GregtechMeta_MultiBlockBase<?>> { - AirIntake(GregtechMeta_MultiBlockBase::addAirIntakeToMachineList, GT_MetaTileEntity_Hatch_AirIntake.class) { - @Override - public long count(GregtechMeta_MultiBlockBase<?> t) { - return t.mAirIntakes.size(); - } - }, - ControlCore(GregtechMeta_MultiBlockBase::addControlCoreToMachineList, GT_MetaTileEntity_Hatch_ControlCore.class) { - @Override - public long count(GregtechMeta_MultiBlockBase<?> t) { - return t.mControlCoreBus.size(); - } - }, - TTDynamo(GregtechMeta_MultiBlockBase::addMultiAmpDynamoToMachineList, "com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_DynamoMulti") { - @Override - public long count(GregtechMeta_MultiBlockBase<?> t) { - return t.mTecTechDynamoHatches.size(); - } - }, - TTEnergy(GregtechMeta_MultiBlockBase::addMultiAmpEnergyToMachineList, "com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_EnergyMulti") { - @Override - public long count(GregtechMeta_MultiBlockBase<?> t) { - return t.mTecTechEnergyHatches.size(); - } - }, - ; - - @SuppressWarnings("unchecked") - private static <T> Class<T> retype(Class<?> clazz) { - return (Class<T>) clazz; - } - - private final List<? extends Class<? extends IMetaTileEntity>> mMteClasses; - private final IGT_HatchAdder<? super GregtechMeta_MultiBlockBase<?>> mAdder; - - @SafeVarargs - GTPPHatchElement(IGT_HatchAdder<? super GregtechMeta_MultiBlockBase<?>> aAdder, Class<? extends IMetaTileEntity>... aMteClasses) { - this.mMteClasses = Arrays.asList(aMteClasses); - this.mAdder = aAdder; - } - - GTPPHatchElement(IGT_HatchAdder<? super GregtechMeta_MultiBlockBase<?>> aAdder, String... aClassNames) { - this.mMteClasses = Arrays.stream(aClassNames) - .map(ReflectionUtils::getClass) - .filter(Objects::nonNull) - .<Class<? extends IMetaTileEntity>>map(GTPPHatchElement::retype) - .collect(Collectors.toList()); - this.mAdder = aAdder; - } - - @Override - public List<? extends Class<? extends IMetaTileEntity>> mteClasses() { - return mMteClasses; - } - - @Override - public IGT_HatchAdder<? super GregtechMeta_MultiBlockBase<?>> adder() { - return mAdder; - } - } + public void updateSlots() { + for (final GT_MetaTileEntity_Hatch_InputBattery tHatch : this.mChargeHatches) { + if (isValidMetaTileEntity(tHatch)) { + tHatch.updateSlots(); + } + } + for (final GT_MetaTileEntity_Hatch_OutputBattery tHatch : this.mDischargeHatches) { + if (isValidMetaTileEntity(tHatch)) { + tHatch.updateSlots(); + } + } + super.updateSlots(); + } + + public boolean isToolCreative(ItemStack mStack) { + Materials t1 = GT_MetaGenerated_Tool.getPrimaryMaterial(mStack); + Materials t2 = GT_MetaGenerated_Tool.getSecondaryMaterial(mStack); + if (t1 == Materials._NULL && t2 == Materials._NULL) { + return true; + } + return false; + } + + /** + * Causes a Random Maint. Issue. + * @return {@link boolean} - Returns whether or not an issue was caused, should always be true. + */ + public boolean causeMaintenanceIssue() { + boolean b = false; + switch (this.getBaseMetaTileEntity().getRandomNumber(6)) { + case 0: { + this.mWrench = false; + b = true; + break; + } + case 1: { + this.mScrewdriver = false; + b = true; + break; + } + case 2: { + this.mSoftHammer = false; + b = true; + break; + } + case 3: { + this.mHardHammer = false; + b = true; + break; + } + case 4: { + this.mSolderingTool = false; + b = true; + break; + } + case 5: { + this.mCrowbar = false; + b = true; + break; + } + } + return b; + } + + public void fixAllMaintenanceIssue() { + this.mCrowbar = true; + this.mWrench = true; + this.mHardHammer = true; + this.mSoftHammer = true; + this.mSolderingTool = true; + this.mScrewdriver = true; + } + + public boolean checkHatch() { + return mMaintenanceHatches.size() <= 1 + && (this.getPollutionPerSecond(null) > 0 ? !mMufflerHatches.isEmpty() : true); + } + + public <E> boolean addToMachineListInternal( + ArrayList<E> aList, final IGregTechTileEntity aTileEntity, final int aBaseCasingIndex) { + return addToMachineListInternal(aList, getMetaTileEntity(aTileEntity), aBaseCasingIndex); + } + + public <E> boolean addToMachineListInternal( + ArrayList<E> aList, final IMetaTileEntity aTileEntity, final int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } + + // Check type + /* + * Class <?> aHatchType = ReflectionUtils.getTypeOfGenericObject(aList); if + * (!aHatchType.isInstance(aTileEntity)) { return false; } + */ + + // Try setRecipeMap + + try { + if (aTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { + resetRecipeMapForHatch((GT_MetaTileEntity_Hatch) aTileEntity, getRecipeMap()); + } + if (aTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus) { + resetRecipeMapForHatch((GT_MetaTileEntity_Hatch) aTileEntity, getRecipeMap()); + } + } catch (Throwable t) { + t.printStackTrace(); + } + + if (aList.isEmpty()) { + if (aTileEntity instanceof GT_MetaTileEntity_Hatch) { + if (GTplusplus.CURRENT_LOAD_PHASE == INIT_PHASE.STARTED) { + log("Adding " + aTileEntity.getInventoryName() + " at " + + new BlockPos(aTileEntity.getBaseMetaTileEntity()).getLocationString()); + } + updateTexture(aTileEntity, aBaseCasingIndex); + return aList.add((E) aTileEntity); + } + } else { + IGregTechTileEntity aCur = aTileEntity.getBaseMetaTileEntity(); + if (aList.contains(aTileEntity)) { + log("Found Duplicate " + aTileEntity.getInventoryName() + " @ " + + new BlockPos(aCur).getLocationString()); + return false; + } + BlockPos aCurPos = new BlockPos(aCur); + boolean aExists = false; + for (E m : aList) { + IGregTechTileEntity b = ((IMetaTileEntity) m).getBaseMetaTileEntity(); + if (b != null) { + BlockPos aPos = new BlockPos(b); + if (aPos != null) { + if (aCurPos.equals(aPos)) { + if (GTplusplus.CURRENT_LOAD_PHASE == INIT_PHASE.STARTED) { + log("Found Duplicate " + b.getInventoryName() + " at " + aPos.getLocationString()); + } + return false; + } + } + } + } + if (aTileEntity instanceof GT_MetaTileEntity_Hatch) { + if (GTplusplus.CURRENT_LOAD_PHASE == INIT_PHASE.STARTED) { + log("Adding " + aCur.getInventoryName() + " at " + aCurPos.getLocationString()); + } + updateTexture(aTileEntity, aBaseCasingIndex); + return aList.add((E) aTileEntity); + } + } + return false; + } + + public int getControlCoreTier() { + + // Always return best tier if config is off. + /*boolean aCoresConfig = gtPlusPlus.core.lib.CORE.ConfigSwitches.requireControlCores; + if (!aCoresConfig) { + return 10; + }*/ + + if (mControlCoreBus.isEmpty()) { + log("No Control Core Modules Found."); + return 0; + } + GT_MetaTileEntity_Hatch_ControlCore i = getControlCoreBus(); + if (i != null) { + ItemStack x = i.mInventory[0]; + if (x != null) { + return x.getItemDamage(); + } + } + log("Control Core Module was null."); + return 0; + } + + public GT_MetaTileEntity_Hatch_ControlCore getControlCoreBus() { + if (this.mControlCoreBus == null || this.mControlCoreBus.isEmpty()) { + return null; + } + GT_MetaTileEntity_Hatch_ControlCore x = this.mControlCoreBus.get(0); + if (x != null) { + log("getControlCore(ok)"); + return x; + } + log("getControlCore(bad)"); + return null; + } + + // mControlCoreBus + public boolean addControlCoreToMachineList(final IGregTechTileEntity aTileEntity, final int aBaseCasingIndex) { + if (!mControlCoreBus.isEmpty()) { + log("Tried to add a secondary control core module."); + return false; + } + GT_MetaTileEntity_Hatch_ControlCore Module = + (GT_MetaTileEntity_Hatch_ControlCore) getMetaTileEntity(aTileEntity); + if (Module != null) { + if (Module.setOwner(aTileEntity)) { + log("Adding control core module."); + return addToMachineListInternal(mControlCoreBus, Module, aBaseCasingIndex); + } + } + return false; + } + + private IMetaTileEntity getMetaTileEntity(final IGregTechTileEntity aTileEntity) { + if (aTileEntity == null) { + return null; + } + final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + return aMetaTileEntity; + } + + @Override + public boolean addToMachineList(final IGregTechTileEntity aTileEntity, final int aBaseCasingIndex) { + return addToMachineList(getMetaTileEntity(aTileEntity), aBaseCasingIndex); + } + + public boolean addToMachineList(final IMetaTileEntity aMetaTileEntity, final int aBaseCasingIndex) { + if (aMetaTileEntity == null) { + return false; + } + + // Use this to determine the correct value, then update the hatch texture after. + boolean aDidAdd = false; + + // Handle Custom Hatches + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_ControlCore) { + log("Found GT_MetaTileEntity_Hatch_ControlCore"); + if (!mControlCoreBus.isEmpty()) { + log("Tried to add a secondary control core module."); + return false; + } + aDidAdd = addToMachineListInternal(this.mControlCoreBus, aMetaTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBattery) { + log("Found GT_MetaTileEntity_Hatch_InputBattery"); + aDidAdd = addToMachineListInternal(mChargeHatches, aMetaTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBattery) { + log("Found GT_MetaTileEntity_Hatch_OutputBattery"); + aDidAdd = addToMachineListInternal(mDischargeHatches, aMetaTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_AirIntake) { + aDidAdd = addToMachineListInternal(mAirIntakes, aMetaTileEntity, aBaseCasingIndex) + && addToMachineListInternal(mInputHatches, aMetaTileEntity, aBaseCasingIndex); + } + + // Handle TT Multi-A Energy Hatches + else if (LoadedMods.TecTech && isThisHatchMultiEnergy(aMetaTileEntity)) { + log("Found isThisHatchMultiEnergy"); + aDidAdd = addToMachineListInternal(mTecTechEnergyHatches, aMetaTileEntity, aBaseCasingIndex); + updateMasterEnergyHatchList(aMetaTileEntity); + } + + // Handle TT Multi-A Dynamos + else if (LoadedMods.TecTech && isThisHatchMultiDynamo(aMetaTileEntity)) { + log("Found isThisHatchMultiDynamo"); + aDidAdd = addToMachineListInternal(mTecTechDynamoHatches, aMetaTileEntity, aBaseCasingIndex); + updateMasterDynamoHatchList(aMetaTileEntity); + } + + // Handle Fluid Hatches using seperate logic + else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) + aDidAdd = addToMachineListInternal(mInputHatches, aMetaTileEntity, aBaseCasingIndex); + else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) + aDidAdd = addToMachineListInternal(mOutputHatches, aMetaTileEntity, aBaseCasingIndex); + + // Process Remaining hatches using Vanilla GT Logic + else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus) + aDidAdd = addToMachineListInternal(mInputBusses, aMetaTileEntity, aBaseCasingIndex); + else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) + aDidAdd = addToMachineListInternal(mOutputBusses, aMetaTileEntity, aBaseCasingIndex); + else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy) { + aDidAdd = addToMachineListInternal(mEnergyHatches, aMetaTileEntity, aBaseCasingIndex); + updateMasterEnergyHatchList(aMetaTileEntity); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Dynamo) { + aDidAdd = addToMachineListInternal(mDynamoHatches, aMetaTileEntity, aBaseCasingIndex); + updateMasterDynamoHatchList(aMetaTileEntity); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance) + aDidAdd = addToMachineListInternal(mMaintenanceHatches, aMetaTileEntity, aBaseCasingIndex); + else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) + aDidAdd = addToMachineListInternal(mMufflerHatches, aMetaTileEntity, aBaseCasingIndex); + + // return super.addToMachineList(aTileEntity, aBaseCasingIndex); + return aDidAdd; + } + + @Override + public boolean addMaintenanceToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + IMetaTileEntity aMetaTileEntity = getMetaTileEntity(aTileEntity); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance) { + return addToMachineList(aMetaTileEntity, aBaseCasingIndex); + } + return false; + } + + @Override + public boolean addMufflerToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + IMetaTileEntity aMetaTileEntity = getMetaTileEntity(aTileEntity); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) { + return addToMachineList(aMetaTileEntity, aBaseCasingIndex); + } + return false; + } + + @Override + public boolean addInputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + IMetaTileEntity aMetaTileEntity = getMetaTileEntity(aTileEntity); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input + || aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus) { + return addToMachineList(aMetaTileEntity, aBaseCasingIndex); + } + return false; + } + + @Override + public boolean addOutputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + IMetaTileEntity aMetaTileEntity = getMetaTileEntity(aTileEntity); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output + || aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) { + return addToMachineList(aMetaTileEntity, aBaseCasingIndex); + } + return false; + } + + public boolean addAirIntakeToMachineList(final IGregTechTileEntity aMetaTileEntity, final int aBaseCasingIndex) { + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_AirIntake) { + return addToMachineList(aMetaTileEntity, aBaseCasingIndex); + } + return false; + } + + public boolean addFluidInputToMachineList(final IGregTechTileEntity aTileEntity, final int aBaseCasingIndex) { + return addFluidInputToMachineList(getMetaTileEntity(aTileEntity), aBaseCasingIndex); + } + + public boolean addFluidInputToMachineList(final IMetaTileEntity aMetaTileEntity, final int aBaseCasingIndex) { + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { + return addToMachineList(aMetaTileEntity, aBaseCasingIndex); + } + return false; + } + + public boolean clearRecipeMapForAllInputHatches() { + return resetRecipeMapForAllInputHatches(null); + } + + public boolean resetRecipeMapForAllInputHatches() { + return resetRecipeMapForAllInputHatches(this.getRecipeMap()); + } + + public boolean resetRecipeMapForAllInputHatches(GT_Recipe_Map aMap) { + int cleared = 0; + for (GT_MetaTileEntity_Hatch_Input g : this.mInputHatches) { + if (resetRecipeMapForHatch(g, aMap)) { + cleared++; + } + } + for (GT_MetaTileEntity_Hatch_InputBus g : this.mInputBusses) { + if (resetRecipeMapForHatch(g, aMap)) { + cleared++; + } + } + return cleared > 0; + } + + public boolean resetRecipeMapForHatch(IGregTechTileEntity aTileEntity, GT_Recipe_Map aMap) { + try { + final IMetaTileEntity aMetaTileEntity = getMetaTileEntity(aTileEntity); + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input + || aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus + || aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Steam_BusInput) { + return resetRecipeMapForHatch((GT_MetaTileEntity_Hatch) aMetaTileEntity, aMap); + } else { + return false; + } + } catch (Throwable t) { + t.printStackTrace(); + return false; + } + } + + public boolean resetRecipeMapForHatch(GT_MetaTileEntity_Hatch aTileEntity, GT_Recipe_Map aMap) { + if (aTileEntity == null) { + return false; + } + final IMetaTileEntity aMetaTileEntity = aTileEntity; + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input + || aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus + || aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Steam_BusInput) { + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { + ((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity).mRecipeMap = null; + ((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity).mRecipeMap = aMap; + if (aMap != null && aMap.mNEIName != null) { + log("Remapped Input Hatch to " + aMap.mNEIName + "."); + } else { + log("Cleared Input Hatch."); + } + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus) { + ((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity).mRecipeMap = null; + ((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity).mRecipeMap = aMap; + if (aMap != null && aMap.mNEIName != null) { + log("Remapped Input Bus to " + aMap.mNEIName + "."); + } else { + log("Cleared Input Bus."); + } + } else { + ((GT_MetaTileEntity_Hatch_Steam_BusInput) aMetaTileEntity).mRecipeMap = null; + ((GT_MetaTileEntity_Hatch_Steam_BusInput) aMetaTileEntity).mRecipeMap = aMap; + if (aMap != null && aMap.mNEIName != null) { + log("Remapped Input Bus to " + aMap.mNEIName + "."); + } else { + log("Cleared Input Bus."); + } + } + return true; + } else { + return false; + } + } + + @Override + public final void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); + clearRecipeMapForAllInputHatches(); + onModeChangeByScrewdriver(aSide, aPlayer, aX, aY, aZ); + resetRecipeMapForAllInputHatches(); + } + + public void onModeChangeByScrewdriver(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) {} + + /** + * Enable Texture Casing Support if found in GT 5.09 + */ + public boolean updateTexture(final IGregTechTileEntity aTileEntity, int aCasingID) { + return updateTexture(getMetaTileEntity(aTileEntity), aCasingID); + } + + /** + * Enable Texture Casing Support if found in GT 5.09 + */ + @SuppressWarnings("deprecation") + public boolean updateTexture(final IMetaTileEntity aTileEntity, int aCasingID) { + try { // gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch.updateTexture(int) + + final IMetaTileEntity aMetaTileEntity = aTileEntity; + if (aMetaTileEntity == null) { + return false; + } + Method mProper = ReflectionUtils.getMethod(GT_MetaTileEntity_Hatch.class, "updateTexture", int.class); + if (mProper != null) { + if (GT_MetaTileEntity_Hatch.class.isInstance(aMetaTileEntity)) { + mProper.setAccessible(true); + mProper.invoke(aMetaTileEntity, aCasingID); + // log("Good Method Call for updateTexture."); + return true; + } + } else { + log("Bad Method Call for updateTexture."); + if (GT_MetaTileEntity_Hatch.class.isInstance(aMetaTileEntity)) { + if (aCasingID <= Byte.MAX_VALUE) { + ((GT_MetaTileEntity_Hatch) aTileEntity).mMachineBlock = (byte) aCasingID; + log( + "Good Method Call for updateTexture. Used fallback method of setting mMachineBlock as casing id was <= 128."); + return true; + } else { + log("updateTexture returning false. 1.2"); + } + } else { + log("updateTexture returning false. 1.3"); + } + } + log("updateTexture returning false. 1"); + return false; + } catch (SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + log("updateTexture returning false."); + log("updateTexture returning false. 2"); + e.printStackTrace(); + return false; + } + } + + /** + * TecTech Support + */ + + /** + * This is the array Used to Store the Tectech Multi-Amp Dynamo hatches. + */ + public ArrayList<GT_MetaTileEntity_Hatch> mTecTechDynamoHatches = new ArrayList<GT_MetaTileEntity_Hatch>(); + + /** + * This is the array Used to Store the Tectech Multi-Amp Energy hatches. + */ + public ArrayList<GT_MetaTileEntity_Hatch> mTecTechEnergyHatches = new ArrayList<GT_MetaTileEntity_Hatch>(); + + /** + * TecTech Multi-Amp Dynamo Support + * @param aTileEntity - The Dynamo Hatch + * @param aBaseCasingIndex - Casing Texture + * @return + */ + public boolean addMultiAmpDynamoToMachineList(final IGregTechTileEntity aTileEntity, final int aBaseCasingIndex) { + final IMetaTileEntity aMetaTileEntity = getMetaTileEntity(aTileEntity); + if (aMetaTileEntity == null) { + return false; + } + if (isThisHatchMultiDynamo(aTileEntity)) { + return addToMachineListInternal(mTecTechDynamoHatches, aMetaTileEntity, aBaseCasingIndex); + } + return false; + } + + public boolean isThisHatchMultiDynamo(IGregTechTileEntity aTileEntity) { + return isThisHatchMultiDynamo(getMetaTileEntity(aTileEntity)); + } + + public boolean isThisHatchMultiDynamo(IMetaTileEntity aMetaTileEntity) { + Class<?> mDynamoClass; + mDynamoClass = ReflectionUtils.getClass( + "com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_DynamoMulti"); + if (mDynamoClass != null) { + if (mDynamoClass.isInstance(aMetaTileEntity)) { + return true; + } + } + return false; + } + + @Override + public boolean addDynamoToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + IMetaTileEntity aMetaTileEntity = getMetaTileEntity(aTileEntity); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Dynamo || isThisHatchMultiDynamo(aMetaTileEntity)) { + return addToMachineList(aMetaTileEntity, aBaseCasingIndex); + } + return false; + } + + private boolean updateMasterDynamoHatchList(IMetaTileEntity aMetaTileEntity) { + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch) { + GT_MetaTileEntity_Hatch aHatch = (GT_MetaTileEntity_Hatch) aMetaTileEntity; + return mAllDynamoHatches.add(aHatch); + } + return false; + } + + /** + * TecTech Multi-Amp Energy Hatch Support + * @param aTileEntity - The Energy Hatch + * @param aBaseCasingIndex - Casing Texture + * @return + */ + public boolean addMultiAmpEnergyToMachineList(final IGregTechTileEntity aTileEntity, final int aBaseCasingIndex) { + final IMetaTileEntity aMetaTileEntity = getMetaTileEntity(aTileEntity); + if (aMetaTileEntity == null) { + return false; + } + if (isThisHatchMultiEnergy(aMetaTileEntity)) { + return addToMachineListInternal(mTecTechEnergyHatches, aMetaTileEntity, aBaseCasingIndex); + } + return false; + } + + public boolean isThisHatchMultiEnergy(IGregTechTileEntity aTileEntity) { + return isThisHatchMultiEnergy(getMetaTileEntity(aTileEntity)); + } + + public boolean isThisHatchMultiEnergy(IMetaTileEntity aMetaTileEntity) { + Class<?> mDynamoClass; + mDynamoClass = ReflectionUtils.getClass( + "com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_EnergyMulti"); + if (mDynamoClass != null) { + if (mDynamoClass.isInstance(aMetaTileEntity)) { + return true; + } + } + return false; + } + + @Override + public boolean addEnergyInputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + IMetaTileEntity aMetaTileEntity = getMetaTileEntity(aTileEntity); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy || isThisHatchMultiEnergy(aMetaTileEntity)) { + return addToMachineList(aMetaTileEntity, aBaseCasingIndex); + } + return false; + } + + private boolean updateMasterEnergyHatchList(IMetaTileEntity aMetaTileEntity) { + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch) { + GT_MetaTileEntity_Hatch aHatch = (GT_MetaTileEntity_Hatch) aMetaTileEntity; + return mAllEnergyHatches.add(aHatch); + } + return false; + } + + /** + * Pollution Management + */ + private static Method calculatePollutionReduction = null; + + public int calculatePollutionReductionForHatch(GT_MetaTileEntity_Hatch_Muffler i, int g) { + if (calculatePollutionReduction != null) { + try { + return (int) calculatePollutionReduction.invoke(i, g); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + + } + } + return 0; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setLong("mTotalRunTime", this.mTotalRunTime); + aNBT.setBoolean("mVoidExcess", this.mVoidExcess); + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + this.mTotalRunTime = aNBT.getLong("mTotalRunTime"); + this.mVoidExcess = aNBT.getBoolean("mVoidExcess"); + super.loadNBTData(aNBT); + } + + /** + * Custom Find Recipe with Debugging + */ + public GT_Recipe findRecipe( + final IHasWorldObjectAndCoords aTileEntity, + final boolean aNotUnificated, + final boolean aDontCheckStackSizes, + final long aVoltage, + final FluidStack[] aFluids, + final ItemStack... aInputs) { + return this.findRecipe( + aTileEntity, null, aNotUnificated, aDontCheckStackSizes, aVoltage, aFluids, (ItemStack) null, aInputs); + } + + public GT_Recipe findRecipe( + final IHasWorldObjectAndCoords aTileEntity, + final boolean aNotUnificated, + final long aVoltage, + final FluidStack[] aFluids, + final ItemStack... aInputs) { + return this.findRecipe(aTileEntity, null, aNotUnificated, aVoltage, aFluids, (ItemStack) null, aInputs); + } + + public GT_Recipe findRecipe( + final IHasWorldObjectAndCoords aTileEntity, + final GT_Recipe aRecipe, + final boolean aNotUnificated, + final boolean aDontCheckStackSizes, + final long aVoltage, + final FluidStack[] aFluids, + final ItemStack... aInputs) { + return this.findRecipe( + aTileEntity, + aRecipe, + aNotUnificated, + aDontCheckStackSizes, + aVoltage, + aFluids, + (ItemStack) null, + aInputs); + } + + public GT_Recipe findRecipe( + final IHasWorldObjectAndCoords aTileEntity, + final GT_Recipe aRecipe, + final boolean aNotUnificated, + final long aVoltage, + final FluidStack[] aFluids, + final ItemStack... aInputs) { + return this.findRecipe(aTileEntity, aRecipe, aNotUnificated, aVoltage, aFluids, (ItemStack) null, aInputs); + } + + public GT_Recipe findRecipe( + final IHasWorldObjectAndCoords aTileEntity, + final GT_Recipe aRecipe, + final boolean aNotUnificated, + final long aVoltage, + final FluidStack[] aFluids, + final ItemStack aSpecialSlot, + final ItemStack... aInputs) { + return this.findRecipe(aTileEntity, aRecipe, aNotUnificated, true, aVoltage, aFluids, aSpecialSlot, aInputs); + } + + public GT_Recipe findRecipe( + final IHasWorldObjectAndCoords aTileEntity, + final GT_Recipe aRecipe, + final boolean aNotUnificated, + final boolean aDontCheckStackSizes, + final long aVoltage, + final FluidStack[] aFluids, + final ItemStack aSpecialSlot, + ItemStack... aInputs) { + if (this.getRecipeMap().mRecipeList.isEmpty()) { + log("No Recipes in Map to search through."); + return null; + } + GT_Recipe mRecipeResult = null; + try { + if (GregTech_API.sPostloadFinished) { + if (this.getRecipeMap().mMinimalInputFluids > 0) { + if (aFluids == null) { + log("aFluids == null && minFluids > 0"); + return null; + } + int tAmount = 0; + for (final FluidStack aFluid : aFluids) { + if (aFluid != null) { + ++tAmount; + } + } + if (tAmount < this.getRecipeMap().mMinimalInputFluids) { + log("Not enough fluids?"); + return null; + } + } + if (this.getRecipeMap().mMinimalInputItems > 0) { + if (aInputs == null) { + log("No inputs and minItems > 0"); + return null; + } + int tAmount = 0; + for (final ItemStack aInput : aInputs) { + if (aInput != null) { + ++tAmount; + } + } + if (tAmount < this.getRecipeMap().mMinimalInputItems) { + log("Not enough items?"); + return null; + } + } + } else { + log("Game Not Loaded properly for recipe lookup."); + } + if (aNotUnificated) { + aInputs = GT_OreDictUnificator.getStackArray(true, (Object[]) aInputs); + } + if (aRecipe != null + && !aRecipe.mFakeRecipe + && aRecipe.mCanBeBuffered + && aRecipe.isRecipeInputEqual(false, aDontCheckStackSizes, aFluids, aInputs)) { + mRecipeResult = (aRecipe.mEnabled /* && aVoltage * this.getRecipeMap().mAmperage >= aRecipe.mEUt*/) + ? aRecipe + : null; + log("x) Found Recipe? " + (mRecipeResult != null ? "true" : "false")); + if (mRecipeResult != null) { + return mRecipeResult; + } + } + if (mRecipeResult == null + && this.getRecipeMap().mUsualInputCount >= 0 + && aInputs != null + && aInputs.length > 0) { + for (final ItemStack tStack : aInputs) { + if (tStack != null) { + Collection<GT_Recipe> tRecipes = + this.getRecipeMap().mRecipeItemMap.get(new GT_ItemStack(tStack)); + if (tRecipes != null) { + for (final GT_Recipe tRecipe : tRecipes) { + if (!tRecipe.mFakeRecipe + && tRecipe.isRecipeInputEqual(false, aDontCheckStackSizes, aFluids, aInputs)) { + mRecipeResult = + (tRecipe.mEnabled /* && aVoltage * this.getRecipeMap().mAmperage >= tRecipe.mEUt*/) + ? tRecipe + : null; + log("1) Found Recipe? " + (mRecipeResult != null ? "true" : "false")); + // return mRecipeResult; + } + } + } + + // TODO - Investigate if this requires to be in it's own block + tRecipes = this.getRecipeMap() + .mRecipeItemMap + .get(new GT_ItemStack(GT_Utility.copyMetaData(32767L, new Object[] {tStack}))); + if (tRecipes != null) { + for (final GT_Recipe tRecipe : tRecipes) { + if (!tRecipe.mFakeRecipe + && tRecipe.isRecipeInputEqual(false, aDontCheckStackSizes, aFluids, aInputs)) { + mRecipeResult = + (tRecipe.mEnabled /*&& aVoltage * this.getRecipeMap().mAmperage >= tRecipe.mEUt*/) + ? tRecipe + : null; + log("2) Found Recipe? " + (mRecipeResult != null ? "true" : "false")); + // return mRecipeResult; + } + } + } + } + } + } + if (mRecipeResult == null + && this.getRecipeMap().mMinimalInputItems == 0 + && aFluids != null + && aFluids.length > 0) { + for (final FluidStack aFluid2 : aFluids) { + if (aFluid2 != null) { + final Collection<GT_Recipe> tRecipes = + this.getRecipeMap().mRecipeFluidMap.get(aFluid2.getFluid()); + if (tRecipes != null) { + for (final GT_Recipe tRecipe : tRecipes) { + if (!tRecipe.mFakeRecipe + && tRecipe.isRecipeInputEqual(false, aDontCheckStackSizes, aFluids, aInputs)) { + mRecipeResult = + (tRecipe.mEnabled /* && aVoltage * this.getRecipeMap().mAmperage >= tRecipe.mEUt*/) + ? tRecipe + : null; + log("3) Found Recipe? " + (mRecipeResult != null ? "true" : "false")); + // return mRecipeResult; + } + } + } + } + } + } + } catch (Throwable t) { + log("Invalid recipe lookup."); + } + + if (mRecipeResult == null) { + log("Invalid recipe, Fallback lookup. " + + this.getRecipeMap().mRecipeList.size() + " | " + this.getRecipeMap().mNEIName); + if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { + try { + return (GT_Recipe) findRecipe08.invoke( + getRecipeMap(), + aTileEntity, + aRecipe, + aNotUnificated, + aVoltage, + aFluids, + aSpecialSlot, + aInputs); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + e.printStackTrace(); + return null; + } + } else { + try { + return (GT_Recipe) findRecipe09.invoke( + getRecipeMap(), + aTileEntity, + aRecipe, + aNotUnificated, + aDontCheckStackSizes, + aVoltage, + aFluids, + aSpecialSlot, + aInputs); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + e.printStackTrace(); + return null; + } + } + } else { + return mRecipeResult; + } + } + + /** + * Custom Tool Handling + */ + @Override + public boolean onRightclick( + IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, byte aSide, float aX, float aY, float aZ) { + // Do Things + if (this.getBaseMetaTileEntity().isServerSide()) { + // Logger.INFO("Right Clicked Controller."); + ItemStack tCurrentItem = aPlayer.inventory.getCurrentItem(); + if (tCurrentItem != null) { + // Logger.INFO("Holding Item."); + if (tCurrentItem.getItem() instanceof GT_MetaGenerated_Tool) { + // Logger.INFO("Is GT_MetaGenerated_Tool."); + int[] aOreID = OreDictionary.getOreIDs(tCurrentItem); + for (int id : aOreID) { + // Plunger + if (OreDictionary.getOreName(id).equals("craftingToolPlunger")) { + // Logger.INFO("Is Plunger."); + return onPlungerRightClick(aPlayer, aSide, aX, aY, aZ); + } + } + } + } + } + // Do Super + boolean aSuper = super.onRightclick(aBaseMetaTileEntity, aPlayer, aSide, aX, aY, aZ); + return aSuper; + } + + public boolean onPlungerRightClick(EntityPlayer aPlayer, byte aSide, float aX, float aY, float aZ) { + int aHatchIndex = 0; + PlayerUtils.messagePlayer(aPlayer, "Trying to clear " + mOutputHatches.size() + " output hatches."); + for (GT_MetaTileEntity_Hatch_Output hatch : this.mOutputHatches) { + if (hatch.mFluid != null) { + PlayerUtils.messagePlayer( + aPlayer, + "Clearing " + hatch.mFluid.amount + "L of " + hatch.mFluid.getLocalizedName() + " from hatch " + + aHatchIndex + "."); + hatch.mFluid = null; + } + aHatchIndex++; + } + return aHatchIndex > 0; + } + + @Override + public boolean onSolderingToolRightClick( + byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + boolean tSuper = super.onSolderingToolRightClick(aSide, aWrenchingSide, aPlayer, aX, aY, aZ); + if (aPlayer.isSneaking()) return tSuper; + mVoidExcess = !mVoidExcess; + aPlayer.addChatMessage(new ChatComponentTranslation( + mVoidExcess ? "interaction.voidexcess.enabled" : "interaction.voidexcess.disabled")); + return true; + } + + public boolean isValidBlockForStructure( + IGregTechTileEntity aBaseMetaTileEntity, + int aCasingID, + boolean canBeHatch, + Block aFoundBlock, + int aFoundMeta, + Block aExpectedBlock, + int aExpectedMeta) { + boolean isHatch = false; + if (aBaseMetaTileEntity != null) { + + // Unsure why this check exists? + /*if (aCasingID < 64) { + aCasingID = TAE.GTPP_INDEX(aCasingID); + }*/ + + isHatch = this.addToMachineList(aBaseMetaTileEntity, aCasingID); + if (isHatch) { + return true; + } else { + int aMetaTileID = aBaseMetaTileEntity.getMetaTileID(); + // Found a controller + if (aMetaTileID >= 750 && aMetaTileID < 1000 && aFoundBlock == GregTech_API.sBlockMachines) { + return true; + } + // Vanilla Hatches/Busses + else if (aMetaTileID >= 10 && aMetaTileID <= 99 && aFoundBlock == GregTech_API.sBlockMachines) { + return true; + } + // Adv Mufflers + else if (aMetaTileID >= 30001 && aMetaTileID <= 30009 && aFoundBlock == GregTech_API.sBlockMachines) { + return true; + } + // Control Core, Super IO + else if (aMetaTileID >= 30020 && aMetaTileID <= 30040 && aFoundBlock == GregTech_API.sBlockMachines) { + return true; + } + // Auto maint + else if (aMetaTileID == 111 && aFoundBlock == GregTech_API.sBlockMachines) { + return true; + } + // Data Ports + else if ((aMetaTileID == 131 || aMetaTileID == 132) && aFoundBlock == GregTech_API.sBlockMachines) { + return true; + } else { + log("Found meta Tile: " + aMetaTileID); + } + } + } + if (!isHatch) { + if (aFoundBlock == aExpectedBlock && aFoundMeta == aExpectedMeta) { + return true; + } 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())); + } + return false; + } else if (aFoundMeta != aExpectedMeta) { + log("A2"); + return false; + } + } + log("A3"); + return false; + } + + @Override + public void onServerStart() { + super.onServerStart(); + tryTickWaitTimerDown(); + } + + @Override + public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { + super.onFirstTick(aBaseMetaTileEntity); + tryTickWaitTimerDown(); + } + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPreTick(aBaseMetaTileEntity, aTick); + tryTickWaitTimerDown(); + } + + @Override + public void onCreated(ItemStack aStack, World aWorld, EntityPlayer aPlayer) { + super.onCreated(aStack, aWorld, aPlayer); + tryTickWaitTimerDown(); + } + + private final void tryTickWaitTimerDown() { + /*if (mStartUpCheck > 10) { + mStartUpCheck = 10; + }*/ + } + + // Only support to use meta to tier + + /** + * accept meta [0, maxMeta) + * @param maxMeta exclusive + */ + public static <T> IStructureElement<T> addTieredBlock( + Block aBlock, + BiConsumer<T, Integer> aSetTheFuckingMeta, + Function<T, Integer> aGetTheFuckingMeta, + int maxMeta) { + return addTieredBlock( + aBlock, + (t, i) -> { + aSetTheFuckingMeta.accept(t, i); + return true; + }, + aGetTheFuckingMeta, + 0, + maxMeta); + } + + /** + * + * @param minMeta inclusive + * @param maxMeta exclusive + */ + public static <T> IStructureElement<T> addTieredBlock( + Block aBlock, + BiConsumer<T, Integer> aSetTheFuckingMeta, + Function<T, Integer> aGetTheFuckingMeta, + int minMeta, + int maxMeta) { + return addTieredBlock( + aBlock, + (t, i) -> { + aSetTheFuckingMeta.accept(t, i); + return true; + }, + aGetTheFuckingMeta, + minMeta, + maxMeta); + } + + /** + * + * @param minMeta inclusive + * @param maxMeta exclusive + */ + public static <T> IStructureElement<T> addTieredBlock( + Block aBlock, + BiPredicate<T, Integer> aSetTheFuckingMeta, + Function<T, Integer> aGetTheFuckingMeta, + int minMeta, + int maxMeta) { + + return new IStructureElement<T>() { + @Override + public boolean check(T t, World world, int x, int y, int z) { + Block tBlock = world.getBlock(x, y, z); + if (aBlock == tBlock) { + Integer currentMeta = aGetTheFuckingMeta.apply(t); + int newMeta = tBlock.getDamageValue(world, x, y, z) + 1; + if (newMeta > maxMeta || newMeta < minMeta + 1) return false; + if (currentMeta == 0) { + return aSetTheFuckingMeta.test(t, newMeta); + } else { + return currentMeta == newMeta; + } + } + return false; + } + + @Override + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { + StructureLibAPI.hintParticle(world, x, y, z, aBlock, getMeta(trigger)); + return true; + } + + @Override + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { + return world.setBlock(x, y, z, aBlock, getMeta(trigger), 3); + } + + private int getMeta(ItemStack trigger) { + int meta = trigger.stackSize; + if (meta <= 0) meta = minMeta; + if (meta + minMeta >= maxMeta) meta = maxMeta - 1 - minMeta; + return meta + minMeta; + } + + @Override + public PlaceResult survivalPlaceBlock( + T t, + World world, + int x, + int y, + int z, + ItemStack trigger, + IItemSource s, + EntityPlayerMP actor, + Consumer<IChatComponent> chatter) { + if (world.getBlock(x, y, z) == aBlock) { + if (world.getBlockMetadata(x, y, z) == getMeta(trigger)) { + return PlaceResult.SKIP; + } + return PlaceResult.REJECT; + } + return StructureUtility.survivalPlaceBlock(aBlock, getMeta(trigger), world, x, y, z, s, actor, chatter); + } + }; + } + + @Override + public ITexture[] getTexture( + IGregTechTileEntity aBaseMetaTileEntity, + byte aSide, + byte aFacing, + byte aColorIndex, + boolean aActive, + boolean aRedstone) { + if (aSide == aFacing) { + if (aActive) + return new ITexture[] { + getCasingTexture(), + TextureFactory.builder() + .addIcon(getActiveOverlay()) + .extFacing() + .build() + }; + return new ITexture[] { + getCasingTexture(), + TextureFactory.builder() + .addIcon(getInactiveOverlay()) + .extFacing() + .build() + }; + } + return new ITexture[] {getCasingTexture()}; + } + + protected IIconContainer getActiveOverlay() { + return null; + } + + protected IIconContainer getInactiveOverlay() { + return null; + } + + protected ITexture getCasingTexture() { + return Textures.BlockIcons.getCasingTextureForId(getCasingTextureId()); + } + + protected int getCasingTextureId() { + return 0; + } + + public enum GTPPHatchElement implements IHatchElement<GregtechMeta_MultiBlockBase<?>> { + AirIntake(GregtechMeta_MultiBlockBase::addAirIntakeToMachineList, GT_MetaTileEntity_Hatch_AirIntake.class) { + @Override + public long count(GregtechMeta_MultiBlockBase<?> t) { + return t.mAirIntakes.size(); + } + }, + ControlCore( + GregtechMeta_MultiBlockBase::addControlCoreToMachineList, GT_MetaTileEntity_Hatch_ControlCore.class) { + @Override + public long count(GregtechMeta_MultiBlockBase<?> t) { + return t.mControlCoreBus.size(); + } + }, + TTDynamo( + GregtechMeta_MultiBlockBase::addMultiAmpDynamoToMachineList, + "com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_DynamoMulti") { + @Override + public long count(GregtechMeta_MultiBlockBase<?> t) { + return t.mTecTechDynamoHatches.size(); + } + }, + TTEnergy( + GregtechMeta_MultiBlockBase::addMultiAmpEnergyToMachineList, + "com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_EnergyMulti") { + @Override + public long count(GregtechMeta_MultiBlockBase<?> t) { + return t.mTecTechEnergyHatches.size(); + } + }, + ; + + @SuppressWarnings("unchecked") + private static <T> Class<T> retype(Class<?> clazz) { + return (Class<T>) clazz; + } + + private final List<? extends Class<? extends IMetaTileEntity>> mMteClasses; + private final IGT_HatchAdder<? super GregtechMeta_MultiBlockBase<?>> mAdder; + + @SafeVarargs + GTPPHatchElement( + IGT_HatchAdder<? super GregtechMeta_MultiBlockBase<?>> aAdder, + Class<? extends IMetaTileEntity>... aMteClasses) { + this.mMteClasses = Arrays.asList(aMteClasses); + this.mAdder = aAdder; + } + + GTPPHatchElement(IGT_HatchAdder<? super GregtechMeta_MultiBlockBase<?>> aAdder, String... aClassNames) { + this.mMteClasses = Arrays.stream(aClassNames) + .map(ReflectionUtils::getClass) + .filter(Objects::nonNull) + .<Class<? extends IMetaTileEntity>>map(GTPPHatchElement::retype) + .collect(Collectors.toList()); + this.mAdder = aAdder; + } + + @Override + public List<? extends Class<? extends IMetaTileEntity>> mteClasses() { + return mMteClasses; + } + + @Override + public IGT_HatchAdder<? super GregtechMeta_MultiBlockBase<?>> adder() { + return mAdder; + } + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_SteamMultiBase.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_SteamMultiBase.java index 5503280409..119d681212 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_SteamMultiBase.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_SteamMultiBase.java @@ -1,7 +1,7 @@ package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base; -import java.util.ArrayList; -import java.util.List; +import static gregtech.api.enums.GT_Values.V; +import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; @@ -16,265 +16,268 @@ import gtPlusPlus.api.objects.data.*; import gtPlusPlus.core.util.minecraft.FluidUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Steam_BusInput; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Steam_BusOutput; +import java.util.ArrayList; +import java.util.List; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.util.StatCollector; import net.minecraftforge.fluids.FluidStack; import org.apache.commons.lang3.ArrayUtils; +public abstract class GregtechMeta_SteamMultiBase<T extends GregtechMeta_SteamMultiBase<T>> + extends GregtechMeta_MultiBlockBase<T> { -import static gregtech.api.enums.GT_Values.V; -import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; + public ArrayList<GT_MetaTileEntity_Hatch_Steam_BusInput> mSteamInputs = + new ArrayList<GT_MetaTileEntity_Hatch_Steam_BusInput>(); + public ArrayList<GT_MetaTileEntity_Hatch_Steam_BusOutput> mSteamOutputs = + new ArrayList<GT_MetaTileEntity_Hatch_Steam_BusOutput>(); + public ArrayList<GT_MetaTileEntity_Hatch_CustomFluidBase> mSteamInputFluids = + new ArrayList<GT_MetaTileEntity_Hatch_CustomFluidBase>(); + + protected static final String TT_steaminputbus = StatCollector.translateToLocal("GTPP.MBTT.SteamInputBus"); + protected static final String TT_steamoutputbus = StatCollector.translateToLocal("GTPP.MBTT.SteamOutputBus"); + protected static final String TT_steamhatch = StatCollector.translateToLocal("GTPP.MBTT.SteamHatch"); + + public GregtechMeta_SteamMultiBase(String aName) { + super(aName); + } + + public GregtechMeta_SteamMultiBase(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + @Override + public ITexture[] getTexture( + final IGregTechTileEntity aBaseMetaTileEntity, + final byte aSide, + final byte aFacing, + final byte aColorIndex, + final boolean aActive, + final boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[] { + Textures.BlockIcons.getCasingTextureForId(getCasingTextureIndex()), + aActive ? getFrontOverlayActive() : getFrontOverlay() + }; + } + return new ITexture[] {Textures.BlockIcons.getCasingTextureForId(getCasingTextureIndex())}; + } + + protected abstract GT_RenderedTexture getFrontOverlay(); + + protected abstract GT_RenderedTexture getFrontOverlayActive(); + + private int getCasingTextureIndex() { + return 10; + } + + @Override + public boolean hasSlotInGUI() { + return true; + } + + @Override + public String getCustomGUIResourceName() { + return null; + } + + @Override + public int getEuDiscountForParallelism() { + return 0; + } + + @Override + public boolean checkRecipe(ItemStack arg0) { + + log("Running checkRecipeGeneric(0)"); + ArrayList<ItemStack> tItems = getStoredInputs(); + ArrayList<FluidStack> tFluids = getStoredFluids(); + GT_Recipe_Map tMap = this.getRecipeMap(); + if (tMap == null) { + return false; + } + ItemStack[] aItemInputs = tItems.toArray(new ItemStack[0]); + FluidStack[] aFluidInputs = tFluids.toArray(new FluidStack[0]); + GT_Recipe tRecipe = tMap.findRecipe(getBaseMetaTileEntity(), mLastRecipe, false, V[1], null, null, aItemInputs); + if (tRecipe == null) { + log("BAD RETURN - 1"); + return false; + } + + int aEUPercent = 100; + int aSpeedBonusPercent = 0; + int aOutputChanceRoll = 10000; + + // Reset outputs and progress stats + this.mEUt = 0; + this.mMaxProgresstime = 0; + this.mOutputItems = new ItemStack[] {}; + this.mOutputFluids = new FluidStack[] {}; + + log("Running checkRecipeGeneric(1)"); + // Remember last recipe - an optimization for findRecipe() + this.mLastRecipe = tRecipe; + + int aMaxParallelRecipes = + canBufferOutputs(tRecipe.mOutputs, tRecipe.mFluidOutputs, this.getMaxParallelRecipes()); + if (aMaxParallelRecipes == 0) { + log("BAD RETURN - 2"); + return false; + } + + // EU discount + float tRecipeEUt = (tRecipe.mEUt * aEUPercent) / 100.0f; + float tTotalEUt = 0.0f; + + int parallelRecipes = 0; + + log("parallelRecipes: " + parallelRecipes); + log("aMaxParallelRecipes: " + aMaxParallelRecipes); + log("tTotalEUt: " + tTotalEUt); + log("tRecipeEUt: " + tRecipeEUt); + + // Count recipes to do in parallel, consuming input items and fluids and considering input voltage limits + for (; parallelRecipes < aMaxParallelRecipes && tTotalEUt < (32 - tRecipeEUt); parallelRecipes++) { + if (!tRecipe.isRecipeInputEqual(true, aFluidInputs, aItemInputs)) { + log("Broke at " + parallelRecipes + "."); + break; + } + log("Bumped EU from " + tTotalEUt + " to " + (tTotalEUt + tRecipeEUt) + "."); + tTotalEUt += tRecipeEUt; + } + + if (parallelRecipes == 0) { + log("BAD RETURN - 3"); + return false; + } + + // -- Try not to fail after this point - inputs have already been consumed! -- + + // Convert speed bonus to duration multiplier + // e.g. 100% speed bonus = 200% speed = 100%/200% = 50% recipe duration. + aSpeedBonusPercent = Math.max(-99, aSpeedBonusPercent); + float tTimeFactor = 100.0f / (100.0f + aSpeedBonusPercent); + this.mMaxProgresstime = (int) (tRecipe.mDuration * tTimeFactor * 1.5f); + + this.mEUt = (int) Math.ceil(tTotalEUt * 1.33f); + + // this.mEUt = (3 * tRecipe.mEUt); + + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + + if (this.mEUt > 0) { + this.mEUt = (-this.mEUt); + } + + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + + // Collect fluid outputs + FluidStack[] tOutputFluids = getOutputFluids(tRecipe, parallelRecipes); + + // Collect output item types + ItemStack[] tOutputItems = getOutputItems(tRecipe); + + // 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 < parallelRecipes; 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[0]); + + // Commit outputs + this.mOutputItems = tOutputItems; + this.mOutputFluids = tOutputFluids; + updateSlots(); + + // Play sounds (GT++ addition - GT multiblocks play no sounds) + startProcess(); + + log("GOOD RETURN - 1"); + return true; + } + + public ArrayList<FluidStack> getAllSteamStacks() { + ArrayList<FluidStack> aFluids = new ArrayList<FluidStack>(); + FluidStack aSteam = FluidUtils.getSteam(1); + for (FluidStack aFluid : this.getStoredFluids()) { + if (aFluid.isFluidEqual(aSteam)) { + aFluids.add(aFluid); + } + } + return aFluids; + } + + public int getTotalSteamStored() { + int aSteam = 0; + for (FluidStack aFluid : getAllSteamStacks()) { + aSteam += aFluid.amount; + } + return aSteam; + } + + public boolean tryConsumeSteam(int aAmount) { + if (getTotalSteamStored() <= 0) { + return false; + } else { + return this.depleteInput(FluidUtils.getSteam(aAmount)); + } + } + + @Override + public int getMaxEfficiency(ItemStack arg0) { + return 0; + } + + @Override + public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { + if (aBaseMetaTileEntity.isServerSide()) { + if (this.mUpdate == 1 || this.mStartUpCheck == 1) { + this.mSteamInputs.clear(); + this.mSteamOutputs.clear(); + this.mSteamInputFluids.clear(); + } + } + super.onPostTick(aBaseMetaTileEntity, aTick); + } -public abstract class GregtechMeta_SteamMultiBase<T extends GregtechMeta_SteamMultiBase<T>> extends GregtechMeta_MultiBlockBase<T> { - - public ArrayList<GT_MetaTileEntity_Hatch_Steam_BusInput> mSteamInputs = new ArrayList<GT_MetaTileEntity_Hatch_Steam_BusInput>(); - public ArrayList<GT_MetaTileEntity_Hatch_Steam_BusOutput> mSteamOutputs = new ArrayList<GT_MetaTileEntity_Hatch_Steam_BusOutput>(); - public ArrayList<GT_MetaTileEntity_Hatch_CustomFluidBase> mSteamInputFluids = new ArrayList<GT_MetaTileEntity_Hatch_CustomFluidBase>(); - - protected static final String TT_steaminputbus = StatCollector.translateToLocal("GTPP.MBTT.SteamInputBus"); - protected static final String TT_steamoutputbus = StatCollector.translateToLocal("GTPP.MBTT.SteamOutputBus"); - protected static final String TT_steamhatch = StatCollector.translateToLocal("GTPP.MBTT.SteamHatch"); - - public GregtechMeta_SteamMultiBase(String aName) { - super(aName); - } - - public GregtechMeta_SteamMultiBase(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { - if (aSide == aFacing) { - return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(getCasingTextureIndex()), aActive ? getFrontOverlayActive() : getFrontOverlay()}; - } - return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(getCasingTextureIndex())}; - } - - protected abstract GT_RenderedTexture getFrontOverlay(); - - protected abstract GT_RenderedTexture getFrontOverlayActive(); - - private int getCasingTextureIndex() { - return 10; - } - - @Override - public boolean hasSlotInGUI() { - return true; - } - - @Override - public String getCustomGUIResourceName() { - return null; - } - - @Override - public int getEuDiscountForParallelism() { - return 0; - } - - @Override - public boolean checkRecipe(ItemStack arg0) { - - - log("Running checkRecipeGeneric(0)"); - ArrayList<ItemStack> tItems = getStoredInputs(); - ArrayList<FluidStack> tFluids = getStoredFluids(); - GT_Recipe_Map tMap = this.getRecipeMap(); - if (tMap == null) { - return false; - } - ItemStack[] aItemInputs = tItems.toArray(new ItemStack[0]); - FluidStack[] aFluidInputs = tFluids.toArray(new FluidStack[0]); - GT_Recipe tRecipe = tMap.findRecipe(getBaseMetaTileEntity(), mLastRecipe, false, V[1], null, null, aItemInputs); - if (tRecipe == null) { - log("BAD RETURN - 1"); - return false; - } - - int aEUPercent = 100; - int aSpeedBonusPercent = 0; - int aOutputChanceRoll = 10000; - - // Reset outputs and progress stats - this.mEUt = 0; - this.mMaxProgresstime = 0; - this.mOutputItems = new ItemStack[]{}; - this.mOutputFluids = new FluidStack[]{}; - - - log("Running checkRecipeGeneric(1)"); - // Remember last recipe - an optimization for findRecipe() - this.mLastRecipe = tRecipe; - - - int aMaxParallelRecipes = canBufferOutputs(tRecipe.mOutputs, tRecipe.mFluidOutputs, this.getMaxParallelRecipes()); - if (aMaxParallelRecipes == 0) { - log("BAD RETURN - 2"); - return false; - } - - // EU discount - float tRecipeEUt = (tRecipe.mEUt * aEUPercent) / 100.0f; - float tTotalEUt = 0.0f; - - int parallelRecipes = 0; - - log("parallelRecipes: "+parallelRecipes); - log("aMaxParallelRecipes: "+aMaxParallelRecipes); - log("tTotalEUt: "+tTotalEUt); - log("tRecipeEUt: "+tRecipeEUt); - - - - // Count recipes to do in parallel, consuming input items and fluids and considering input voltage limits - for (; parallelRecipes < aMaxParallelRecipes && tTotalEUt < (32 - tRecipeEUt); parallelRecipes++) { - if (!tRecipe.isRecipeInputEqual(true, aFluidInputs, aItemInputs)) { - log("Broke at "+parallelRecipes+"."); - break; - } - log("Bumped EU from "+tTotalEUt+" to "+(tTotalEUt+tRecipeEUt)+"."); - tTotalEUt += tRecipeEUt; - } - - if (parallelRecipes == 0) { - log("BAD RETURN - 3"); - return false; - } - - // -- Try not to fail after this point - inputs have already been consumed! -- - - - - // Convert speed bonus to duration multiplier - // e.g. 100% speed bonus = 200% speed = 100%/200% = 50% recipe duration. - aSpeedBonusPercent = Math.max(-99, aSpeedBonusPercent); - float tTimeFactor = 100.0f / (100.0f + aSpeedBonusPercent); - this.mMaxProgresstime = (int)(tRecipe.mDuration * tTimeFactor * 1.5f); - - this.mEUt = (int)Math.ceil(tTotalEUt*1.33f); - - //this.mEUt = (3 * tRecipe.mEUt); - - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - - if (this.mEUt > 0) { - this.mEUt = (-this.mEUt); - } - - this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - - // Collect fluid outputs - FluidStack[] tOutputFluids = getOutputFluids(tRecipe, parallelRecipes); - - // Collect output item types - ItemStack[] tOutputItems = getOutputItems(tRecipe); - - // 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 < parallelRecipes; 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[0]); - - // Commit outputs - this.mOutputItems = tOutputItems; - this.mOutputFluids = tOutputFluids; - updateSlots(); - - // Play sounds (GT++ addition - GT multiblocks play no sounds) - startProcess(); - - log("GOOD RETURN - 1"); - return true; - - } - - public ArrayList<FluidStack> getAllSteamStacks(){ - ArrayList<FluidStack> aFluids = new ArrayList<FluidStack>(); - FluidStack aSteam = FluidUtils.getSteam(1); - for (FluidStack aFluid : this.getStoredFluids()) { - if (aFluid.isFluidEqual(aSteam)) { - aFluids.add(aFluid); - } - } - return aFluids; - } - - public int getTotalSteamStored() { - int aSteam = 0; - for (FluidStack aFluid : getAllSteamStacks()) { - aSteam += aFluid.amount; - } - return aSteam; - } - - public boolean tryConsumeSteam(int aAmount) { - if (getTotalSteamStored() <= 0) { - return false; - } - else { - return this.depleteInput(FluidUtils.getSteam(aAmount)); - } - } - - @Override - public int getMaxEfficiency(ItemStack arg0) { - return 0; - } - - @Override - public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { - if (aBaseMetaTileEntity.isServerSide()) { - if (this.mUpdate == 1 || this.mStartUpCheck == 1) { - this.mSteamInputs.clear(); - this.mSteamOutputs.clear(); - this.mSteamInputFluids.clear(); - } - } - super.onPostTick(aBaseMetaTileEntity, aTick); - } - /** * Called every tick the Machine runs */ public boolean onRunningTick(ItemStack aStack) { - fixAllMaintenanceIssue(); + fixAllMaintenanceIssue(); if (mEUt < 0) { - long aSteamVal = (((long) -mEUt * 10000) / Math.max(1000, mEfficiency)); - //Logger.INFO("Trying to drain "+aSteamVal+" steam per tick."); + long aSteamVal = (((long) -mEUt * 10000) / Math.max(1000, mEfficiency)); + // Logger.INFO("Trying to drain "+aSteamVal+" steam per tick."); if (!tryConsumeSteam((int) aSteamVal)) { stopMachine(); return false; @@ -282,403 +285,408 @@ public abstract class GregtechMeta_SteamMultiBase<T extends GregtechMeta_SteamMu } return true; } - - @Override - public boolean addToMachineList(final IGregTechTileEntity aTileEntity, final int aBaseCasingIndex) { - if (aTileEntity == null) { - log("Invalid IGregTechTileEntity"); - return false; - } - final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) { - log("Invalid IMetaTileEntity"); - return false; - } - - //Use this to determine the correct value, then update the hatch texture after. - boolean aDidAdd = false; - - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_CustomFluidBase) { - log("Adding Steam Input Hatch"); - aDidAdd = addToMachineListInternal(mSteamInputFluids, aMetaTileEntity, aBaseCasingIndex); - } - else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Steam_BusInput) { - log("Trying to set recipe map. Type: "+(getRecipeMap() != null ? getRecipeMap().mNEIName : "Null")); - this.resetRecipeMapForHatch(aTileEntity, getRecipeMap()); - log("Adding Steam Input Bus"); + + @Override + public boolean addToMachineList(final IGregTechTileEntity aTileEntity, final int aBaseCasingIndex) { + if (aTileEntity == null) { + log("Invalid IGregTechTileEntity"); + return false; + } + final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + log("Invalid IMetaTileEntity"); + return false; + } + + // Use this to determine the correct value, then update the hatch texture after. + boolean aDidAdd = false; + + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_CustomFluidBase) { + log("Adding Steam Input Hatch"); + aDidAdd = addToMachineListInternal(mSteamInputFluids, aMetaTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Steam_BusInput) { + log("Trying to set recipe map. Type: " + (getRecipeMap() != null ? getRecipeMap().mNEIName : "Null")); + this.resetRecipeMapForHatch(aTileEntity, getRecipeMap()); + log("Adding Steam Input Bus"); aDidAdd = addToMachineListInternal(mSteamInputs, aMetaTileEntity, aBaseCasingIndex); - } - else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Steam_BusOutput) { - log("Adding Steam Output Bus"); - aDidAdd = addToMachineListInternal(mSteamOutputs, aMetaTileEntity, aBaseCasingIndex); - } - - return aDidAdd; - } - - - - - @Override - public void stopMachine() { - super.stopMachine(); - } - - public FluidStack[] getOutputFluids(GT_Recipe aRecipe, int parallelRecipes) { - // Collect fluid outputs - FluidStack[] tOutputFluids = new FluidStack[aRecipe.mFluidOutputs.length]; - for (int h = 0; h < aRecipe.mFluidOutputs.length; h++) { - if (aRecipe.getFluidOutput(h) != null) { - tOutputFluids[h] = aRecipe.getFluidOutput(h).copy(); - tOutputFluids[h].amount *= parallelRecipes; - } - } - return tOutputFluids; - } - - public ItemStack[] getOutputItems(GT_Recipe aRecipe) { - // Collect output item types - ItemStack[] tOutputItems = new ItemStack[aRecipe.mOutputs.length]; - for (int h = 0; h < aRecipe.mOutputs.length; h++) { - if (aRecipe.getOutput(h) != null) { - tOutputItems[h] = aRecipe.getOutput(h).copy(); - tOutputItems[h].stackSize = 0; - } - } - return tOutputItems; - } - - public int getOutputCount(ItemStack[] aOutputs) { - return aOutputs.length; - } - public int getOutputFluidCount(FluidStack[] aOutputs) { - return aOutputs.length; - } - - public int canBufferOutputs(final ItemStack[] aOutputs, FluidStack[] aFluidOutputs, int aParallelRecipes) { - - log("Determining if we have space to buffer outputs. Parallel: "+aParallelRecipes); - - // Null recipe or a recipe with lots of outputs? - // E.G. Gendustry custom comb with a billion centrifuge outputs? - // Do it anyway, provided the multi allows it. Default behaviour is aAllow16SlotWithoutCheck = true. - if (aOutputs == null && aFluidOutputs == null) { - return 0; - } - - // Do we even need to check for item outputs? - boolean aDoesOutputItems = aOutputs != null ? aOutputs.length > 0 : false; - // Do we even need to check for fluid outputs? - boolean aDoesOutputFluids = aFluidOutputs != null ? aFluidOutputs.length > 0 : false; - - if (!aDoesOutputItems && !aDoesOutputFluids) { - return 0; - } - - /* ======================================== - * Item Management - * ======================================== - */ - - if (aDoesOutputItems) { - log("We have items to output."); - - // How many slots are free across all the output buses? - int aInputBusSlotsFree = 0; - - /* - * Create Variables for Item Output - */ - - AutoMap<FlexiblePair<ItemStack, Integer>> aItemMap = new AutoMap<FlexiblePair<ItemStack, Integer>>(); - AutoMap<ItemStack> aItemOutputs = new AutoMap<ItemStack>(aOutputs); - - for (final GT_MetaTileEntity_Hatch_Steam_BusOutput tBus : this.mSteamOutputs) { - if (!isValidMetaTileEntity(tBus)) { - continue; - } - final IInventory tBusInv = tBus.getBaseMetaTileEntity(); - for (int i = 0; i < tBusInv.getSizeInventory(); i++) { - if (tBus.getStackInSlot(i) == null) { - aInputBusSlotsFree++; - } - else { - ItemStack aT = tBus.getStackInSlot(i); - int aSize = aT.stackSize; - aT = aT.copy(); - aT.stackSize = 0; - aItemMap.put(new FlexiblePair<ItemStack, Integer>(aT, aSize)); - } - } - } - - // Count the slots we need, later we can check if any are able to merge with existing stacks - int aRecipeSlotsRequired = 0; - - // A map to hold the items we will be 'inputting' into the output buses. These itemstacks are actually the recipe outputs. - ConcurrentSet<FlexiblePair<ItemStack, Integer>> aInputMap = new ConcurrentHashSet<FlexiblePair<ItemStack, Integer>>(); - - // Iterate over the outputs, calculating require stack spacing they will require. - for (int i=0;i<getOutputCount(aOutputs);i++) { - ItemStack aY = aItemOutputs.get(i); - if (aY == null) { - continue; - } - else { - int aStackSize = aY.stackSize * aParallelRecipes; - if (aStackSize > 64) { - int aSlotsNeedsForThisStack = (int) Math.ceil((double) ((float) aStackSize / 64f)); - // Should round up and add as many stacks as required nicely. - aRecipeSlotsRequired += aSlotsNeedsForThisStack; - for (int o=0;o<aRecipeSlotsRequired;o++) { - int aStackToRemove = (aStackSize -= 64) > 64 ? 64 : aStackSize; - aY = aY.copy(); - aY.stackSize = 0; - aInputMap.add(new FlexiblePair<ItemStack, Integer>(aY, aStackToRemove)); - } - } - else { - // Only requires one slot - aRecipeSlotsRequired++; - aY = aY.copy(); - aY.stackSize = 0; - aInputMap.add(new FlexiblePair<ItemStack, Integer>(aY, aStackSize)); - } - } - } - - // We have items to add to the output buses. See if any are not full stacks and see if we can make them full. - if (aInputMap.size() > 0) { - // Iterate over the current stored items in the Output busses, if any match and are not full, we can try account for merging. - busItems: for (FlexiblePair<ItemStack, Integer> y : aItemMap) { - // Iterate over the 'inputs', we can safely remove these as we go. - outputItems: for (FlexiblePair<ItemStack, Integer> u : aInputMap) { - // Create local vars for readability. - ItemStack aOutputBusStack = y.getKey(); - ItemStack aOutputStack = u.getKey(); - // Stacks match, including NBT. - if (GT_Utility.areStacksEqual(aOutputBusStack, aOutputStack, false)) { - // Stack Matches, but it's full, continue. - if (aOutputBusStack.stackSize >= 64) { - // This stack is full, no point checking it. - continue busItems; - } - else { - // We can merge these two stacks without any hassle. - if ((aOutputBusStack.stackSize + aOutputStack.stackSize) <= 64) { - // Update the stack size in the bus storage map. - y.setValue(aOutputBusStack.stackSize + aOutputStack.stackSize); - // Remove the 'input' stack from the recipe outputs, so we don't try count it again. - aInputMap.remove(u); - continue outputItems; - } - // Stack merging is too much, so we fill this stack, leave the remainder. - else { - int aRemainder = (aOutputBusStack.stackSize + aOutputStack.stackSize) - 64; - // Update the stack size in the bus storage map. - y.setValue(64); - // Create a new object to iterate over later, with the remainder data; - FlexiblePair<ItemStack, Integer> t = new FlexiblePair<ItemStack, Integer>(u.getKey(), aRemainder); - // Remove the 'input' stack from the recipe outputs, so we don't try count it again. - aInputMap.remove(u); - // Add the remainder stack. - aInputMap.add(t); - continue outputItems; - } - } - } - else { - continue outputItems; - } - } - } - } - - // We have stacks that did not merge, do we have space for them? - if (aInputMap.size() > 0) { - if (aInputMap.size() > aInputBusSlotsFree) { - aParallelRecipes = (int) Math.floor((double) aInputBusSlotsFree/aInputMap.size() * aParallelRecipes); - // We do not have enough free slots in total to accommodate the remaining managed stacks. - log(" Free: "+aInputBusSlotsFree+", Required: "+aInputMap.size()); - if(aParallelRecipes == 0) { - log("Failed to find enough space for all item outputs."); - return 0; - } - - } - } - - /* - * End Item Management - */ - - } - - - - - - /* ======================================== - * Fluid Management - * ======================================== - */ - - - - if (aDoesOutputFluids) { - log("We have Fluids to output."); - // How many slots are free across all the output buses? - int aFluidHatches = 0; - int aEmptyFluidHatches = 0; - int aFullFluidHatches = 0; - // Create Map for Fluid Output - ArrayList<Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer>> aOutputHatches = new ArrayList<Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer>>(); - for (final GT_MetaTileEntity_Hatch_Output tBus : this.mOutputHatches) { - if (!isValidMetaTileEntity(tBus)) { - continue; - } - aFluidHatches++; - // Map the Hatch with the space left for easy checking later. - if (tBus.getFluid() == null) { - aOutputHatches.add(new Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer>(tBus, null, tBus.getCapacity())); - } - else { - int aSpaceLeft = tBus.getCapacity() - tBus.getFluidAmount(); - aOutputHatches.add(new Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer>(tBus, tBus.getFluid(), aSpaceLeft)); - } - } - // Create a map of all the fluids we would like to output, we can iterate over this and see how many we can merge into existing hatch stacks. - ArrayList<FluidStack> aOutputFluids = new ArrayList<FluidStack>(); - // Ugly ass boxing - aOutputFluids.addAll(new AutoMap<FluidStack>(aFluidOutputs)); - // Iterate the Hatches, updating their 'stored' data. - //for (Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer> aHatchData : aOutputHatches) { - for (int i = 0;i<aOutputHatches.size();i++) { - // The Hatch Itself - GT_MetaTileEntity_Hatch_Output aHatch = aOutputHatches.get(i).getValue_1(); - // Fluid in the Hatch - FluidStack aHatchStack = aOutputHatches.get(i).getValue_2(); - // Space left in Hatch - int aSpaceLeftInHatch = aHatch.getCapacity() - aHatch.getFluidAmount(); - // Hatch is full, - if (aSpaceLeftInHatch <= 0) { - aFullFluidHatches++; - aOutputHatches.remove(aOutputHatches.get(i)); - i--; - continue; - } - // Hatch has space - else { - // Check if any fluids match - //aFluidMatch: for (FluidStack aOutputStack : aOutputFluids) { - for(int j = 0;j<getOutputFluidCount(aFluidOutputs);j++) { - //log(" aHatchStack "+aHatchStack.getLocalizedName()+" aOutput stack "+aOutputStack.getLocalizedName()); - if (GT_Utility.areFluidsEqual(aHatchStack, aOutputFluids.get(j))) { - int aFluidToPutIntoHatch = aOutputFluids.get(j).amount * aParallelRecipes; - // Not Enough space to insert all of the fluid. - // We fill this hatch and add a smaller Fluidstack back to the iterator. - if (aSpaceLeftInHatch < aFluidToPutIntoHatch) { - // Copy existing Hatch Stack - FluidStack aNewHatchStack = aHatchStack.copy(); - aNewHatchStack.amount = 0; - // Copy existing Hatch Stack again - FluidStack aNewOutputStack = aHatchStack.copy(); - aNewOutputStack.amount = 0; - // How much fluid do we have left after we fill the hatch? - int aFluidLeftAfterInsert = aFluidToPutIntoHatch - aSpaceLeftInHatch; - // Set new stacks to appropriate values - aNewHatchStack.amount = aHatch.getCapacity(); - aNewOutputStack.amount = aFluidLeftAfterInsert; - // Remove fluid from output list, merge success - aOutputFluids.remove(aOutputFluids.get(j)); - j--; - // Remove hatch from hatch list, data is now invalid. - aOutputHatches.remove(aOutputHatches.get(i)); - i--; - // Add remaining Fluid to Output list - aOutputFluids.add(aNewOutputStack); - // Re-add hatch to hatch list, with new data. - //Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer> aNewHatchData = new Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer>(aHatch, aNewHatchStack, aNewHatchStack.amount); - //aOutputHatches.add(aNewHatchData); - break; - } - // We can fill this hatch perfectly (rare case), may as well add it directly to the full list. - else if (aSpaceLeftInHatch == aFluidToPutIntoHatch) { - // Copy Old Stack - FluidStack aNewHatchStack = aHatchStack.copy(); - // Add in amount from output stack - aNewHatchStack.amount += aFluidToPutIntoHatch; - // Remove fluid from output list, merge success - aOutputFluids.remove(aOutputFluids.get(j)); - j--; - // Remove hatch from hatch list, data is now invalid. - aOutputHatches.remove(aOutputHatches.get(i)); - i--; - // Re-add hatch to hatch list, with new data. - Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer> aNewHatchData = new Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer>(aHatch, aNewHatchStack, aNewHatchStack.amount); - aOutputHatches.add(aNewHatchData); - break; - } - // We have more space than we need to merge, so we remove the stack from the output list and update the hatch list. - else { - // Copy Old Stack - FluidStack aNewHatchStack = aHatchStack.copy(); - // Add in amount from output stack - aNewHatchStack.amount += aFluidToPutIntoHatch; - // Remove fluid from output list, merge success - aOutputFluids.remove(aOutputFluids.get(j)); - j--; - // Remove hatch from hatch list, data is now invalid. - aOutputHatches.remove(aOutputHatches.get(i)); - i--; - // Re-add hatch to hatch list, with new data. - Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer> aNewHatchData = new Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer>(aHatch, aNewHatchStack, aNewHatchStack.amount); - aOutputHatches.add(aNewHatchData); - // Check next fluid - continue; - } - - } - else { - continue; - } - } - } - } - - for (Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer> aFreeHatchCheck : aOutputHatches) { - // Free Hatch - if (aFreeHatchCheck.getValue_2() == null || aFreeHatchCheck.getValue_3() == 0 || aFreeHatchCheck.getValue_1().getFluid() == null) { - aEmptyFluidHatches++; - } - } - - // We have Fluid Stacks we did not merge. Do we have space? - log("fluids to output "+aOutputFluids.size()+" empty hatches "+aEmptyFluidHatches); - if (aOutputFluids.size() > 0) { - // Not enough space to add fluids. - if (aOutputFluids.size() > aEmptyFluidHatches) { - aParallelRecipes = (int) Math.floor((double) aEmptyFluidHatches/aOutputFluids.size() * aParallelRecipes); - log("Failed to find enough space for all fluid outputs. Free: "+aEmptyFluidHatches+", Required: "+aOutputFluids.size()); - return 0; - - } - } - - /* - * End Fluid Management - */ - } - - return aParallelRecipes; - } - - - /* - * Handle I/O with custom hatches - */ - - @Override + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Steam_BusOutput) { + log("Adding Steam Output Bus"); + aDidAdd = addToMachineListInternal(mSteamOutputs, aMetaTileEntity, aBaseCasingIndex); + } + + return aDidAdd; + } + + @Override + public void stopMachine() { + super.stopMachine(); + } + + public FluidStack[] getOutputFluids(GT_Recipe aRecipe, int parallelRecipes) { + // Collect fluid outputs + FluidStack[] tOutputFluids = new FluidStack[aRecipe.mFluidOutputs.length]; + for (int h = 0; h < aRecipe.mFluidOutputs.length; h++) { + if (aRecipe.getFluidOutput(h) != null) { + tOutputFluids[h] = aRecipe.getFluidOutput(h).copy(); + tOutputFluids[h].amount *= parallelRecipes; + } + } + return tOutputFluids; + } + + public ItemStack[] getOutputItems(GT_Recipe aRecipe) { + // Collect output item types + ItemStack[] tOutputItems = new ItemStack[aRecipe.mOutputs.length]; + for (int h = 0; h < aRecipe.mOutputs.length; h++) { + if (aRecipe.getOutput(h) != null) { + tOutputItems[h] = aRecipe.getOutput(h).copy(); + tOutputItems[h].stackSize = 0; + } + } + return tOutputItems; + } + + public int getOutputCount(ItemStack[] aOutputs) { + return aOutputs.length; + } + + public int getOutputFluidCount(FluidStack[] aOutputs) { + return aOutputs.length; + } + + public int canBufferOutputs(final ItemStack[] aOutputs, FluidStack[] aFluidOutputs, int aParallelRecipes) { + + log("Determining if we have space to buffer outputs. Parallel: " + aParallelRecipes); + + // Null recipe or a recipe with lots of outputs? + // E.G. Gendustry custom comb with a billion centrifuge outputs? + // Do it anyway, provided the multi allows it. Default behaviour is aAllow16SlotWithoutCheck = true. + if (aOutputs == null && aFluidOutputs == null) { + return 0; + } + + // Do we even need to check for item outputs? + boolean aDoesOutputItems = aOutputs != null ? aOutputs.length > 0 : false; + // Do we even need to check for fluid outputs? + boolean aDoesOutputFluids = aFluidOutputs != null ? aFluidOutputs.length > 0 : false; + + if (!aDoesOutputItems && !aDoesOutputFluids) { + return 0; + } + + /* ======================================== + * Item Management + * ======================================== + */ + + if (aDoesOutputItems) { + log("We have items to output."); + + // How many slots are free across all the output buses? + int aInputBusSlotsFree = 0; + + /* + * Create Variables for Item Output + */ + + AutoMap<FlexiblePair<ItemStack, Integer>> aItemMap = new AutoMap<FlexiblePair<ItemStack, Integer>>(); + AutoMap<ItemStack> aItemOutputs = new AutoMap<ItemStack>(aOutputs); + + for (final GT_MetaTileEntity_Hatch_Steam_BusOutput tBus : this.mSteamOutputs) { + if (!isValidMetaTileEntity(tBus)) { + continue; + } + final IInventory tBusInv = tBus.getBaseMetaTileEntity(); + for (int i = 0; i < tBusInv.getSizeInventory(); i++) { + if (tBus.getStackInSlot(i) == null) { + aInputBusSlotsFree++; + } else { + ItemStack aT = tBus.getStackInSlot(i); + int aSize = aT.stackSize; + aT = aT.copy(); + aT.stackSize = 0; + aItemMap.put(new FlexiblePair<ItemStack, Integer>(aT, aSize)); + } + } + } + + // Count the slots we need, later we can check if any are able to merge with existing stacks + int aRecipeSlotsRequired = 0; + + // A map to hold the items we will be 'inputting' into the output buses. These itemstacks are actually the + // recipe outputs. + ConcurrentSet<FlexiblePair<ItemStack, Integer>> aInputMap = + new ConcurrentHashSet<FlexiblePair<ItemStack, Integer>>(); + + // Iterate over the outputs, calculating require stack spacing they will require. + for (int i = 0; i < getOutputCount(aOutputs); i++) { + ItemStack aY = aItemOutputs.get(i); + if (aY == null) { + continue; + } else { + int aStackSize = aY.stackSize * aParallelRecipes; + if (aStackSize > 64) { + int aSlotsNeedsForThisStack = (int) Math.ceil((double) ((float) aStackSize / 64f)); + // Should round up and add as many stacks as required nicely. + aRecipeSlotsRequired += aSlotsNeedsForThisStack; + for (int o = 0; o < aRecipeSlotsRequired; o++) { + int aStackToRemove = (aStackSize -= 64) > 64 ? 64 : aStackSize; + aY = aY.copy(); + aY.stackSize = 0; + aInputMap.add(new FlexiblePair<ItemStack, Integer>(aY, aStackToRemove)); + } + } else { + // Only requires one slot + aRecipeSlotsRequired++; + aY = aY.copy(); + aY.stackSize = 0; + aInputMap.add(new FlexiblePair<ItemStack, Integer>(aY, aStackSize)); + } + } + } + + // We have items to add to the output buses. See if any are not full stacks and see if we can make them + // full. + if (aInputMap.size() > 0) { + // Iterate over the current stored items in the Output busses, if any match and are not full, we can try + // account for merging. + busItems: + for (FlexiblePair<ItemStack, Integer> y : aItemMap) { + // Iterate over the 'inputs', we can safely remove these as we go. + outputItems: + for (FlexiblePair<ItemStack, Integer> u : aInputMap) { + // Create local vars for readability. + ItemStack aOutputBusStack = y.getKey(); + ItemStack aOutputStack = u.getKey(); + // Stacks match, including NBT. + if (GT_Utility.areStacksEqual(aOutputBusStack, aOutputStack, false)) { + // Stack Matches, but it's full, continue. + if (aOutputBusStack.stackSize >= 64) { + // This stack is full, no point checking it. + continue busItems; + } else { + // We can merge these two stacks without any hassle. + if ((aOutputBusStack.stackSize + aOutputStack.stackSize) <= 64) { + // Update the stack size in the bus storage map. + y.setValue(aOutputBusStack.stackSize + aOutputStack.stackSize); + // Remove the 'input' stack from the recipe outputs, so we don't try count it again. + aInputMap.remove(u); + continue outputItems; + } + // Stack merging is too much, so we fill this stack, leave the remainder. + else { + int aRemainder = (aOutputBusStack.stackSize + aOutputStack.stackSize) - 64; + // Update the stack size in the bus storage map. + y.setValue(64); + // Create a new object to iterate over later, with the remainder data; + FlexiblePair<ItemStack, Integer> t = + new FlexiblePair<ItemStack, Integer>(u.getKey(), aRemainder); + // Remove the 'input' stack from the recipe outputs, so we don't try count it again. + aInputMap.remove(u); + // Add the remainder stack. + aInputMap.add(t); + continue outputItems; + } + } + } else { + continue outputItems; + } + } + } + } + + // We have stacks that did not merge, do we have space for them? + if (aInputMap.size() > 0) { + if (aInputMap.size() > aInputBusSlotsFree) { + aParallelRecipes = + (int) Math.floor((double) aInputBusSlotsFree / aInputMap.size() * aParallelRecipes); + // We do not have enough free slots in total to accommodate the remaining managed stacks. + log(" Free: " + aInputBusSlotsFree + ", Required: " + aInputMap.size()); + if (aParallelRecipes == 0) { + log("Failed to find enough space for all item outputs."); + return 0; + } + } + } + + /* + * End Item Management + */ + + } + + /* ======================================== + * Fluid Management + * ======================================== + */ + + if (aDoesOutputFluids) { + log("We have Fluids to output."); + // How many slots are free across all the output buses? + int aFluidHatches = 0; + int aEmptyFluidHatches = 0; + int aFullFluidHatches = 0; + // Create Map for Fluid Output + ArrayList<Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer>> aOutputHatches = + new ArrayList<Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer>>(); + for (final GT_MetaTileEntity_Hatch_Output tBus : this.mOutputHatches) { + if (!isValidMetaTileEntity(tBus)) { + continue; + } + aFluidHatches++; + // Map the Hatch with the space left for easy checking later. + if (tBus.getFluid() == null) { + aOutputHatches.add(new Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer>( + tBus, null, tBus.getCapacity())); + } else { + int aSpaceLeft = tBus.getCapacity() - tBus.getFluidAmount(); + aOutputHatches.add(new Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer>( + tBus, tBus.getFluid(), aSpaceLeft)); + } + } + // Create a map of all the fluids we would like to output, we can iterate over this and see how many we can + // merge into existing hatch stacks. + ArrayList<FluidStack> aOutputFluids = new ArrayList<FluidStack>(); + // Ugly ass boxing + aOutputFluids.addAll(new AutoMap<FluidStack>(aFluidOutputs)); + // Iterate the Hatches, updating their 'stored' data. + // for (Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer> aHatchData : aOutputHatches) { + for (int i = 0; i < aOutputHatches.size(); i++) { + // The Hatch Itself + GT_MetaTileEntity_Hatch_Output aHatch = aOutputHatches.get(i).getValue_1(); + // Fluid in the Hatch + FluidStack aHatchStack = aOutputHatches.get(i).getValue_2(); + // Space left in Hatch + int aSpaceLeftInHatch = aHatch.getCapacity() - aHatch.getFluidAmount(); + // Hatch is full, + if (aSpaceLeftInHatch <= 0) { + aFullFluidHatches++; + aOutputHatches.remove(aOutputHatches.get(i)); + i--; + continue; + } + // Hatch has space + else { + // Check if any fluids match + // aFluidMatch: for (FluidStack aOutputStack : aOutputFluids) { + for (int j = 0; j < getOutputFluidCount(aFluidOutputs); j++) { + // log(" aHatchStack "+aHatchStack.getLocalizedName()+" aOutput stack + // "+aOutputStack.getLocalizedName()); + if (GT_Utility.areFluidsEqual(aHatchStack, aOutputFluids.get(j))) { + int aFluidToPutIntoHatch = aOutputFluids.get(j).amount * aParallelRecipes; + // Not Enough space to insert all of the fluid. + // We fill this hatch and add a smaller Fluidstack back to the iterator. + if (aSpaceLeftInHatch < aFluidToPutIntoHatch) { + // Copy existing Hatch Stack + FluidStack aNewHatchStack = aHatchStack.copy(); + aNewHatchStack.amount = 0; + // Copy existing Hatch Stack again + FluidStack aNewOutputStack = aHatchStack.copy(); + aNewOutputStack.amount = 0; + // How much fluid do we have left after we fill the hatch? + int aFluidLeftAfterInsert = aFluidToPutIntoHatch - aSpaceLeftInHatch; + // Set new stacks to appropriate values + aNewHatchStack.amount = aHatch.getCapacity(); + aNewOutputStack.amount = aFluidLeftAfterInsert; + // Remove fluid from output list, merge success + aOutputFluids.remove(aOutputFluids.get(j)); + j--; + // Remove hatch from hatch list, data is now invalid. + aOutputHatches.remove(aOutputHatches.get(i)); + i--; + // Add remaining Fluid to Output list + aOutputFluids.add(aNewOutputStack); + // Re-add hatch to hatch list, with new data. + // Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer> aNewHatchData = new + // Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer>(aHatch, aNewHatchStack, + // aNewHatchStack.amount); + // aOutputHatches.add(aNewHatchData); + break; + } + // We can fill this hatch perfectly (rare case), may as well add it directly to the full + // list. + else if (aSpaceLeftInHatch == aFluidToPutIntoHatch) { + // Copy Old Stack + FluidStack aNewHatchStack = aHatchStack.copy(); + // Add in amount from output stack + aNewHatchStack.amount += aFluidToPutIntoHatch; + // Remove fluid from output list, merge success + aOutputFluids.remove(aOutputFluids.get(j)); + j--; + // Remove hatch from hatch list, data is now invalid. + aOutputHatches.remove(aOutputHatches.get(i)); + i--; + // Re-add hatch to hatch list, with new data. + Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer> aNewHatchData = + new Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer>( + aHatch, aNewHatchStack, aNewHatchStack.amount); + aOutputHatches.add(aNewHatchData); + break; + } + // We have more space than we need to merge, so we remove the stack from the output list and + // update the hatch list. + else { + // Copy Old Stack + FluidStack aNewHatchStack = aHatchStack.copy(); + // Add in amount from output stack + aNewHatchStack.amount += aFluidToPutIntoHatch; + // Remove fluid from output list, merge success + aOutputFluids.remove(aOutputFluids.get(j)); + j--; + // Remove hatch from hatch list, data is now invalid. + aOutputHatches.remove(aOutputHatches.get(i)); + i--; + // Re-add hatch to hatch list, with new data. + Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer> aNewHatchData = + new Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer>( + aHatch, aNewHatchStack, aNewHatchStack.amount); + aOutputHatches.add(aNewHatchData); + // Check next fluid + continue; + } + + } else { + continue; + } + } + } + } + + for (Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer> aFreeHatchCheck : aOutputHatches) { + // Free Hatch + if (aFreeHatchCheck.getValue_2() == null + || aFreeHatchCheck.getValue_3() == 0 + || aFreeHatchCheck.getValue_1().getFluid() == null) { + aEmptyFluidHatches++; + } + } + + // We have Fluid Stacks we did not merge. Do we have space? + log("fluids to output " + aOutputFluids.size() + " empty hatches " + aEmptyFluidHatches); + if (aOutputFluids.size() > 0) { + // Not enough space to add fluids. + if (aOutputFluids.size() > aEmptyFluidHatches) { + aParallelRecipes = + (int) Math.floor((double) aEmptyFluidHatches / aOutputFluids.size() * aParallelRecipes); + log("Failed to find enough space for all fluid outputs. Free: " + aEmptyFluidHatches + + ", Required: " + aOutputFluids.size()); + return 0; + } + } + + /* + * End Fluid Management + */ + } + + return aParallelRecipes; + } + + /* + * Handle I/O with custom hatches + */ + + @Override public boolean depleteInput(FluidStack aLiquid) { if (aLiquid == null) return false; for (GT_MetaTileEntity_Hatch_CustomFluidBase tHatch : mSteamInputFluids) { @@ -696,14 +704,15 @@ public abstract class GregtechMeta_SteamMultiBase<T extends GregtechMeta_SteamMu return false; } - @Override + @Override public boolean depleteInput(ItemStack aStack) { if (GT_Utility.isStackInvalid(aStack)) return false; FluidStack aLiquid = GT_Utility.getFluidForFilledItem(aStack, true); if (aLiquid != null) return depleteInput(aLiquid); for (GT_MetaTileEntity_Hatch_CustomFluidBase tHatch : mSteamInputFluids) { if (isValidMetaTileEntity(tHatch)) { - if (GT_Utility.areStacksEqual(aStack, tHatch.getBaseMetaTileEntity().getStackInSlot(0))) { + if (GT_Utility.areStacksEqual( + aStack, tHatch.getBaseMetaTileEntity().getStackInSlot(0))) { if (tHatch.getBaseMetaTileEntity().getStackInSlot(0).stackSize >= aStack.stackSize) { tHatch.getBaseMetaTileEntity().decrStackSize(0, aStack.stackSize); return true; @@ -715,7 +724,8 @@ public abstract class GregtechMeta_SteamMultiBase<T extends GregtechMeta_SteamMu tHatch.mRecipeMap = getRecipeMap(); if (isValidMetaTileEntity(tHatch)) { for (int i = tHatch.getBaseMetaTileEntity().getSizeInventory() - 1; i >= 0; i--) { - if (GT_Utility.areStacksEqual(aStack, tHatch.getBaseMetaTileEntity().getStackInSlot(i))) { + if (GT_Utility.areStacksEqual( + aStack, tHatch.getBaseMetaTileEntity().getStackInSlot(i))) { if (tHatch.getBaseMetaTileEntity().getStackInSlot(0).stackSize >= aStack.stackSize) { tHatch.getBaseMetaTileEntity().decrStackSize(0, aStack.stackSize); return true; @@ -727,7 +737,7 @@ public abstract class GregtechMeta_SteamMultiBase<T extends GregtechMeta_SteamMu return false; } - @Override + @Override public ArrayList<FluidStack> getStoredFluids() { ArrayList<FluidStack> rList = new ArrayList<FluidStack>(); for (GT_MetaTileEntity_Hatch_CustomFluidBase tHatch : mSteamInputFluids) { @@ -738,7 +748,7 @@ public abstract class GregtechMeta_SteamMultiBase<T extends GregtechMeta_SteamMu return rList; } - @Override + @Override public ArrayList<ItemStack> getStoredInputs() { ArrayList<ItemStack> rList = new ArrayList<ItemStack>(); for (GT_MetaTileEntity_Hatch_Steam_BusInput tHatch : mSteamInputs) { @@ -746,7 +756,7 @@ public abstract class GregtechMeta_SteamMultiBase<T extends GregtechMeta_SteamMu if (isValidMetaTileEntity(tHatch)) { for (int i = tHatch.getBaseMetaTileEntity().getSizeInventory() - 1; i >= 0; i--) { if (tHatch.getBaseMetaTileEntity().getStackInSlot(i) != null) { - rList.add(tHatch.getBaseMetaTileEntity().getStackInSlot(i)); + rList.add(tHatch.getBaseMetaTileEntity().getStackInSlot(i)); } } } @@ -754,7 +764,7 @@ public abstract class GregtechMeta_SteamMultiBase<T extends GregtechMeta_SteamMu return rList; } - @Override + @Override public boolean addOutput(ItemStack aStack) { if (GT_Utility.isStackInvalid(aStack)) return false; aStack = GT_Utility.copy(aStack); @@ -778,7 +788,7 @@ public abstract class GregtechMeta_SteamMultiBase<T extends GregtechMeta_SteamMu return outputSuccess; } - @Override + @Override public ArrayList<ItemStack> getStoredOutputs() { ArrayList<ItemStack> rList = new ArrayList<ItemStack>(); for (GT_MetaTileEntity_Hatch_Steam_BusOutput tHatch : mSteamOutputs) { @@ -791,13 +801,11 @@ public abstract class GregtechMeta_SteamMultiBase<T extends GregtechMeta_SteamMu return rList; } - @Override + @Override public void updateSlots() { for (GT_MetaTileEntity_Hatch_CustomFluidBase tHatch : mSteamInputFluids) if (isValidMetaTileEntity(tHatch)) tHatch.updateSlots(); for (GT_MetaTileEntity_Hatch_Steam_BusInput tHatch : mSteamInputs) if (isValidMetaTileEntity(tHatch)) tHatch.updateSlots(); } - - } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechDoubleFuelGeneratorBase.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechDoubleFuelGeneratorBase.java index 287d2105ac..473b2ad538 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechDoubleFuelGeneratorBase.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechDoubleFuelGeneratorBase.java @@ -2,427 +2,478 @@ package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.generat import static gregtech.api.enums.GT_Values.V; -import java.util.Collection; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; - import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gregtech.api.util.GT_Utility; - import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.lib.CORE; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_DeluxeTank; +import java.util.Collection; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; public abstract class GregtechDoubleFuelGeneratorBase extends GT_MetaTileEntity_DeluxeTank { - private boolean useFuel = false; - - public GregtechDoubleFuelGeneratorBase(final int aID, final String aName, final String aNameRegional, final int aTier, final String aDescription, final ITexture... aTextures) { - super(aID, aName, aNameRegional, aTier, 4, aDescription, aTextures); - } - - public GregtechDoubleFuelGeneratorBase(final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures) { - super(aName, aTier, 4, aDescription, aTextures); - } - - @Override - public ITexture[][][] getTextureSet(final ITexture[] aTextures) { - final ITexture[][][] rTextures = new ITexture[10][17][]; - for (byte i = -1; i < 16; i++) { - rTextures[0][i + 1] = this.getFront(i); - rTextures[1][i + 1] = this.getBack(i); - rTextures[2][i + 1] = this.getBottom(i); - rTextures[3][i + 1] = this.getTop(i); - rTextures[4][i + 1] = this.getSides(i); - rTextures[5][i + 1] = this.getFrontActive(i); - rTextures[6][i + 1] = this.getBackActive(i); - rTextures[7][i + 1] = this.getBottomActive(i); - rTextures[8][i + 1] = this.getTopActive(i); - rTextures[9][i + 1] = this.getSidesActive(i); - } - return rTextures; - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { - return this.mTextures[(aActive ? 5 : 0) + (aSide == aFacing ? 0 : aSide == GT_Utility.getOppositeSide(aFacing) ? 1 : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][aColorIndex + 1]; - } - - - @Override - public String[] getDescription() { - return new String[]{this.mDescription, "Fuel Efficiency: " + this.getEfficiency() + "%"}; - } - - - /* @Override + private boolean useFuel = false; + + public GregtechDoubleFuelGeneratorBase( + final int aID, + final String aName, + final String aNameRegional, + final int aTier, + final String aDescription, + final ITexture... aTextures) { + super(aID, aName, aNameRegional, aTier, 4, aDescription, aTextures); + } + + public GregtechDoubleFuelGeneratorBase( + final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures) { + super(aName, aTier, 4, aDescription, aTextures); + } + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + final ITexture[][][] rTextures = new ITexture[10][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = this.getFront(i); + rTextures[1][i + 1] = this.getBack(i); + rTextures[2][i + 1] = this.getBottom(i); + rTextures[3][i + 1] = this.getTop(i); + rTextures[4][i + 1] = this.getSides(i); + rTextures[5][i + 1] = this.getFrontActive(i); + rTextures[6][i + 1] = this.getBackActive(i); + rTextures[7][i + 1] = this.getBottomActive(i); + rTextures[8][i + 1] = this.getTopActive(i); + rTextures[9][i + 1] = this.getSidesActive(i); + } + return rTextures; + } + + @Override + public ITexture[] getTexture( + final IGregTechTileEntity aBaseMetaTileEntity, + final byte aSide, + final byte aFacing, + final byte aColorIndex, + final boolean aActive, + final boolean aRedstone) { + return this.mTextures[ + (aActive ? 5 : 0) + + (aSide == aFacing + ? 0 + : aSide == GT_Utility.getOppositeSide(aFacing) + ? 1 + : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][ + aColorIndex + 1]; + } + + @Override + public String[] getDescription() { + return new String[] {this.mDescription, "Fuel Efficiency: " + this.getEfficiency() + "%"}; + } + + /* @Override public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { if (aBaseMetaTileEntity.isClientSide()) return true; aBaseMetaTileEntity.openGUI(aPlayer); return true; }*/ - @Override - public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()){ - Logger.WARNING("Entity is Client side, simply returning true"); - return true; - } - Logger.WARNING("Entity is not Client side, opening entity Container and by extension, it's GUI, then returning true"); - aBaseMetaTileEntity.openGUI(aPlayer); - return true; - } - - public ITexture[] getFront(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]}; - } - - public ITexture[] getBack(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]}; - } - - public ITexture[] getBottom(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]}; - } - - public ITexture[] getTop(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]}; - } - - public ITexture[] getSides(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]}; - } - - public ITexture[] getFrontActive(final byte aColor) { - return this.getFront(aColor); - } - - public ITexture[] getBackActive(final byte aColor) { - return this.getBack(aColor); - } - - public ITexture[] getBottomActive(final byte aColor) { - return this.getBottom(aColor); - } - - public ITexture[] getTopActive(final byte aColor) { - return this.getTop(aColor); - } - - public ITexture[] getSidesActive(final byte aColor) { - return this.getSides(aColor); - } - - @Override - public boolean isFacingValid(final byte aSide) { - return aSide > 1; - } - - @Override - public boolean isSimpleMachine() { - return false; - } - - @Override - public boolean isValidSlot(final int aIndex) { - return aIndex < 2; - } - - @Override - public boolean isEnetOutput() { - return true; - } - - @Override - public boolean isOutputFacing(final byte aSide) { - return true; - } - - @Override - public boolean isAccessAllowed(final EntityPlayer aPlayer) { - return true; - } - - @Override - public long maxEUOutput() { - return this.getBaseMetaTileEntity().isAllowedToWork() ? V[this.mTier] : 0; - } - - @Override - public long maxEUStore() { - return Math.max(this.getEUVar(), (V[this.mTier] * 115) + this.getMinimumStoredEU()); - } - - @Override - public boolean doesFillContainers() { - return this.getBaseMetaTileEntity().isAllowedToWork(); - } - - @Override - public boolean doesEmptyContainers() { - return this.getBaseMetaTileEntity().isAllowedToWork(); - } - - @Override - public boolean canTankBeFilled() { - return this.getBaseMetaTileEntity().isAllowedToWork(); - } - - @Override - public boolean canTankBeEmptied() { - return this.getBaseMetaTileEntity().isAllowedToWork(); - } - - @Override - public boolean displaysItemStack() { - return true; - } - - @Override - public boolean displaysStackSize() { - return false; - } - - @Override - public boolean isFluidInputAllowed(final FluidStack aFluid) { - return this.getFuelValue(aFluid) > 0; - } - - @Override - public long getMinimumStoredEU() { - return 512; - } - - @Override - public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { - if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.isAllowedToWork() && ((aTick % 10) == 0)) { - if (this.mFluid == null) { - if (aBaseMetaTileEntity.getUniversalEnergyStored() < (this.maxEUOutput() + this.getMinimumStoredEU())) { - this.mInventory[this.getStackDisplaySlot()] = null; - } else { - if (this.mInventory[this.getStackDisplaySlot()] == null) { - this.mInventory[this.getStackDisplaySlot()] = new ItemStack(Blocks.fire, 1); - } - this.mInventory[this.getStackDisplaySlot()].setStackDisplayName("Generating: " + (aBaseMetaTileEntity.getUniversalEnergyStored() - this.getMinimumStoredEU()) + " EU"); - } - } else { - if ((this.mFluid != null) && (this.mFluid2 != null)){ - final int tFuelValue = this.getFuelValue(this.mFluid), tConsumed = this.consumedFluidPerOperation(this.mFluid); - final int tFuelValue2 = this.getFuelValue(this.mFluid2), tConsumed2 = this.consumedFluidPerOperation(this.mFluid2); - if (((tFuelValue > 0) && (tConsumed > 0) && (this.mFluid.amount > tConsumed))/* && (tFuelValue2 > 0 && tConsumed2 > 0 && mFluid2.amount > tConsumed2)*/) { - - Logger.WARNING("tFuelValue: "+tFuelValue); - Logger.WARNING("tConsumed: "+tConsumed); - Logger.WARNING("mFluid.name: "+this.mFluid.getFluid().getName()); - Logger.WARNING("mFluid.amount: "+this.mFluid.amount); - Logger.WARNING("mFluid.amount > tConsumed: "+(this.mFluid.amount > tConsumed)); - - Logger.WARNING("========================================================="); - - Logger.WARNING("tFuelValue2: "+tFuelValue2); - Logger.WARNING("tConsumed2: "+tConsumed2); - Logger.WARNING("mFluid2.name: "+this.mFluid2.getFluid().getName()); - Logger.WARNING("mFluid2.amount: "+this.mFluid2.amount); - Logger.WARNING("mFluid2.amount > tConsumed2: "+(this.mFluid2.amount > tConsumed2)); - long tFluidAmountToUse = Math.min(this.mFluid.amount / tConsumed, (((this.maxEUOutput() * 30) + this.getMinimumStoredEU()) - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue); - long tFluidAmountToUse2 = Math.min(this.mFluid2.amount / tConsumed2, (((this.maxEUOutput() * 30) + this.getMinimumStoredEU()) - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue2); - - if (tFluidAmountToUse <= 0){ - /*if ((mFluid.amount / tConsumed) == getCapacity()){ - tFluidAmountToUse = 1; - }*/ - - if (aBaseMetaTileEntity.getUniversalEnergyStored() <= (aBaseMetaTileEntity.getEUCapacity()-aBaseMetaTileEntity.getUniversalEnergyStored())){ - tFluidAmountToUse = 1; - Logger.WARNING("========================================================="); - Logger.WARNING("tFluidAmountToUse - Updated: "+tFluidAmountToUse); - Logger.WARNING("========================================================="); - } - } - - if (tFluidAmountToUse2 <= 0){ - /*if ((mFluid2.amount / tConsumed) == getCapacity()){ - tFluidAmountToUse2 = 1; - }*/ - if (aBaseMetaTileEntity.getUniversalEnergyStored() <= (aBaseMetaTileEntity.getEUCapacity()-aBaseMetaTileEntity.getUniversalEnergyStored())){ - tFluidAmountToUse2 = 1; - Logger.WARNING("========================================================="); - Logger.WARNING("tFluidAmountToUse2 - Updated: "+tFluidAmountToUse2); - Logger.WARNING("========================================================="); - } - } - - Logger.WARNING("========================================================="); - Logger.WARNING("tFluidAmountToUse: "+tFluidAmountToUse); - Logger.WARNING("========================================================="); - - /*Utils.LOG_WARNING("mFluid.amount / tConsumed: "+("fluidAmount:"+mFluid.amount)+(" tConsumed:"+tConsumed)+" | "+(mFluid.amount / tConsumed)); - Utils.LOG_WARNING("maxEUOutput() * 20 + getMinimumStoredEU(): "+(maxEUOutput() * 30 + getMinimumStoredEU())); - Utils.LOG_WARNING("maxEUOutput(): "+maxEUOutput()); - Utils.LOG_WARNING("maxEUOutput() * 20: "+(maxEUOutput() * 30)); - Utils.LOG_WARNING("getMinimumStoredEU(): "+(getMinimumStoredEU())); - Utils.LOG_WARNING("aBaseMetaTileEntity.getUniversalEnergyStored(): "+(aBaseMetaTileEntity.getUniversalEnergyStored())); - Utils.LOG_WARNING("(maxEUOutput() * 20 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()): "+((maxEUOutput() * 30 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()))); - Utils.LOG_WARNING("tFuelValue: "+(tFuelValue)); - Utils.LOG_WARNING("(maxEUOutput() * 20 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue): "+((maxEUOutput() * 30 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue)); - */ - - Logger.WARNING("========================================================="); - Logger.WARNING("tFluidAmountToUse2: "+tFluidAmountToUse2); - Logger.WARNING("========================================================="); - - /*Utils.LOG_WARNING("mFluid2.amount / tConsumed2: "+("fluidAmount2:"+mFluid2.amount)+(" tConsumed2:"+tConsumed2)+" | "+(mFluid2.amount / tConsumed2)); - Utils.LOG_WARNING("maxEUOutput() * 20 + getMinimumStoredEU(): "+(maxEUOutput() * 30 + getMinimumStoredEU())); - Utils.LOG_WARNING("maxEUOutput(): "+maxEUOutput()); - Utils.LOG_WARNING("maxEUOutput() * 20: "+(maxEUOutput() * 30)); - Utils.LOG_WARNING("getMinimumStoredEU(): "+(getMinimumStoredEU())); - Utils.LOG_WARNING("aBaseMetaTileEntity.getUniversalEnergyStored(): "+(aBaseMetaTileEntity.getUniversalEnergyStored())); - Utils.LOG_WARNING("(maxEUOutput() * 20 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()): "+((maxEUOutput() * 30 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()))); - Utils.LOG_WARNING("tFuelValue2: "+(tFuelValue2)); - Utils.LOG_WARNING("(maxEUOutput() * 20 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue2): "+((maxEUOutput() * 30 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue2)); - */ - if (((tFluidAmountToUse > 0) && aBaseMetaTileEntity.increaseStoredEnergyUnits(tFluidAmountToUse * tFuelValue, true)) && ((tFluidAmountToUse2 > 0) && aBaseMetaTileEntity.increaseStoredEnergyUnits(tFluidAmountToUse2 * tFuelValue2, true))){ - - Logger.WARNING("tFuelValue: "+tFuelValue); - Logger.WARNING("tConsumed: "+tConsumed); - Logger.WARNING("mFluid.name: "+this.mFluid.getFluid().getName()); - Logger.WARNING("mFluid.amount: "+this.mFluid.amount); - Logger.WARNING("mFluid.amount > tConsumed: "+(this.mFluid.amount > tConsumed)); - - Logger.WARNING("========================================================="); - - Logger.WARNING("tFuelValue2: "+tFuelValue2); - Logger.WARNING("tConsumed2: "+tConsumed2); - Logger.WARNING("mFluid2.name: "+this.mFluid2.getFluid().getName()); - Logger.WARNING("mFluid2.amount: "+this.mFluid2.amount); - Logger.WARNING("mFluid2.amount > tConsumed2: "+(this.mFluid2.amount > tConsumed2)); - - if (this.useFuel){ - this.mFluid.amount -= tFluidAmountToUse * tConsumed; - this.mFluid2.amount -= tFluidAmountToUse2 * tConsumed2; - this.useFuel = false; - } - else { - this.useFuel = true; - } - - } - else { - Logger.WARNING("========================================================="); - Logger.WARNING("Either tFluidAmountToUse1 <= 0, power cannot be increased of tFluidAmountToUse2 <= 0"); - Logger.WARNING("tFluidAmountToUse1: "+tFluidAmountToUse); - Logger.WARNING("tFluidAmountToUse2: "+tFluidAmountToUse2); - } - } - else { - /*Utils.LOG_WARNING("(tFuelValue > 0 && tConsumed > 0 && mFluid.amount > tConsumed) && (tFuelValue2 > 0 && tConsumed2 > 0 && mFluid2.amount > tConsumed2)"); - Utils.LOG_WARNING("tFuelValue: "+tFuelValue); - Utils.LOG_WARNING("tConsumed: "+tConsumed); - Utils.LOG_WARNING("mFluid.amount: "+mFluid.amount); - Utils.LOG_WARNING("mFluid.amount > tConsumed: "+(mFluid.amount > tConsumed)); - - Utils.LOG_WARNING("========================================================="); - - Utils.LOG_WARNING("tFuelValue2: "+tFuelValue2); - Utils.LOG_WARNING("tConsumed2: "+tConsumed2); - Utils.LOG_WARNING("mFluid2.amount: "+mFluid2.amount); - Utils.LOG_WARNING("mFluid2.amount > tConsumed2: "+(mFluid2.amount > tConsumed2)); */ - } - } - else { - Logger.WARNING("One mFluid is null"); - if (this.mFluid != null) { - Logger.WARNING("mFluid1 is not null"); - } - if (this.mFluid2 != null) { - Logger.WARNING("mFluid2 is not null"); - } - } - } - if ((this.mInventory[this.getInputSlot()] != null) && (aBaseMetaTileEntity.getUniversalEnergyStored() < ((this.maxEUOutput() * 20) + this.getMinimumStoredEU())) && (GT_Utility.getFluidForFilledItem(this.mInventory[this.getInputSlot()], true) == null)) { - final int tFuelValue = this.getFuelValue(this.mInventory[this.getInputSlot()]); - if (tFuelValue > 0) { - final ItemStack tEmptyContainer = this.getEmptyContainer(this.mInventory[this.getInputSlot()]); - if (aBaseMetaTileEntity.addStackToSlot(this.getOutputSlot(), tEmptyContainer)) { - aBaseMetaTileEntity.increaseStoredEnergyUnits(tFuelValue, true); - aBaseMetaTileEntity.decrStackSize(this.getInputSlot(), 1); - } - } - } - } - - if (aBaseMetaTileEntity.isServerSide()) { - aBaseMetaTileEntity.setActive(aBaseMetaTileEntity.isAllowedToWork() && (aBaseMetaTileEntity.getUniversalEnergyStored() >= (this.maxEUOutput() + this.getMinimumStoredEU()))); - } - } - - public abstract GT_Recipe_Map getRecipes(); - - public abstract int getEfficiency(); - - public int consumedFluidPerOperation(final FluidStack aLiquid) { - return 1; - } - - public int getFuelValue(final FluidStack aLiquid) { - if ((aLiquid == null) || (this.getRecipes() == null)) { - return 0; - } - FluidStack tLiquid; - final Collection<GT_Recipe> tRecipeList = this.getRecipes().mRecipeList; - if (tRecipeList != null) { - for (final GT_Recipe tFuel : tRecipeList) { - if ((tLiquid = GT_Utility.getFluidForFilledItem(tFuel.getRepresentativeInput(0), true)) != null) { - if (aLiquid.isFluidEqual(tLiquid)) { - return (int) (((long) tFuel.mSpecialValue * this.getEfficiency() * this.consumedFluidPerOperation(tLiquid)) / 100); - } - } - } - } - return 0; - } - - public int getFuelValue(final ItemStack aStack) { - if (GT_Utility.isStackInvalid(aStack) || (this.getRecipes() == null)) { - return 0; - } - final GT_Recipe tFuel = this.getRecipes().findRecipe(this.getBaseMetaTileEntity(), false, Long.MAX_VALUE, null, aStack); - if (tFuel != null) { - return (int) ((tFuel.mSpecialValue * 1000L * this.getEfficiency()) / 100); - } - return 0; - } - - public ItemStack getEmptyContainer(final ItemStack aStack) { - if (GT_Utility.isStackInvalid(aStack) || (this.getRecipes() == null)) { - return null; - } - final GT_Recipe tFuel = this.getRecipes().findRecipe(this.getBaseMetaTileEntity(), false, Long.MAX_VALUE, null, aStack); - if (tFuel != null) { - return GT_Utility.copy(tFuel.getOutput(0)); - } - return GT_Utility.getContainerItem(aStack, true); - } - - @Override - public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { - return super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack) && ((this.getFuelValue(aStack) > 0) || (this.getFuelValue(GT_Utility.getFluidForFilledItem(aStack, true)) > 0)); - } - - @Override - public int getCapacity() { - return 32000; - } - - @Override - public int getTankPressure() { - return -100; - } + @Override + public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + Logger.WARNING("Entity is Client side, simply returning true"); + return true; + } + Logger.WARNING( + "Entity is not Client side, opening entity Container and by extension, it's GUI, then returning true"); + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + + public ITexture[] getFront(final byte aColor) { + return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]}; + } + + public ITexture[] getBack(final byte aColor) { + return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]}; + } + + public ITexture[] getBottom(final byte aColor) { + return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]}; + } + + public ITexture[] getTop(final byte aColor) { + return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]}; + } + + public ITexture[] getSides(final byte aColor) { + return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]}; + } + + public ITexture[] getFrontActive(final byte aColor) { + return this.getFront(aColor); + } + + public ITexture[] getBackActive(final byte aColor) { + return this.getBack(aColor); + } + + public ITexture[] getBottomActive(final byte aColor) { + return this.getBottom(aColor); + } + + public ITexture[] getTopActive(final byte aColor) { + return this.getTop(aColor); + } + + public ITexture[] getSidesActive(final byte aColor) { + return this.getSides(aColor); + } + + @Override + public boolean isFacingValid(final byte aSide) { + return aSide > 1; + } + + @Override + public boolean isSimpleMachine() { + return false; + } + + @Override + public boolean isValidSlot(final int aIndex) { + return aIndex < 2; + } + + @Override + public boolean isEnetOutput() { + return true; + } + + @Override + public boolean isOutputFacing(final byte aSide) { + return true; + } + + @Override + public boolean isAccessAllowed(final EntityPlayer aPlayer) { + return true; + } + + @Override + public long maxEUOutput() { + return this.getBaseMetaTileEntity().isAllowedToWork() ? V[this.mTier] : 0; + } + + @Override + public long maxEUStore() { + return Math.max(this.getEUVar(), (V[this.mTier] * 115) + this.getMinimumStoredEU()); + } + + @Override + public boolean doesFillContainers() { + return this.getBaseMetaTileEntity().isAllowedToWork(); + } + + @Override + public boolean doesEmptyContainers() { + return this.getBaseMetaTileEntity().isAllowedToWork(); + } + + @Override + public boolean canTankBeFilled() { + return this.getBaseMetaTileEntity().isAllowedToWork(); + } + + @Override + public boolean canTankBeEmptied() { + return this.getBaseMetaTileEntity().isAllowedToWork(); + } + + @Override + public boolean displaysItemStack() { + return true; + } + + @Override + public boolean displaysStackSize() { + return false; + } + + @Override + public boolean isFluidInputAllowed(final FluidStack aFluid) { + return this.getFuelValue(aFluid) > 0; + } + + @Override + public long getMinimumStoredEU() { + return 512; + } + + @Override + public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { + if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.isAllowedToWork() && ((aTick % 10) == 0)) { + if (this.mFluid == null) { + if (aBaseMetaTileEntity.getUniversalEnergyStored() < (this.maxEUOutput() + this.getMinimumStoredEU())) { + this.mInventory[this.getStackDisplaySlot()] = null; + } else { + if (this.mInventory[this.getStackDisplaySlot()] == null) { + this.mInventory[this.getStackDisplaySlot()] = new ItemStack(Blocks.fire, 1); + } + this.mInventory[this.getStackDisplaySlot()].setStackDisplayName("Generating: " + + (aBaseMetaTileEntity.getUniversalEnergyStored() - this.getMinimumStoredEU()) + " EU"); + } + } else { + if ((this.mFluid != null) && (this.mFluid2 != null)) { + final int tFuelValue = this.getFuelValue(this.mFluid), + tConsumed = this.consumedFluidPerOperation(this.mFluid); + final int tFuelValue2 = this.getFuelValue(this.mFluid2), + tConsumed2 = this.consumedFluidPerOperation(this.mFluid2); + if (((tFuelValue > 0) + && (tConsumed > 0) + && (this.mFluid.amount + > tConsumed)) /* && (tFuelValue2 > 0 && tConsumed2 > 0 && mFluid2.amount > tConsumed2)*/) { + + Logger.WARNING("tFuelValue: " + tFuelValue); + Logger.WARNING("tConsumed: " + tConsumed); + Logger.WARNING("mFluid.name: " + this.mFluid.getFluid().getName()); + Logger.WARNING("mFluid.amount: " + this.mFluid.amount); + Logger.WARNING("mFluid.amount > tConsumed: " + (this.mFluid.amount > tConsumed)); + + Logger.WARNING("========================================================="); + + Logger.WARNING("tFuelValue2: " + tFuelValue2); + Logger.WARNING("tConsumed2: " + tConsumed2); + Logger.WARNING( + "mFluid2.name: " + this.mFluid2.getFluid().getName()); + Logger.WARNING("mFluid2.amount: " + this.mFluid2.amount); + Logger.WARNING("mFluid2.amount > tConsumed2: " + (this.mFluid2.amount > tConsumed2)); + long tFluidAmountToUse = Math.min( + this.mFluid.amount / tConsumed, + (((this.maxEUOutput() * 30) + this.getMinimumStoredEU()) + - aBaseMetaTileEntity.getUniversalEnergyStored()) + / tFuelValue); + long tFluidAmountToUse2 = Math.min( + this.mFluid2.amount / tConsumed2, + (((this.maxEUOutput() * 30) + this.getMinimumStoredEU()) + - aBaseMetaTileEntity.getUniversalEnergyStored()) + / tFuelValue2); + + if (tFluidAmountToUse <= 0) { + /*if ((mFluid.amount / tConsumed) == getCapacity()){ + tFluidAmountToUse = 1; + }*/ + + if (aBaseMetaTileEntity.getUniversalEnergyStored() + <= (aBaseMetaTileEntity.getEUCapacity() + - aBaseMetaTileEntity.getUniversalEnergyStored())) { + tFluidAmountToUse = 1; + Logger.WARNING("========================================================="); + Logger.WARNING("tFluidAmountToUse - Updated: " + tFluidAmountToUse); + Logger.WARNING("========================================================="); + } + } + + if (tFluidAmountToUse2 <= 0) { + /*if ((mFluid2.amount / tConsumed) == getCapacity()){ + tFluidAmountToUse2 = 1; + }*/ + if (aBaseMetaTileEntity.getUniversalEnergyStored() + <= (aBaseMetaTileEntity.getEUCapacity() + - aBaseMetaTileEntity.getUniversalEnergyStored())) { + tFluidAmountToUse2 = 1; + Logger.WARNING("========================================================="); + Logger.WARNING("tFluidAmountToUse2 - Updated: " + tFluidAmountToUse2); + Logger.WARNING("========================================================="); + } + } + + Logger.WARNING("========================================================="); + Logger.WARNING("tFluidAmountToUse: " + tFluidAmountToUse); + Logger.WARNING("========================================================="); + + /*Utils.LOG_WARNING("mFluid.amount / tConsumed: "+("fluidAmount:"+mFluid.amount)+(" tConsumed:"+tConsumed)+" | "+(mFluid.amount / tConsumed)); + Utils.LOG_WARNING("maxEUOutput() * 20 + getMinimumStoredEU(): "+(maxEUOutput() * 30 + getMinimumStoredEU())); + Utils.LOG_WARNING("maxEUOutput(): "+maxEUOutput()); + Utils.LOG_WARNING("maxEUOutput() * 20: "+(maxEUOutput() * 30)); + Utils.LOG_WARNING("getMinimumStoredEU(): "+(getMinimumStoredEU())); + Utils.LOG_WARNING("aBaseMetaTileEntity.getUniversalEnergyStored(): "+(aBaseMetaTileEntity.getUniversalEnergyStored())); + Utils.LOG_WARNING("(maxEUOutput() * 20 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()): "+((maxEUOutput() * 30 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()))); + Utils.LOG_WARNING("tFuelValue: "+(tFuelValue)); + Utils.LOG_WARNING("(maxEUOutput() * 20 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue): "+((maxEUOutput() * 30 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue)); + */ + + Logger.WARNING("========================================================="); + Logger.WARNING("tFluidAmountToUse2: " + tFluidAmountToUse2); + Logger.WARNING("========================================================="); + + /*Utils.LOG_WARNING("mFluid2.amount / tConsumed2: "+("fluidAmount2:"+mFluid2.amount)+(" tConsumed2:"+tConsumed2)+" | "+(mFluid2.amount / tConsumed2)); + Utils.LOG_WARNING("maxEUOutput() * 20 + getMinimumStoredEU(): "+(maxEUOutput() * 30 + getMinimumStoredEU())); + Utils.LOG_WARNING("maxEUOutput(): "+maxEUOutput()); + Utils.LOG_WARNING("maxEUOutput() * 20: "+(maxEUOutput() * 30)); + Utils.LOG_WARNING("getMinimumStoredEU(): "+(getMinimumStoredEU())); + Utils.LOG_WARNING("aBaseMetaTileEntity.getUniversalEnergyStored(): "+(aBaseMetaTileEntity.getUniversalEnergyStored())); + Utils.LOG_WARNING("(maxEUOutput() * 20 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()): "+((maxEUOutput() * 30 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()))); + Utils.LOG_WARNING("tFuelValue2: "+(tFuelValue2)); + Utils.LOG_WARNING("(maxEUOutput() * 20 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue2): "+((maxEUOutput() * 30 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue2)); + */ + if (((tFluidAmountToUse > 0) + && aBaseMetaTileEntity.increaseStoredEnergyUnits( + tFluidAmountToUse * tFuelValue, true)) + && ((tFluidAmountToUse2 > 0) + && aBaseMetaTileEntity.increaseStoredEnergyUnits( + tFluidAmountToUse2 * tFuelValue2, true))) { + + Logger.WARNING("tFuelValue: " + tFuelValue); + Logger.WARNING("tConsumed: " + tConsumed); + Logger.WARNING( + "mFluid.name: " + this.mFluid.getFluid().getName()); + Logger.WARNING("mFluid.amount: " + this.mFluid.amount); + Logger.WARNING("mFluid.amount > tConsumed: " + (this.mFluid.amount > tConsumed)); + + Logger.WARNING("========================================================="); + + Logger.WARNING("tFuelValue2: " + tFuelValue2); + Logger.WARNING("tConsumed2: " + tConsumed2); + Logger.WARNING( + "mFluid2.name: " + this.mFluid2.getFluid().getName()); + Logger.WARNING("mFluid2.amount: " + this.mFluid2.amount); + Logger.WARNING("mFluid2.amount > tConsumed2: " + (this.mFluid2.amount > tConsumed2)); + + if (this.useFuel) { + this.mFluid.amount -= tFluidAmountToUse * tConsumed; + this.mFluid2.amount -= tFluidAmountToUse2 * tConsumed2; + this.useFuel = false; + } else { + this.useFuel = true; + } + + } else { + Logger.WARNING("========================================================="); + Logger.WARNING( + "Either tFluidAmountToUse1 <= 0, power cannot be increased of tFluidAmountToUse2 <= 0"); + Logger.WARNING("tFluidAmountToUse1: " + tFluidAmountToUse); + Logger.WARNING("tFluidAmountToUse2: " + tFluidAmountToUse2); + } + } else { + /*Utils.LOG_WARNING("(tFuelValue > 0 && tConsumed > 0 && mFluid.amount > tConsumed) && (tFuelValue2 > 0 && tConsumed2 > 0 && mFluid2.amount > tConsumed2)"); + Utils.LOG_WARNING("tFuelValue: "+tFuelValue); + Utils.LOG_WARNING("tConsumed: "+tConsumed); + Utils.LOG_WARNING("mFluid.amount: "+mFluid.amount); + Utils.LOG_WARNING("mFluid.amount > tConsumed: "+(mFluid.amount > tConsumed)); + + Utils.LOG_WARNING("========================================================="); + + Utils.LOG_WARNING("tFuelValue2: "+tFuelValue2); + Utils.LOG_WARNING("tConsumed2: "+tConsumed2); + Utils.LOG_WARNING("mFluid2.amount: "+mFluid2.amount); + Utils.LOG_WARNING("mFluid2.amount > tConsumed2: "+(mFluid2.amount > tConsumed2)); */ + } + } else { + Logger.WARNING("One mFluid is null"); + if (this.mFluid != null) { + Logger.WARNING("mFluid1 is not null"); + } + if (this.mFluid2 != null) { + Logger.WARNING("mFluid2 is not null"); + } + } + } + if ((this.mInventory[this.getInputSlot()] != null) + && (aBaseMetaTileEntity.getUniversalEnergyStored() + < ((this.maxEUOutput() * 20) + this.getMinimumStoredEU())) + && (GT_Utility.getFluidForFilledItem(this.mInventory[this.getInputSlot()], true) == null)) { + final int tFuelValue = this.getFuelValue(this.mInventory[this.getInputSlot()]); + if (tFuelValue > 0) { + final ItemStack tEmptyContainer = this.getEmptyContainer(this.mInventory[this.getInputSlot()]); + if (aBaseMetaTileEntity.addStackToSlot(this.getOutputSlot(), tEmptyContainer)) { + aBaseMetaTileEntity.increaseStoredEnergyUnits(tFuelValue, true); + aBaseMetaTileEntity.decrStackSize(this.getInputSlot(), 1); + } + } + } + } + + if (aBaseMetaTileEntity.isServerSide()) { + aBaseMetaTileEntity.setActive(aBaseMetaTileEntity.isAllowedToWork() + && (aBaseMetaTileEntity.getUniversalEnergyStored() + >= (this.maxEUOutput() + this.getMinimumStoredEU()))); + } + } + + public abstract GT_Recipe_Map getRecipes(); + + public abstract int getEfficiency(); + + public int consumedFluidPerOperation(final FluidStack aLiquid) { + return 1; + } + + public int getFuelValue(final FluidStack aLiquid) { + if ((aLiquid == null) || (this.getRecipes() == null)) { + return 0; + } + FluidStack tLiquid; + final Collection<GT_Recipe> tRecipeList = this.getRecipes().mRecipeList; + if (tRecipeList != null) { + for (final GT_Recipe tFuel : tRecipeList) { + if ((tLiquid = GT_Utility.getFluidForFilledItem(tFuel.getRepresentativeInput(0), true)) != null) { + if (aLiquid.isFluidEqual(tLiquid)) { + return (int) (((long) tFuel.mSpecialValue + * this.getEfficiency() + * this.consumedFluidPerOperation(tLiquid)) + / 100); + } + } + } + } + return 0; + } + + public int getFuelValue(final ItemStack aStack) { + if (GT_Utility.isStackInvalid(aStack) || (this.getRecipes() == null)) { + return 0; + } + final GT_Recipe tFuel = + this.getRecipes().findRecipe(this.getBaseMetaTileEntity(), false, Long.MAX_VALUE, null, aStack); + if (tFuel != null) { + return (int) ((tFuel.mSpecialValue * 1000L * this.getEfficiency()) / 100); + } + return 0; + } + + public ItemStack getEmptyContainer(final ItemStack aStack) { + if (GT_Utility.isStackInvalid(aStack) || (this.getRecipes() == null)) { + return null; + } + final GT_Recipe tFuel = + this.getRecipes().findRecipe(this.getBaseMetaTileEntity(), false, Long.MAX_VALUE, null, aStack); + if (tFuel != null) { + return GT_Utility.copy(tFuel.getOutput(0)); + } + return GT_Utility.getContainerItem(aStack, true); + } + + @Override + public boolean allowPutStack( + final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack) + && ((this.getFuelValue(aStack) > 0) + || (this.getFuelValue(GT_Utility.getFluidForFilledItem(aStack, true)) > 0)); + } + + @Override + public int getCapacity() { + return 32000; + } + + @Override + public int getTankPressure() { + return -100; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechMetaBoilerBase.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechMetaBoilerBase.java index 99ad81a4a9..7333f5fb3d 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechMetaBoilerBase.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechMetaBoilerBase.java @@ -1,10 +1,5 @@ package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.generators; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; - import gregtech.api.GregTech_API; import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; @@ -15,368 +10,360 @@ import gregtech.api.objects.GT_ItemStack; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_OreDictUnificator; import gregtech.api.util.GT_Utility; - import gtPlusPlus.core.util.math.MathUtils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidHandler; -public abstract class GregtechMetaBoilerBase extends GT_MetaTileEntity_BasicTank -{ - public int mTemperature = 20; - public int mProcessingEnergy = 0; - public int mLossTimer = 0; - public FluidStack mSteam = null; - public boolean mHadNoWater = false; - public long RI = MathUtils.randLong(5L, 30L); - - public GregtechMetaBoilerBase(final int aID, final String aName, final String aNameRegional, final String aDescription, final ITexture... aTextures) - { - super(aID, aName, aNameRegional, 0, 4, aDescription, aTextures); - } - - public GregtechMetaBoilerBase(final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures) - { - super(aName, aTier, 4, aDescription, aTextures); - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) - { - ITexture[] tmp = this.mTextures[aSide >= 2 ? aSide != aFacing ? 2 : ((byte)(aActive ? 4 : 3)) : aSide][aColorIndex + 1]; - //mTextures[(aSide==aFacing?(aActive?4:3):aSide==GT_Utility.getOppositeSide(aFacing)?2:aSide==0?0:aSide==1?1:2)][aColorIndex+1]; - if((aSide!=aFacing)&&(tmp.length==2)){ - tmp = new ITexture[]{tmp[0]}; - } - return tmp; - } - - @Override - public boolean isElectric() - { - return false; - } - - @Override - public boolean isPneumatic() - { - return false; - } - - @Override - public boolean isSteampowered() - { - return false; - } - - @Override - public boolean isSimpleMachine() - { - return false; - } - - @Override - public boolean isFacingValid(final byte aFacing) - { - return aFacing > 1; - } - - @Override - public boolean isAccessAllowed(final EntityPlayer aPlayer) - { - return true; - } - - @Override - public boolean isValidSlot(final int aIndex) - { - return true; - } - - @Override - public int getProgresstime() - { - return this.mTemperature; - } - - @Override - public int maxProgresstime() - { - return 500; - } - - @Override - public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) - { - if (aBaseMetaTileEntity.isClientSide()) { - return true; - } - if (aPlayer != null) { - if (GT_Utility.areStacksEqual(aPlayer.getCurrentEquippedItem(), new ItemStack(Items.water_bucket, 1))) - { - this.fill(Materials.Water.getFluid(1000 * aPlayer.getCurrentEquippedItem().stackSize), true); - aPlayer.getCurrentEquippedItem().func_150996_a(Items.bucket); - } - else - { - aBaseMetaTileEntity.openGUI(aPlayer); - } - } - return true; - } - - @Override - public boolean doesFillContainers() - { - return true; - } - - @Override - public boolean doesEmptyContainers() - { - return true; - } - - @Override - public boolean canTankBeFilled() - { - return true; - } - - @Override - public boolean canTankBeEmptied() - { - return true; - } - - @Override - public boolean displaysItemStack() - { - return false; - } - - @Override - public boolean displaysStackSize() - { - return false; - } - - @Override - public boolean isFluidInputAllowed(final FluidStack aFluid) - { - return GT_ModHandler.isWater(aFluid); - } - - @Override - public FluidStack getDrainableStack() - { - return this.mSteam; - } - - @Override - public FluidStack setDrainableStack(final FluidStack aFluid) - { - this.mSteam = aFluid; - return this.mSteam; - } - - @Override - public boolean isDrainableStackSeparate() { - return true; - } - - @Override - public boolean allowCoverOnSide(final byte aSide, final GT_ItemStack aCover) - { - return GregTech_API.getCoverBehavior(aCover.toStack()).isSimpleCover(); - } - - @Override - public void saveNBTData(final NBTTagCompound aNBT) - { - super.saveNBTData(aNBT); - aNBT.setInteger("mLossTimer", this.mLossTimer); - aNBT.setInteger("mTemperature", this.mTemperature); - aNBT.setInteger("mProcessingEnergy", this.mProcessingEnergy); - if (this.mSteam != null) { - try - { - aNBT.setTag("mSteam", this.mSteam.writeToNBT(new NBTTagCompound())); - } - catch (final Throwable e) {} - } - } - - @Override - public void loadNBTData(final NBTTagCompound aNBT) - { - super.loadNBTData(aNBT); - this.mLossTimer = aNBT.getInteger("mLossTimer"); - this.mTemperature = aNBT.getInteger("mTemperature"); - this.mProcessingEnergy = aNBT.getInteger("mProcessingEnergy"); - this.mSteam = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mSteam")); - } - - @Override - public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) - { - if ((aBaseMetaTileEntity.isServerSide()) && (aTick > 20L)) - { - if (this.mTemperature <= 20) - { - this.mTemperature = 20; - this.mLossTimer = 0; - } - if (++this.mLossTimer > 40) - { - this.mTemperature -= 1; - this.mLossTimer = 0; - } - for (byte i = 1; (this.mSteam != null) && (i < 6); i = (byte)(i + 1)) { - if (i != aBaseMetaTileEntity.getFrontFacing()) - { - final IFluidHandler tTileEntity = aBaseMetaTileEntity.getITankContainerAtSide(i); - if (tTileEntity != null) - { - final FluidStack tDrained = aBaseMetaTileEntity.drain(ForgeDirection.getOrientation(i), Math.max(1, this.mSteam.amount / 2), false); - if (tDrained != null) - { - final int tFilledAmount = tTileEntity.fill(ForgeDirection.getOrientation(i).getOpposite(), tDrained, false); - if (tFilledAmount > 0) { - tTileEntity.fill(ForgeDirection.getOrientation(i).getOpposite(), aBaseMetaTileEntity.drain(ForgeDirection.getOrientation(i), tFilledAmount, true), true); - } - } - } - } - } - if ((aTick % 10L) == 0L) { - if (this.mTemperature > 100) - { - if ((this.mFluid == null) || (!GT_ModHandler.isWater(this.mFluid)) || (this.mFluid.amount <= 0)) - { - this.mHadNoWater = true; - } - else - { - if (this.mHadNoWater) - { - aBaseMetaTileEntity.doExplosion(2048L); - return; - } - this.mFluid.amount -= 1; - if (this.mSteam == null) { - this.mSteam = GT_ModHandler.getSteam(150L); - } else if (GT_ModHandler.isSteam(this.mSteam)) { - this.mSteam.amount += 150; - } else { - this.mSteam = GT_ModHandler.getSteam(150L); - } - } - } - else { - this.mHadNoWater = false; - } - } - if ((this.mSteam != null) && - (this.mSteam.amount > getSteamCapacity())) - { - this.sendSound((byte)1); - this.mSteam.amount = getSteamCapacity() * 3 / 4; - } - if ((this.mProcessingEnergy <= 0) && (aBaseMetaTileEntity.isAllowedToWork()) && - (this.mInventory[2] != null)) { - if ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.gem.get(Materials.Coal))) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.dust.get(Materials.Coal))) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.dustImpure.get(Materials.Coal))) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.crushed.get(Materials.Coal)))) - { - this.mProcessingEnergy += 160; - aBaseMetaTileEntity.decrStackSize(2, 1); - if (aBaseMetaTileEntity.getRandomNumber(3) == 0) { - aBaseMetaTileEntity.addStackToSlot(3, GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.DarkAsh, 1L)); - } - } - else if (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.gem.get(Materials.Charcoal))) - { - this.mProcessingEnergy += 160; - aBaseMetaTileEntity.decrStackSize(2, 1); - if (aBaseMetaTileEntity.getRandomNumber(3) == 0) { - aBaseMetaTileEntity.addStackToSlot(3, GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.Ash, 1L)); - } - } - else if (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], "fuelCoke")) - { - this.mProcessingEnergy += 640; - aBaseMetaTileEntity.decrStackSize(2, 1); - if (aBaseMetaTileEntity.getRandomNumber(2) == 0) { - aBaseMetaTileEntity.addStackToSlot(3, GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.Ash, 1L)); - } - } - else if ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.gem.get(Materials.Lignite))) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.dust.get(Materials.Lignite))) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.dustImpure.get(Materials.Lignite))) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.crushed.get(Materials.Lignite)))) - { - this.mProcessingEnergy += 40; - aBaseMetaTileEntity.decrStackSize(2, 1); - if (aBaseMetaTileEntity.getRandomNumber(8) == 0) { - aBaseMetaTileEntity.addStackToSlot(3, GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.DarkAsh, 1L)); - } - } - } - if ((this.mTemperature < 1000) && (this.mProcessingEnergy > 0) && ((aTick % 12L) == 0L)) - { - this.mProcessingEnergy -= 2; - this.mTemperature += 1; - } - aBaseMetaTileEntity.setActive(this.mProcessingEnergy > 0); - } - } - - @Override - // Since this type of machine can have different water and steam capacities, we need to override getTankInfo() to - // support returning those different capacities. - public FluidTankInfo[] getTankInfo(ForgeDirection aSide) { - return new FluidTankInfo[]{ - new FluidTankInfo(this.mFluid, getCapacity()), - new FluidTankInfo(this.mSteam, getSteamCapacity()) - }; - } - - @Override - public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) - { - return (aIndex == 1) || (aIndex == 3); - } - - @Override - public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) - { - return aIndex == 2; - } - - @Override - public void doSound(final byte aIndex, final double aX, final double aY, final double aZ) - { - if (aIndex == 1) - { - GT_Utility.doSoundAtClient(GregTech_API.sSoundList.get(Integer.valueOf(4)), 2, 1.0F, aX, aY, aZ); - for (int l = 0; l < 8; l++) { - this.getBaseMetaTileEntity().getWorld().spawnParticle("largesmoke", (aX - 0.5D) + Math.random(), aY, (aZ - 0.5D) + Math.random(), 0.0D, 0.0D, 0.0D); - } - } - } - - @Override - public int getCapacity() - { - return 16000; - } - - // This type of machine can have different water and steam capacities. - public int getSteamCapacity() - { - return 32000; - } - - @Override - public int getTankPressure() - { - return 100; - } +public abstract class GregtechMetaBoilerBase extends GT_MetaTileEntity_BasicTank { + public int mTemperature = 20; + public int mProcessingEnergy = 0; + public int mLossTimer = 0; + public FluidStack mSteam = null; + public boolean mHadNoWater = false; + public long RI = MathUtils.randLong(5L, 30L); + + public GregtechMetaBoilerBase( + final int aID, + final String aName, + final String aNameRegional, + final String aDescription, + final ITexture... aTextures) { + super(aID, aName, aNameRegional, 0, 4, aDescription, aTextures); + } + + public GregtechMetaBoilerBase( + final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures) { + super(aName, aTier, 4, aDescription, aTextures); + } + + @Override + public ITexture[] getTexture( + final IGregTechTileEntity aBaseMetaTileEntity, + final byte aSide, + final byte aFacing, + final byte aColorIndex, + final boolean aActive, + final boolean aRedstone) { + ITexture[] tmp = + this.mTextures[aSide >= 2 ? aSide != aFacing ? 2 : ((byte) (aActive ? 4 : 3)) : aSide][aColorIndex + 1]; + // mTextures[(aSide==aFacing?(aActive?4:3):aSide==GT_Utility.getOppositeSide(aFacing)?2:aSide==0?0:aSide==1?1:2)][aColorIndex+1]; + if ((aSide != aFacing) && (tmp.length == 2)) { + tmp = new ITexture[] {tmp[0]}; + } + return tmp; + } + + @Override + public boolean isElectric() { + return false; + } + + @Override + public boolean isPneumatic() { + return false; + } + + @Override + public boolean isSteampowered() { + return false; + } + + @Override + public boolean isSimpleMachine() { + return false; + } + + @Override + public boolean isFacingValid(final byte aFacing) { + return aFacing > 1; + } + + @Override + public boolean isAccessAllowed(final EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean isValidSlot(final int aIndex) { + return true; + } + + @Override + public int getProgresstime() { + return this.mTemperature; + } + + @Override + public int maxProgresstime() { + return 500; + } + + @Override + public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } + if (aPlayer != null) { + if (GT_Utility.areStacksEqual(aPlayer.getCurrentEquippedItem(), new ItemStack(Items.water_bucket, 1))) { + this.fill(Materials.Water.getFluid(1000 * aPlayer.getCurrentEquippedItem().stackSize), true); + aPlayer.getCurrentEquippedItem().func_150996_a(Items.bucket); + } else { + aBaseMetaTileEntity.openGUI(aPlayer); + } + } + return true; + } + + @Override + public boolean doesFillContainers() { + return true; + } + + @Override + public boolean doesEmptyContainers() { + return true; + } + + @Override + public boolean canTankBeFilled() { + return true; + } + + @Override + public boolean canTankBeEmptied() { + return true; + } + + @Override + public boolean displaysItemStack() { + return false; + } + + @Override + public boolean displaysStackSize() { + return false; + } + + @Override + public boolean isFluidInputAllowed(final FluidStack aFluid) { + return GT_ModHandler.isWater(aFluid); + } + + @Override + public FluidStack getDrainableStack() { + return this.mSteam; + } + + @Override + public FluidStack setDrainableStack(final FluidStack aFluid) { + this.mSteam = aFluid; + return this.mSteam; + } + + @Override + public boolean isDrainableStackSeparate() { + return true; + } + + @Override + public boolean allowCoverOnSide(final byte aSide, final GT_ItemStack aCover) { + return GregTech_API.getCoverBehavior(aCover.toStack()).isSimpleCover(); + } + + @Override + public void saveNBTData(final NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setInteger("mLossTimer", this.mLossTimer); + aNBT.setInteger("mTemperature", this.mTemperature); + aNBT.setInteger("mProcessingEnergy", this.mProcessingEnergy); + if (this.mSteam != null) { + try { + aNBT.setTag("mSteam", this.mSteam.writeToNBT(new NBTTagCompound())); + } catch (final Throwable e) { + } + } + } + + @Override + public void loadNBTData(final NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + this.mLossTimer = aNBT.getInteger("mLossTimer"); + this.mTemperature = aNBT.getInteger("mTemperature"); + this.mProcessingEnergy = aNBT.getInteger("mProcessingEnergy"); + this.mSteam = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mSteam")); + } + + @Override + public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { + if ((aBaseMetaTileEntity.isServerSide()) && (aTick > 20L)) { + if (this.mTemperature <= 20) { + this.mTemperature = 20; + this.mLossTimer = 0; + } + if (++this.mLossTimer > 40) { + this.mTemperature -= 1; + this.mLossTimer = 0; + } + for (byte i = 1; (this.mSteam != null) && (i < 6); i = (byte) (i + 1)) { + if (i != aBaseMetaTileEntity.getFrontFacing()) { + final IFluidHandler tTileEntity = aBaseMetaTileEntity.getITankContainerAtSide(i); + if (tTileEntity != null) { + final FluidStack tDrained = aBaseMetaTileEntity.drain( + ForgeDirection.getOrientation(i), Math.max(1, this.mSteam.amount / 2), false); + if (tDrained != null) { + final int tFilledAmount = tTileEntity.fill( + ForgeDirection.getOrientation(i).getOpposite(), tDrained, false); + if (tFilledAmount > 0) { + tTileEntity.fill( + ForgeDirection.getOrientation(i).getOpposite(), + aBaseMetaTileEntity.drain( + ForgeDirection.getOrientation(i), tFilledAmount, true), + true); + } + } + } + } + } + if ((aTick % 10L) == 0L) { + if (this.mTemperature > 100) { + if ((this.mFluid == null) || (!GT_ModHandler.isWater(this.mFluid)) || (this.mFluid.amount <= 0)) { + this.mHadNoWater = true; + } else { + if (this.mHadNoWater) { + aBaseMetaTileEntity.doExplosion(2048L); + return; + } + this.mFluid.amount -= 1; + if (this.mSteam == null) { + this.mSteam = GT_ModHandler.getSteam(150L); + } else if (GT_ModHandler.isSteam(this.mSteam)) { + this.mSteam.amount += 150; + } else { + this.mSteam = GT_ModHandler.getSteam(150L); + } + } + } else { + this.mHadNoWater = false; + } + } + if ((this.mSteam != null) && (this.mSteam.amount > getSteamCapacity())) { + this.sendSound((byte) 1); + this.mSteam.amount = getSteamCapacity() * 3 / 4; + } + if ((this.mProcessingEnergy <= 0) + && (aBaseMetaTileEntity.isAllowedToWork()) + && (this.mInventory[2] != null)) { + if ((GT_OreDictUnificator.isItemStackInstanceOf( + this.mInventory[2], OrePrefixes.gem.get(Materials.Coal))) + || (GT_OreDictUnificator.isItemStackInstanceOf( + this.mInventory[2], OrePrefixes.dust.get(Materials.Coal))) + || (GT_OreDictUnificator.isItemStackInstanceOf( + this.mInventory[2], OrePrefixes.dustImpure.get(Materials.Coal))) + || (GT_OreDictUnificator.isItemStackInstanceOf( + this.mInventory[2], OrePrefixes.crushed.get(Materials.Coal)))) { + this.mProcessingEnergy += 160; + aBaseMetaTileEntity.decrStackSize(2, 1); + if (aBaseMetaTileEntity.getRandomNumber(3) == 0) { + aBaseMetaTileEntity.addStackToSlot( + 3, GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.DarkAsh, 1L)); + } + } else if (GT_OreDictUnificator.isItemStackInstanceOf( + this.mInventory[2], OrePrefixes.gem.get(Materials.Charcoal))) { + this.mProcessingEnergy += 160; + aBaseMetaTileEntity.decrStackSize(2, 1); + if (aBaseMetaTileEntity.getRandomNumber(3) == 0) { + aBaseMetaTileEntity.addStackToSlot( + 3, GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.Ash, 1L)); + } + } else if (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], "fuelCoke")) { + this.mProcessingEnergy += 640; + aBaseMetaTileEntity.decrStackSize(2, 1); + if (aBaseMetaTileEntity.getRandomNumber(2) == 0) { + aBaseMetaTileEntity.addStackToSlot( + 3, GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.Ash, 1L)); + } + } else if ((GT_OreDictUnificator.isItemStackInstanceOf( + this.mInventory[2], OrePrefixes.gem.get(Materials.Lignite))) + || (GT_OreDictUnificator.isItemStackInstanceOf( + this.mInventory[2], OrePrefixes.dust.get(Materials.Lignite))) + || (GT_OreDictUnificator.isItemStackInstanceOf( + this.mInventory[2], OrePrefixes.dustImpure.get(Materials.Lignite))) + || (GT_OreDictUnificator.isItemStackInstanceOf( + this.mInventory[2], OrePrefixes.crushed.get(Materials.Lignite)))) { + this.mProcessingEnergy += 40; + aBaseMetaTileEntity.decrStackSize(2, 1); + if (aBaseMetaTileEntity.getRandomNumber(8) == 0) { + aBaseMetaTileEntity.addStackToSlot( + 3, GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.DarkAsh, 1L)); + } + } + } + if ((this.mTemperature < 1000) && (this.mProcessingEnergy > 0) && ((aTick % 12L) == 0L)) { + this.mProcessingEnergy -= 2; + this.mTemperature += 1; + } + aBaseMetaTileEntity.setActive(this.mProcessingEnergy > 0); + } + } + + @Override + // Since this type of machine can have different water and steam capacities, we need to override getTankInfo() to + // support returning those different capacities. + public FluidTankInfo[] getTankInfo(ForgeDirection aSide) { + return new FluidTankInfo[] { + new FluidTankInfo(this.mFluid, getCapacity()), new FluidTankInfo(this.mSteam, getSteamCapacity()) + }; + } + + @Override + public boolean allowPullStack( + final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return (aIndex == 1) || (aIndex == 3); + } + + @Override + public boolean allowPutStack( + final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return aIndex == 2; + } + + @Override + public void doSound(final byte aIndex, final double aX, final double aY, final double aZ) { + if (aIndex == 1) { + GT_Utility.doSoundAtClient(GregTech_API.sSoundList.get(Integer.valueOf(4)), 2, 1.0F, aX, aY, aZ); + for (int l = 0; l < 8; l++) { + this.getBaseMetaTileEntity() + .getWorld() + .spawnParticle( + "largesmoke", + (aX - 0.5D) + Math.random(), + aY, + (aZ - 0.5D) + Math.random(), + 0.0D, + 0.0D, + 0.0D); + } + } + } + + @Override + public int getCapacity() { + return 16000; + } + + // This type of machine can have different water and steam capacities. + public int getSteamCapacity() { + return 32000; + } + + @Override + public int getTankPressure() { + return 100; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechMetaSolarGenerator.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechMetaSolarGenerator.java index e692530963..258f6320ae 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechMetaSolarGenerator.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechMetaSolarGenerator.java @@ -2,214 +2,251 @@ package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.generat import static gregtech.api.enums.GT_Values.V; -import net.minecraft.entity.player.EntityPlayer; - import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicTank; import gregtech.api.util.GT_Utility; +import net.minecraft.entity.player.EntityPlayer; public abstract class GregtechMetaSolarGenerator extends GT_MetaTileEntity_BasicTank { - public int mEfficiency; - public int mProcessingEnergy = 0; - public int mSolarCharge = 20; - public int mLossTimer = 0; - public static int sEnergyPerTick = 16; - - public GregtechMetaSolarGenerator(final int aID, final String aName, final String aNameRegional, final int aTier, final String aDescription, final ITexture... aTextures) { - super(aID, aName, aNameRegional, aTier, 3, aDescription, aTextures); - } - - public GregtechMetaSolarGenerator(final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures) { - super(aName, aTier, 3, aDescription, aTextures); - } - - @Override - public ITexture[][][] getTextureSet(final ITexture[] aTextures) { - final ITexture[][][] rTextures = new ITexture[10][17][]; - for (byte i = -1; i < 16; i++) { - rTextures[0][i + 1] = this.getFront(i); - rTextures[1][i + 1] = this.getBack(i); - rTextures[2][i + 1] = this.getBottom(i); - rTextures[3][i + 1] = this.getTop(i); - rTextures[4][i + 1] = this.getSides(i); - rTextures[5][i + 1] = this.getFrontActive(i); - rTextures[6][i + 1] = this.getBackActive(i); - rTextures[7][i + 1] = this.getBottomActive(i); - rTextures[8][i + 1] = this.getTopActive(i); - rTextures[9][i + 1] = this.getSidesActive(i); - } - return rTextures; - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { - return this.mTextures[(aActive ? 5 : 0) + (aSide == aFacing ? 0 : aSide == GT_Utility.getOppositeSide(aFacing) ? 1 : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][aColorIndex + 1]; - } - - @Override - public String[] getDescription() { - return new String[]{this.mDescription, "Efficiency: " + this.getEfficiency() + "%"}; - } - - @Override - public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) { - return true; - } - aBaseMetaTileEntity.openGUI(aPlayer); - return true; - } - - public ITexture[] getFront(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]}; - } - - public ITexture[] getBack(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]}; - } - - public ITexture[] getBottom(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]}; - } - - public ITexture[] getTop(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]}; - } - - public ITexture[] getSides(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]}; - } - - public ITexture[] getFrontActive(final byte aColor) { - return this.getFront(aColor); - } - - public ITexture[] getBackActive(final byte aColor) { - return this.getBack(aColor); - } - - public ITexture[] getBottomActive(final byte aColor) { - return this.getBottom(aColor); - } - - public ITexture[] getTopActive(final byte aColor) { - return this.getTop(aColor); - } - - public ITexture[] getSidesActive(final byte aColor) { - return this.getSides(aColor); - } - - @Override - public boolean isFacingValid(final byte aSide) { - return aSide > 1; - } - - @Override - public boolean isSimpleMachine() { - return false; - } - - @Override - public boolean isValidSlot(final int aIndex) { - return aIndex < 2; - } - - @Override - public boolean isEnetOutput() { - return true; - } - - @Override - public boolean isOutputFacing(final byte aSide) { - return true; - } - - @Override - public boolean isAccessAllowed(final EntityPlayer aPlayer) { - return true; - } - - @Override - public long maxEUOutput() { - return this.getBaseMetaTileEntity().isAllowedToWork() ? V[this.mTier] : 0; - } - - @Override - public long maxEUStore() { - return Math.max(this.getEUVar(), (V[this.mTier] * 40) + this.getMinimumStoredEU()); - } - - @Override - public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { - if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.isAllowedToWork() && (aTick > 20L) - && (aBaseMetaTileEntity.getUniversalEnergyStored() < (this.maxEUOutput() + aBaseMetaTileEntity.getEUCapacity()))) { - - if (this.mSolarCharge <= 20) { - this.mSolarCharge = 20; - this.mLossTimer = 0; - } - if (++this.mLossTimer > 45) { - this.mSolarCharge -= 1; - this.mLossTimer = 0; - } - - if ((aTick % 25L) == 0L) { - if (this.mSolarCharge > 100) { - if ((this.mProcessingEnergy > 0) && (aBaseMetaTileEntity.isAllowedToWork()) && ((aTick % 256L) == 0L) && (!aBaseMetaTileEntity.getWorld().isThundering() && (aBaseMetaTileEntity.getUniversalEnergyStored() < ((this.maxEUOutput() * 20) + this.getMinimumStoredEU())))) { - this.getBaseMetaTileEntity().increaseStoredEnergyUnits((sEnergyPerTick * this.getEfficiency()) / 10, false); - } - } - } - - if ((this.mSolarCharge < 500) && (this.mProcessingEnergy > 0) && ((aTick % 12L) == 0L)) { - this.mProcessingEnergy -= 1; - this.mSolarCharge += 1; - } - - if ((this.mProcessingEnergy <= 0) && (aBaseMetaTileEntity.isAllowedToWork()) && ((aTick % 256L) == 0L) && (!aBaseMetaTileEntity.getWorld().isThundering())) { - final boolean bRain = aBaseMetaTileEntity.getWorld().isRaining() && (aBaseMetaTileEntity.getBiome().rainfall > 0.0F); - this.mProcessingEnergy += (bRain && (aBaseMetaTileEntity.getWorld().skylightSubtracted >= 4)) || !aBaseMetaTileEntity.getSkyAtSide((byte) 1) ? 0 : !bRain && aBaseMetaTileEntity.getWorld().isDaytime() ? 8 : 1; - } - - if (aBaseMetaTileEntity.isServerSide()){ - aBaseMetaTileEntity.setActive(aBaseMetaTileEntity.isAllowedToWork() && (aBaseMetaTileEntity.getUniversalEnergyStored() >= (this.maxEUOutput() + this.getMinimumStoredEU()))); - } - } - } - - public abstract int getEfficiency(); - - @Override - public boolean doesFillContainers() { - return false; - } - - @Override - public boolean doesEmptyContainers() { - return false; - } - - @Override - public boolean canTankBeFilled() { - return false; - } - - @Override - public boolean canTankBeEmptied() { - return false; - } - - @Override - public boolean displaysItemStack() { - return false; - } - - @Override - public boolean displaysStackSize() { - return false; - } + public int mEfficiency; + public int mProcessingEnergy = 0; + public int mSolarCharge = 20; + public int mLossTimer = 0; + public static int sEnergyPerTick = 16; + + public GregtechMetaSolarGenerator( + final int aID, + final String aName, + final String aNameRegional, + final int aTier, + final String aDescription, + final ITexture... aTextures) { + super(aID, aName, aNameRegional, aTier, 3, aDescription, aTextures); + } + + public GregtechMetaSolarGenerator( + final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures) { + super(aName, aTier, 3, aDescription, aTextures); + } + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + final ITexture[][][] rTextures = new ITexture[10][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = this.getFront(i); + rTextures[1][i + 1] = this.getBack(i); + rTextures[2][i + 1] = this.getBottom(i); + rTextures[3][i + 1] = this.getTop(i); + rTextures[4][i + 1] = this.getSides(i); + rTextures[5][i + 1] = this.getFrontActive(i); + rTextures[6][i + 1] = this.getBackActive(i); + rTextures[7][i + 1] = this.getBottomActive(i); + rTextures[8][i + 1] = this.getTopActive(i); + rTextures[9][i + 1] = this.getSidesActive(i); + } + return rTextures; + } + + @Override + public ITexture[] getTexture( + final IGregTechTileEntity aBaseMetaTileEntity, + final byte aSide, + final byte aFacing, + final byte aColorIndex, + final boolean aActive, + final boolean aRedstone) { + return this.mTextures[ + (aActive ? 5 : 0) + + (aSide == aFacing + ? 0 + : aSide == GT_Utility.getOppositeSide(aFacing) + ? 1 + : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][ + aColorIndex + 1]; + } + + @Override + public String[] getDescription() { + return new String[] {this.mDescription, "Efficiency: " + this.getEfficiency() + "%"}; + } + + @Override + public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + + public ITexture[] getFront(final byte aColor) { + return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]}; + } + + public ITexture[] getBack(final byte aColor) { + return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]}; + } + + public ITexture[] getBottom(final byte aColor) { + return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]}; + } + + public ITexture[] getTop(final byte aColor) { + return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]}; + } + + public ITexture[] getSides(final byte aColor) { + return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]}; + } + + public ITexture[] getFrontActive(final byte aColor) { + return this.getFront(aColor); + } + + public ITexture[] getBackActive(final byte aColor) { + return this.getBack(aColor); + } + + public ITexture[] getBottomActive(final byte aColor) { + return this.getBottom(aColor); + } + + public ITexture[] getTopActive(final byte aColor) { + return this.getTop(aColor); + } + + public ITexture[] getSidesActive(final byte aColor) { + return this.getSides(aColor); + } + + @Override + public boolean isFacingValid(final byte aSide) { + return aSide > 1; + } + + @Override + public boolean isSimpleMachine() { + return false; + } + + @Override + public boolean isValidSlot(final int aIndex) { + return aIndex < 2; + } + + @Override + public boolean isEnetOutput() { + return true; + } + + @Override + public boolean isOutputFacing(final byte aSide) { + return true; + } + + @Override + public boolean isAccessAllowed(final EntityPlayer aPlayer) { + return true; + } + + @Override + public long maxEUOutput() { + return this.getBaseMetaTileEntity().isAllowedToWork() ? V[this.mTier] : 0; + } + + @Override + public long maxEUStore() { + return Math.max(this.getEUVar(), (V[this.mTier] * 40) + this.getMinimumStoredEU()); + } + + @Override + public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { + if (aBaseMetaTileEntity.isServerSide() + && aBaseMetaTileEntity.isAllowedToWork() + && (aTick > 20L) + && (aBaseMetaTileEntity.getUniversalEnergyStored() + < (this.maxEUOutput() + aBaseMetaTileEntity.getEUCapacity()))) { + + if (this.mSolarCharge <= 20) { + this.mSolarCharge = 20; + this.mLossTimer = 0; + } + if (++this.mLossTimer > 45) { + this.mSolarCharge -= 1; + this.mLossTimer = 0; + } + + if ((aTick % 25L) == 0L) { + if (this.mSolarCharge > 100) { + if ((this.mProcessingEnergy > 0) + && (aBaseMetaTileEntity.isAllowedToWork()) + && ((aTick % 256L) == 0L) + && (!aBaseMetaTileEntity.getWorld().isThundering() + && (aBaseMetaTileEntity.getUniversalEnergyStored() + < ((this.maxEUOutput() * 20) + this.getMinimumStoredEU())))) { + this.getBaseMetaTileEntity() + .increaseStoredEnergyUnits((sEnergyPerTick * this.getEfficiency()) / 10, false); + } + } + } + + if ((this.mSolarCharge < 500) && (this.mProcessingEnergy > 0) && ((aTick % 12L) == 0L)) { + this.mProcessingEnergy -= 1; + this.mSolarCharge += 1; + } + + if ((this.mProcessingEnergy <= 0) + && (aBaseMetaTileEntity.isAllowedToWork()) + && ((aTick % 256L) == 0L) + && (!aBaseMetaTileEntity.getWorld().isThundering())) { + final boolean bRain = + aBaseMetaTileEntity.getWorld().isRaining() && (aBaseMetaTileEntity.getBiome().rainfall > 0.0F); + this.mProcessingEnergy += (bRain && (aBaseMetaTileEntity.getWorld().skylightSubtracted >= 4)) + || !aBaseMetaTileEntity.getSkyAtSide((byte) 1) + ? 0 + : !bRain && aBaseMetaTileEntity.getWorld().isDaytime() ? 8 : 1; + } + + if (aBaseMetaTileEntity.isServerSide()) { + aBaseMetaTileEntity.setActive(aBaseMetaTileEntity.isAllowedToWork() + && (aBaseMetaTileEntity.getUniversalEnergyStored() + >= (this.maxEUOutput() + this.getMinimumStoredEU()))); + } + } + } + + public abstract int getEfficiency(); + + @Override + public boolean doesFillContainers() { + return false; + } + + @Override + public boolean doesEmptyContainers() { + return false; + } + + @Override + public boolean canTankBeFilled() { + return false; + } + + @Override + public boolean canTankBeEmptied() { + return false; + } + + @Override + public boolean displaysItemStack() { + return false; + } + + @Override + public boolean displaysStackSize() { + return false; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechRocketFuelGeneratorBase.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechRocketFuelGeneratorBase.java index f9105dceb1..fe7ffee685 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechRocketFuelGeneratorBase.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechRocketFuelGeneratorBase.java @@ -2,8 +2,6 @@ package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.generat import static gregtech.api.enums.GT_Values.V; -import java.util.Collection; - import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -14,6 +12,7 @@ import gregtech.api.util.GT_Utility; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils; +import java.util.Collection; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; @@ -21,352 +20,384 @@ import net.minecraftforge.fluids.FluidStack; public abstract class GregtechRocketFuelGeneratorBase extends GT_MetaTileEntity_BasicTank { - private boolean useFuel = false; - protected int pollMin, pollMax; - - public GregtechRocketFuelGeneratorBase(final int aID, final String aName, final String aNameRegional, final int aTier, final String aDescription, final ITexture... aTextures) { - super(aID, aName, aNameRegional, aTier, 3, aDescription, aTextures); - int pollMin = (int)(CORE.ConfigSwitches.baseMinPollutionPerSecondRocketFuelGenerator * CORE.ConfigSwitches.pollutionReleasedByTierRocketFuelGenerator[mTier]); - int pollMax = (int)(CORE.ConfigSwitches.baseMaxPollutionPerSecondRocketFuelGenerator * CORE.ConfigSwitches.pollutionReleasedByTierRocketFuelGenerator[mTier]); - } - - public GregtechRocketFuelGeneratorBase(final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures) { - super(aName, aTier, 3, aDescription, aTextures); - int pollMin = (int)(CORE.ConfigSwitches.baseMinPollutionPerSecondRocketFuelGenerator * CORE.ConfigSwitches.pollutionReleasedByTierRocketFuelGenerator[mTier]); - int pollMax = (int)(CORE.ConfigSwitches.baseMaxPollutionPerSecondRocketFuelGenerator * CORE.ConfigSwitches.pollutionReleasedByTierRocketFuelGenerator[mTier]); - } - - @Override - public ITexture[][][] getTextureSet(final ITexture[] aTextures) { - final ITexture[][][] rTextures = new ITexture[10][17][]; - for (byte i = -1; i < 16; i++) { - rTextures[0][i + 1] = this.getFront(i); - rTextures[1][i + 1] = this.getBack(i); - rTextures[2][i + 1] = this.getBottom(i); - rTextures[3][i + 1] = this.getTop(i); - rTextures[4][i + 1] = this.getSides(i); - rTextures[5][i + 1] = this.getFrontActive(i); - rTextures[6][i + 1] = this.getBackActive(i); - rTextures[7][i + 1] = this.getBottomActive(i); - rTextures[8][i + 1] = this.getTopActive(i); - rTextures[9][i + 1] = this.getSidesActive(i); - } - return rTextures; - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { - return this.mTextures[(aActive ? 5 : 0) + (aSide == aFacing ? 0 : aSide == GT_Utility.getOppositeSide(aFacing) ? 1 : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][aColorIndex + 1]; - } - - - @Override - public String[] getDescription() { - String aPollution = "Causes between "+pollMin+" and "+pollMax+ " Pollution per second"; - return new String[]{ - this.mDescription, - "Fuel Efficiency: " + this.getEfficiency() + "%", - aPollution, - CORE.GT_Tooltip}; - } - - - - @Override - public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) { - return true; - } - aBaseMetaTileEntity.openGUI(aPlayer); - return true; - } - - public ITexture[] getFront(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]}; - } - - public ITexture[] getBack(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]}; - } - - public ITexture[] getBottom(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]}; - } - - public ITexture[] getTop(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]}; - } - - public ITexture[] getSides(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]}; - } - - public ITexture[] getFrontActive(final byte aColor) { - return this.getFront(aColor); - } - - public ITexture[] getBackActive(final byte aColor) { - return this.getBack(aColor); - } - - public ITexture[] getBottomActive(final byte aColor) { - return this.getBottom(aColor); - } - - public ITexture[] getTopActive(final byte aColor) { - return this.getTop(aColor); - } - - public ITexture[] getSidesActive(final byte aColor) { - return this.getSides(aColor); - } - - @Override - public boolean isFacingValid(final byte aSide) { - return aSide > 1; - } - - @Override - public boolean isSimpleMachine() { - return false; - } - - @Override - public boolean isValidSlot(final int aIndex) { - return aIndex < 2; - } - - @Override - public boolean isEnetOutput() { - return true; - } - - @Override - public boolean isOutputFacing(final byte aSide) { - return this.getBaseMetaTileEntity().getFrontFacing() == aSide; - } - - @Override - public boolean isAccessAllowed(final EntityPlayer aPlayer) { - return true; - } - - @Override - public long maxEUOutput() { - return V[this.mTier]; - } - - @Override - public long maxEUStore() { - return Math.max(this.getEUVar(), (V[this.mTier] * 500) + this.getMinimumStoredEU()); - } - - @Override - public boolean doesFillContainers() { - return false; - } - - @Override - public boolean doesEmptyContainers() { - return true; - } - - @Override - public boolean canTankBeFilled() { - return true; - } - - @Override - public boolean canTankBeEmptied() { - return false; - } - - @Override - public boolean displaysItemStack() { - return true; - } - - @Override - public boolean displaysStackSize() { - return false; - } - - @Override - public boolean isFluidInputAllowed(final FluidStack aFluid) { - return this.getFuelValue(aFluid) > 0; - } - - @Override - public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { - - - //super.onPostTick(aBaseMetaTileEntity, aTick); - - /*if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.isAllowedToWork() && aTick % 10L == 0L) { - int tFuelValue; - if (this.mFluid == null) { - if (aBaseMetaTileEntity.getUniversalEnergyStored() < this.maxEUOutput() + this.getMinimumStoredEU()) { - this.mInventory[this.getStackDisplaySlot()] = null; - } else { - if (this.mInventory[this.getStackDisplaySlot()] == null) { - this.mInventory[this.getStackDisplaySlot()] = new ItemStack(Blocks.fire, 1); - } - - this.mInventory[this.getStackDisplaySlot()].setStackDisplayName("Generating: " - + (aBaseMetaTileEntity.getUniversalEnergyStored() - this.getMinimumStoredEU()) + " EU"); - } - } else { - tFuelValue = this.getFuelValue(this.mFluid); - int tConsumed = this.consumedFluidPerOperation(this.mFluid); - if (tFuelValue > 0 && tConsumed > 0 && this.mFluid.amount > tConsumed) { - long tFluidAmountToUse = Math.min((long) (this.mFluid.amount / tConsumed), - (this.maxEUStore() - aBaseMetaTileEntity.getUniversalEnergyStored()) / (long) tFuelValue); - if (tFluidAmountToUse > 0L && aBaseMetaTileEntity - .increaseStoredEnergyUnits(tFluidAmountToUse * (long) tFuelValue, true)) { - PollutionUtils.addPollution(this.getBaseMetaTileEntity(), 10 * this.getPollution()); - this.mFluid.amount = (int) ((long) this.mFluid.amount - tFluidAmountToUse * (long) tConsumed); - } - } - } - - if (this.mInventory[this.getInputSlot()] != null - && aBaseMetaTileEntity.getUniversalEnergyStored() < this.maxEUOutput() * 20L - + this.getMinimumStoredEU() - && GT_Utility.getFluidForFilledItem(this.mInventory[this.getInputSlot()], true) == null) { - tFuelValue = this.getFuelValue(this.mInventory[this.getInputSlot()]); - if (tFuelValue > 0) { - ItemStack tEmptyContainer = this.getEmptyContainer(this.mInventory[this.getInputSlot()]); - if (aBaseMetaTileEntity.addStackToSlot(this.getOutputSlot(), tEmptyContainer)) { - aBaseMetaTileEntity.increaseStoredEnergyUnits((long) tFuelValue, true); - aBaseMetaTileEntity.decrStackSize(this.getInputSlot(), 1); - PollutionUtils.addPollution(this.getBaseMetaTileEntity(), 10 * this.getPollution()); - } - } - } - } - - if (aBaseMetaTileEntity.isServerSide()) { - aBaseMetaTileEntity.setActive(aBaseMetaTileEntity.isAllowedToWork() && aBaseMetaTileEntity - .getUniversalEnergyStored() >= this.maxEUOutput() + this.getMinimumStoredEU()); - }*/ - - - - - if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.isAllowedToWork() && ((aTick % 10) == 0)) { - if (this.mFluid == null) { - if (aBaseMetaTileEntity.getUniversalEnergyStored() < (this.maxEUOutput() + this.getMinimumStoredEU())) { - this.mInventory[this.getStackDisplaySlot()] = null; - } else { - if (this.mInventory[this.getStackDisplaySlot()] == null) { - this.mInventory[this.getStackDisplaySlot()] = new ItemStack(Blocks.fire, 1); - } - this.mInventory[this.getStackDisplaySlot()].setStackDisplayName("Generating: " + (aBaseMetaTileEntity.getUniversalEnergyStored() - this.getMinimumStoredEU()) + " EU"); - } - } else { - final int tFuelValue = this.getFuelValue(this.mFluid), tConsumed = this.consumedFluidPerOperation(this.mFluid); - if ((tFuelValue > 0) && (tConsumed > 0) && (this.mFluid.amount >= tConsumed)) { - final long tFluidAmountToUse = Math.min(this.mFluid.amount / tConsumed, (((this.maxEUOutput() * 20) + this.getMinimumStoredEU()) - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue); - if ((tFluidAmountToUse > 0) && aBaseMetaTileEntity.increaseStoredEnergyUnits(tFluidAmountToUse * tFuelValue, true)){ - int aSafeFloor = (int) Math.max(((tFluidAmountToUse * tConsumed)/3), 1); - this.mFluid.amount -= (int) aSafeFloor; - PollutionUtils.addPollution(getBaseMetaTileEntity(), 10 * getPollution()); - } - } - } - if ((this.mInventory[this.getInputSlot()] != null) && (aBaseMetaTileEntity.getUniversalEnergyStored() < ((this.maxEUOutput() * 20) + this.getMinimumStoredEU())) && (GT_Utility.getFluidForFilledItem(this.mInventory[this.getInputSlot()], true) == null)) { - final int tFuelValue = this.getFuelValue(this.mInventory[this.getInputSlot()]); - if (tFuelValue > 0) { - final ItemStack tEmptyContainer = this.getEmptyContainer(this.mInventory[this.getInputSlot()]); - if (aBaseMetaTileEntity.addStackToSlot(this.getOutputSlot(), tEmptyContainer)) { - aBaseMetaTileEntity.increaseStoredEnergyUnits(tFuelValue, true); - aBaseMetaTileEntity.decrStackSize(this.getInputSlot(), 1); - PollutionUtils.addPollution(getBaseMetaTileEntity(), 10 * getPollution()); - } - } - } - } - - if (aBaseMetaTileEntity.isServerSide()) { - aBaseMetaTileEntity.setActive(aBaseMetaTileEntity.isAllowedToWork() && (aBaseMetaTileEntity.getUniversalEnergyStored() >= (this.maxEUOutput() + this.getMinimumStoredEU()))); - } - } - - public int getPollution() { - return MathUtils.randInt(pollMin, pollMax); - } - - public abstract GT_Recipe_Map getRecipes(); - - public abstract int getEfficiency(); - - public int consumedFluidPerOperation(final FluidStack aLiquid) { - return 1; - } - - public int getFuelValue(final FluidStack aLiquid) { - if ((aLiquid == null) || (this.getRecipes() == null)) { - return 0; - } - FluidStack tLiquid; - final Collection<GT_Recipe> tRecipeList = this.getRecipes().mRecipeList; - if (tRecipeList != null) { - //Logger.INFO("Step A"); - for (final GT_Recipe tFuel : tRecipeList) { - //Logger.INFO("Step B"); - if ((tLiquid = tFuel.mFluidInputs[0]) != null) { - //Logger.INFO("Step C"); - if (aLiquid.isFluidEqual(tLiquid)) { - //Logger.INFO("Found some fuel?"); - int aperOp = this.consumedFluidPerOperation(tLiquid); - int aConsume = (int) (((long) tFuel.mSpecialValue * this.getEfficiency() * aperOp) / 100); - //Logger.INFO("Fuel Value: "+tFuel.mSpecialValue); - //Logger.INFO("Efficiency: "+getEfficiency()); - //Logger.INFO("Consumed per op: "+aperOp); - //Logger.INFO("Consuming "+aConsume); - return aConsume; - } - } - } - } - //Logger.INFO("No Fuel Value | Valid? "+(aLiquid != null)); - return 0; - } - - public int getFuelValue(final ItemStack aStack) { - if (GT_Utility.isStackInvalid(aStack) || (this.getRecipes() == null)) { - return 0; - } - final GT_Recipe tFuel = this.getRecipes().findRecipe(this.getBaseMetaTileEntity(), false, Long.MAX_VALUE, null, aStack); - if (tFuel != null) { - return (int) ((tFuel.mSpecialValue * 1000L * this.getEfficiency()) / 100); - } - return 0; - } - - public ItemStack getEmptyContainer(final ItemStack aStack) { - if (GT_Utility.isStackInvalid(aStack) || (this.getRecipes() == null)) { - return null; - } - final GT_Recipe tFuel = this.getRecipes().findRecipe(this.getBaseMetaTileEntity(), false, Long.MAX_VALUE, null, aStack); - if (tFuel != null) { - return GT_Utility.copy(tFuel.getOutput(0)); - } - return GT_Utility.getContainerItem(aStack, true); - } - - @Override - public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { - return super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack) && ((this.getFuelValue(aStack) > 0) || (this.getFuelValue(GT_Utility.getFluidForFilledItem(aStack, true)) > 0)); - } - - @Override - public int getCapacity() { - return 32000; - } - - @Override - public int getTankPressure() { - return -100; - } + private boolean useFuel = false; + protected int pollMin, pollMax; + + public GregtechRocketFuelGeneratorBase( + final int aID, + final String aName, + final String aNameRegional, + final int aTier, + final String aDescription, + final ITexture... aTextures) { + super(aID, aName, aNameRegional, aTier, 3, aDescription, aTextures); + int pollMin = (int) (CORE.ConfigSwitches.baseMinPollutionPerSecondRocketFuelGenerator + * CORE.ConfigSwitches.pollutionReleasedByTierRocketFuelGenerator[mTier]); + int pollMax = (int) (CORE.ConfigSwitches.baseMaxPollutionPerSecondRocketFuelGenerator + * CORE.ConfigSwitches.pollutionReleasedByTierRocketFuelGenerator[mTier]); + } + + public GregtechRocketFuelGeneratorBase( + final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures) { + super(aName, aTier, 3, aDescription, aTextures); + int pollMin = (int) (CORE.ConfigSwitches.baseMinPollutionPerSecondRocketFuelGenerator + * CORE.ConfigSwitches.pollutionReleasedByTierRocketFuelGenerator[mTier]); + int pollMax = (int) (CORE.ConfigSwitches.baseMaxPollutionPerSecondRocketFuelGenerator + * CORE.ConfigSwitches.pollutionReleasedByTierRocketFuelGenerator[mTier]); + } + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + final ITexture[][][] rTextures = new ITexture[10][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = this.getFront(i); + rTextures[1][i + 1] = this.getBack(i); + rTextures[2][i + 1] = this.getBottom(i); + rTextures[3][i + 1] = this.getTop(i); + rTextures[4][i + 1] = this.getSides(i); + rTextures[5][i + 1] = this.getFrontActive(i); + rTextures[6][i + 1] = this.getBackActive(i); + rTextures[7][i + 1] = this.getBottomActive(i); + rTextures[8][i + 1] = this.getTopActive(i); + rTextures[9][i + 1] = this.getSidesActive(i); + } + return rTextures; + } + + @Override + public ITexture[] getTexture( + final IGregTechTileEntity aBaseMetaTileEntity, + final byte aSide, + final byte aFacing, + final byte aColorIndex, + final boolean aActive, + final boolean aRedstone) { + return this.mTextures[ + (aActive ? 5 : 0) + + (aSide == aFacing + ? 0 + : aSide == GT_Utility.getOppositeSide(aFacing) + ? 1 + : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][ + aColorIndex + 1]; + } + + @Override + public String[] getDescription() { + String aPollution = "Causes between " + pollMin + " and " + pollMax + " Pollution per second"; + return new String[] { + this.mDescription, "Fuel Efficiency: " + this.getEfficiency() + "%", aPollution, CORE.GT_Tooltip + }; + } + + @Override + public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + + public ITexture[] getFront(final byte aColor) { + return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]}; + } + + public ITexture[] getBack(final byte aColor) { + return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]}; + } + + public ITexture[] getBottom(final byte aColor) { + return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]}; + } + + public ITexture[] getTop(final byte aColor) { + return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]}; + } + + public ITexture[] getSides(final byte aColor) { + return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]}; + } + + public ITexture[] getFrontActive(final byte aColor) { + return this.getFront(aColor); + } + + public ITexture[] getBackActive(final byte aColor) { + return this.getBack(aColor); + } + + public ITexture[] getBottomActive(final byte aColor) { + return this.getBottom(aColor); + } + + public ITexture[] getTopActive(final byte aColor) { + return this.getTop(aColor); + } + + public ITexture[] getSidesActive(final byte aColor) { + return this.getSides(aColor); + } + + @Override + public boolean isFacingValid(final byte aSide) { + return aSide > 1; + } + + @Override + public boolean isSimpleMachine() { + return false; + } + + @Override + public boolean isValidSlot(final int aIndex) { + return aIndex < 2; + } + + @Override + public boolean isEnetOutput() { + return true; + } + + @Override + public boolean isOutputFacing(final byte aSide) { + return this.getBaseMetaTileEntity().getFrontFacing() == aSide; + } + + @Override + public boolean isAccessAllowed(final EntityPlayer aPlayer) { + return true; + } + + @Override + public long maxEUOutput() { + return V[this.mTier]; + } + + @Override + public long maxEUStore() { + return Math.max(this.getEUVar(), (V[this.mTier] * 500) + this.getMinimumStoredEU()); + } + + @Override + public boolean doesFillContainers() { + return false; + } + + @Override + public boolean doesEmptyContainers() { + return true; + } + + @Override + public boolean canTankBeFilled() { + return true; + } + + @Override + public boolean canTankBeEmptied() { + return false; + } + + @Override + public boolean displaysItemStack() { + return true; + } + + @Override + public boolean displaysStackSize() { + return false; + } + + @Override + public boolean isFluidInputAllowed(final FluidStack aFluid) { + return this.getFuelValue(aFluid) > 0; + } + + @Override + public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { + + // super.onPostTick(aBaseMetaTileEntity, aTick); + + /*if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.isAllowedToWork() && aTick % 10L == 0L) { + int tFuelValue; + if (this.mFluid == null) { + if (aBaseMetaTileEntity.getUniversalEnergyStored() < this.maxEUOutput() + this.getMinimumStoredEU()) { + this.mInventory[this.getStackDisplaySlot()] = null; + } else { + if (this.mInventory[this.getStackDisplaySlot()] == null) { + this.mInventory[this.getStackDisplaySlot()] = new ItemStack(Blocks.fire, 1); + } + + this.mInventory[this.getStackDisplaySlot()].setStackDisplayName("Generating: " + + (aBaseMetaTileEntity.getUniversalEnergyStored() - this.getMinimumStoredEU()) + " EU"); + } + } else { + tFuelValue = this.getFuelValue(this.mFluid); + int tConsumed = this.consumedFluidPerOperation(this.mFluid); + if (tFuelValue > 0 && tConsumed > 0 && this.mFluid.amount > tConsumed) { + long tFluidAmountToUse = Math.min((long) (this.mFluid.amount / tConsumed), + (this.maxEUStore() - aBaseMetaTileEntity.getUniversalEnergyStored()) / (long) tFuelValue); + if (tFluidAmountToUse > 0L && aBaseMetaTileEntity + .increaseStoredEnergyUnits(tFluidAmountToUse * (long) tFuelValue, true)) { + PollutionUtils.addPollution(this.getBaseMetaTileEntity(), 10 * this.getPollution()); + this.mFluid.amount = (int) ((long) this.mFluid.amount - tFluidAmountToUse * (long) tConsumed); + } + } + } + + if (this.mInventory[this.getInputSlot()] != null + && aBaseMetaTileEntity.getUniversalEnergyStored() < this.maxEUOutput() * 20L + + this.getMinimumStoredEU() + && GT_Utility.getFluidForFilledItem(this.mInventory[this.getInputSlot()], true) == null) { + tFuelValue = this.getFuelValue(this.mInventory[this.getInputSlot()]); + if (tFuelValue > 0) { + ItemStack tEmptyContainer = this.getEmptyContainer(this.mInventory[this.getInputSlot()]); + if (aBaseMetaTileEntity.addStackToSlot(this.getOutputSlot(), tEmptyContainer)) { + aBaseMetaTileEntity.increaseStoredEnergyUnits((long) tFuelValue, true); + aBaseMetaTileEntity.decrStackSize(this.getInputSlot(), 1); + PollutionUtils.addPollution(this.getBaseMetaTileEntity(), 10 * this.getPollution()); + } + } + } + } + + if (aBaseMetaTileEntity.isServerSide()) { + aBaseMetaTileEntity.setActive(aBaseMetaTileEntity.isAllowedToWork() && aBaseMetaTileEntity + .getUniversalEnergyStored() >= this.maxEUOutput() + this.getMinimumStoredEU()); + }*/ + + if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.isAllowedToWork() && ((aTick % 10) == 0)) { + if (this.mFluid == null) { + if (aBaseMetaTileEntity.getUniversalEnergyStored() < (this.maxEUOutput() + this.getMinimumStoredEU())) { + this.mInventory[this.getStackDisplaySlot()] = null; + } else { + if (this.mInventory[this.getStackDisplaySlot()] == null) { + this.mInventory[this.getStackDisplaySlot()] = new ItemStack(Blocks.fire, 1); + } + this.mInventory[this.getStackDisplaySlot()].setStackDisplayName("Generating: " + + (aBaseMetaTileEntity.getUniversalEnergyStored() - this.getMinimumStoredEU()) + " EU"); + } + } else { + final int tFuelValue = this.getFuelValue(this.mFluid), + tConsumed = this.consumedFluidPerOperation(this.mFluid); + if ((tFuelValue > 0) && (tConsumed > 0) && (this.mFluid.amount >= tConsumed)) { + final long tFluidAmountToUse = Math.min( + this.mFluid.amount / tConsumed, + (((this.maxEUOutput() * 20) + this.getMinimumStoredEU()) + - aBaseMetaTileEntity.getUniversalEnergyStored()) + / tFuelValue); + if ((tFluidAmountToUse > 0) + && aBaseMetaTileEntity.increaseStoredEnergyUnits(tFluidAmountToUse * tFuelValue, true)) { + int aSafeFloor = (int) Math.max(((tFluidAmountToUse * tConsumed) / 3), 1); + this.mFluid.amount -= (int) aSafeFloor; + PollutionUtils.addPollution(getBaseMetaTileEntity(), 10 * getPollution()); + } + } + } + if ((this.mInventory[this.getInputSlot()] != null) + && (aBaseMetaTileEntity.getUniversalEnergyStored() + < ((this.maxEUOutput() * 20) + this.getMinimumStoredEU())) + && (GT_Utility.getFluidForFilledItem(this.mInventory[this.getInputSlot()], true) == null)) { + final int tFuelValue = this.getFuelValue(this.mInventory[this.getInputSlot()]); + if (tFuelValue > 0) { + final ItemStack tEmptyContainer = this.getEmptyContainer(this.mInventory[this.getInputSlot()]); + if (aBaseMetaTileEntity.addStackToSlot(this.getOutputSlot(), tEmptyContainer)) { + aBaseMetaTileEntity.increaseStoredEnergyUnits(tFuelValue, true); + aBaseMetaTileEntity.decrStackSize(this.getInputSlot(), 1); + PollutionUtils.addPollution(getBaseMetaTileEntity(), 10 * getPollution()); + } + } + } + } + + if (aBaseMetaTileEntity.isServerSide()) { + aBaseMetaTileEntity.setActive(aBaseMetaTileEntity.isAllowedToWork() + && (aBaseMetaTileEntity.getUniversalEnergyStored() + >= (this.maxEUOutput() + this.getMinimumStoredEU()))); + } + } + + public int getPollution() { + return MathUtils.randInt(pollMin, pollMax); + } + + public abstract GT_Recipe_Map getRecipes(); + + public abstract int getEfficiency(); + + public int consumedFluidPerOperation(final FluidStack aLiquid) { + return 1; + } + + public int getFuelValue(final FluidStack aLiquid) { + if ((aLiquid == null) || (this.getRecipes() == null)) { + return 0; + } + FluidStack tLiquid; + final Collection<GT_Recipe> tRecipeList = this.getRecipes().mRecipeList; + if (tRecipeList != null) { + // Logger.INFO("Step A"); + for (final GT_Recipe tFuel : tRecipeList) { + // Logger.INFO("Step B"); + if ((tLiquid = tFuel.mFluidInputs[0]) != null) { + // Logger.INFO("Step C"); + if (aLiquid.isFluidEqual(tLiquid)) { + // Logger.INFO("Found some fuel?"); + int aperOp = this.consumedFluidPerOperation(tLiquid); + int aConsume = (int) (((long) tFuel.mSpecialValue * this.getEfficiency() * aperOp) / 100); + // Logger.INFO("Fuel Value: "+tFuel.mSpecialValue); + // Logger.INFO("Efficiency: "+getEfficiency()); + // Logger.INFO("Consumed per op: "+aperOp); + // Logger.INFO("Consuming "+aConsume); + return aConsume; + } + } + } + } + // Logger.INFO("No Fuel Value | Valid? "+(aLiquid != null)); + return 0; + } + + public int getFuelValue(final ItemStack aStack) { + if (GT_Utility.isStackInvalid(aStack) || (this.getRecipes() == null)) { + return 0; + } + final GT_Recipe tFuel = + this.getRecipes().findRecipe(this.getBaseMetaTileEntity(), false, Long.MAX_VALUE, null, aStack); + if (tFuel != null) { + return (int) ((tFuel.mSpecialValue * 1000L * this.getEfficiency()) / 100); + } + return 0; + } + + public ItemStack getEmptyContainer(final ItemStack aStack) { + if (GT_Utility.isStackInvalid(aStack) || (this.getRecipes() == null)) { + return null; + } + final GT_Recipe tFuel = + this.getRecipes().findRecipe(this.getBaseMetaTileEntity(), false, Long.MAX_VALUE, null, aStack); + if (tFuel != null) { + return GT_Utility.copy(tFuel.getOutput(0)); + } + return GT_Utility.getContainerItem(aStack, true); + } + + @Override + public boolean allowPutStack( + final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack) + && ((this.getFuelValue(aStack) > 0) + || (this.getFuelValue(GT_Utility.getFluidForFilledItem(aStack, true)) > 0)); + } + + @Override + public int getCapacity() { + return 32000; + } + + @Override + public int getTankPressure() { + return -100; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/machines/GregtechMetaSafeBlockBase.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/machines/GregtechMetaSafeBlockBase.java index 34b3e86c70..a76ed88a17 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/machines/GregtechMetaSafeBlockBase.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/machines/GregtechMetaSafeBlockBase.java @@ -2,290 +2,310 @@ package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.machine import static gregtech.api.enums.GT_Values.V; -import java.util.UUID; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; - import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; 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_Utility; - import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.util.minecraft.PlayerUtils; import gtPlusPlus.core.util.player.PlayerCache; +import java.util.UUID; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; public abstract class GregtechMetaSafeBlockBase extends GT_MetaTileEntity_TieredMachineBlock { - public boolean bOutput = false, bRedstoneIfFull = false, bInvert = false, bUnbreakable = false; - public int mSuccess = 0, mTargetStackSize = 0; - public UUID ownerUUID; - //UnbreakableBlockManager Xasda = new UnbreakableBlockManager(); - private boolean value_last = false, value_current = false; - - public GregtechMetaSafeBlockBase(final int aID, final String aName, final String aNameRegional, final int aTier, final int aInvSlotCount, final String aDescription) { - super(aID, aName, aNameRegional, aTier, aInvSlotCount, aDescription); - } - - public GregtechMetaSafeBlockBase(final String aName, final int aTier, final int aInvSlotCount, final String aDescription, final ITexture[][][] aTextures) { - super(aName, aTier, aInvSlotCount, aDescription, aTextures); - } - - @Override - public ITexture[][][] getTextureSet(final ITexture[] aTextures) { - final ITexture[][][] rTextures = new ITexture[6][17][]; - final ITexture tIcon = this.getOverlayIcon(), tOut = new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_QCHEST), tUp = new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_VENT); - for (byte i = -1; i < 16; i++) { - rTextures[0][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][i + 1], tUp, tIcon}; //Back - rTextures[1][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][i + 1], tIcon}; // Right, Strangely The top side as well when facing East? - rTextures[2][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][i + 1], tIcon}; // Top And Bottom, When Facing South (What the hell?) - rTextures[3][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][i + 1], tIcon}; // Left, Top if facing West and Bottom if facing east? - rTextures[4][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][i + 1], tIcon}; // Top and Bottom when Facing North.. - rTextures[5][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][i + 1], tOut}; // Front - } - return rTextures; - - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { - if (aSide == aFacing) { - return this.mTextures[5][aColorIndex + 1]; - } - if (GT_Utility.getOppositeSide(aSide) == aFacing) { - return this.mTextures[0][aColorIndex + 1]; - } - switch (aFacing) { - case 0: - return this.mTextures[4][aColorIndex + 1]; - case 1: - return this.mTextures[2][aColorIndex + 1]; - case 2: - switch (aSide) { - case 0: - return this.mTextures[2][aColorIndex + 1]; - case 1: - return this.mTextures[2][aColorIndex + 1]; - case 4: - return this.mTextures[1][aColorIndex + 1]; - case 5: - return this.mTextures[3][aColorIndex + 1]; - } - case 3: - switch (aSide) { - case 0: - return this.mTextures[4][aColorIndex + 1]; - case 1: - return this.mTextures[4][aColorIndex + 1]; - case 4: - return this.mTextures[3][aColorIndex + 1]; - case 5: - return this.mTextures[1][aColorIndex + 1]; - } - case 4: - switch (aSide) { - case 0: - return this.mTextures[3][aColorIndex + 1]; - case 1: - return this.mTextures[1][aColorIndex + 1]; - case 2: - return this.mTextures[3][aColorIndex + 1]; - case 3: - return this.mTextures[1][aColorIndex + 1]; - } - case 5: - switch (aSide) { - case 0: - return this.mTextures[1][aColorIndex + 1]; - case 1: - return this.mTextures[3][aColorIndex + 1]; - case 2: - return this.mTextures[1][aColorIndex + 1]; - case 3: - return this.mTextures[3][aColorIndex + 1]; - } - } - return this.mTextures[5][aColorIndex + 1]; - } - - @Override - public boolean isSimpleMachine() { - return false; - } - - @Override - public boolean isValidSlot(final int aIndex) { - return aIndex < (this.mInventory.length - 1); - } - - @Override - public boolean isFacingValid(final byte aFacing) { - return true; - } - - @Override - public boolean isEnetInput() { - return true; - } - - @Override - public boolean isEnetOutput() { - return true; - } - - @Override - public boolean isInputFacing(final byte aSide) { - return !this.isOutputFacing(aSide); - } - - @Override - public boolean isOutputFacing(final byte aSide) { - return this.getBaseMetaTileEntity().getBackFacing() == aSide; - } - - @Override - public boolean isTeleporterCompatible() { - return false; - } - - @Override - public long getMinimumStoredEU() { - return 512; - } - - @Override - public long maxEUStore() { - return 512 + (V[this.mTier] * 50); - } - - @Override - public long maxEUInput() { - return V[this.mTier]; - } - - @Override - public long maxEUOutput() { - return this.bOutput ? V[this.mTier] : 0; - } - - @Override - public long maxAmperesIn() { - return 1; - } - - @Override - public long maxAmperesOut() { - return 1; - } - - @Override - public boolean isAccessAllowed(final EntityPlayer aPlayer) { - return true; - } - - public abstract ITexture getOverlayIcon(); - - @Override - public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { - - if (aBaseMetaTileEntity.isClientSide()) { - //Utils.LOG_WARNING("Clicky Clicky."); - return true; - - } - if (aPlayer != null) { - final UUID tempUUID = aPlayer.getUniqueID(); - /*if (!aPlayer.worldObj.isRemote){ - //PlayerCache.appendParamChanges(aPlayer.getDisplayName(), aPlayer.getUniqueID().toString()); - }*/ - //Utils.LOG_INFO("test"); - if (this.ownerUUID == null){ - Logger.INFO("No owner yet for this block."); - } - else { - //Utils.LOG_INFO("test"); - Logger.INFO("Current Owner: "+PlayerCache.lookupPlayerByUUID(this.ownerUUID)+" - UUID: "+this.ownerUUID); - } - Logger.WARNING("Is ownerUUID Null"); - if (this.ownerUUID == null){ - Logger.WARNING("OwnerUUID is Null, let's set it."); - Logger.WARNING("Accessing Players UUID is: "+tempUUID); - this.ownerUUID = tempUUID; - //Utils.messagePlayer(aPlayer, "Owner of this safe, now set. Try accessing it again."); - Logger.WARNING("Block Owner is now set to: "+this.ownerUUID); - } - Logger.WARNING("No, it is not."); - Logger.WARNING("Checking ownerUUID."); - if (this.ownerUUID != null){ - Logger.WARNING("ownerUUID != Null, if accessor == owner."); - Logger.WARNING("Accessing is: "+PlayerCache.lookupPlayerByUUID(tempUUID)); - if (this.ownerUUID.equals(tempUUID)){ - Logger.WARNING("Owner's UUID: "+this.ownerUUID); - aBaseMetaTileEntity.openGUI(aPlayer); - //Utils.LOG_WARNING("GUI should now be open for you sir."); - } - else { - PlayerUtils.messagePlayer(aPlayer, "Access Denied, This does not belong to you."); - PlayerUtils.messagePlayer(aPlayer, "it is owned by: "+PlayerCache.lookupPlayerByUUID(this.ownerUUID)); - Logger.WARNING("Expecting Player : "+PlayerCache.lookupPlayerByUUID(this.ownerUUID)); - Logger.ERROR("Access Denied."); - return true; - } - - } - - /*else { - Utils.LOG_ERROR("This is NOT good. Tell Draknyte1 your safe broke."); - }*/ - /*Utils.LOG_WARNING("Clicky Clicky."); - Utils.messagePlayer(aPlayer, "Owner of this safe, now set."); - aBaseMetaTileEntity.openGUI(aPlayer); */ - - } - return true; - } - - @Override - public void saveNBTData(final NBTTagCompound aNBT) { - aNBT.setBoolean("bUnbreakable", this.bUnbreakable); - aNBT.setBoolean("bOutput", this.bOutput); - aNBT.setBoolean("bRedstoneIfFull", this.bRedstoneIfFull); - aNBT.setInteger("mTargetStackSize", this.mTargetStackSize); - if (this.ownerUUID != null) { - aNBT.setString("ownerUUID", this.ownerUUID.toString()); - } - } - - @Override - public void loadNBTData(final NBTTagCompound aNBT) { - this.bUnbreakable = aNBT.getBoolean("bUnbreakable"); - this.bOutput = aNBT.getBoolean("bOutput"); - this.bRedstoneIfFull = aNBT.getBoolean("bRedstoneIfFull"); - this.mTargetStackSize = aNBT.getInteger("mTargetStackSize"); - if (aNBT.hasKey("ownerUUID")) { - this.ownerUUID = UUID.fromString(aNBT.getString("ownerUUID")); - } - } - - @Override - public void setItemNBT(final NBTTagCompound aNBT) { - super.setItemNBT(aNBT); - if (this.mTargetStackSize > 0) { - aNBT.setInteger("mTargetStackSize", this.mTargetStackSize); - } - } - - - @Override - public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { - return false; - } - - @Override - public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { - return aSide != aBaseMetaTileEntity.getBackFacing(); - } -}
\ No newline at end of file + public boolean bOutput = false, bRedstoneIfFull = false, bInvert = false, bUnbreakable = false; + public int mSuccess = 0, mTargetStackSize = 0; + public UUID ownerUUID; + // UnbreakableBlockManager Xasda = new UnbreakableBlockManager(); + private boolean value_last = false, value_current = false; + + public GregtechMetaSafeBlockBase( + final int aID, + final String aName, + final String aNameRegional, + final int aTier, + final int aInvSlotCount, + final String aDescription) { + super(aID, aName, aNameRegional, aTier, aInvSlotCount, aDescription); + } + + public GregtechMetaSafeBlockBase( + final String aName, + final int aTier, + final int aInvSlotCount, + final String aDescription, + final ITexture[][][] aTextures) { + super(aName, aTier, aInvSlotCount, aDescription, aTextures); + } + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + final ITexture[][][] rTextures = new ITexture[6][17][]; + final ITexture tIcon = this.getOverlayIcon(), + tOut = new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_QCHEST), + tUp = new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_VENT); + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = + new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[this.mTier][i + 1], tUp, tIcon}; // Back + rTextures[1][i + 1] = new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[this.mTier][i + 1], tIcon + }; // Right, Strangely The top side as well when facing East? + rTextures[2][i + 1] = new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[this.mTier][i + 1], tIcon + }; // Top And Bottom, When Facing South (What the hell?) + rTextures[3][i + 1] = new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[this.mTier][i + 1], tIcon + }; // Left, Top if facing West and Bottom if facing east? + rTextures[4][i + 1] = new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[this.mTier][i + 1], tIcon + }; // Top and Bottom when Facing North.. + rTextures[5][i + 1] = + new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[this.mTier][i + 1], tOut}; // Front + } + return rTextures; + } + + @Override + public ITexture[] getTexture( + final IGregTechTileEntity aBaseMetaTileEntity, + final byte aSide, + final byte aFacing, + final byte aColorIndex, + final boolean aActive, + final boolean aRedstone) { + if (aSide == aFacing) { + return this.mTextures[5][aColorIndex + 1]; + } + if (GT_Utility.getOppositeSide(aSide) == aFacing) { + return this.mTextures[0][aColorIndex + 1]; + } + switch (aFacing) { + case 0: + return this.mTextures[4][aColorIndex + 1]; + case 1: + return this.mTextures[2][aColorIndex + 1]; + case 2: + switch (aSide) { + case 0: + return this.mTextures[2][aColorIndex + 1]; + case 1: + return this.mTextures[2][aColorIndex + 1]; + case 4: + return this.mTextures[1][aColorIndex + 1]; + case 5: + return this.mTextures[3][aColorIndex + 1]; + } + case 3: + switch (aSide) { + case 0: + return this.mTextures[4][aColorIndex + 1]; + case 1: + return this.mTextures[4][aColorIndex + 1]; + case 4: + return this.mTextures[3][aColorIndex + 1]; + case 5: + return this.mTextures[1][aColorIndex + 1]; + } + case 4: + switch (aSide) { + case 0: + return this.mTextures[3][aColorIndex + 1]; + case 1: + return this.mTextures[1][aColorIndex + 1]; + case 2: + return this.mTextures[3][aColorIndex + 1]; + case 3: + return this.mTextures[1][aColorIndex + 1]; + } + case 5: + switch (aSide) { + case 0: + return this.mTextures[1][aColorIndex + 1]; + case 1: + return this.mTextures[3][aColorIndex + 1]; + case 2: + return this.mTextures[1][aColorIndex + 1]; + case 3: + return this.mTextures[3][aColorIndex + 1]; + } + } + return this.mTextures[5][aColorIndex + 1]; + } + + @Override + public boolean isSimpleMachine() { + return false; + } + + @Override + public boolean isValidSlot(final int aIndex) { + return aIndex < (this.mInventory.length - 1); + } + + @Override + public boolean isFacingValid(final byte aFacing) { + return true; + } + + @Override + public boolean isEnetInput() { + return true; + } + + @Override + public boolean isEnetOutput() { + return true; + } + + @Override + public boolean isInputFacing(final byte aSide) { + return !this.isOutputFacing(aSide); + } + + @Override + public boolean isOutputFacing(final byte aSide) { + return this.getBaseMetaTileEntity().getBackFacing() == aSide; + } + + @Override + public boolean isTeleporterCompatible() { + return false; + } + + @Override + public long getMinimumStoredEU() { + return 512; + } + + @Override + public long maxEUStore() { + return 512 + (V[this.mTier] * 50); + } + + @Override + public long maxEUInput() { + return V[this.mTier]; + } + + @Override + public long maxEUOutput() { + return this.bOutput ? V[this.mTier] : 0; + } + + @Override + public long maxAmperesIn() { + return 1; + } + + @Override + public long maxAmperesOut() { + return 1; + } + + @Override + public boolean isAccessAllowed(final EntityPlayer aPlayer) { + return true; + } + + public abstract ITexture getOverlayIcon(); + + @Override + public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { + + if (aBaseMetaTileEntity.isClientSide()) { + // Utils.LOG_WARNING("Clicky Clicky."); + return true; + } + if (aPlayer != null) { + final UUID tempUUID = aPlayer.getUniqueID(); + /*if (!aPlayer.worldObj.isRemote){ + //PlayerCache.appendParamChanges(aPlayer.getDisplayName(), aPlayer.getUniqueID().toString()); + }*/ + // Utils.LOG_INFO("test"); + if (this.ownerUUID == null) { + Logger.INFO("No owner yet for this block."); + } else { + // Utils.LOG_INFO("test"); + Logger.INFO("Current Owner: " + PlayerCache.lookupPlayerByUUID(this.ownerUUID) + " - UUID: " + + this.ownerUUID); + } + Logger.WARNING("Is ownerUUID Null"); + if (this.ownerUUID == null) { + Logger.WARNING("OwnerUUID is Null, let's set it."); + Logger.WARNING("Accessing Players UUID is: " + tempUUID); + this.ownerUUID = tempUUID; + // Utils.messagePlayer(aPlayer, "Owner of this safe, now set. Try accessing it again."); + Logger.WARNING("Block Owner is now set to: " + this.ownerUUID); + } + Logger.WARNING("No, it is not."); + Logger.WARNING("Checking ownerUUID."); + if (this.ownerUUID != null) { + Logger.WARNING("ownerUUID != Null, if accessor == owner."); + Logger.WARNING("Accessing is: " + PlayerCache.lookupPlayerByUUID(tempUUID)); + if (this.ownerUUID.equals(tempUUID)) { + Logger.WARNING("Owner's UUID: " + this.ownerUUID); + aBaseMetaTileEntity.openGUI(aPlayer); + // Utils.LOG_WARNING("GUI should now be open for you sir."); + } else { + PlayerUtils.messagePlayer(aPlayer, "Access Denied, This does not belong to you."); + PlayerUtils.messagePlayer( + aPlayer, "it is owned by: " + PlayerCache.lookupPlayerByUUID(this.ownerUUID)); + Logger.WARNING("Expecting Player : " + PlayerCache.lookupPlayerByUUID(this.ownerUUID)); + Logger.ERROR("Access Denied."); + return true; + } + } + + /*else { + Utils.LOG_ERROR("This is NOT good. Tell Draknyte1 your safe broke."); + }*/ + /*Utils.LOG_WARNING("Clicky Clicky."); + Utils.messagePlayer(aPlayer, "Owner of this safe, now set."); + aBaseMetaTileEntity.openGUI(aPlayer); */ + + } + return true; + } + + @Override + public void saveNBTData(final NBTTagCompound aNBT) { + aNBT.setBoolean("bUnbreakable", this.bUnbreakable); + aNBT.setBoolean("bOutput", this.bOutput); + aNBT.setBoolean("bRedstoneIfFull", this.bRedstoneIfFull); + aNBT.setInteger("mTargetStackSize", this.mTargetStackSize); + if (this.ownerUUID != null) { + aNBT.setString("ownerUUID", this.ownerUUID.toString()); + } + } + + @Override + public void loadNBTData(final NBTTagCompound aNBT) { + this.bUnbreakable = aNBT.getBoolean("bUnbreakable"); + this.bOutput = aNBT.getBoolean("bOutput"); + this.bRedstoneIfFull = aNBT.getBoolean("bRedstoneIfFull"); + this.mTargetStackSize = aNBT.getInteger("mTargetStackSize"); + if (aNBT.hasKey("ownerUUID")) { + this.ownerUUID = UUID.fromString(aNBT.getString("ownerUUID")); + } + } + + @Override + public void setItemNBT(final NBTTagCompound aNBT) { + super.setItemNBT(aNBT); + if (this.mTargetStackSize > 0) { + aNBT.setInteger("mTargetStackSize", this.mTargetStackSize); + } + } + + @Override + public boolean allowPullStack( + final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack( + final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return aSide != aBaseMetaTileEntity.getBackFacing(); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/machines/GregtechMetaTreeFarmerBase.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/machines/GregtechMetaTreeFarmerBase.java index df838f012a..39d61acebc 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/machines/GregtechMetaTreeFarmerBase.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/machines/GregtechMetaTreeFarmerBase.java @@ -1,176 +1,199 @@ package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.machines; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; - import gregtech.api.interfaces.ITexture; 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_Utility; - import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; public abstract class GregtechMetaTreeFarmerBase extends GT_MetaTileEntity_TieredMachineBlock { - public boolean bOutput = false, bRedstoneIfFull = false, bInvert = false, bUnbreakable = false; - public int mSuccess = 0, mTargetStackSize = 0; - - public GregtechMetaTreeFarmerBase(final int aID, final String aName, final String aNameRegional, final int aTier, final int aInvSlotCount, final String aDescription) { - super(aID, aName, aNameRegional, aTier, aInvSlotCount, aDescription); - } - - public GregtechMetaTreeFarmerBase(final String aName, final int aTier, final int aInvSlotCount, final String aDescription, final ITexture[][][] aTextures) { - super(aName, aTier, aInvSlotCount, aDescription, aTextures); - } - - @Override - public ITexture[][][] getTextureSet(final ITexture[] aTextures) { - final ITexture[][][] rTextures = new ITexture[10][17][]; - for (byte i = -1; i < 16; i++) { - rTextures[0][i + 1] = this.getFront(i); - rTextures[1][i + 1] = this.getBack(i); - rTextures[2][i + 1] = this.getBottom(i); - rTextures[3][i + 1] = this.getTop(i); - rTextures[4][i + 1] = this.getSides(i); - rTextures[5][i + 1] = this.getFrontActive(i); - rTextures[6][i + 1] = this.getBackActive(i); - rTextures[7][i + 1] = this.getBottomActive(i); - rTextures[8][i + 1] = this.getTopActive(i); - rTextures[9][i + 1] = this.getSidesActive(i); - } - return rTextures; - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { - return this.mTextures[(aActive ? 5 : 0) + (aSide == aFacing ? 0 : aSide == GT_Utility.getOppositeSide(aFacing) ? 1 : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][aColorIndex + 1]; - } - - @Override - public boolean isSimpleMachine() { - return false; - } - - @Override - public boolean isValidSlot(final int aIndex) { - return false; - } - - @Override - public boolean isFacingValid(final byte aFacing) { - return true; - } - - @Override - public boolean isEnetInput() { - return false; - } - - @Override - public boolean isEnetOutput() { - return false; - } - - @Override - public boolean isInputFacing(final byte aSide) { - return !this.isOutputFacing(aSide); - } - - @Override - public boolean isOutputFacing(final byte aSide) { - return this.getBaseMetaTileEntity().getBackFacing() == aSide; - } - - @Override - public boolean isTeleporterCompatible() { - return false; - } - - @Override - public long getMinimumStoredEU() { - return 0; - } - - @Override - public long maxEUStore() { - return 0; - } - - @Override - public long maxEUInput() { - return 0; - } - - @Override - public long maxEUOutput() { - return 0; - } - - @Override - public long maxAmperesIn() { - return 0; - } - - @Override - public long maxAmperesOut() { - return 0; - } - - @Override - public boolean isAccessAllowed(final EntityPlayer aPlayer) { - return false; - } - - public abstract ITexture getOverlayIcon(); - - - @Override - public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { - return false; - } - - @Override - public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { - return false; - } - - public ITexture[] getFront(final byte aColor) { - return new ITexture[]{new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Farm_Manager)}; - } - - public ITexture[] getBack(final byte aColor) { - return new ITexture[]{new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Farm_Manager)}; - } - - public ITexture[] getBottom(final byte aColor) { - return new ITexture[]{new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Acacia_Log)}; - } - - public ITexture[] getTop(final byte aColor) { - return new ITexture[]{new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Podzol)}; - } - - public ITexture[] getSides(final byte aColor) { - return new ITexture[]{new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Farm_Manager)}; - } - - public ITexture[] getFrontActive(final byte aColor) { - return this.getFront(aColor); - } - - public ITexture[] getBackActive(final byte aColor) { - return this.getBack(aColor); - } - - public ITexture[] getBottomActive(final byte aColor) { - return this.getBottom(aColor); - } - - public ITexture[] getTopActive(final byte aColor) { - return this.getTop(aColor); - } - - public ITexture[] getSidesActive(final byte aColor) { - return this.getSides(aColor); - } -}
\ No newline at end of file + public boolean bOutput = false, bRedstoneIfFull = false, bInvert = false, bUnbreakable = false; + public int mSuccess = 0, mTargetStackSize = 0; + + public GregtechMetaTreeFarmerBase( + final int aID, + final String aName, + final String aNameRegional, + final int aTier, + final int aInvSlotCount, + final String aDescription) { + super(aID, aName, aNameRegional, aTier, aInvSlotCount, aDescription); + } + + public GregtechMetaTreeFarmerBase( + final String aName, + final int aTier, + final int aInvSlotCount, + final String aDescription, + final ITexture[][][] aTextures) { + super(aName, aTier, aInvSlotCount, aDescription, aTextures); + } + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + final ITexture[][][] rTextures = new ITexture[10][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = this.getFront(i); + rTextures[1][i + 1] = this.getBack(i); + rTextures[2][i + 1] = this.getBottom(i); + rTextures[3][i + 1] = this.getTop(i); + rTextures[4][i + 1] = this.getSides(i); + rTextures[5][i + 1] = this.getFrontActive(i); + rTextures[6][i + 1] = this.getBackActive(i); + rTextures[7][i + 1] = this.getBottomActive(i); + rTextures[8][i + 1] = this.getTopActive(i); + rTextures[9][i + 1] = this.getSidesActive(i); + } + return rTextures; + } + + @Override + public ITexture[] getTexture( + final IGregTechTileEntity aBaseMetaTileEntity, + final byte aSide, + final byte aFacing, + final byte aColorIndex, + final boolean aActive, + final boolean aRedstone) { + return this.mTextures[ + (aActive ? 5 : 0) + + (aSide == aFacing + ? 0 + : aSide == GT_Utility.getOppositeSide(aFacing) + ? 1 + : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][ + aColorIndex + 1]; + } + + @Override + public boolean isSimpleMachine() { + return false; + } + + @Override + public boolean isValidSlot(final int aIndex) { + return false; + } + + @Override + public boolean isFacingValid(final byte aFacing) { + return true; + } + + @Override + public boolean isEnetInput() { + return false; + } + + @Override + public boolean isEnetOutput() { + return false; + } + + @Override + public boolean isInputFacing(final byte aSide) { + return !this.isOutputFacing(aSide); + } + + @Override + public boolean isOutputFacing(final byte aSide) { + return this.getBaseMetaTileEntity().getBackFacing() == aSide; + } + + @Override + public boolean isTeleporterCompatible() { + return false; + } + + @Override + public long getMinimumStoredEU() { + return 0; + } + + @Override + public long maxEUStore() { + return 0; + } + + @Override + public long maxEUInput() { + return 0; + } + + @Override + public long maxEUOutput() { + return 0; + } + + @Override + public long maxAmperesIn() { + return 0; + } + + @Override + public long maxAmperesOut() { + return 0; + } + + @Override + public boolean isAccessAllowed(final EntityPlayer aPlayer) { + return false; + } + + public abstract ITexture getOverlayIcon(); + + @Override + public boolean allowPullStack( + final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack( + final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return false; + } + + public ITexture[] getFront(final byte aColor) { + return new ITexture[] {new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Farm_Manager)}; + } + + public ITexture[] getBack(final byte aColor) { + return new ITexture[] {new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Farm_Manager)}; + } + + public ITexture[] getBottom(final byte aColor) { + return new ITexture[] {new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Acacia_Log)}; + } + + public ITexture[] getTop(final byte aColor) { + return new ITexture[] {new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Podzol)}; + } + + public ITexture[] getSides(final byte aColor) { + return new ITexture[] {new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Farm_Manager)}; + } + + public ITexture[] getFrontActive(final byte aColor) { + return this.getFront(aColor); + } + + public ITexture[] getBackActive(final byte aColor) { + return this.getBack(aColor); + } + + public ITexture[] getBottomActive(final byte aColor) { + return this.getBottom(aColor); + } + + public ITexture[] getTopActive(final byte aColor) { + return this.getTop(aColor); + } + + public ITexture[] getSidesActive(final byte aColor) { + return this.getSides(aColor); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/nbthandlers/GT_MetaTileEntity_Hatch_Catalysts.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/nbthandlers/GT_MetaTileEntity_Hatch_Catalysts.java index 5e0918059d..46666114c1 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/nbthandlers/GT_MetaTileEntity_Hatch_Catalysts.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/nbthandlers/GT_MetaTileEntity_Hatch_Catalysts.java @@ -9,7 +9,7 @@ import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import net.minecraft.item.ItemStack; public class GT_MetaTileEntity_Hatch_Catalysts extends GT_MetaTileEntity_Hatch_NbtConsumable { - + public GT_MetaTileEntity_Hatch_Catalysts(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional, 0, 16, "Dedicated Catalyst Storage", false); } @@ -17,55 +17,53 @@ public class GT_MetaTileEntity_Hatch_Catalysts extends GT_MetaTileEntity_Hatch_N public GT_MetaTileEntity_Hatch_Catalysts(String aName, String aDescription, ITexture[][][] aTextures) { super(aName, 0, 16, aDescription, false, aTextures); } - + public GT_MetaTileEntity_Hatch_Catalysts(String aName, String[] aDescription, ITexture[][][] aTextures) { super(aName, 0, 16, aDescription[0], false, aTextures); } @Override public ITexture[] getTexturesActive(ITexture aBaseTexture) { - return new ITexture[]{aBaseTexture, new GT_RenderedTexture(TexturesGtBlock.Overlay_Bus_Catalyst)}; + return new ITexture[] {aBaseTexture, new GT_RenderedTexture(TexturesGtBlock.Overlay_Bus_Catalyst)}; } @Override public ITexture[] getTexturesInactive(ITexture aBaseTexture) { - return new ITexture[]{aBaseTexture, new GT_RenderedTexture(TexturesGtBlock.Overlay_Bus_Catalyst)}; + return new ITexture[] {aBaseTexture, new GT_RenderedTexture(TexturesGtBlock.Overlay_Bus_Catalyst)}; + } + + @Override + public String[] getDescription() { + return new String[] {this.mDescription, CORE.GT_Tooltip}; } - - @Override - public String[] getDescription() { - return new String[]{ - this.mDescription, - CORE.GT_Tooltip}; - } @Override public boolean isFacingValid(byte aFacing) { return true; } - @Override - public Class<? extends GT_MetaTileEntity_Hatch_NbtConsumable> getHatchEntityClass() { - return GT_MetaTileEntity_Hatch_Catalysts.class; - } + @Override + public Class<? extends GT_MetaTileEntity_Hatch_NbtConsumable> getHatchEntityClass() { + return GT_MetaTileEntity_Hatch_Catalysts.class; + } - @Override - public String getNameGUI() { - return "Catalyst Container"; - } + @Override + public String getNameGUI() { + return "Catalyst Container"; + } - @Override - public AutoMap<ItemStack> getItemsValidForUsageSlots() { - return new AutoMap<ItemStack>(); - } + @Override + public AutoMap<ItemStack> getItemsValidForUsageSlots() { + return new AutoMap<ItemStack>(); + } - @Override - public boolean isItemValidForUsageSlot(ItemStack aStack) { - return ItemUtils.isCatalyst(aStack); - } + @Override + public boolean isItemValidForUsageSlot(ItemStack aStack) { + return ItemUtils.isCatalyst(aStack); + } - @Override - public int getInputSlotCount() { - return 16; - } + @Override + public int getInputSlotCount() { + return 16; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/nbthandlers/GT_MetaTileEntity_Hatch_MillingBalls.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/nbthandlers/GT_MetaTileEntity_Hatch_MillingBalls.java index 0f10272ad7..265088a9e0 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/nbthandlers/GT_MetaTileEntity_Hatch_MillingBalls.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/nbthandlers/GT_MetaTileEntity_Hatch_MillingBalls.java @@ -9,7 +9,7 @@ import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import net.minecraft.item.ItemStack; public class GT_MetaTileEntity_Hatch_MillingBalls extends GT_MetaTileEntity_Hatch_NbtConsumable { - + public GT_MetaTileEntity_Hatch_MillingBalls(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional, 6, 4, "Dedicated Milling Ball Storage", false); } @@ -17,55 +17,53 @@ public class GT_MetaTileEntity_Hatch_MillingBalls extends GT_MetaTileEntity_Hatc public GT_MetaTileEntity_Hatch_MillingBalls(String aName, String aDescription, ITexture[][][] aTextures) { super(aName, 6, 4, aDescription, false, aTextures); } - + public GT_MetaTileEntity_Hatch_MillingBalls(String aName, String[] aDescription, ITexture[][][] aTextures) { super(aName, 6, 4, aDescription[0], false, aTextures); } @Override public ITexture[] getTexturesActive(ITexture aBaseTexture) { - return new ITexture[]{aBaseTexture, new GT_RenderedTexture(TexturesGtBlock.Overlay_Bus_Milling_Balls)}; + return new ITexture[] {aBaseTexture, new GT_RenderedTexture(TexturesGtBlock.Overlay_Bus_Milling_Balls)}; } @Override public ITexture[] getTexturesInactive(ITexture aBaseTexture) { - return new ITexture[]{aBaseTexture, new GT_RenderedTexture(TexturesGtBlock.Overlay_Bus_Milling_Balls)}; + return new ITexture[] {aBaseTexture, new GT_RenderedTexture(TexturesGtBlock.Overlay_Bus_Milling_Balls)}; + } + + @Override + public String[] getDescription() { + return new String[] {this.mDescription, CORE.GT_Tooltip}; } - - @Override - public String[] getDescription() { - return new String[]{ - this.mDescription, - CORE.GT_Tooltip}; - } @Override public boolean isFacingValid(byte aFacing) { return true; } - @Override - public Class<? extends GT_MetaTileEntity_Hatch_NbtConsumable> getHatchEntityClass() { - return GT_MetaTileEntity_Hatch_MillingBalls.class; - } + @Override + public Class<? extends GT_MetaTileEntity_Hatch_NbtConsumable> getHatchEntityClass() { + return GT_MetaTileEntity_Hatch_MillingBalls.class; + } - @Override - public String getNameGUI() { - return "Ball Housing"; - } + @Override + public String getNameGUI() { + return "Ball Housing"; + } - @Override - public AutoMap<ItemStack> getItemsValidForUsageSlots() { - return new AutoMap<ItemStack>(); - } + @Override + public AutoMap<ItemStack> getItemsValidForUsageSlots() { + return new AutoMap<ItemStack>(); + } - @Override - public boolean isItemValidForUsageSlot(ItemStack aStack) { - return ItemUtils.isMillingBall(aStack); - } + @Override + public boolean isItemValidForUsageSlot(ItemStack aStack) { + return ItemUtils.isMillingBall(aStack); + } - @Override - public int getInputSlotCount() { - return 4; - } + @Override + public int getInputSlotCount() { + return 4; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/nbthandlers/GT_MetaTileEntity_Hatch_NbtConsumable.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/nbthandlers/GT_MetaTileEntity_Hatch_NbtConsumable.java index 552042a4c5..5d232836b4 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/nbthandlers/GT_MetaTileEntity_Hatch_NbtConsumable.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/nbthandlers/GT_MetaTileEntity_Hatch_NbtConsumable.java @@ -1,7 +1,5 @@ package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.nbthandlers; -import java.lang.reflect.Constructor; - import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; @@ -15,269 +13,308 @@ import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.gregtech.api.gui.hatches.CONTAINER_HatchNbtConsumable; import gtPlusPlus.xmod.gregtech.api.gui.hatches.GUI_HatchNbtConsumable; import gtPlusPlus.xmod.gregtech.common.StaticFields59; +import java.lang.reflect.Constructor; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; public abstract class GT_MetaTileEntity_Hatch_NbtConsumable extends GT_MetaTileEntity_Hatch { - public GT_Recipe_Map mRecipeMap = null; - private final int mInputslotCount; - private final int mTotalSlotCount; - private final boolean mAllowDuplicateUsageTypes; - - public GT_MetaTileEntity_Hatch_NbtConsumable(int aID, String aName, String aNameRegional, int aTier, int aInputSlots, String aDescription, boolean aAllowDuplicateTypes) { - super(aID, aName, aNameRegional, aTier, aInputSlots*2, aDescription); - mInputslotCount = getInputSlotCount(); - mTotalSlotCount = getInputSlotCount()*2; - mAllowDuplicateUsageTypes = aAllowDuplicateTypes; - } - - public GT_MetaTileEntity_Hatch_NbtConsumable(String aName, int aTier, int aInputSlots, String aDescription, boolean aAllowDuplicateTypes, ITexture[][][] aTextures) { - super(aName, aTier, aInputSlots*2, aDescription, aTextures); - mInputslotCount = getInputSlotCount(); - mTotalSlotCount = getInputSlotCount()*2; - mAllowDuplicateUsageTypes = aAllowDuplicateTypes; - } - - public GT_MetaTileEntity_Hatch_NbtConsumable(String aName, int aTier, int aInputSlots, String[] aDescription, boolean aAllowDuplicateTypes, ITexture[][][] aTextures) { - super(aName, aTier, aInputSlots*2, aDescription, aTextures); - mInputslotCount = getInputSlotCount(); - mTotalSlotCount = getInputSlotCount()*2; - mAllowDuplicateUsageTypes = aAllowDuplicateTypes; - } - - @Override - public abstract ITexture[] getTexturesActive(ITexture aBaseTexture); - - @Override - public abstract ITexture[] getTexturesInactive(ITexture aBaseTexture); - - public abstract int getInputSlotCount(); - - @Override - public final boolean isSimpleMachine() { - return true; - } - - @Override - public boolean isFacingValid(byte aFacing) { - return true; - } - - @Override - public final boolean isAccessAllowed(EntityPlayer aPlayer) { - return true; - } - - @Override - public final boolean isValidSlot(int aIndex) { - return true; - } - - @Override - public final MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - Constructor<?> aConstructor = ReflectionUtils.getConstructor(getHatchEntityClass(), new Class[] {String.class, String[].class, ITexture[][][].class}); - GT_MetaTileEntity_Hatch_NbtConsumable aInstance = ReflectionUtils.createNewInstanceFromConstructor(aConstructor, new Object[] {mName, StaticFields59.getDescriptionArray(this), mTextures}); - if (aInstance instanceof GT_MetaTileEntity_Hatch_NbtConsumable) { - GT_MetaTileEntity_Hatch_NbtConsumable aMetaTile = (GT_MetaTileEntity_Hatch_NbtConsumable) aInstance; - return aMetaTile; - } - return null; - } - - public abstract Class<? extends GT_MetaTileEntity_Hatch_NbtConsumable> getHatchEntityClass(); - - @Override - public final boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) { - return true; - } - aBaseMetaTileEntity.openGUI(aPlayer); - return true; - } - - @Override - public final Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new CONTAINER_HatchNbtConsumable(aPlayerInventory, aBaseMetaTileEntity, mInputslotCount); - } - - @Override - public final Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - CONTAINER_HatchNbtConsumable aContainer = new CONTAINER_HatchNbtConsumable(aPlayerInventory, aBaseMetaTileEntity, mInputslotCount); - return new GUI_HatchNbtConsumable(aContainer, getNameGUI()); - } - - public abstract String getNameGUI(); - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { - validateUsageSlots(); - if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.hasInventoryBeenModified()) { - fillStacksIntoFirstSlots(); - tryFillUsageSlots(); - } - } - - public final void updateSlots() { - for (int i = 0; i < mInventory.length; i++) { - if (mInventory[i] != null && mInventory[i].stackSize <= 0) { - mInventory[i] = null; - } - // Only moves items in the first four slots - if (i <= getSlotID_LastInput()) { - fillStacksIntoFirstSlots(); - } - } - } - - protected void validateUsageSlots() { - for (int i = getSlotID_FirstUsage(); i <= getSlotID_LastUsage(); i++) { - if (mInventory[i] != null && mInventory[i].stackSize < 1) { - mInventory[i] = null; - this.markDirty(); - } - } - } - - // Only moves items in the first four slots - protected final void fillStacksIntoFirstSlots() { - for (int i = 0; i <= getSlotID_LastInput() ; i++) { - for (int j = i + 1; j <= getSlotID_LastInput(); j++) { - if (mInventory[j] != null && (mInventory[i] == null || GT_Utility.areStacksEqual(mInventory[i], mInventory[j]))) { - GT_Utility.moveStackFromSlotAToSlotB(getBaseMetaTileEntity(), getBaseMetaTileEntity(), j, i, (byte) 64, (byte) 1, (byte) 64, (byte) 1); - } - } - } - } - - public final void tryFillUsageSlots() { - int aSlotSpace = (mInputslotCount - getContentUsageSlots().size()); - if (aSlotSpace > 0) { - Logger.INFO("We have empty usage slots. "+aSlotSpace); - for (int i=getSlotID_FirstInput();i<=getSlotID_LastInput();i++) { - ItemStack aStackToTryMove = mInventory[i]; - if (aStackToTryMove != null && isItemValidForUsageSlot(aStackToTryMove)) { - Logger.INFO("Trying to move stack from input slot "+i); - if (moveItemFromStockToUsageSlots(aStackToTryMove)) { - Logger.INFO("Updating Slots."); - updateSlots(); - } - } - } - } - } - - private int getSlotID_FirstInput() { - return 0; - } - private int getSlotID_LastInput() { - return mInputslotCount-1; - } - private int getSlotID_FirstUsage() { - return mInputslotCount; - } - private int getSlotID_LastUsage() { - return mTotalSlotCount-1; - } - - - public final AutoMap<ItemStack> getContentUsageSlots() { - AutoMap<ItemStack> aItems = new AutoMap<ItemStack>(); - for (int i=mInputslotCount;i<mTotalSlotCount;i++) { - if (mInventory[i] != null) { - aItems.add(mInventory[i]); - } - } - return aItems; - } - - - public final boolean moveItemFromStockToUsageSlots(ItemStack aStack) { - return moveItemFromStockToUsageSlots(aStack, mAllowDuplicateUsageTypes); - } - - public final boolean moveItemFromStockToUsageSlots(ItemStack aStack, boolean aAllowMultiOfSameTypeInUsageSlots) { - if (aStack != null) { - if (aStack.stackSize > 0) { - - if (!isItemValidForUsageSlot(aStack)) { - Logger.INFO("Stack not valid: "+ItemUtils.getItemName(aStack)); - return false; - } - - // Copy the input stack into a new object - ItemStack aStackToMove = aStack.copy(); - // Set stack size of stack to move to 1. - aStackToMove.stackSize = 1; - // Did we set a stack in the usage slots? - boolean aDidSet = false; - // Did we find another of this item already in the usage slots? - boolean aFoundMatching = false; - // Continue processing with our new stack - // First check for duplicates - for (int i = getSlotID_FirstUsage(); i <= getSlotID_LastUsage(); i++) { - if (mInventory[i] != null) { - if (GT_Utility.areStacksEqual(aStackToMove, mInventory[i], true)) { - Logger.INFO("Found matching stack in slot "+i+"."); - aFoundMatching = true; - break; - } - } - } - // Then Move stack to Usage slots - for (int i = getSlotID_FirstUsage(); i <= getSlotID_LastUsage(); i++) { - if (mInventory[i] == null) { - if ((aFoundMatching && aAllowMultiOfSameTypeInUsageSlots) || !aFoundMatching) { - mInventory[i] = aStackToMove; - aDidSet = true; - Logger.INFO("Moving new stack to usage slots."); - break; - } - } - } - if (aDidSet) { - Logger.INFO("Depleting input stack size by 1."); - // Depleted one from the original input stack - aStack.stackSize--; - } - return aDidSet; - } - } - return false; - } - - @Override - public final boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return false; - } - - @Override - public final boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return aSide == getBaseMetaTileEntity().getFrontFacing() && isItemValidForUsageSlot(aStack) && aIndex < mInputslotCount; - } - - /** - * Items that get compared when checking for Usage Slot validity. - * Can return an empty map if isItemValidForUsageSlot() is overridden. - * @return - */ - public abstract AutoMap<ItemStack> getItemsValidForUsageSlots(); - - /** - * Checks if the given item is valid for Usage Slots. - * Can be overridden for easier handling if you already have methods to check this. - * @param aStack - * @return - */ - public boolean isItemValidForUsageSlot(ItemStack aStack) { - if (aStack != null) { - for (ItemStack aValid : getItemsValidForUsageSlots()) { - if (GT_Utility.areStacksEqual(aStack, aValid, true)) { - return true; - } - } - } - return false; - } + public GT_Recipe_Map mRecipeMap = null; + private final int mInputslotCount; + private final int mTotalSlotCount; + private final boolean mAllowDuplicateUsageTypes; + + public GT_MetaTileEntity_Hatch_NbtConsumable( + int aID, + String aName, + String aNameRegional, + int aTier, + int aInputSlots, + String aDescription, + boolean aAllowDuplicateTypes) { + super(aID, aName, aNameRegional, aTier, aInputSlots * 2, aDescription); + mInputslotCount = getInputSlotCount(); + mTotalSlotCount = getInputSlotCount() * 2; + mAllowDuplicateUsageTypes = aAllowDuplicateTypes; + } + + public GT_MetaTileEntity_Hatch_NbtConsumable( + String aName, + int aTier, + int aInputSlots, + String aDescription, + boolean aAllowDuplicateTypes, + ITexture[][][] aTextures) { + super(aName, aTier, aInputSlots * 2, aDescription, aTextures); + mInputslotCount = getInputSlotCount(); + mTotalSlotCount = getInputSlotCount() * 2; + mAllowDuplicateUsageTypes = aAllowDuplicateTypes; + } + + public GT_MetaTileEntity_Hatch_NbtConsumable( + String aName, + int aTier, + int aInputSlots, + String[] aDescription, + boolean aAllowDuplicateTypes, + ITexture[][][] aTextures) { + super(aName, aTier, aInputSlots * 2, aDescription, aTextures); + mInputslotCount = getInputSlotCount(); + mTotalSlotCount = getInputSlotCount() * 2; + mAllowDuplicateUsageTypes = aAllowDuplicateTypes; + } + + @Override + public abstract ITexture[] getTexturesActive(ITexture aBaseTexture); + + @Override + public abstract ITexture[] getTexturesInactive(ITexture aBaseTexture); + + public abstract int getInputSlotCount(); + + @Override + public final boolean isSimpleMachine() { + return true; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return true; + } + + @Override + public final boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public final boolean isValidSlot(int aIndex) { + return true; + } + + @Override + public final MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + Constructor<?> aConstructor = ReflectionUtils.getConstructor( + getHatchEntityClass(), new Class[] {String.class, String[].class, ITexture[][][].class}); + GT_MetaTileEntity_Hatch_NbtConsumable aInstance = ReflectionUtils.createNewInstanceFromConstructor( + aConstructor, new Object[] {mName, StaticFields59.getDescriptionArray(this), mTextures}); + if (aInstance instanceof GT_MetaTileEntity_Hatch_NbtConsumable) { + GT_MetaTileEntity_Hatch_NbtConsumable aMetaTile = (GT_MetaTileEntity_Hatch_NbtConsumable) aInstance; + return aMetaTile; + } + return null; + } + + public abstract Class<? extends GT_MetaTileEntity_Hatch_NbtConsumable> getHatchEntityClass(); + + @Override + public final boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + + @Override + public final Object getServerGUI( + int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new CONTAINER_HatchNbtConsumable(aPlayerInventory, aBaseMetaTileEntity, mInputslotCount); + } + + @Override + public final Object getClientGUI( + int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + CONTAINER_HatchNbtConsumable aContainer = + new CONTAINER_HatchNbtConsumable(aPlayerInventory, aBaseMetaTileEntity, mInputslotCount); + return new GUI_HatchNbtConsumable(aContainer, getNameGUI()); + } + + public abstract String getNameGUI(); + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { + validateUsageSlots(); + if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.hasInventoryBeenModified()) { + fillStacksIntoFirstSlots(); + tryFillUsageSlots(); + } + } + + public final void updateSlots() { + for (int i = 0; i < mInventory.length; i++) { + if (mInventory[i] != null && mInventory[i].stackSize <= 0) { + mInventory[i] = null; + } + // Only moves items in the first four slots + if (i <= getSlotID_LastInput()) { + fillStacksIntoFirstSlots(); + } + } + } + + protected void validateUsageSlots() { + for (int i = getSlotID_FirstUsage(); i <= getSlotID_LastUsage(); i++) { + if (mInventory[i] != null && mInventory[i].stackSize < 1) { + mInventory[i] = null; + this.markDirty(); + } + } + } + + // Only moves items in the first four slots + protected final void fillStacksIntoFirstSlots() { + for (int i = 0; i <= getSlotID_LastInput(); i++) { + for (int j = i + 1; j <= getSlotID_LastInput(); j++) { + if (mInventory[j] != null + && (mInventory[i] == null || GT_Utility.areStacksEqual(mInventory[i], mInventory[j]))) { + GT_Utility.moveStackFromSlotAToSlotB( + getBaseMetaTileEntity(), + getBaseMetaTileEntity(), + j, + i, + (byte) 64, + (byte) 1, + (byte) 64, + (byte) 1); + } + } + } + } + + public final void tryFillUsageSlots() { + int aSlotSpace = (mInputslotCount - getContentUsageSlots().size()); + if (aSlotSpace > 0) { + Logger.INFO("We have empty usage slots. " + aSlotSpace); + for (int i = getSlotID_FirstInput(); i <= getSlotID_LastInput(); i++) { + ItemStack aStackToTryMove = mInventory[i]; + if (aStackToTryMove != null && isItemValidForUsageSlot(aStackToTryMove)) { + Logger.INFO("Trying to move stack from input slot " + i); + if (moveItemFromStockToUsageSlots(aStackToTryMove)) { + Logger.INFO("Updating Slots."); + updateSlots(); + } + } + } + } + } + + private int getSlotID_FirstInput() { + return 0; + } + + private int getSlotID_LastInput() { + return mInputslotCount - 1; + } + + private int getSlotID_FirstUsage() { + return mInputslotCount; + } + + private int getSlotID_LastUsage() { + return mTotalSlotCount - 1; + } + + public final AutoMap<ItemStack> getContentUsageSlots() { + AutoMap<ItemStack> aItems = new AutoMap<ItemStack>(); + for (int i = mInputslotCount; i < mTotalSlotCount; i++) { + if (mInventory[i] != null) { + aItems.add(mInventory[i]); + } + } + return aItems; + } + + public final boolean moveItemFromStockToUsageSlots(ItemStack aStack) { + return moveItemFromStockToUsageSlots(aStack, mAllowDuplicateUsageTypes); + } + + public final boolean moveItemFromStockToUsageSlots(ItemStack aStack, boolean aAllowMultiOfSameTypeInUsageSlots) { + if (aStack != null) { + if (aStack.stackSize > 0) { + + if (!isItemValidForUsageSlot(aStack)) { + Logger.INFO("Stack not valid: " + ItemUtils.getItemName(aStack)); + return false; + } + + // Copy the input stack into a new object + ItemStack aStackToMove = aStack.copy(); + // Set stack size of stack to move to 1. + aStackToMove.stackSize = 1; + // Did we set a stack in the usage slots? + boolean aDidSet = false; + // Did we find another of this item already in the usage slots? + boolean aFoundMatching = false; + // Continue processing with our new stack + // First check for duplicates + for (int i = getSlotID_FirstUsage(); i <= getSlotID_LastUsage(); i++) { + if (mInventory[i] != null) { + if (GT_Utility.areStacksEqual(aStackToMove, mInventory[i], true)) { + Logger.INFO("Found matching stack in slot " + i + "."); + aFoundMatching = true; + break; + } + } + } + // Then Move stack to Usage slots + for (int i = getSlotID_FirstUsage(); i <= getSlotID_LastUsage(); i++) { + if (mInventory[i] == null) { + if ((aFoundMatching && aAllowMultiOfSameTypeInUsageSlots) || !aFoundMatching) { + mInventory[i] = aStackToMove; + aDidSet = true; + Logger.INFO("Moving new stack to usage slots."); + break; + } + } + } + if (aDidSet) { + Logger.INFO("Depleting input stack size by 1."); + // Depleted one from the original input stack + aStack.stackSize--; + } + return aDidSet; + } + } + return false; + } + + @Override + public final boolean allowPullStack( + IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return false; + } + + @Override + public final boolean allowPutStack( + IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return aSide == getBaseMetaTileEntity().getFrontFacing() + && isItemValidForUsageSlot(aStack) + && aIndex < mInputslotCount; + } + + /** + * Items that get compared when checking for Usage Slot validity. + * Can return an empty map if isItemValidForUsageSlot() is overridden. + * @return + */ + public abstract AutoMap<ItemStack> getItemsValidForUsageSlots(); + + /** + * Checks if the given item is valid for Usage Slots. + * Can be overridden for easier handling if you already have methods to check this. + * @param aStack + * @return + */ + public boolean isItemValidForUsageSlot(ItemStack aStack) { + if (aStack != null) { + for (ItemStack aValid : getItemsValidForUsageSlots()) { + if (GT_Utility.areStacksEqual(aStack, aValid, true)) { + return true; + } + } + } + return false; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/objects/GTPP_CopiedBlockTexture.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/objects/GTPP_CopiedBlockTexture.java index fdf237bb11..5336b60fc7 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/objects/GTPP_CopiedBlockTexture.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/objects/GTPP_CopiedBlockTexture.java @@ -12,7 +12,7 @@ import net.minecraft.block.Block; @SuppressWarnings("deprecation") public class GTPP_CopiedBlockTexture extends GT_CopiedBlockTexture { - public GTPP_CopiedBlockTexture(Block aBlock, int aSide, int aMeta, short[] aRGBa, boolean aAllowAlpha) { + public GTPP_CopiedBlockTexture(Block aBlock, int aSide, int aMeta, short[] aRGBa, boolean aAllowAlpha) { super(aBlock, aMeta, aMeta, aRGBa, aAllowAlpha); } @@ -23,5 +23,4 @@ public class GTPP_CopiedBlockTexture extends GT_CopiedBlockTexture { public GTPP_CopiedBlockTexture(Block aBlock, int aSide, int aMeta) { this(aBlock, aSide, aMeta, Dyes._NULL.mRGBa); } - } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/objects/GTPP_RenderedTexture.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/objects/GTPP_RenderedTexture.java index 562be6a8ef..6764a1e206 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/objects/GTPP_RenderedTexture.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/objects/GTPP_RenderedTexture.java @@ -12,7 +12,7 @@ import gregtech.api.objects.GT_RenderedTexture; @SuppressWarnings("deprecation") public class GTPP_RenderedTexture extends GT_RenderedTexture { - public GTPP_RenderedTexture(IIconContainer aIcon, short[] aRGBa, boolean aAllowAlpha) { + public GTPP_RenderedTexture(IIconContainer aIcon, short[] aRGBa, boolean aAllowAlpha) { super(aIcon, aRGBa, aAllowAlpha); } @@ -23,5 +23,4 @@ public class GTPP_RenderedTexture extends GT_RenderedTexture { public GTPP_RenderedTexture(IIconContainer aIcon) { this(aIcon, Dyes._NULL.mRGBa); } - } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/objects/GregtechFluid.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/objects/GregtechFluid.java index 9cc0e3a315..40699aa108 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/objects/GregtechFluid.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/objects/GregtechFluid.java @@ -1,28 +1,29 @@ package gtPlusPlus.xmod.gregtech.api.objects; import gregtech.api.GregTech_API; - import gtPlusPlus.core.lib.CORE; import net.minecraftforge.fluids.Fluid; public class GregtechFluid extends Fluid implements Runnable { - public final String mTextureName; - private final short[] mRGBa; + public final String mTextureName; + private final short[] mRGBa; - public GregtechFluid(final String aName, final String aTextureName, final short[] aRGBa) { - super(aName); - this.mRGBa = aRGBa; - this.mTextureName = aTextureName; - GregTech_API.sGTBlockIconload.add(this); - } + public GregtechFluid(final String aName, final String aTextureName, final short[] aRGBa) { + super(aName); + this.mRGBa = aRGBa; + this.mTextureName = aTextureName; + GregTech_API.sGTBlockIconload.add(this); + } - @Override - public int getColor() { - return (Math.max(0, Math.min(255, this.mRGBa[0])) << 16) | (Math.max(0, Math.min(255, this.mRGBa[1])) << 8) | Math.max(0, Math.min(255, this.mRGBa[2])); - } + @Override + public int getColor() { + return (Math.max(0, Math.min(255, this.mRGBa[0])) << 16) + | (Math.max(0, Math.min(255, this.mRGBa[1])) << 8) + | Math.max(0, Math.min(255, this.mRGBa[2])); + } - @Override - public void run() { - this.setIcons(GregTech_API.sBlockIcons.registerIcon(CORE.MODID+ ":" + "fluids/fluid." + this.mTextureName)); - } -}
\ No newline at end of file + @Override + public void run() { + this.setIcons(GregTech_API.sBlockIcons.registerIcon(CORE.MODID + ":" + "fluids/fluid." + this.mTextureName)); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/objects/GregtechItemData.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/objects/GregtechItemData.java index eb5939caca..a26cfbb192 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/objects/GregtechItemData.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/objects/GregtechItemData.java @@ -1,144 +1,151 @@ package gtPlusPlus.xmod.gregtech.api.objects; -import java.util.*; - -import net.minecraft.item.ItemStack; - import gregtech.api.objects.GT_ArrayList; - import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes; import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes.GT_Materials; +import java.util.*; +import net.minecraft.item.ItemStack; public class GregtechItemData { - private static final GregtechMaterialStack[] EMPTY_GT_MaterialStack_ARRAY = new GregtechMaterialStack[0]; - - public final List<Object> mExtraData = new GT_ArrayList<>(false, 1); - public final GregtechOrePrefixes mPrefix; - public final GregtechMaterialStack mMaterial; - public final GregtechMaterialStack[] mByProducts; - public boolean mBlackListed = false; - public ItemStack mUnificationTarget = null; - - public GregtechItemData(final GregtechOrePrefixes aPrefix, final GT_Materials aMaterial, final boolean aBlackListed) { - this.mPrefix = aPrefix; - this.mMaterial = aMaterial == null ? null : new GregtechMaterialStack(aMaterial, aPrefix.mMaterialAmount); - this.mBlackListed = aBlackListed; - this.mByProducts = (aPrefix.mSecondaryMaterial == null) || (aPrefix.mSecondaryMaterial.mMaterial == null) ? EMPTY_GT_MaterialStack_ARRAY : new GregtechMaterialStack[]{aPrefix.mSecondaryMaterial.clone()}; - } - - public GregtechItemData(final GregtechOrePrefixes aPrefix, final GT_Materials aMaterial) { - this(aPrefix, aMaterial, false); - } - - public GregtechItemData(final GregtechMaterialStack aMaterial, final GregtechMaterialStack... aByProducts) { - this.mPrefix = null; - this.mMaterial = aMaterial.mMaterial == null ? null : aMaterial.clone(); - this.mBlackListed = true; - if (aByProducts == null) { - this.mByProducts = EMPTY_GT_MaterialStack_ARRAY; - } else { - final GregtechMaterialStack[] tByProducts = aByProducts.length < 1 ? EMPTY_GT_MaterialStack_ARRAY : new GregtechMaterialStack[aByProducts.length]; - int j = 0; - for (int i = 0; i < aByProducts.length; i++) { - if ((aByProducts[i] != null) && (aByProducts[i].mMaterial != null)) { - tByProducts[j++] = aByProducts[i].clone(); - } - } - this.mByProducts = j > 0 ? new GregtechMaterialStack[j] : EMPTY_GT_MaterialStack_ARRAY; - for (int i = 0; i < this.mByProducts.length; i++) { - this.mByProducts[i] = tByProducts[i]; - } - } - } - - public GregtechItemData(final GT_Materials aMaterial, final long aAmount, final GregtechMaterialStack... aByProducts) { - this(new GregtechMaterialStack(aMaterial, aAmount), aByProducts); - } - - public GregtechItemData(final GT_Materials aMaterial, final long aAmount, final GT_Materials aByProduct, final long aByProductAmount) { - this(new GregtechMaterialStack(aMaterial, aAmount), new GregtechMaterialStack(aByProduct, aByProductAmount)); - } - - public GregtechItemData(final GregtechItemData... aData) { - this.mPrefix = null; - this.mBlackListed = true; - - final ArrayList<GregtechMaterialStack> aList = new ArrayList<>(), rList = new ArrayList<>(); - - for (final GregtechItemData tData : aData) { - if (tData != null) { - if (tData.hasValidMaterialData() && (tData.mMaterial.mAmount > 0)) { - aList.add(tData.mMaterial.clone()); - } - for (final GregtechMaterialStack tMaterial : tData.mByProducts) { - if (tMaterial.mAmount > 0) { - aList.add(tMaterial.clone()); - } - } - } - } - - for (final GregtechMaterialStack aMaterial : aList) { - boolean temp = true; - for (final GregtechMaterialStack tMaterial : rList) { - if (aMaterial.mMaterial == tMaterial.mMaterial) { - tMaterial.mAmount += aMaterial.mAmount; - temp = false; - break; - } - } - if (temp) { - rList.add(aMaterial.clone()); - } - } - - Collections.sort(rList, new Comparator<GregtechMaterialStack>() { - @Override - public int compare(final GregtechMaterialStack a, final GregtechMaterialStack b) { - return a.mAmount == b.mAmount ? 0 : a.mAmount > b.mAmount ? -1 : +1; - } - }); - - if (rList.isEmpty()) { - this.mMaterial = null; - } else { - this.mMaterial = rList.get(0); - rList.remove(0); - } - - this.mByProducts = rList.toArray(new GregtechMaterialStack[rList.size()]); - } - - public boolean hasValidPrefixMaterialData() { - return (this.mPrefix != null) && (this.mMaterial != null) && (this.mMaterial.mMaterial != null); - } - - public boolean hasValidPrefixData() { - return this.mPrefix != null; - } - - public boolean hasValidMaterialData() { - return (this.mMaterial != null) && (this.mMaterial.mMaterial != null); - } - - public ArrayList<GregtechMaterialStack> getAllGT_MaterialStacks() { - final ArrayList<GregtechMaterialStack> rList = new ArrayList<GregtechMaterialStack>(); - if (this.hasValidMaterialData()) { - rList.add(this.mMaterial); - } - rList.addAll(Arrays.asList(this.mByProducts)); - return rList; - } - - public GregtechMaterialStack getByProduct(final int aIndex) { - return (aIndex >= 0) && (aIndex < this.mByProducts.length) ? this.mByProducts[aIndex] : null; - } - - @Override - public String toString() { - if ((this.mPrefix == null) || (this.mMaterial == null) || (this.mMaterial.mMaterial == null)) { - return ""; - } - return this.mPrefix.name() + this.mMaterial.mMaterial.name(); - } -}
\ No newline at end of file + private static final GregtechMaterialStack[] EMPTY_GT_MaterialStack_ARRAY = new GregtechMaterialStack[0]; + + public final List<Object> mExtraData = new GT_ArrayList<>(false, 1); + public final GregtechOrePrefixes mPrefix; + public final GregtechMaterialStack mMaterial; + public final GregtechMaterialStack[] mByProducts; + public boolean mBlackListed = false; + public ItemStack mUnificationTarget = null; + + public GregtechItemData( + final GregtechOrePrefixes aPrefix, final GT_Materials aMaterial, final boolean aBlackListed) { + this.mPrefix = aPrefix; + this.mMaterial = aMaterial == null ? null : new GregtechMaterialStack(aMaterial, aPrefix.mMaterialAmount); + this.mBlackListed = aBlackListed; + this.mByProducts = (aPrefix.mSecondaryMaterial == null) || (aPrefix.mSecondaryMaterial.mMaterial == null) + ? EMPTY_GT_MaterialStack_ARRAY + : new GregtechMaterialStack[] {aPrefix.mSecondaryMaterial.clone()}; + } + + public GregtechItemData(final GregtechOrePrefixes aPrefix, final GT_Materials aMaterial) { + this(aPrefix, aMaterial, false); + } + + public GregtechItemData(final GregtechMaterialStack aMaterial, final GregtechMaterialStack... aByProducts) { + this.mPrefix = null; + this.mMaterial = aMaterial.mMaterial == null ? null : aMaterial.clone(); + this.mBlackListed = true; + if (aByProducts == null) { + this.mByProducts = EMPTY_GT_MaterialStack_ARRAY; + } else { + final GregtechMaterialStack[] tByProducts = aByProducts.length < 1 + ? EMPTY_GT_MaterialStack_ARRAY + : new GregtechMaterialStack[aByProducts.length]; + int j = 0; + for (int i = 0; i < aByProducts.length; i++) { + if ((aByProducts[i] != null) && (aByProducts[i].mMaterial != null)) { + tByProducts[j++] = aByProducts[i].clone(); + } + } + this.mByProducts = j > 0 ? new GregtechMaterialStack[j] : EMPTY_GT_MaterialStack_ARRAY; + for (int i = 0; i < this.mByProducts.length; i++) { + this.mByProducts[i] = tByProducts[i]; + } + } + } + + public GregtechItemData( + final GT_Materials aMaterial, final long aAmount, final GregtechMaterialStack... aByProducts) { + this(new GregtechMaterialStack(aMaterial, aAmount), aByProducts); + } + + public GregtechItemData( + final GT_Materials aMaterial, + final long aAmount, + final GT_Materials aByProduct, + final long aByProductAmount) { + this(new GregtechMaterialStack(aMaterial, aAmount), new GregtechMaterialStack(aByProduct, aByProductAmount)); + } + + public GregtechItemData(final GregtechItemData... aData) { + this.mPrefix = null; + this.mBlackListed = true; + + final ArrayList<GregtechMaterialStack> aList = new ArrayList<>(), rList = new ArrayList<>(); + + for (final GregtechItemData tData : aData) { + if (tData != null) { + if (tData.hasValidMaterialData() && (tData.mMaterial.mAmount > 0)) { + aList.add(tData.mMaterial.clone()); + } + for (final GregtechMaterialStack tMaterial : tData.mByProducts) { + if (tMaterial.mAmount > 0) { + aList.add(tMaterial.clone()); + } + } + } + } + + for (final GregtechMaterialStack aMaterial : aList) { + boolean temp = true; + for (final GregtechMaterialStack tMaterial : rList) { + if (aMaterial.mMaterial == tMaterial.mMaterial) { + tMaterial.mAmount += aMaterial.mAmount; + temp = false; + break; + } + } + if (temp) { + rList.add(aMaterial.clone()); + } + } + + Collections.sort(rList, new Comparator<GregtechMaterialStack>() { + @Override + public int compare(final GregtechMaterialStack a, final GregtechMaterialStack b) { + return a.mAmount == b.mAmount ? 0 : a.mAmount > b.mAmount ? -1 : +1; + } + }); + + if (rList.isEmpty()) { + this.mMaterial = null; + } else { + this.mMaterial = rList.get(0); + rList.remove(0); + } + + this.mByProducts = rList.toArray(new GregtechMaterialStack[rList.size()]); + } + + public boolean hasValidPrefixMaterialData() { + return (this.mPrefix != null) && (this.mMaterial != null) && (this.mMaterial.mMaterial != null); + } + + public boolean hasValidPrefixData() { + return this.mPrefix != null; + } + + public boolean hasValidMaterialData() { + return (this.mMaterial != null) && (this.mMaterial.mMaterial != null); + } + + public ArrayList<GregtechMaterialStack> getAllGT_MaterialStacks() { + final ArrayList<GregtechMaterialStack> rList = new ArrayList<GregtechMaterialStack>(); + if (this.hasValidMaterialData()) { + rList.add(this.mMaterial); + } + rList.addAll(Arrays.asList(this.mByProducts)); + return rList; + } + + public GregtechMaterialStack getByProduct(final int aIndex) { + return (aIndex >= 0) && (aIndex < this.mByProducts.length) ? this.mByProducts[aIndex] : null; + } + + @Override + public String toString() { + if ((this.mPrefix == null) || (this.mMaterial == null) || (this.mMaterial.mMaterial == null)) { + return ""; + } + return this.mPrefix.name() + this.mMaterial.mMaterial.name(); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/objects/GregtechMaterialStack.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/objects/GregtechMaterialStack.java index 6ec5907256..107202a027 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/objects/GregtechMaterialStack.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/objects/GregtechMaterialStack.java @@ -3,47 +3,53 @@ package gtPlusPlus.xmod.gregtech.api.objects; import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes.GT_Materials; public class GregtechMaterialStack implements Cloneable { - public long mAmount; - public GT_Materials mMaterial; - - public GregtechMaterialStack(final GT_Materials aMaterial, final long aAmount) { - this.mMaterial = aMaterial == null ? GT_Materials._NULL : aMaterial; - this.mAmount = aAmount; - } - - public GregtechMaterialStack copy(final long aAmount) { - return new GregtechMaterialStack(this.mMaterial, aAmount); - } - - @Override - public GregtechMaterialStack clone() { - return new GregtechMaterialStack(this.mMaterial, this.mAmount); - } - - @Override - public boolean equals(final Object aObject) { - if (aObject == this) { - return true; - } - if (aObject == null) { - return false; - } - if (aObject instanceof GT_Materials) { - return aObject == this.mMaterial; - } - if (aObject instanceof GregtechMaterialStack) { - return (((GregtechMaterialStack) aObject).mMaterial == this.mMaterial) && ((this.mAmount < 0) || (((GregtechMaterialStack) aObject).mAmount < 0) || (((GregtechMaterialStack) aObject).mAmount == this.mAmount)); - } - return false; - } - - @Override - public String toString() { - return ((this.mMaterial.mMaterialList.size() > 1) && (this.mAmount > 1) ? "(" : "") + this.mMaterial.getToolTip(true) + ((this.mMaterial.mMaterialList.size() > 1) && (this.mAmount > 1) ? ")" : "") + (this.mAmount > 1 ? this.mAmount : ""); - } - - @Override - public int hashCode() { - return this.mMaterial.hashCode(); - } -}
\ No newline at end of file + public long mAmount; + public GT_Materials mMaterial; + + public GregtechMaterialStack(final GT_Materials aMaterial, final long aAmount) { + this.mMaterial = aMaterial == null ? GT_Materials._NULL : aMaterial; + this.mAmount = aAmount; + } + + public GregtechMaterialStack copy(final long aAmount) { + return new GregtechMaterialStack(this.mMaterial, aAmount); + } + + @Override + public GregtechMaterialStack clone() { + return new GregtechMaterialStack(this.mMaterial, this.mAmount); + } + + @Override + public boolean equals(final Object aObject) { + if (aObject == this) { + return true; + } + if (aObject == null) { + return false; + } + if (aObject instanceof GT_Materials) { + return aObject == this.mMaterial; + } + if (aObject instanceof GregtechMaterialStack) { + return (((GregtechMaterialStack) aObject).mMaterial == this.mMaterial) + && ((this.mAmount < 0) + || (((GregtechMaterialStack) aObject).mAmount < 0) + || (((GregtechMaterialStack) aObject).mAmount == this.mAmount)); + } + return false; + } + + @Override + public String toString() { + return ((this.mMaterial.mMaterialList.size() > 1) && (this.mAmount > 1) ? "(" : "") + + this.mMaterial.getToolTip(true) + + ((this.mMaterial.mMaterialList.size() > 1) && (this.mAmount > 1) ? ")" : "") + + (this.mAmount > 1 ? this.mAmount : ""); + } + + @Override + public int hashCode() { + return this.mMaterial.hashCode(); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/recipe/ProcessingSkookumChoocherToolRecipes.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/recipe/ProcessingSkookumChoocherToolRecipes.java index 976f21c329..ce73d1495f 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/recipe/ProcessingSkookumChoocherToolRecipes.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/recipe/ProcessingSkookumChoocherToolRecipes.java @@ -1,22 +1,32 @@ package gtPlusPlus.xmod.gregtech.api.recipe; -import net.minecraft.item.ItemStack; - import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; import gregtech.api.enums.ToolDictNames; import gregtech.api.interfaces.IOreRecipeRegistrator; import gregtech.api.util.GT_ModHandler; - import gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedGregtechTools; +import net.minecraft.item.ItemStack; public class ProcessingSkookumChoocherToolRecipes implements IOreRecipeRegistrator { - public ProcessingSkookumChoocherToolRecipes() { - //GregtechOrePrefixes.toolSkookumChoocher.add(this); - } + public ProcessingSkookumChoocherToolRecipes() { + // GregtechOrePrefixes.toolSkookumChoocher.add(this); + } - @Override - public void registerOre(final OrePrefixes aPrefix, final Materials aMaterial, final String aOreDictName, final String aModName, final ItemStack aStack) { - GT_ModHandler.addShapelessCraftingRecipe(MetaGeneratedGregtechTools.INSTANCE.getToolWithStats(7734, 1, aMaterial, aMaterial, null), new Object[]{aOreDictName, OrePrefixes.stick.get(aMaterial), OrePrefixes.screw.get(aMaterial), ToolDictNames.craftingToolScrewdriver}); - } + @Override + public void registerOre( + final OrePrefixes aPrefix, + final Materials aMaterial, + final String aOreDictName, + final String aModName, + final ItemStack aStack) { + GT_ModHandler.addShapelessCraftingRecipe( + MetaGeneratedGregtechTools.INSTANCE.getToolWithStats(7734, 1, aMaterial, aMaterial, null), + new Object[] { + aOreDictName, + OrePrefixes.stick.get(aMaterial), + OrePrefixes.screw.get(aMaterial), + ToolDictNames.craftingToolScrewdriver + }); + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/util/GTPP_Config.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/util/GTPP_Config.java index dcdc1220d0..ee4892e11a 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/util/GTPP_Config.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/util/GTPP_Config.java @@ -2,12 +2,10 @@ package gtPlusPlus.xmod.gregtech.api.util; import static gregtech.api.enums.GT_Values.E; -import net.minecraft.item.ItemStack; - import gregtech.api.GregTech_API; import gregtech.api.util.GT_OreDictUnificator; import gregtech.api.util.GT_Utility; - +import net.minecraft.item.ItemStack; import net.minecraftforge.common.config.Configuration; import net.minecraftforge.common.config.Property; @@ -25,7 +23,8 @@ public class GTPP_Config implements Runnable { public static int addIDConfig(Object aCategory, String aName, int aDefault) { if (GT_Utility.isStringInvalid(aName)) return aDefault; - Property tProperty = sConfigFileIDs.get(aCategory.toString().replaceAll("\\|", "."), aName.replaceAll("\\|", "."), aDefault); + Property tProperty = + sConfigFileIDs.get(aCategory.toString().replaceAll("\\|", "."), aName.replaceAll("\\|", "."), aDefault); int rResult = tProperty.getInt(aDefault); if (!tProperty.wasRead() && GregTech_API.sPostloadFinished) sConfigFileIDs.save(); return rResult; @@ -37,7 +36,9 @@ public class GTPP_Config implements Runnable { if (rName != null) return rName.toString(); try { if (GT_Utility.isStringValid(rName = aStack.getUnlocalizedName())) return rName.toString(); - } catch (Throwable e) {/*Do nothing*/} + } catch (Throwable e) { + /*Do nothing*/ + } String sName = aStack.getItem().toString(); String[] tmp = sName.split("@"); if (tmp.length > 0) sName = tmp[0]; @@ -51,7 +52,8 @@ public class GTPP_Config implements Runnable { public boolean get(Object aCategory, String aName, boolean aDefault) { if (GT_Utility.isStringInvalid(aName)) return aDefault; - Property tProperty = mConfig.get(aCategory.toString().replaceAll("\\|", "_"), (aName + "_" + aDefault).replaceAll("\\|", "_"), aDefault); + Property tProperty = mConfig.get( + aCategory.toString().replaceAll("\\|", "_"), (aName + "_" + aDefault).replaceAll("\\|", "_"), aDefault); boolean rResult = tProperty.getBoolean(aDefault); if (!tProperty.wasRead() && GregTech_API.sPostloadFinished) mConfig.save(); return rResult; @@ -63,7 +65,8 @@ public class GTPP_Config implements Runnable { public int get(Object aCategory, String aName, int aDefault) { if (GT_Utility.isStringInvalid(aName)) return aDefault; - Property tProperty = mConfig.get(aCategory.toString().replaceAll("\\|", "_"), (aName + "_" + aDefault).replaceAll("\\|", "_"), aDefault); + Property tProperty = mConfig.get( + aCategory.toString().replaceAll("\\|", "_"), (aName + "_" + aDefault).replaceAll("\\|", "_"), aDefault); int rResult = tProperty.getInt(aDefault); if (!tProperty.wasRead() && GregTech_API.sPostloadFinished) mConfig.save(); return rResult; @@ -75,7 +78,8 @@ public class GTPP_Config implements Runnable { public double get(Object aCategory, String aName, double aDefault) { if (GT_Utility.isStringInvalid(aName)) return aDefault; - Property tProperty = mConfig.get(aCategory.toString().replaceAll("\\|", "_"), (aName + "_" + aDefault).replaceAll("\\|", "_"), aDefault); + Property tProperty = mConfig.get( + aCategory.toString().replaceAll("\\|", "_"), (aName + "_" + aDefault).replaceAll("\\|", "_"), aDefault); double rResult = tProperty.getDouble(aDefault); if (!tProperty.wasRead() && GregTech_API.sPostloadFinished) mConfig.save(); return rResult; @@ -87,7 +91,8 @@ public class GTPP_Config implements Runnable { public String get(Object aCategory, String aName, String aDefault) { if (GT_Utility.isStringInvalid(aName)) return aDefault; - Property tProperty = mConfig.get(aCategory.toString().replaceAll("\\|", "_"), (aName + "_" + aDefault).replaceAll("\\|", "_"), aDefault); + Property tProperty = mConfig.get( + aCategory.toString().replaceAll("\\|", "_"), (aName + "_" + aDefault).replaceAll("\\|", "_"), aDefault); String rResult = tProperty.getString(); if (!tProperty.wasRead() && GregTech_API.sPostloadFinished) mConfig.save(); return rResult; @@ -97,4 +102,4 @@ public class GTPP_Config implements Runnable { public void run() { mConfig.save(); } -}
\ No newline at end of file +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/util/GregtechOreDictUnificator.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/util/GregtechOreDictUnificator.java index 3e0084139e..c5671b88b9 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/util/GregtechOreDictUnificator.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/util/GregtechOreDictUnificator.java @@ -1,5 +1,7 @@ package gtPlusPlus.xmod.gregtech.api.util; +import static gregtech.api.enums.GT_Values.*; + import gregtech.api.GregTech_API; import gregtech.api.enums.Dyes; import gregtech.api.enums.Materials; @@ -10,37 +12,32 @@ import gregtech.api.objects.GT_ItemStack; import gregtech.api.objects.ItemData; import gregtech.api.objects.MaterialStack; import gregtech.api.util.*; - import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.gregtech.common.StaticFields59; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraftforge.oredict.OreDictionary; - import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; - -import static gregtech.api.enums.GT_Values.*; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraftforge.oredict.OreDictionary; public class GregtechOreDictUnificator { - - + private static final Map<String, ItemStack> sName2StackMap = new HashMap<String, ItemStack>(); private static final Map<GT_ItemStack, ItemData> sItemStack2DataMap = new HashMap<GT_ItemStack, ItemData>(); - private static final Map<GT_ItemStack, List<ItemStack>> sUnificationTable = new HashMap<GT_ItemStack, List<ItemStack>>(); + private static final Map<GT_ItemStack, List<ItemStack>> sUnificationTable = + new HashMap<GT_ItemStack, List<ItemStack>>(); private static final GT_HashSet<GT_ItemStack> sNoUnificationList = new GT_HashSet<GT_ItemStack>(); - - + private static int isRegisteringOre = 0, isAddingOre = 0; private static boolean mRunThroughTheList = true; static { - if (ReflectionUtils.getField(GT_OreDictUnificator.class, "sUnificationTable") == null) { - GregTech_API.sItemStackMappings.add(sUnificationTable); - } + if (ReflectionUtils.getField(GT_OreDictUnificator.class, "sUnificationTable") == null) { + GregTech_API.sItemStackMappings.add(sUnificationTable); + } } /** @@ -64,14 +61,23 @@ public class GregtechOreDictUnificator { set(aPrefix, aMaterial, aStack, true, false); } - public static void set(OrePrefixes aPrefix, Materials aMaterial, ItemStack aStack, boolean aOverwrite, boolean aAlreadyRegistered) { - if (aMaterial == null || aPrefix == null || GT_Utility.isStackInvalid(aStack) || Items.feather.getDamage(aStack) == W) - return; + public static void set( + OrePrefixes aPrefix, + Materials aMaterial, + ItemStack aStack, + boolean aOverwrite, + boolean aAlreadyRegistered) { + if (aMaterial == null + || aPrefix == null + || GT_Utility.isStackInvalid(aStack) + || Items.feather.getDamage(aStack) == W) return; isAddingOre++; aStack = GT_Utility.copyAmount(1, aStack); if (!aAlreadyRegistered) registerOre(aPrefix.get(aMaterial), aStack); addAssociation(aPrefix, aMaterial, aStack, isBlacklisted(aStack)); - if (aOverwrite || GT_Utility.isStackInvalid(sName2StackMap.get(aPrefix.get(aMaterial).toString()))) + if (aOverwrite + || GT_Utility.isStackInvalid( + sName2StackMap.get(aPrefix.get(aMaterial).toString()))) sName2StackMap.put(aPrefix.get(aMaterial).toString(), aStack); isAddingOre--; } @@ -96,16 +102,24 @@ public class GregtechOreDictUnificator { } public static ItemStack get(OrePrefixes aPrefix, Object aMaterial, ItemStack aReplacement, long aAmount) { - //if (Materials.mDefaultComponents.contains(aPrefix) && !aPrefix.mDynamicItems.contains((Materials)aMaterial)) aPrefix.mDynamicItems.add((Materials) aMaterial); - if (StaticFields59.geOrePrefixesBooleanPreventableComponents().contains(aPrefix) && StaticFields59.getOrePrefixesBooleanDisabledItems().contains(aMaterial)) return aReplacement; + // if (Materials.mDefaultComponents.contains(aPrefix) && !aPrefix.mDynamicItems.contains((Materials)aMaterial)) + // aPrefix.mDynamicItems.add((Materials) aMaterial); + if (StaticFields59.geOrePrefixesBooleanPreventableComponents().contains(aPrefix) + && StaticFields59.getOrePrefixesBooleanDisabledItems().contains(aMaterial)) return aReplacement; return get(aPrefix.get(aMaterial), aReplacement, aAmount, false, true); } - public static ItemStack get(Object aName, ItemStack aReplacement, long aAmount, boolean aMentionPossibleTypos, boolean aNoInvalidAmounts) { + public static ItemStack get( + Object aName, + ItemStack aReplacement, + long aAmount, + boolean aMentionPossibleTypos, + boolean aNoInvalidAmounts) { if (aNoInvalidAmounts && aAmount < 1) return null; if (!sName2StackMap.containsKey(aName.toString()) && aMentionPossibleTypos) GT_Log.err.println("Unknown Key for Unification, Typo? " + aName); - return GT_Utility.copyAmount(aAmount, sName2StackMap.get(aName.toString()), getFirstOre(aName, aAmount), aReplacement); + return GT_Utility.copyAmount( + aAmount, sName2StackMap.get(aName.toString()), getFirstOre(aName, aAmount), aReplacement); } public static ItemStack[] setStackArray(boolean aUseBlackList, ItemStack... aStacks) { @@ -141,18 +155,19 @@ public class GregtechOreDictUnificator { } public static ItemStack get(boolean aUseBlackList, ItemStack aStack, boolean aOnUnificationTableCreation) { - if (GT_Utility.isStackInvalid(aStack)) return null; + if (GT_Utility.isStackInvalid(aStack)) return null; ItemData tPrefixMaterial = getAssociation(aStack); ItemStack rStack = null; - if (tPrefixMaterial == null || !tPrefixMaterial.hasValidPrefixMaterialData() || (aUseBlackList && tPrefixMaterial.mBlackListed)) - return GT_Utility.copy(aStack); + if (tPrefixMaterial == null + || !tPrefixMaterial.hasValidPrefixMaterialData() + || (aUseBlackList && tPrefixMaterial.mBlackListed)) return GT_Utility.copy(aStack); if (aUseBlackList && !GregTech_API.sUnificationEntriesRegistered && isBlacklisted(aStack)) { tPrefixMaterial.mBlackListed = true; return GT_Utility.copy(aStack); } if (tPrefixMaterial.mUnificationTarget == null) { - tPrefixMaterial.mUnificationTarget = sName2StackMap.get(tPrefixMaterial.toString()); - if (!aOnUnificationTableCreation) sUnificationTable.clear(); + tPrefixMaterial.mUnificationTarget = sName2StackMap.get(tPrefixMaterial.toString()); + if (!aOnUnificationTableCreation) sUnificationTable.clear(); } rStack = tPrefixMaterial.mUnificationTarget; if (GT_Utility.isStackInvalid(rStack)) return GT_Utility.copy(aStack); @@ -162,37 +177,37 @@ public class GregtechOreDictUnificator { } public static List<ItemStack> getNonUnifiedStacks(Object obj) { - synchronized (sUnificationTable) { - if (sUnificationTable.isEmpty() && !sItemStack2DataMap.isEmpty()) { - for (GT_ItemStack tGTStack0 : sItemStack2DataMap.keySet()) { - ItemStack tStack0 = tGTStack0.toStack(); - ItemStack tStack1 = get(false, tStack0, true); - if (tStack0 != null && tStack1 != null && !GT_Utility.areStacksEqual(tStack0, tStack1)) { - GT_ItemStack tGTStack1 = new GT_ItemStack(tStack1); - List<ItemStack> list = sUnificationTable.get(tGTStack1); - if (list == null) sUnificationTable.put(tGTStack1, list = new ArrayList<ItemStack>()); - if (!list.contains(tStack0)) list.add(tStack0); - } - } - } - } - ItemStack[] aStacks = {}; - if (obj instanceof ItemStack) aStacks = new ItemStack[]{(ItemStack) obj}; - else if (obj instanceof ItemStack[]) aStacks = (ItemStack[]) obj; - else if (obj instanceof List) aStacks = (ItemStack[]) ((List)obj).toArray(new ItemStack[0]); - List<ItemStack> rList = new ArrayList<ItemStack>(); - for (ItemStack aStack : aStacks) { - rList.add(aStack); - List<ItemStack> tList = sUnificationTable.get(new GT_ItemStack(aStack)); - if (tList != null) { - for (ItemStack tStack : tList) { - ItemStack tStack1 = GT_Utility.copyAmount(aStack.stackSize, tStack); - tStack1.setTagCompound(aStack.getTagCompound()); - rList.add(tStack1); - } - } - } - return rList; + synchronized (sUnificationTable) { + if (sUnificationTable.isEmpty() && !sItemStack2DataMap.isEmpty()) { + for (GT_ItemStack tGTStack0 : sItemStack2DataMap.keySet()) { + ItemStack tStack0 = tGTStack0.toStack(); + ItemStack tStack1 = get(false, tStack0, true); + if (tStack0 != null && tStack1 != null && !GT_Utility.areStacksEqual(tStack0, tStack1)) { + GT_ItemStack tGTStack1 = new GT_ItemStack(tStack1); + List<ItemStack> list = sUnificationTable.get(tGTStack1); + if (list == null) sUnificationTable.put(tGTStack1, list = new ArrayList<ItemStack>()); + if (!list.contains(tStack0)) list.add(tStack0); + } + } + } + } + ItemStack[] aStacks = {}; + if (obj instanceof ItemStack) aStacks = new ItemStack[] {(ItemStack) obj}; + else if (obj instanceof ItemStack[]) aStacks = (ItemStack[]) obj; + else if (obj instanceof List) aStacks = (ItemStack[]) ((List) obj).toArray(new ItemStack[0]); + List<ItemStack> rList = new ArrayList<ItemStack>(); + for (ItemStack aStack : aStacks) { + rList.add(aStack); + List<ItemStack> tList = sUnificationTable.get(new GT_ItemStack(aStack)); + if (tList != null) { + for (ItemStack tStack : tList) { + ItemStack tStack1 = GT_Utility.copyAmount(aStack.stackSize, tStack); + tStack1.setTagCompound(aStack.getTagCompound()); + rList.add(tStack1); + } + } + } + return rList; } public static void addItemData(ItemStack aStack, ItemData aData) { @@ -203,8 +218,9 @@ public class GregtechOreDictUnificator { if (GT_Utility.isStackInvalid(aStack) || aData == null) return; ItemData tData = getItemData(aStack); if (tData == null || !tData.hasValidPrefixMaterialData()) { - if (tData != null) for (Object tObject : tData.mExtraData) - if (!aData.mExtraData.contains(tObject)) aData.mExtraData.add(tObject); + if (tData != null) + for (Object tObject : tData.mExtraData) + if (!aData.mExtraData.contains(tObject)) aData.mExtraData.add(tObject); if (aStack.stackSize > 1) { if (aData.mMaterial != null) aData.mMaterial.mAmount /= aStack.stackSize; for (MaterialStack tMaterial : aData.mByProducts) tMaterial.mAmount /= aStack.stackSize; @@ -212,9 +228,13 @@ public class GregtechOreDictUnificator { } sItemStack2DataMap.put(new GT_ItemStack(aStack), aData); if (aData.hasValidMaterialData()) { - long tValidMaterialAmount = aData.mMaterial.mMaterial.contains(SubTag.NO_RECYCLING) ? 0 : aData.mMaterial.mAmount >= 0 ? aData.mMaterial.mAmount : M; + long tValidMaterialAmount = aData.mMaterial.mMaterial.contains(SubTag.NO_RECYCLING) + ? 0 + : aData.mMaterial.mAmount >= 0 ? aData.mMaterial.mAmount : M; for (MaterialStack tMaterial : aData.mByProducts) - tValidMaterialAmount += tMaterial.mMaterial.contains(SubTag.NO_RECYCLING) ? 0 : tMaterial.mAmount >= 0 ? tMaterial.mAmount : M; + tValidMaterialAmount += tMaterial.mMaterial.contains(SubTag.NO_RECYCLING) + ? 0 + : tMaterial.mAmount >= 0 ? tMaterial.mAmount : M; if (tValidMaterialAmount < M) GT_ModHandler.addToRecyclerBlackList(aStack); } if (mRunThroughTheList) { @@ -222,7 +242,8 @@ public class GregtechOreDictUnificator { mRunThroughTheList = false; for (Entry<GT_ItemStack, ItemData> tEntry : sItemStack2DataMap.entrySet()) if (!tEntry.getValue().hasValidPrefixData() || tEntry.getValue().mPrefix.mAllowNormalRecycling) - GT_RecipeRegistrator.registerMaterialRecycling(tEntry.getKey().toStack(), tEntry.getValue()); + GT_RecipeRegistrator.registerMaterialRecycling( + tEntry.getKey().toStack(), tEntry.getValue()); } } else { if (!aData.hasValidPrefixData() || aData.mPrefix.mAllowNormalRecycling) @@ -234,10 +255,13 @@ public class GregtechOreDictUnificator { } } - public static void addAssociation(OrePrefixes aPrefix, Materials aMaterial, ItemStack aStack, boolean aBlackListed) { + public static void addAssociation( + OrePrefixes aPrefix, Materials aMaterial, ItemStack aStack, boolean aBlackListed) { if (aPrefix == null || aMaterial == null || GT_Utility.isStackInvalid(aStack)) return; - if (Items.feather.getDamage(aStack) == W) for (byte i = 0; i < 16; i++) - setItemData(GT_Utility.copyAmountAndMetaData(1, i, aStack), new ItemData(aPrefix, aMaterial, aBlackListed)); + if (Items.feather.getDamage(aStack) == W) + for (byte i = 0; i < 16; i++) + setItemData( + GT_Utility.copyAmountAndMetaData(1, i, aStack), new ItemData(aPrefix, aMaterial, aBlackListed)); setItemData(aStack, new ItemData(aPrefix, aMaterial, aBlackListed)); } @@ -305,8 +329,7 @@ public class GregtechOreDictUnificator { public static ItemStack getGem(Materials aMaterial, long aMaterialAmount) { ItemStack rStack = null; - if (((aMaterialAmount >= M))) - rStack = get(OrePrefixes.gem, aMaterial, aMaterialAmount / M); + if (((aMaterialAmount >= M))) rStack = get(OrePrefixes.gem, aMaterial, aMaterialAmount / M); if (rStack == null) { if ((((aMaterialAmount * 2) % M == 0) || aMaterialAmount >= M * 16)) rStack = get(OrePrefixes.gemFlawed, aMaterial, (aMaterialAmount * 2) / M); @@ -365,7 +388,10 @@ public class GregtechOreDictUnificator { public static ItemStack getIngotOrDust(MaterialStack aMaterial) { ItemStack rStack = getIngot(aMaterial); - if(aMaterial!=null&&aMaterial.mMaterial!=null&&(aMaterial.mMaterial==Materials.Naquadah||aMaterial.mMaterial==Materials.NaquadahEnriched))rStack = getDust(aMaterial); + if (aMaterial != null + && aMaterial.mMaterial != null + && (aMaterial.mMaterial == Materials.Naquadah || aMaterial.mMaterial == Materials.NaquadahEnriched)) + rStack = getDust(aMaterial); if (rStack == null) rStack = getDust(aMaterial); return rStack; } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/util/SpecialBehaviourTooltipHandler.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/util/SpecialBehaviourTooltipHandler.java index 74655fb744..d03d4da099 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/util/SpecialBehaviourTooltipHandler.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/util/SpecialBehaviourTooltipHandler.java @@ -1,35 +1,33 @@ package gtPlusPlus.xmod.gregtech.api.util; -import java.util.HashMap; - import cpw.mods.fml.common.eventhandler.SubscribeEvent; import gregtech.api.util.GT_Utility; +import java.util.HashMap; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.event.entity.player.ItemTooltipEvent; public class SpecialBehaviourTooltipHandler { - private static final HashMap<ItemStack, String> mTooltipCache = new HashMap<ItemStack, String>(); - - public static void addTooltipForItem(ItemStack aStack, String aTooltip) { - mTooltipCache.put(aStack, aTooltip); - } - - @SubscribeEvent - public void onItemTooltip(ItemTooltipEvent event){ - if (event != null) { - if (event.itemStack != null) { - for (ItemStack aKey : mTooltipCache.keySet()) { - if (GT_Utility.areStacksEqual(aKey, event.itemStack, false)) { - String s = mTooltipCache.get(aKey); - if (s != null && s.length() > 0) { - event.toolTip.add(EnumChatFormatting.RED+s); - } - } - } - } - } - } - + private static final HashMap<ItemStack, String> mTooltipCache = new HashMap<ItemStack, String>(); + + public static void addTooltipForItem(ItemStack aStack, String aTooltip) { + mTooltipCache.put(aStack, aTooltip); + } + + @SubscribeEvent + public void onItemTooltip(ItemTooltipEvent event) { + if (event != null) { + if (event.itemStack != null) { + for (ItemStack aKey : mTooltipCache.keySet()) { + if (GT_Utility.areStacksEqual(aKey, event.itemStack, false)) { + String s = mTooltipCache.get(aKey); + if (s != null && s.length() > 0) { + event.toolTip.add(EnumChatFormatting.RED + s); + } + } + } + } + } + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen.java index 795fd18826..6f58823eb1 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen.java @@ -6,11 +6,10 @@ import java.util.List; import java.util.Map; import java.util.Random; import java.util.concurrent.ConcurrentHashMap; - import net.minecraft.world.World; import net.minecraft.world.chunk.IChunkProvider; -public abstract class GTPP_Worldgen{ +public abstract class GTPP_Worldgen { public final String mWorldGenName; public final boolean mEnabled; @@ -31,7 +30,15 @@ public abstract class GTPP_Worldgen{ * @param aChunkZ zCoord of the Chunk * @return if the Worldgeneration has been successfully completed */ - public boolean executeWorldgen(World aWorld, Random aRandom, String aBiome, int aDimensionType, int aChunkX, int aChunkZ, IChunkProvider aChunkGenerator, IChunkProvider aChunkProvider) { + public boolean executeWorldgen( + World aWorld, + Random aRandom, + String aBiome, + int aDimensionType, + int aChunkX, + int aChunkZ, + IChunkProvider aChunkGenerator, + IChunkProvider aChunkProvider) { return false; } @@ -44,7 +51,15 @@ public abstract class GTPP_Worldgen{ * @param aChunkZ zCoord of the Chunk * @return if the Worldgeneration has been successfully completed */ - public boolean executeCavegen(World aWorld, Random aRandom, String aBiome, int aDimensionType, int aChunkX, int aChunkZ, IChunkProvider aChunkGenerator, IChunkProvider aChunkProvider) { + public boolean executeCavegen( + World aWorld, + Random aRandom, + String aBiome, + int aDimensionType, + int aChunkX, + int aChunkZ, + IChunkProvider aChunkGenerator, + IChunkProvider aChunkProvider) { return false; } @@ -52,10 +67,11 @@ public abstract class GTPP_Worldgen{ String aDimName = aWorld.provider.getDimensionName(); Boolean tAllowed = mDimensionMap.get(aDimName); if (tAllowed == null) { - boolean tValue = sCustomWorldgenFile.get("worldgen.dimensions." + mWorldGenName, aDimName, aDimensionType == aAllowedDimensionType); + boolean tValue = sCustomWorldgenFile.get( + "worldgen.dimensions." + mWorldGenName, aDimName, aDimensionType == aAllowedDimensionType); mDimensionMap.put(aDimName, tValue); return tValue; } return tAllowed; } -}
\ No newline at end of file +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen_Boulder.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen_Boulder.java index ca78a72e04..26f1b38084 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen_Boulder.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen_Boulder.java @@ -1,9 +1,8 @@ package gtPlusPlus.xmod.gregtech.api.world; +import gtPlusPlus.core.lib.CORE; import java.util.Collection; import java.util.Random; - -import gtPlusPlus.core.lib.CORE; import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.util.MathHelper; @@ -11,26 +10,69 @@ import net.minecraft.world.World; import net.minecraft.world.chunk.IChunkProvider; public class GTPP_Worldgen_Boulder extends GTPP_Worldgen_Ore { - public GTPP_Worldgen_Boulder(String aName, boolean aDefault, Block aBlock, int aBlockMeta, int aDimensionType, int aAmount, int aSize, int aProbability, int aMinY, int aMaxY, Collection<String> aBiomeList, boolean aAllowToGenerateinVoid) { - super(aName, aDefault, aBlock, aBlockMeta, aDimensionType, aAmount, aSize, aProbability, aMinY, aMaxY, aBiomeList, aAllowToGenerateinVoid); + public GTPP_Worldgen_Boulder( + String aName, + boolean aDefault, + Block aBlock, + int aBlockMeta, + int aDimensionType, + int aAmount, + int aSize, + int aProbability, + int aMinY, + int aMaxY, + Collection<String> aBiomeList, + boolean aAllowToGenerateinVoid) { + super( + aName, + aDefault, + aBlock, + aBlockMeta, + aDimensionType, + aAmount, + aSize, + aProbability, + aMinY, + aMaxY, + aBiomeList, + aAllowToGenerateinVoid); } @Override - public boolean executeWorldgen(World aWorld, Random aRandom, String aBiome, int aDimensionType, int aChunkX, int aChunkZ, IChunkProvider aChunkGenerator, IChunkProvider aChunkProvider) { - if (isGenerationAllowed(aWorld, aDimensionType, mDimensionType) && (mBiomeList.isEmpty() || mBiomeList.contains(aBiome)) && (mProbability <= 1 || aRandom.nextInt(mProbability) == 0)) { + public boolean executeWorldgen( + World aWorld, + Random aRandom, + String aBiome, + int aDimensionType, + int aChunkX, + int aChunkZ, + IChunkProvider aChunkGenerator, + IChunkProvider aChunkProvider) { + if (isGenerationAllowed(aWorld, aDimensionType, mDimensionType) + && (mBiomeList.isEmpty() || mBiomeList.contains(aBiome)) + && (mProbability <= 1 || aRandom.nextInt(mProbability) == 0)) { for (int i = 0; i < mAmount; i++) { - int tX = aChunkX + aRandom.nextInt(16), tY = mMinY + aRandom.nextInt(mMaxY - mMinY), tZ = aChunkZ + aRandom.nextInt(16); + int tX = aChunkX + aRandom.nextInt(16), + tY = mMinY + aRandom.nextInt(mMaxY - mMinY), + tZ = aChunkZ + aRandom.nextInt(16); Block tBlock = aWorld.getBlock(tX, tY - 7, tZ); - if (tBlock != null && tBlock.isOpaqueCube() && aWorld.getBlock(tX, tY - 6, tZ).isAir(aWorld, tX, tY - 6, tZ)) { + if (tBlock != null + && tBlock.isOpaqueCube() + && aWorld.getBlock(tX, tY - 6, tZ).isAir(aWorld, tX, tY - 6, tZ)) { float math_pi = CORE.PI; float var6 = aRandom.nextFloat() * math_pi; float var1b = mSize / 8.0F; - float var3b = MathHelper.sin(var6) * var1b; float var4b = MathHelper.cos(var6) * var1b; - float var8b = -2*var3b;float var9b = -2*var4b; - int var10b = (tX + 8);int var11b = (tZ + 8); + float var3b = MathHelper.sin(var6) * var1b; + float var4b = MathHelper.cos(var6) * var1b; + float var8b = -2 * var3b; + float var9b = -2 * var4b; + int var10b = (tX + 8); + int var11b = (tZ + 8); float var7 = (var10b + var3b); float var11 = (var11b + var4b); - int var5b = aRandom.nextInt(3);int var6b = aRandom.nextInt(3);int var7b = var6b - var5b; + int var5b = aRandom.nextInt(3); + int var6b = aRandom.nextInt(3); + int var7b = var6b - var5b; float var15 = (tY + var5b - 2); float var12b = math_pi / mSize; @@ -59,7 +101,11 @@ public class GTPP_Worldgen_Boulder extends GTPP_Worldgen_Ore { for (int var44 = var34; var44 <= var37; ++var44) { float var45 = (var44 + 0.5F - var24) / (var28); Block block = aWorld.getBlock(var38, var41, var44); - if (var14b + var45 * var45 < 1.0F && ((mAllowToGenerateinVoid && aWorld.getBlock(var38, var41, var44).isAir(aWorld, var38, var41, var44)) || (block != null && !(block instanceof BlockContainer)))) { + if (var14b + var45 * var45 < 1.0F + && ((mAllowToGenerateinVoid + && aWorld.getBlock(var38, var41, var44) + .isAir(aWorld, var38, var41, var44)) + || (block != null && !(block instanceof BlockContainer)))) { aWorld.setBlock(var38, var41, var44, mBlock, mBlockMeta, 0); } } @@ -74,4 +120,4 @@ public class GTPP_Worldgen_Boulder extends GTPP_Worldgen_Ore { } return false; } -}
\ No newline at end of file +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen_GT_Ore_Layer.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen_GT_Ore_Layer.java index 7cd215aa4e..0dbd354547 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen_GT_Ore_Layer.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen_GT_Ore_Layer.java @@ -2,166 +2,274 @@ package gtPlusPlus.xmod.gregtech.api.world; import static gtPlusPlus.xmod.gregtech.HANDLER_GT.sCustomWorldgenFile; +import gregtech.api.GregTech_API; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Materials; +import gregtech.common.blocks.GT_TileEntity_Ores; +import gregtech.loaders.misc.GT_Achievements; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.material.Material; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Random; - import net.minecraft.util.MathHelper; import net.minecraft.world.World; import net.minecraft.world.chunk.IChunkProvider; -import gregtech.api.GregTech_API; -import gregtech.api.enums.GT_Values; -import gregtech.api.enums.Materials; -import gregtech.common.blocks.GT_TileEntity_Ores; -import gregtech.loaders.misc.GT_Achievements; +public class GTPP_Worldgen_GT_Ore_Layer extends GTPP_Worldgen { + public static ArrayList<GTPP_Worldgen_GT_Ore_Layer> sList = new ArrayList<GTPP_Worldgen_GT_Ore_Layer>(); + public static int sWeight = 0; + public final short mMinY; + public final short mMaxY; + public final short mWeight; + public final short mDensity; + public final short mSize; + public short mPrimaryMeta; + public short mSecondaryMeta; + public short mBetweenMeta; + public short mSporadicMeta; + public final String mRestrictBiome; + public final boolean mDarkWorld; + public final String aTextWorldgen = "worldgen.gtpp."; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.material.Material; + public GTPP_Worldgen_GT_Ore_Layer( + String aName, + boolean aDefault, + int aMinY, + int aMaxY, + int aWeight, + int aDensity, + int aSize, + boolean aOverworld, + Materials aPrimary, + Materials aSecondary, + Materials aBetween, + Materials aSporadic) { + super(aName, sList, aDefault); + this.mDarkWorld = sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Overworld", aOverworld); + this.mMinY = ((short) sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "MinHeight", aMinY)); + this.mMaxY = ((short) Math.max( + this.mMinY + 5, sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "MaxHeight", aMaxY))); + this.mWeight = ((short) sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "RandomWeight", aWeight)); + this.mDensity = ((short) sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Density", aDensity)); + this.mSize = ((short) Math.max(1, sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Size", aSize))); + this.mPrimaryMeta = ((short) sCustomWorldgenFile.get( + aTextWorldgen + this.mWorldGenName, "OrePrimaryLayer", aPrimary.mMetaItemSubID)); + this.mSecondaryMeta = ((short) sCustomWorldgenFile.get( + aTextWorldgen + this.mWorldGenName, "OreSecondaryLayer", aSecondary.mMetaItemSubID)); + this.mBetweenMeta = ((short) sCustomWorldgenFile.get( + aTextWorldgen + this.mWorldGenName, "OreSporadiclyInbetween", aBetween.mMetaItemSubID)); + this.mSporadicMeta = ((short) sCustomWorldgenFile.get( + aTextWorldgen + this.mWorldGenName, "OreSporaticlyAround", aSporadic.mMetaItemSubID)); + this.mRestrictBiome = + sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "RestrictToBiomeName", "None"); -public class GTPP_Worldgen_GT_Ore_Layer -extends GTPP_Worldgen { - public static ArrayList<GTPP_Worldgen_GT_Ore_Layer> sList = new ArrayList<GTPP_Worldgen_GT_Ore_Layer>(); - public static int sWeight = 0; - public final short mMinY; - public final short mMaxY; - public final short mWeight; - public final short mDensity; - public final short mSize; - public short mPrimaryMeta; - public short mSecondaryMeta; - public short mBetweenMeta; - public short mSporadicMeta; - public final String mRestrictBiome; - public final boolean mDarkWorld; - public final String aTextWorldgen = "worldgen.gtpp."; + if (this.mEnabled) { + GT_Achievements.registerOre( + GregTech_API.sGeneratedMaterials[(mPrimaryMeta % 1000)], + aMinY, + aMaxY, + aWeight, + false, + false, + false); + GT_Achievements.registerOre( + GregTech_API.sGeneratedMaterials[(mSecondaryMeta % 1000)], + aMinY, + aMaxY, + aWeight, + false, + false, + false); + GT_Achievements.registerOre( + GregTech_API.sGeneratedMaterials[(mBetweenMeta % 1000)], + aMinY, + aMaxY, + aWeight, + false, + false, + false); + GT_Achievements.registerOre( + GregTech_API.sGeneratedMaterials[(mSporadicMeta % 1000)], + aMinY, + aMaxY, + aWeight, + false, + false, + false); + sWeight += this.mWeight; + } + } - public GTPP_Worldgen_GT_Ore_Layer(String aName, boolean aDefault, int aMinY, int aMaxY, int aWeight, int aDensity, int aSize, boolean aOverworld, Materials aPrimary, Materials aSecondary, Materials aBetween, Materials aSporadic) { - super(aName, sList, aDefault); - this.mDarkWorld = sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Overworld", aOverworld); - this.mMinY = ((short) sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "MinHeight", aMinY)); - this.mMaxY = ((short) Math.max(this.mMinY + 5, sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "MaxHeight", aMaxY))); - this.mWeight = ((short) sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "RandomWeight", aWeight)); - this.mDensity = ((short) sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Density", aDensity)); - this.mSize = ((short) Math.max(1, sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Size", aSize))); - this.mPrimaryMeta = ((short) sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "OrePrimaryLayer", aPrimary.mMetaItemSubID)); - this.mSecondaryMeta = ((short) sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "OreSecondaryLayer", aSecondary.mMetaItemSubID)); - this.mBetweenMeta = ((short) sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "OreSporadiclyInbetween", aBetween.mMetaItemSubID)); - this.mSporadicMeta = ((short) sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "OreSporaticlyAround", aSporadic.mMetaItemSubID)); - this.mRestrictBiome = sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "RestrictToBiomeName", "None"); + public GTPP_Worldgen_GT_Ore_Layer( + String aName, + boolean aDefault, + int aMinY, + int aMaxY, + int aWeight, + int aDensity, + int aSize, + Material aPrimary, + Material aSecondary, + Material aBetween, + Material aSporadic) { + super(aName, sList, aDefault); + this.mDarkWorld = sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Darkworld", true); + this.mMinY = ((short) sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "MinHeight", aMinY)); + this.mMaxY = ((short) Math.max( + this.mMinY + 5, sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "MaxHeight", aMaxY))); + this.mWeight = ((short) sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "RandomWeight", aWeight)); + this.mDensity = ((short) sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Density", aDensity)); + this.mSize = ((short) Math.max(1, sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Size", aSize))); + /*this.mPrimaryMeta = ((short) sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "OrePrimaryLayer", aPrimary.mMetaItemSubID)); + this.mSecondaryMeta = ((short) sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "OreSecondaryLayer", aSecondary.mMetaItemSubID)); + this.mBetweenMeta = ((short) sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "OreSporadiclyInbetween", aBetween.mMetaItemSubID)); + this.mSporadicMeta = ((short) sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "OreSporaticlyAround", aSporadic.mMetaItemSubID)); + */ this.mRestrictBiome = + sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "RestrictToBiomeName", "None"); - if (this.mEnabled) { - GT_Achievements.registerOre(GregTech_API.sGeneratedMaterials[(mPrimaryMeta % 1000)], aMinY, aMaxY, aWeight, false, false, false); - GT_Achievements.registerOre(GregTech_API.sGeneratedMaterials[(mSecondaryMeta % 1000)], aMinY, aMaxY, aWeight, false, false, false); - GT_Achievements.registerOre(GregTech_API.sGeneratedMaterials[(mBetweenMeta % 1000)], aMinY, aMaxY, aWeight, false, false, false); - GT_Achievements.registerOre(GregTech_API.sGeneratedMaterials[(mSporadicMeta % 1000)], aMinY, aMaxY, aWeight, false, false, false); - sWeight += this.mWeight; - } - } + if (this.mEnabled) { + /* GT_Achievements.registerOre(GregTech_API.sGeneratedMaterials[(mPrimaryMeta % 1000)], aMinY, aMaxY, aWeight, false, false, false); + GT_Achievements.registerOre(GregTech_API.sGeneratedMaterials[(mSecondaryMeta % 1000)], aMinY, aMaxY, aWeight, false, false, false); + GT_Achievements.registerOre(GregTech_API.sGeneratedMaterials[(mBetweenMeta % 1000)], aMinY, aMaxY, aWeight, false, false, false); + GT_Achievements.registerOre(GregTech_API.sGeneratedMaterials[(mSporadicMeta % 1000)], aMinY, aMaxY, aWeight, false, false, false); + */ sWeight += this.mWeight; + } + } - public GTPP_Worldgen_GT_Ore_Layer(String aName, boolean aDefault, int aMinY, int aMaxY, int aWeight, int aDensity, - int aSize, Material aPrimary, Material aSecondary, Material aBetween, - Material aSporadic) { - super(aName, sList, aDefault); - this.mDarkWorld = sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Darkworld", true); - this.mMinY = ((short) sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "MinHeight", aMinY)); - this.mMaxY = ((short) Math.max(this.mMinY + 5, sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "MaxHeight", aMaxY))); - this.mWeight = ((short) sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "RandomWeight", aWeight)); - this.mDensity = ((short) sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Density", aDensity)); - this.mSize = ((short) Math.max(1, sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Size", aSize))); - /*this.mPrimaryMeta = ((short) sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "OrePrimaryLayer", aPrimary.mMetaItemSubID)); - this.mSecondaryMeta = ((short) sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "OreSecondaryLayer", aSecondary.mMetaItemSubID)); - this.mBetweenMeta = ((short) sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "OreSporadiclyInbetween", aBetween.mMetaItemSubID)); - this.mSporadicMeta = ((short) sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "OreSporaticlyAround", aSporadic.mMetaItemSubID)); - */this.mRestrictBiome = sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "RestrictToBiomeName", "None"); + @Override + public boolean executeWorldgen( + World aWorld, + Random aRandom, + String aBiome, + int aDimensionType, + int aChunkX, + int aChunkZ, + IChunkProvider aChunkGenerator, + IChunkProvider aChunkProvider) { + if (!this.mRestrictBiome.equals("None") && !(this.mRestrictBiome.equals(aBiome))) { + return false; // Not the correct biome for ore mix + } + if (!isGenerationAllowed( + aWorld, + aDimensionType, + ((aDimensionType == -1) && (false)) + || ((aDimensionType == 0) && (this.mDarkWorld)) + || ((aDimensionType == 1) && (false)) + || ((aWorld.provider.getDimensionName().equals("Moon")) && (false)) + || ((aWorld.provider.getDimensionName().equals("Mars")) && (false)) + ? aDimensionType + : aDimensionType ^ 0xFFFFFFFF)) { + return false; + } + int tMinY = this.mMinY + aRandom.nextInt(this.mMaxY - this.mMinY - 5); - if (this.mEnabled) { - /* GT_Achievements.registerOre(GregTech_API.sGeneratedMaterials[(mPrimaryMeta % 1000)], aMinY, aMaxY, aWeight, false, false, false); - GT_Achievements.registerOre(GregTech_API.sGeneratedMaterials[(mSecondaryMeta % 1000)], aMinY, aMaxY, aWeight, false, false, false); - GT_Achievements.registerOre(GregTech_API.sGeneratedMaterials[(mBetweenMeta % 1000)], aMinY, aMaxY, aWeight, false, false, false); - GT_Achievements.registerOre(GregTech_API.sGeneratedMaterials[(mSporadicMeta % 1000)], aMinY, aMaxY, aWeight, false, false, false); - */ sWeight += this.mWeight; - } - } + int cX = aChunkX - aRandom.nextInt(this.mSize); + int eX = aChunkX + 16 + aRandom.nextInt(this.mSize); + for (int tX = cX; tX <= eX; tX++) { + int cZ = aChunkZ - aRandom.nextInt(this.mSize); + int eZ = aChunkZ + 16 + aRandom.nextInt(this.mSize); + for (int tZ = cZ; tZ <= eZ; tZ++) { + if (this.mSecondaryMeta > 0) { + for (int i = tMinY - 1; i < tMinY + 2; i++) { + if ((aRandom.nextInt(Math.max( + 1, + Math.max(MathHelper.abs_int(cZ - tZ), MathHelper.abs_int(eZ - tZ)) + / this.mDensity)) + == 0) + || (aRandom.nextInt(Math.max( + 1, + Math.max(MathHelper.abs_int(cX - tX), MathHelper.abs_int(eX - tX)) + / this.mDensity)) + == 0)) { + setOreBlock(aWorld, tX, i, tZ, this.mSecondaryMeta, false); + } + } + } + if ((this.mBetweenMeta > 0) + && ((aRandom.nextInt(Math.max( + 1, + Math.max(MathHelper.abs_int(cZ - tZ), MathHelper.abs_int(eZ - tZ)) + / this.mDensity)) + == 0) + || (aRandom.nextInt(Math.max( + 1, + Math.max(MathHelper.abs_int(cX - tX), MathHelper.abs_int(eX - tX)) + / this.mDensity)) + == 0))) { + setOreBlock(aWorld, tX, tMinY + 2 + aRandom.nextInt(2), tZ, this.mBetweenMeta, false); + } + if (this.mPrimaryMeta > 0) { + for (int i = tMinY + 3; i < tMinY + 6; i++) { + if ((aRandom.nextInt(Math.max( + 1, + Math.max(MathHelper.abs_int(cZ - tZ), MathHelper.abs_int(eZ - tZ)) + / this.mDensity)) + == 0) + || (aRandom.nextInt(Math.max( + 1, + Math.max(MathHelper.abs_int(cX - tX), MathHelper.abs_int(eX - tX)) + / this.mDensity)) + == 0)) { + setOreBlock(aWorld, tX, i, tZ, this.mPrimaryMeta, false); + } + } + } + if ((this.mSporadicMeta > 0) + && ((aRandom.nextInt(Math.max( + 1, + Math.max(MathHelper.abs_int(cZ - tZ), MathHelper.abs_int(eZ - tZ)) + / this.mDensity)) + == 0) + || (aRandom.nextInt(Math.max( + 1, + Math.max(MathHelper.abs_int(cX - tX), MathHelper.abs_int(eX - tX)) + / this.mDensity)) + == 0))) { + setOreBlock(aWorld, tX, tMinY - 1 + aRandom.nextInt(7), tZ, this.mSporadicMeta, false); + } + } + } + if (GT_Values.D1) { + System.out.println("Generated Orevein: " + this.mWorldGenName + " " + aChunkX + " " + aChunkZ); + } + return true; + } - @Override - public boolean executeWorldgen(World aWorld, Random aRandom, String aBiome, int aDimensionType, int aChunkX, int aChunkZ, IChunkProvider aChunkGenerator, IChunkProvider aChunkProvider) { - if (!this.mRestrictBiome.equals("None") && !(this.mRestrictBiome.equals(aBiome))) { - return false; //Not the correct biome for ore mix - } - if (!isGenerationAllowed(aWorld, aDimensionType, ((aDimensionType == -1) && (false)) || ((aDimensionType == 0) && (this.mDarkWorld)) || ((aDimensionType == 1) && (false)) || ((aWorld.provider.getDimensionName().equals("Moon")) && (false)) || ((aWorld.provider.getDimensionName().equals("Mars")) && (false)) ? aDimensionType : aDimensionType ^ 0xFFFFFFFF)) { - return false; - } - int tMinY = this.mMinY + aRandom.nextInt(this.mMaxY - this.mMinY - 5); + private Method mSetOre = null; - int cX = aChunkX - aRandom.nextInt(this.mSize); - int eX = aChunkX + 16 + aRandom.nextInt(this.mSize); - for (int tX = cX; tX <= eX; tX++) { - int cZ = aChunkZ - aRandom.nextInt(this.mSize); - int eZ = aChunkZ + 16 + aRandom.nextInt(this.mSize); - for (int tZ = cZ; tZ <= eZ; tZ++) { - if (this.mSecondaryMeta > 0) { - for (int i = tMinY - 1; i < tMinY + 2; i++) { - if ((aRandom.nextInt(Math.max(1, Math.max(MathHelper.abs_int(cZ - tZ), MathHelper.abs_int(eZ - tZ)) / this.mDensity)) == 0) || (aRandom.nextInt(Math.max(1, Math.max(MathHelper.abs_int(cX - tX), MathHelper.abs_int(eX - tX)) / this.mDensity)) == 0)) { - setOreBlock(aWorld, tX, i, tZ, this.mSecondaryMeta, false); - } - } - } - if ((this.mBetweenMeta > 0) && ((aRandom.nextInt(Math.max(1, Math.max(MathHelper.abs_int(cZ - tZ), MathHelper.abs_int(eZ - tZ)) / this.mDensity)) == 0) || (aRandom.nextInt(Math.max(1, Math.max(MathHelper.abs_int(cX - tX), MathHelper.abs_int(eX - tX)) / this.mDensity)) == 0))) { - setOreBlock(aWorld, tX, tMinY + 2 + aRandom.nextInt(2), tZ, this.mBetweenMeta, false); - } - if (this.mPrimaryMeta > 0) { - for (int i = tMinY + 3; i < tMinY + 6; i++) { - if ((aRandom.nextInt(Math.max(1, Math.max(MathHelper.abs_int(cZ - tZ), MathHelper.abs_int(eZ - tZ)) / this.mDensity)) == 0) || (aRandom.nextInt(Math.max(1, Math.max(MathHelper.abs_int(cX - tX), MathHelper.abs_int(eX - tX)) / this.mDensity)) == 0)) { - setOreBlock(aWorld, tX, i, tZ, this.mPrimaryMeta, false); - } - } - } - if ((this.mSporadicMeta > 0) && ((aRandom.nextInt(Math.max(1, Math.max(MathHelper.abs_int(cZ - tZ), MathHelper.abs_int(eZ - tZ)) / this.mDensity)) == 0) || (aRandom.nextInt(Math.max(1, Math.max(MathHelper.abs_int(cX - tX), MathHelper.abs_int(eX - tX)) / this.mDensity)) == 0))) { - setOreBlock(aWorld, tX, tMinY - 1 + aRandom.nextInt(7), tZ, this.mSporadicMeta, false); - } - } - } - if (GT_Values.D1) { - System.out.println("Generated Orevein: " + this.mWorldGenName+" "+aChunkX +" "+ aChunkZ); - } - return true; - } - private Method mSetOre = null; - private boolean setOreBlock(World world, int x, int y, int z, int secondarymeta, boolean bool){ + private boolean setOreBlock(World world, int x, int y, int z, int secondarymeta, boolean bool) { - if (mSetOre == null){ - try { - mSetOre = GT_TileEntity_Ores.class.getMethod("setOreBlock", World.class, int.class, int.class, int.class, int.class, boolean.class); - } - catch (SecurityException | NoSuchMethodException e) { - try { - mSetOre = GT_TileEntity_Ores.class.getMethod("setOreBlock", World.class, int.class, int.class, int.class, int.class); - } - catch (SecurityException | NoSuchMethodException r) {} - } - } + if (mSetOre == null) { + try { + mSetOre = GT_TileEntity_Ores.class.getMethod( + "setOreBlock", World.class, int.class, int.class, int.class, int.class, boolean.class); + } catch (SecurityException | NoSuchMethodException e) { + try { + mSetOre = GT_TileEntity_Ores.class.getMethod( + "setOreBlock", World.class, int.class, int.class, int.class, int.class); + } catch (SecurityException | NoSuchMethodException r) { + } + } + } - if (mSetOre != null) { - if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK){ - try { - return (boolean) mSetOre.invoke(world, x, y, z, secondarymeta, bool); - } - catch (IllegalArgumentException | IllegalAccessException | InvocationTargetException t) { - return false; - } - } - else { - try { - return (boolean) mSetOre.invoke(world, x, y, z, secondarymeta); - } - catch (IllegalArgumentException | IllegalAccessException | InvocationTargetException t) { - return false;} - } - } - else { - return false; - } - } -}
\ No newline at end of file + if (mSetOre != null) { + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { + try { + return (boolean) mSetOre.invoke(world, x, y, z, secondarymeta, bool); + } catch (IllegalArgumentException | IllegalAccessException | InvocationTargetException t) { + return false; + } + } else { + try { + return (boolean) mSetOre.invoke(world, x, y, z, secondarymeta); + } catch (IllegalArgumentException | IllegalAccessException | InvocationTargetException t) { + return false; + } + } + } else { + return false; + } + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen_Handler.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen_Handler.java index aae3bdd48a..b295d5be82 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen_Handler.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen_Handler.java @@ -4,38 +4,52 @@ import static gtPlusPlus.xmod.gregtech.api.world.WorldGenUtils.mOresToRegister; import gtPlusPlus.core.material.Material; -public class GTPP_Worldgen_Handler implements Runnable{ - - - - @Override - public void run() { - - for (GT_OreVein_Object ore : mOresToRegister){ - generateNewVein(ore); - } - - } - - - - private final GTPP_Worldgen_GT_Ore_Layer generateNewVein(final GT_OreVein_Object ore){ - return generateNewVein(ore.mOreMixName, ore.minY, ore.maxY, ore.weight, ore.density, ore.size, ore.aPrimary, ore.aSecondary, ore.aBetween, ore.aSporadic); - } - - private final GTPP_Worldgen_GT_Ore_Layer generateNewVein(String mOreMixName, int minY, int maxY, int weight, int density, int size, - Material aPrimary, Material aSecondary, Material aBetween, Material aSporadic){ - return new GTPP_Worldgen_GT_Ore_Layer( - "ore.mix."+mOreMixName, //String aName, - true, //boolean aDefault, - minY, maxY, //int aMinY, int aMaxY, - weight, //int aWeight, - density, //int aDensity, - size, //int aSize, - aPrimary, //Materials aPrimary, - aSecondary, //Materials aSecondary, - aBetween, //Materials aBetween, - aSporadic); //Materials aSporadic - } - +public class GTPP_Worldgen_Handler implements Runnable { + + @Override + public void run() { + + for (GT_OreVein_Object ore : mOresToRegister) { + generateNewVein(ore); + } + } + + private final GTPP_Worldgen_GT_Ore_Layer generateNewVein(final GT_OreVein_Object ore) { + return generateNewVein( + ore.mOreMixName, + ore.minY, + ore.maxY, + ore.weight, + ore.density, + ore.size, + ore.aPrimary, + ore.aSecondary, + ore.aBetween, + ore.aSporadic); + } + + private final GTPP_Worldgen_GT_Ore_Layer generateNewVein( + String mOreMixName, + int minY, + int maxY, + int weight, + int density, + int size, + Material aPrimary, + Material aSecondary, + Material aBetween, + Material aSporadic) { + return new GTPP_Worldgen_GT_Ore_Layer( + "ore.mix." + mOreMixName, // String aName, + true, // boolean aDefault, + minY, + maxY, // int aMinY, int aMaxY, + weight, // int aWeight, + density, // int aDensity, + size, // int aSize, + aPrimary, // Materials aPrimary, + aSecondary, // Materials aSecondary, + aBetween, // Materials aBetween, + aSporadic); // Materials aSporadic + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen_Ore.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen_Ore.java index 2d7f817060..e93a6c6d38 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen_Ore.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen_Ore.java @@ -2,13 +2,11 @@ package gtPlusPlus.xmod.gregtech.api.world; import static gtPlusPlus.xmod.gregtech.HANDLER_GT.sCustomWorldgenFile; +import gtPlusPlus.xmod.gregtech.HANDLER_GT; import java.util.ArrayList; import java.util.Collection; - import net.minecraft.block.Block; -import gtPlusPlus.xmod.gregtech.HANDLER_GT; - public abstract class GTPP_Worldgen_Ore extends GTPP_Worldgen { public final int mBlockMeta, mAmount, mSize, mMinY, mMaxY, mProbability, mDimensionType; public final Block mBlock; @@ -16,7 +14,19 @@ public abstract class GTPP_Worldgen_Ore extends GTPP_Worldgen { public final boolean mAllowToGenerateinVoid; private final String aTextWorldgen = "worldgen."; - public GTPP_Worldgen_Ore(String aName, boolean aDefault, Block aBlock, int aBlockMeta, int aDimensionType, int aAmount, int aSize, int aProbability, int aMinY, int aMaxY, Collection<String> aBiomeList, boolean aAllowToGenerateinVoid) { + public GTPP_Worldgen_Ore( + String aName, + boolean aDefault, + Block aBlock, + int aBlockMeta, + int aDimensionType, + int aAmount, + int aSize, + int aProbability, + int aMinY, + int aMaxY, + Collection<String> aBiomeList, + boolean aAllowToGenerateinVoid) { super(aName, HANDLER_GT.sCustomWorldgenList, aDefault); mDimensionType = aDimensionType; mBlock = aBlock; @@ -30,4 +40,4 @@ public abstract class GTPP_Worldgen_Ore extends GTPP_Worldgen { else mBiomeList = aBiomeList; mAllowToGenerateinVoid = aAllowToGenerateinVoid; } -}
\ No newline at end of file +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen_Ore_Normal.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen_Ore_Normal.java index e66106ad4a..3f0a6d48c9 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen_Ore_Normal.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen_Ore_Normal.java @@ -1,9 +1,8 @@ package gtPlusPlus.xmod.gregtech.api.world; +import gtPlusPlus.core.lib.CORE; import java.util.Collection; import java.util.Random; - -import gtPlusPlus.core.lib.CORE; import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.util.MathHelper; @@ -11,24 +10,66 @@ import net.minecraft.world.World; import net.minecraft.world.chunk.IChunkProvider; public class GTPP_Worldgen_Ore_Normal extends GTPP_Worldgen_Ore { - public GTPP_Worldgen_Ore_Normal(String aName, boolean aDefault, Block aBlock, int aBlockMeta, int aDimensionType, int aAmount, int aSize, int aProbability, int aMinY, int aMaxY, Collection<String> aBiomeList, boolean aAllowToGenerateinVoid) { - super(aName, aDefault, aBlock, aBlockMeta, aDimensionType, aAmount, aSize, aProbability, aMinY, aMaxY, aBiomeList, aAllowToGenerateinVoid); + public GTPP_Worldgen_Ore_Normal( + String aName, + boolean aDefault, + Block aBlock, + int aBlockMeta, + int aDimensionType, + int aAmount, + int aSize, + int aProbability, + int aMinY, + int aMaxY, + Collection<String> aBiomeList, + boolean aAllowToGenerateinVoid) { + super( + aName, + aDefault, + aBlock, + aBlockMeta, + aDimensionType, + aAmount, + aSize, + aProbability, + aMinY, + aMaxY, + aBiomeList, + aAllowToGenerateinVoid); } @Override - public boolean executeWorldgen(World aWorld, Random aRandom, String aBiome, int aDimensionType, int aChunkX, int aChunkZ, IChunkProvider aChunkGenerator, IChunkProvider aChunkProvider) { - if (isGenerationAllowed(aWorld, aDimensionType, mDimensionType) && (mBiomeList.isEmpty() || mBiomeList.contains(aBiome)) && (mProbability <= 1 || aRandom.nextInt(mProbability) == 0)) { + public boolean executeWorldgen( + World aWorld, + Random aRandom, + String aBiome, + int aDimensionType, + int aChunkX, + int aChunkZ, + IChunkProvider aChunkGenerator, + IChunkProvider aChunkProvider) { + if (isGenerationAllowed(aWorld, aDimensionType, mDimensionType) + && (mBiomeList.isEmpty() || mBiomeList.contains(aBiome)) + && (mProbability <= 1 || aRandom.nextInt(mProbability) == 0)) { for (int i = 0; i < mAmount; i++) { - int tX = aChunkX + aRandom.nextInt(16), tY = mMinY + aRandom.nextInt(mMaxY - mMinY), tZ = aChunkZ + aRandom.nextInt(16); + int tX = aChunkX + aRandom.nextInt(16), + tY = mMinY + aRandom.nextInt(mMaxY - mMinY), + tZ = aChunkZ + aRandom.nextInt(16); if (mAllowToGenerateinVoid || aWorld.getBlock(tX, tY, tZ).isAir(aWorld, tX, tY, tZ)) { - float math_pi = CORE.PI;float var1b = mSize / 8.0F; + float math_pi = CORE.PI; + float var1b = mSize / 8.0F; float var6 = aRandom.nextFloat() * math_pi; - float var3b = MathHelper.sin(var6) * var1b; float var4b = MathHelper.cos(var6) * var1b; - float var8b = -2*var3b;float var9b = -2*var4b; - int var10b = (tX + 8);int var11b = (tZ + 8); + float var3b = MathHelper.sin(var6) * var1b; + float var4b = MathHelper.cos(var6) * var1b; + float var8b = -2 * var3b; + float var9b = -2 * var4b; + int var10b = (tX + 8); + int var11b = (tZ + 8); float var7 = (var10b + var3b); float var11 = (var11b + var4b); - int var5b = aRandom.nextInt(3);int var6b = aRandom.nextInt(3);int var7b = var6b - var5b; + int var5b = aRandom.nextInt(3); + int var6b = aRandom.nextInt(3); + int var7b = var6b - var5b; float var15 = (tY + var5b - 2); float var12b = math_pi / mSize; @@ -57,7 +98,29 @@ public class GTPP_Worldgen_Ore_Normal extends GTPP_Worldgen_Ore { for (int var44 = var34; var44 <= var37; ++var44) { float var45 = (var44 + 0.5F - var24) / (var28); Block block = aWorld.getBlock(var38, var41, var44); - if (var14b + var45 * var45 < 1.0F && ((mAllowToGenerateinVoid && aWorld.getBlock(var38, var41, var44).isAir(aWorld, var38, var41, var44)) || (block != null && (block.isReplaceableOreGen(aWorld, var38, var41, var44, Blocks.stone) || block.isReplaceableOreGen(aWorld, var38, var41, var44, Blocks.end_stone) || block.isReplaceableOreGen(aWorld, var38, var41, var44, Blocks.netherrack))))) { + if (var14b + var45 * var45 < 1.0F + && ((mAllowToGenerateinVoid + && aWorld.getBlock(var38, var41, var44) + .isAir(aWorld, var38, var41, var44)) + || (block != null + && (block.isReplaceableOreGen( + aWorld, + var38, + var41, + var44, + Blocks.stone) + || block.isReplaceableOreGen( + aWorld, + var38, + var41, + var44, + Blocks.end_stone) + || block.isReplaceableOreGen( + aWorld, + var38, + var41, + var44, + Blocks.netherrack))))) { aWorld.setBlock(var38, var41, var44, mBlock, mBlockMeta, 0); } } @@ -72,4 +135,4 @@ public class GTPP_Worldgen_Ore_Normal extends GTPP_Worldgen_Ore { } return false; } -}
\ No newline at end of file +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/world/GT_OreVein_Object.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/world/GT_OreVein_Object.java index 770083fee8..c6e9e6c92a 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/world/GT_OreVein_Object.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/world/GT_OreVein_Object.java @@ -4,28 +4,36 @@ import gtPlusPlus.core.material.Material; public class GT_OreVein_Object { - final String mOreMixName; //String aName, - final int minY, maxY; //int aMinY, int aMaxY, - final int weight; //int aWeight, - final int density; //int aDensity, - final int size; //int aSize, - final Material aPrimary; //Materials aPrimary, - final Material aSecondary; //Materials aSecondary, - final Material aBetween; //Materials aBetween, - final Material aSporadic; //Materials aSporadic - - GT_OreVein_Object(String mOreMixName, int minY, int maxY, int weight, int density, int size, - Material aPrimary, Material aSecondary, Material aBetween, Material aSporadic){ - this.mOreMixName = mOreMixName; - this.minY = minY; - this.maxY = maxY; - this.weight = weight; - this.density = density; - this.size = size; - this.aPrimary = aPrimary; - this.aSecondary = aSecondary; - this.aBetween = aBetween; - this.aSporadic = aSporadic; - } - + final String mOreMixName; // String aName, + final int minY, maxY; // int aMinY, int aMaxY, + final int weight; // int aWeight, + final int density; // int aDensity, + final int size; // int aSize, + final Material aPrimary; // Materials aPrimary, + final Material aSecondary; // Materials aSecondary, + final Material aBetween; // Materials aBetween, + final Material aSporadic; // Materials aSporadic + + GT_OreVein_Object( + String mOreMixName, + int minY, + int maxY, + int weight, + int density, + int size, + Material aPrimary, + Material aSecondary, + Material aBetween, + Material aSporadic) { + this.mOreMixName = mOreMixName; + this.minY = minY; + this.maxY = maxY; + this.weight = weight; + this.density = density; + this.size = size; + this.aPrimary = aPrimary; + this.aSecondary = aSecondary; + this.aBetween = aBetween; + this.aSporadic = aSporadic; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/world/WorldGenUtils.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/world/WorldGenUtils.java index fd0738596a..78f04269cf 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/world/WorldGenUtils.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/world/WorldGenUtils.java @@ -1,23 +1,31 @@ package gtPlusPlus.xmod.gregtech.api.world; +import gtPlusPlus.core.material.Material; import java.util.ArrayList; import java.util.List; -import gtPlusPlus.core.material.Material; - public class WorldGenUtils { - static List<GT_OreVein_Object> mOresToRegister = new ArrayList<GT_OreVein_Object>(); - - public static final void addNewOreMixForWorldgen(GT_OreVein_Object newVein){ - mOresToRegister.add(newVein); - } - - public static boolean generateNewOreVeinObject(String mOreMixName, int minY, int maxY, int weight, int density, int size, - Material aPrimary, Material aSecondary, Material aBetween, Material aSporadic){ - GT_OreVein_Object newVein = new GT_OreVein_Object(mOreMixName, minY, maxY, weight, density, size, aPrimary, aSecondary, aBetween, aSporadic); - addNewOreMixForWorldgen(newVein); - return true; - } - + static List<GT_OreVein_Object> mOresToRegister = new ArrayList<GT_OreVein_Object>(); + + public static final void addNewOreMixForWorldgen(GT_OreVein_Object newVein) { + mOresToRegister.add(newVein); + } + + public static boolean generateNewOreVeinObject( + String mOreMixName, + int minY, + int maxY, + int weight, + int density, + int size, + Material aPrimary, + Material aSecondary, + Material aBetween, + Material aSporadic) { + GT_OreVein_Object newVein = new GT_OreVein_Object( + mOreMixName, minY, maxY, weight, density, size, aPrimary, aSecondary, aBetween, aSporadic); + addNewOreMixForWorldgen(newVein); + return true; + } } |