예제 #1
0
  /** A function to open a door. */
  public void onPoweredBlockChange(World par1World, int par2, int par3, int par4, boolean par5) {
    int var6 = this.getFullMetadata(par1World, par2, par3, par4);
    boolean var7 = (var6 & 4) != 0;

    if (var7 != par5) {
      int var8 = var6 & 7;
      var8 ^= 4;

      if ((var6 & 8) != 0) {
        par1World.setBlockMetadataWithNotify(par2, par3 - 1, par4, var8);
        par1World.markBlocksDirty(par2, par3 - 1, par4, par2, par3, par4);
      } else {
        par1World.setBlockMetadataWithNotify(par2, par3, par4, var8);
        par1World.markBlocksDirty(par2, par3, par4, par2, par3, par4);
      }

      par1World.playAuxSFXAtEntity((EntityPlayer) null, 1003, par2, par3, par4, 0);
    }
  }
  /** A function to open a door. */
  public void onPoweredBlockChange(World par1World, int par2, int par3, int par4, boolean par5) {
    int i = getFullMetadata(par1World, par2, par3, par4);
    boolean flag = (i & 4) != 0;

    if (flag == par5) {
      return;
    }

    int j = i & 7;
    j ^= 4;

    if ((i & 8) != 0) {
      par1World.setBlockMetadataWithNotify(par2, par3 - 1, par4, j);
      par1World.markBlocksDirty(par2, par3 - 1, par4, par2, par3, par4);
    } else {
      par1World.setBlockMetadataWithNotify(par2, par3, par4, j);
      par1World.markBlocksDirty(par2, par3, par4, par2, par3, par4);
    }

    par1World.playAuxSFXAtEntity(null, 1003, par2, par3, par4, 0);
  }
예제 #3
0
  /**
   * Called upon block activation (left or right click on the block.). The three integers represent
   * x,y,z of the block.
   */
  public boolean blockActivated(
      World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer) {
    if (this.blockMaterial == Material.iron) {
      return false;
    } else {
      int var6 = this.getFullMetadata(par1World, par2, par3, par4);
      int var7 = var6 & 7;
      var7 ^= 4;

      if ((var6 & 8) != 0) {
        par1World.setBlockMetadataWithNotify(par2, par3 - 1, par4, var7);
        par1World.markBlocksDirty(par2, par3 - 1, par4, par2, par3, par4);
      } else {
        par1World.setBlockMetadataWithNotify(par2, par3, par4, var7);
        par1World.markBlocksDirty(par2, par3, par4, par2, par3, par4);
      }

      par1World.playAuxSFXAtEntity(par5EntityPlayer, 1003, par2, par3, par4, 0);
      return true;
    }
  }
  /**
   * Called upon block activation (left or right click on the block.). The three integers represent
   * x,y,z of the block.
   */
  public boolean blockActivated(
      World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer) {
    if (blockMaterial == Material.iron) {
      return true;
    }

    int i = getFullMetadata(par1World, par2, par3, par4);
    int j = i & 7;
    j ^= 4;

    if ((i & 8) != 0) {
      par1World.setBlockMetadataWithNotify(par2, par3 - 1, par4, j);
      par1World.markBlocksDirty(par2, par3 - 1, par4, par2, par3, par4);
    } else {
      par1World.setBlockMetadataWithNotify(par2, par3, par4, j);
      par1World.markBlocksDirty(par2, par3, par4, par2, par3, par4);
    }

    par1World.playAuxSFXAtEntity(par5EntityPlayer, 1003, par2, par3, par4, 0);
    return true;
  }
예제 #5
0
 private void func_30003_j(World world, int i, int j, int k) {
   int l = world.getBlockMetadata(i, j, k);
   world.setBlockAndMetadata(i, j, k, blockID + 1, l);
   world.markBlocksDirty(i, j, k, i, j, k);
   world.markBlockNeedsUpdate(i, j, k);
 }
