當前位置: 首頁>>代碼示例>>Java>>正文


Java World.markBlockForUpdate方法代碼示例

本文整理匯總了Java中net.minecraft.world.World.markBlockForUpdate方法的典型用法代碼示例。如果您正苦於以下問題:Java World.markBlockForUpdate方法的具體用法?Java World.markBlockForUpdate怎麽用?Java World.markBlockForUpdate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.minecraft.world.World的用法示例。


在下文中一共展示了World.markBlockForUpdate方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: update

import net.minecraft.world.World; //導入方法依賴的package包/類
@Override
public void update(World world)
{
	this.timeSinceLastBuild++;
	if (this.timeSinceLastBuild > this.speedInTicks && !this.pendingBlock)
		updatePath();

	if (this.path.size() > 0 && this.pendingBlock)
	{
   		BlockPos bp = this.path.get(this.path.size() - 1);
   		// Create the block, or a gap if we are leaving a gap:
      		world.setBlockState(bp, this.consecutiveGaps == 0 ? this.freshBlock : Blocks.air.getDefaultState());
      		world.markBlockForUpdate(bp);
		this.pendingBlock = false;
   		
   		// Create space above and below this block (even if we are leaving a gap):
		BlockPos bpUp = bp;
		BlockPos bpDown = bp;
   		for (int i = 0; i < 3; i++) {
       		bpUp = bpUp.add(0, 1, 0);
       		bpDown = bpDown.add(0, -1, 0);
       		world.setBlockToAir(bpUp);
       		world.setBlockToAir(bpDown);
   		}
  		
   		// Now remove block at the other end of the path, if need be:
   		if (this.path.size() > this.maxPathLength) {
   			bp = this.path.remove(0);
   			world.setBlockState(bp, this.staleBlock);
   		}
   	}
}
 
開發者ID:Yarichi,項目名稱:Proyecto-DASI,代碼行數:33,代碼來源:SnakeDecoratorImplementation.java

示例2: onItemUse

import net.minecraft.world.World; //導入方法依賴的package包/類
/**
 * Called when a Block is right-clicked with this Item
 */
public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
{
    if (worldIn.isRemote)
    {
        return true;
    }
    else if (!playerIn.canPlayerEdit(pos.offset(side), side, stack))
    {
        return false;
    }
    else
    {
        IBlockState iblockstate = worldIn.getBlockState(pos);

        if (iblockstate.getBlock() == Blocks.mob_spawner)
        {
            TileEntity tileentity = worldIn.getTileEntity(pos);

            if (tileentity instanceof TileEntityMobSpawner)
            {
                MobSpawnerBaseLogic mobspawnerbaselogic = ((TileEntityMobSpawner)tileentity).getSpawnerBaseLogic();
                mobspawnerbaselogic.setEntityName(EntityList.getStringFromID(stack.getMetadata()));
                tileentity.markDirty();
                worldIn.markBlockForUpdate(pos);

                if (!playerIn.capabilities.isCreativeMode)
                {
                    --stack.stackSize;
                }

                return true;
            }
        }

        pos = pos.offset(side);
        double d0 = 0.0D;

        if (side == EnumFacing.UP && iblockstate instanceof BlockFence)
        {
            d0 = 0.5D;
        }

        Entity entity = spawnCreature(worldIn, stack.getMetadata(), (double)pos.getX() + 0.5D, (double)pos.getY() + d0, (double)pos.getZ() + 0.5D);

        if (entity != null)
        {
            if (entity instanceof EntityLivingBase && stack.hasDisplayName())
            {
                entity.setCustomNameTag(stack.getDisplayName());
            }

            if (!playerIn.capabilities.isCreativeMode)
            {
                --stack.stackSize;
            }
        }

        return true;
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:64,代碼來源:ItemMonsterPlacer.java

示例3: onBlockActivated

import net.minecraft.world.World; //導入方法依賴的package包/類
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
{
    ItemStack itemstack = playerIn.inventory.getCurrentItem();

    if (itemstack != null && itemstack.getItem() instanceof ItemBlock)
    {
        TileEntityFlowerPot tileentityflowerpot = this.getTileEntity(worldIn, pos);

        if (tileentityflowerpot == null)
        {
            return false;
        }
        else if (tileentityflowerpot.getFlowerPotItem() != null)
        {
            return false;
        }
        else
        {
            Block block = Block.getBlockFromItem(itemstack.getItem());

            if (!this.canNotContain(block, itemstack.getMetadata()))
            {
                return false;
            }
            else
            {
                tileentityflowerpot.setFlowerPotData(itemstack.getItem(), itemstack.getMetadata());
                tileentityflowerpot.markDirty();
                worldIn.markBlockForUpdate(pos);
                playerIn.triggerAchievement(StatList.field_181736_T);

                if (!playerIn.capabilities.isCreativeMode && --itemstack.stackSize <= 0)
                {
                    playerIn.inventory.setInventorySlotContents(playerIn.inventory.currentItem, (ItemStack)null);
                }

                return true;
            }
        }
    }
    else
    {
        return false;
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:46,代碼來源:BlockFlowerPot.java

示例4: processCommand

import net.minecraft.world.World; //導入方法依賴的package包/類
/**
 * Callback when the command is invoked
 */
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
    if (args.length < 4)
    {
        throw new WrongUsageException("commands.blockdata.usage", new Object[0]);
    }
    else
    {
        sender.setCommandStat(CommandResultStats.Type.AFFECTED_BLOCKS, 0);
        BlockPos blockpos = parseBlockPos(sender, args, 0, false);
        World world = sender.getEntityWorld();

        if (!world.isBlockLoaded(blockpos))
        {
            throw new CommandException("commands.blockdata.outOfWorld", new Object[0]);
        }
        else
        {
            TileEntity tileentity = world.getTileEntity(blockpos);

            if (tileentity == null)
            {
                throw new CommandException("commands.blockdata.notValid", new Object[0]);
            }
            else
            {
                NBTTagCompound nbttagcompound = new NBTTagCompound();
                tileentity.writeToNBT(nbttagcompound);
                NBTTagCompound nbttagcompound1 = (NBTTagCompound)nbttagcompound.copy();
                NBTTagCompound nbttagcompound2;

                try
                {
                    nbttagcompound2 = JsonToNBT.getTagFromJson(getChatComponentFromNthArg(sender, args, 3).getUnformattedText());
                }
                catch (NBTException nbtexception)
                {
                    throw new CommandException("commands.blockdata.tagError", new Object[] {nbtexception.getMessage()});
                }

                nbttagcompound.merge(nbttagcompound2);
                nbttagcompound.setInteger("x", blockpos.getX());
                nbttagcompound.setInteger("y", blockpos.getY());
                nbttagcompound.setInteger("z", blockpos.getZ());

                if (nbttagcompound.equals(nbttagcompound1))
                {
                    throw new CommandException("commands.blockdata.failed", new Object[] {nbttagcompound.toString()});
                }
                else
                {
                    tileentity.readFromNBT(nbttagcompound);
                    tileentity.markDirty();
                    world.markBlockForUpdate(blockpos);
                    sender.setCommandStat(CommandResultStats.Type.AFFECTED_BLOCKS, 1);
                    notifyOperators(sender, this, "commands.blockdata.success", new Object[] {nbttagcompound.toString()});
                }
            }
        }
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:65,代碼來源:CommandBlockData.java


注:本文中的net.minecraft.world.World.markBlockForUpdate方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。