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


Java World.canMineBlock方法代码示例

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


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

示例1: onItemRightClick

import net.minecraft.world.World; //导入方法依赖的package包/类
@Override
public ItemStack onItemRightClick(ItemStack is, World world, EntityPlayer player)
{
    MovingObjectPosition mop = this.getMovingObjectPositionFromPlayer(world, player, false);

    if (mop == null)
        return is;

    if (mop.typeOfHit == MovingObjectType.BLOCK)
    {
        int x = mop.blockX;
        int y = mop.blockY;
        int z = mop.blockZ;

        if (!world.canMineBlock(player, x, y, z))
            return is;

        return new ItemStack(TFCItems.woodenBucketEmpty);
    }

    return is;
}
 
开发者ID:Wahazar,项目名称:TFCPrimitiveTech,代码行数:23,代码来源:WoodenBucket_BasePotashLiquor.java

示例2: onItemRightClick

import net.minecraft.world.World; //导入方法依赖的package包/类
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
	if (world.isRemote)
		return stack;
	else {
		MovingObjectPosition movingobjectposition = getMovingObjectPositionFromPlayer(world, player, true);

		if (movingobjectposition == null)
			return stack;
		else {
			if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
				int i = movingobjectposition.blockX;
				int j = movingobjectposition.blockY;
				int k = movingobjectposition.blockZ;

				if (!world.canMineBlock(player, i, j, k))
					return stack;

				if (!player.canPlayerEdit(i, j, k, movingobjectposition.sideHit, stack))
					return stack;

				if (world.getBlock(i, j, k) instanceof BlockLiquid) {
					Entity entity = spawnEntity(world, stack.getItemDamage(), i, j, k);

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

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

			return stack;
		}
	}
}
 
开发者ID:jm-organization,项目名称:connor41-etfuturum2,代码行数:39,代码来源:ItemEntityEgg.java

示例3: checkReloadFromWater

import net.minecraft.world.World; //导入方法依赖的package包/类
private void checkReloadFromWater(ItemStack stack, World world, EntityPlayer player)
  {
MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(world, player, true);
FillBucketEvent event = new FillBucketEvent(player, stack, world, movingobjectposition);
      
if (MinecraftForge.EVENT_BUS.post(event)) { return; }

      MovingObjectPosition movObj = this.getMovingObjectPositionFromPlayer(world, player, true);

      if (movObj == null) { return; }	// Didn't click on anything in particular
      else
      {            
          if (movObj.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
          {
              int x = movObj.blockX;
              int y = movObj.blockY;
              int z = movObj.blockZ;

              if (!world.canMineBlock(player, x, y, z)) { return; }					// Not allowed to mine this, getting out of here
              if (!player.canPlayerEdit(x, y, z, movObj.sideHit, stack)) { return; }	// Not allowed to edit this, getting out of here

              Material material = world.getBlock(x, y, z).getMaterial();
              int meta = world.getBlockMetadata(x, y, z);

              // Is this water?
              if (material == Material.water && meta == 0)
              {
              	world.setBlockToAir(x, y, z);
              	stack.setItemDamage(0);
              	
                  return;
              }
              // else, not water
          }
          // else, didn't click on a block
      }
  }
 
开发者ID:Domochevsky,项目名称:minecraft-quiverbow,代码行数:38,代码来源:AquaAccelerator.java


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