Skip to content

Commit 40bfdc8

Browse files
committed
Add ChestCount HUD and update Baritone build logic
Introduces a new ChestCount HUD element to display the number of chests in render distance. Updates BetterBaritoneBuild to improve event handling and pathing logic, and changes Baritone dependency to compileOnly. Also bumps mod version to 1.1.4.
1 parent 67319e6 commit 40bfdc8

File tree

5 files changed

+62
-6
lines changed

5 files changed

+62
-6
lines changed

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ dependencies {
3636
modImplementation("meteordevelopment:meteor-client:$meteorClientVersion-SNAPSHOT")
3737

3838
// Baritone
39-
modImplementation("meteordevelopment:baritone:$minecraftVersion-SNAPSHOT")
39+
modCompileOnly("meteordevelopment:baritone:$minecraftVersion-SNAPSHOT")
4040
}
4141

4242
tasks {

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx2G
22
org.gradle.configuration-cache=true
33

44
# Mod Global Properties
5-
mod_version=1.1.3
5+
mod_version=1.1.4
66
maven_group=xyz.omegaware
77
archives_base_name=OmegaWare Addons
88

src/main/java/xyz/omegaware/addon/OmegawareAddons.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import net.fabricmc.loader.api.metadata.ModMetadata;
1010
import xyz.omegaware.addon.commands.LinkCommand;
1111
import xyz.omegaware.addon.commands.ShulkerQueueCommand;
12+
import xyz.omegaware.addon.hud.ChestCount;
1213
import xyz.omegaware.addon.hud.OnlineTSRMembersHUD;
1314
import xyz.omegaware.addon.modules.*;
1415
import com.mojang.logging.LogUtils;
@@ -28,7 +29,7 @@ public class OmegawareAddons extends MeteorAddon {
2829
public static final Category CATEGORY = new Category("OmegaWare");
2930
public static final HudGroup HUD_GROUP = new HudGroup("OmegaWare");
3031

31-
public static final BetterBaritoneBuild BETTER_BARITONE_BUILD = new BetterBaritoneBuild();
32+
public static BetterBaritoneBuild BETTER_BARITONE_BUILD = null;
3233

3334
public static File GetConfigFile(String key, String filename) {
3435
return new File(new File(new File(new File(MeteorClient.FOLDER, "omegaware"), key), Utils.getFileWorldName()), filename);
@@ -52,13 +53,15 @@ public void onInitialize() {
5253
}
5354

5455
if (BaritoneUtils.IS_AVAILABLE) {
56+
BETTER_BARITONE_BUILD = new BetterBaritoneBuild();
5557
Modules.get().add(BETTER_BARITONE_BUILD);
5658
}
5759

5860
Commands.add(new LinkCommand());
5961
Commands.add(new ShulkerQueueCommand());
6062

6163
Hud.get().register(OnlineTSRMembersHUD.INFO);
64+
Hud.get().register(ChestCount.INFO);
6265
}
6366

6467
@Override
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package xyz.omegaware.addon.hud;
2+
3+
import meteordevelopment.meteorclient.settings.SettingGroup;
4+
import meteordevelopment.meteorclient.systems.hud.HudElement;
5+
import meteordevelopment.meteorclient.systems.hud.HudElementInfo;
6+
import meteordevelopment.meteorclient.systems.hud.HudRenderer;
7+
import meteordevelopment.meteorclient.utils.Utils;
8+
import meteordevelopment.meteorclient.utils.render.color.Color;
9+
import net.minecraft.block.BlockState;
10+
import net.minecraft.block.ChestBlock;
11+
import net.minecraft.block.entity.BlockEntity;
12+
import net.minecraft.block.entity.ChestBlockEntity;
13+
import net.minecraft.block.enums.ChestType;
14+
import xyz.omegaware.addon.OmegawareAddons;
15+
16+
import static meteordevelopment.meteorclient.MeteorClient.mc;
17+
18+
public class ChestCount extends HudElement {
19+
public static final HudElementInfo<ChestCount> INFO = new HudElementInfo<>(OmegawareAddons.HUD_GROUP, "Dubs Count", "Displays how many dubs are in render distance", ChestCount::new);
20+
21+
public ChestCount() {
22+
super(INFO);
23+
}
24+
25+
@Override
26+
public void render(HudRenderer renderer) {
27+
if (mc.player == null || mc.world == null) return;
28+
29+
int count = 0;
30+
for (BlockEntity blockEntity : Utils.blockEntities()) {
31+
if (!(blockEntity instanceof ChestBlockEntity chestBlock)) continue;
32+
33+
BlockState blockState = chestBlock.getCachedState();
34+
ChestType chestType = blockState.get(ChestBlock.CHEST_TYPE);
35+
36+
// Only count left chests to avoid double counting
37+
if (chestType.equals(ChestType.SINGLE) || chestType.equals(ChestType.RIGHT)) continue;
38+
39+
count++;
40+
}
41+
42+
renderer.text("Dubs: ", x, y, Color.WHITE, true);
43+
renderer.text("" + count, x + renderer.textWidth("Dubs: ", true), y, Color.LIGHT_GRAY, true);
44+
45+
setSize(renderer.textWidth("Dubs: " + count, true), renderer.textHeight(true) + 1);
46+
}
47+
}

src/main/java/xyz/omegaware/addon/modules/BetterBaritoneBuild.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ public void onServerConnectEnd(ServerConnectEndEvent event) {
651651
}
652652

653653
@EventHandler
654-
private void onTickPost(TickEvent.Post event) {
654+
private void onTickPre(TickEvent.Pre event) {
655655
if (!isActive()) return;
656656

657657
if (!EventRegistry.INSTANCE.isEmpty() && currentEvent == null) {
@@ -662,6 +662,7 @@ private void onTickPost(TickEvent.Post event) {
662662
if (debugMode.get()) {
663663
Logger.info("Executing event: %s", currentEvent.type.toString());
664664
}
665+
665666
if (currentEvent.bWaitOnPath && baritone.getPathingBehavior().hasPath() || baritone.getPathingBehavior().isPathing()) {
666667
// Wait for Baritone to finish pathing
667668
return;
@@ -670,7 +671,11 @@ private void onTickPost(TickEvent.Post event) {
670671
currentEvent.callback.run();
671672
currentEvent = null;
672673
}
673-
// Home shit
674+
}
675+
676+
@EventHandler
677+
private void onTickPost(TickEvent.Post event) {
678+
// Home Shit and anti-stuck shit
674679
}
675680

676681
@EventHandler
@@ -889,7 +894,8 @@ private void onInventory(InventoryEvent event) {
889894
FetchRegistry.INSTANCE.update();
890895

891896
if (FetchRegistry.INSTANCE.isEmpty()) {
892-
EventRegistry.INSTANCE.push(new EventRegistry.Event(EventRegistry.Event.EventType.Resume, true, () -> baritone.getCommandManager().execute(buildCommand)));
897+
baritone.getPathingBehavior().cancelEverything();
898+
EventRegistry.INSTANCE.push(new EventRegistry.Event(EventRegistry.Event.EventType.Resume, false, () -> baritone.getCommandManager().execute(buildCommand)));
893899
}
894900
});
895901
});

0 commit comments

Comments
 (0)