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

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

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

Block.onBlockAdded介绍

暂无

代码示例

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

@Override
public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state)
{
 super.onBlockAdded(worldIn, pos, state);
 worldIn.setTileEntity(pos, this.createTileEntity(worldIn, state));
}

代码示例来源:origin: MatterOverdrive/MatterOverdrive-Legacy-Edition

/**
 * Called whenever the block is added into the world. Args: world, x, y, z
 */
@Override
public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state) {
  super.onBlockAdded(worldIn, pos, state);
  IMOTileEntity tileEntity = (IMOTileEntity) worldIn.getTileEntity(pos);
  if (tileEntity != null) {
    tileEntity.onAdded(worldIn, pos, state);
  }
}

代码示例来源:origin: OpenMods/OpenModsLib

@Override
public void onBlockAdded(World world, BlockPos blockPos, IBlockState state) {
  super.onBlockAdded(world, blockPos, state);
  if (requiresInitialization || hasCapability(TileEntityCapability.ADD_LISTENER)) {
    world.addBlockEvent(blockPos, this, EVENT_ADDED, 0);
  }
}

代码示例来源:origin: vadis365/TheErebus

@Override
public void onBlockAdded(World world, BlockPos pos, IBlockState state) {
  super.onBlockAdded(world, pos, state);
  if (world.isBlockPowered(pos)) {
    onBlockDestroyedByPlayer(world, pos, state.withProperty(EXPLODE, Boolean.valueOf(true)));
    world.setBlockToAir(pos);
  }
}

代码示例来源:origin: squeek502/VeganOption

@Override
public void onBlockAdded(World world, BlockPos pos, IBlockState state)
{
  super.onBlockAdded(world, pos, state);
  TileEntity tile = world.getTileEntity(pos);
  if (tile instanceof TileEntityBasin)
  {
    ((TileEntityBasin) tile).setPowered(world.isBlockPowered(pos));
    ((TileEntityBasin) tile).scheduleFluidConsume();
  }
}

代码示例来源:origin: amadornes/MCMultiPart

if (!newBlock.getBlock().hasTileEntity(newBlock)) // Containers get placed automatically
  newBlock.getBlock().onBlockAdded(world, snap.getPos(), newBlock);

代码示例来源: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类方法