use of net.minecraft.entity.item.ExperienceOrbEntity in project minecolonies by ldtteam.
the class EntityAIWorkFisherman method generateBonusLoot.
/**
* Generates bonus fishing loot according to the building-level table
*/
private void generateBonusLoot() {
final LootContext context = (new LootContext.Builder((ServerWorld) this.world)).withParameter(LootParameters.ORIGIN, entityFishHook.position()).withParameter(LootParameters.THIS_ENTITY, entityFishHook).withParameter(LootParameters.TOOL, worker.getMainHandItem()).withParameter(LootParameters.KILLER_ENTITY, worker).withRandom(worker.getRandom()).withLuck((float) getPrimarySkillLevel()).create(LootParameterSets.FISHING);
final LootTable bonusLoot = this.world.getServer().getLootTables().get(ModLootTables.FISHERMAN_BONUS.getOrDefault(this.getOwnBuilding().getBuildingLevel(), new ResourceLocation("")));
final List<ItemStack> loot = bonusLoot.getRandomItems(context);
for (final ItemStack itemstack : loot) {
final ItemEntity itementity = new ItemEntity(this.world, entityFishHook.position().x, entityFishHook.position().y, entityFishHook.position().z, itemstack);
final double d0 = worker.getX() - entityFishHook.position().x;
final double d1 = (worker.getY() + 0.5D) - entityFishHook.position().y;
final double d2 = worker.getZ() - entityFishHook.position().z;
itementity.noPhysics = true;
itementity.setDeltaMovement(d0 * 0.1D, d1 * 0.1D + Math.sqrt(Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2)) * 0.08D, d2 * 0.1D);
this.world.addFreshEntity(itementity);
worker.level.addFreshEntity(new ExperienceOrbEntity(worker.level, worker.getX(), worker.getY() + 0.5D, worker.getZ() + 0.5D, XP_PER_CATCH));
}
}
Aggregations