Java 类net.minecraft.entity.item.EntityItem 实例源码

项目:MakeClayValuableAgain    文件:ClayProgressionImprovements.java   
@SubscribeEvent
public void dropClay(LivingDropsEvent event) {
    EntityLivingBase deadEntity = event.getEntityLiving();
    World world = deadEntity.getEntityWorld();
    BlockPos position = deadEntity.getPosition();
    double x = position.getX();
    double y = position.getY();
    double z = position.getZ();
    if (deadEntity instanceof EntityWitherSkeleton) {
        if (world.rand.nextInt(10) == 5) {
            event.getDrops().add(new EntityItem(world, x, y, z, new ItemStack(Items.CLAY_BALL)));
        }
    } else if (deadEntity instanceof EntityDragon || deadEntity instanceof EntityWither) {
        event.getDrops().add(new EntityItem(world, x, y, z, new ItemStack(Items.CLAY_BALL)));
    }
}
项目:DecompiledMinecraft    文件:BehaviorDefaultDispenseItem.java   
public static void doDispense(World worldIn, ItemStack stack, int speed, EnumFacing facing, IPosition position)
{
    double d0 = position.getX();
    double d1 = position.getY();
    double d2 = position.getZ();

    if (facing.getAxis() == EnumFacing.Axis.Y)
    {
        d1 = d1 - 0.125D;
    }
    else
    {
        d1 = d1 - 0.15625D;
    }

    EntityItem entityitem = new EntityItem(worldIn, d0, d1, d2, stack);
    double d3 = worldIn.rand.nextDouble() * 0.1D + 0.2D;
    entityitem.motionX = (double)facing.getFrontOffsetX() * d3;
    entityitem.motionY = 0.20000000298023224D;
    entityitem.motionZ = (double)facing.getFrontOffsetZ() * d3;
    entityitem.motionX += worldIn.rand.nextGaussian() * 0.007499999832361937D * (double)speed;
    entityitem.motionY += worldIn.rand.nextGaussian() * 0.007499999832361937D * (double)speed;
    entityitem.motionZ += worldIn.rand.nextGaussian() * 0.007499999832361937D * (double)speed;
    worldIn.spawnEntityInWorld(entityitem);
}
项目:pnc-repressurized    文件:RenderDroneHeldItem.java   
public void render(@Nonnull ItemStack droneHeldItem) {
    EntityItem carriedItem = new EntityItem(world);
    carriedItem.hoverStart = 0.0F;
    carriedItem.setItem(droneHeldItem);

    double scaleFactor = carriedItem.getItem().getItem() instanceof ItemBlock ? 0.7F : 0.5F;

    double yOffset = -0.2F;
    if (carriedItem.getItem().getItem() instanceof ItemTool || carriedItem.getItem().getItem() instanceof ItemSword) {
        // since items are rendered suspended under the drone,
        // holding tools upside down looks more natural - especially if the drone is digging with them
        GlStateManager.rotate(180, 1, 0, 0);
    }
    GlStateManager.translate(0, yOffset, 0);
    GlStateManager.scale(scaleFactor, scaleFactor, scaleFactor);
    customRenderItem.doRender(carriedItem, 0, 0, 0, 0, 0);
}
项目:DecompiledMinecraft    文件:EntityLiving.java   
/**
 * Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons
 * use this to react to sunlight and start to burn.
 */
