|
7 | 7 | import de.hysky.skyblocker.skyblock.tabhud.widget.component.ProgressComponent;
|
8 | 8 | import de.hysky.skyblocker.utils.ItemUtils;
|
9 | 9 | import net.minecraft.client.MinecraftClient;
|
| 10 | +import net.minecraft.entity.Entity; |
10 | 11 | import net.minecraft.item.ItemStack;
|
11 | 12 | import net.minecraft.text.MutableText;
|
12 | 13 | import net.minecraft.text.Text;
|
@@ -49,18 +50,19 @@ public FarmingHudWidget() {
|
49 | 50 | update();
|
50 | 51 | }
|
51 | 52 |
|
52 |
| - @SuppressWarnings("DataFlowIssue") |
53 | 53 | @Override
|
54 | 54 | public void updateContent() {
|
55 |
| - ItemStack icon = FARMING_TOOLS.getOrDefault(ItemUtils.getItemId(client.player.getMainHandStack()), Ico.HOE); |
| 55 | + ItemStack icon = client.player == null ? Ico.HOE : FARMING_TOOLS.getOrDefault(ItemUtils.getItemId(client.player.getMainHandStack()), Ico.HOE); |
56 | 56 | addSimpleIcoText(icon, "Counter: ", Formatting.YELLOW, FarmingHud.NUMBER_FORMAT.format(FarmingHud.counter()));
|
57 | 57 | addSimpleIcoText(icon, "Crops/min: ", Formatting.YELLOW, FarmingHud.NUMBER_FORMAT.format((int) FarmingHud.cropsPerMinute() / 100 * 100));
|
58 | 58 | addSimpleIcoText(icon, "Blocks/s: ", Formatting.YELLOW, Integer.toString(FarmingHud.blockBreaks()));
|
| 59 | + //noinspection DataFlowIssue |
59 | 60 | addComponent(new ProgressComponent(Ico.LANTERN, Text.literal("Farming Level: "), FarmingHud.farmingXpPercentProgress(), Formatting.GOLD.getColorValue()));
|
60 | 61 | addSimpleIcoText(Ico.LIME_DYE, "Farming XP/h: ", Formatting.YELLOW, FarmingHud.NUMBER_FORMAT.format((int) FarmingHud.farmingXpPerHour()));
|
61 | 62 |
|
62 |
| - double yaw = client.getCameraEntity().getYaw(); |
63 |
| - double pitch = client.getCameraEntity().getPitch(); |
| 63 | + Entity cameraEntity = client.getCameraEntity(); |
| 64 | + double yaw = cameraEntity == null ? 0.0d : cameraEntity.getYaw(); |
| 65 | + double pitch = cameraEntity == null ? 0.0d : cameraEntity.getPitch(); |
64 | 66 | addComponent(new PlainTextComponent(Text.literal("Yaw: " + String.format("%.3f", MathHelper.wrapDegrees(yaw))).formatted(Formatting.YELLOW)));
|
65 | 67 | addComponent(new PlainTextComponent(Text.literal("Pitch: " + String.format("%.3f", MathHelper.wrapDegrees(pitch))).formatted(Formatting.YELLOW)));
|
66 | 68 | }
|
|
0 commit comments