本文整理汇总了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;
}
示例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));
}
}
}
示例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);
}
示例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);
}
}