예제 #1
0
 public void updateTick(World world, int i, int j, int k, Random random) {
   if (world.isBlockIndirectlyGettingPowered(i, j, k)
       || world.isBlockIndirectlyGettingPowered(i, j - 1, k)) {
     // Whatever you put here is what happens when it's powered
     explode(world, i, j, k);
     fuse = 80;
   }
 }
예제 #2
0
 public void onNeighborBlockChange(World world, int i, int j, int k, int l) {
   if (l > 0 && Block.blocksList[l].canProvidePower()) {
     // Which direction the power can come from, i is the x coord, j is y, and k is z.
     boolean flag =
         world.isBlockIndirectlyGettingPowered(i, j, k)
             || world.isBlockIndirectlyGettingPowered(i, j - 1, k);
     if (flag) {
       world.scheduleBlockUpdate(i, j, k, blockID, tickRate());
     }
   }
 }
 /** Called whenever the block is added into the world. Args: world, x, y, z */
 public void onBlockAdded(World par1World, int par2, int par3, int par4) {
   if (!par1World.isRemote) {
     if (this.powered && !par1World.isBlockIndirectlyGettingPowered(par2, par3, par4)) {
       par1World.scheduleBlockUpdate(par2, par3, par4, this.blockID, 4);
     } else if (!this.powered && par1World.isBlockIndirectlyGettingPowered(par2, par3, par4)) {
       int m = par1World.getBlockMetadata(par2, par3, par4);
       par1World.setBlockAndMetadataWithNotify(
           par2, par3, par4, MinecraftPlusBase.holidaylights_1Active.blockID, m);
     }
   }
 }
예제 #4
0
 @Override
 public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, Block par5) {
   boolean flag =
       par1World.isBlockIndirectlyGettingPowered(par2, par3, par4)
           || par1World.isBlockIndirectlyGettingPowered(par2, par3 + 1, par4);
   int i1 = par1World.getBlockMetadata(par2, par3, par4);
   boolean flag1 = (i1 & 8) != 0;
   if (flag && !flag1) {
     par1World.scheduleBlockUpdate(par2, par3, par4, this, this.tickRate(par1World));
     par1World.setBlockMetadataWithNotify(par2, par3, par4, i1 | 8, 4);
   } else if (!flag && flag1) {
     par1World.setBlockMetadataWithNotify(par2, par3, par4, i1 & -9, 4);
   }
 }
예제 #5
0
 /**
  * Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed
  * (coordinates passed are their own) Args: x, y, z, neighbor Block
  */
 public void onNeighborBlockChange(
     World p_149695_1_, int p_149695_2_, int p_149695_3_, int p_149695_4_, Block p_149695_5_) {
   if (p_149695_1_.isBlockIndirectlyGettingPowered(p_149695_2_, p_149695_3_, p_149695_4_)) {
     this.onBlockDestroyedByPlayer(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_, 1);
     p_149695_1_.setBlockToAir(p_149695_2_, p_149695_3_, p_149695_4_);
   }
 }
