@@ -100,14 +100,14 @@ private boolean wasKilledByMob(Player player) {
100100 Entity damager = entityEvent .getDamager ();
101101
102102 // Check if damager is a mob
103- if (damager instanceof Monster || damager instanceof Animals ) {
103+ if (damager instanceof LivingEntity && !( damager instanceof Player ) ) {
104104 return true ;
105105 }
106106
107107 // Check if damager is a projectile from a mob
108108 if (damager instanceof Projectile projectile ) {
109109 ProjectileSource shooter = projectile .getShooter ();
110- return shooter instanceof Monster || shooter instanceof Animals ;
110+ return shooter instanceof LivingEntity && !( shooter instanceof Player ) ;
111111 }
112112
113113 return false ;
@@ -128,17 +128,16 @@ private boolean isWorldAllowed(String worldName) {
128128
129129 private Location findChestLocation (Location deathLocation ) {
130130 Location location = deathLocation .clone ();
131- Block block = location .getBlock ();
132131
133- // Try current position
134- if (isSuitableForChest (block )) {
132+ // Пробуем сначала текущий блок
133+ if (isSuitableForChest (location . getBlock () )) {
135134 return location ;
136135 }
137136
138- // Try positions around death location
137+ // Проверяем куб 3x3x5 (вверх и вниз)
139138 for (int x = -1 ; x <= 1 ; x ++) {
140139 for (int z = -1 ; z <= 1 ; z ++) {
141- for (int y = 0 ; y <= 2 ; y ++) {
140+ for (int y = - 2 ; y <= 2 ; y ++) {
142141 Location testLoc = location .clone ().add (x , y , z );
143142 if (isSuitableForChest (testLoc .getBlock ())) {
144143 return testLoc ;
@@ -152,8 +151,18 @@ private Location findChestLocation(Location deathLocation) {
152151
153152 private boolean isSuitableForChest (Block block ) {
154153 Material type = block .getType ();
155- return (type .isAir () || type == Material .WATER || type == Material .LAVA ) &&
156- block .getRelative (0 , 1 , 0 ).getType ().isAir ();
154+ return type .isAir ()
155+ || type == Material .SHORT_GRASS
156+ || type == Material .TALL_GRASS
157+ || type == Material .FERN
158+ || type == Material .LARGE_FERN
159+ || type == Material .DEAD_BUSH
160+ || type == Material .SEAGRASS
161+ || type == Material .TALL_SEAGRASS
162+ || type == Material .VINE
163+ || type == Material .SNOW
164+ || type == Material .WATER
165+ || type == Material .LAVA ;
157166 }
158167
159168 /**
0 commit comments