Remove unnecessary base bindable class

Jarbo 8 exists
This commit is contained in:
Nicholas Ignoffo 2018-02-13 17:24:06 -08:00
parent 3fb708d2be
commit 65b89795bc
5 changed files with 25 additions and 55 deletions

View file

@ -1,5 +1,6 @@
package WayofTime.bloodmagic.apibutnotreally.iface; package WayofTime.bloodmagic.apibutnotreally.iface;
import WayofTime.bloodmagic.apibutnotreally.Constants;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; 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. * Implement this interface on any Item that can be bound to a player.
*/ */
public interface IBindable { public interface IBindable {
/** /**
* Gets the username of the Item's owner. Usually for display, such as in * Gets the username of the Item's owner. Usually for display, such as in
* the tooltip. * the tooltip.
@ -16,7 +18,9 @@ public interface IBindable {
* @param stack - The owned ItemStack * @param stack - The owned ItemStack
* @return - The username of the Item's owner * @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. * Gets the UUID of the Item's owner.
@ -26,7 +30,9 @@ public interface IBindable {
* @param stack - The owned ItemStack * @param stack - The owned ItemStack
* @return - The UUID of the Item's owner * @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. * Called when the player attempts to bind the item.
@ -35,5 +41,7 @@ public interface IBindable {
* @param stack - The ItemStack to attempt binding * @param stack - The ItemStack to attempt binding
* @return If binding was successful. * @return If binding was successful.
*/ */
boolean onBind(EntityPlayer player, ItemStack stack); default boolean onBind(EntityPlayer player, ItemStack stack) {
return true;
}
} }

View file

@ -12,9 +12,14 @@ import javax.annotation.Nonnull;
* Sigils of Holdings. * Sigils of Holdings.
*/ */
public interface ISigil { 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 { interface Holding {
@Nonnull @Nonnull

View file

@ -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;
}
}

View file

@ -1,16 +1,16 @@
package WayofTime.bloodmagic.apibutnotreally.impl; package WayofTime.bloodmagic.apibutnotreally.impl;
import WayofTime.bloodmagic.apibutnotreally.Constants; import WayofTime.bloodmagic.apibutnotreally.Constants;
import WayofTime.bloodmagic.apibutnotreally.iface.IBindable;
import WayofTime.bloodmagic.apibutnotreally.iface.ISigil; import WayofTime.bloodmagic.apibutnotreally.iface.ISigil;
import WayofTime.bloodmagic.apibutnotreally.util.helper.NBTHelper; import WayofTime.bloodmagic.apibutnotreally.util.helper.NBTHelper;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
/** /**
* Base class for all (static) sigils. * Base class for all (static) sigils.
*/ */
public class ItemSigil extends ItemBindable implements ISigil { public class ItemSigil extends Item implements IBindable, ISigil {
private int lpUsed; private int lpUsed;
public ItemSigil(int lpUsed) { public ItemSigil(int lpUsed) {
@ -32,16 +32,6 @@ public class ItemSigil extends ItemBindable implements ISigil {
return stack; return stack;
} }
@Override
public boolean performArrayEffect(World world, BlockPos pos) {
return false;
}
@Override
public boolean hasArrayEffect() {
return false;
}
public int getLpUsed() { public int getLpUsed() {
return lpUsed; return lpUsed;
} }

View file

@ -1,11 +1,12 @@
package WayofTime.bloodmagic.item; package WayofTime.bloodmagic.item;
import WayofTime.bloodmagic.BloodMagic; 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.apibutnotreally.util.helper.PlayerHelper;
import WayofTime.bloodmagic.util.helper.TextHelper; import WayofTime.bloodmagic.util.helper.TextHelper;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import net.minecraft.client.util.ITooltipFlag; import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
@ -13,11 +14,12 @@ import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.List; import java.util.List;
public class ItemBindableBase extends ItemBindable { public class ItemBindableBase extends Item implements IBindable {
public ItemBindableBase() { public ItemBindableBase() {
super(); super();
setCreativeTab(BloodMagic.TAB_BM); setCreativeTab(BloodMagic.TAB_BM);
setMaxStackSize(1);
} }
@Override @Override