net.minecraft.util.SoundEvent#net.minecraft.entity.item.EntityItem源码实例Demo

下面列出了net.minecraft.util.SoundEvent#net.minecraft.entity.item.EntityItem 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

private void outputInChamber(){
    TileEntityPressureChamberValve valve = getCore();
    if(valve != null) {
        for(int i = 0; i < 6; i++) {
            int x = xCoord + Facing.offsetsXForSide[i];
            int y = yCoord + Facing.offsetsYForSide[i];
            int z = zCoord + Facing.offsetsZForSide[i];
            if(valve.isCoordWithinChamber(worldObj, x, y, z)) {
                enoughAir = Math.abs(valve.currentAir) > inventory[0].stackSize * PneumaticValues.USAGE_CHAMBER_INTERFACE;
                if(enoughAir) {
                    valve.addAir((valve.currentAir > 0 ? -1 : 1) * inventory[0].stackSize * PneumaticValues.USAGE_CHAMBER_INTERFACE, ForgeDirection.UNKNOWN);
                    EntityItem item = new EntityItem(worldObj, x + 0.5D, y + 0.5D, z + 0.5D, inventory[0].copy());
                    worldObj.spawnEntityInWorld(item);
                    setInventorySlotContents(0, null);
                    break;
                }
            }
        }
    }
}
 
源代码2 项目: ForbiddenMagic   文件: BlockWrathCage.java
@Override
public void onBlockPreDestroy(World world, int x, int y, int z, int side) {
    TileEntityWrathCage spawner = (TileEntityWrathCage) world.getTileEntity(x, y, z);

    if (spawner != null && spawner.getSpawnerLogic().isMobSet()) {
        float f = world.rand.nextFloat() * 0.8F + 0.1F;
        float f1 = world.rand.nextFloat() * 0.8F + 0.1F;
        float f2 = world.rand.nextFloat() * 0.8F + 0.1F;

        ItemStack crystal = new ItemStack(ForbiddenItems.mobCrystal);
        crystal.setTagCompound(new NBTTagCompound());
        String mob = spawner.getSpawnerLogic().getEntityNameToSpawn();
        crystal.stackTagCompound.setString("mob", mob);

        EntityItem entityitem = new EntityItem(world, (double) ((float) x + f), (double) ((float) y + f1), (double) ((float) z + f2), crystal);

        entityitem.motionX = (double) ((float) world.rand.nextGaussian() * 0.05F);
        entityitem.motionY = (double) ((float) world.rand.nextGaussian() * 0.05F + 0.2F);
        entityitem.motionZ = (double) ((float) world.rand.nextGaussian() * 0.05F);
        world.spawnEntityInWorld(entityitem);

    }

    super.onBlockPreDestroy(world, x, y, z, side);
}
 
源代码3 项目: Gadomancy   文件: TileAuraPylon.java
private void breakTile() {
    if(!isPartOfMultiblock || worldObj.isRemote) return;

    int meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord);
    Block pylon = worldObj.getBlock(xCoord, yCoord, zCoord);
    if(pylon != null) {
        ArrayList<ItemStack> stacks = pylon.getDrops(worldObj, xCoord, yCoord, zCoord, meta, 0);
        for(ItemStack i : stacks) {
            EntityItem item = new EntityItem(worldObj, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, i);
            //ItemUtils.applyRandomDropOffset(item, worldObj.rand);
            worldObj.spawnEntityInWorld(item);
        }
    }
    worldObj.removeTileEntity(xCoord, yCoord, zCoord);
    worldObj.setBlockToAir(xCoord, yCoord, zCoord);
    worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
 
源代码4 项目: GregTech   文件: ScoopBehaviour.java
@Method(modid = GTValues.MODID_FR)
private boolean processButterflyCatch(ItemStack itemStack, EntityPlayer player, Entity entity) {
    if (entity instanceof IEntityButterfly) {
        if (player.world.isRemote) {
            return true;
        }
        if (player.capabilities.isCreativeMode || GTUtility.doDamageItem(itemStack, this.cost, false)) {
            IEntityButterfly butterfly = (IEntityButterfly) entity;
            IAlleleButterflySpecies species = butterfly.getButterfly().getGenome().getPrimary();
            species.getRoot().getBreedingTracker(entity.world, player.getGameProfile()).registerCatch(butterfly.getButterfly());
            player.world.spawnEntity(new EntityItem(player.world, entity.posX, entity.posY, entity.posZ,
                species.getRoot().getMemberStack(butterfly.getButterfly().copy(), EnumFlutterType.BUTTERFLY)));
            entity.setDead();
        }
        return true;
    }
    return false;
}
 
