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


Java BlockBreakable类代码示例

本文整理汇总了Java中net.minecraft.block.BlockBreakable的典型用法代码示例。如果您正苦于以下问题:Java BlockBreakable类的具体用法?Java BlockBreakable怎么用?Java BlockBreakable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: isCover

import net.minecraft.block.BlockBreakable; //导入依赖的package包/类
/**
 * Returns whether block is a cover.
 */
public static boolean isCover(ItemStack itemStack)
{
    if (itemStack.getItem() instanceof ItemBlock && !isOverlay(itemStack)) {

        Block block = toBlock(itemStack);

        return block.renderAsNormalBlock() ||
               block instanceof BlockSlab ||
               block instanceof BlockPane ||
               block instanceof BlockBreakable ||
               FeatureRegistry.coverExceptions.contains(itemStack.getDisplayName()) ||
               FeatureRegistry.coverExceptions.contains(ChatHandler.getDefaultTranslation(itemStack));

    }

    return false;
}
 
开发者ID:Mineshopper,项目名称:carpentersblocks,代码行数:21,代码来源:BlockProperties.java

示例2: checkForSideTransparency

import net.minecraft.block.BlockBreakable; //导入依赖的package包/类
public boolean checkForSideTransparency(IBlockAccess world, BlockPos keypadPos, Block neighborBlock, EnumFacing side) {
	if(neighborBlock == Blocks.AIR)
		return true;

	// Slightly cheating here, checking if the block is an instance of BlockBreakable
	// and a vanilla block instead of checking for specific blocks, since all vanilla
	// BlockBreakable blocks are transparent.
	if(neighborBlock instanceof BlockBreakable && neighborBlock.toString().replace("Block{", "").startsWith("minecraft:"))
		return false;

	return true;
}
 
开发者ID:Geforce132,项目名称:SecurityCraft,代码行数:13,代码来源:BlockKeypad.java

示例3: checkForSideTransparency

import net.minecraft.block.BlockBreakable; //导入依赖的package包/类
public boolean checkForSideTransparency(IBlockAccess world, BlockPos keypadPos, Block neighborBlock, EnumFacing side) {
	if(neighborBlock == Blocks.air)
		return true;

	// Slightly cheating here, checking if the block is an instance of BlockBreakable
	// and a vanilla block instead of checking for specific blocks, since all vanilla
	// BlockBreakable blocks are transparent.
	if(neighborBlock instanceof BlockBreakable && neighborBlock.toString().startsWith("net.minecraft.block"))
		return false;

	return true;
}
 
开发者ID:Geforce132,项目名称:SecurityCraft,代码行数:13,代码来源:BlockKeypad.java

示例4: checkForSideTransparency

import net.minecraft.block.BlockBreakable; //导入依赖的package包/类
public boolean checkForSideTransparency(IBlockAccess world, BlockPos keypadPos, Block neighborBlock, EnumFacing side) {
	if(neighborBlock == Blocks.air)
		return true;

	// Slightly cheating here, checking if the block is an instance of BlockBreakable
	// and a vanilla block instead of checking for specific blocks, since all vanilla
	// BlockBreakable blocks are transparent.
	if(neighborBlock instanceof BlockBreakable && neighborBlock.toString().replace("Block{", "").startsWith("minecraft:"))
		return false;

	return true;
}
 
开发者ID:Geforce132,项目名称:SecurityCraft,代码行数:13,代码来源:BlockKeypad.java

示例5: PreInit

import net.minecraft.block.BlockBreakable; //导入依赖的package包/类
@EventHandler
   public void PreInit(FMLPreInitializationEvent preEvent) {

// blocks
blockDarkGlass = (BlockBreakable) new DarkGlass(Material.glass, false).setBlockName("DarkGlass").setLightOpacity(1000000);
GameRegistry.registerBlock(blockDarkGlass, "DarkGlass");

blockClearGlass = (BlockBreakable) new DarkGlass(Material.glass, false).setBlockName("ClearGlass").setLightOpacity(0);
GameRegistry.registerBlock(blockClearGlass, "ClearGlass");

blockBrightGlass = (BlockBreakable) new DarkGlass(Material.glass, false).setBlockName("BrightGlass").setLightLevel(0.8F);
GameRegistry.registerBlock(blockBrightGlass, "BrightGlass");

   }
 
开发者ID:AllForFun,项目名称:modpack,代码行数:15,代码来源:Main.java

示例6: blockWasLifted

import net.minecraft.block.BlockBreakable; //导入依赖的package包/类
/**
 * Returns true if the ILiftBlock itemstack was able to pick up the block clicked
 * and the useBlock result should be denied
 */