예제 #6
0
  @Override
  public void onBlockPlacedBy(
      World world, int x, int y, int z, EntityLivingBase entityliving, ItemStack itemstack) {
    TileEntityBasicBlock tileEntity = (TileEntityBasicBlock) world.getTileEntity(x, y, z);

    int side =
        MathHelper.floor_double((double) (entityliving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
    int change = 3;

    switch (side) {
      case 0:
        change = 2;
        break;
      case 1:
        change = 5;
        break;
      case 2:
        change = 3;
        break;
      case 3:
        change = 4;
        break;
    }

    tileEntity.setFacing((short) change);
    tileEntity.redstone = world.isBlockIndirectlyGettingPowered(x, y, z);
  }
예제 #7
0
  /**
   * Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed
   * (coordinates passed are their own) Args: x, y, z, neighbor Block
   */
  public void onNeighborBlockChange(
      World p_149695_1_, int p_149695_2_, int p_149695_3_, int p_149695_4_, Block p_149695_5_) {
    int l = p_149695_1_.getBlockMetadata(p_149695_2_, p_149695_3_, p_149695_4_);

    if ((l & 8) == 0) {
      boolean flag = false;

      if (p_149695_1_.getBlock(p_149695_2_, p_149695_3_ + 1, p_149695_4_) != this) {
        p_149695_1_.setBlockToAir(p_149695_2_, p_149695_3_, p_149695_4_);
        flag = true;
      }

      if (!World.doesBlockHaveSolidTopSurface(
          p_149695_1_, p_149695_2_, p_149695_3_ - 1, p_149695_4_)) {
        p_149695_1_.setBlockToAir(p_149695_2_, p_149695_3_, p_149695_4_);
        flag = true;

        if (p_149695_1_.getBlock(p_149695_2_, p_149695_3_ + 1, p_149695_4_) == this) {
          p_149695_1_.setBlockToAir(p_149695_2_, p_149695_3_ + 1, p_149695_4_);
        }
      }

      if (flag) {
        if (!p_149695_1_.isRemote) {
          this.dropBlockAsItem(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_, l, 0);
        }
      } else {
        boolean flag1 =
            p_149695_1_.isBlockIndirectlyGettingPowered(p_149695_2_, p_149695_3_, p_149695_4_)
                || p_149695_1_.isBlockIndirectlyGettingPowered(
                    p_149695_2_, p_149695_3_ + 1, p_149695_4_);

        if ((flag1 || p_149695_5_.canProvidePower()) && p_149695_5_ != this) {
          this.func_150014_a(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_, flag1);
        }
      }
    } else {
      if (p_149695_1_.getBlock(p_149695_2_, p_149695_3_ - 1, p_149695_4_) != this) {
        p_149695_1_.setBlockToAir(p_149695_2_, p_149695_3_, p_149695_4_);
      }

      if (p_149695_5_ != this) {
        this.onNeighborBlockChange(
            p_149695_1_, p_149695_2_, p_149695_3_ - 1, p_149695_4_, p_149695_5_);
      }
    }
  }
예제 #8
0
  /** Called whenever the block is added into the world. Args: world, x, y, z */
  public void onBlockAdded(World p_149726_1_, int p_149726_2_, int p_149726_3_, int p_149726_4_) {
    super.onBlockAdded(p_149726_1_, p_149726_2_, p_149726_3_, p_149726_4_);

    if (p_149726_1_.isBlockIndirectlyGettingPowered(p_149726_2_, p_149726_3_, p_149726_4_)) {
      this.onBlockDestroyedByPlayer(p_149726_1_, p_149726_2_, p_149726_3_, p_149726_4_, 1);
      p_149726_1_.setBlockToAir(p_149726_2_, p_149726_3_, p_149726_4_);
    }
  }
예제 #9
0
  /** Called whenever the block is added into the world. Args: world, x, y, z */
  public void onBlockAdded(World par1World, int par2, int par3, int par4) {
    super.onBlockAdded(par1World, par2, par3, par4);

    if (par1World.isBlockIndirectlyGettingPowered(par2, par3, par4)) {
      this.onBlockDestroyedByPlayer(par1World, par2, par3, par4, 1);
      par1World.setBlockToAir(par2, par3, par4);
    }
  }
 /** Ticks the block if it's been scheduled */
 public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) {
   if (!par1World.isRemote
       && this.powered
       && !par1World.isBlockIndirectlyGettingPowered(par2, par3, par4)) {
     int m = par1World.getBlockMetadata(par2, par3, par4);
     par1World.setBlockAndMetadataWithNotify(
         par2, par3, par4, MinecraftPlusBase.holidaylights_1Idle.blockID, m);
   }
 }
예제 #11
0
 @Override
 public void onNeighborBlockChange(World world, int x, int y, int z, Block block) {
   boolean flag = world.isBlockIndirectlyGettingPowered(x, y, z);
   TileEntity tileEntity = world.getTileEntity(x, y, z);
   if ((tileEntity != null && tileEntity instanceof TileEntityFan)) {
     TileEntityFan ped = (TileEntityFan) tileEntity;
     ped.updateRedstoneState(flag);
   }
 }
예제 #12
0
  private void updatePowerState(World world, int x, int y, int z) {
    int meta = world.getBlockMetadata(x, y, z);
    int dir = getDirectionFromMetadata(meta);
    boolean recievesPower = !world.isBlockIndirectlyGettingPowered(x, y, z);
    boolean hopperPower = checkMeta(meta);

    if (recievesPower != hopperPower) {
      world.setBlockMetadataWithNotify(x, y, z, dir | (recievesPower ? 0 : 8), 4);
    }
  }
 @Override
 public void onNeighborBlockChange(World world, int x, int y, int z, Block b) {
   if (DragonAPICore.isReikasComputer() && ReikaObfuscationHelper.isDeObfEnvironment()) {
     if (world.isBlockIndirectlyGettingPowered(x, y, z)) {
       if (world.getBlockMetadata(x, y, z) == LaserEffectType.EMITTER.ordinal()) {
         LaserEffectTile te = (LaserEffectTile) world.getTileEntity(x, y, z);
         te.fire();
         return;
       }
     }
   }
 }
예제 #14
0
  /**
   * Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed
   * (coordinates passed are their own) Args: x, y, z, neighbor blockID
   */
  public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5) {
    boolean flag = par1World.isBlockIndirectlyGettingPowered(par2, par3, par4);
    TileEntityNote tileentitynote = (TileEntityNote) par1World.getBlockTileEntity(par2, par3, par4);

    if (tileentitynote != null && tileentitynote.previousRedstoneState != flag) {
      if (flag) {
        tileentitynote.triggerNote(par1World, par2, par3, par4);
      }

      tileentitynote.previousRedstoneState = flag;
    }
  }