源代码5 项目: mocreaturesdev   文件: MoCEntityKitty.java
@Override
protected void attackEntity(Entity entity, float f)
{

    if ((f > 2.0F) && (f < 6F) && (rand.nextInt(30) == 0) && onGround)
    {
        double d = entity.posX - posX;
        double d1 = entity.posZ - posZ;
        float f1 = MathHelper.sqrt_double((d * d) + (d1 * d1));
        motionX = ((d / f1) * 0.5D * 0.8D) + (motionX * 0.2D);
        motionZ = ((d1 / f1) * 0.5D * 0.8D) + (motionZ * 0.2D);
        motionY = 0.4D;
    }
    if ((f < 2D) && (entity.boundingBox.maxY > boundingBox.minY) && (entity.boundingBox.minY < boundingBox.maxY))
    {
        attackTime = 20;
        if ((getKittyState() != 18) && (getKittyState() != 10))
        {
            swingArm();
        }
        if (((getKittyState() == 13) && (entity instanceof EntityPlayer)) || ((getKittyState() == 8) && (entity instanceof EntityItem)) || ((getKittyState() == 18) && (entity instanceof MoCEntityKitty)) || (getKittyState() == 10)) { return; }
        //if(worldObj.isRemote) 
        entity.attackEntityFrom(DamageSource.causeMobDamage(this), 1);
    }
}
 
源代码6 项目: PneumaticCraft   文件: BlockRepulsionPlant.java
@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.REPULSION_PLANT_DAMAGE);
        EntityItem plant = new EntityItem(world, x + 0.5D, y + 0.8D, z + 0.5D, seed);
        plant.motionX = (rand.nextFloat() - 0.5F) / 2;
        plant.motionY = 0.7F;
        plant.motionZ = (rand.nextFloat() - 0.5F) / 2;
        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);
    }
}
 
源代码7 项目: PneumaticCraft   文件: BlockElevatorBase.java
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, Block block){
    super.onNeighborBlockChange(world, x, y, z, block);
    TileEntity te = world.getTileEntity(x, y, z);
    if(te instanceof TileEntityElevatorBase) {
        TileEntityElevatorBase thisTe = (TileEntityElevatorBase)te;
        if(thisTe.isCoreElevator()) {
            TileEntityElevatorBase teAbove = getCoreTileEntity(world, x, y, z);
            if(teAbove != null && teAbove != thisTe) {
                for(int i = 0; i < thisTe.getSizeInventory(); i++) {
                    ItemStack item = thisTe.getStackInSlot(i);
                    if(item != null) {
                        ItemStack leftover = TileEntityHopper.func_145889_a(teAbove, item, 0);
                        thisTe.setInventorySlotContents(i, null);
                        if(leftover != null) {
                            EntityItem entity = new EntityItem(world, teAbove.xCoord + 0.5, teAbove.yCoord + 1.5, teAbove.zCoord + 0.5, leftover);
                            world.spawnEntityInWorld(entity);
                        }
                    }
                }
            }
        }
    }
}
 
源代码8 项目: PneumaticCraft   文件: BlockPneumaticPlantBase.java
@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);
    }
}
 
源代码9 项目: AgriCraft   文件: ItemClipper.java
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitx, float hity, float hitz) {
    if (world.isRemote) {
        return EnumActionResult.SUCCESS;
    }
    TileEntity te = world.getTileEntity(pos);
    if (te instanceof IAgriCrop) {
        IAgriCrop crop = (IAgriCrop) te;
        if (crop.hasSeed() && crop.getGrowthStage() > 1) {
            crop.setGrowthStage(crop.getGrowthStage() - 1);
            AgriSeed seed = crop.getSeed();
            seed = seed.withStat(seed.getStat());
            world.spawnEntity(new EntityItem(world, pos.getX(), pos.getY() + 1, pos.getZ(), ItemClipping.getClipping(seed, 1)));
            return EnumActionResult.SUCCESS;
        }
        return EnumActionResult.FAIL;
    }
    return EnumActionResult.PASS;   //return PASS or else no other use methods will be called (for instance "onBlockActivated" on the crops block)
}
 
