Skip to content

Commit 04ffc8b

Browse files
Merge pull request #610 from viciscat/fix-issue-609
Fix #609
2 parents c7f9e5f + dfc6b4b commit 04ffc8b

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/main/java/de/hysky/skyblocker/skyblock/garden/FarmingHudWidget.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import de.hysky.skyblocker.skyblock.tabhud.widget.component.ProgressComponent;
88
import de.hysky.skyblocker.utils.ItemUtils;
99
import net.minecraft.client.MinecraftClient;
10+
import net.minecraft.entity.Entity;
1011
import net.minecraft.item.ItemStack;
1112
import net.minecraft.text.MutableText;
1213
import net.minecraft.text.Text;
@@ -49,18 +50,19 @@ public FarmingHudWidget() {
4950
update();
5051
}
5152

52-
@SuppressWarnings("DataFlowIssue")
5353
@Override
5454
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);
5656
addSimpleIcoText(icon, "Counter: ", Formatting.YELLOW, FarmingHud.NUMBER_FORMAT.format(FarmingHud.counter()));
5757
addSimpleIcoText(icon, "Crops/min: ", Formatting.YELLOW, FarmingHud.NUMBER_FORMAT.format((int) FarmingHud.cropsPerMinute() / 100 * 100));
5858
addSimpleIcoText(icon, "Blocks/s: ", Formatting.YELLOW, Integer.toString(FarmingHud.blockBreaks()));
59+
//noinspection DataFlowIssue
5960
addComponent(new ProgressComponent(Ico.LANTERN, Text.literal("Farming Level: "), FarmingHud.farmingXpPercentProgress(), Formatting.GOLD.getColorValue()));
6061
addSimpleIcoText(Ico.LIME_DYE, "Farming XP/h: ", Formatting.YELLOW, FarmingHud.NUMBER_FORMAT.format((int) FarmingHud.farmingXpPerHour()));
6162

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();
6466
addComponent(new PlainTextComponent(Text.literal("Yaw: " + String.format("%.3f", MathHelper.wrapDegrees(yaw))).formatted(Formatting.YELLOW)));
6567
addComponent(new PlainTextComponent(Text.literal("Pitch: " + String.format("%.3f", MathHelper.wrapDegrees(pitch))).formatted(Formatting.YELLOW)));
6668
}

0 commit comments

Comments
 (0)