예제 #6
0
 private void setStateIfMobInteractsWithPlate(World world, int i, int j, int k) {
   boolean flag = world.getBlockMetadata(i, j, k) == 1;
   boolean flag1 = false;
   float f = 0.125F;
   List list = null;
   if (triggerMobType == EnumMobType.everything) {
     list =
         world.getEntitiesWithinAABBExcludingEntity(
             null,
             AxisAlignedBB.getBoundingBoxFromPool(
                 (float) i + f,
                 j,
                 (float) k + f,
                 (float) (i + 1) - f,
                 (double) j + 0.25D,
                 (float) (k + 1) - f));
   }
   if (triggerMobType == EnumMobType.mobs) {
     list =
         world.getEntitiesWithinAABB(
             net.minecraft.src.EntityLiving.class,
             AxisAlignedBB.getBoundingBoxFromPool(
                 (float) i + f,
                 j,
                 (float) k + f,
                 (float) (i + 1) - f,
                 (double) j + 0.25D,
                 (float) (k + 1) - f));
   }
   if (triggerMobType == EnumMobType.players) {
     list =
         world.getEntitiesWithinAABB(
             net.minecraft.src.EntityPlayer.class,
             AxisAlignedBB.getBoundingBoxFromPool(
                 (float) i + f,
                 j,
                 (float) k + f,
                 (float) (i + 1) - f,
                 (double) j + 0.25D,
                 (float) (k + 1) - f));
   }
   if (list.size() > 0) {
     flag1 = true;
   }
   if (flag1 && !flag) {
     world.setBlockMetadataWithNotify(i, j, k, 1);
     world.notifyBlocksOfNeighborChange(i, j, k, blockID);
     world.notifyBlocksOfNeighborChange(i, j - 1, k, blockID);
     world.markBlocksDirty(i, j, k, i, j, k);
     world.playSoundEffect(
         (double) i + 0.5D,
         (double) j + 0.10000000000000001D,
         (double) k + 0.5D,
         "random.click",
         0.3F,
         0.6F);
   }
   if (!flag1 && flag) {
     world.setBlockMetadataWithNotify(i, j, k, 0);
     world.notifyBlocksOfNeighborChange(i, j, k, blockID);
     world.notifyBlocksOfNeighborChange(i, j - 1, k, blockID);
     world.markBlocksDirty(i, j, k, i, j, k);
     world.playSoundEffect(
         (double) i + 0.5D,
         (double) j + 0.10000000000000001D,
         (double) k + 0.5D,
         "random.click",
         0.3F,
         0.5F);
   }
   if (flag1) {
     world.scheduleBlockUpdate(i, j, k, blockID, tickRate());
   }
 }
  private void calculateCurrentChanges(
      World par1World, int par2, int par3, int par4, int par5, int par6, int par7) {
    int var8 = par1World.getBlockMetadata(par2, par3, par4);
    int var9 = 0;
    this.wiresProvidePower = false;
    boolean var10 = par1World.isBlockIndirectlyGettingPowered(par2, par3, par4);
    this.wiresProvidePower = true;
    int var11;
    int var12;
    int var13;

    if (var10) {
      var9 = 15;
    } else {
      for (var11 = 0; var11 < 4; ++var11) {
        var12 = par2;
        var13 = par4;

        if (var11 == 0) {
          var12 = par2 - 1;
        }

        if (var11 == 1) {
          ++var12;
        }

        if (var11 == 2) {
          var13 = par4 - 1;
        }

        if (var11 == 3) {
          ++var13;
        }

        if (var12 != par5 || par3 != par6 || var13 != par7) {
          var9 = this.getMaxCurrentStrength(par1World, var12, par3, var13, var9);
        }

        if (par1World.isBlockNormalCube(var12, par3, var13)
            && !par1World.isBlockNormalCube(par2, par3 + 1, par4)) {
          if (var12 != par5 || par3 + 1 != par6 || var13 != par7) {
            var9 = this.getMaxCurrentStrength(par1World, var12, par3 + 1, var13, var9);
          }
        } else if (!par1World.isBlockNormalCube(var12, par3, var13)
            && (var12 != par5 || par3 - 1 != par6 || var13 != par7)) {
          var9 = this.getMaxCurrentStrength(par1World, var12, par3 - 1, var13, var9);
        }
      }

      if (var9 > 0) {
        --var9;
      } else {
        var9 = 0;
      }
    }

    if (var8 != var9) {
      par1World.editingBlocks = true;
      par1World.setBlockMetadataWithNotify(par2, par3, par4, var9);
      par1World.markBlocksDirty(par2, par3, par4, par2, par3, par4);
      par1World.editingBlocks = false;

      for (var11 = 0; var11 < 4; ++var11) {
        var12 = par2;
        var13 = par4;
        int var14 = par3 - 1;

        if (var11 == 0) {
          var12 = par2 - 1;
        }

        if (var11 == 1) {
          ++var12;
        }

        if (var11 == 2) {
          var13 = par4 - 1;
        }

        if (var11 == 3) {
          ++var13;
        }

        if (par1World.isBlockNormalCube(var12, par3, var13)) {
          var14 += 2;
        }

        boolean var15 = false;
        int var16 = this.getMaxCurrentStrength(par1World, var12, par3, var13, -1);
        var9 = par1World.getBlockMetadata(par2, par3, par4);

        if (var9 > 0) {
          --var9;
        }

        if (var16 >= 0 && var16 != var9) {
          this.calculateCurrentChanges(par1World, var12, par3, var13, par2, par3, par4);
        }

        var16 = this.getMaxCurrentStrength(par1World, var12, var14, var13, -1);
        var9 = par1World.getBlockMetadata(par2, par3, par4);

        if (var9 > 0) {
          --var9;
        }

        if (var16 >= 0 && var16 != var9) {
          this.calculateCurrentChanges(par1World, var12, var14, var13, par2, par3, par4);
        }
      }

      if (var8 < var9 || var9 == 0) {
        this.blocksNeedingUpdate.add(new ChunkPosition(par2, par3, par4));
        this.blocksNeedingUpdate.add(new ChunkPosition(par2 - 1, par3, par4));
        this.blocksNeedingUpdate.add(new ChunkPosition(par2 + 1, par3, par4));
        this.blocksNeedingUpdate.add(new ChunkPosition(par2, par3 - 1, par4));
        this.blocksNeedingUpdate.add(new ChunkPosition(par2, par3 + 1, par4));
        this.blocksNeedingUpdate.add(new ChunkPosition(par2, par3, par4 - 1));
        this.blocksNeedingUpdate.add(new ChunkPosition(par2, par3, par4 + 1));
      }
    }
  }
  private void func_21030_a(World world, int i, int j, int k, int l, int i1, int j1) {
    int k1 = world.getBlockMetadata(i, j, k);
    int l1 = 0;
    wiresProvidePower = false;
    boolean flag = world.isBlockIndirectlyGettingPowered(i, j, k);
    wiresProvidePower = true;
    if (flag) {
      l1 = 15;
    } else {
      for (int i2 = 0; i2 < 4; i2++) {
        int k2 = i;
        int i3 = k;
        if (i2 == 0) {
          k2--;
        }
        if (i2 == 1) {
          k2++;
        }
        if (i2 == 2) {
          i3--;
        }
        if (i2 == 3) {
          i3++;
        }
        if (k2 != l || j != i1 || i3 != j1) {
          l1 = getMaxCurrentStrength(world, k2, j, i3, l1);
        }
        if (world.isBlockOpaqueCube(k2, j, i3) && !world.isBlockOpaqueCube(i, j + 1, k)) {
          if (k2 != l || j + 1 != i1 || i3 != j1) {
            l1 = getMaxCurrentStrength(world, k2, j + 1, i3, l1);
          }
          continue;
        }
        if (!world.isBlockOpaqueCube(k2, j, i3) && (k2 != l || j - 1 != i1 || i3 != j1)) {
          l1 = getMaxCurrentStrength(world, k2, j - 1, i3, l1);
        }
      }

      if (l1 > 0) {
        l1--;
      } else {
        l1 = 0;
      }
    }
    if (k1 != l1) {
      world.field_1043_h = true;
      world.setBlockMetadataWithNotify(i, j, k, l1);
      world.markBlocksDirty(i, j, k, i, j, k);
      world.field_1043_h = false;
      for (int j2 = 0; j2 < 4; j2++) {
        int l2 = i;
        int j3 = k;
        int k3 = j - 1;
        if (j2 == 0) {
          l2--;
        }
        if (j2 == 1) {
          l2++;
        }
        if (j2 == 2) {
          j3--;
        }
        if (j2 == 3) {
          j3++;
        }
        if (world.isBlockOpaqueCube(l2, j, j3)) {
          k3 += 2;
        }
        int l3 = 0;
        l3 = getMaxCurrentStrength(world, l2, j, j3, -1);
        l1 = world.getBlockMetadata(i, j, k);
        if (l1 > 0) {
          l1--;
        }
        if (l3 >= 0 && l3 != l1) {
          func_21030_a(world, l2, j, j3, i, j, k);
        }
        l3 = getMaxCurrentStrength(world, l2, k3, j3, -1);
        l1 = world.getBlockMetadata(i, j, k);
        if (l1 > 0) {
          l1--;
        }
        if (l3 >= 0 && l3 != l1) {
          func_21030_a(world, l2, k3, j3, i, j, k);
        }
      }

      if (k1 == 0 || l1 == 0) {
        field_21031_b.add(new ChunkPosition(i, j, k));
        field_21031_b.add(new ChunkPosition(i - 1, j, k));
        field_21031_b.add(new ChunkPosition(i + 1, j, k));
        field_21031_b.add(new ChunkPosition(i, j - 1, k));
        field_21031_b.add(new ChunkPosition(i, j + 1, k));
        field_21031_b.add(new ChunkPosition(i, j, k - 1));
        field_21031_b.add(new ChunkPosition(i, j, k + 1));
      }
    }
  }