public void onLivingUpdate()
{
    super.onLivingUpdate();
    this.worldObj.theProfiler.startSection("looting");

    if (!this.worldObj.isRemote && this.canPickUpLoot() && !this.dead && this.worldObj.getGameRules().getBoolean("mobGriefing"))
    {
        for (EntityItem entityitem : this.worldObj.getEntitiesWithinAABB(EntityItem.class, this.getEntityBoundingBox().expand(1.0D, 0.0D, 1.0D)))
        {
            if (!entityitem.isDead && entityitem.getEntityItem() != null && !entityitem.cannotPickup())
            {
                this.updateEquipmentIfNeeded(entityitem);
            }
        }
    }

    this.worldObj.theProfiler.endSection();
}
项目:minecraft-quiverbow    文件:Endernymous.java   
private void dropMagazine(World world, ItemStack stack, Entity entity)
{
    if (!(entity instanceof EntityPlayer)) // For QuiverMobs/Arms Assistants
    {
        this.setCooldown(stack, 60);
        return;
    }

    ItemStack clipStack = Helper.getAmmoStack(EnderQuartzClip.class, stack.getItemDamage());    // Unloading all ammo into that clip

    stack.setItemDamage(this.getMaxDamage());   // Emptying out

    // Creating the clip
    EntityItem entityitem = new EntityItem(world, entity.posX, entity.posY + 1.0d, entity.posZ, clipStack);
    entityitem.delayBeforeCanPickup = 10;

    // And dropping it
    if (entity.captureDrops) { entity.capturedDrops.add(entityitem); }
    else { world.spawnEntityInWorld(entityitem); }

    // SFX
    world.playSoundAtEntity(entity, "random.break", 1.0F, 0.3F);
}
项目:uniquecrops    文件:Dirigible.java   
@Override
   public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) {

    if (world.getLightFromNeighbors(pos.up()) >= 9) {
        if ((this.getAge(state) + 1) >= getMaxAge())
        {
            EntityItem ei = new EntityItem(world, pos.getX() + 0.5D, pos.getY(), pos.getZ() + 0.5D, UCItems.generic.createStack(EnumItems.PLUM));
            if (!world.isRemote)
                world.spawnEntityInWorld(ei);
            UCPacketHandler.sendToNearbyPlayers(world, pos, new PacketUCEffect(EnumParticleTypes.EXPLOSION_NORMAL, pos.getX(), pos.getY(), pos.getZ(), 4));
            world.setBlockState(pos, withAge(0), 2);
            return;
        }
    }
    super.updateTick(world, pos, state, rand);
}
项目:minecraft-quiverbow    文件:NetherBellows.java   
private void dropMagazine(World world, ItemStack stack, Entity entity)
{
    if (!(entity instanceof EntityPlayer)) // For QuiverMobs/Arms Assistants
    {
        this.setCooldown(stack, 60);
        return;
    }

    ItemStack clipStack = Helper.getAmmoStack(LargeNetherrackMagazine.class, stack.getItemDamage());    // Unloading all ammo into that clip

    stack.setItemDamage(this.getMaxDamage());   // Emptying out

    // Creating the clip
    EntityItem entityitem = new EntityItem(world, entity.posX, entity.posY + 1.0d, entity.posZ, clipStack);
    entityitem.delayBeforeCanPickup = 10;

    // And dropping it
    if (entity.captureDrops) { entity.capturedDrops.add(entityitem); }
    else { world.spawnEntityInWorld(entityitem); }

    // SFX
    world.playSoundAtEntity(entity, "random.break", 1.0F, 0.5F);
}
项目:uniquecrops    文件:EntityEulaBook.java   
@Override
  protected void onImpact(RayTraceResult result) {

BlockPos pos = new BlockPos(result.hitVec);
if (result.typeOfHit == RayTraceResult.Type.ENTITY) {
    Entity ent = result.entityHit;
    if (!ent.isDead && ent instanceof EntityPlayerMP && ent.worldObj.isRemote) {
        ((EntityPlayerMP)ent).openGui(UniqueCrops.instance, 1, worldObj, (int)ent.posX, (int)ent.posY, (int)ent.posZ);
    }
    this.setDead();
    UCPacketHandler.sendToNearbyPlayers(worldObj, pos, new PacketUCEffect(EnumParticleTypes.CRIT, pos.getX() - 0.5D, pos.getY() - 0.5D, pos.getZ() - 0.5D, 5));
}
else if (result.typeOfHit == RayTraceResult.Type.BLOCK) {
    ItemStack stack = UCItems.generic.createStack(EnumItems.EULA);
    EntityItem eibook = new EntityItem(worldObj, pos.offset(result.sideHit).getX(), pos.offset(result.sideHit).getY(), pos.offset(result.sideHit).getZ(), stack);
    if (!worldObj.isRemote)
        worldObj.spawnEntityInWorld(eibook);
    this.setDead();
}
else
    this.setDead();
  }
项目:DecompiledMinecraft    文件:EntityLivingBase.java   
/**
 * Called whenever an item is picked up from walking over it. Args: pickedUpEntity, stackSize
 */
