diff --git a/resources/assets/enderio/lang/en_US.lang b/resources/assets/enderio/lang/en_US.lang index 71d50c75..d5d51839 100644 --- a/resources/assets/enderio/lang/en_US.lang +++ b/resources/assets/enderio/lang/en_US.lang @@ -516,6 +516,7 @@ item.enderio.itemConduitProbe.tooltip.detailed.line5=R-Click to paste them item.enderio.itemConduitProbe.tooltip.detailed.line6=Use Shift-Mouse Wheel or 'Y' to change mode item.itemSoulVessel.name=Soul Vial +enderio.item.itemSoulVessel.tooltip.fluidname=Fluid Name: item.itemSoulVessel.tooltip.detailed.line1=R-Click on a mob to item.itemSoulVessel.tooltip.detailed.line2=capture its soul item.itemSoulVessel.tooltip.detailed.line3=R-Click again to release it @@ -810,6 +811,7 @@ enderio.gui.conduit.gas.autoExtract=Auto Extract //Enchants enchantment.enderio.soulBound=Soulbound +description.enchantment.enderio.soulBound=This enchantment prevents the item from being lost on death //Configuration enderio.config.title=Ender IO Configuration diff --git a/src/main/java/crazypants/enderio/item/ItemSoulVessel.java b/src/main/java/crazypants/enderio/item/ItemSoulVessel.java index f9820c8d..1e2de73b 100644 --- a/src/main/java/crazypants/enderio/item/ItemSoulVessel.java +++ b/src/main/java/crazypants/enderio/item/ItemSoulVessel.java @@ -22,6 +22,8 @@ import net.minecraft.util.Facing; import net.minecraft.util.IIcon; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -31,6 +33,7 @@ import crazypants.enderio.ModObject; import crazypants.enderio.config.Config; import crazypants.enderio.gui.IResourceTooltipProvider; import crazypants.util.EntityUtil; +import crazypants.util.Lang; public class ItemSoulVessel extends Item implements IResourceTooltipProvider { @@ -135,6 +138,10 @@ public class ItemSoulVessel extends Item implements IResourceTooltipProvider { return false; } + if(itemstack.hasDisplayName() && mob instanceof EntityLiving) { + ((EntityLiving)mob).setCustomNameTag(itemstack.getDisplayName()); + } + world.spawnEntityInWorld(mob); if(mob instanceof EntityLiving) { ((EntityLiving)mob).playLivingSound(); @@ -186,11 +193,13 @@ public class ItemSoulVessel extends Item implements IResourceTooltipProvider { entity.writeToNBT(root); ItemStack capturedMobVessel = new ItemStack(EnderIO.itemSoulVessel); + capturedMobVessel.setTagCompound(root); + setDisplayNameFromEntityNameTag(capturedMobVessel, entity); + player.swingItem(); if(!isCreative) { entity.setDead(); if(entity.isDead) { - capturedMobVessel.setTagCompound(root); item.stackSize--; if (!player.inventory.addItemStackToInventory(capturedMobVessel)) { @@ -201,7 +210,6 @@ public class ItemSoulVessel extends Item implements IResourceTooltipProvider { return true; } } else { - capturedMobVessel.setTagCompound(root); if (!player.inventory.addItemStackToInventory(capturedMobVessel)) //Inventory full, drop it in the world! { entity.worldObj.spawnEntityInWorld(new EntityItem(entity.worldObj,entity.posX, entity.posY, entity.posZ, capturedMobVessel)); @@ -231,9 +239,23 @@ public class ItemSoulVessel extends Item implements IResourceTooltipProvider { ItemStack res = new ItemStack(this); res.stackTagCompound = root; + + setDisplayNameFromEntityNameTag(res, ent); return res; } + private void setDisplayNameFromEntityNameTag(ItemStack item, Entity ent) { + if(ent instanceof EntityLiving) { + EntityLiving entLiv = (EntityLiving)ent; + if(entLiv.hasCustomNameTag()) { + String name = entLiv.getCustomNameTag(); + if(name.length() > 0) { + item.setStackDisplayName(name); + } + } + } + } + public boolean containsSoul(ItemStack item) { if(item == null) { return false; @@ -254,6 +276,17 @@ public class ItemSoulVessel extends Item implements IResourceTooltipProvider { return item.stackTagCompound.getString("id"); } + /** Support for displaying fluid name of captured Moo Fluids cow */ + public String getFluidNameFromStack(ItemStack item) { + if(!containsSoul(item)) { + return null; + } + if(item == null || item.stackTagCompound == null || !item.stackTagCompound.hasKey("FluidName")) { + return null; + } + return item.stackTagCompound.getString("FluidName"); + } + private boolean isBlackListed(String entityId) { for (String str : blackList) { if(str != null && str.equals(entityId)) { @@ -278,6 +311,14 @@ public class ItemSoulVessel extends Item implements IResourceTooltipProvider { } else { par3List.add("Empty"); } + + String fluidName = getFluidNameFromStack(par1ItemStack); + if(fluidName != null) { + Fluid fluid = FluidRegistry.getFluid(fluidName); + if(fluid != null) { + par3List.add(Lang.localize("item.itemSoulVessel.tooltip.fluidname") + " " + fluid.getLocalizedName()); + } + } } }