源代码10 项目: mocreaturesdev   文件: MoCEntityAnimal.java
public EntityItem getClosestEntityItem(Entity entity, double d)
{
	double d1 = -1D;
	EntityItem entityitem = null;
	List list = worldObj.getEntitiesWithinAABBExcludingEntity(this, boundingBox.expand(d, d, d));
	for (int k = 0; k < list.size(); k++)
	{
		Entity entity1 = (Entity) list.get(k);
		if (!(entity1 instanceof EntityItem))
		{
			continue;
		}
		EntityItem entityitem1 = (EntityItem) entity1;
		double d2 = entityitem1.getDistanceSq(entity.posX, entity.posY, entity.posZ);
		if (((d < 0.0D) || (d2 < (d * d))) && ((d1 == -1D) || (d2 < d1)))
		{
			d1 = d2;
			entityitem = entityitem1;
		}
	}

	return entityitem;
}
 
源代码11 项目: PneumaticCraft   文件: FarmLogicHelium.java
@Override
public Collection<ItemStack> collect(){
    List<ItemStack> col = new ArrayList<ItemStack>();
    int[] coords = housing.getCoords();
    int[] area = housing.getArea();
    int[] offset = housing.getOffset();

    AxisAlignedBB harvestBox = AxisAlignedBB.getBoundingBox(coords[0] + offset[0], coords[1] + offset[1], coords[2] + offset[2], coords[0] + offset[0] + area[0], coords[1] + offset[1] + area[1], coords[2] + offset[2] + area[2]);
    List<EntityItem> list = housing.getWorld().getEntitiesWithinAABB(EntityItem.class, harvestBox);

    for(EntityItem item : list) {
        if(!item.isDead) {
            ItemStack contained = item.getEntityItem();
            if(isAcceptedGermling(contained)) {
                col.add(contained.copy());
                item.setDead();
            }
        }
    }
    return col;
}
 
源代码12 项目: PneumaticCraft   文件: BlockBurstPlant.java
@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);
    }
}
 
源代码13 项目: Kettle   文件: TrackingRange.java
/**
 * Gets the range an entity should be 'tracked' by players and visible in
 * the client.
 *
 * @param entity
 * @param defaultRange Default range defined by Mojang
 * @return
 */
public static int getEntityTrackingRange(Entity entity, int defaultRange) {
    SpigotWorldConfig config = entity.world.spigotConfig;
    if (entity instanceof EntityPlayer) {
        return config.playerTrackingRange;
    } else if (entity.activationType == 1) {
        return config.monsterTrackingRange;
    } else if (entity instanceof EntityGhast) {
        if (config.monsterTrackingRange > config.monsterActivationRange) {
            return config.monsterTrackingRange;
        } else {
            return config.monsterActivationRange;
        }
    } else if (entity.activationType == 2) {
        return config.animalTrackingRange;
    } else if (entity instanceof EntityItemFrame || entity instanceof EntityPainting || entity instanceof EntityItem || entity instanceof EntityXPOrb) {
        return config.miscTrackingRange;
    } else {
        return config.otherTrackingRange;
    }
}
 
源代码14 项目: PneumaticCraft   文件: RenderEntityChopperSeeds.java
public void renderChopperSeeds(EntityChopperSeeds entity, double x, double y, double z, float var1, float partialTicks){
    float scaleFactor = 0.7F;
    GL11.glPushMatrix(); // start
    GL11.glTranslatef((float)x, (float)y, (float)z); // size
    // GL11.glScalef(1.0F, -1F, -1F);
    GL11.glScalef(scaleFactor, scaleFactor, scaleFactor);
    EntityItem ghostEntityItem = new EntityItem(entity.worldObj);
    ghostEntityItem.hoverStart = 0.0F;
    ghostEntityItem.setEntityItemStack(iStack);
    double radius = 0.25D;
    for(int i = 0; i < 4; i++) {
        GL11.glPushMatrix();
        GL11.glTranslated(Math.sin(0.5D * Math.PI * i + (entity.ticksExisted + partialTicks) * 0.4D) * radius, 0, Math.cos(0.5D * Math.PI * i + (entity.ticksExisted + partialTicks) * 0.4D) * radius);
        itemRenderer.doRender(ghostEntityItem, 0, 0, 0, 0, 0);
        GL11.glPopMatrix();
    }
    GL11.glPopMatrix();
}
 