예제 #15
0
  @Override
  public void onNeighborBlockChange(World world, int x, int y, int z, Block block) {
    super.onNeighborBlockChange(world, x, y, z, block);

    if (world.isBlockIndirectlyGettingPowered(x, y, z)) {
      IvTileEntityMultiBlock parent = getValidatedTotalParent(this, world, x, y, z);

      if (parent instanceof TileEntityStatue) {
        if (((TileEntityStatue) parent).letStatueComeAlive())
          world.setBlock(x, y, z, Blocks.air, 0, 3);
      }
    }
  }
예제 #16
0
  @Override
  public void onNeighborBlockChange(World world, int x, int y, int z, int id) {
    if (world.isRemote && world.isBlockIndirectlyGettingPowered(x, y, z)) {
      int newMeta;
      if (world.getBlockMetadata(x, y, z) == 0) {
        newMeta = 1;
      } else {
        newMeta = 0;
      }

      world.setBlockMetadataWithNotify(x, y, z, newMeta, 3);
    }
  }
  /**
   * Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed
   * (coordinates passed are their own) Args: x, y, z, neighbor blockID
   */
  public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5) {
    if (!par1World.isRemote) {
      if (this.powered && !par1World.isBlockIndirectlyGettingPowered(par2, par3, par4)) {
        par1World.scheduleBlockUpdate(par2, par3, par4, this.blockID, 4);
      } else if (!this.powered && par1World.isBlockIndirectlyGettingPowered(par2, par3, par4)) {
        int m = par1World.getBlockMetadata(par2, par3, par4);
        par1World.setBlockAndMetadataWithNotify(
            par2, par3, par4, MinecraftPlusBase.holidaylights_1Active.blockID, m);
      }
    }
    int var6 = par1World.getBlockMetadata(par2, par3, par4);
    boolean var7 = false;

    if (var6 == 2 && par1World.isBlockSolidOnSide(par2, par3, par4 + 1, NORTH)) {
      var7 = true;
    }

    if (var6 == 3 && par1World.isBlockSolidOnSide(par2, par3, par4 - 1, SOUTH)) {
      var7 = true;
    }

    if (var6 == 4 && par1World.isBlockSolidOnSide(par2 + 1, par3, par4, WEST)) {
      var7 = true;
    }

    if (var6 == 5 && par1World.isBlockSolidOnSide(par2 - 1, par3, par4, EAST)) {
      var7 = true;
    }

    if (!var7) {
      this.dropBlockAsItem(par1World, par2, par3, par4, var6, 0);
      par1World.setBlockWithNotify(par2, par3, par4, 0);
    }

    super.onNeighborBlockChange(par1World, par2, par3, par4, par5);
  }
