|
3 | 3 | import net.earthcomputer.clientcommands.TempRules; |
4 | 4 | import net.earthcomputer.clientcommands.command.ClientCommandManager; |
5 | 5 | import net.minecraft.client.MinecraftClient; |
| 6 | +import net.minecraft.client.MinecraftClientGame; |
6 | 7 | import net.minecraft.client.network.ClientPlayerEntity; |
7 | 8 | import net.minecraft.client.resource.language.I18n; |
8 | 9 | import net.minecraft.enchantment.EnchantmentHelper; |
|
11 | 12 | import net.minecraft.item.ArmorItem; |
12 | 13 | import net.minecraft.item.Item; |
13 | 14 | import net.minecraft.item.ItemStack; |
| 15 | +import net.minecraft.network.packet.s2c.play.TitleS2CPacket; |
14 | 16 | import net.minecraft.screen.slot.Slot; |
15 | 17 | import net.minecraft.screen.slot.SlotActionType; |
16 | 18 | import net.minecraft.server.network.ServerPlayerEntity; |
| 19 | +import net.minecraft.sound.SoundEvent; |
| 20 | +import net.minecraft.sound.SoundEvents; |
17 | 21 | import net.minecraft.text.LiteralText; |
| 22 | +import net.minecraft.text.MutableText; |
18 | 23 | import net.minecraft.text.TranslatableText; |
19 | 24 | import net.minecraft.util.Formatting; |
20 | 25 | import net.minecraft.util.StringIdentifiable; |
@@ -186,8 +191,15 @@ public static void onItemDamage(int amount, LivingEntity holder, ItemStack stack |
186 | 191 | onUnbreaking(stack, amount, unbreakingLevel); |
187 | 192 |
|
188 | 193 | if (TempRules.toolBreakWarning && stack.getDamage() + amount >= stack.getMaxDamage() - 30) { |
| 194 | + |
| 195 | + if(stack.getDamage() + amount >= stack.getMaxDamage() - 15){ |
| 196 | + MinecraftClient.getInstance().player.playSound(SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP, 10,0.1f); |
| 197 | + } |
| 198 | + |
| 199 | + MutableText durability = new LiteralText(String.valueOf(stack.getMaxDamage() - stack.getDamage() - 1)).formatted(Formatting.RED); |
| 200 | + |
189 | 201 | MinecraftClient.getInstance().inGameHud.setOverlayMessage( |
190 | | - new TranslatableText("playerManip.toolBreakWarning", stack.getMaxDamage() - stack.getDamage() - 1), |
| 202 | + new TranslatableText("playerManip.toolBreakWarning", durability).formatted(Formatting.GOLD), |
191 | 203 | false); |
192 | 204 | } |
193 | 205 |
|
|
0 commit comments