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);
}
}
}
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)));
}
}
}
Aggregations