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


Java EntityItem.setItem方法代码示例

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


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

示例1: 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

示例2: breakBlock

import net.minecraft.entity.item.EntityItem; //导入方法依赖的package包/类
@Override
public void breakBlock(World worldIn, BlockPos pos, IBlockState state) {
    if (worldIn.getTileEntity(pos) instanceof TileFaerieHome) {
        TileFaerieHome te = (TileFaerieHome) worldIn.getTileEntity(pos);
        if (te != null) {
            ItemStack itemStack = te.itemStackHandler.getStackInSlot(0);
            if (itemStack != ItemStack.EMPTY) {
                EntityItem droppedJar = new EntityItem(worldIn, pos.getX(), pos.getY(), pos.getZ());
                droppedJar.setItem(itemStack);
                worldIn.spawnEntity(droppedJar);
            }
        }
    }
    EntityItem droppedHome = new EntityItem(worldIn, pos.getX(), pos.getY(), pos.getZ());
    droppedHome.setItem(new ItemStack(Item.getItemFromBlock(this), 1, 0));
    worldIn.spawnEntity(droppedHome);
    super.breakBlock(worldIn, pos, state);
}
 
开发者ID:BenjaminSutter,项目名称:genera,代码行数:19,代码来源:BlockFaerieHome.java

示例3: render

import net.minecraft.entity.item.EntityItem; //导入方法依赖的package包/类
@Override
public void render(TilePotteryKiln te, double x, double y, double z, float partialTicks, int destroyStage,
		float alpha) {
	GlStateManager.pushAttrib();
	GlStateManager.pushMatrix();
	GlStateManager.translate(x, y, z);
	GlStateManager.disableRescaleNormal();
	if(te.getWorld().getBlockState(te.getPos()).getBlock()==BlocksRegistry.potteryKiln&&te.getWorld().getBlockState(te.getPos()).getValue(BlockPotteryKiln.TYPE)==EnumKilnTypes.EMPTY){
		ItemStack stack=te.pottery.getStackInSlot(0);
		if(!stack.isEmpty()){
			item=new EntityItem(te.getWorld());
			item.setItem(stack);
			item.hoverStart=0F;
			RenderHelper.enableStandardItemLighting();
			GlStateManager.enableLighting();
			GlStateManager.pushMatrix();
			GlStateManager.translate(0.5D, -0.1D, 0.5D);
			GlStateManager.scale(1D, 1D, 1D);
			Minecraft.getMinecraft().getRenderManager().renderEntity(item, 0, 0, 0, 0, 0, false);
			GlStateManager.popMatrix();
		}
	}
	GlStateManager.popAttrib();
	GlStateManager.popMatrix();
}
 
开发者ID:EnderiumSmith,项目名称:CharcoalPit,代码行数:26,代码来源:TESRPotteryKiln.java

示例4: onItemUse

import net.minecraft.entity.item.EntityItem; //导入方法依赖的package包/类
@Override
public EnumActionResult onItemUse(EntityPlayer playerIn, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
    IBlockState state = world.getBlockState(pos);
    if (state.getBlock() == BlockRegistry.crystal)
    {
        world.playSound(playerIn, pos, SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.PLAYERS, 1, 1);
        if (!world.isRemote)
        {
            ItemStack is = SipUtils.getStackWithSip(new ItemStack(ItemRegistry.crystal), SipUtils.getSipInBlock(world, pos));
            world.setBlockToAir(pos);
            EntityItem ei = new EntityItem(world, pos.getX(), pos.getY(), pos.getZ());
            ei.setItem(is);
            world.spawnEntity(ei);
        }
        return EnumActionResult.SUCCESS;
    }
    return EnumActionResult.PASS;
}
 
开发者ID:PearXTeam,项目名称:PurificatiMagicae,代码行数:20,代码来源:ItemCrystalCutter.java

示例5: rotateBlock

