1010import java .util .List ;
1111
1212import net .minecraft .client .util .math .MatrixStack ;
13+ import net .minecraft .entity .Entity ;
1314import net .minecraft .util .math .Box ;
1415import net .minecraft .util .math .Vec3d ;
1516import net .wurstclient .Category ;
1920import net .wurstclient .hack .Hack ;
2021import net .wurstclient .hacks .chestesp .ChestEspGroup ;
2122import net .wurstclient .hacks .chestesp .ChestEspGroupManager ;
23+ import net .wurstclient .settings .CheckboxSetting ;
2224import net .wurstclient .settings .EspStyleSetting ;
2325import net .wurstclient .settings .SliderSetting ;
2426import net .wurstclient .util .RenderUtils ;
@@ -34,102 +36,14 @@ public class ChestEspHack extends Hack implements UpdateListener,
3436 + "On: Keeps results anchored (useful for pathing back).\n "
3537 + "Note: ChestESP tracks loaded block entities; visibility is still limited by server view distance." ,
3638 false );
39+ private final ChestEspGroupManager groups = new ChestEspGroupManager ();
3740
38- private final ChestEspBlockGroup basicChests = new ChestEspBlockGroup (
39- new ColorSetting ("Chest color" ,
40- "Normal chests will be highlighted in this color." , Color .GREEN ),
41- null );
42-
43- private final ChestEspBlockGroup trapChests = new ChestEspBlockGroup (
44- new ColorSetting ("Trap chest color" ,
45- "Trapped chests will be highlighted in this color." ,
46- new Color (0xFF8000 )),
47- new CheckboxSetting ("Include trap chests" , true ));
48-
49- private final ChestEspBlockGroup enderChests = new ChestEspBlockGroup (
50- new ColorSetting ("Ender color" ,
51- "Ender chests will be highlighted in this color." , Color .CYAN ),
52- new CheckboxSetting ("Include ender chests" , true ));
53-
54- private final ChestEspEntityGroup chestCarts =
55- new ChestEspEntityGroup (
56- new ColorSetting ("Chest cart color" ,
57- "Minecarts with chests will be highlighted in this color." ,
58- Color .YELLOW ),
59- new CheckboxSetting ("Include chest carts" , true ));
60-
61- private final ChestEspEntityGroup chestBoats =
62- new ChestEspEntityGroup (
63- new ColorSetting ("Chest boat color" ,
64- "Boats with chests will be highlighted in this color." ,
65- Color .YELLOW ),
66- new CheckboxSetting ("Include chest boats" , true ));
67-
68- private final ChestEspBlockGroup barrels = new ChestEspBlockGroup (
69- new ColorSetting ("Barrel color" ,
70- "Barrels will be highlighted in this color." , Color .GREEN ),
71- new CheckboxSetting ("Include barrels" , true ));
72-
73- private final ChestEspBlockGroup pots = new ChestEspBlockGroup (
74- new ColorSetting ("Pots color" ,
75- "Decorated pots will be highlighted in this color." , Color .GREEN ),
76- new CheckboxSetting ("Include pots" , false ));
77-
78- private final ChestEspBlockGroup shulkerBoxes = new ChestEspBlockGroup (
79- new ColorSetting ("Shulker color" ,
80- "Shulker boxes will be highlighted in this color." , Color .MAGENTA ),
81- new CheckboxSetting ("Include shulkers" , true ));
82-
83- private final ChestEspBlockGroup hoppers = new ChestEspBlockGroup (
84- new ColorSetting ("Hopper color" ,
85- "Hoppers will be highlighted in this color." , Color .WHITE ),
86- new CheckboxSetting ("Include hoppers" , false ));
87-
88- private final ChestEspEntityGroup hopperCarts =
89- new ChestEspEntityGroup (
90- new ColorSetting ("Hopper cart color" ,
91- "Minecarts with hoppers will be highlighted in this color." ,
92- Color .YELLOW ),
93- new CheckboxSetting ("Include hopper carts" , false ));
94-
95- private final ChestEspBlockGroup droppers = new ChestEspBlockGroup (
96- new ColorSetting ("Dropper color" ,
97- "Droppers will be highlighted in this color." , Color .WHITE ),
98- new CheckboxSetting ("Include droppers" , false ));
99-
100- private final ChestEspBlockGroup dispensers = new ChestEspBlockGroup (
101- new ColorSetting ("Dispenser color" ,
102- "Dispensers will be highlighted in this color." ,
103- new Color (0xFF8000 )),
104- new CheckboxSetting ("Include dispensers" , false ));
105-
106- private final ChestEspBlockGroup crafters = new ChestEspBlockGroup (
107- new ColorSetting ("Crafter color" ,
108- "Crafters will be highlighted in this color." , Color .WHITE ),
109- new CheckboxSetting ("Include crafters" , false ));
110-
111- private final ChestEspBlockGroup furnaces =
112- new ChestEspBlockGroup (new ColorSetting ("Furnace color" ,
113- "Furnaces, smokers, and blast furnaces will be highlighted in this color." ,
114- Color .RED ), new CheckboxSetting ("Include furnaces" , false ));
115-
116- private final List <ChestEspGroup > groups =
117- Arrays .asList (basicChests , trapChests , enderChests , chestCarts ,
118- chestBoats , barrels , pots , shulkerBoxes , hoppers , hopperCarts ,
119- droppers , dispensers , crafters , furnaces );
120-
121- private final List <ChestEspEntityGroup > entityGroups =
122- Arrays .asList (chestCarts , chestBoats , hopperCarts );
123-
124- // New: optionally show detected count in HackList
12541 private final CheckboxSetting showCountInHackList = new CheckboxSetting (
12642 "HackList count" ,
12743 "Appends the number of detected chests/containers to this hack's entry in the HackList." ,
12844 false );
129-
13045 private int foundCount ;
13146
132- // Above-ground filter
13347 private final CheckboxSetting onlyAboveGround =
13448 new CheckboxSetting ("Above ground only" ,
13549 "Only show chests/containers at or above the configured Y level." ,
@@ -143,7 +57,7 @@ public ChestEspHack()
14357 setCategory (Category .RENDER );
14458 addSetting (style );
14559 addSetting (stickyArea );
146- groups .stream ().flatMap (ChestEspGroup ::getSettings )
60+ groups .allGroups . stream ().flatMap (ChestEspGroup ::getSettings )
14761 .forEach (this ::addSetting );
14862 addSetting (onlyAboveGround );
14963 addSetting (aboveGroundY );
@@ -165,67 +79,39 @@ protected void onDisable()
16579 EVENTS .remove (CameraTransformViewBobbingListener .class , this );
16680 EVENTS .remove (RenderListener .class , this );
16781
168- groups .forEach (ChestEspGroup ::clear );
169- entityGroups .forEach (ChestEspGroup ::clear );
82+ groups .allGroups .forEach (ChestEspGroup ::clear );
17083 foundCount = 0 ;
17184 }
17285
17386 @ Override
17487 public void onUpdate ()
17588 {
176- groups .forEach (ChestEspGroup ::clear );
89+ groups .allGroups . forEach (ChestEspGroup ::clear );
17790
178- ArrayList <BlockEntity > blockEntities =
179- ChunkUtils .getLoadedBlockEntities ()
180- .collect (Collectors .toCollection (ArrayList ::new ));
91+ double yLimit = aboveGroundY .getValue ();
92+ boolean enforceAboveGround = onlyAboveGround .isChecked ();
18193
182- for (BlockEntity blockEntity : blockEntities )
183- {
184- if (onlyAboveGround .isChecked ()
185- && blockEntity .getPos ().getY () < aboveGroundY .getValue ())
186- continue ;
187- if (blockEntity instanceof TrappedChestBlockEntity )
188- trapChests .add (blockEntity );
189- else if (blockEntity instanceof ChestBlockEntity )
190- basicChests .add (blockEntity );
191- else if (blockEntity instanceof EnderChestBlockEntity )
192- enderChests .add (blockEntity );
193- else if (blockEntity instanceof ShulkerBoxBlockEntity )
194- shulkerBoxes .add (blockEntity );
195- else if (blockEntity instanceof BarrelBlockEntity )
196- barrels .add (blockEntity );
197- else if (blockEntity instanceof DecoratedPotBlockEntity )
198- pots .add (blockEntity );
199- else if (blockEntity instanceof HopperBlockEntity )
200- hoppers .add (blockEntity );
201- else if (blockEntity instanceof DropperBlockEntity )
202- droppers .add (blockEntity );
203- else if (blockEntity instanceof DispenserBlockEntity )
204- dispensers .add (blockEntity );
205- else if (blockEntity instanceof CrafterBlockEntity )
206- crafters .add (blockEntity );
207- else if (blockEntity instanceof AbstractFurnaceBlockEntity )
208- furnaces .add (blockEntity );
94+ ChunkUtils .getLoadedBlockEntities ().forEach (be -> {
95+ if (enforceAboveGround && be .getPos ().getY () < yLimit )
96+ return ;
20997
210- }
98+ groups .blockGroups .forEach (group -> group .addIfMatches (be ));
99+ });
211100
212- for ( Entity entity : MC .world . getEntities () )
101+ if ( MC .world != null )
213102 {
214- if (onlyAboveGround .isChecked ()
215- && entity .getY () < aboveGroundY .getValue ())
216- continue ;
217- if (entity instanceof ChestMinecartEntity )
218- chestCarts .add (entity );
219- else if (entity instanceof HopperMinecartEntity )
220- hopperCarts .add (entity );
221- else if (entity instanceof ChestBoatEntity
222- || entity instanceof ChestRaftEntity )
223- chestBoats .add (entity );
103+ for (Entity entity : MC .world .getEntities ())
104+ {
105+ if (enforceAboveGround && entity .getY () < yLimit )
106+ continue ;
107+
108+ groups .entityGroups
109+ .forEach (group -> group .addIfMatches (entity ));
110+ }
224111 }
225112
226- // compute found count from enabled groups (clamped)
227- int total = groups .stream ().mapToInt (g -> g .getBoxes ().size ()).sum ();
228- total += entityGroups .stream ().mapToInt (g -> g .getBoxes ().size ()).sum ();
113+ int total = groups .allGroups .stream ().filter (ChestEspGroup ::isEnabled )
114+ .mapToInt (g -> g .getBoxes ().size ()).sum ();
229115 foundCount = Math .min (total , 999 );
230116 }
231117
0 commit comments