2929import net .minecraft .world .level .block .state .BlockState ;
3030import net .minecraft .world .level .block .state .properties .ChestType ;
3131import net .minecraft .world .level .block .entity .BlockEntity ;
32+ import net .minecraft .world .level .block .entity .ChestBlockEntity ;
3233import net .minecraft .world .level .block .entity .TrialSpawnerBlockEntity ;
3334import net .minecraft .world .phys .AABB ;
3435import net .minecraft .world .phys .Vec3 ;
@@ -100,9 +101,14 @@ public class ChestEspHack extends Hack implements UpdateListener,
100101
101102 private final CheckboxSetting filterTrialChambers = new CheckboxSetting (
102103 "Filter trial chambers" ,
103- "Hides single chests that match common trial chamber layouts. Does not affect double chests or shulkers." ,
104+ "Hides single chests and barrels that match common trial chamber layouts. Does not affect double chests or shulkers." ,
104105 false );
105106
107+ private final CheckboxSetting doubleChestsOnly =
108+ new CheckboxSetting ("Double chests only" ,
109+ "Only highlight/tracer double chests when searching for chests." ,
110+ false );
111+
106112 private final CheckboxSetting filterVillages = new CheckboxSetting (
107113 "Filter villages" ,
108114 "Hides single chests that appear to belong to villages. Does not affect double chests or shulkers." ,
@@ -129,6 +135,7 @@ public ChestEspHack()
129135 addSetting (onlyBuried );
130136 addSetting (filterNearSpawners );
131137 addSetting (filterTrialChambers );
138+ addSetting (doubleChestsOnly );
132139 addSetting (filterVillages );
133140 addSetting (showCountInHackList );
134141 groups .allGroups .stream ().flatMap (ChestEspGroup ::getSettings )
@@ -169,6 +176,9 @@ public void onUpdate()
169176 if (enforceAboveGround && be .getBlockPos ().getY () < yLimit )
170177 return ;
171178
179+ if (shouldSkipSingleChest (be ))
180+ return ;
181+
172182 groups .blockGroups .forEach (group -> group .addIfMatches (be ));
173183 });
174184
@@ -771,6 +781,17 @@ private List<AABB> filterBoxesByEnvironment(List<AABB> boxes)
771781 BlockPos singleChestPos = getSingleChestPosIfApplicable (box );
772782 if (singleChestPos == null )
773783 {
784+ BlockPos barrelPos = getSingleBarrelPosIfApplicable (box );
785+ if (barrelPos == null )
786+ {
787+ out .add (box );
788+ continue ;
789+ }
790+
791+ if (filterTrialChambers .isChecked ()
792+ && isTrialChamberChest (barrelPos ))
793+ continue ;
794+
774795 out .add (box );
775796 continue ;
776797 }
@@ -846,6 +867,60 @@ private BlockPos getSingleChestPosIfApplicable(AABB box)
846867 return foundChest ;
847868 }
848869
870+ private BlockPos getSingleBarrelPosIfApplicable (AABB box )
871+ {
872+ if (MC .level == null || box == null )
873+ return null ;
874+
875+ int boxMinX = (int )Math .floor (box .minX + 1e-6 );
876+ int boxMaxX = (int )Math .floor (box .maxX - 1e-6 );
877+ int boxMinY = (int )Math .floor (box .minY + 1e-6 );
878+ int boxMaxY = (int )Math .floor (box .maxY - 1e-6 );
879+ int boxMinZ = (int )Math .floor (box .minZ + 1e-6 );
880+ int boxMaxZ = (int )Math .floor (box .maxZ - 1e-6 );
881+
882+ BlockPos foundBarrel = null ;
883+ int barrelCount = 0 ;
884+
885+ for (int x = boxMinX ; x <= boxMaxX ; x ++)
886+ {
887+ for (int y = boxMinY ; y <= boxMaxY ; y ++)
888+ {
889+ for (int z = boxMinZ ; z <= boxMaxZ ; z ++)
890+ {
891+ BlockPos pos = new BlockPos (x , y , z );
892+ BlockState state = MC .level .getBlockState (pos );
893+ if (state == null )
894+ continue ;
895+
896+ if (state .getBlock () instanceof BarrelBlock )
897+ {
898+ barrelCount ++;
899+ if (foundBarrel == null )
900+ foundBarrel = pos ;
901+
902+ if (barrelCount > 1 )
903+ return null ;
904+ }
905+ }
906+ }
907+ }
908+
909+ return foundBarrel ;
910+ }
911+
912+ private boolean shouldSkipSingleChest (BlockEntity be )
913+ {
914+ if (!doubleChestsOnly .isChecked () || !(be instanceof ChestBlockEntity ))
915+ return false ;
916+
917+ BlockState state = be .getBlockState ();
918+ if (!state .hasProperty (ChestBlock .TYPE ))
919+ return false ;
920+
921+ return state .getValue (ChestBlock .TYPE ) == ChestType .SINGLE ;
922+ }
923+
849924 private boolean isNearSpawner (BlockPos center , int range )
850925 {
851926 return BlockUtils .getAllInBoxStream (center , range )
0 commit comments