Search in sources :

Example 21 with EntityItem

use of net.minecraft.entity.item.EntityItem in project PneumaticCraft by MineMaarten.

the class BlockPneumaticPlantBase method dropBlockAsItem.

@Override
protected void dropBlockAsItem(World world, int x, int y, int z, ItemStack stack) {
    if (!world.isRemote && world.getGameRules().getGameRuleBooleanValue("doTileDrops")) {
        if (captureDrops.get()) {
            capturedDrops.get().add(stack);
            return;
        }
        float f = 0.7F;
        double d0 = world.rand.nextFloat() * f + (1.0F - f) * 0.5D;
        double d1 = world.rand.nextFloat() * f + (1.0F - f) * 0.5D;
        double d2 = world.rand.nextFloat() * f + (1.0F - f) * 0.5D;
        EntityItem entityitem = new EntityItem(world, x + d0, y + d1, z + d2, stack);
        entityitem.delayBeforeCanPickup = 10;
        world.spawnEntityInWorld(entityitem);
        ItemPlasticPlants.markInactive(entityitem);
    }
}
Also used : EntityItem(net.minecraft.entity.item.EntityItem)

Example 22 with EntityItem

use of net.minecraft.entity.item.EntityItem in project PneumaticCraft by MineMaarten.

the class BlockRainPlant method executeFullGrownEffect.

@Override
public void executeFullGrownEffect(World world, int x, int y, int z, Random rand) {
    if (!world.isRemote && world.isRaining()) {
        ItemStack seed = new ItemStack(Itemss.plasticPlant, 1, ItemPlasticPlants.RAIN_PLANT_DAMAGE);
        EntityItem plant = new EntityItem(world, x + rand.nextInt(16) - 8, 128, z + rand.nextInt(16) - 8, seed);
        plant.lifespan = 300;
        ItemPlasticPlants.markInactive(plant);
        world.spawnEntityInWorld(plant);
        world.setBlockMetadataWithNotify(x, y, z, world.getBlockMetadata(x, y, z) - 2, 3);
    }
}
Also used : ItemStack(net.minecraft.item.ItemStack) EntityItem(net.minecraft.entity.item.EntityItem)

Example 23 with EntityItem

use of net.minecraft.entity.item.EntityItem in project PneumaticCraft by MineMaarten.

the class BlockPressureTube method breakBlock.

@Override
public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
    List<ItemStack> drops = getModuleDrops((TileEntityPressureTube) world.getTileEntity(x, y, z));
    for (ItemStack drop : drops) {
        EntityItem entity = new EntityItem(world, x + 0.5, y + 0.5, z + 0.5);
        entity.setEntityItemStack(drop);
        world.spawnEntityInWorld(entity);
    }
    super.breakBlock(world, x, y, z, block, meta);
}
Also used : ItemStack(net.minecraft.item.ItemStack) EntityItem(net.minecraft.entity.item.EntityItem)

Example 24 with EntityItem

use of net.minecraft.entity.item.EntityItem in project PneumaticCraft by MineMaarten.

the class BlockBurstPlant method executeFullGrownEffect.

@Override
public void executeFullGrownEffect(World world, int x, int y, int z, Random rand) {
    if (!world.isRemote) {
        ItemStack seed = new ItemStack(Itemss.plasticPlant, 1, ItemPlasticPlants.BURST_PLANT_DAMAGE);
        EntityItem plant = new EntityItem(world, x + 0.5D, y + 0.8D, z + 0.5D, seed);
        plant.motionX = rand.nextFloat() - 0.5F;
        plant.motionY = 1.0F;
        plant.motionZ = rand.nextFloat() - 0.5F;
        plant.lifespan = 300;
        ItemPlasticPlants.markInactive(plant);
        world.spawnEntityInWorld(plant);
        plant.playSound("mob.newsound.chickenplop", 0.2F, ((rand.nextFloat() - rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
        world.setBlockMetadataWithNotify(x, y, z, world.getBlockMetadata(x, y, z) - 2, 3);
    }
}
Also used : ItemStack(net.minecraft.item.ItemStack) EntityItem(net.minecraft.entity.item.EntityItem)

Example 25 with EntityItem

use of net.minecraft.entity.item.EntityItem in project PneumaticCraft by MineMaarten.

the class SemiBlockManager method breakSemiBlock.

public void breakSemiBlock(World world, int x, int y, int z, EntityPlayer player) {
    ISemiBlock semiBlock = getSemiBlock(world, x, y, z);
    if (semiBlock != null) {
        List<ItemStack> drops = new ArrayList<ItemStack>();
        semiBlock.addDrops(drops);
        for (ItemStack stack : drops) {
            EntityItem item = new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, stack);
            world.spawnEntityInWorld(item);
            if (player != null)
                item.onCollideWithPlayer(player);
        }
        setSemiBlock(world, x, y, z, null);
    }
}
Also used : ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack) EntityItem(net.minecraft.entity.item.EntityItem)

Aggregations

EntityItem (net.minecraft.entity.item.EntityItem)284 ItemStack (net.minecraft.item.ItemStack)178 TileEntity (net.minecraft.tileentity.TileEntity)45 EntityPlayer (net.minecraft.entity.player.EntityPlayer)36 Entity (net.minecraft.entity.Entity)26 ArrayList (java.util.ArrayList)19 BlockPos (net.minecraft.util.math.BlockPos)19 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)18 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)16 World (net.minecraft.world.World)16 Random (java.util.Random)15 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)14 Item (net.minecraft.item.Item)13 IInventory (net.minecraft.inventory.IInventory)12 AxisAlignedBB (net.minecraft.util.AxisAlignedBB)12 List (java.util.List)11 Block (net.minecraft.block.Block)11 EntityLivingBase (net.minecraft.entity.EntityLivingBase)11 IBlockState (net.minecraft.block.state.IBlockState)10 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)6