Skip to content

Commit

Permalink
fix: Fire aspect application workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
Aurelien30000 committed Jul 19, 2024
1 parent 018964b commit 1ea392b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>uk.antiperson.stackmob</groupId>
<artifactId>StackMob</artifactId>
<version>5.9.0</version>
<version>5.9.1</version>

<build>
<sourceDirectory>src/main/java</sourceDirectory>
Expand Down
18 changes: 16 additions & 2 deletions src/main/java/uk/antiperson/stackmob/listeners/DeathListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import uk.antiperson.stackmob.utils.Utilities;

import java.lang.reflect.InvocationTargetException;
import java.util.List;
import java.util.Map;

public class DeathListener implements Listener {
Expand Down Expand Up @@ -64,8 +65,16 @@ public void onStackDeath(EntityDeathEvent event) {
}
final Drops drop = stackEntity.getDrops();
final int experience = drop.calculateDeathExperience(toMultiply, event.getDroppedExp());
final Map<ItemStack, Integer> drops = drop.calculateDrops(toMultiply, event.getDrops(), isSkipDeathAnimation);
Drops.dropItems(entity.getLocation(), drops);
// Workaround for craftbukkit bug?/change
// Enchantment effects are now applied after the death event is fired....
// Should probably investigate more...? How are the drops in the event correct.
if (Utilities.isVersionAtLeast(Utilities.MinecraftVersion.V1_21) && sm.getMainConfig().isDropLootTables(entity.getType())) {
final int finalToMultiply = toMultiply;
final Runnable runnable = () -> doDrops(entity, drop, finalToMultiply, event.getDrops(), isSkipDeathAnimation);
sm.getScheduler().runTaskLater(sm, stackEntity.getEntity(), runnable, 1);
} else {
doDrops(entity, drop, toMultiply, event.getDrops(), isSkipDeathAnimation);
}
if (isSkipDeathAnimation && Utilities.isPaper()) {
final ExperienceOrb orb = (ExperienceOrb) entity.getWorld().spawnEntity(entity.getLocation(), EntityType.EXPERIENCE_ORB);
orb.setExperience(experience);
Expand All @@ -92,4 +101,9 @@ public DeathMethod calculateDeath(StackEntity entity) {
}
}

private void doDrops(LivingEntity entity, Drops drop, int toMultiply, List<ItemStack> drops, boolean isSkipDeathAnimation) {
final Map<ItemStack, Integer> map = drop.calculateDrops(toMultiply, drops, isSkipDeathAnimation);
Drops.dropItems(entity.getLocation(), map);
}

}

0 comments on commit 1ea392b

Please sign in to comment.