/** Called when the block is placed in the world. */
  public void onBlockPlacedBy(World world, int i, int j, int k, EntityLiving par5EntityLiving) {
    TileCandyMaker tile = (TileCandyMaker) world.getBlockTileEntity(i, j, k);

    if (tile != null) {
      tile.checkRedstonePower();
    }
    int var6 =
        MathHelper.floor_double((double) (par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;

    if (var6 == 0) {
      world.setBlockMetadataWithNotify(i, j, k, 2);
    }

    if (var6 == 1) {
      world.setBlockMetadataWithNotify(i, j, k, 5);
    }

    if (var6 == 2) {
      world.setBlockMetadataWithNotify(i, j, k, 3);
    }

    if (var6 == 3) {
      world.setBlockMetadataWithNotify(i, j, k, 4);
    }
  }
Exemple #2
0
  @Override
  public void onBlockPlacedBy(World world, int x, int y, int z, EntityLiving entityliving) {
    super.onBlockPlacedBy(world, x, y, z, entityliving);

    // -- Current direction the player is facing while placing the block ( f variable if you press
    // F3 )
    int f = MathHelper.floor_double(entityliving.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
    world.setBlockMetadataWithNotify(x, y, z, f);
  }
  @Override
  public void onBlockPlacedBy(World world, int i, int j, int k, EntityLiving entityliving) {
    super.onBlockPlacedBy(world, i, j, k, entityliving);

    ForgeDirection orientation =
        Utils.get2dOrientation(
            new Position(entityliving.posX, entityliving.posY, entityliving.posZ),
            new Position(i, j, k));

    world.setBlockMetadataWithNotify(i, j, k, orientation.getOpposite().ordinal());
  }
 /*
  * ここで成長処理判定
  * world.getBlockLightValueが光度判定
  * 9以上なら成長するよという記述 最大15(太陽が一番照っているとき)
  */
 public void updateTick(World world, int i, int j, int k, Random random) {
   super.updateTick(world, i, j, k, random);
   if (world.getBlockLightValue(i, j + 1, k) >= 9) {
     int l = world.getBlockMetadata(i, j, k);
     if (l < 7) {
       float f = getGrowthRate(world, i, j, k);
       if (random.nextInt((int) (25F / f) + 1) == 0) {
         l++;
         world.setBlockMetadataWithNotify(i, j, k, l);
       }
     }
   }
 }
  /** Called when the block is placed in the world. */
  public void onBlockPlacedBy(
      World par1World, int par2, int par3, int par4, EntityLiving par5EntityLiving) {
    int var6 = par1World.getBlockId(par2, par3, par4 - 1);
    int var7 = par1World.getBlockId(par2, par3, par4 + 1);
    int var8 = par1World.getBlockId(par2 - 1, par3, par4);
    int var9 = par1World.getBlockId(par2 + 1, par3, par4);
    byte var10 = 0;
    int var11 =
        MathHelper.floor_double((double) (par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;

    if (var11 == 0) {
      var10 = 2;
    }

    if (var11 == 1) {
      var10 = 5;
    }

    if (var11 == 2) {
      var10 = 3;
    }

    if (var11 == 3) {
      var10 = 4;
    }

    if (var6 != this.blockID
        && var7 != this.blockID
        && var8 != this.blockID
        && var9 != this.blockID) {
      par1World.setBlockMetadataWithNotify(par2, par3, par4, var10);
    } else {
      if ((var6 == this.blockID || var7 == this.blockID) && (var10 == 4 || var10 == 5)) {
        if (var6 == this.blockID) {
          par1World.setBlockMetadataWithNotify(par2, par3, par4 - 1, var10);
        } else {
          par1World.setBlockMetadataWithNotify(par2, par3, par4 + 1, var10);
        }

        par1World.setBlockMetadataWithNotify(par2, par3, par4, var10);
      }

      if ((var8 == this.blockID || var9 == this.blockID) && (var10 == 2 || var10 == 3)) {
        if (var8 == this.blockID) {
          par1World.setBlockMetadataWithNotify(par2 - 1, par3, par4, var10);
        } else {
          par1World.setBlockMetadataWithNotify(par2 + 1, par3, par4, var10);
        }

        par1World.setBlockMetadataWithNotify(par2, par3, par4, var10);
      }
    }
  }
  @Override
  public boolean onBlockActivated(
      World world,
      int i,
      int j,
      int k,
      EntityPlayer entityplayer,
      int something1,
      float something2,
      float something3,
      float something4) {
    if (world.isRemote) {
      return true;
    }

    TileEntityCamoFull entity = (TileEntityCamoFull) world.getBlockTileEntity(i, j, k);
    System.out.println("ACTIVATED: " + entity.getCopyID());

    int l = world.getBlockMetadata(i, j, k);
    int i1 = l & 7;
    int j1 = 8 - (l & 8);
    world.setBlockMetadataWithNotify(i, j, k, i1 + j1);
    world.markBlocksDirty(i, j, k, i, j, k);
    world.playSoundEffect(
        (double) i + 0.5D,
        (double) j + 0.5D,
        (double) k + 0.5D,
        "random.click",
        0.3F,
        j1 <= 0 ? 0.5F : 0.6F);
    world.notifyBlocksOfNeighborChange(i, j, k, blockID);
    world.markBlockNeedsUpdate(i, j, k);

    if (i1 == 1) {
      world.notifyBlocksOfNeighborChange(i - 1, j, k, blockID);
    } else if (i1 == 2) {
      world.notifyBlocksOfNeighborChange(i + 1, j, k, blockID);
    } else if (i1 == 3) {
      world.notifyBlocksOfNeighborChange(i, j, k - 1, blockID);
    } else if (i1 == 4) {
      world.notifyBlocksOfNeighborChange(i, j, k + 1, blockID);
    } else {
      world.notifyBlocksOfNeighborChange(i, j - 1, k, blockID);
    }

    return true;
  }
  @Override
  public void updateBlockMetadata(
      World world,
      int i,
      int j,
      int k,
      int l,
      float something1,
      float something2,
      float something3) {
    int i1 = world.getBlockMetadata(i, j, k);
    int j1 = i1 & 8;
    i1 &= 7;
    i1 = -1;

    if (l == 1 && world.isBlockNormalCube(i, j - 1, k)) {
      i1 = 5 + world.rand.nextInt(2);
    }

    if (l == 2 && world.isBlockNormalCube(i, j, k + 1)) {
      i1 = 4;
    }

    if (l == 3 && world.isBlockNormalCube(i, j, k - 1)) {
      i1 = 3;
    }

    if (l == 4 && world.isBlockNormalCube(i + 1, j, k)) {
      i1 = 2;
    }

    if (l == 5 && world.isBlockNormalCube(i - 1, j, k)) {
      i1 = 1;
    }

    if (i1 == -1) {
      dropBlockAsItem(world, i, j, k, world.getBlockMetadata(i, j, k), 0);
      world.setBlockWithNotify(i, j, k, 0);
    } else {
      System.out.println("metadata = " + (i1));
      world.setBlockMetadataWithNotify(i, j, k, i1 + j1);
    }

    super.updateBlockMetadata(world, i, j, k, l, something1, something2, something3);
  }
 @Override
 public boolean onItemUseFirst(
     ItemStack stack, EntityPlayer player, World world, int X, int Y, int Z, int side) {
   TileEntity te = world.getBlockTileEntity(X, Y, Z);
   if (te != null && te instanceof TileEntityIronChest) {
     TileEntityIronChest ironchest = (TileEntityIronChest) te;
     TileEntityIronChest newchest = ironchest.applyUpgradeItem(this);
     if (newchest == null) {
       return false;
     }
     world.setBlockTileEntity(X, Y, Z, newchest);
     world.setBlockMetadataWithNotify(X, Y, Z, newchest.getType().ordinal());
     world.notifyBlocksOfNeighborChange(X, Y, Z, world.getBlockId(X, Y, Z));
     world.markBlockNeedsUpdate(X, Y, Z);
     stack.stackSize = 0;
     return true;
   } else {
     return false;
   }
 }
  /**
   * Called when a block is placed using an item. Used often for taking the facing and figuring out
   * how to position the item. Args: x, y, z, facing
   */
  public void onBlockPlaced(World par1World, int par2, int par3, int par4, int par5) {
    int var6 = par1World.getBlockMetadata(par2, par3, par4);

    if ((var6 == 0 || par5 == 2) && par1World.isBlockSolidOnSide(par2, par3, par4 + 1, 2)) {
      var6 = 2;
    }

    if ((var6 == 0 || par5 == 3) && par1World.isBlockSolidOnSide(par2, par3, par4 - 1, 3)) {
      var6 = 3;
    }

    if ((var6 == 0 || par5 == 4) && par1World.isBlockSolidOnSide(par2 + 1, par3, par4, 4)) {
      var6 = 4;
    }

    if ((var6 == 0 || par5 == 5) && par1World.isBlockSolidOnSide(par2 - 1, par3, par4, 5)) {
      var6 = 5;
    }

    par1World.setBlockMetadataWithNotify(par2, par3, par4, var6);
  }
Exemple #10
0
 public static void updateBlockState(boolean active, World world, int x, int y, int z) {
   int subId = world.getBlockMetadata(x, y, z);
   TileEntity rebench = world.getBlockTileEntity(x, y, z);
   world.setBlockMetadataWithNotify(x, y, z, subId);
 }
 /*
  * 未確認ですが、ここで骨粉処理してるはず。
  */
 public void fertilize(World world, int i, int j, int k) {
   world.setBlockMetadataWithNotify(i, j, k, 7);
 }
  /** Turns the adjacent chests to a double chest. */
  public void unifyAdjacentChests(World par1World, int par2, int par3, int par4) {
    if (!par1World.isRemote) {
      int var5 = par1World.getBlockId(par2, par3, par4 - 1);
      int var6 = par1World.getBlockId(par2, par3, par4 + 1);
      int var7 = par1World.getBlockId(par2 - 1, par3, par4);
      int var8 = par1World.getBlockId(par2 + 1, par3, par4);
      boolean var9 = true;
      int var10;
      int var11;
      boolean var12;
      byte var13;
      int var14;

      if (var5 != this.blockID && var6 != this.blockID) {
        if (var7 != this.blockID && var8 != this.blockID) {
          var13 = 3;

          if (Block.opaqueCubeLookup[var5] && !Block.opaqueCubeLookup[var6]) {
            var13 = 3;
          }

          if (Block.opaqueCubeLookup[var6] && !Block.opaqueCubeLookup[var5]) {
            var13 = 2;
          }

          if (Block.opaqueCubeLookup[var7] && !Block.opaqueCubeLookup[var8]) {
            var13 = 5;
          }

          if (Block.opaqueCubeLookup[var8] && !Block.opaqueCubeLookup[var7]) {
            var13 = 4;
          }
        } else {
          var10 = par1World.getBlockId(var7 == this.blockID ? par2 - 1 : par2 + 1, par3, par4 - 1);
          var11 = par1World.getBlockId(var7 == this.blockID ? par2 - 1 : par2 + 1, par3, par4 + 1);
          var13 = 3;
          var12 = true;

          if (var7 == this.blockID) {
            var14 = par1World.getBlockMetadata(par2 - 1, par3, par4);
          } else {
            var14 = par1World.getBlockMetadata(par2 + 1, par3, par4);
          }

          if (var14 == 2) {
            var13 = 2;
          }

          if ((Block.opaqueCubeLookup[var5] || Block.opaqueCubeLookup[var10])
              && !Block.opaqueCubeLookup[var6]
              && !Block.opaqueCubeLookup[var11]) {
            var13 = 3;
          }

          if ((Block.opaqueCubeLookup[var6] || Block.opaqueCubeLookup[var11])
              && !Block.opaqueCubeLookup[var5]
              && !Block.opaqueCubeLookup[var10]) {
            var13 = 2;
          }
        }
      } else {
        var10 = par1World.getBlockId(par2 - 1, par3, var5 == this.blockID ? par4 - 1 : par4 + 1);
        var11 = par1World.getBlockId(par2 + 1, par3, var5 == this.blockID ? par4 - 1 : par4 + 1);
        var13 = 5;
        var12 = true;

        if (var5 == this.blockID) {
          var14 = par1World.getBlockMetadata(par2, par3, par4 - 1);
        } else {
          var14 = par1World.getBlockMetadata(par2, par3, par4 + 1);
        }

        if (var14 == 4) {
          var13 = 4;
        }

        if ((Block.opaqueCubeLookup[var7] || Block.opaqueCubeLookup[var10])
            && !Block.opaqueCubeLookup[var8]
            && !Block.opaqueCubeLookup[var11]) {
          var13 = 5;
        }

        if ((Block.opaqueCubeLookup[var8] || Block.opaqueCubeLookup[var11])
            && !Block.opaqueCubeLookup[var7]
            && !Block.opaqueCubeLookup[var10]) {
          var13 = 4;
        }
      }

      par1World.setBlockMetadataWithNotify(par2, par3, par4, var13);
    }
  }
 protected void setMetadata(World world, int x, int y, int z, int metadata) {
   if (doBlockNotify) world.setBlockMetadataWithNotify(x, y, z, metadata);
   else if (world.blockExists(x, y, z) && world.getChunkFromBlockCoords(x, z).field_50025_o) {
     if (world.setBlockMetadata(x, y, z, metadata)) world.markBlockNeedsUpdate(x, y, z);
   } else world.setBlockMetadata(x, y, z, metadata);
 }
  /** Ticks the block if it's been scheduled */
  @Override
  public void updateTick(
      final World par1World,
      final int par2,
      final int par3,
      final int par4,
      final Random par5Random) {
    int var6 = this.getFlowDecay(par1World, par2, par3, par4);
    byte var7 = 1;

    if ((this.blockMaterial == Material.lava) && !par1World.provider.isHellWorld) {
      var7 = 2;
    }

    boolean var8 = true;
    int var10;

    if (var6 > 0) {
      final byte var9 = -100;
      this.numAdjacentSources = 0;
      int var12 = this.getSmallestFlowDecay(par1World, par2 - 1, par3, par4, var9);
      var12 = this.getSmallestFlowDecay(par1World, par2 + 1, par3, par4, var12);
      var12 = this.getSmallestFlowDecay(par1World, par2, par3, par4 - 1, var12);
      var12 = this.getSmallestFlowDecay(par1World, par2, par3, par4 + 1, var12);
      var10 = var12 + var7;

      if ((var10 >= 8) || (var12 < 0)) {
        var10 = -1;
      }

      if (this.getFlowDecay(par1World, par2, par3 + 1, par4) >= 0) {
        final int var11 = this.getFlowDecay(par1World, par2, par3 + 1, par4);

        if (var11 >= 8) {
          var10 = var11;
        } else {
          var10 = var11 + 8;
        }
      }

      if ((this.numAdjacentSources >= 2) && (this.blockMaterial == Material.water)) {
        if (par1World.getBlockMaterial(par2, par3 - 1, par4).isSolid()) {
          var10 = 0;
        } else if ((par1World.getBlockMaterial(par2, par3 - 1, par4) == this.blockMaterial)
            && (par1World.getBlockMetadata(par2, par3, par4) == 0)) {
          var10 = 0;
        }
      }

      if ((this.blockMaterial == Material.lava)
          && (var6 < 8)
          && (var10 < 8)
          && (var10 > var6)
          && (par5Random.nextInt(4) != 0)) {
        var10 = var6;
        var8 = false;
      }

      if (var10 == var6) {
        if (var8) {
          this.updateFlow(par1World, par2, par3, par4);
        }
      } else {
        var6 = var10;

        if (var10 < 0) {
          par1World.setBlockWithNotify(par2, par3, par4, 0);
        } else {
          par1World.setBlockMetadataWithNotify(par2, par3, par4, var10);
          par1World.scheduleBlockUpdate(par2, par3, par4, this.blockID, this.tickRate());
          par1World.notifyBlocksOfNeighborChange(par2, par3, par4, this.blockID);
        }
      }
    } else {
      this.updateFlow(par1World, par2, par3, par4);
    }

    if (this.liquidCanDisplaceBlock(par1World, par2, par3 - 1, par4)) {
      if ((this.blockMaterial == Material.lava)
          && (par1World.getBlockMaterial(par2, par3 - 1, par4) == Material.water)) {
        par1World.setBlockWithNotify(par2, par3 - 1, par4, Block.stone.blockID);
        this.triggerLavaMixEffects(par1World, par2, par3 - 1, par4);
        return;
      }

      if (var6 >= 8) {
        this.flowIntoBlock(par1World, par2, par3 - 1, par4, var6);
      } else {
        this.flowIntoBlock(par1World, par2, par3 - 1, par4, var6 + 8);
      }
    } else if ((var6 >= 0)
        && ((var6 == 0) || this.blockBlocksFlow(par1World, par2, par3 - 1, par4))) {
      final boolean[] var13 = this.getOptimalFlowDirections(par1World, par2, par3, par4);
      var10 = var6 + var7;

      if (var6 >= 8) {
        var10 = 1;
      }

      if (var10 >= 8) {
        return;
      }

      if (var13[0]) {
        this.flowIntoBlock(par1World, par2 - 1, par3, par4, var10);
      }

      if (var13[1]) {
        this.flowIntoBlock(par1World, par2 + 1, par3, par4, var10);
      }

      if (var13[2]) {
        this.flowIntoBlock(par1World, par2, par3, par4 - 1, var10);
      }

      if (var13[3]) {
        this.flowIntoBlock(par1World, par2, par3, par4 + 1, var10);
      }
    }
  }
 /** Called when the block is placed in the world. */
 public void onBlockPlacedBy(World var1, int var2, int var3, int var4, EntityLiving var5) {
   int var6 =
       (MathHelper.floor_double((double) (var5.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3) % 4;
   var1.setBlockMetadataWithNotify(var2, var3, var4, var6);
 }