MCPcopy Create free account
hub / github.com/GregTech6/gregtech6 / MultiItem

Class MultiItem

src/main/java/gregapi/item/multiitem/MultiItem.java:57–552  ·  view source on GitHub ↗

@author Gregorius Techneticies For Custom Items.

Source from the content-addressed store, hash-verified

55 * For Custom Items.
56 */
57@Optional.InterfaceList(value = {
58 @Optional.Interface(iface = "ic2.api.item.ISpecialElectricItem", modid = ModIDs.IC2)
59, @Optional.Interface(iface = "ic2.api.item.IElectricItemManager", modid = ModIDs.IC2)
60, @Optional.Interface(iface = "micdoodle8.mods.galacticraft.api.item.IItemElectric", modid = ModIDs.GC)
61})
62public abstract class MultiItem extends ItemBase implements IItemEnergy {
63 public final HashMap<Short, ArrayList<IBehavior<MultiItem>>> mItemBehaviors = new HashMap<>();
64
65 public final HashMap<Short, Long[]> mFluidContainerStats = new HashMap<>();
66
67 /**
68 * Creates the Item using these Parameters.
69 * @param aUnlocalized The Unlocalized Name of this Item. DO NOT START YOUR UNLOCALISED NAME WITH "gt."!!!
70 */
71 public MultiItem(String aModID, String aUnlocalized) {
72 super(aModID, aUnlocalized, "Generated Item", null);
73 setHasSubtypes(T);
74 setMaxDamage(0);
75 }
76
77 /**
78 * Adds a special Item Behaviour to the Item.
79 *
80 * Note: the boolean Behaviours sometimes won't be executed if another boolean Behaviour returned true before.
81 *
82 * @param aMeta the Meta Value of the Item you want to add it to. [0 - 32766]
83 * @param aBehavior the Click Behavior you want to add.
84 * @return the Item itself for convenience in constructing.
85 */
86 public MultiItem addItemBehavior(int aMeta, IBehavior<MultiItem> aBehavior) {
87 if (aMeta < 0 || aMeta >= 32767 || aBehavior == null) return this;
88 ArrayList<IBehavior<MultiItem>> tList = mItemBehaviors.get((short)aMeta);
89 if (tList == null) {
90 tList = new ArrayListNoNulls<>();
91 mItemBehaviors.put((short)aMeta, tList);
92 }
93 tList.add(aBehavior);
94 return this;
95 }
96 public MultiItem addItemBehavior(IBehavior<MultiItem> aBehavior, int... aMetas) {
97 for (int aMeta : aMetas) addItemBehavior(aMeta, aBehavior);
98 return this;
99 }
100
101 @Override
102 public boolean hasProjectile(TagData aProjectileType, ItemStack aStack) {
103 ArrayList<IBehavior<MultiItem>> tList = mItemBehaviors.get(ST.meta_(aStack));
104 if (tList != null) for (IBehavior<MultiItem> tBehavior : tList) if (tBehavior.hasProjectile(this, aProjectileType, aStack)) return T;
105 return super.hasProjectile(aProjectileType, aStack);
106 }
107
108 @Override
109 public EntityProjectile getProjectile(TagData aProjectileType, ItemStack aStack, World aWorld, double aX, double aY, double aZ) {
110 ArrayList<IBehavior<MultiItem>> tList = mItemBehaviors.get(ST.meta_(aStack));
111 if (tList != null) for (IBehavior<MultiItem> tBehavior : tList) {
112 EntityProjectile rArrow = tBehavior.getProjectile(this, aProjectileType, aStack, aWorld, aX, aY, aZ);
113 if (rArrow != null) return rArrow;
114 }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected