net.minecraft.block.Block.getMaterial()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(7.2k)|赞(0)|评价(0)|浏览(140)

本文整理了Java中net.minecraft.block.Block.getMaterial()方法的一些代码示例,展示了Block.getMaterial()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Block.getMaterial()方法的具体详情如下:
包路径:net.minecraft.block.Block
类名称:Block
方法名:getMaterial

Block.getMaterial介绍

暂无

代码示例

代码示例来源:origin: DimensionalDevelopment/VanillaFix

@Override
public Material getMaterial() {
  return block.getMaterial(this);
}

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

private BlockSlabCommon( Block block )
{
  super( block.getMaterial( block.getDefaultState() ) );
  this.setHardness( block.getBlockHardness( block.getDefaultState(), null, null ) );
  this.setResistance( block.getExplosionResistance( null ) * 5.0F / 3.0F );
  IBlockState iblockstate = this.blockState.getBaseState();
  if( !this.isDouble() )
  {
    iblockstate = iblockstate.withProperty( HALF, BlockSlab.EnumBlockHalf.BOTTOM );
  }
  this.setDefaultState( iblockstate.withProperty( VARIANT, Variant.DEFAULT ) );
  this.setCreativeTab( CreativeTabs.BUILDING_BLOCKS );
  this.useNeighborBrightness = true;
}

代码示例来源:origin: Electrical-Age/ElectricalAge

@Override
  public float getStrVsBlock(ItemStack stack, Block block) {
    float value = block != null && (block.getMaterial() == Material.iron || block.getMaterial() == Material.glass || block.getMaterial() == Material.anvil || block.getMaterial() == Material.rock) ? getStrength(stack) : super.getStrVsBlock(stack, block);
    for (Block b : blocksEffectiveAgainst) {
      if (b == block) {
        value = getStrength(stack);
        break;
      }
    }
    // Utils.println("****" + value);
    return value;
  }
}

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

if( block.getMaterial( state ) != Material.AIR )

代码示例来源:origin: DimensionalDevelopment/VanillaFix

@Override
public Material getMaterial() {
  return normalState.getBlock().getMaterial(this);
}

代码示例来源:origin: Electrical-Age/ElectricalAge

@Override
  public float getStrVsBlock(ItemStack stack, Block block) {
    float value = block != null && (block.getMaterial() == Material.wood || block.getMaterial() == Material.plants || block.getMaterial() == Material.vine) ? getStrength(stack) : super.getStrVsBlock(stack, block);
    Utils.println(value);
    return value;
  }
}

代码示例来源:origin: TheGreyGhost/MinecraftByExample

/** returns true if the web should connect to this block
 * Copied from BlockFence...
 * @param worldIn
 * @param pos
 * @return
 */
private boolean canConnectTo(IBlockAccess worldIn, BlockPos pos)
{
 IBlockState iblockstate = worldIn.getBlockState(pos);
 Block block = iblockstate.getBlock();
 if (block == Blocks.BARRIER) return false;
 if (block == StartupCommon.block3DWeb) return true;
 if (block.getMaterial(iblockstate).isOpaque() && block.isFullCube(iblockstate) && block.getMaterial(iblockstate) != Material.GOURD) return true;
 return false;
}

代码示例来源:origin: WayofTime/BloodMagic

public boolean shouldConnect(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing attachedSide) {
  IBlockState blockState = world.getBlockState(pos);
  Block block = blockState.getBlock();
  return block.getMaterial(blockState).isOpaque() && blockState.isFullCube();
}

代码示例来源:origin: WayofTime/BloodMagic

@Override
public boolean displaceIfPossible(World world, BlockPos blockPos) {
  return !world.getBlockState(blockPos).getBlock().getMaterial(world.getBlockState(blockPos)).isLiquid() && super.displaceIfPossible(world, blockPos);
}

代码示例来源:origin: Esteemed-Innovation/Esteemed-Innovation

/**
 * Returns whether the block can be blown by the leaf blower.
 * @param block The block
 * @param world The world
 * @param pos The block's position
 * @return Whether the leaf blower should blow this block away.
 */
public static boolean isLeaves(Block block, World world, BlockPos pos) {
  IBlockState state = world.getBlockState(pos);
  return (OreDictHelper.listHasItem(OreDictHelper.leaves, Item.getItemFromBlock(block)) ||
   block.isLeaves(state, world, pos) || LEAF_MATERIALS.contains(block.getMaterial(state)));
}

代码示例来源:origin: WayofTime/BloodMagic

@Override
public boolean canDisplace(IBlockAccess world, BlockPos blockPos) {
  return !world.getBlockState(blockPos).getBlock().getMaterial(world.getBlockState(blockPos)).isLiquid() && super.canDisplace(world, blockPos);
}

