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


Java EntityItem.getItem方法代码示例

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


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

示例1: collideItem

import net.minecraft.entity.item.EntityItem; //导入方法依赖的package包/类
@SuppressWarnings("ConstantConditions")
public void collideItem(EntityItem entityItem) {
	final ItemStack dropped = entityItem.getItem();
	if (dropped.isEmpty() || entityItem.isDead)
		return;

	if (inv.hasFluid()) {
		if (!inv.hasFluid(FluidRegistry.LAVA)) {
			boolean splash = false;
			if (getContainer().isEmpty() && isBoiling()) {
				splash = recipeDropLogic(dropped);
			}
			if (splash) {
				play(SoundEvents.ENTITY_GENERIC_SPLASH, 0.5F, 0.5F);
			}
		} else {
			play(SoundEvents.BLOCK_LAVA_EXTINGUISH, 1F, 1F);
			entityItem.setDead();
			return;
		}
		if (dropped.getCount() == 0)
			entityItem.setDead();
	}
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:25,代码来源:TileCauldron.java

示例2: plantAll

import net.minecraft.entity.item.EntityItem; //导入方法依赖的package包/类
private void plantAll(List<EntityItem> items, World world, BlockPos pos, int amplifier) {
	int box = 1 + (int) ((float) amplifier / 2F);

	BlockPos posI = pos.add(box, 1, box);
	BlockPos posF = pos.add(-box, -1, -box);

	Iterable<BlockPos> spots = BlockPos.getAllInBox(posI, posF);

	for (EntityItem item : items) {
		ItemStack stack = item.getItem();
		for (BlockPos spot : spots) {
			if (stack.isEmpty()) {
				item.setDead();
				break;
			}
			IBlockState state = world.getBlockState(spot);
			IPlantable seed = (IPlantable) stack.getItem();
			if (world.isAirBlock(spot.up()) && state.getBlock().canSustainPlant(state, world, spot, EnumFacing.UP, seed)) {
				world.setBlockState(spot.up(), seed.getPlant(world, spot.up()));
				stack.shrink(1);
			}
		}
	}
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:25,代码来源:AutoPlantBrew.java

示例3: buildSupport

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

示例4: buildSupport

import net.minecraft.entity.item.EntityItem; //导入方法依赖的package包/类
private void buildSupport(BlockPos pos, EntityItem entityItem) {
    IMeeCreep entity = helper.getMeeCreep();
    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;
    }

    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);
}
 
开发者ID:McJty,项目名称:MeeCreeps,代码行数:23,代码来源:DigdownStairsActionWorker.java

示例5: collectCobble

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

示例6: placeStair

import net.minecraft.entity.item.EntityItem; //导入方法依赖的package包/类
private void placeStair(EnumFacing facing, BlockPos pos, EntityItem entityItem) {
    ItemStack blockStack = entityItem.getItem();
    ItemStack actual = blockStack.splitStack(32);
    numStairs += 32;
    if (blockStack.isEmpty()) {
        entityItem.setDead();
    }
    if (actual.isEmpty()) {
        return;
    }
    Item item = actual.getItem();
    if (!(item instanceof ItemBlock)) {
        // Safety
        return;
    }

    placeStair(facing, pos);
}
 
开发者ID:McJty,项目名称:MeeCreeps,代码行数:19,代码来源:DigdownStairsActionWorker.java

示例7: doRender

import net.minecraft.entity.item.EntityItem; //导入方法依赖的package包/类
@Override
public void doRender(EntityItem entity, double x, double y, double z, float entityYaw, float partialTicks)
{
	GLHelper.renderFancyBeams(x, y + 0.5, z,
			Anima.getFromBiome(entity.world.getBiome(new BlockPos(x, y, z))).getColor(), entity.world.getSeed(),
			entity.getAge(), 16, 0.7f, 30, 10);

	GlStateManager.pushMatrix();

	ItemStack stack = entity.getItem();
	if (!stack.isEmpty())
	{
		super.doRender(entity, x, y, z, entityYaw, partialTicks);
	}
	GlStateManager.popMatrix();
}
 
开发者ID:raphydaphy,项目名称:ArcaneMagic,代码行数:17,代码来源:RenderEntityItemFancy.java

示例8: updateEquipmentIfNeeded

import net.minecraft.entity.item.EntityItem; //导入方法依赖的package包/类
@Override
protected void updateEquipmentIfNeeded(EntityItem itemEntity) {
	ItemStack stack = itemEntity.getItem();
	if (canFriendermanPickupItem(stack)) {
		if (lidClosed) {
			lidClosed = false;
			lidOpening = true;
		}
		ItemStack itemstack1 = ItemStack.EMPTY;
		if (!lidClosed && !lidOpening) {
			itemstack1 = InventoryUtils.addItem(getHeldChestInventory(), stack);
			if (itemstack1.isEmpty()) {
				if (movingTowardItem != null) {
					movingTowardItem = null;
				}
				itemEntity.setDead();
			}
			else {
				stack.setCount(itemstack1.getCount());
			}
		}
	}
}
 
开发者ID:p455w0rd,项目名称:EndermanEvolution,代码行数:24,代码来源:EntityFrienderman.java

示例9: pickupItem

import net.minecraft.entity.item.EntityItem; //导入方法依赖的package包/类
protected void pickupItem(EntityItem itemEntity) {
	ItemStack stack = itemEntity.getItem();
	if (thePet.canFriendermanPickupItem(stack)) {
		if (thePet.lidClosed) {
			thePet.lidClosed = false;
			thePet.lidOpening = true;
		}
		ItemStack itemstack1 = ItemStack.EMPTY;
		if (!thePet.lidClosed && !thePet.lidOpening) {
			itemstack1 = InventoryUtils.addItem(thePet.getHeldChestInventory(), stack);
			if (itemstack1.isEmpty()) {
				if (currentTargetItem != null) {
					currentTargetItem = null;
				}
				itemEntity.setDead();
			}
			else {
				stack.setCount(itemstack1.getCount());
			}
		}
	}
}
 
