本文整理匯總了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);
}
}