Search in sources :

Example 1 with CraftLootTable

use of org.bukkit.craftbukkit.v1_16_R3.CraftLootTable in project Magma-1.16.x by magmafoundation.

the class CraftEventFactory method callLootGenerateEvent.

public static LootGenerateEvent callLootGenerateEvent(IInventory inventory, LootTable lootTable, LootContext lootInfo, List<ItemStack> loot, boolean plugin) {
    CraftWorld world = lootInfo.getLevel().getWorldCB();
    Entity entity = lootInfo.getParamOrNull(LootParameters.THIS_ENTITY);
    NamespacedKey key = CraftNamespacedKey.fromMinecraft(world.getHandle().getServer().getLootTables().lootTableToKey.get(lootTable));
    CraftLootTable craftLootTable = new CraftLootTable(key, lootTable);
    List<org.bukkit.inventory.ItemStack> bukkitLoot = loot.stream().map(CraftItemStack::asCraftMirror).collect(Collectors.toCollection(ArrayList::new));
    LootGenerateEvent event = new LootGenerateEvent(world, (entity != null ? entity.getBukkitEntity() : null), InventoryHelper.getHolderOwner(inventory), craftLootTable, CraftLootTable.convertContext(lootInfo), bukkitLoot, plugin);
    Bukkit.getPluginManager().callEvent(event);
    return event;
}
Also used : VillagerEntity(net.minecraft.entity.merchant.villager.VillagerEntity) WaterMobEntity(net.minecraft.entity.passive.WaterMobEntity) ProjectileEntity(net.minecraft.entity.projectile.ProjectileEntity) GolemEntity(net.minecraft.entity.passive.GolemEntity) AbstractRaiderEntity(net.minecraft.entity.monster.AbstractRaiderEntity) SlimeEntity(net.minecraft.entity.monster.SlimeEntity) LivingEntity(org.bukkit.entity.LivingEntity) ExperienceOrbEntity(net.minecraft.entity.item.ExperienceOrbEntity) AreaEffectCloudEntity(net.minecraft.entity.AreaEffectCloudEntity) StriderEntity(net.minecraft.entity.passive.StriderEntity) PotionEntity(net.minecraft.entity.projectile.PotionEntity) AnimalEntity(net.minecraft.entity.passive.AnimalEntity) EnderDragonEntity(net.minecraft.entity.boss.dragon.EnderDragonEntity) MonsterEntity(net.minecraft.entity.monster.MonsterEntity) CraftEntity(org.bukkit.craftbukkit.v1_16_R3.entity.CraftEntity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) SpellcastingIllagerEntity(net.minecraft.entity.monster.SpellcastingIllagerEntity) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity) FireworkRocketEntity(net.minecraft.entity.projectile.FireworkRocketEntity) MobEntity(net.minecraft.entity.MobEntity) HumanEntity(org.bukkit.entity.HumanEntity) Entity(net.minecraft.entity.Entity) GhastEntity(net.minecraft.entity.monster.GhastEntity) ItemEntity(net.minecraft.entity.item.ItemEntity) CraftLivingEntity(org.bukkit.craftbukkit.v1_16_R3.entity.CraftLivingEntity) CraftNamespacedKey(org.bukkit.craftbukkit.v1_16_R3.util.CraftNamespacedKey) NamespacedKey(org.bukkit.NamespacedKey) CraftLootTable(org.bukkit.craftbukkit.v1_16_R3.CraftLootTable) LootGenerateEvent(org.bukkit.event.world.LootGenerateEvent) ItemStack(net.minecraft.item.ItemStack) CraftItemStack(org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack) CraftWorld(org.bukkit.craftbukkit.v1_16_R3.CraftWorld)

Example 2 with CraftLootTable

use of org.bukkit.craftbukkit.v1_16_R3.CraftLootTable in project LoliServer by Loli-Server.

the class CraftEventFactory method callLootGenerateEvent.

