Rewrite IBindable to provide an object instead of storing 2 strings

This commit is contained in:
Nicholas Ignoffo 2018-02-27 16:59:51 -08:00
parent 941173dbf4
commit 2a43e53842
47 changed files with 416 additions and 510 deletions
src/main/java/WayofTime/bloodmagic/iface

View file

@ -1,9 +1,26 @@
package WayofTime.bloodmagic.iface;
import WayofTime.bloodmagic.util.Constants;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import javax.annotation.Nonnull;
public interface IActivatable {
boolean getActivated(ItemStack stack);
ItemStack setActivatedState(ItemStack stack, boolean activated);
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 NBTTagCompound());
stack.getTagCompound().setBoolean(Constants.NBT.ACTIVATED, activated);
}
return stack;
}
}