当前位置: 首页>>代码示例>>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;未经允许,请勿转载。