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


Java TileEntityFurnace.setInventorySlotContents方法代码示例

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


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

示例1: convert

import net.minecraft.tileentity.TileEntityFurnace; //导入方法依赖的package包/类
@Override
public boolean convert(EntityPlayer player, World world, int x, int y, int z)
{
	TileEntityFurnace furnace = (TileEntityFurnace)world.getTileEntity(x, y, z);
	NBTTagCompound tag = new NBTTagCompound();
	int newMeta = 3;

	furnace.writeToNBT(tag);

	for(int i = 0; i < furnace.getSizeInventory(); i++)
	{
		furnace.setInventorySlotContents(i, null);
	}

	switch(world.getBlockMetadata(x, y, z))
	{
		case 5: newMeta = 4; break;
		case 4: newMeta = 2; break;
		case 2: newMeta = 1; break;
	}

	world.setBlock(x, y, z, SCContent.keypadFurnace, newMeta, 3);
	((IOwnable) world.getTileEntity(x, y, z)).getOwner().set(player.getCommandSenderName(), player.getUniqueID().toString());
	((TileEntityFurnace)world.getTileEntity(x, y, z)).readFromNBT(tag);
	return true;
}
 
开发者ID:Geforce132,项目名称:SecurityCraft,代码行数:27,代码来源:BlockKeypadFurnace.java

示例2: PlaceAndFillCraftingMachines

import net.minecraft.tileentity.TileEntityFurnace; //导入方法依赖的package包/类
private static void PlaceAndFillCraftingMachines(EntityPlayer player, World world, BlockPos cornerPosition, EnumFacing facing, boolean addCraftingTable, boolean addFurnace)
{
	BlockPos itemPosition = cornerPosition.offset(facing.rotateY()).offset(facing).down();
	
	if (addCraftingTable)
	{
		BuildingMethods.ReplaceBlock(world, itemPosition, Blocks.CRAFTING_TABLE);
	}
	
	// Trigger the workbench achievement.
	// TODO: Figure out how to trigger this advancement.
	//player.addStat(AchievementList.BUILD_WORK_BENCH);

	// Place a furnace next to the crafting table and fill it with 20 coal.
	if (addFurnace)
	{
		itemPosition = itemPosition.offset(facing.rotateY());
		BuildingMethods.ReplaceBlock(world, itemPosition, Blocks.FURNACE.getDefaultState().withProperty(BlockFurnace.FACING, facing));

		TileEntity tileEntity = world.getTileEntity(itemPosition);

		if (tileEntity instanceof TileEntityFurnace)
		{
			TileEntityFurnace furnaceTile = (TileEntityFurnace) tileEntity;
			furnaceTile.setInventorySlotContents(1, new ItemStack(Items.COAL, 20));
		}
	}
}
 
开发者ID:Brian-Wuest,项目名称:MC-Prefab,代码行数:29,代码来源:HouseConfiguration.java

示例3: AfterBuilding

import net.minecraft.tileentity.TileEntityFurnace; //导入方法依赖的package包/类
/**
 * This method is used after the main building is build for any additional
 * structures or modifications.
 * 
 * @param configuration The structure configuration.
 * @param world The current world.
 * @param originalPos The original position clicked on.
 * @param assumedNorth The assumed northern direction.
 * @param player The player which initiated the construction.
 */
@Override
public void AfterBuilding(StructureConfiguration configuration, World world, BlockPos originalPos, EnumFacing assumedNorth, EntityPlayer player)
{
	ModerateHouseConfiguration houseConfig = (ModerateHouseConfiguration)configuration;
	EntityPlayerConfiguration playerConfig = EntityPlayerConfiguration.loadFromEntityData((EntityPlayerMP)player);
	
	if (this.furnacePosition != null)
	{
		for (BlockPos furnacePos : this.furnacePosition)
		{
			// Fill the furnace.
			TileEntity tileEntity = world.getTileEntity(furnacePos);
			
			if (tileEntity instanceof TileEntityFurnace)
			{
				TileEntityFurnace furnaceTile = (TileEntityFurnace) tileEntity;
				furnaceTile.setInventorySlotContents(1, new ItemStack(Items.COAL, 20));
			}
		}
	}

	if (this.chestPosition != null  && !playerConfig.builtStarterHouse && houseConfig.addChestContents)
	{
		// Fill the chest if the player hasn't generated the starting house yet.
		StructureModerateHouse.FillChest(world, this.chestPosition, houseConfig, player);
	}

	if (this.trapDoorPosition != null && this.trapDoorPosition.getY() > 15 && houseConfig.addMineshaft)
	{
		// Build the mineshaft.
		StructureAlternateStart.PlaceMineShaft(world, this.trapDoorPosition.down(), houseConfig.houseFacing, false);
	}
	
	// Make sure to set this value so the player cannot fill the chest a second time.
	playerConfig.builtStarterHouse = true;
	playerConfig.saveToPlayer(player);
}
 
开发者ID:Brian-Wuest,项目名称:MC-Prefab,代码行数:48,代码来源:StructureModerateHouse.java

示例4: tryMergeStackIntoSlot

import net.minecraft.tileentity.TileEntityFurnace; //导入方法依赖的package包/类
public static void tryMergeStackIntoSlot(TileEntityFurnace furnace, EntityPlayer entityPlayer, int playerSlot, int furnaceSlot) {
  ItemStack current = furnace.getStackInSlot(furnaceSlot);
  ItemStack held = entityPlayer.inventory.getStackInSlot(playerSlot);
  boolean success = false;
  World worldObj = entityPlayer.getEntityWorld();
  if (current.isEmpty()) {
    // just done
    if (worldObj.isRemote == false) {
      furnace.setInventorySlotContents(furnaceSlot, held.copy());
      held = ItemStack.EMPTY;
    }
    success = true;
  }
  else if (held.isItemEqual(current)) {
    //ModMain.logger.info("slot is NOT empty and they match, current old:" + current.stackSize);
    // merging updates the stack size numbers in both furnace and in players
    success = true;
    if (worldObj.isRemote == false) {
      UtilItemStack.mergeItemsBetweenStacks(held, current);
    }
  }
  if (success) {
    if (worldObj.isRemote == false) {
      if (!held.isEmpty() && held.getCount() == 0) {// so now we just fix if something is size zero
        held = ItemStack.EMPTY;
      }
      entityPlayer.inventory.setInventorySlotContents(playerSlot, held);
      entityPlayer.inventory.markDirty();
    }
    UtilSound.playSound(entityPlayer, SoundEvents.ENTITY_ITEM_PICKUP);
  }
}
 
开发者ID:PrinceOfAmber,项目名称:Cyclic,代码行数:33,代码来源:UtilFurnace.java


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