当前位置: 首页>>代码示例>>Java>>正文


Java EntityItem类代码示例

本文整理汇总了Java中net.minecraft.entity.item.EntityItem的典型用法代码示例。如果您正苦于以下问题:Java EntityItem类的具体用法?Java EntityItem怎么用?Java EntityItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


EntityItem类属于net.minecraft.entity.item包,在下文中一共展示了EntityItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: dropClay

import net.minecraft.entity.item.EntityItem; //导入依赖的package包/类
@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)));
    }
}
 
开发者ID:elifoster,项目名称:MakeClayValuableAgain,代码行数:17,代码来源:ClayProgressionImprovements.java

示例2: doDispense

import net.minecraft.entity.item.EntityItem; //导入依赖的package包/类
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);
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:26,代码来源:BehaviorDefaultDispenseItem.java

示例3: render

import net.minecraft.entity.item.EntityItem; //导入依赖的package包/类
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);
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:18,代码来源:RenderDroneHeldItem.java

示例4: onLivingUpdate

import net.minecraft.entity.item.EntityItem; //导入依赖的package包/类
/**
 * 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();
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:23,代码来源:EntityLiving.java

示例5: dropMagazine

import net.minecraft.entity.item.EntityItem; //导入依赖的package包/类
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);
}
 
开发者ID:Domochevsky,项目名称:minecraft-quiverbow,代码行数:24,代码来源:Endernymous.java

示例6: updateTick

import net.minecraft.entity.item.EntityItem; //导入依赖的package包/类
@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);
}
 
开发者ID:bafomdad,项目名称:uniquecrops,代码行数:17,代码来源:Dirigible.java

示例7: dropMagazine

import net.minecraft.entity.item.EntityItem; //导入依赖的package包/类
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);
}
 
开发者ID:Domochevsky,项目名称:minecraft-quiverbow,代码行数:24,代码来源:NetherBellows.java

示例8: onImpact

import net.minecraft.entity.item.EntityItem; //导入依赖的package包/类
@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();
  }
 
开发者ID:bafomdad,项目名称:uniquecrops,代码行数:23,代码来源:EntityEulaBook.java

示例9: onItemPickup

import net.minecraft.entity.item.EntityItem; //导入依赖的package包/类
/**
 * 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()));
        }
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:26,代码来源:EntityLivingBase.java

示例10: canAdvance

import net.minecraft.entity.item.EntityItem; //导入依赖的package包/类
@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;
}
 
开发者ID:bafomdad,项目名称:uniquecrops,代码行数:19,代码来源:GrowthSteps.java

示例11: spawnAsEntity

import net.minecraft.entity.item.EntityItem; //导入依赖的package包/类
/**
 * 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);
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:22,代码来源:Block.java

示例12: dropFewItems

import net.minecraft.entity.item.EntityItem; //导入依赖的package包/类
/**
 * 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);
        }
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:21,代码来源:EntityWither.java

示例13: render

import net.minecraft.entity.item.EntityItem; //导入依赖的package包/类
@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();
}
 
开发者ID:kenijey,项目名称:harshencastle,代码行数:20,代码来源:BaseItemRenderer.java

示例14: onImpact

import net.minecraft.entity.item.EntityItem; //导入依赖的package包/类
@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();
	}
}
 
开发者ID:the-realest-stu,项目名称:Adventurers-Toolbox,代码行数:19,代码来源:EntityRock.java

示例15: onBlockActivated

import net.minecraft.entity.item.EntityItem; //导入依赖的package包/类
@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;
}
 
开发者ID:the-realest-stu,项目名称:Infernum,代码行数:27,代码来源:BlockPedestal.java


注:本文中的net.minecraft.entity.item.EntityItem类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。