MCPcopy Create free account
hub / github.com/DGVPSH/SlackOpen / spawnAsEntity

Method spawnAsEntity

src/main/java/net/minecraft/block/Block.java:650–662  ·  view source on GitHub ↗

Spawns the given ItemStack as an EntityItem into the World at the given position

(World worldIn, BlockPos pos, ItemStack stack)

Source from the content-addressed store, hash-verified

648 * Spawns the given ItemStack as an EntityItem into the World at the given position
649 */
650 public static void spawnAsEntity(World worldIn, BlockPos pos, ItemStack stack)
651 {
652 if (!worldIn.isRemote && worldIn.getGameRules().getGameRuleBooleanValue("doTileDrops"))
653 {
654 float f = 0.5F;
655 double d0 = (double)(worldIn.rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D;
656 double d1 = (double)(worldIn.rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D;
657 double d2 = (double)(worldIn.rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D;
658 EntityItem entityitem = new EntityItem(worldIn, (double)pos.getX() + d0, (double)pos.getY() + d1, (double)pos.getZ() + d2, stack);
659 entityitem.setDefaultPickupDelay();
660 worldIn.spawnEntityInWorld(entityitem);
661 }
662 }
663
664 /**
665 * Spawns the given amount of experience into the World as XP orb entities

Callers 15

harvestBlockMethod · 0.95
dropBlockMethod · 0.95
dropContentsMethod · 0.95
harvestBlockMethod · 0.80
breakBlockMethod · 0.80
dropAppleMethod · 0.80
harvestBlockMethod · 0.80

Calls 7

setDefaultPickupDelayMethod · 0.95
getXMethod · 0.65
getYMethod · 0.65
getZMethod · 0.65
getGameRulesMethod · 0.45
spawnEntityInWorldMethod · 0.45

Tested by

no test coverage detected