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