|
18 | 18 |
|
19 | 19 | public class EventConverter {
|
20 | 20 |
|
| 21 | + public static List<ItemStack> createXmapList(Collection<ItemEntity> drops, LivingEntity entity) { |
| 22 | + return XmapList.create((List<ItemEntity>) drops, ItemStack.class, |
| 23 | + (ItemEntity e) -> CraftItemStack.asCraftMirror(e.getItem()), |
| 24 | + itemStack -> { |
| 25 | + ItemEntity itemEntity = new ItemEntity(entity.level(), entity.getX(), entity.getY(), entity.getZ(), CraftItemStack.asNMSCopy(itemStack)); |
| 26 | + itemEntity.setDefaultPickUpDelay(); |
| 27 | + return itemEntity; |
| 28 | + }); |
| 29 | + } |
| 30 | + |
21 | 31 | public static LivingDropsEvent callLivingDropsEvent(LivingEntity entity, DamageSource source, Collection<ItemEntity> drops, int lootingLevel, boolean recentlyHit) {
|
22 | 32 | LivingDropsEvent event = new LivingDropsEvent(entity, source, drops, lootingLevel, recentlyHit);
|
23 | 33 | if (entity instanceof ServerPlayer) return event;
|
24 | 34 |
|
25 | 35 | if (!(drops instanceof ArrayList))
|
26 | 36 | drops = new ArrayList<>(drops);
|
27 | 37 |
|
28 |
| - List<ItemStack> bukkitDrops = XmapList.create((List<ItemEntity>) drops, ItemStack.class, |
29 |
| - (ItemEntity e) -> CraftItemStack.asCraftMirror(e.getItem()), |
30 |
| - itemStack -> { |
31 |
| - ItemEntity itemEntity = new ItemEntity(entity.level(), entity.getX(), entity.getY(), entity.getZ(), CraftItemStack.asNMSCopy(itemStack)); |
32 |
| - itemEntity.setDefaultPickUpDelay(); |
33 |
| - return itemEntity; |
34 |
| - }); |
| 38 | + List<ItemStack> bukkitDrops = createXmapList(drops, entity); |
35 | 39 |
|
36 | 40 | CraftLivingEntity craftLivingEntity = ((CraftLivingEntity) entity.getBukkitEntity());
|
37 | 41 | EntityDeathEvent bukkitEvent = new EntityDeathEvent(craftLivingEntity, bukkitDrops, entity.getExpReward());
|
|
0 commit comments