源代码15 项目: TFC2   文件: BlockLogVertical.java
@Override
public void createFallingEntity(World world, BlockPos pos, IBlockState state)
{
	if(world.rand.nextFloat() < 0.4)
	{
		world.setBlockToAir(pos);
		EntityItem ei = new EntityItem(world, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(Items.STICK, 1+world.rand.nextInt(3)));
		world.spawnEntity(ei);
	}
	else
	{
		int x = 0;
		int z = 0;
		if(world.rand.nextFloat() < 0.25)
		{
			x = -1 + world.rand.nextInt(3);
			z = -1 + world.rand.nextInt(3);
		}
		world.setBlockToAir(pos);
		EntityFallingBlockTFC entityfallingblock = new EntityFallingBlockTFC(world, pos.getX() + 0.5D + x, pos.getY(), pos.getZ() + 0.5D + z, state);
		world.spawnEntity(entityfallingblock);
	}
}
 
源代码16 项目: ExNihiloAdscensio   文件: ProjectileStone.java
@Override
protected void onImpact(RayTraceResult result)
{
    if (result.entityHit != null)
    {
        result.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, getThrower()), (int) (Math.random() * (4.0F / 3.0F)));
    }
    else if (!world.isRemote)
    {
        setDead();
        
        if(stack != null)
        {
            world.spawnEntity(new EntityItem(world, posX, posY, posZ, stack));
        }
    }
    
    for (int j = 0; j < 8; ++j)
    {
        world.spawnParticle(EnumParticleTypes.BLOCK_CRACK, posX, posY, posZ, 0.0D, 0.0D, 0.0D, new int[] { Block.getStateId(Blocks.STONE.getDefaultState()) });
    }
}
 
源代码17 项目: SimplyJetpacks   文件: PlatingReturnHandler.java
@SubscribeEvent
public void onItemCrafted(ItemCraftedEvent evt) {
    if (evt.player.worldObj.isRemote || !(evt.crafting.getItem() instanceof ItemPack)) {
        return;
    }
    
    PackBase outputPack = ((ItemPack) evt.crafting.getItem()).getPack(evt.crafting);
    if (outputPack.isArmored) {
        return;
    }
    
    for (int i = 0; i < evt.craftMatrix.getSizeInventory(); i++) {
        ItemStack input = evt.craftMatrix.getStackInSlot(i);
        if (input == null || !(input.getItem() instanceof ItemPack)) {
            continue;
        }
        PackBase inputPack = ((ItemPack) input.getItem()).getPack(input);
        if (inputPack != null && inputPack.isArmored && inputPack.platingMeta != null) {
            EntityItem item = evt.player.entityDropItem(new ItemStack(ModItems.armorPlatings, 1, inputPack.platingMeta), 0.0F);
            item.delayBeforeCanPickup = 0;
            break;
        }
    }
}
 
源代码18 项目: SkyblockAddons   文件: RenderManagerHook.java
public static void shouldRender(Entity entityIn, ReturnValue<Boolean> returnValue) {
    SkyblockAddons main = SkyblockAddons.getInstance();

    if (main.getUtils().isOnSkyblock()) {
        Location currentLocation = main.getUtils().getLocation();

        if (entityIn instanceof EntityItem &&
                entityIn.ridingEntity instanceof EntityArmorStand && entityIn.ridingEntity.isInvisible()) { // Conditions for skeleton helmet flying bones
            if (main.getConfigValues().isEnabled(Feature.HIDE_BONES)) {
                returnValue.cancel();
            }
        }
        if (main.getConfigValues().isEnabled(Feature.HIDE_PLAYERS_NEAR_NPCS)) {
            if (entityIn instanceof EntityOtherPlayerMP && NPCUtils.isNearAnyNPCWithTag(entityIn, Tag.IMPORTANT) && !NPCUtils.isNPC(entityIn)) {
                returnValue.cancel();
            }
        }
        if (main.getConfigValues().isEnabled(Feature.HIDE_PLAYERS_IN_LOBBY)) {
            if (currentLocation == Location.VILLAGE || currentLocation == Location.AUCTION_HOUSE ||
                    currentLocation == Location.BANK) {
                if ((entityIn instanceof EntityOtherPlayerMP || entityIn instanceof EntityFX || entityIn instanceof EntityItemFrame) &&
                        entityIn.getDistanceToEntity(Minecraft.getMinecraft().thePlayer) > 7) {
                    returnValue.cancel();
                }
            }
        }
        if(main.getConfigValues().isEnabled(Feature.HIDE_SVEN_PUP_NAMETAGS)) {
            if (entityIn instanceof EntityArmorStand && entityIn.hasCustomName()) {
                String customNameTag = entityIn.getCustomNameTag();

                if (customNameTag.contains("Sven Pup")) {
                    returnValue.cancel();
                }
            }
        }
    }
}
 
