Change some int displays to Roman Numerals

May not be 100% accurate if you somehow manage to get these really, really high, but it's good enough.
This commit is contained in:
Nick 2016-04-17 13:51:39 -07:00
parent d71f181729
commit a4f55d88b6
7 changed files with 45 additions and 7 deletions

View file

@ -8,6 +8,7 @@ import java.util.List;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import WayofTime.bloodmagic.util.helper.NumeralHelper;
import mezz.jei.api.recipe.BlankRecipeWrapper;
import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemStack;
@ -30,7 +31,7 @@ public class AltarRecipeJEI extends BlankRecipeWrapper
this.input = input;
this.output = output;
this.infoString = new String[] { TextHelper.localize("jei.BloodMagic.recipe.requiredTier", tier), TextHelper.localize("jei.BloodMagic.recipe.requiredLP", requiredLP) };
this.infoString = new String[] { TextHelper.localize("jei.BloodMagic.recipe.requiredTier", NumeralHelper.toRoman(tier)), TextHelper.localize("jei.BloodMagic.recipe.requiredLP", requiredLP) };
this.consumptionRate = consumptionRate;
this.drainRate = drainRate;
}

View file

@ -8,6 +8,7 @@ import java.util.List;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import WayofTime.bloodmagic.util.helper.NumeralHelper;
import mezz.jei.api.recipe.wrapper.IShapedCraftingRecipeWrapper;
import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemStack;
@ -80,7 +81,7 @@ public class ShapedOrbRecipeJEI implements IShapedCraftingRecipeWrapper
@Override
public void drawInfo(@Nonnull Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY)
{
String draw = TextHelper.localize("jei.BloodMagic.recipe.requiredTier", tier);
String draw = TextHelper.localize("jei.BloodMagic.recipe.requiredTier", NumeralHelper.toRoman(tier));
minecraft.fontRendererObj.drawString(draw, 72 - minecraft.fontRendererObj.getStringWidth(draw) / 2, 10, Color.gray.getRGB());
}

View file

@ -8,6 +8,7 @@ import java.util.List;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import WayofTime.bloodmagic.util.helper.NumeralHelper;
import mezz.jei.api.recipe.wrapper.ICraftingRecipeWrapper;
import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemStack;
@ -68,7 +69,7 @@ public class ShapelessOrbRecipeJEI implements ICraftingRecipeWrapper
@Override
public void drawInfo(@Nonnull Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY)
{
String draw = TextHelper.localize("jei.BloodMagic.recipe.requiredTier", tier);
String draw = TextHelper.localize("jei.BloodMagic.recipe.requiredTier", NumeralHelper.toRoman(tier));
minecraft.fontRendererObj.drawString(draw, 72 - minecraft.fontRendererObj.getStringWidth(draw) / 2, 10, Color.gray.getRGB());
}

View file