예제 #18
0
  @Override
  public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) {
    if (!world.isBlockIndirectlyGettingPowered(x, y, z)) {
      double moveX = 0;
      double moveZ = 0;

      double speed = 0.01;

      int meta = world.getBlockMetadata(x, y, z);
      switch (meta % 8) {
        case 6:
          moveX += speed;
          break;
        case 7:
          moveX += speed;
          moveZ += speed;
          break;
        case 0:
          moveZ += speed;
          break;
        case 1:
          moveZ += speed;
          moveX -= speed;
          break;
        case 2:
          moveX -= speed;
          break;
        case 3:
          moveX -= speed;
          moveZ -= speed;
          break;
        case 4:
          moveZ -= speed;
          break;
        case 5:
          moveZ -= speed;
          moveX += speed;
          break;
      }

      entity.addVelocity(moveX, 0, moveZ);
    }

    if (entity instanceof EntityItem) {
      ((EntityItem) entity).age = 0;
    }
  }
예제 #19
0
  /**
   * Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed
   * (coordinates passed are their own) Args: x, y, z, neighbor Block
   */
  public void onNeighborBlockChange(
      World p_149695_1_, int p_149695_2_, int p_149695_3_, int p_149695_4_, Block p_149695_5_) {
    if (!p_149695_1_.isRemote) {
      int l = p_149695_1_.getBlockMetadata(p_149695_2_, p_149695_3_, p_149695_4_);
      int i1 = p_149695_2_;
      int j1 = p_149695_4_;

      if ((l & 3) == 0) {
        j1 = p_149695_4_ + 1;
      }

      if ((l & 3) == 1) {
        --j1;
      }

      if ((l & 3) == 2) {
        i1 = p_149695_2_ + 1;
      }

      if ((l & 3) == 3) {
        --i1;
      }

      if (!(func_150119_a(p_149695_1_.getBlock(i1, p_149695_3_, j1))
          || p_149695_1_.isSideSolid(
              i1, p_149695_3_, j1, ForgeDirection.getOrientation((l & 3) + 2)))) {
        p_149695_1_.setBlockToAir(p_149695_2_, p_149695_3_, p_149695_4_);
        this.dropBlockAsItem(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_, l, 0);
      }

      boolean flag =
          p_149695_1_.isBlockIndirectlyGettingPowered(p_149695_2_, p_149695_3_, p_149695_4_);

      if (flag || p_149695_5_.canProvidePower()) {
        this.func_150120_a(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_, flag);
      }
    }
  }