源代码19 项目: Gadomancy   文件: TileKnowledgeBook.java
private void applyMovementVectors(EntityItem entity) {
    double var3 = (this.xCoord + 0.5D - entity.posX) / 15.0D;
    double var5 = (this.yCoord + 0.5D - entity.posY) / 15.0D;
    double var7 = (this.zCoord + 0.5D - entity.posZ) / 15.0D;
    double var9 = Math.sqrt(var3 * var3 + var5 * var5 + var7 * var7);
    double var11 = 1.0D - var9;
    if (var11 > 0.0D) {
        var11 *= var11;
        entity.motionX += var3 / var9 * var11 * 0.15D;
        entity.motionY += var5 / var9 * var11 * 0.25D;
        entity.motionZ += var7 / var9 * var11 * 0.15D;
    }
}
 
源代码20 项目: ToroQuest   文件: ToroQuestCommand.java
private void dropItems(EntityPlayer player, List<ItemStack> items) {
	for (ItemStack stack : items) {
		EntityItem dropItem = new EntityItem(player.world, player.posX, player.posY, player.posZ, stack);
		dropItem.setNoPickupDelay();
		player.world.spawnEntity(dropItem);
	}
}
 
源代码21 项目: mocreaturesdev   文件: MoCEntityHorse.java
/**
 * Drops a chest block if the horse is bagged
 */
public void dropBags()
{
    if (!isBagger() || !getChestedHorse() || !MoCreatures.isServer()) { return; }

    EntityItem entityitem = new EntityItem(worldObj, posX, posY, posZ, new ItemStack(Block.chest, 1));
    float f3 = 0.05F;
    entityitem.motionX = (float) worldObj.rand.nextGaussian() * f3;
    entityitem.motionY = ((float) worldObj.rand.nextGaussian() * f3) + 0.2F;
    entityitem.motionZ = (float) worldObj.rand.nextGaussian() * f3;
    worldObj.spawnEntityInWorld(entityitem);
    setChestedHorse(false);
}
 
源代码22 项目: Sakura_mod   文件: BlockShoji.java
@Override
public void breakBlock(World worldIn, BlockPos pos, IBlockState state) {
 ItemStack stack = getDefaultItemStack();
 TileEntityShoji te = (TileEntityShoji) worldIn.getTileEntity(pos);
 if (te != null) {
 	RecipesUtil.getItemTagCompound(stack).setInteger("type", te.getType());
 } else {
 	RecipesUtil.getItemTagCompound(stack).setInteger("type", 0);
 }
    worldIn.spawnEntity(new EntityItem(worldIn, pos.getX(), pos.getY(), pos.getZ(), stack));
    super.breakBlock(worldIn, pos, state);
}
 
源代码23 项目: TFC2   文件: BlockWoodSupport.java
@Override
public void createFallingEntity(World world, BlockPos pos, IBlockState state)
{
	world.setBlockToAir(pos);
	EntityItem ei = new EntityItem(world, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(Items.STICK, 1+world.rand.nextInt(3)));
	world.spawnEntity(ei);
}
 
源代码24 项目: AdvancedMod   文件: TileEntityModularStorage.java
@Override
public void invalidate(){
    super.invalidate();
    for(ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
        TileEntity te = worldObj.getTileEntity(xCoord + d.offsetX, yCoord + d.offsetY, zCoord + d.offsetZ);
        if(te instanceof TileEntityModularStorage) {
            ((TileEntityModularStorage)te).master = null;
            ((TileEntityModularStorage)te).initializeMultiblockIfNecessary();
        }
    }
    for(ItemStack stack : inventory) {
        if(stack != null) worldObj.spawnEntityInWorld(new EntityItem(worldObj, xCoord, yCoord, zCoord, stack));
    }
}
 