public void onItemPickup(Entity p_71001_1_, int p_71001_2_)
{
    if (!p_71001_1_.isDead && !this.worldObj.isRemote)
    {
        EntityTracker entitytracker = ((WorldServer)this.worldObj).getEntityTracker();

        if (p_71001_1_ instanceof EntityItem)
        {
            entitytracker.sendToAllTrackingEntity(p_71001_1_, new S0DPacketCollectItem(p_71001_1_.getEntityId(), this.getEntityId()));
        }

        if (p_71001_1_ instanceof EntityArrow)
        {
            entitytracker.sendToAllTrackingEntity(p_71001_1_, new S0DPacketCollectItem(p_71001_1_.getEntityId(), this.getEntityId()));
        }

        if (p_71001_1_ instanceof EntityXPOrb)
        {
            entitytracker.sendToAllTrackingEntity(p_71001_1_, new S0DPacketCollectItem(p_71001_1_.getEntityId(), this.getEntityId()));
        }
    }
}
项目:uniquecrops    文件:GrowthSteps.java   
@Override
public boolean canAdvance(World world, BlockPos pos, IBlockState state) {

    List<EntityItem> items = world.getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(pos, pos.add(1, 1, 1)));
    for (EntityItem item : items) {
        if (!item.isDead && item.getEntityItem() != null) {
            if (item.getEntityItem().getItem() instanceof ItemFood)
            {
                UCPacketHandler.sendToNearbyPlayers(world, pos, new PacketUCEffect(EnumParticleTypes.CLOUD, pos.getX(), pos.getY(), pos.getZ(), 6));
                item.getEntityItem().stackSize--;
                if (item.getEntityItem().stackSize <= 0)
                    item.setDead();
                return true;
            }
        }
    }
    return false;
}
项目:CustomWorldGen    文件:Block.java   
/**
 * Spawns the given ItemStack as an EntityItem into the World at the given position
 */
public static void spawnAsEntity(World worldIn, BlockPos pos, ItemStack stack)
{
    if (!worldIn.isRemote && worldIn.getGameRules().getBoolean("doTileDrops") && !worldIn.restoringBlockSnapshots) // do not drop items while restoring blockstates, prevents item dupe
    {
        if (captureDrops.get())
        {
            capturedDrops.get().add(stack);
            return;
        }
        float f = 0.5F;
        double d0 = (double)(worldIn.rand.nextFloat() * 0.5F) + 0.25D;
        double d1 = (double)(worldIn.rand.nextFloat() * 0.5F) + 0.25D;
        double d2 = (double)(worldIn.rand.nextFloat() * 0.5F) + 0.25D;
        EntityItem entityitem = new EntityItem(worldIn, (double)pos.getX() + d0, (double)pos.getY() + d1, (double)pos.getZ() + d2, stack);
        entityitem.setDefaultPickupDelay();
        worldIn.spawnEntityInWorld(entityitem);
    }
}
项目:DecompiledMinecraft    文件:EntityWither.java   
/**
 * Drop 0-2 items of this living's type
 */