예제 #20
0
  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.markBlockRangeForRenderUpdate(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 calculateCurrentChanges(World world, int i, int j, int k) {
    int metadata = world.getBlockMetadata(i, j, k);
    int strength = 0;
    this.wiresProvidePower = false;
    boolean isPowered = world.isBlockIndirectlyGettingPowered(i, j, k);
    this.wiresProvidePower = true;
    int counter;
    int x;
    int y;
    int z;

    if (isPowered) {
      strength = 15;
    } else {
      for (counter = 0; counter < 6; counter++) {
        x = i;
        y = j;
        z = k;

        if (counter == 0) {
          x = i - 1;
        }

        if (counter == 1) {
          ++x;
        }

        if (counter == 2) {
          z = k - 1;
        }

        if (counter == 3) {
          ++z;
        }

        if (counter == 4) {
          y = j - 1;
        }

        if (counter == 5) {
          ++y;
        }

        if (x != i || y != j || z != k) {
          strength = this.getMaxCurrentStrength(world, x, y, z, strength);
        }
      }

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

    if (metadata != strength) {
      world.setBlockMetadataWithNotify(i, j, k, strength, 2);
      world.markBlockRangeForRenderUpdate(i, j, k, i, j, k);

      for (counter = 0; counter < 6; ++counter) {
        x = i;
        y = j;
        z = k;

        if (counter == 0) {
          x = i - 1;
        }

        if (counter == 1) {
          ++x;
        }

        if (counter == 2) {
          z = k - 1;
        }

        if (counter == 3) {
          ++z;
        }

        if (counter == 4) {
          y = j - 1;
        }

        if (counter == 5) {
          ++y;
        }

        int maxStrength = this.getMaxCurrentStrength(world, x, y, z, -1);
        strength = world.getBlockMetadata(i, j, k);

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

        if (maxStrength >= 0 && maxStrength != strength) {
          this.calculateCurrentChanges(world, x, y, z);
        }

        maxStrength = this.getMaxCurrentStrength(world, x, y, z, -1);
        strength = world.getBlockMetadata(i, j, k);

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

        if (maxStrength >= 0 && maxStrength != strength) {
          this.calculateCurrentChanges(world, x, y, z);
        }
      }

      if (metadata < strength || strength == 0) {
        this.blocksNeedingUpdate.add(new ChunkPosition(i, j, k));
        this.blocksNeedingUpdate.add(new ChunkPosition(i - 1, j, k));
        this.blocksNeedingUpdate.add(new ChunkPosition(i + 1, j, k));
        this.blocksNeedingUpdate.add(new ChunkPosition(i, j - 1, k));
        this.blocksNeedingUpdate.add(new ChunkPosition(i, j + 1, k));
        this.blocksNeedingUpdate.add(new ChunkPosition(i, j, k - 1));
        this.blocksNeedingUpdate.add(new ChunkPosition(i, j, k + 1));
      }
    }
  }
 public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5) {
   if (!par1World.isRemote) {
     ((TileEntitySpawnerBlock) par1World.getBlockTileEntity(par2, par3, par4))
         .setIsGettingPowered(par1World.isBlockIndirectlyGettingPowered(par2, par3, par4));
   }
 }
예제 #23
0
  @Override
  public void onNeighborBlockChange(World p_149695_1_, int x, int y, int z, Block p_149695_5_) {
    TileEntityLaunchPad entity = (TileEntityLaunchPad) p_149695_1_.getTileEntity(x, y, z);
    if (p_149695_1_.isBlockIndirectlyGettingPowered(x, y, z)) {
      if (entity.slots[1] != null
          && entity.slots[1].getItem() == ModItems.designator
          && entity.slots[1].stackTagCompound != null) {
        int xCoord = entity.slots[1].stackTagCompound.getInteger("xCoord");
        int zCoord = entity.slots[1].stackTagCompound.getInteger("zCoord");

        if (xCoord == entity.xCoord && zCoord == entity.zCoord) {
          xCoord += 1;
        }

        if (entity.slots[0] != null
            && entity.slots[0].getItem() == ModItems.missile_generic
            && entity.power >= 75000) {
          EntityMissileGeneric missile =
              new EntityMissileGeneric(p_149695_1_, xCoord, zCoord, x + 0.5F, y + 2F, z + 0.5F);
          p_149695_1_.spawnEntityInWorld(missile);
          entity.power -= 75000;

          entity.slots[0] = null;
        }
        if (entity.slots[0] != null
            && entity.slots[0].getItem() == ModItems.missile_anti_ballistic
            && entity.power >= 75000) {
          EntityMissileAntiBallistic missile =
              new EntityMissileAntiBallistic(
                  p_149695_1_, xCoord, zCoord, x + 0.5F, y + 2F, z + 0.5F);
          p_149695_1_.spawnEntityInWorld(missile);
          entity.power -= 75000;

          entity.slots[0] = null;
        }
        if (entity.slots[0] != null
            && entity.slots[0].getItem() == ModItems.missile_incendiary
            && entity.power >= 75000) {
          EntityMissileIncendiary missile =
              new EntityMissileIncendiary(p_149695_1_, xCoord, zCoord, x + 0.5F, y + 2F, z + 0.5F);
          p_149695_1_.spawnEntityInWorld(missile);
          entity.power -= 75000;

          entity.slots[0] = null;
        }
        if (entity.slots[0] != null
            && entity.slots[0].getItem() == ModItems.missile_cluster
            && entity.power >= 75000) {
          EntityMissileCluster missile =
              new EntityMissileCluster(p_149695_1_, xCoord, zCoord, x + 0.5F, y + 2F, z + 0.5F);
          p_149695_1_.spawnEntityInWorld(missile);
          entity.power -= 75000;

          entity.slots[0] = null;
        }
        if (entity.slots[0] != null
            && entity.slots[0].getItem() == ModItems.missile_buster
            && entity.power >= 75000) {
          EntityMissileBunkerBuster missile =
              new EntityMissileBunkerBuster(
                  p_149695_1_, xCoord, zCoord, x + 0.5F, y + 2F, z + 0.5F);
          p_149695_1_.spawnEntityInWorld(missile);
          entity.power -= 75000;

          entity.slots[0] = null;
        }
        if (entity.slots[0] != null
            && entity.slots[0].getItem() == ModItems.missile_strong
            && entity.power >= 75000) {
          EntityMissileStrong missile =
              new EntityMissileStrong(p_149695_1_, xCoord, zCoord, x + 0.5F, y + 2F, z + 0.5F);
          p_149695_1_.spawnEntityInWorld(missile);
          entity.power -= 75000;

          entity.slots[0] = null;
        }
        if (entity.slots[0] != null
            && entity.slots[0].getItem() == ModItems.missile_incendiary_strong
            && entity.power >= 75000) {
          EntityMissileIncendiaryStrong missile =
              new EntityMissileIncendiaryStrong(
                  p_149695_1_, xCoord, zCoord, x + 0.5F, y + 2F, z + 0.5F);
          p_149695_1_.spawnEntityInWorld(missile);
          entity.power -= 75000;

          entity.slots[0] = null;
        }
        if (entity.slots[0] != null
            && entity.slots[0].getItem() == ModItems.missile_cluster_strong
            && entity.power >= 75000) {
          EntityMissileClusterStrong missile =
              new EntityMissileClusterStrong(
                  p_149695_1_, xCoord, zCoord, x + 0.5F, y + 2F, z + 0.5F);
          p_149695_1_.spawnEntityInWorld(missile);
          entity.power -= 75000;

          entity.slots[0] = null;
        }
        if (entity.slots[0] != null
            && entity.slots[0].getItem() == ModItems.missile_buster_strong
            && entity.power >= 75000) {
          EntityMissileBusterStrong missile =
              new EntityMissileBusterStrong(
                  p_149695_1_, xCoord, zCoord, x + 0.5F, y + 2F, z + 0.5F);
          p_149695_1_.spawnEntityInWorld(missile);
          entity.power -= 75000;

          entity.slots[0] = null;
        }
        if (entity.slots[0] != null
            && entity.slots[0].getItem() == ModItems.missile_burst
            && entity.power >= 75000) {
          EntityMissileBurst missile =
              new EntityMissileBurst(p_149695_1_, xCoord, zCoord, x + 0.5F, y + 2F, z + 0.5F);
          p_149695_1_.spawnEntityInWorld(missile);
          entity.power -= 75000;

          entity.slots[0] = null;
        }
        if (entity.slots[0] != null
            && entity.slots[0].getItem() == ModItems.missile_inferno
            && entity.power >= 75000) {
          EntityMissileInferno missile =
              new EntityMissileInferno(p_149695_1_, xCoord, zCoord, x + 0.5F, y + 2F, z + 0.5F);
          p_149695_1_.spawnEntityInWorld(missile);
          entity.power -= 75000;

          entity.slots[0] = null;
        }
        if (entity.slots[0] != null
            && entity.slots[0].getItem() == ModItems.missile_rain
            && entity.power >= 75000) {
          EntityMissileRain missile =
              new EntityMissileRain(p_149695_1_, xCoord, zCoord, x + 0.5F, y + 2F, z + 0.5F);
          p_149695_1_.spawnEntityInWorld(missile);
          entity.power -= 75000;

          entity.slots[0] = null;
        }
        if (entity.slots[0] != null
            && entity.slots[0].getItem() == ModItems.missile_drill
            && entity.power >= 75000) {
          EntityMissileDrill missile =
              new EntityMissileDrill(p_149695_1_, xCoord, zCoord, x + 0.5F, y + 2F, z + 0.5F);
          p_149695_1_.spawnEntityInWorld(missile);
          entity.power -= 75000;

          entity.slots[0] = null;
        }
        if (entity.slots[0] != null
            && entity.slots[0].getItem() == ModItems.missile_nuclear
            && entity.power >= 75000) {
          EntityMissileNuclear missile =
              new EntityMissileNuclear(p_149695_1_, xCoord, zCoord, x + 0.5F, y + 2F, z + 0.5F);
          p_149695_1_.spawnEntityInWorld(missile);
          entity.power -= 75000;

          entity.slots[0] = null;
        }
        if (entity.slots[0] != null
            && entity.slots[0].getItem() == ModItems.missile_endo
            && entity.power >= 75000) {
          EntityMissileEndo missile =
              new EntityMissileEndo(p_149695_1_, xCoord, zCoord, x + 0.5F, y + 2F, z + 0.5F);
          p_149695_1_.spawnEntityInWorld(missile);
          entity.power -= 75000;

          entity.slots[0] = null;
        }
        if (entity.slots[0] != null
            && entity.slots[0].getItem() == ModItems.missile_exo
            && entity.power >= 75000) {
          EntityMissileExo missile =
              new EntityMissileExo(p_149695_1_, xCoord, zCoord, x + 0.5F, y + 2F, z + 0.5F);
          p_149695_1_.spawnEntityInWorld(missile);
          entity.power -= 75000;

          entity.slots[0] = null;
        }
        if (entity.slots[0] != null
            && entity.slots[0].getItem() == ModItems.missile_nuclear_cluster
            && entity.power >= 75000) {
          EntityMissileMirv missile =
              new EntityMissileMirv(p_149695_1_, xCoord, zCoord, x + 0.5F, y + 2F, z + 0.5F);
          p_149695_1_.spawnEntityInWorld(missile);
          entity.power -= 75000;

          entity.slots[0] = null;
        }
      }
    }
  }
 @Override
 public void updateEntity() {
   super.updateEntity();
   World world = this.worldObj;
   if (!world.isRemote) {
     ItemStack inputItem = getStackInSlot(0);
     ItemStack spice = getStackInSlot(1);
     ItemStack outputItem = getStackInSlot(2);
     // progress
     if (inputItem != null
         && world.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)
         && world.getBlock(xCoord, yCoord + 1, zCoord) == Blocks.anvil) {
       if (outputItem == null) {
         if ((inputItem.getItem() == Items.coffeeBean && inputItem.getItemDamage() == 3)
             || (inputItem.getItem() == Item.getItemFromBlock(net.minecraft.init.Blocks.wool)
                 && inputItem.getItemDamage() != 15)) {
           this.progressTime++;
         }
         if (this.progressTime == 600) {
           this.progressTime = 0;
           if (inputItem.getItem() == Items.coffeeBean && inputItem.getItemDamage() == 3) {
             if (inputItem.stackSize >= 3) {
               if (inputItem.stackSize == 3) {
                 inputItem = null;
               } else {
                 inputItem.stackSize -= 3;
               }
               outputItem = new ItemStack(Items.coffeePowder, 1);
             } else {
               outputItem = new ItemStack(Items.mixedPowder, inputItem.stackSize);
               inputItem = null;
             }
           } else if (inputItem.getItem() == Item.getItemFromBlock(net.minecraft.init.Blocks.wool)
               && inputItem.getItemDamage() == 0) {
             if (inputItem.stackSize >= 5) {
               if (inputItem.stackSize == 5) {
                 inputItem = null;
               } else {
                 inputItem.stackSize -= 5;
               }
               outputItem =
                   new ItemStack(net.minecraft.init.Items.string, 3 + world.rand.nextInt(8));
             } else {
               outputItem = new ItemStack(Items.mixedPowder, inputItem.stackSize);
               inputItem = null;
             }
           } else if (inputItem.getItem() == Item.getItemFromBlock(net.minecraft.init.Blocks.wool)
               && inputItem.getItemDamage() == 3) {
             if (inputItem.stackSize >= 3) {
               if (inputItem.stackSize == 3) {
                 inputItem = null;
               } else {
                 inputItem.stackSize -= 3;
               }
               outputItem = new ItemStack(Items.cocoaPowder, 2);
             } else {
               outputItem = new ItemStack(Items.mixedPowder, inputItem.stackSize);
               inputItem = null;
             }
           } else if (inputItem.getItem() == Item.getItemFromBlock(net.minecraft.init.Blocks.wool)
               && inputItem.getItemDamage() != 15) {
             if (inputItem.stackSize >= 2) {
               if (inputItem.stackSize == 2) {
                 inputItem = null;
               } else {
                 inputItem.stackSize -= 2;
               }
               outputItem =
                   new ItemStack(
                       net.minecraft.init.Items.dye,
                       3 + world.rand.nextInt(13),
                       15 - inputItem.getItemDamage());
             } else {
               outputItem = new ItemStack(Items.mixedPowder, inputItem.stackSize);
               inputItem = null;
             }
           }
         }
       } else {
         if (allowProgress(inputItem, outputItem)) {
           this.progressTime++;
         }
         if (this.progressTime == 600) {
           this.progressTime = 0;
           if (inputItem.getItem() == Items.coffeeBean && inputItem.getItemDamage() == 3) {
             if (inputItem.stackSize >= 3) {
               if (inputItem.stackSize == 3) {
                 inputItem = null;
               } else {
                 inputItem.stackSize -= 3;
               }
               outputItem.stackSize++;
             }
           } else if (inputItem.getItem() == Item.getItemFromBlock(net.minecraft.init.Blocks.wool)
               && inputItem.getItemDamage() == 0) {
             if (inputItem.stackSize >= 5) {
               if (inputItem.stackSize == 5) {
                 inputItem = null;
               } else {
                 inputItem.stackSize -= 5;
               }
               outputItem.stackSize += 3 + world.rand.nextInt(8);
             }
           } else if (inputItem.getItem() == Item.getItemFromBlock(net.minecraft.init.Blocks.wool)
               && inputItem.getItemDamage() == 3) {
             if (inputItem.stackSize >= 3) {
               if (inputItem.stackSize == 3) {
                 inputItem = null;
               } else {
                 inputItem.stackSize -= 3;
               }
               outputItem.stackSize += 2;
             }
           } else if (inputItem.getItem() == Item.getItemFromBlock(net.minecraft.init.Blocks.wool)
               && inputItem.getItemDamage() != 15) {
             if (inputItem.stackSize >= 2) {
               if (inputItem.stackSize == 2) {
                 inputItem = null;
               } else {
                 inputItem.stackSize -= 2;
               }
               outputItem.stackSize += 3 + world.rand.nextInt(13);
             }
           }
         }
       }
       setInventorySlotContents(0, inputItem);
       setInventorySlotContents(2, outputItem);
     } else {
       this.progressTime = 0;
     }
   }
 }
