use of net.silentchaos512.lib.util.LocalizationHelper in project SilentGems by SilentChaos512.
the class ItemTeleporterLinker method renderGameOverlay.
@SideOnly(Side.CLIENT)
public void renderGameOverlay(RenderGameOverlayEvent event) {
if (event.getType() != ElementType.TEXT) {
return;
}
Minecraft mc = Minecraft.getMinecraft();
EntityPlayer player = mc.player;
ItemStack heldItem = mc.player.getHeldItem(EnumHand.MAIN_HAND);
if (StackHelper.isEmpty(heldItem)) {
heldItem = mc.player.getHeldItem(EnumHand.OFF_HAND);
}
if (StackHelper.isValid(heldItem) && heldItem.getItem() == this) {
ScaledResolution res = new ScaledResolution(mc);
FontRenderer fontRender = mc.fontRenderer;
int width = res.getScaledWidth();
int height = res.getScaledHeight();
String str;
if (isLinked(heldItem)) {
DimensionalPosition pos = getLinkedPosition(heldItem);
double x = pos.x - player.posX;
double z = pos.z - player.posZ;
int distance = (int) Math.sqrt(x * x + z * z);
LocalizationHelper loc = SilentGems.instance.localizationHelper;
str = loc.getItemSubText(itemName, "Distance", distance);
int textX = width / 2 - fontRender.getStringWidth(str) / 2;
int textY = height * 3 / 5;
// Text colored differently depending on situation.
// Outside free range, same dimension
int color = 0xffff00;
if (pos.dim != player.dimension) {
// Different dimension
color = 0xff6600;
str = loc.getItemSubText(itemName, "DifferentDimension");
} else if (distance < GemsConfig.TELEPORTER_FREE_RANGE) {
// Inside free range
color = 0x00aaff;
}
fontRender.drawStringWithShadow(str, textX, textY, color);
}
}
}
use of net.silentchaos512.lib.util.LocalizationHelper in project SilentGems by SilentChaos512.
the class ItemChaosOrb method clAddInformation.
@Override
public void clAddInformation(ItemStack stack, World world, List list, boolean advanced) {
final boolean shifted = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_LSHIFT);
LocalizationHelper loc = SilentGems.instance.localizationHelper;
list.add(loc.getMiscText("ChaosCharge", getCharge(stack), getMaxCharge(stack)));
list.add(loc.getItemSubText(itemName, "breakChance", (int) (getType(stack).breakChance * 100)));
boolean mode = isItemSendEnabled(stack);
String onOrOff = loc.getMiscText("state." + (mode ? "on" : "off"));
onOrOff = (mode ? TextFormatting.GREEN : TextFormatting.RED) + onOrOff;
list.add(loc.getItemSubText(Names.CHAOS_ORB, "itemSend", onOrOff));
if (shifted) {
for (String str : loc.getItemDescriptionLines(itemName)) {
list.add(TextFormatting.ITALIC + str);
}
}
}
use of net.silentchaos512.lib.util.LocalizationHelper in project SilentGems by SilentChaos512.
the class ItemEnchantmentToken method clAddInformation.
// =========================
// Item and ItemSL overrides
// =========================
@Override
public void clAddInformation(ItemStack stack, World world, List list, boolean advanced) {
LocalizationHelper loc = SilentGems.localizationHelper;
Map<Enchantment, Integer> enchants = getEnchantments(stack);
if (enchants.size() == 1) {
Enchantment ench = enchants.keySet().iterator().next();
list.add(loc.getItemSubText(itemName, "maxLevel", ench.getMaxLevel()));
// Recipe info
if (KeyTracker.isControlDown()) {
list.add(loc.getItemSubText(itemName, "materials"));
String recipeString = recipeMap.get(ench);
if (recipeString != null && !recipeString.isEmpty()) {
for (String str : recipeString.split(";")) {
list.add(" " + str);
}
}
} else {
list.add(loc.getItemSubText(itemName, "pressCtrl"));
}
// Debug info
if (KeyTracker.isAltDown()) {
list.add(TextFormatting.DARK_GRAY + ench.getRegistryName().toString());
// list.add(TextFormatting.DARK_GRAY + "EnchID: " + ench.getEnchantmentID(ench));
}
}
// Enchantment list
for (Entry<Enchantment, Integer> entry : enchants.entrySet()) {
Enchantment e = entry.getKey();
String enchName = e.getTranslatedName(entry.getValue());
String modName = Loader.instance().getIndexedModList().get(e.getRegistryName().getResourceDomain()).getName();
list.add(loc.getItemSubText(itemName, "enchNameWithMod", enchName, modName));
String descKey = e.getName().replaceAll(":", ".").toLowerCase() + ".desc";
String desc = loc.getLocalizedString(descKey);
if (!desc.equals(descKey))
list.add(TextFormatting.ITALIC + " " + desc);
}
}
use of net.silentchaos512.lib.util.LocalizationHelper in project SilentGems by SilentChaos512.
the class ItemHoldingGem method clAddInformation.
@Override
public void clAddInformation(ItemStack stack, World world, List list, boolean advanced) {
LocalizationHelper loc = SilentGems.localizationHelper;
IBlockState state = getBlockPlaced(stack);
if (state == null) {
list.addAll(loc.getItemDescriptionLines(itemName));
return;
}
Block block = state.getBlock();
ItemStack placedStack = new ItemStack(Item.getItemFromBlock(block), 1, block.getMetaFromState(state));
list.add(placedStack.getDisplayName());
super.clAddInformation(stack, world, list, advanced);
}
use of net.silentchaos512.lib.util.LocalizationHelper in project SilentGems by SilentChaos512.
the class ItemReturnHome method tryTeleportPlayer.
public void tryTeleportPlayer(ItemStack stack, EntityPlayer player) {
LocalizationHelper loc = SilentGems.localizationHelper;
DimensionalPosition pos = getBoundPosition(stack);
// Not bound?
if (pos == null) {
return;
}
// Enough charge?
if (getCharge(stack) < getTeleportCost(stack, player)) {
ChatHelper.sendMessage(player, loc.getItemSubText(itemName, TEXT_NOT_ENOUGH_CHARGE));
return;
}
// Is the destination sane? (ie, y > 0)
if (pos.y <= 0) {
ChatHelper.sendMessage(player, loc.getItemSubText(itemName, TEXT_NOT_SANE));
return;
}
// Is the destination safe? (ie, no solid block at head level)
WorldServer worldServer = player.getServer().getWorld(pos.dim);
int height = (int) Math.ceil(player.eyeHeight);
BlockPos target = pos.toBlockPos().up(height);
// FIXME: Obstruction checks?
// if (worldServer.isBlockNormalCube(target, true)) {
// PlayerHelper.addChatMessage(player, loc.getItemSubText(itemName, TEXT_NOT_SAFE));
// PlayerHelper.addChatMessage(player, "" + target);
// PlayerHelper.addChatMessage(player, "" + worldServer.getBlockState(target));
// SilentGems.logHelper.warning("Return Home Charm believes destination is obstructed:\n"
// + "Target: " + target + "\nBlockstate: " + worldServer.getBlockState(target));
// return;
// }
// It should be safe to teleport.
// Reset fall distance then teleport.
player.fallDistance = 0.0f;
teleportPlayer(stack, player, pos);
// Play sounds
float soundPitch = 0.8f + 0.3f * SilentGems.random.nextFloat();
for (BlockPos p : new BlockPos[] { player.getPosition(), pos.toBlockPos() }) {
player.world.playSound(null, p, SoundEvents.ENTITY_ENDERMEN_TELEPORT, SoundCategory.PLAYERS, 1.0f, soundPitch);
}
}
Aggregations