protected void dropFewItems(boolean p_70628_1_, int p_70628_2_)
{
    EntityItem entityitem = this.dropItem(Items.nether_star, 1);

    if (entityitem != null)
    {
        entityitem.setNoDespawn();
    }

    if (!this.worldObj.isRemote)
    {
        for (EntityPlayer entityplayer : this.worldObj.getEntitiesWithinAABB(EntityPlayer.class, this.getEntityBoundingBox().expand(50.0D, 100.0D, 50.0D)))
        {
            entityplayer.triggerAchievement(AchievementList.killWither);
        }
    }
}
项目:harshencastle    文件:BaseItemRenderer.java   
@Override
public void render(T te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
    super.render(te, x, y, z, partialTicks, destroyStage, alpha);
    EntityItem item = new EntityItem(Minecraft.getMinecraft().world, 0, 0, 0, te.getItem());
    item.hoverStart = 0.0f;
    int rotateAngle = te.getTimer() * 6;
    GlStateManager.pushMatrix();
    {
        GlStateManager.translate(x, y, z);
        GlStateManager.translate(movePos().x, movePos().y, movePos().z);
        GlStateManager.scale(0.7f, 0.7f, 0.7f);
        GlStateManager.translate(0, Math.sin(rotateAngle) / 20f, 0);
        moveMore(te);
        GlStateManager.rotate(te.getTimer() % 360 * getMovementSpeed(te), 0, 1, 0);
        Minecraft.getMinecraft().getRenderManager().renderEntity(item, 0f, 0f, 0f, 0f, 0f, false);

    }
    GlStateManager.popMatrix();
}
项目:Adventurers-Toolbox    文件:EntityRock.java   
@Override
protected void onImpact(RayTraceResult result) {
    //System.out.println(MathHelper.sqrt((MathHelper.abs((float) this.motionX) + MathHelper.abs((float) this.motionY) + MathHelper.abs((float) this.motionZ))));
    if (result.entityHit != null) {
        float f = MathHelper.sqrt((MathHelper.abs((float) this.motionX) + MathHelper.abs((float) this.motionY) + MathHelper.abs((float) this.motionZ)));
        result.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), 4F * f);
    }

    if (!this.world.isRemote) {
        if (this.rand.nextFloat() < 0.5F) {
            EntityItem rock = new EntityItem(world, posX, posY, posZ, new ItemStack(ModItems.rock));
            world.spawnEntity(rock);
        } else {
            this.world.setEntityState(this, (byte) 3);
        }
        this.setDead();
    }
}
项目:Infernum    文件:BlockPedestal.java   
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand,
        EnumFacing side, float hitX, float hitY, float hitZ) {

    if (!world.isRemote && world.getTileEntity(pos) instanceof TilePedestal) {
        TilePedestal pedestal = (TilePedestal) world.getTileEntity(pos);
        if (pedestal.getStack().func_190926_b()) {
            if (!player.getHeldItem(hand).func_190926_b()) {
                pedestal.setStack(player.getHeldItem(hand));
                player.inventory.setInventorySlotContents(player.inventory.currentItem, ItemStack.field_190927_a);
                player.openContainer.detectAndSendChanges();
            }
        } else {
            ItemStack stack = pedestal.getStack();
            pedestal.setStack(ItemStack.field_190927_a);
            if (!player.inventory.addItemStackToInventory(stack)) {
                EntityItem entityItem = new EntityItem(world, pos.getX(), pos.getY() + 1, pos.getZ(), stack);
                world.spawnEntity(entityItem);
            } else {
                player.openContainer.detectAndSendChanges();
            }
        }
    }

    return true;
}
项目:DecompiledMinecraft    文件:EntityLiving.java   
/**
 * Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons
 * use this to react to sunlight and start to burn.
 */
public void onLivingUpdate()
{
    super.onLivingUpdate();
    this.worldObj.theProfiler.startSection("looting");

    if (!this.worldObj.isRemote && this.canPickUpLoot() && !this.dead && this.worldObj.getGameRules().getBoolean("mobGriefing"))
    {
        for (EntityItem entityitem : this.worldObj.getEntitiesWithinAABB(EntityItem.class, this.getEntityBoundingBox().expand(1.0D, 0.0D, 1.0D)))
        {
            if (!entityitem.isDead && entityitem.getEntityItem() != null && !entityitem.cannotPickup())
            {
                this.updateEquipmentIfNeeded(entityitem);
            }
        }
    }

    this.worldObj.theProfiler.endSection();
}
项目:CustomWorldGen    文件:EntityLiving.java   
/**
 * Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons
 * use this to react to sunlight and start to burn.
 */
public void onLivingUpdate()
{
    super.onLivingUpdate();
    this.worldObj.theProfiler.startSection("looting");

    if (!this.worldObj.isRemote && this.canPickUpLoot() && !this.dead && this.worldObj.getGameRules().getBoolean("mobGriefing"))
    {
        for (EntityItem entityitem : this.worldObj.getEntitiesWithinAABB(EntityItem.class, this.getEntityBoundingBox().expand(1.0D, 0.0D, 1.0D)))
        {
            if (!entityitem.isDead && entityitem.getEntityItem() != null && !entityitem.cannotPickup())
            {
                this.updateEquipmentIfNeeded(entityitem);
            }
        }
    }

    this.worldObj.theProfiler.endSection();
}
项目:MeeCreeps    文件:DigTunnelActionWorker.java   
private void buildSupport(BlockPos pos, EntityItem entityItem) {
    ItemStack blockStack = entityItem.getItem();
    ItemStack actual = blockStack.splitStack(1);
    if (blockStack.isEmpty()) {
        entityItem.setDead();
    }
    if (actual.isEmpty()) {
        return;
    }
    Item item = actual.getItem();
    if (!(item instanceof ItemBlock)) {
        // Safety
        return;
    }

    IMeeCreep entity = helper.getMeeCreep();
    World world = entity.getWorld();
    Block block = ((ItemBlock) item).getBlock();
    IBlockState stateForPlacement = block.getStateForPlacement(world, pos, EnumFacing.UP, 0, 0, 0, item.getMetadata(actual), GeneralTools.getHarvester(), EnumHand.MAIN_HAND);
    world.setBlockState(pos, stateForPlacement, 3);
    SoundTools.playSound(world, block.getSoundType().getPlaceSound(), pos.getX(), pos.getY(), pos.getZ(), 1.0f, 1.0f);
}
项目:DecompiledMinecraft    文件:EntityLivingBase.java   
/**
 * Called whenever an item is picked up from walking over it. Args: pickedUpEntity, stackSize
 */
