Search in sources :

Example 31 with ItemEntity

use of net.minecraft.entity.ItemEntity in project Terracraft by SimplyCmd.

the class PotBlock method dropHearts.

private void dropHearts(World world, BlockPos pos) {
    if (world.getClosestPlayer(pos.getX(), pos.getY(), pos.getZ(), 10000, true).getHealth() < 20) {
        // Spawn first heart
        ItemEntity heart = new ItemEntity(world, pos.getX(), pos.getY(), pos.getZ(), ItemRegistry.heart.getItem().getDefaultStack());
        world.spawnEntity(heart);
        // Spawn second heart
        if (RANDOM.nextFloat() < 0.5) {
            ItemEntity heart2 = new ItemEntity(world, pos.getX(), pos.getY(), pos.getZ(), ItemRegistry.heart.getItem().getDefaultStack());
            world.spawnEntity(heart2);
        }
    }
}
Also used : ItemEntity(net.minecraft.entity.ItemEntity)

Example 32 with ItemEntity

use of net.minecraft.entity.ItemEntity in project Neutrino by FrostWizard4.

the class AlpacaEntity method sheared.

@Override
public void sheared(SoundCategory shearedSoundCategory) {
    sheared = true;
    this.world.playSoundFromEntity((PlayerEntity) null, this, SoundEvents.ENTITY_SHEEP_SHEAR, shearedSoundCategory, 1.0F, 1.0F);
    int i = 1 + this.random.nextInt(3);
    for (int j = 0; j < i; ++j) {
        ItemEntity itemEntity = this.dropItem(ItemRegistry.ALPACA_FUR, 1);
        if (itemEntity != null) {
            itemEntity.setVelocity(itemEntity.getVelocity().add((double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F), (double) (this.random.nextFloat() * 0.05F), (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F)));
        }
    }
}
Also used : ItemEntity(net.minecraft.entity.ItemEntity)

Aggregations

ItemEntity (net.minecraft.entity.ItemEntity)32 ItemStack (net.minecraft.item.ItemStack)15 PlayerEntity (net.minecraft.entity.player.PlayerEntity)7 Inject (org.spongepowered.asm.mixin.injection.Inject)6 Entity (net.minecraft.entity.Entity)5 LivingEntity (net.minecraft.entity.LivingEntity)5 Box (net.minecraft.util.math.Box)4 Monster (net.minecraft.entity.mob.Monster)3 Vec3d (net.minecraft.util.math.Vec3d)3 Item (net.minecraft.item.Item)2 ServerPlayerEntity (net.minecraft.server.network.ServerPlayerEntity)2 World (net.minecraft.world.World)2 AllowConcurrentEvents (com.google.common.eventbus.AllowConcurrentEvents)1 Subscribe (com.google.common.eventbus.Subscribe)1 CapeItem (com.jab125.thonkutil.api.CapeItem)1 CauldronRecipe (de.siphalor.nbtcrafting.recipe.cauldron.CauldronRecipe)1 TemporaryCauldronInventory (de.siphalor.nbtcrafting.recipe.cauldron.TemporaryCauldronInventory)1 FlyRandomlyGoal (frozenblock.wild.mod.liukrastapi.FlyRandomlyGoal)1 Color (java.awt.Color)1 Iterator (java.util.Iterator)1