Skip to content

Commit 2f1f420

Browse files
committed
v1.1.1 - улучшено определение смерти от моба. Улучшен поиск позиции для установки сундука
1 parent 5a37479 commit 2f1f420

4 files changed

Lines changed: 21 additions & 12 deletions

File tree

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ plugins {
33
}
44

55
group = 'com.flyaway.deathchest'
6-
version = '1.1.0'
6+
version = '1.1.1'
77

88
java {
99
toolchain {

src/main/java/com/flyaway/deathchest/DeathChestCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
7171

7272
case "version":
7373
Component versionMessage = miniMessage.deserialize(
74-
configManager.getPrefix() + " <white>DeathChest v1.1.0"
74+
configManager.getPrefix() + " <white>DeathChest v1.1.1"
7575
);
7676
player.sendMessage(versionMessage);
7777
break;

src/main/java/com/flyaway/deathchest/listeners/DeathListener.java

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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
/**

src/main/resources/plugin.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: DeathChest
2-
version: 1.1.0
2+
version: 1.1.1
33
main: com.flyaway.deathchest.DeathChest
44
api-version: 1.21
55
author: FlyAwayMaking

0 commit comments

Comments
 (0)