use of net.silentchaos512.lib.util.LocalizationHelper in project SilentGems by SilentChaos512.
the class BlockTeleporter method clOnBlockActivated.
@Override
protected boolean clOnBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
ItemStack heldItem = player.getHeldItem(hand);
boolean holdingLinker = StackHelper.isValid(heldItem) && heldItem.getItem() == ModItems.teleporterLinker;
boolean holdingReturnHome = StackHelper.isValid(heldItem) && heldItem.getItem() == ModItems.returnHomeCharm;
if (world.isRemote) {
return holdingLinker || holdingReturnHome ? true : !isAnchor;
}
TileTeleporter tile = (TileTeleporter) world.getTileEntity(pos);
if (tile == null) {
SilentGems.logHelper.warning("Teleporter tile at " + pos + " not found!");
return false;
}
// Link teleporters with linker.
if (holdingLinker) {
return tile.linkTeleporters(player, world, pos, heldItem, hand);
}
// Link return home charm.
if (holdingReturnHome) {
return tile.linkReturnHomeCharm(player, world, pos, heldItem, hand);
}
// If this is an anchor, we're done.
if (isAnchor) {
return false;
}
LocalizationHelper loc = SilentGems.instance.localizationHelper;
// Destination set?
if (!tile.isDestinationSet()) {
ChatHelper.sendMessage(player, loc.getBlockSubText(Names.TELEPORTER, "NoDestination"));
return true;
}
// Safety checks before teleporting:
if (!tile.isDestinationSane(player)) {
ChatHelper.sendMessage(player, loc.getBlockSubText(Names.TELEPORTER, "NotSane"));
return true;
}
if (!tile.isDestinationSafe(player)) {
ChatHelper.sendMessage(player, loc.getBlockSubText(Names.TELEPORTER, "NotSafe"));
return true;
}
if (!tile.isDestinationAllowedIfDumb(player)) {
ChatHelper.sendMessage(player, loc.getBlockSubText(Names.TELEPORTER, "NoReceiver"));
return true;
}
// Check available charge, drain if there is enough.
if (!tile.checkAndDrainChaos(player)) {
return true;
}
// Teleport player
tile.teleportEntityToDestination(player);
// Play sounds
float pitch = 0.7f + 0.3f * SilentGems.instance.random.nextFloat();
for (BlockPos p : new BlockPos[] { pos, tile.getDestination().toBlockPos() }) {
world.playSound(null, p, SoundEvents.ENTITY_ENDERMEN_TELEPORT, SoundCategory.BLOCKS, 1.0f, pitch);
}
return true;
}
use of net.silentchaos512.lib.util.LocalizationHelper in project SilentGems by SilentChaos512.
the class ItemChaosOrb method clOnItemRightClick.
@Override
protected ActionResult<ItemStack> clOnItemRightClick(World world, EntityPlayer player, EnumHand hand) {
ItemStack stack = player.getHeldItem(hand);
if (player.isSneaking()) {
toggleItemSendEnabled(stack);
boolean mode = isItemSendEnabled(stack);
LocalizationHelper loc = SilentGems.localizationHelper;
String onOrOff = loc.getMiscText("state." + (mode ? "on" : "off"));
onOrOff = (mode ? TextFormatting.GREEN : TextFormatting.RED) + onOrOff;
String line = loc.getItemSubText(Names.CHAOS_ORB, "itemSend", onOrOff);
ChatHelper.sendStatusMessage(player, new TextComponentString(line), true);
}
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
}
use of net.silentchaos512.lib.util.LocalizationHelper in project SilentGems by SilentChaos512.
the class ItemChaosRune method clAddInformation.
@Override
public void clAddInformation(ItemStack stack, World world, List list, boolean advanced) {
ChaosBuff buff = getBuff(stack);
if (buff != null) {
LocalizationHelper loc = SilentGems.localizationHelper;
// Name
TextFormatting nameColor = buff.getPotion() != null && buff.getPotion().isBadEffect() ? TextFormatting.RED : TextFormatting.GOLD;
list.add(nameColor + buff.getLocalizedName(1));
// Description (may not have one)
String desc = " " + buff.getDescription();
if (!desc.isEmpty())
list.add(TextFormatting.DARK_GRAY + desc);
list.add(" " + loc.getItemSubText(itemName, "maxLevel", buff.getMaxLevel()));
list.add(" " + loc.getItemSubText(itemName, "slotsUsed", buff.getSlotsUsed(1)));
String varCost = buff.hasVariableCost() ? loc.getItemSubText(itemName, "variableCost") : "";
list.add(" " + loc.getItemSubText(itemName, "chaosCost", buff.getChaosCost(1, null), varCost));
// Debug
if (KeyTracker.isAltDown()) {
list.add(TextFormatting.DARK_GRAY + String.format("Key: %s", buff.getKey()));
list.add(TextFormatting.DARK_GRAY + String.format("Potion: %s", buff.getPotion()));
list.add(TextFormatting.DARK_GRAY + String.format("Color: %X", buff.getColor()));
}
}
}
use of net.silentchaos512.lib.util.LocalizationHelper in project SilentGems by SilentChaos512.
the class ItemReturnHome method clAddInformation.
@Override
public void clAddInformation(ItemStack stack, World world, List list, boolean par4) {
// Is ctrl key down?
boolean modifier = Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL);
LocalizationHelper loc = SilentGems.instance.localizationHelper;
// How to use
list.addAll(loc.getItemDescriptionLines(itemName));
// Display coordinates if modifier key is held.
DimensionalPosition pos = getBoundPosition(stack);
if (pos != null) {
if (modifier) {
list.add(loc.getItemSubText(itemName, TEXT_BOUND_TO, pos));
} else {
list.add(loc.getMiscText("PressCtrl"));
}
} else {
list.add(loc.getItemSubText(itemName, TEXT_NOT_BOUND));
}
}
use of net.silentchaos512.lib.util.LocalizationHelper in project SilentGems by SilentChaos512.
the class ItemSoulGem method getItemStackDisplayName.
@Override
public String getItemStackDisplayName(ItemStack stack) {
LocalizationHelper loc = SilentGems.localizationHelper;
Soul soul = getSoul(stack);
if (soul == null) {
return getUnlocalizedName(stack);
}
if (StackHelper.isValid(soul.matchStack)) {
return loc.getItemSubText(Names.SOUL_GEM, "name_proper", soul.matchStack.getDisplayName());
} else {
String name = "entity." + soul.id + ".name";
name = loc.getLocalizedString(name);
return loc.getItemSubText(Names.SOUL_GEM, "name_proper", name);
}
}
Aggregations