public static LootGenerateEvent callLootGenerateEvent(IInventory inventory, LootTable lootTable, LootContext lootInfo, List<ItemStack> loot, boolean plugin) {
    CraftWorld world = lootInfo.getLevel().getWorld();
    Entity entity = lootInfo.getParamOrNull(LootParameters.THIS_ENTITY);
    // LoliServer
    NamespacedKey key = CraftNamespacedKey.fromMinecraft(world.getHandle().getServer().getLootTables().getKey(lootTable));
    CraftLootTable craftLootTable = new CraftLootTable(key, lootTable);
    List<org.bukkit.inventory.ItemStack> bukkitLoot = loot.stream().map(CraftItemStack::asCraftMirror).collect(Collectors.toCollection(ArrayList::new));
    LootGenerateEvent event = new LootGenerateEvent(world, (entity != null ? entity.getBukkitEntity() : null), InventoryOwner.get(inventory), craftLootTable, CraftLootTable.convertContext(lootInfo), bukkitLoot, plugin);
    Bukkit.getPluginManager().callEvent(event);
    return event;
}
Also used : StriderEntity(net.minecraft.entity.passive.StriderEntity) VillagerEntity(net.minecraft.entity.merchant.villager.VillagerEntity) WaterMobEntity(net.minecraft.entity.passive.WaterMobEntity) PotionEntity(net.minecraft.entity.projectile.PotionEntity) LivingEntity(net.minecraft.entity.LivingEntity) ProjectileEntity(net.minecraft.entity.projectile.ProjectileEntity) AnimalEntity(net.minecraft.entity.passive.AnimalEntity) EnderDragonEntity(net.minecraft.entity.boss.dragon.EnderDragonEntity) MonsterEntity(net.minecraft.entity.monster.MonsterEntity) GolemEntity(net.minecraft.entity.passive.GolemEntity) CraftEntity(org.bukkit.craftbukkit.v1_16_R3.entity.CraftEntity) AbstractRaiderEntity(net.minecraft.entity.monster.AbstractRaiderEntity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) SlimeEntity(net.minecraft.entity.monster.SlimeEntity) SpellcastingIllagerEntity(net.minecraft.entity.monster.SpellcastingIllagerEntity) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity) FireworkRocketEntity(net.minecraft.entity.projectile.FireworkRocketEntity) AbstractFishEntity(net.minecraft.entity.passive.fish.AbstractFishEntity) ExperienceOrbEntity(net.minecraft.entity.item.ExperienceOrbEntity) PiglinEntity(net.minecraft.entity.monster.piglin.PiglinEntity) MobEntity(net.minecraft.entity.MobEntity) AreaEffectCloudEntity(net.minecraft.entity.AreaEffectCloudEntity) Entity(net.minecraft.entity.Entity) GhastEntity(net.minecraft.entity.monster.GhastEntity) ItemEntity(net.minecraft.entity.item.ItemEntity) CraftLivingEntity(org.bukkit.craftbukkit.v1_16_R3.entity.CraftLivingEntity) CraftNamespacedKey(org.bukkit.craftbukkit.v1_16_R3.util.CraftNamespacedKey) NamespacedKey(org.bukkit.NamespacedKey) CraftLootTable(org.bukkit.craftbukkit.v1_16_R3.CraftLootTable) LootGenerateEvent(org.bukkit.event.world.LootGenerateEvent) ItemStack(net.minecraft.item.ItemStack) CraftItemStack(org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack) CraftWorld(org.bukkit.craftbukkit.v1_16_R3.CraftWorld)

Aggregations

AreaEffectCloudEntity (net.minecraft.entity.AreaEffectCloudEntity)2 Entity (net.minecraft.entity.Entity)2 MobEntity (net.minecraft.entity.MobEntity)2 EnderDragonEntity (net.minecraft.entity.boss.dragon.EnderDragonEntity)2 ExperienceOrbEntity (net.minecraft.entity.item.ExperienceOrbEntity)2 ItemEntity (net.minecraft.entity.item.ItemEntity)2 VillagerEntity (net.minecraft.entity.merchant.villager.VillagerEntity)2 AbstractRaiderEntity (net.minecraft.entity.monster.AbstractRaiderEntity)2 GhastEntity (net.minecraft.entity.monster.GhastEntity)2 MonsterEntity (net.minecraft.entity.monster.MonsterEntity)2 SlimeEntity (net.minecraft.entity.monster.SlimeEntity)2 SpellcastingIllagerEntity (net.minecraft.entity.monster.SpellcastingIllagerEntity)2 AnimalEntity (net.minecraft.entity.passive.AnimalEntity)2 GolemEntity (net.minecraft.entity.passive.GolemEntity)2 StriderEntity (net.minecraft.entity.passive.StriderEntity)2 WaterMobEntity (net.minecraft.entity.passive.WaterMobEntity)2 PlayerEntity (net.minecraft.entity.player.PlayerEntity)2 ServerPlayerEntity (net.minecraft.entity.player.ServerPlayerEntity)2 FireworkRocketEntity (net.minecraft.entity.projectile.FireworkRocketEntity)2 PotionEntity (net.minecraft.entity.projectile.PotionEntity)2