From 65b89795bc3735dccf80478b7eabe12cce29c6d2 Mon Sep 17 00:00:00 2001 From: Nicholas Ignoffo Date: Tue, 13 Feb 2018 17:24:06 -0800 Subject: [PATCH] Remove unnecessary base bindable class Jarbo 8 exists --- .../apibutnotreally/iface/IBindable.java | 14 ++++++-- .../apibutnotreally/iface/ISigil.java | 9 +++-- .../apibutnotreally/impl/ItemBindable.java | 35 ------------------- .../apibutnotreally/impl/ItemSigil.java | 16 ++------- .../bloodmagic/item/ItemBindableBase.java | 6 ++-- 5 files changed, 25 insertions(+), 55 deletions(-) delete mode 100644 src/main/java/WayofTime/bloodmagic/apibutnotreally/impl/ItemBindable.java diff --git a/src/main/java/WayofTime/bloodmagic/apibutnotreally/iface/IBindable.java b/src/main/java/WayofTime/bloodmagic/apibutnotreally/iface/IBindable.java index 19cca36f..37b32d8f 100644 --- a/src/main/java/WayofTime/bloodmagic/apibutnotreally/iface/IBindable.java +++ b/src/main/java/WayofTime/bloodmagic/apibutnotreally/iface/IBindable.java @@ -1,5 +1,6 @@ package WayofTime.bloodmagic.apibutnotreally.iface; +import WayofTime.bloodmagic.apibutnotreally.Constants; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -7,6 +8,7 @@ import net.minecraft.item.ItemStack; * Implement this interface on any Item that can be bound to a player. */ public interface IBindable { + /** * Gets the username of the Item's owner. Usually for display, such as in * the tooltip. @@ -16,7 +18,9 @@ public interface IBindable { * @param stack - The owned ItemStack * @return - The username of the Item's owner */ - String getOwnerName(ItemStack stack); + default String getOwnerName(ItemStack stack) { + return !stack.isEmpty() && stack.hasTagCompound() ? stack.getTagCompound().getString(Constants.NBT.OWNER_NAME) : null; + } /** * Gets the UUID of the Item's owner. @@ -26,7 +30,9 @@ public interface IBindable { * @param stack - The owned ItemStack * @return - The UUID of the Item's owner */ - String getOwnerUUID(ItemStack stack); + default String getOwnerUUID(ItemStack stack) { + return !stack.isEmpty() && stack.hasTagCompound() ? stack.getTagCompound().getString(Constants.NBT.OWNER_UUID) : null; + } /** * Called when the player attempts to bind the item. @@ -35,5 +41,7 @@ public interface IBindable { * @param stack - The ItemStack to attempt binding * @return If binding was successful. */ - boolean onBind(EntityPlayer player, ItemStack stack); + default boolean onBind(EntityPlayer player, ItemStack stack) { + return true; + } } diff --git a/src/main/java/WayofTime/bloodmagic/apibutnotreally/iface/ISigil.java b/src/main/java/WayofTime/bloodmagic/apibutnotreally/iface/ISigil.java index 12f54b04..196aa098 100644 --- a/src/main/java/WayofTime/bloodmagic/apibutnotreally/iface/ISigil.java +++ b/src/main/java/WayofTime/bloodmagic/apibutnotreally/iface/ISigil.java @@ -12,9 +12,14 @@ import javax.annotation.Nonnull; * Sigils of Holdings. */ public interface ISigil { - boolean performArrayEffect(World world, BlockPos pos); - boolean hasArrayEffect(); + default boolean performArrayEffect(World world, BlockPos pos) { + return false; + } + + default boolean hasArrayEffect() { + return false; + } interface Holding { @Nonnull diff --git a/src/main/java/WayofTime/bloodmagic/apibutnotreally/impl/ItemBindable.java b/src/main/java/WayofTime/bloodmagic/apibutnotreally/impl/ItemBindable.java deleted file mode 100644 index 2add8510..00000000 --- a/src/main/java/WayofTime/bloodmagic/apibutnotreally/impl/ItemBindable.java +++ /dev/null @@ -1,35 +0,0 @@ -package WayofTime.bloodmagic.apibutnotreally.impl; - -import WayofTime.bloodmagic.apibutnotreally.Constants; -import WayofTime.bloodmagic.apibutnotreally.iface.IBindable; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; - -/** - * Base class for all bindable items. - */ -public class ItemBindable extends Item implements IBindable { - public ItemBindable() { - super(); - - setMaxStackSize(1); - } - - // IBindable - - @Override - public boolean onBind(EntityPlayer player, ItemStack stack) { - return true; - } - - @Override - public String getOwnerName(ItemStack stack) { - return !stack.isEmpty() && stack.hasTagCompound() ? stack.getTagCompound().getString(Constants.NBT.OWNER_NAME) : null; - } - - @Override - public String getOwnerUUID(ItemStack stack) { - return !stack.isEmpty() && stack.hasTagCompound() ? stack.getTagCompound().getString(Constants.NBT.OWNER_UUID) : null; - } -} diff --git a/src/main/java/WayofTime/bloodmagic/apibutnotreally/impl/ItemSigil.java b/src/main/java/WayofTime/bloodmagic/apibutnotreally/impl/ItemSigil.java index 3d2dbe87..208f2b67 100644 --- a/src/main/java/WayofTime/bloodmagic/apibutnotreally/impl/ItemSigil.java +++ b/src/main/java/WayofTime/bloodmagic/apibutnotreally/impl/ItemSigil.java @@ -1,16 +1,16 @@ package WayofTime.bloodmagic.apibutnotreally.impl; import WayofTime.bloodmagic.apibutnotreally.Constants; +import WayofTime.bloodmagic.apibutnotreally.iface.IBindable; import WayofTime.bloodmagic.apibutnotreally.iface.ISigil; import WayofTime.bloodmagic.apibutnotreally.util.helper.NBTHelper; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; /** * Base class for all (static) sigils. */ -public class ItemSigil extends ItemBindable implements ISigil { +public class ItemSigil extends Item implements IBindable, ISigil { private int lpUsed; public ItemSigil(int lpUsed) { @@ -32,16 +32,6 @@ public class ItemSigil extends ItemBindable implements ISigil { return stack; } - @Override - public boolean performArrayEffect(World world, BlockPos pos) { - return false; - } - - @Override - public boolean hasArrayEffect() { - return false; - } - public int getLpUsed() { return lpUsed; } diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemBindableBase.java b/src/main/java/WayofTime/bloodmagic/item/ItemBindableBase.java index c413e43b..092c1bed 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemBindableBase.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemBindableBase.java @@ -1,11 +1,12 @@ package WayofTime.bloodmagic.item; import WayofTime.bloodmagic.BloodMagic; -import WayofTime.bloodmagic.apibutnotreally.impl.ItemBindable; +import WayofTime.bloodmagic.apibutnotreally.iface.IBindable; import WayofTime.bloodmagic.apibutnotreally.util.helper.PlayerHelper; import WayofTime.bloodmagic.util.helper.TextHelper; import com.google.common.base.Strings; import net.minecraft.client.util.ITooltipFlag; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; @@ -13,11 +14,12 @@ import net.minecraftforge.fml.relauncher.SideOnly; import java.util.List; -public class ItemBindableBase extends ItemBindable { +public class ItemBindableBase extends Item implements IBindable { public ItemBindableBase() { super(); setCreativeTab(BloodMagic.TAB_BM); + setMaxStackSize(1); } @Override