源代码25 项目: CommunityMod   文件: EntityChickenArrow.java
@Override
protected void onHit(RayTraceResult raytraceResultIn) {
    if (this.world.isRemote)
        return;
    this.setDead();
    EntityChicken chicken = new EntityChicken(world);
    Vec3d hit = raytraceResultIn.hitVec;
    chicken.setPosition(hit.x, hit.y, hit.z);
    world.spawnEntity(chicken);
    world.spawnEntity(new EntityItem(world, hit.x, hit.y, hit.z, new ItemStack(Items.EGG)));
}
 
源代码26 项目: CommunityMod   文件: BlockAltar.java
@Override
public void breakBlock(World world, BlockPos pos, IBlockState state) {
	TileEntity tileEntity = world.getTileEntity(pos);
	if (tileEntity instanceof TileEntityAltar) {
		ItemStack stack = ((TileEntityAltar) tileEntity).getStack();
		if (!stack.isEmpty()) {
			EntityItem drop = new EntityItem(world, pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, stack);
			world.spawnEntity(drop);
		}
	}
	super.breakBlock(world, pos, state);
}
 
源代码27 项目: CodeChickenLib   文件: InventoryUtils.java
/**
 * Spawns an itemstack in the world at a location
 */
public static void dropItem(ItemStack stack, World world, Vector3 dropLocation) {
    EntityItem item = new EntityItem(world, dropLocation.x, dropLocation.y, dropLocation.z, stack);
    item.motionX = world.rand.nextGaussian() * 0.05;
    item.motionY = world.rand.nextGaussian() * 0.05 + 0.2F;
    item.motionZ = world.rand.nextGaussian() * 0.05;
    world.spawnEntityInWorld(item);
}
 
源代码28 项目: EmergingTechnology   文件: HarvesterTileEntity.java
private boolean pullItems(EnumFacing facing) {

        if (getTargetBlockState(facing) == null) {
            return false;
        }

        // Includes target and directly above target
        AxisAlignedBB collectionArea = new AxisAlignedBB(getTarget(facing)).expand(0, 1, 0);

        List<EntityItem> entityItems = world.getEntitiesWithinAABB(EntityItem.class, collectionArea);
        insertItems(entityItems);

        return true;
    }
 
源代码29 项目: Cyberware   文件: ItemBrainUpgrade.java
@SubscribeEvent
public void handleClone(PlayerEvent.Clone event)
{
	if (event.isWasDeath())
	{
		EntityPlayer p = event.getOriginal();
		
		if (CyberwareAPI.isCyberwareInstalled(p, new ItemStack(this, 1, 0)) && !p.worldObj.getGameRules().getBoolean("keepInventory"))
		{
			/*float range = 5F;
			List<EntityXPOrb> orbs = p.worldObj.getEntitiesWithinAABB(EntityXPOrb.class, new AxisAlignedBB(p.posX - range, p.posY - range, p.posZ - range, p.posX + p.width + range, p.posY + p.height + range, p.posZ + p.width + range));
			for (EntityXPOrb orb : orbs)
			{
				orb.setDead();
			}*/

			if (!p.worldObj.isRemote)
			{
				ItemStack stack = new ItemStack(CyberwareContent.expCapsule);
				NBTTagCompound c = new NBTTagCompound();
				c.setInteger("xp", p.experienceTotal);
				stack.setTagCompound(c);
				EntityItem item = new EntityItem(p.worldObj, p.posX, p.posY, p.posZ, stack);
				p.worldObj.spawnEntityInWorld(item);
			}
		}
		else if (CyberwareAPI.isCyberwareInstalled(p, new ItemStack(this, 1, 2)) && !p.worldObj.getGameRules().getBoolean("keepInventory"))
		{
			event.getEntityPlayer().addExperience((int) (Math.min(100, p.experienceLevel * 7) * .9F));
		}
	}
}
 
源代码30 项目: AdvancedMod   文件: AdvancedModEventHandler.java
/**
 * Using the LivingDropsEvent. Note that this is from  net.minecraftforge.event, so to make this method be called, this class needs to be registered at MinecraftForge.EVENT_BUS.register(new AdvancedModEventHandler()).
 * @param event
 */
@SubscribeEvent
public void addPigDrops(LivingDropsEvent event){
    if(event.entityLiving instanceof EntityPig && event.entityLiving.getRNG().nextInt(3) == 0) {
        ItemStack stack = new ItemStack(ModBlocks.dutchFlag);
        event.drops.add(new EntityItem(event.entityLiving.worldObj, event.entityLiving.posX, event.entityLiving.posY, event.entityLiving.posZ, stack));
    }
}