@ -3,6 +3,7 @@ package WayofTime.bloodmagic.item;
import java.util.ArrayList;
import java.util.List;
import WayofTime.bloodmagic.util.helper.NumeralHelper;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
@ -76,7 +77,7 @@ public class ItemAltarMaker extends Item implements IAltarManipulator, IVariantP
stack.getTagCompound().setInteger(Constants.NBT.ALTARMAKER_CURRENT_TIER, stack.getTagCompound().getInteger(Constants.NBT.ALTARMAKER_CURRENT_TIER) + 1);
setTierToBuild(EnumAltarTier.values()[stack.getTagCompound().getInteger(Constants.NBT.ALTARMAKER_CURRENT_TIER)]);
ChatUtil.sendNoSpam(player, TextHelper.localizeEffect("chat.BloodMagic.altarMaker.setTier", stack.getTagCompound().getInteger(Constants.NBT.ALTARMAKER_CURRENT_TIER) + 1));
ChatUtil.sendNoSpam(player, TextHelper.localizeEffect("chat.BloodMagic.altarMaker.setTier", NumeralHelper.toRoman(stack.getTagCompound().getInteger(Constants.NBT.ALTARMAKER_CURRENT_TIER) + 1)));
return super.onItemRightClick(stack, world, player, hand);
}
@ -86,7 +87,7 @@ public class ItemAltarMaker extends Item implements IAltarManipulator, IVariantP
if (mop.typeOfHit == RayTraceResult.Type.BLOCK && world.getBlockState(mop.getBlockPos()).getBlock() instanceof BlockAltar)
{
ChatUtil.sendNoSpam(player, TextHelper.localizeEffect("chat.BloodMagic.altarMaker.building", tierToBuild));
ChatUtil.sendNoSpam(player, TextHelper.localizeEffect("chat.BloodMagic.altarMaker.building", NumeralHelper.toRoman(tierToBuild.toInt())));
buildAltar(world, mop.getBlockPos());
IBlockState state = world.getBlockState(mop.getBlockPos());

View file

@ -3,6 +3,7 @@ package WayofTime.bloodmagic.item.sigil;
import java.util.ArrayList;
import java.util.List;
import WayofTime.bloodmagic.util.helper.NumeralHelper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
@ -57,7 +58,7 @@ public class ItemSigilDivination extends ItemSigilBase implements IAltarReader
int currentEssence = altar.getCurrentBlood();
int capacity = altar.getCapacity();
altar.checkTier();
ChatUtil.sendNoSpam(player, new TextComponentTranslation(tooltipBase + "currentAltarTier", tier), new TextComponentTranslation(tooltipBase + "currentEssence", currentEssence), new TextComponentTranslation(tooltipBase + "currentAltarCapacity", capacity));
ChatUtil.sendNoSpam(player, new TextComponentTranslation(tooltipBase + "currentAltarTier", NumeralHelper.toRoman(tier)), new TextComponentTranslation(tooltipBase + "currentEssence", currentEssence), new TextComponentTranslation(tooltipBase + "currentAltarCapacity", capacity));
} else if (tile != null && tile instanceof TileIncenseAltar)
{
TileIncenseAltar altar = (TileIncenseAltar) tile;

View file

@ -3,6 +3,7 @@ package WayofTime.bloodmagic.item.sigil;
import java.util.ArrayList;
import java.util.List;
import WayofTime.bloodmagic.util.helper.NumeralHelper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
@ -70,7 +71,7 @@ public class ItemSigilSeer extends ItemSigilBase implements IAltarReader
ChatUtil.sendNoSpam(player, new TextComponentTranslation(tooltipBase + "currentAltarProgress", progress, totalLiquidRequired), new TextComponentTranslation(tooltipBase + "currentAltarConsumptionRate", consumptionRate), new TextComponentTranslation(tooltipBase + "currentAltarTier", tier), new TextComponentTranslation(tooltipBase + "currentEssence", currentEssence), new TextComponentTranslation(tooltipBase + "currentAltarCapacity", capacity), new TextComponentTranslation(tooltipBase + "currentCharge", charge));
} else
{
ChatUtil.sendNoSpam(player, new TextComponentTranslation(tooltipBase + "currentAltarTier", tier), new TextComponentTranslation(tooltipBase + "currentEssence", currentEssence), new TextComponentTranslation(tooltipBase + "currentAltarCapacity", capacity), new TextComponentTranslation(tooltipBase + "currentCharge", charge));
ChatUtil.sendNoSpam(player, new TextComponentTranslation(tooltipBase + "currentAltarTier", NumeralHelper.toRoman(tier)), new TextComponentTranslation(tooltipBase + "currentEssence", currentEssence), new TextComponentTranslation(tooltipBase + "currentAltarCapacity", capacity), new TextComponentTranslation(tooltipBase + "currentCharge", charge));
}
}
} else if (tile != null && tile instanceof TileIncenseAltar)

View file

@ -0,0 +1,32 @@
package WayofTime.bloodmagic.util.helper;
import java.util.TreeMap;
public class NumeralHelper {
private static final TreeMap<Integer, String> romanNumerals = new TreeMap<Integer, String>();
static {
romanNumerals.put(1000, "M" );
romanNumerals.put(900 , "CM");
romanNumerals.put(500 , "D" );
romanNumerals.put(400 , "CD");
romanNumerals.put(100 , "C" );
romanNumerals.put(90 , "XC");
romanNumerals.put(50 , "L" );
romanNumerals.put(40 , "XL");
romanNumerals.put(10 , "X" );
romanNumerals.put(9 , "IX");
romanNumerals.put(5 , "V" );
romanNumerals.put(4 , "IV");
romanNumerals.put(1 , "I" );
}
public static String toRoman(int arabic) {
int convert = romanNumerals.floorKey(arabic);
if (arabic == convert)
return romanNumerals.get(convert);
return romanNumerals.get(convert) + toRoman(arabic - convert);
}
}