예제 #25
0
  protected int getMineState(World par1World, int par2, int par3, int par4) {
    EnumMobType triggerMobType;

    TileEntityLandmine te = (TileEntityLandmine) par1World.getBlockTileEntity(par2, par3, par4);

    // Change to return 1 if you want the landmine to blow up when the block
    // holding it is broken
    if (te == null) {
      return 0;
    }
    switch (te.triggerType) {
      case 0:
        triggerMobType = EnumMobType.everything;
        break;
      case 1:
        triggerMobType = EnumMobType.mobs;
        break;
      case 2:
        triggerMobType = EnumMobType.players;
        break;
      default:
        triggerMobType = null;
        break;
    }

    if (triggerMobType != null) {
      List list = null;

      if (triggerMobType == EnumMobType.everything) {
        list =
            par1World.getEntitiesWithinAABBExcludingEntity(
                (Entity) null, getSensitiveAABB(par1World, par2, par3, par4));
      }

      if (triggerMobType == EnumMobType.mobs) {
        list =
            par1World.getEntitiesWithinAABB(
                EntityLivingBase.class, getSensitiveAABB(par1World, par2, par3, par4));
      }

      if (triggerMobType == EnumMobType.players) {
        list =
            par1World.getEntitiesWithinAABB(
                EntityPlayer.class, this.getSensitiveAABB(par1World, par2, par3, par4));
      }

      if (list != null && !list.isEmpty()) {
        Iterator iterator = list.iterator();

        while (iterator.hasNext()) {
          Entity entity = (Entity) iterator.next();

          if (!entity.doesEntityNotTriggerPressurePlate()) {
            return 1;
          }
        }
      }
    }

    return par1World.isBlockIndirectlyGettingPowered(par2, par3, par4) ? 1 : 0;
  }