public void onItemPickup(Entity p_71001_1_, int p_71001_2_)
{
    if (!p_71001_1_.isDead && !this.worldObj.isRemote)
    {
        EntityTracker entitytracker = ((WorldServer)this.worldObj).getEntityTracker();

        if (p_71001_1_ instanceof EntityItem)
        {
            entitytracker.sendToAllTrackingEntity(p_71001_1_, new S0DPacketCollectItem(p_71001_1_.getEntityId(), this.getEntityId()));
        }

        if (p_71001_1_ instanceof EntityArrow)
        {
            entitytracker.sendToAllTrackingEntity(p_71001_1_, new S0DPacketCollectItem(p_71001_1_.getEntityId(), this.getEntityId()));
        }

        if (p_71001_1_ instanceof EntityXPOrb)
        {
            entitytracker.sendToAllTrackingEntity(p_71001_1_, new S0DPacketCollectItem(p_71001_1_.getEntityId(), this.getEntityId()));
        }
    }
}
项目:MeeCreeps    文件:DigdownStairsActionWorker.java   
private void collectCobble(EntityItem entityItem) {
    ItemStack blockStack = entityItem.getItem();
    ItemStack actual = blockStack.splitStack(6);
    if (blockStack.isEmpty()) {
        entityItem.setDead();
    }
    if (actual.isEmpty()) {
        return;
    }
    Item item = actual.getItem();
    if (!(item instanceof ItemBlock)) {
        // Safety
        return;
    }
    numCobble += actual.getCount();
}
项目:BaseClient    文件:EntityWither.java   
/**
 * Drop 0-2 items of this living's type
 */
protected void dropFewItems(boolean p_70628_1_, int p_70628_2_)
{
    EntityItem entityitem = this.dropItem(Items.nether_star, 1);

    if (entityitem != null)
    {
        entityitem.setNoDespawn();
    }

    if (!this.worldObj.isRemote)
    {
        for (EntityPlayer entityplayer : this.worldObj.getEntitiesWithinAABB(EntityPlayer.class, this.getEntityBoundingBox().expand(50.0D, 100.0D, 50.0D)))
        {
            entityplayer.triggerAchievement(AchievementList.killWither);
        }
    }
}
项目:pnc-repressurized    文件:ModelChargingStation.java   
public void renderModel(float scale, boolean renderChargePad, EntityItem ghostEntityItem) {
    if (renderChargePad) {
        shape3.render(scale);
        shape4.render(scale);
        shape5.render(scale);
        shape6.render(scale);
        shape7.render(scale);
        shape8.render(scale);
        shape9.render(scale);
        shape10.render(scale);
        shape11.render(scale);
        shape12.render(scale);
        shape13.render(scale);
        shape14.render(scale);
        shape15.render(scale);
        shape16.render(scale);
    }
    if (ghostEntityItem != null) {
        if (customRenderItem == null) {
            customRenderItem = new AbstractModelRenderer.NoBobItemRenderer();
        }
        GlStateManager.translate(0, 1.25f, 0);
        GlStateManager.scale(1.0F, -1F, -1F);

        RenderManager renderManager = Minecraft.getMinecraft().getRenderManager();
        boolean fancySetting = renderManager.options.fancyGraphics;
        renderManager.options.fancyGraphics = true;
        customRenderItem.doRender(ghostEntityItem, 0, 0, 0, 0, 0);
        renderManager.options.fancyGraphics = fancySetting;
    }
}
项目:Thermionics    文件:BlockScaffold.java   
@Override
public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity entity) {
    if (entity instanceof EntityItem) return;

    if (entity.isCollidedHorizontally) {
        entity.motionY = 0.35;
    } else if (entity.isSneaking()) {
        entity.motionY = 0.08; //Stop, but also counteract EntityLivingBase-applied microgravity
    } else if (entity.motionY<-0.20) {
        entity.motionY = -0.20;
    }
    entity.fallDistance = 0.0f;
}
项目:Backmemed    文件:EntityPlayer.java   
@Nullable

    /**
     * Drop one item out of the currently selected stack if {@code dropAll} is false. If {@code dropItem} is true the
     * entire stack is dropped.
     */
    public EntityItem dropItem(boolean dropAll)
    {
        return this.dropItem(this.inventory.decrStackSize(this.inventory.currentItem, dropAll && !this.inventory.getCurrentItem().func_190926_b() ? this.inventory.getCurrentItem().func_190916_E() : 1), false, true);
    }
