Allow lang files to specify the location of the fluid name, closes #1386

This commit is contained in:
modmuss50 2017-12-28 14:19:26 +00:00
parent fbd31e1177
commit 751746df6f
No known key found for this signature in database
GPG key ID: 773D17BE8BF49C82
2 changed files with 5 additions and 6 deletions

View file

@ -40,13 +40,10 @@ import net.minecraft.util.EnumHand;
import net.minecraft.util.NonNullList; import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.text.translation.I18n;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.capabilities.ICapabilityProvider; import net.minecraftforge.common.capabilities.ICapabilityProvider;
import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.*;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidUtil;
import net.minecraftforge.fluids.IFluidBlock;
import net.minecraftforge.fluids.capability.IFluidHandlerItem; import net.minecraftforge.fluids.capability.IFluidHandlerItem;
import net.minecraftforge.fluids.capability.templates.FluidHandlerItemStack; import net.minecraftforge.fluids.capability.templates.FluidHandlerItemStack;
import org.apache.commons.lang3.Validate; import org.apache.commons.lang3.Validate;
@ -161,12 +158,13 @@ public class DynamicCell extends Item {
} }
} }
@SuppressWarnings("deprecation")
@Override @Override
public String getItemStackDisplayName(ItemStack stack) { public String getItemStackDisplayName(ItemStack stack) {
FluidStack fluidStack = getFluidHandler(stack).getFluid(); FluidStack fluidStack = getFluidHandler(stack).getFluid();
if (fluidStack == null) if (fluidStack == null)
return super.getItemStackDisplayName(stack); return super.getItemStackDisplayName(stack);
return fluidStack.getLocalizedName() + " Cell"; return I18n.translateToLocal("item.techreborn.cell.fluid.name").replaceAll("\\$fluid\\$", fluidStack.getLocalizedName());
} }
@Override @Override

View file

@ -375,6 +375,7 @@ item.techreborn.dustsmall.diorite.name=Small Pile of Diorite Dust
item.techreborn.dustsmall.granite.name=Small Pile of Granite Dust item.techreborn.dustsmall.granite.name=Small Pile of Granite Dust
item.techreborn.cell.name=Empty Cell item.techreborn.cell.name=Empty Cell
item.techreborn.cell.fluid.name=$fluid$ Cell
item.techreborn.rebattery.name=Battery item.techreborn.rebattery.name=Battery
item.techreborn.lithiumBattery.name=Lithium Battery item.techreborn.lithiumBattery.name=Lithium Battery
item.techreborn.energyCrystal.name=Energy Crystal item.techreborn.energyCrystal.name=Energy Crystal