Big item refactor (#73)

Co-authored-by: Maya <[email protected]>
This commit is contained in:
koolkrafter5andMaya authored and GitHub committed 2025-05-07 15:43:45 +00:00
1 parent e75e9f778a
commit 9f2d0b5241
66 files changed
+731 -1429

No files matched your search

@@ -33,6 +33,7 @@ public class BoundPickaxe extends ItemPickaxe implements IBindable {
public float efficiencyOnProperMaterial = 12.0F;
public float damageVsEntity;
public int rightClickCost = 10000;
@SideOnly(Side.CLIENT)
private IIcon activeIcon;
@@ -60,24 +61,16 @@ public class BoundPickaxe extends ItemPickaxe implements IBindable {
return this.energyUsed;
}
@Override
public int drainCost() {
return this.energyUsed;
}
@Override
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) {
par3List.add(StatCollector.translateToLocal("tooltip.boundpickaxe.desc1"));
par3List.add(StatCollector.translateToLocal("tooltip.boundpickaxe.desc2"));
if (!(par1ItemStack.getTagCompound() == null)) {
if (par1ItemStack.getTagCompound().getBoolean("isActive")) {
par3List.add(StatCollector.translateToLocal("tooltip.sigil.state.activated"));
} else {
par3List.add(StatCollector.translateToLocal("tooltip.sigil.state.deactivated"));
}
if (!par1ItemStack.getTagCompound().getString("ownerName").equals("")) {
par3List.add(
StatCollector.translateToLocal("tooltip.owner.currentowner") + " "
+ par1ItemStack.getTagCompound().getString("ownerName"));
}
}
addBindingInformation(par1ItemStack, par3List);
}
@Override
@@ -90,13 +83,7 @@ public class BoundPickaxe extends ItemPickaxe implements IBindable {
@Override
public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) {
if (stack.getTagCompound() == null) {
stack.setTagCompound(new NBTTagCompound());
}
NBTTagCompound tag = stack.getTagCompound();
if (tag.getBoolean("isActive")) {
if (IBindable.isActive(stack)) {
return this.activeIcon;
} else {
return this.passiveIcon;
@@ -105,32 +92,9 @@ public class BoundPickaxe extends ItemPickaxe implements IBindable {
@Override
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
if (!EnergyItems.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer) || par3EntityPlayer.isSneaking()) {
this.setActivated(par1ItemStack, !getActivated(par1ItemStack));
par1ItemStack.getTagCompound().setInteger("worldTimeDelay", (int) (par2World.getWorldTime() - 1) % 200);
if (checkRightClick(par1ItemStack, par2World, par3EntityPlayer)) {
return par1ItemStack;
}
if (par2World.isRemote) {
return par1ItemStack;
}
if (!getActivated(par1ItemStack) || SpellHelper.isFakePlayer(par2World, par3EntityPlayer)) {
return par1ItemStack;
}
if (AlchemicalWizardry.disableBoundToolsRightClick) {
return par1ItemStack;
}
if (par3EntityPlayer.isPotionActive(AlchemicalWizardry.customPotionInhibit)) {
return par1ItemStack;
}
if (!EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, 10000)) {
return par1ItemStack;
}
Vec3 blockVec = SpellHelper.getEntityBlockVector(par3EntityPlayer);
int posX = (int) (blockVec.xCoord);
int posY = (int) (blockVec.yCoord);
@@ -203,38 +167,11 @@ public class BoundPickaxe extends ItemPickaxe implements IBindable {
par1ItemStack.setTagCompound(new NBTTagCompound());
}
if (par2World.getWorldTime() % 200 == par1ItemStack.getTagCompound().getInteger("worldTimeDelay")
&& par1ItemStack.getTagCompound().getBoolean("isActive")) {
if (!par3EntityPlayer.capabilities.isCreativeMode) {
if (!EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, 20)) {
this.setActivated(par1ItemStack, false);
}
}
}
checkPassiveDrain(par1ItemStack, par2World, par3EntityPlayer);
par1ItemStack.setItemDamage(0);
}
public void setActivated(ItemStack par1ItemStack, boolean newActivated) {
NBTTagCompound itemTag = par1ItemStack.getTagCompound();
if (itemTag == null) {
par1ItemStack.setTagCompound(new NBTTagCompound());
}
itemTag.setBoolean("isActive", newActivated);
}
public boolean getActivated(ItemStack par1ItemStack) {
if (!par1ItemStack.hasTagCompound()) {
par1ItemStack.setTagCompound(new NBTTagCompound());
}
NBTTagCompound itemTag = par1ItemStack.getTagCompound();
return itemTag.getBoolean("isActive");
}
/**
* Returns the strength of the stack against a given block. 1.0F base, (Quality+1)*2 if correct blocktype, 1.5F if
* sword
@@ -242,7 +179,7 @@ public class BoundPickaxe extends ItemPickaxe implements IBindable {
@Override
public float func_150893_a(ItemStack par1ItemStack, Block par2Block) // getStrVsBlock
{
if (!getActivated(par1ItemStack)) {
if (!IBindable.isActive(par1ItemStack)) {
return 0.0F;
}
@@ -253,9 +190,10 @@ public class BoundPickaxe extends ItemPickaxe implements IBindable {
* Current implementations of this method in child classes do not use the entry argument beside ev. They just raise
* the damage on the stack.
*/
@Override
public boolean hitEntity(ItemStack par1ItemStack, EntityLivingBase par2EntityLivingBase,
EntityLivingBase par3EntityLivingBase) {
return getActivated(par1ItemStack);
return IBindable.isActive(par1ItemStack);
}
@Override
@@ -263,7 +201,7 @@ public class BoundPickaxe extends ItemPickaxe implements IBindable {
EntityLivingBase par7EntityLivingBase) {
if (par7EntityLivingBase instanceof EntityPlayer) {
EnergyItems.syphonBatteries(par1ItemStack, (EntityPlayer) par7EntityLivingBase, getEnergyUsed());
EnergyItems.syphonBatteries(par1ItemStack, (EntityPlayer) par7EntityLivingBase, drainCost());
}
return true;
}
@@ -290,7 +228,7 @@ public class BoundPickaxe extends ItemPickaxe implements IBindable {
*/
@Override
public float getDigSpeed(ItemStack stack, Block block, int meta) {
if (!getActivated(stack)) {
if (!IBindable.isActive(stack)) {
return 0.0F;
}
@@ -303,11 +241,21 @@ public class BoundPickaxe extends ItemPickaxe implements IBindable {
@Override
public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) {
return !getActivated(stack);
return !IBindable.isActive(stack);
}
@Override
public int getHarvestLevel(ItemStack stack, String toolClass) {
return getActivated(stack) ? super.getHarvestLevel(stack, toolClass) : -1;
return IBindable.isActive(stack) ? super.getHarvestLevel(stack, toolClass) : -1;
}
@Override
public boolean isBoundTool() {
return true;
}
@Override
public int rightClickCost() {
return rightClickCost;
}
}