项目:pnc-repressurized    文件:PneumaticCraftUtils.java   
public static void dropItemOnGroundPrecisely(ItemStack stack, World world, double x, double y, double z) {
    EntityItem entityItem = new EntityItem(world, x, y, z, new ItemStack(stack.getItem(), stack.getCount(), stack.getItemDamage()));

    if (stack.hasTagCompound()) {
        entityItem.getItem().setTagCompound(stack.getTagCompound().copy());
    }

    world.spawnEntity(entityItem);
    stack.setCount(0);
}
项目:CustomWorldGen    文件:TileEntityHopper.java   
/**
 * Attempts to place the passed EntityItem's stack into the inventory using as many slots as possible. Returns false
 * if the stackSize of the drop was not depleted.
 */
public static boolean putDropInInventoryAllSlots(IInventory p_145898_0_, EntityItem itemIn)
{
    boolean flag = false;

    if (itemIn == null)
    {
        return false;
    }
    else
    {
        ItemStack itemstack = itemIn.getEntityItem().copy();
        ItemStack itemstack1 = putStackInInventoryAllSlots(p_145898_0_, itemstack, (EnumFacing)null);

        if (itemstack1 != null && itemstack1.stackSize != 0)
        {
            itemIn.setEntityItemStack(itemstack1);
        }
        else
        {
            flag = true;
            itemIn.setDead();
        }

        return flag;
    }
}
项目:EndermanEvolution    文件:EntityFrienderman.java   
@Override
public boolean shouldExecute() {
    //EntityLivingBase entitylivingbase = thePet.getOwner();
    itemsNear = thePet.getEntityWorld().getEntitiesWithinAABB(EntityItem.class, thePet.getEntityBoundingBox().expand(0.0D, -1.0D, 0.0D).expand(6.0D, 2.0D, 6.0D));
    if (!thePet.isTamed() || itemsNear.size() <= 0 || !thePet.isHoldingChest()) {
        return false;
    }
    return true;
}
项目:pnc-repressurized    文件:TileEntityPressureChamberValve.java   
private void captureEntityItemsInChamber(){
    AxisAlignedBB bbBox = getChamberAABB();
    List<EntityItem> items = getWorld().getEntitiesWithinAABB(EntityItem.class, bbBox);
    for(EntityItem item : items){
        if(!item.isDead){
            ItemStack stack = item.getItem();
            ItemStack leftover = ItemHandlerHelper.insertItem(itemsInChamber, stack, false);
            if(leftover.isEmpty()) item.setDead();
            else item.setItem(stack);
        }
    }
}
项目:BaseClient    文件:RenderEntityItem.java   
private int func_177077_a(EntityItem itemIn, double p_177077_2_, double p_177077_4_, double p_177077_6_, float p_177077_8_, IBakedModel p_177077_9_)
{
    ItemStack itemstack = itemIn.getEntityItem();
    Item item = itemstack.getItem();

    if (item == null)
    {
        return 0;
    }
    else
    {
        boolean flag = p_177077_9_.isGui3d();
        int i = this.func_177078_a(itemstack);
        float f = 0.25F;
        float f1 = MathHelper.sin(((float)itemIn.getAge() + p_177077_8_) / 10.0F + itemIn.hoverStart) * 0.1F + 0.1F;
        float f2 = p_177077_9_.getItemCameraTransforms().getTransform(ItemCameraTransforms.TransformType.GROUND).scale.y;
        GlStateManager.translate((float)p_177077_2_, (float)p_177077_4_ + f1 + 0.25F * f2, (float)p_177077_6_);

        if (flag || this.renderManager.options != null)
        {
            float f3 = (((float)itemIn.getAge() + p_177077_8_) / 20.0F + itemIn.hoverStart) * (180F / (float)Math.PI);
            GlStateManager.rotate(f3, 0.0F, 1.0F, 0.0F);
        }

        if (!flag)
        {
            float f6 = -0.0F * (float)(i - 1) * 0.5F;
            float f4 = -0.0F * (float)(i - 1) * 0.5F;
            float f5 = -0.046875F * (float)(i - 1) * 0.5F;
            GlStateManager.translate(f6, f4, f5);
        }

        GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
        return i;
    }
}
项目:BetterBeginningsReborn    文件:TileEntityInfusionRepair.java   
private void absorbItems()
   {
List<EntityItem> items = world.getEntitiesWithinAABB(EntityItem.class, searchBox);
IBlockState state = world.getBlockState(pos);
for (EntityItem entityItem : items)
{
    if(tryAbsorbDroppedItem(entityItem, state))
    {
    markDirty();
    world.notifyBlockUpdate(pos, state, state, 8);
    }
    if(entityItem.getItem().getCount() == 0)
    entityItem.setDead();
}
   }
