Rewrite IBindable to provide an object instead of storing 2 strings
This commit is contained in:
parent
941173dbf4
commit
2a43e53842
47 changed files with 416 additions and 510 deletions
src/main/java/WayofTime/bloodmagic/iface
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue