コード例 #1
0
  @Override
  public boolean itemUsedOnBlock(
      EntityPlayer player,
      DataDrivenBlock block,
      DataDrivenItemBlock item,
      ItemStack stack,
      World world,
      int x,
      int y,
      int z,
      ForgeDirection face,
      float hitX,
      float hitY,
      float hitZ) {
    if (item.field_150939_a != block) return false;

    int metadata = world.getBlockMetadata(x - face.offsetX, y - face.offsetY, z - face.offsetZ);
    ForgeDirection actualTopFace = block.reverseTransformBlockFacing(metadata, ForgeDirection.UP);

    if (face == actualTopFace) {
      int newMetadata = (block.getSubBlockMask() & metadata);
      Block newBlock = (Block) Block.blockRegistry.getObject(targetBlock);

      world.setBlock(x, y - face.offsetY, z, newBlock, newMetadata, 3);
      return true;
    }

    return false;
  }
コード例 #2
0
  @Override
  public boolean transformShouldPlaceBlock(
      EntityPlayer player,
      DataDrivenBlock block,
      DataDrivenItemBlock item,
      ItemStack stack,
      World world,
      int x,
      int y,
      int z,
      ForgeDirection face,
      float hitX,
      float hitY,
      float hitZ,
      boolean shouldPlaceBlock) {
    if (item.field_150939_a != block) return shouldPlaceBlock;

    int metadata = world.getBlockMetadata(x - face.offsetX, y - face.offsetY, z - face.offsetZ);
    ForgeDirection actualTopFace = block.reverseTransformBlockFacing(metadata, ForgeDirection.UP);

    if (face == actualTopFace) return false;

    return shouldPlaceBlock;
  }