import net.minecraft.entity.item.EntityItem; //导入方法依赖的package包/类
@Override
public boolean rotateBlock(World world, EntityPlayer player, BlockPos pos, EnumFacing side) {
    TileEntityPressureTube tube = ModInteractionUtils.getInstance().getTube(getTE(world, pos));
    if (player.isSneaking()) {
        TubeModule module = getLookedModule(world, pos, player);
        if (module != null) {
            // detach and drop the module as an item
            if (!player.capabilities.isCreativeMode) {
                List<ItemStack> drops = module.getDrops();
                for (ItemStack drop : drops) {
                    EntityItem entity = new EntityItem(world, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5);
                    entity.setItem(drop);
                    world.spawnEntity(entity);
                    entity.onCollideWithPlayer(player);
                }
            }
            tube.setModule(null, module.getDirection());
            neighborChanged(world.getBlockState(pos), world, pos, this, pos.offset(side));
            world.notifyNeighborsOfStateChange(pos, this, true);
        } else {
            // drop the pipe as an item
            if (!player.capabilities.isCreativeMode) dropBlockAsItem(world, pos, world.getBlockState(pos), 0);
            world.setBlockToAir(pos);
        }
    } else {
        // close (or reopen) this side of the pipe
        Pair<Boolean, EnumFacing> lookData = getLookedTube(world, pos, player);
        if (lookData != null) {
            boolean isCore = lookData.getLeft();
            EnumFacing sideHit = lookData.getRight();
            tube.sidesClosed[sideHit.ordinal()] = !tube.sidesClosed[sideHit.ordinal()];
            neighborChanged(world.getBlockState(pos), world, pos, this, pos.offset(side));
            world.notifyNeighborsOfStateChange(pos, this, true);
        }
    }
    return true;
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:38,代码来源:BlockPressureTube.java

示例6: breakBlock

import net.minecraft.entity.item.EntityItem; //导入方法依赖的package包/类
@Override
public void breakBlock(World world, BlockPos pos, IBlockState state) {
    List<ItemStack> drops = getModuleDrops((TileEntityPressureTube) getTE(world, pos));
    for (ItemStack drop : drops) {
        EntityItem entity = new EntityItem(world, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5);
        entity.setItem(drop);
        world.spawnEntity(entity);
    }
    super.breakBlock(world, pos, state);
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:11,代码来源:BlockPressureTube.java

示例7: 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

示例8: smeltAndSpawn

import net.minecraft.entity.item.EntityItem; //导入方法依赖的package包/类
private void smeltAndSpawn(EntityItem e) {
	ItemStack copy = e.getItem().copy();
	ItemStack is = copy.splitStack(1);
	if (rng.nextDouble() < 0.7d) {
		ItemStack result = FurnaceRecipes.instance().getSmeltingResult(is).copy();
		e.getEntityWorld().spawnEntity(new EntityItem(e.getEntityWorld(), e.posX, e.posY, e.posZ, result));
	} else {
		e.getEntityWorld().spawnEntity(new EntityXPOrb(e.getEntityWorld(), e.posX, e.posY, e.posZ, 2));
	}
	e.setItem(copy);
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:12,代码来源:RitualFlames.java

示例9: dropRemainingDrops

import net.minecraft.entity.item.EntityItem; //导入方法依赖的package包/类
private void dropRemainingDrops(ActionOptions option, World world) {
    List<Pair<BlockPos, ItemStack>> drops = option.getDrops();
    if (!drops.isEmpty()) {
        for (Pair<BlockPos, ItemStack> pair : drops) {
            EntityItem entityItem = new EntityItem(world);
            entityItem.setItem(pair.getValue());
            BlockPos pos = pair.getKey();
            entityItem.setLocationAndAngles(pos.getX(), pos.getY(), pos.getZ(), 0, 0);
            world.spawnEntity(entityItem);
        }
    }
}
 
开发者ID:McJty,项目名称:MeeCreeps,代码行数:13,代码来源:ServerActionManager.java

示例10: pickup

import net.minecraft.entity.item.EntityItem; //导入方法依赖的package包/类
@Override
public void pickup(EntityItem item) {
    ItemStack remaining = entity.addStack(item.getItem().copy());
    if (remaining.isEmpty()) {
        item.setDead();
    } else {
        item.setItem(remaining);
        needsToPutAway = true;
    }
}
 
开发者ID:McJty,项目名称:MeeCreeps,代码行数:11,代码来源:WorkerHelper.java

示例11: renderShelf

import net.minecraft.entity.item.EntityItem; //导入方法依赖的package包/类
public void renderShelf(TileEntityDisplay te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
	EnumFacing facing = te.getWorld().getBlockState(te.getPos()).getValue(BlockHorizontal.FACING);

	for (int i = 0; i < 4; ++i) {
		if (!te.getStackInSlot(i).isEmpty()) {
			EntityItem customItem = new EntityItem(te.getWorld());
			customItem.hoverStart = 0.0F;
			customItem.setItem(te.getStackInSlot(i));
			GlStateManager.pushMatrix();
			GlStateManager.translate((float) x, (float) y, (float) z);
			if (facing == EnumFacing.NORTH || facing == EnumFacing.SOUTH) {
				if (i < 2) {
					GlStateManager.translate(0.25F + (0.5F * i), 0.5F, 0.5F);
				} else {
					GlStateManager.translate(0.25F + (0.5F * (i - 2)), 0F, 0.5F);
				}
			} else {
				if (i < 2) {
					GlStateManager.translate(0.5F, 0.5F, 0.75F - (0.5F * i));
				} else {
					GlStateManager.translate(0.5F, 0F, 0.75F - (0.5F * (i - 2)));
				}
			}

			if (ConfigHandler.laidDownShelves && !(te.getStackInSlot(i).getItem() instanceof ItemBlock)) {
				GlStateManager.rotate(-90, 1, 0, 0);

				GlStateManager.translate(0, -0.25, 0.075);
			}

			GlStateManager.rotate(90 * facing.getOpposite().getHorizontalIndex(), 0.0F, 1.0F, 0.0F);

			GlStateManager.scale(0.7F, 0.7F, 0.7F);

			itemRender.doRender(customItem, 0, 0, 0, 0, 0);
			GlStateManager.popMatrix();
		}
	}
}
 
开发者ID:Zundrel,项目名称:Never-Enough-Currency,代码行数:40,代码来源:TileEntityRenderDisplay.java

示例12: renderTable

import net.minecraft.entity.item.EntityItem; //导入方法依赖的package包/类
public void renderTable(TileEntityDisplay te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
	for (int i = 0; i < 4; ++i) {
		if (!te.getStackInSlot(i).isEmpty()) {
			EntityItem customItem = new EntityItem(te.getWorld());
			customItem.hoverStart = 0.0F;
			customItem.setItem(te.getStackInSlot(i));
			GlStateManager.pushMatrix();
			GlStateManager.translate((float) x, (float) y, (float) z);

			if (i < 2) {
				GlStateManager.translate(0.25F + (0.5F * (i)), 0.94F, 0.25F);
			} else {
				GlStateManager.translate(0.25F + (0.5F * (i - 2)), 0.94F, 0.75F);
			}

			if (ConfigHandler.laidDownTables && !(te.getStackInSlot(i).getItem() instanceof ItemBlock)) {
				GlStateManager.rotate(-90, 1, 0, 0);

				GlStateManager.translate(0, -0.25, 0.075);
			}

			GlStateManager.scale(0.7F, 0.7F, 0.7F);

			itemRender.doRender(customItem, 0, 0, 0, 0, 0);
			GlStateManager.popMatrix();
		}
	}
}
 
开发者ID:Zundrel,项目名称:Never-Enough-Currency,代码行数:29,代码来源:TileEntityRenderDisplay.java


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