代码示例来源:origin: McJtyMods/LostCities

public static boolean isSolid(World world, int x, int y, int z) {
  if (world.isAirBlock(new BlockPos(x, y, z))) {
    return false;
  }
  IBlockState state = world.getBlockState(new BlockPos(x, y, z));
  Block block = state.getBlock();
  return block.getMaterial(state).blocksMovement();
}

代码示例来源:origin: CyclopsMC/EvilCraft

@Override
public boolean canPlaceBlockAt(World world, BlockPos blockPos) {
  IBlockState blockState = world.getBlockState(blockPos.add(0, -1, 0));
  if (blockState == null) return false;
  if (blockState.getBlock() == this && (Integer) blockState.getValue(LAYERS) == 8) return true;
  return (blockState.getBlock().isLeaves(blockState, world, blockPos.add(0, -1, 0))
      || blockState.isOpaqueCube()) && blockState.getBlock().getMaterial(blockState).blocksMovement();
}

代码示例来源:origin: JurassiCraftTeam/JurassiCraft2

public AncientSlabBlock(TreeType type, IBlockState referenceState) {
  super(referenceState.getBlock().getMaterial(referenceState));
  this.type = type;
  IBlockState state = this.blockState.getBaseState();
  if (!this.isDouble()) {
    state = state.withProperty(HALF, BlockSlab.EnumBlockHalf.BOTTOM);
  }
  Block block = state.getBlock();
  this.setHardness(block.getBlockHardness(state, null, null));
  this.setResistance((block.getExplosionResistance(null) * 5.0F) / 3.0F);
  this.setSoundType(SoundType.WOOD);
  this.setHarvestLevel(block.getHarvestTool(state), block.getHarvestLevel(state));
  this.setUnlocalizedName(type.name().toLowerCase(Locale.ENGLISH) + "_slab");
  this.setDefaultState(state);
}

代码示例来源:origin: McJtyMods/LostCities

public static int findSuitableEmptySpot(World world, int x, int z) {
  int y = world.getTopSolidOrLiquidBlock(new BlockPos(x, 0, z)).getY();
  if (y == -1) {
    return -1;
  }
  y--;            // y should now be at a solid or liquid block.
  if (y > world.getHeight() - 5) {
    y = world.getHeight() / 2;
  }
  IBlockState state = world.getBlockState(new BlockPos(x, y + 1, z));
  Block block = state.getBlock();
  while (block.getMaterial(state).isLiquid()) {
    y++;
    if (y > world.getHeight()-10) {
      return -1;
    }
    state = world.getBlockState(new BlockPos(x, y + 1, z));
    block = state.getBlock();
  }
  return y;
}

代码示例来源:origin: Electrical-Age/ElectricalAge

if (!player.canPlayerEdit(x, y, z, side, stack))
  return false;
if ((y == 255) && (this.field_150939_a.getMaterial().isSolid()))
  return false;

代码示例来源:origin: Vazkii/Quark

@SubscribeEvent(priority = EventPriority.LOWEST)
public void onPlayerInteract(PlayerInteractEvent.RightClickBlock event) {
  if(event.getEntityPlayer().isSneaking() || event.isCanceled() || event.getResult() == Result.DENY)
    return;
  World world = event.getWorld();
  IBlockState state = world.getBlockState(event.getPos()).getActualState(world, event.getPos());
  Block block = state.getBlock();
  if(!(block instanceof BlockDoor))
    return;
  EnumFacing direction = state.getValue(BlockDoor.FACING);
  boolean isOpen = state.getValue(BlockDoor.OPEN);
  BlockDoor.EnumHingePosition isMirrored = state.getValue(BlockDoor.HINGE);
  BlockPos mirrorPos = event.getPos().offset(isMirrored == BlockDoor.EnumHingePosition.RIGHT ? direction.rotateYCCW() : direction.rotateY());
  BlockPos doorPos = state.getValue(BlockDoor.HALF) == BlockDoor.EnumDoorHalf.LOWER ? mirrorPos : mirrorPos.down();
  IBlockState other = world.getBlockState(doorPos).getActualState(world, doorPos);
  if(block.getMaterial(state) != Material.IRON && other.getBlock() == (BlockDoor) block && other.getValue(BlockDoor.FACING) == direction && other.getValue(BlockDoor.OPEN) == isOpen && other.getValue(BlockDoor.HINGE) != isMirrored) {
    IBlockState newState = other.cycleProperty(BlockDoor.OPEN);
    world.setBlockState(doorPos, newState, 10);
  }
}

相关文章

Block类方法