Removed some redundant stuff for Bindable items, improved inheritance (#1455)

* Added explicit Tooltip for unbound items and restructured Bindable inheritance

- Added a "Item is not bound" tooltip to ItemBindableBase

- Streamlined inheritance. All Sigils now extend ItemBindableBase at some point.

- removed redundant hasTextCompound check

* Removed TextHelper usages in the affected files.

* Nobody likes tooltips.

* Forgot the translation entry.

* Reverted change
This commit is contained in:
Tobias Gremeyer 2019-02-01 02:16:02 +01:00 committed by Nick Ignoffo
parent 95464ca509
commit 05f0bb733b
4 changed files with 10 additions and 23 deletions

View file

@ -3,10 +3,10 @@ package WayofTime.bloodmagic.item;
import WayofTime.bloodmagic.BloodMagic; import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.core.data.Binding; import WayofTime.bloodmagic.core.data.Binding;
import WayofTime.bloodmagic.iface.IBindable; import WayofTime.bloodmagic.iface.IBindable;
import WayofTime.bloodmagic.util.helper.TextHelper;
import net.minecraft.client.util.ITooltipFlag; import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
@ -29,6 +29,6 @@ public class ItemBindableBase extends Item implements IBindable {
Binding binding = getBinding(stack); Binding binding = getBinding(stack);
if (binding != null) if (binding != null)
tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic.currentOwner", binding.getOwnerName())); tooltip.add(new TextComponentTranslation("tooltip.bloodmagic.currentOwner", binding.getOwnerName()).getFormattedText());
} }
} }

View file

@ -1,16 +1,15 @@
package WayofTime.bloodmagic.item.sigil; package WayofTime.bloodmagic.item.sigil;
import WayofTime.bloodmagic.util.Constants;
import WayofTime.bloodmagic.iface.IBindable;
import WayofTime.bloodmagic.iface.ISigil; import WayofTime.bloodmagic.iface.ISigil;
import WayofTime.bloodmagic.item.ItemBindableBase;
import WayofTime.bloodmagic.util.Constants;
import WayofTime.bloodmagic.util.helper.NBTHelper; import WayofTime.bloodmagic.util.helper.NBTHelper;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
/** /**
* Base class for all (static) sigils. * Base class for all (static) sigils.
*/ */
public class ItemSigil extends Item implements IBindable, ISigil { public class ItemSigil extends ItemBindableBase implements ISigil {
private int lpUsed; private int lpUsed;
public ItemSigil(int lpUsed) { public ItemSigil(int lpUsed) {

View file

@ -2,14 +2,15 @@ package WayofTime.bloodmagic.item.sigil;
import WayofTime.bloodmagic.BloodMagic; import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.client.IVariantProvider; import WayofTime.bloodmagic.client.IVariantProvider;
import WayofTime.bloodmagic.core.data.Binding;
import WayofTime.bloodmagic.util.helper.TextHelper; import WayofTime.bloodmagic.util.helper.TextHelper;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import net.minecraft.client.util.ITooltipFlag; import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
import org.apache.commons.lang3.text.WordUtils;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import java.util.Arrays; import java.util.Arrays;
@ -24,7 +25,6 @@ public class ItemSigilBase extends ItemSigil implements IVariantProvider {
super(lpUsed); super(lpUsed);
setUnlocalizedName(BloodMagic.MODID + ".sigil." + name); setUnlocalizedName(BloodMagic.MODID + ".sigil." + name);
setCreativeTab(BloodMagic.TAB_BM);
this.name = name; this.name = name;
this.tooltipBase = "tooltip.bloodmagic.sigil." + name + "."; this.tooltipBase = "tooltip.bloodmagic.sigil." + name + ".";
@ -38,14 +38,7 @@ public class ItemSigilBase extends ItemSigil implements IVariantProvider {
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag) { public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag) {
if (TextHelper.canTranslate(tooltipBase + "desc")) if (TextHelper.canTranslate(tooltipBase + "desc"))
tooltip.addAll(Arrays.asList(TextHelper.cutLongString(TextHelper.localizeEffect(tooltipBase + "desc")))); tooltip.addAll(Arrays.asList(WordUtils.wrap(new TextComponentTranslation(tooltipBase + "desc").getFormattedText(), 30, "/cut", false).split("/cut")));
if (!stack.hasTagCompound())
return;
Binding binding = getBinding(stack);
if (binding != null)
tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic.currentOwner", binding.getOwnerName()));
super.addInformation(stack, world, tooltip, flag); super.addInformation(stack, world, tooltip, flag);
} }

View file

@ -3,11 +3,10 @@ package WayofTime.bloodmagic.item.sigil;
import WayofTime.bloodmagic.BloodMagic; import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.client.IMeshProvider; import WayofTime.bloodmagic.client.IMeshProvider;
import WayofTime.bloodmagic.client.mesh.CustomMeshDefinitionActivatable; import WayofTime.bloodmagic.client.mesh.CustomMeshDefinitionActivatable;
import WayofTime.bloodmagic.core.data.Binding;
import WayofTime.bloodmagic.util.helper.TextHelper;
import net.minecraft.client.renderer.ItemMeshDefinition; import net.minecraft.client.renderer.ItemMeshDefinition;
import net.minecraft.client.util.ITooltipFlag; import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
@ -38,11 +37,7 @@ public class ItemSigilToggleableBase extends ItemSigilToggleable implements IMes
if (!stack.hasTagCompound()) if (!stack.hasTagCompound())
return; return;
tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic." + (getActivated(stack) ? "activated" : "deactivated"))); tooltip.add(new TextComponentTranslation("tooltip.bloodmagic." + (getActivated(stack) ? "activated" : "deactivated")).getFormattedText());
Binding binding = getBinding(stack);
if (binding != null)
tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic.currentOwner", binding.getOwnerName()));
} }
@Override @Override