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

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

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

Block.isEqualTo介绍

暂无

代码示例

代码示例来源:origin: ForestryMC/ForestryMC

/**
 * Called from Chunk.setBlockIDWithMetadata, determines if this tile entity should be re-created when the ID, or Metadata changes.
 * Use with caution as this will leave straggler TileEntities, or create conflicts with other TileEntities if not used properly.
 */
@Override
public boolean shouldRefresh(World world, BlockPos pos, IBlockState oldState, IBlockState newSate) {
  return !Block.isEqualTo(oldState.getBlock(), newSate.getBlock());
}

代码示例来源:origin: ForestryMC/ForestryMC

@Override
public boolean shouldRefresh(World world, BlockPos pos, IBlockState oldState, IBlockState newSate) {
  return !Block.isEqualTo(oldState.getBlock(), newSate.getBlock());
}

代码示例来源:origin: CoFH/CoFHCore

public static FluidStack getFluidFromWorld(World world, BlockPos pos, boolean doDrain) {
  IBlockState state = world.getBlockState(pos);
  Block bId = state.getBlock();
  int bMeta = bId.getMetaFromState(state);
  if (Block.isEqualTo(bId, Blocks.WATER)) {
    if (bMeta == 0) {
      return WATER.copy();
    } else {
      return null;
    }
  } else if (Block.isEqualTo(bId, Blocks.LAVA) || Block.isEqualTo(bId, Blocks.FLOWING_LAVA)) {
    if (bMeta == 0) {
      return LAVA.copy();
    } else {
      return null;
    }
  } else if (bId instanceof IFluidBlock) {
    IFluidBlock block = (IFluidBlock) bId;
    return block.drain(world, pos, doDrain);
  }
  return null;
}

代码示例来源:origin: ForestryMC/ForestryMC

private static boolean setHive(World world, Random rand, BlockPos pos, Hive hive) {
    IBlockState hiveState = hive.getHiveBlockState();
    Block hiveBlock = hiveState.getBlock();
    boolean placed = world.setBlockState(pos, hiveState, Constants.FLAG_BLOCK_SYNC);
    if (!placed) {
      return false;
    }

    IBlockState state = world.getBlockState(pos);
    Block placedBlock = state.getBlock();
    if (!Block.isEqualTo(hiveBlock, placedBlock)) {
      return false;
    }

    hiveBlock.onBlockAdded(world, pos, state);

    if (!Config.generateBeehivesDebug) {
      hive.postGen(world, rand, pos);
    }

    if (Config.logHivePlacement) {
      Log.info("Placed {} at {}", hive, pos);
    }

    return true;
  }
}

代码示例来源:origin: ForestryMC/ForestryMC

private static boolean setCocoon(World world, BlockPos pos, IButterfly butterfly) {
  Block cocoonBlock = ModuleLepidopterology.getBlocks().solidCocoon;
  boolean placed = world.setBlockState(pos, cocoonBlock.getDefaultState(), Constants.FLAG_BLOCK_SYNC);
  if (!placed) {
    return false;
  }
  IBlockState state = world.getBlockState(pos);
  if (!Block.isEqualTo(cocoonBlock, state.getBlock())) {
    return false;
  }
  TileCocoon cocoon = TileUtil.getTile(world, pos, TileCocoon.class);
  if (cocoon != null) {
    cocoon.setCaterpillar(butterfly);
  } else {
    return false;
  }
  cocoonBlock.onBlockAdded(world, pos, state);
  world.markBlockRangeForRenderUpdate(pos, pos);
  return true;
}

相关文章

Block类方法