项目:uniquecrops    文件:BlockHourglass.java   
@Override
public Entity createEntity(World world, Entity location, ItemStack stack) {

    if (location instanceof EntityItem) {
        EntityItemHourglass hourglass = new EntityItemHourglass(world, (EntityItem)location, stack);
        return hourglass;
    }
    return null;
}
项目:Uranium    文件: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.worldObj.getSpigotConfig(); // Cauldron
    int range = defaultRange;
    if ( entity instanceof EntityPlayerMP )
    {
        range = config.playerTrackingRange;
    } else if ( entity.defaultActivationState || entity instanceof EntityGhast )
    {
        range = defaultRange;
    } else if ( entity.activationType == 1 )
    {
        range = config.monsterTrackingRange;
    } else if ( entity.activationType == 2 )
    {
        range = config.animalTrackingRange;
    } else if ( entity instanceof EntityItemFrame || entity instanceof EntityPainting || entity instanceof EntityItem || entity instanceof EntityXPOrb )
    {
        range = config.miscTrackingRange;
    }
    // Cauldron start - allow for 0 to disable tracking ranges
    if (range == 0)
    {
        return defaultRange;
    }
    // Cauldron end

    return Math.min( config.maxTrackingRange, range );
}
项目:Uranium    文件:ItemSnapshot.java   
/**
 * 将物品放到玩家身上
 * 
 * @return 如果背包满,将生成物品在地上并返回false
 */
public boolean apply(){
    if(!this.mApply){
        this.mApply=true;

        if(!this.mPlayer.inventory.addItemStackToInventory(this.mItem)){
            this.mPlayer.worldObj.spawnEntityInWorld(
                    new EntityItem(this.mPlayer.worldObj,this.mPlayer.posX,this.mPlayer.posY,this.mPlayer.posZ,this.mItem));
            return false;
        }
    }
    return true;
}
项目:JustJunk    文件:PotionSick.java   
@Override
public void performEffect(EntityLivingBase entityLivingBaseIn, int p_76394_2_){
    if (!entityLivingBaseIn.world.isRemote){
        EntityItem item = new EntityItem(entityLivingBaseIn.world, entityLivingBaseIn.posX + (entityLivingBaseIn.getLookVec().xCoord * 0.2F), entityLivingBaseIn.posY + entityLivingBaseIn.getEyeHeight() - 0.7F, entityLivingBaseIn.posZ + (entityLivingBaseIn.getLookVec().zCoord), new ItemStack(loot_table[(int) (Math.random() * loot_table.length)], 1));
        item.setPickupDelay(15);
        entityLivingBaseIn.world.spawnEntity(item);
    }
}
项目:ExPetrum    文件:BlockLog.java   
@Override
public void dropLogItem(World w, IBlockState state, Vec3d at)
{
    state = state.withProperty(AXIS, Axis.Y);
    EntityItem item = new EntityItem(w, at.x, at.y, at.z, new ItemStack(ExPBlocks.logsDeco[this.logIndex], 1, this.getMetaFromState(state)));
    if (!w.isRemote)
    {
        w.spawnEntity(item);
    }
}
项目:BaseClient    文件:EntityPlayerSP.java   
/**
 * Called when player presses the drop item key
 */
