77 */
88package net .wurstclient .hacks ;
99
10- import java .awt .Color ;
11- import java .util .ArrayList ;
12- import java .util .Arrays ;
1310import java .util .List ;
14- import java .util .stream .Collectors ;
1511
16- import net .minecraft .block .entity .*;
1712import net .minecraft .client .util .math .MatrixStack ;
18- import net .minecraft .entity .Entity ;
19- import net .minecraft .entity .vehicle .ChestBoatEntity ;
20- import net .minecraft .entity .vehicle .ChestMinecartEntity ;
21- import net .minecraft .entity .vehicle .ChestRaftEntity ;
22- import net .minecraft .entity .vehicle .HopperMinecartEntity ;
2313import net .minecraft .util .math .Box ;
2414import net .minecraft .util .math .Vec3d ;
2515import net .wurstclient .Category ;
2616import net .wurstclient .events .CameraTransformViewBobbingListener ;
2717import net .wurstclient .events .RenderListener ;
2818import net .wurstclient .events .UpdateListener ;
2919import net .wurstclient .hack .Hack ;
30- import net .wurstclient .hacks .chestesp .ChestEspBlockGroup ;
31- import net .wurstclient .hacks .chestesp .ChestEspEntityGroup ;
3220import net .wurstclient .hacks .chestesp .ChestEspGroup ;
33- import net .wurstclient .settings .CheckboxSetting ;
34- import net .wurstclient .settings .ColorSetting ;
21+ import net .wurstclient .hacks .chestesp .ChestEspGroupManager ;
3522import net .wurstclient .settings .EspStyleSetting ;
36- import net .wurstclient .util .LootrModCompat ;
3723import net .wurstclient .util .RenderUtils ;
3824import net .wurstclient .util .chunk .ChunkUtils ;
3925
4026public class ChestEspHack extends Hack implements UpdateListener ,
4127 CameraTransformViewBobbingListener , RenderListener
4228{
4329 private final EspStyleSetting style = new EspStyleSetting ();
44-
45- private final ChestEspBlockGroup basicChests = new ChestEspBlockGroup (
46- new ColorSetting ("Chest color" ,
47- "Normal chests will be highlighted in this color." , Color .GREEN ),
48- new CheckboxSetting ("Include normal chests" , true ));
49-
50- private final ChestEspBlockGroup trapChests = new ChestEspBlockGroup (
51- new ColorSetting ("Trap chest color" ,
52- "Trapped chests will be highlighted in this color." ,
53- new Color (0xFF8000 )),
54- new CheckboxSetting ("Include trap chests" , true ));
55-
56- private final ChestEspBlockGroup enderChests = new ChestEspBlockGroup (
57- new ColorSetting ("Ender color" ,
58- "Ender chests will be highlighted in this color." , Color .CYAN ),
59- new CheckboxSetting ("Include ender chests" , true ));
60-
61- private final ChestEspEntityGroup chestCarts =
62- new ChestEspEntityGroup (
63- new ColorSetting ("Chest cart color" ,
64- "Minecarts with chests will be highlighted in this color." ,
65- Color .YELLOW ),
66- new CheckboxSetting ("Include chest carts" , true ));
67-
68- private final ChestEspEntityGroup chestBoats =
69- new ChestEspEntityGroup (
70- new ColorSetting ("Chest boat color" ,
71- "Boats with chests will be highlighted in this color." ,
72- Color .YELLOW ),
73- new CheckboxSetting ("Include chest boats" , true ));
74-
75- private final ChestEspBlockGroup barrels = new ChestEspBlockGroup (
76- new ColorSetting ("Barrel color" ,
77- "Barrels will be highlighted in this color." , Color .GREEN ),
78- new CheckboxSetting ("Include barrels" , true ));
79-
80- private final ChestEspBlockGroup pots = new ChestEspBlockGroup (
81- new ColorSetting ("Pots color" ,
82- "Decorated pots will be highlighted in this color." , Color .GREEN ),
83- new CheckboxSetting ("Include pots" , false ));
84-
85- private final ChestEspBlockGroup shulkerBoxes = new ChestEspBlockGroup (
86- new ColorSetting ("Shulker color" ,
87- "Shulker boxes will be highlighted in this color." , Color .MAGENTA ),
88- new CheckboxSetting ("Include shulkers" , true ));
89-
90- private final ChestEspBlockGroup hoppers = new ChestEspBlockGroup (
91- new ColorSetting ("Hopper color" ,
92- "Hoppers will be highlighted in this color." , Color .WHITE ),
93- new CheckboxSetting ("Include hoppers" , false ));
94-
95- private final ChestEspEntityGroup hopperCarts =
96- new ChestEspEntityGroup (
97- new ColorSetting ("Hopper cart color" ,
98- "Minecarts with hoppers will be highlighted in this color." ,
99- Color .YELLOW ),
100- new CheckboxSetting ("Include hopper carts" , false ));
101-
102- private final ChestEspBlockGroup droppers = new ChestEspBlockGroup (
103- new ColorSetting ("Dropper color" ,
104- "Droppers will be highlighted in this color." , Color .WHITE ),
105- new CheckboxSetting ("Include droppers" , false ));
106-
107- private final ChestEspBlockGroup dispensers = new ChestEspBlockGroup (
108- new ColorSetting ("Dispenser color" ,
109- "Dispensers will be highlighted in this color." ,
110- new Color (0xFF8000 )),
111- new CheckboxSetting ("Include dispensers" , false ));
112-
113- private final ChestEspBlockGroup crafters = new ChestEspBlockGroup (
114- new ColorSetting ("Crafter color" ,
115- "Crafters will be highlighted in this color." , Color .WHITE ),
116- new CheckboxSetting ("Include crafters" , false ));
117-
118- private final ChestEspBlockGroup furnaces =
119- new ChestEspBlockGroup (new ColorSetting ("Furnace color" ,
120- "Furnaces, smokers, and blast furnaces will be highlighted in this color." ,
121- Color .RED ), new CheckboxSetting ("Include furnaces" , false ));
122-
123- private final List <ChestEspGroup > groups =
124- Arrays .asList (basicChests , trapChests , enderChests , chestCarts ,
125- chestBoats , barrels , pots , shulkerBoxes , hoppers , hopperCarts ,
126- droppers , dispensers , crafters , furnaces );
127-
128- private final List <ChestEspEntityGroup > entityGroups =
129- Arrays .asList (chestCarts , chestBoats , hopperCarts );
30+ private final ChestEspGroupManager groups = new ChestEspGroupManager ();
13031
13132 public ChestEspHack ()
13233 {
13334 super ("ChestESP" );
13435 setCategory (Category .RENDER );
135-
13636 addSetting (style );
137- groups .stream ().flatMap (ChestEspGroup ::getSettings )
37+ groups .allGroups . stream ().flatMap (ChestEspGroup ::getSettings )
13838 .forEach (this ::addSetting );
13939 }
14040
@@ -152,53 +52,17 @@ protected void onDisable()
15252 EVENTS .remove (UpdateListener .class , this );
15353 EVENTS .remove (CameraTransformViewBobbingListener .class , this );
15454 EVENTS .remove (RenderListener .class , this );
155-
156- groups .forEach (ChestEspGroup ::clear );
55+ groups .allGroups .forEach (ChestEspGroup ::clear );
15756 }
15857
15958 @ Override
16059 public void onUpdate ()
16160 {
162- groups .forEach (ChestEspGroup ::clear );
163-
164- ArrayList <BlockEntity > blockEntities =
165- ChunkUtils .getLoadedBlockEntities ()
166- .collect (Collectors .toCollection (ArrayList ::new ));
167-
168- for (BlockEntity blockEntity : blockEntities )
169- if (blockEntity instanceof TrappedChestBlockEntity )
170- trapChests .add (blockEntity );
171- else if (blockEntity instanceof ChestBlockEntity )
172- basicChests .add (blockEntity );
173- else if (blockEntity instanceof EnderChestBlockEntity )
174- enderChests .add (blockEntity );
175- else if (blockEntity instanceof ShulkerBoxBlockEntity
176- || LootrModCompat .isLootrShulkerBox (blockEntity ))
177- shulkerBoxes .add (blockEntity );
178- else if (blockEntity instanceof BarrelBlockEntity
179- || LootrModCompat .isLootrBarrel (blockEntity ))
180- barrels .add (blockEntity );
181- else if (blockEntity instanceof DecoratedPotBlockEntity )
182- pots .add (blockEntity );
183- else if (blockEntity instanceof HopperBlockEntity )
184- hoppers .add (blockEntity );
185- else if (blockEntity instanceof DropperBlockEntity )
186- droppers .add (blockEntity );
187- else if (blockEntity instanceof DispenserBlockEntity )
188- dispensers .add (blockEntity );
189- else if (blockEntity instanceof CrafterBlockEntity )
190- crafters .add (blockEntity );
191- else if (blockEntity instanceof AbstractFurnaceBlockEntity )
192- furnaces .add (blockEntity );
193-
194- for (Entity entity : MC .world .getEntities ())
195- if (entity instanceof ChestMinecartEntity )
196- chestCarts .add (entity );
197- else if (entity instanceof HopperMinecartEntity )
198- hopperCarts .add (entity );
199- else if (entity instanceof ChestBoatEntity
200- || entity instanceof ChestRaftEntity )
201- chestBoats .add (entity );
61+ groups .allGroups .forEach (ChestEspGroup ::clear );
62+ ChunkUtils .getLoadedBlockEntities ().forEach (
63+ be -> groups .blockGroups .forEach (group -> group .addIfMatches (be )));
64+ MC .world .getEntities ().forEach (
65+ e -> groups .entityGroups .forEach (group -> group .addIfMatches (e )));
20266 }
20367
20468 @ Override
@@ -212,7 +76,7 @@ public void onCameraTransformViewBobbing(
21276 @ Override
21377 public void onRender (MatrixStack matrixStack , float partialTicks )
21478 {
215- entityGroups .stream ().filter (ChestEspGroup ::isEnabled )
79+ groups . entityGroups .stream ().filter (ChestEspGroup ::isEnabled )
21680 .forEach (g -> g .updateBoxes (partialTicks ));
21781
21882 if (style .hasBoxes ())
@@ -224,7 +88,7 @@ public void onRender(MatrixStack matrixStack, float partialTicks)
22488
22589 private void renderBoxes (MatrixStack matrixStack )
22690 {
227- for (ChestEspGroup group : groups )
91+ for (ChestEspGroup group : groups . allGroups )
22892 {
22993 if (!group .isEnabled ())
23094 continue ;
@@ -241,7 +105,7 @@ private void renderBoxes(MatrixStack matrixStack)
241105
242106 private void renderTracers (MatrixStack matrixStack , float partialTicks )
243107 {
244- for (ChestEspGroup group : groups )
108+ for (ChestEspGroup group : groups . allGroups )
245109 {
246110 if (!group .isEnabled ())
247111 continue ;
0 commit comments