diff options
| author | Draknyte1 <Draknyte1@hotmail.com> | 2016-09-07 16:36:25 +1000 |
|---|---|---|
| committer | Draknyte1 <Draknyte1@hotmail.com> | 2016-09-07 16:36:25 +1000 |
| commit | 221c2f0fe81430e7dd4087e5f5845bd7c62ec56d (patch) | |
| tree | d6e0faaef01b9d517828557e1be82500d476f95e /src/Java/gtPlusPlus/xmod/gregtech/api | |
| parent | 5872c0947ce7bc788b03fa2fb690b8815d3d0a04 (diff) | |
| download | GT5-Unofficial-221c2f0fe81430e7dd4087e5f5845bd7c62ec56d.tar.gz GT5-Unofficial-221c2f0fe81430e7dd4087e5f5845bd7c62ec56d.tar.bz2 GT5-Unofficial-221c2f0fe81430e7dd4087e5f5845bd7c62ec56d.zip | |
% Refactored the entire project to stop using MiscUtils everywhere possible, now it's gtPlusPlus.
Diffstat (limited to 'src/Java/gtPlusPlus/xmod/gregtech/api')
69 files changed, 16384 insertions, 0 deletions
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/energy/IC2ElectricItem.java b/src/Java/gtPlusPlus/xmod/gregtech/api/energy/IC2ElectricItem.java new file mode 100644 index 0000000000..4ec4589c03 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/energy/IC2ElectricItem.java @@ -0,0 +1,55 @@ +package gtPlusPlus.xmod.gregtech.api.energy; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +/** + * Provides the ability to store energy on the implementing item. + * + * 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); +} + diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/energy/IC2ElectricItemManager.java b/src/Java/gtPlusPlus/xmod/gregtech/api/energy/IC2ElectricItemManager.java new file mode 100644 index 0000000000..311947e5e6 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/energy/IC2ElectricItemManager.java @@ -0,0 +1,95 @@ +package gtPlusPlus.xmod.gregtech.api.energy; + +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.item.ItemStack; + +/** + * This interface specifies a manager to handle the various tasks for electric items. + * + * The default implementation does the following: + * - store and retrieve the charge + * - handle charging, taking amount, tier, transfer limit, canProvideEnergy and simulate into account + * - replace item IDs if appropriate (getChargedItemId() and getEmptyItemId()) + * - update and manage the damage value for the visual charge indicator + * + * @note If you're implementing your own variant (ISpecialElectricItem), you can delegate to the + * default implementations through ElectricItem.rawManager. The default implementation is designed + * to minimize its dependency on its own constraints/structure and delegates most work back to the + * 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); + + /** + * 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 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); + + /** + * 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); + + // TODO: add tier getter +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java new file mode 100644 index 0000000000..81252899e7 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java @@ -0,0 +1,229 @@ +package gtPlusPlus.xmod.gregtech.api.enums; + +import static gregtech.api.enums.GT_Values.W; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.xmod.gregtech.api.interfaces.GregtechItemContainer; +import net.minecraft.block.Block; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.Fluid; + +/** + * Class containing all non-OreDict Items of GregTech. + */ +public enum GregtechItemList implements GregtechItemContainer { + + Energy_Buffer_CREATIVE, + + //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, + + //IronBlastFurnace Machine_Bronze_BlastFurnace + Machine_Iron_BlastFurnace, Casing_IronPlatedBricks, + + //Machine Casings + Casing_Shielding, + + //Large Centrifuge + Industrial_Centrifuge, Casing_Centrifuge1, + + //Coke Oven + Industrial_CokeOven, Casing_CokeOven, Casing_CokeOven_Coil1, Casing_CokeOven_Coil2, + + //Bending Maching // Plate Press // Press + Casing_MaterialPress, Industrial_PlatePress, + + //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, + + //Circuits + Circuit_Primitive, Circuit_Basic, Circuit_Good, Circuit_Advanced, + Circuit_Data, Circuit_Elite, Circuit_Master, Tool_DataOrb, Circuit_Ultimate, 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, + + //Unused Machine Casings + Casing_MacerationStack, Casing_MatterGen, Casing_MatterFab, Casing_U7, + //Unused Machine Coils + Casing_Coil_U1, Casing_Coil_U2, Casing_Coil_U3, Casing_Coil_U4, + + //Windmill Shaft Shape for Extruder + Shape_Extruder_WindmillShaft, + + //Batteries + Battery_RE_EV_Sodium, Battery_RE_EV_Cadmium, Battery_RE_EV_Lithium, + + //Industrial Electrolyzer + Casing_Electrolyzer, Industrial_Electrolyzer, + + //Industrial Maceration Stack + Casing_WireFactory, Industrial_MacerationStack, + + //Industrial Wire Factory + Industrial_WireFactory, + + Industrial_MassFab, + + //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, + + + + Food_Baked_Raisin_Bread, + + + Industrial_SinterFurnace, + + SuperConductorInputNode, + + Casing_Reactor_I, Casing_Reactor_II, + + PowerSubStation, + + GT_Dehydrator_EV, GT_Dehydrator_IV, GT_Dehydrator_LuV, GT_Dehydrator_ZPM; + + public static final GregtechItemList[] + DYE_ONLY_ITEMS = { + Energy_Buffer_1by1_EV, Energy_Buffer_1by1_EV }; + private ItemStack mStack; + private boolean mHasNotBeenSet = true; + + public static Fluid sOilExtraHeavy, sOilHeavy, sOilMedium, sOilLight, sNaturalGas; + + @Override + public GregtechItemList set(Item aItem) { + mHasNotBeenSet = false; + if (aItem == null) return this; + ItemStack aStack = new ItemStack(aItem, 1, 0); + mStack = GT_Utility.copyAmount(1, aStack); + return this; + } + + @Override + public GregtechItemList set(ItemStack aStack) { + mHasNotBeenSet = false; + mStack = GT_Utility.copyAmount(1, aStack); + return this; + } + + @Override + public Item getItem() { + if (mHasNotBeenSet) throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!"); + if (GT_Utility.isStackInvalid(mStack)) return null; + return mStack.getItem(); + } + + @Override + public Block getBlock() { + if (mHasNotBeenSet) throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!"); + return GT_Utility.getBlockFromStack(getItem()); + } + + @Override + public final boolean hasBeenSet() { + return !mHasNotBeenSet; + } + + @Override + public boolean isStackEqual(Object aStack) { + return isStackEqual(aStack, false, false); + } + + @Override + public boolean isStackEqual(Object aStack, boolean aWildcard, boolean aIgnoreNBT) { + if (GT_Utility.isStackInvalid(aStack)) return false; + return GT_Utility.areUnificationsEqual((ItemStack)aStack, aWildcard?getWildcard(1):get(1), aIgnoreNBT); + } + + @Override + public ItemStack get(long aAmount, Object... aReplacements) { + if (mHasNotBeenSet) throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!"); + if (GT_Utility.isStackInvalid(mStack)) return GT_Utility.copyAmount(aAmount, aReplacements); + return GT_Utility.copyAmount(aAmount, GT_OreDictUnificator.get(mStack)); + } |