public EntityItem dropOneItem(boolean dropAll)
{
    C07PacketPlayerDigging.Action c07packetplayerdigging$action = dropAll ? C07PacketPlayerDigging.Action.DROP_ALL_ITEMS : C07PacketPlayerDigging.Action.DROP_ITEM;
    this.sendQueue.addToSendQueue(new C07PacketPlayerDigging(c07packetplayerdigging$action, BlockPos.ORIGIN, EnumFacing.DOWN));
    return null;
}
项目:Thermionics    文件:BlockScaffoldCable.java   
@Override
public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity entity) {
    if (entity instanceof EntityItem) return;
    if (entity.isCollidedHorizontally) {
        entity.motionY = 0.35;
    } else if (entity.isSneaking()) {
        entity.motionY = 0.08; //Stop, but also counteract EntityLivingBase-applied microgravity
    } else if (entity.motionY<-0.20) {
        entity.motionY = -0.20;
    }
    entity.fallDistance = 0.0f;
}
项目:Bewitchment    文件:SpellMagnet.java   
@Override
public void performEffect(RayTraceResult rtrace, EntityLivingBase caster, World world) {
    if (rtrace.typeOfHit == Type.BLOCK && caster != null) {
        world.getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(rtrace.hitVec, rtrace.hitVec.addVector(1, 1, 1)).grow(2)).forEach(ei -> {
            ei.setNoPickupDelay();
            if (caster instanceof EntityPlayer) {
                ei.onCollideWithPlayer((EntityPlayer) caster);
            } else {
                ei.setPositionAndUpdate(caster.posX, caster.posY, caster.posZ);
            }
        });
    }
}
项目:DecompiledMinecraft    文件:EntitySheep.java   
/**
 * Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig.
 */
public boolean interact(EntityPlayer player)
{
    ItemStack itemstack = player.inventory.getCurrentItem();

    if (itemstack != null && itemstack.getItem() == Items.shears && !this.getSheared() && !this.isChild())
    {
        if (!this.worldObj.isRemote)
        {
            this.setSheared(true);
            int i = 1 + this.rand.nextInt(3);

            for (int j = 0; j < i; ++j)
            {
                EntityItem entityitem = this.entityDropItem(new ItemStack(Item.getItemFromBlock(Blocks.wool), 1, this.getFleeceColor().getMetadata()), 1.0F);
                entityitem.motionY += (double)(this.rand.nextFloat() * 0.05F);
                entityitem.motionX += (double)((this.rand.nextFloat() - this.rand.nextFloat()) * 0.1F);
                entityitem.motionZ += (double)((this.rand.nextFloat() - this.rand.nextFloat()) * 0.1F);
            }
        }

        itemstack.damageItem(1, player);
        this.playSound("mob.sheep.shear", 1.0F, 1.0F);
    }

    return super.interact(player);
}
项目:uniquecrops    文件:Feroxia.java   
@Override
   public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) {

    if (this.getAge(state) >= getMaxAge() || world.isRemote)
        return;

    if (!this.canBlockStay(world, pos, state)) {
        EntityItem ei = new EntityItem(world, pos.getX() + 0.5, pos.getY() + 0.1, pos.getZ() + 0.5, new ItemStack(this.getSeed()));
        world.spawnEntityInWorld(ei);
        world.setBlockToAir(pos);
        return;
    }
    TileEntity tile = world.getTileEntity(pos);
    if (tile == null || (tile != null && !(tile instanceof TileFeroxia)))
        return;

    TileFeroxia te = (TileFeroxia)tile;
    if (te.getOwner() == null || (te.getOwner() != null && UCUtils.getPlayerFromUUID(te.getOwner().toString()) == null))
        return;

    NBTTagList taglist = UCUtils.getServerTaglist(UCUtils.getPlayerFromUUID(te.getOwner().toString()).getEntityId());
    if (taglist == null)
        return;
    NBTTagCompound tag = taglist.getCompoundTagAt(this.getAge(state));
    int stage = tag.getInteger("stage" + this.getAge(state));

    if (!steps.get(stage).getCondition().canAdvance(world, pos, state)) {
        return;
    }
       int i = this.getAge(state);

       if (i < this.getMaxAge()) {
           float f = getGrowthChance(this, world, pos);
           if (rand.nextInt((int)(25.0F / f) + 1) == 0)
            world.setBlockState(pos, this.withAge(i + 1), 2);
       }
}