Skip to content

Commit

Permalink
lang fix
Browse files Browse the repository at this point in the history
  • Loading branch information
cnlimiter committed May 28, 2022
1 parent 373dac9 commit c034af6
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import net.minecraft.world.inventory.AbstractContainerMenu;
import org.jetbrains.annotations.NotNull;

import java.text.DecimalFormat;
import java.text.NumberFormat;

/**
Expand Down Expand Up @@ -40,6 +41,11 @@ protected static String number(Object number) {
return NumberFormat.getInstance().format(number);
}

protected static String fraction(Object number) {
DecimalFormat df = new DecimalFormat("0.00%");
return df.format(number);
}

@Override
public void render(@NotNull PoseStack matrix, int mouseX, int mouseY, float partialTicks) {
this.renderBackground(matrix);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ public void render(@NotNull PoseStack matrix, int mouseX, int mouseY, float part
List<Component> tooltip = new ArrayList<>();

if (this.getProgress() > 0) {
int i = Mth.clamp(this.getProgress(), 0, this.getTimeRequired());
var text = ModTooltips.PROGRESS.args(number(i) + "%").build();
int i = getProgressBarScaled(1);
var text = ModTooltips.PROGRESS.args(fraction(i)).build();
tooltip.add(text);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/**
* Description:
Expand All @@ -38,7 +39,7 @@
public class HoeInfinityItem extends HoeItem {

public HoeInfinityItem() {
super(Tier.INFINITY_HOE, -10, 17.0f, (new Properties())
super(Tier.INFINITY_HOE, -5, 0f, (new Properties())
.tab(ModTab.TAB)
.stacksTo(1)
.fireResistant());
Expand Down Expand Up @@ -111,7 +112,8 @@ public float getDestroySpeed(@NotNull ItemStack stack, @NotNull BlockState state
}
}
InfinityHandler.stopItemCapture();
ToolHelper.spawnClusters(pLevel, pPlayer, map.keySet());
Set<ItemStack> drops = InfinityHandler.getCapturedDrops();
ToolHelper.spawnClusters(pLevel, pPlayer, drops);
pPlayer.getCooldowns().addCooldown(heldItem.getItem(), 20);
}
pLevel.playSound(pPlayer, pPlayer.getOnPos(), SoundEvents.PLAYER_LEVELUP, SoundSource.PLAYERS, 1.0f, 5.0f);
Expand Down Expand Up @@ -160,7 +162,8 @@ public float getDestroySpeed(@NotNull ItemStack stack, @NotNull BlockState state
}
}
InfinityHandler.stopItemCapture();
ToolHelper.spawnClusters(world, playerentity, map.keySet());
Set<ItemStack> drops = InfinityHandler.getCapturedDrops();
ToolHelper.spawnClusters(world, playerentity, drops);

Iterable<BlockPos> inBoxMutable = BlockPos.betweenClosed(minPos, maxPos.offset(0, 3, 0));
Iterable<BlockPos> allInBoxMutable = BlockPos.betweenClosed(minPos.offset(-1, 0, -1), maxPos.offset(1, 4, 1));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
package nova.committee.avaritia.common.item.tools;

import net.minecraft.ChatFormatting;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.util.Mth;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
Expand All @@ -18,14 +14,11 @@
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.PickaxeItem;
import net.minecraft.world.item.Rarity;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
import net.minecraft.world.item.enchantment.Enchantments;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import nova.committee.avaritia.common.entity.ImmortalItemEntity;
import nova.committee.avaritia.init.config.ModConfig;
import nova.committee.avaritia.init.registry.ModEntities;
Expand All @@ -36,8 +29,6 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;

/**
* Description:
* Author: cnlimiter
Expand Down Expand Up @@ -77,14 +68,6 @@ public int getItemEnchantability(ItemStack stack) {
}


@OnlyIn(Dist.CLIENT)
@Override
public void appendHoverText(@NotNull ItemStack stack, Level worldIn, @NotNull List<Component> tooltip, @NotNull TooltipFlag flagIn) {
if (Screen.hasShiftDown()) {
tooltip.add(new TextComponent(ChatFormatting.GRAY + "由" + ChatFormatting.BLUE + "演变" + "-" + ChatFormatting.DARK_PURPLE + "cnlimiter" + ChatFormatting.YELLOW + "倾情制作~"));
}
}

@Override
public float getDestroySpeed(ItemStack stack, @NotNull BlockState state) {
if (stack.getOrCreateTag().getBoolean("hammer")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,11 +262,22 @@ public static void expCancel(ItemExpireEvent event) {
public static void onTooltip(ItemTooltipEvent event) {
if (event.getItemStack().getItem() instanceof SwordInfinityItem) {
for (int x = 0; x < event.getToolTip().size(); x++) {
if (event.getToolTip().get(x).getString().contains(I18n.get("tooltip.infinity.desc")) || event.getToolTip().get(x).getString().contains("Attack Damage")) {
if (event.getToolTip().get(x).getString().contains(I18n.get("tooltip.infinity.desc")) || event.getToolTip().get(x).getString().equals(I18n.get("attribute.name.generic.attack_damage"))) {
event.getToolTip().set(x, new TextComponent("+").withStyle(ChatFormatting.BLUE).append(new TextComponent(TextUtil.makeFabulous(I18n.get("tooltip.infinity")))).append(" ").append(new TranslatableComponent("tooltip.infinity.desc").withStyle(ChatFormatting.BLUE)));
return;
}
}
} else if (event.getItemStack().getItem() instanceof ArmorInfinityItem) {
for (int x = 0; x < event.getToolTip().size(); x++) {
if (event.getToolTip().get(x).getString().contains(I18n.get("tooltip.armor.desc"))) {
event.getToolTip().set(x, new TextComponent("+").withStyle(ChatFormatting.BLUE).append(new TextComponent(TextUtil.makeFabulous(I18n.get("tooltip.infinity")))).append(" ").append(new TranslatableComponent("tooltip.armor.desc").withStyle(ChatFormatting.BLUE)));
return;
} else if (event.getToolTip().get(x).getString().contains(I18n.get("tooltip.armor_toughness.desc"))) {
event.getToolTip().set(x, new TextComponent("+").withStyle(ChatFormatting.BLUE).append(new TextComponent(TextUtil.makeFabulous(I18n.get("tooltip.infinity")))).append(" ").append(new TranslatableComponent("tooltip.armor_toughness.desc").withStyle(ChatFormatting.BLUE)));
return;
}

}
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/assets/avaritia/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
"tooltip.diamond_lattice.desc": "Dense material...",
"tooltip.infinity": "Infinity",
"tooltip.infinity.desc": "Attack Damage",
"tooltip.armor.desc": "Armor",
"tooltip.armor_toughness.desc": "Armor Toughness",
"tooltip.avaritia.empty": "Empty",
"tooltip.avaritia.eject": "Eject",
"tooltip.avaritia.ejecting": "Ejecting...",
Expand Down
4 changes: 3 additions & 1 deletion src/main/resources/assets/avaritia/lang/ru_ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@
"tooltip.infinity_nugget.desc": "Слёзы ангела...",
"tooltip.diamond_lattice.desc": "Плотный материал...",
"tooltip.infinity": "Бесконечность",
"tooltip.infinity.desc": "Урон от атаки",
"tooltip.infinity.desc": "Урон",
"tooltip.armor.desc": "Броня",
"tooltip.armor_toughness.desc": "Armor Toughness",
"tooltip.avaritia.empty": "Пусто",
"tooltip.avaritia.eject": "Выбросить",
"tooltip.avaritia.ejecting": "Выбрасывание...",
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/assets/avaritia/lang/zh_cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
"tooltip.diamond_lattice.desc": "致密材料...",
"tooltip.infinity": "无限",
"tooltip.infinity.desc": "攻击伤害",
"tooltip.armor.desc": "盔甲",
"tooltip.armor_toughness.desc": "盔甲韧性",
"tooltip.avaritia.empty": "",
"tooltip.avaritia.eject": "弹出",
"tooltip.avaritia.ejecting": "弹出中……",
Expand Down

0 comments on commit c034af6

Please sign in to comment.