mirror of
https://github.com/GTNewHorizons/BloodMagic.git
synced 2026-11-22 21:09:44 +00:00
Replace a bunch of duplicated checks done for various items with methods in IBindable.
Replace a bunch of duplicated checks for toggling sigils in ISigil. Move static methods from EnergyItems to IBindable so they are more relevant for the bound tools (they don't extend EnergyItems because they need to extend the tool classes).
This commit is contained in:
1 parent
46a8c566d7
commit
b14aded91f
57 files changed
+382
-759
No files matched your search
@@ -1,4 +1,33 @@
|
||||
package WayofTime.alchemicalWizardry.api.items.interfaces;
|
||||
|
||||
public interface ISigil {
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import WayofTime.alchemicalWizardry.common.items.EnergyItems;
|
||||
|
||||
public interface ISigil extends IBindable {
|
||||
|
||||
/**
|
||||
* Toggles the state of the sigil. Returns true if the sigil is active after the toggle or false if it is inactive
|
||||
* after the toggle.
|
||||
*/
|
||||
static boolean toggleSigil(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer, int energyUsed,
|
||||
int tickDelay) {
|
||||
IBindable.setActive(par1ItemStack, !IBindable.isActive(par1ItemStack));
|
||||
|
||||
if (!par3EntityPlayer.capabilities.isCreativeMode
|
||||
&& !EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, energyUsed)) {
|
||||
IBindable.setActive(par1ItemStack, false);
|
||||
}
|
||||
|
||||
if (IBindable.isActive(par1ItemStack) && EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, energyUsed)) {
|
||||
par1ItemStack.setItemDamage(1);
|
||||
IBindable.setDrainTick(par1ItemStack, par2World, tickDelay);
|
||||
return true;
|
||||
} else {
|
||||
par1ItemStack.setItemDamage(par1ItemStack.getMaxDamage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user