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

Class ItemBase

src/main/java/gregapi/item/ItemBase.java:52–129  ·  view source on GitHub ↗

@author Gregorius Techneticies

Source from the content-addressed store, hash-verified

50 * @author Gregorius Techneticies
51 */
52public class ItemBase extends Item implements IItemProjectile, IItemUpdatable, IItemGT, IItemNoGTOverride {
53 protected IIcon mIcon;
54 protected final String mModID;
55 protected final String mName, mTooltip;
56
57 /**
58 * @param aUnlocalized The unlocalised Name of this Item. DO NOT START YOUR UNLOCALISED NAME WITH "gt."!!!
59 */
60 public ItemBase(String aModID, String aUnlocalized, String aEnglish, String aEnglishTooltip) {
61 super();
62 if (GAPI.mStartedInit) throw new IllegalStateException("Items can only be initialised within preInit!");
63 mName = aUnlocalized;
64 mModID = aModID;
65 LH.add(mName, aEnglish);
66 if (UT.Code.stringValid(aEnglishTooltip)) LH.add(mTooltip = mName + ".tooltip_main", aEnglishTooltip); else mTooltip = null;
67 ST.register(this, mName);
68 BlockDispenser.dispenseBehaviorRegistry.putObject(this, new GT_Item_Dispense());
69 }
70
71 @Override
72 @SuppressWarnings("unchecked")
73 public void addInformation(ItemStack aStack, EntityPlayer aPlayer, @SuppressWarnings("rawtypes") List aList, boolean aF3_H) {
74 try {
75 if (getMaxDamage() > 0 && !getHasSubtypes()) aList.add((aStack.getMaxDamage() - getDamage(aStack)) + " / " + aStack.getMaxDamage());
76 if (mTooltip != null) aList.add(LanguageHandler.translate(mTooltip, mTooltip));
77 addAdditionalToolTips(aList, aStack, aF3_H);
78 } catch(Throwable e) {
79 e.printStackTrace(ERR);
80 }
81 while (aList.remove(null));
82 }
83
84 protected void addAdditionalToolTips(List<String> aList, ItemStack aStack, boolean aF3_H) {
85 //
86 }
87
88 public ItemStack onDispense(IBlockSource aSource, ItemStack aStack) {
89 EnumFacing enumfacing = BlockDispenser.func_149937_b(aSource.getBlockMetadata());
90 IPosition iposition = BlockDispenser.func_149939_a(aSource);
91 ItemStack itemstack1 = aStack.splitStack(1);
92 BehaviorDefaultDispenseItem.doDispense(aSource.getWorld(), itemstack1, 6, enumfacing, iposition);
93 return aStack;
94 }
95
96 public static class GT_Item_Dispense extends BehaviorProjectileDispense {
97 @Override
98 public ItemStack dispenseStack(IBlockSource aSource, ItemStack aStack) {
99 return ((ItemBase)aStack.getItem()).onDispense(aSource, aStack);
100 }
101
102 @Override
103 protected IProjectile getProjectileEntity(World aWorld, IPosition aPosition) {
104 return null;
105 }
106 }
107
108 @Override public boolean hasProjectile(TagData aProjectileType, ItemStack aStack) {return F;}
109 @Override public EntityProjectile getProjectile(TagData aProjectileType, ItemStack aStack, World aWorld, double aX, double aY, double aZ) {return null;}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected