BloodMagic/src/main/java/WayofTime/bloodmagic/iface/IActivatable.java

27 lines
750 B
Java
Raw Normal View History

package WayofTime.bloodmagic.iface;
import WayofTime.bloodmagic.util.Constants;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import javax.annotation.Nonnull;
2017-08-15 21:30:48 -07:00
public interface IActivatable {
default boolean getActivated(ItemStack stack) {
return !stack.isEmpty() && stack.hasTagCompound() && stack.getTagCompound().getBoolean(Constants.NBT.ACTIVATED);
}
@Nonnull
default ItemStack setActivatedState(ItemStack stack, boolean activated) {
if (!stack.isEmpty()) {
if (!stack.hasTagCompound())
stack.setTagCompound(new CompoundNBT());
stack.getTagCompound().setBoolean(Constants.NBT.ACTIVATED, activated);
}
return stack;
}
}