private boolean blockWasLifted(World world, EntityPlayer player, ItemStack stack, BlockPos pos, EnumFacing face) {
	IBlockState state = world.getBlockState(pos);
	Block block = state.getBlock();
	if (player.canPlayerEdit(pos, face, stack) || block instanceof ILiftable) {
		boolean isLiftable = block instanceof ILiftable;
		boolean isValidBlock = (block.isOpaqueCube() || block instanceof BlockBreakable) && Item.getItemFromBlock(block) != null;
		BlockWeight weight = (isLiftable ? ((ILiftable) block).getLiftWeight(player, stack, state, face)
				: (Config.canLiftVanilla() ? null : BlockWeight.IMPOSSIBLE));
		float strength = ((ILiftBlock) stack.getItem()).getLiftStrength(player, stack, state).weight;
		float resistance = (weight != null ? weight.weight : (block.getExplosionResistance(world, pos, null, null) * 5.0F/3.0F));
		if (isValidBlock && weight != BlockWeight.IMPOSSIBLE && strength >= resistance && (isLiftable || !block.hasTileEntity(state))) {
			if (world.isRemote) { // Send block's render color to server so held block can render correctly
				PacketDispatcher.sendToServer(new HeldBlockColorPacket(block.colorMultiplier(world, pos)));
			} else {
				ItemStack returnStack = ((ILiftBlock) stack.getItem()).onLiftBlock(player, stack, state);
				if (returnStack != null && returnStack.stackSize <= 0) {
					returnStack = null;
				}
				ItemStack heldBlock = ItemHeldBlock.getBlockStack(state, returnStack);
				if (isLiftable) {
					((ILiftable) block).onLifted(world, player, heldBlock, pos, state);
				}
				player.setCurrentItemOrArmor(0, heldBlock);
				world.playSoundEffect(pos.getX() + 0.5D, pos.getY() + 0.5D, pos.getZ() + 0.5D, block.stepSound.getBreakSound(),
						(block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getFrequency() * 0.8F);
				world.setBlockToAir(pos);
			}
			return true;
		} else {
			WorldUtils.playSoundAtEntity(player, Sounds.GRUNT, 0.3F, 0.8F);
		}
	}
	return false;
}
 
开发者ID:coolAlias,项目名称:ZeldaSwordSkills,代码行数:39,代码来源:ZSSItemEvents.java

示例7: blockWasSmashed

import net.minecraft.block.BlockBreakable; //导入依赖的package包/类
/**
 * Returns true if the ISmashBlock itemstack was able to smash up the block clicked
 * and the useBlock result should be denied
 */
private boolean blockWasSmashed(World world, EntityPlayer player, ItemStack stack, BlockPos pos, EnumFacing face) {
	IBlockState state = world.getBlockState(pos);
	Block block = state.getBlock();
	boolean isSmashable = block instanceof ISmashable;
	Result smashResult = Result.DEFAULT;
	boolean wasDestroyed = false;
	if (player.canPlayerEdit(pos, face, stack) || isSmashable) {
		BlockWeight weight = (isSmashable ? ((ISmashable) block).getSmashWeight(player, stack, state, face)
				: (Config.canSmashVanilla() || isVanillaBlockSmashable(block) ? null : BlockWeight.IMPOSSIBLE));
		float strength = ((ISmashBlock) stack.getItem()).getSmashStrength(player, stack, state, face).weight;
		float resistance = (weight != null ? weight.weight : (block.getExplosionResistance(world, pos, null, null) * 5.0F/3.0F));
		smashResult = (isSmashable ? ((ISmashable) block).onSmashed(world, player, stack, pos, state, face) : smashResult);
		if (smashResult == Result.DEFAULT) {
			boolean isValidBlock = block.isOpaqueCube() || block instanceof BlockBreakable;
			if (isValidBlock && weight != BlockWeight.IMPOSSIBLE && strength >= resistance && (!block.hasTileEntity(state) || isSmashable)) {
				if (!(block instanceof BlockBreakable)) {
					world.playSoundAtEntity(player, Sounds.ROCK_FALL, 1.0F, 1.0F);
				}
				if (!world.isRemote) { 
					world.destroyBlock(pos, false);
				}
				wasDestroyed = true;
			}
		}
		((ISmashBlock) stack.getItem()).onBlockSmashed(player, stack, state, face, (smashResult == Result.ALLOW || wasDestroyed));
	}
	return (smashResult == Result.ALLOW || wasDestroyed);
}
 
开发者ID:coolAlias,项目名称:ZeldaSwordSkills,代码行数:33,代码来源:ZSSItemEvents.java

示例8: canHarvestBlock

import net.minecraft.block.BlockBreakable; //导入依赖的package包/类
@Override
public boolean canHarvestBlock(Block block) {
	return block instanceof ISmashable || block instanceof BlockBreakable;
}
 
开发者ID:coolAlias,项目名称:ZeldaSwordSkills,代码行数:5,代码来源:ItemHammer.java

示例9: getSmashStrength

import net.minecraft.block.BlockBreakable; //导入依赖的package包/类
@Override
public BlockWeight getSmashStrength(EntityPlayer player, ItemStack stack, IBlockState state, EnumFacing side) {
	return (state.getBlock() instanceof BlockBreakable) ? strength.next() : strength;
}
 
开发者ID:coolAlias,项目名称:ZeldaSwordSkills,代码行数:5,代码来源:ItemHammer.java


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