开发者ID:p455w0rd,项目名称:EndermanEvolution,代码行数:23,代码来源:EntityFrienderman.java

示例10: captureEntityItemsInChamber

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

示例11: buildSupportBlock

import net.minecraft.entity.item.EntityItem; //导入方法依赖的package包/类
private void buildSupportBlock(EntityItem entityItem) {
    ItemStack blockStack = entityItem.getItem();
    ItemStack actual = blockStack.splitStack(1);
    if (blockStack.isEmpty()) {
        entityItem.setDead();
    }
    IMeeCreep entity = helper.getMeeCreep();
    World world = entity.getWorld();

    Block block = ((ItemBlock) actual.getItem()).getBlock();
    IBlockState stateForPlacement = block.getStateForPlacement(world, supportPosTodo.south(), EnumFacing.DOWN, 0, 0, 0, actual.getItem().getMetadata(actual), GeneralTools.getHarvester(), EnumHand.MAIN_HAND);
    world.setBlockState(supportPosTodo.south(), stateForPlacement, 3);
    placeLadder(supportPosTodo);
    supportPosTodo = null;
}
 
开发者ID:McJty,项目名称:MeeCreeps,代码行数:16,代码来源:DigdownActionWorker.java

示例12: updateEquipmentIfNeeded

import net.minecraft.entity.item.EntityItem; //导入方法依赖的package包/类
/**
 * Used to make treaters pick up items.
 */
@Override
protected void updateEquipmentIfNeeded(EntityItem entity)
{
	ItemStack stack = entity.getItem();

	// if the stack contains mega candy, or the treater's preferred type of candy...
	if (canTreaterPickupItem(stack))
	{
		// if the stack was thrown...
		String thrower = entity.getThrower();
		if (!StringUtils.isNullOrEmpty(thrower))
		{
			// if it was thrown by a player who's within 4 blocks of the treater...
			EntityPlayer player = this.world.getPlayerEntityByName(thrower);
			if (player != null && this.getDistanceToEntity(player) < 4.0F)
			{
				// thank the player and give them an item
				if (stack.getItem() == ModItems.MEGA_CANDY)
				{
					this.chatItUp(player, EnumTreaterMessage.SUPERING);
					dropThankItem(player, true);
				}
				else
				{
					this.chatItUp(player, EnumTreaterMessage.THANKING);
					this.dropThankItem(player, false);
				}
				this.setInLove(player);
			}
		}
		// kill the entity to make the item disappear as if the treater picked it up
		entity.setDead();
	}
}
 
开发者ID:crazysnailboy,项目名称:Halloween,代码行数:38,代码来源:EntityTreater.java

示例13: EntityStaticItem

import net.minecraft.entity.item.EntityItem; //导入方法依赖的package包/类
public EntityStaticItem(EntityItem item) {
	this(item.world, item.posX, item.posY, item.posZ, item.getItem());
}
 
开发者ID:ArekkuusuJerii,项目名称:Solar,代码行数:4,代码来源:EntityStaticItem.java

示例14: tryAbsorbDroppedItem

import net.minecraft.entity.item.EntityItem; //导入方法依赖的package包/类
private boolean tryAbsorbDroppedItem(EntityItem item, IBlockState state)
   {
ItemStack newStack = Prep1_11.getEmptyStack();
ItemStack stack = item.getItem();
switch(mode)
{
case DIFFUSION:
    if(isIngredientPresent(stack)) return false;
    if(stack.getItem() == Items.BOOK || stack.isItemEnchanted())
    {
	newStack = stack.copy();
	newStack.setCount(1);
	if(!world.isRemote) stack.shrink(1);
    }
    break;
case REPAIR:
    if(pendingIngredients.isEmpty()) return false;
    RecipeElement currentIngredient = pendingIngredients.peek();
    if(currentIngredient.matches(stack))
    {
	newStack = stack.copy();
	newStack.setCount(Math.min(currentIngredient.getStackSize(), stack.getCount()));
	currentIngredient.setStackSize(currentIngredient.getStackSize() - Math.min(currentIngredient.getStackSize(), stack.getCount()));

	if(currentIngredient.getStackSize() <= 0)
	{
	    pendingIngredients.pop();
	}
	if(!world.isRemote) stack.shrink(newStack.getCount());
	markDirty();
    }
    break;
default:
    break;
}	
if(newStack == null) return false;
boolean slotFound = false;
if(newStack.isItemEnchanted())
{
    mainHandler.setStackInSlot(SLOT_ENCH_ITEM, newStack);
    slotFound = true;
}
else
{
    //attempt to insert stacks into inv
    for(int s = SLOT_ENCH_ITEM + 1; s < mainHandler.getSlots(); s++)
    {
	ItemStack slotStack = mainHandler.getStackInSlot(s);
	if (ItemHandlerHelper.canItemStacksStack(newStack, slotStack))
	{
	    CapUtils.incrementStack(mainHandler, s, newStack.getCount());
	    slotFound = true;
	    break;
	}
	if(Prep1_11.isEmpty(slotStack))
	{
	    mainHandler.setStackInSlot(s, newStack);
	    slotFound = true;
	    break;
	}
    }
}
return slotFound;
   }
 
开发者ID:einsteinsci,项目名称:BetterBeginningsReborn,代码行数:65,代码来源:TileEntityInfusionRepair.java


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