Search in sources :

Example 1 with ExperienceOrbEntity

use of net.minecraft.entity.ExperienceOrbEntity in project bewitchment by MoriyaShiine.

the class SmeltItemsRitualFunction method tick.

@Override
public void tick(World world, BlockPos glyphPos, BlockPos effectivePos, boolean catFamiliar) {
    int radius = catFamiliar ? 9 : 3;
    if (!world.isClient) {
        if (world.getTime() % 20 == 0) {
            for (ItemEntity itemEntity : world.getEntitiesByType(EntityType.ITEM, new Box(effectivePos).expand(radius, 0, radius), entity -> true)) {
                if (world.random.nextFloat() < 1 / 4f) {
                    world.getRecipeManager().listAllOfType(RecipeType.SMELTING).forEach(smeltingRecipe -> {
                        for (Ingredient ingredient : smeltingRecipe.getIngredients()) {
                            if (ingredient.test(itemEntity.getStack())) {
                                world.playSound(null, itemEntity.getBlockPos(), SoundEvents.BLOCK_FURNACE_FIRE_CRACKLE, SoundCategory.BLOCKS, 1, 1);
                                ItemScatterer.spawn(world, itemEntity.getX(), itemEntity.getY(), itemEntity.getZ(), smeltingRecipe.getOutput().copy());
                                world.spawnEntity(new ExperienceOrbEntity(world, itemEntity.getX(), itemEntity.getY(), itemEntity.getZ(), 1));
                                itemEntity.getStack().decrement(1);
                            }
                        }
                    });
                }
            }
        }
    } else {
        world.addParticle(ParticleTypes.FLAME, effectivePos.getX() + MathHelper.nextDouble(world.random, -radius, radius), effectivePos.getY() + 0.5, effectivePos.getZ() + MathHelper.nextDouble(world.random, -radius, radius), 0, 0, 0);
    }
}
Also used : ItemEntity(net.minecraft.entity.ItemEntity) Ingredient(net.minecraft.recipe.Ingredient) Box(net.minecraft.util.math.Box) ExperienceOrbEntity(net.minecraft.entity.ExperienceOrbEntity)

Example 2 with ExperienceOrbEntity

use of net.minecraft.entity.ExperienceOrbEntity in project wildmod by Osmiooo.

the class FrogMateGoal method breed.

protected void breed() {
    ServerPlayerEntity serverPlayerEntity = this.animal.getLovingPlayer();
    if (serverPlayerEntity == null && this.mate.getLovingPlayer() != null) {
        serverPlayerEntity = this.mate.getLovingPlayer();
    }
    if (serverPlayerEntity != null) {
        serverPlayerEntity.incrementStat(Stats.ANIMALS_BRED);
        Criteria.BRED_ANIMALS.trigger(serverPlayerEntity, this.animal, this.mate, (PassiveEntity) null);
    }
    this.frog.becomePregnant(true);
    this.animal.resetLoveTicks();
    this.mate.resetLoveTicks();
    Random random = this.animal.getRandom();
    if (this.world.getGameRules().getBoolean(GameRules.DO_MOB_LOOT)) {
        this.world.spawnEntity(new ExperienceOrbEntity(this.world, this.animal.getX(), this.animal.getY(), this.animal.getZ(), random.nextInt(7) + 1));
    }
}
Also used : Random(java.util.Random) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) ExperienceOrbEntity(net.minecraft.entity.ExperienceOrbEntity)

Example 3 with ExperienceOrbEntity

use of net.minecraft.entity.ExperienceOrbEntity in project Biome-Makeover by Lemonszz.

the class ToadEntity method breed.

public void breed(ServerWorld serverWorld, AnimalEntity other) {
    ServerPlayerEntity player = this.getLovingPlayer();
    if (player == null && other.getLovingPlayer() != null) {
        player = other.getLovingPlayer();
    }
    if (player != null) {
        player.incrementStat(Stats.ANIMALS_BRED);
        Criteria.BRED_ANIMALS.trigger(player, this, other, null);
    }
    setHasBaby(true);
    this.setBreedingAge(6000);
    other.setBreedingAge(6000);
    this.resetLoveTicks();
    other.resetLoveTicks();
    serverWorld.sendEntityStatus(this, (byte) 18);
    if (serverWorld.getGameRules().getBoolean(GameRules.DO_MOB_LOOT)) {
        serverWorld.spawnEntity(new ExperienceOrbEntity(serverWorld, this.getX(), this.getY(), this.getZ(), this.getRandom().nextInt(7) + 1));
    }
}
Also used : ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) ExperienceOrbEntity(net.minecraft.entity.ExperienceOrbEntity)

Example 4 with ExperienceOrbEntity

use of net.minecraft.entity.ExperienceOrbEntity in project Biome-Makeover by Lemonszz.

the class MushroomVillagerEntity method afterUsing.

protected void afterUsing(TradeOffer offer) {
    if (offer.shouldRewardPlayerExperience()) {
        int i = 3 + this.random.nextInt(4);
        this.world.spawnEntity(new ExperienceOrbEntity(this.world, this.getX(), this.getY() + 0.5D, this.getZ(), i));
    }
}
Also used : ExperienceOrbEntity(net.minecraft.entity.ExperienceOrbEntity)

Aggregations

ExperienceOrbEntity (net.minecraft.entity.ExperienceOrbEntity)4 ServerPlayerEntity (net.minecraft.server.network.ServerPlayerEntity)2 Random (java.util.Random)1 ItemEntity (net.minecraft.entity.ItemEntity)1 Ingredient (net.minecraft.recipe.Ingredient)1 Box (net.minecraft.util.math.Box)1