@Override
  public void fire(World world, double[] xyz) {
    ReikaSoundHelper.playSoundAtBlock(world, xCoord, yCoord, zCoord, "random.explode", 1F, 1.3F);
    ReikaSoundHelper.playSoundAtBlock(world, xCoord, yCoord, zCoord, "random.explode", 1F, 0.5F);

    if (rand.nextBoolean()) {
      int slot = ReikaInventoryHelper.locateInInventory(ItemStacks.scrap, inv, false);
      ReikaInventoryHelper.decrStack(slot, inv);
    }

    double speed = 2;
    double[] v = new double[3];
    v[0] = xyz[0] - xCoord;
    v[1] = xyz[1] - yCoord;
    v[2] = xyz[2] - zCoord;
    double dd = ReikaMathLibrary.py3d(v[0], v[1], v[2]);
    for (int i = 0; i < 3; i++) v[i] /= dd;
    for (int i = 0; i < 3; i++) v[i] *= speed;
    dd = ReikaMathLibrary.py3d(v[0], v[1], v[2]);
    double dx = v[0] / dd;
    double dy = v[1] / dd;
    double dz = v[2] / dd;

    // ReikaJavaLibrary.pConsole(dx+"  "+dy+"  "+dz);
    if (!world.isRemote) {
      double y = this.getFiringPositionY(dy);
      EntityFlakShot flak =
          new EntityFlakShot(
              world, xCoord + 0.5 + dx, y, zCoord + 0.5 + dz, 3 * v[0], 3 * v[1], 3 * v[2], this);
      world.spawnEntityInWorld(flak);
    }
  }
 @Override
 public void overload(int current) {
   overloaded = true;
   ReikaSoundHelper.playBreakSound(worldObj, xCoord, yCoord, zCoord, Blocks.glass);
   ReikaSoundHelper.playSoundAtBlock(worldObj, xCoord, yCoord, zCoord, "random.fizz", 2, 1);
   ReikaPacketHelper.sendDataPacketWithRadius(
       DragonAPIInit.packetChannel, PacketIDs.COLOREDPARTICLE.ordinal(), this, 24, 1, 1, 1, 32, 0);
 }
 @Override
 public boolean onItemUse(
     ItemStack item,
     EntityPlayer player,
     World world,
     int x,
     int y,
     int z,
     int side,
     float par8,
     float par9,
     float par10) {
   if (!ReikaWorldHelper.softBlocks(world.getBlock(x, y, z))) {
     if (side == 0) --y;
     if (side == 1) ++y;
     if (side == 2) --z;
     if (side == 3) ++z;
     if (side == 4) --x;
     if (side == 5) ++x;
   }
   Block idbelow = world.getBlock(x, y - 1, z);
   if ((!ReikaWorldHelper.softBlocks(world.getBlock(x, y, z)))
       || !ReikaPlantHelper.SAPLING.canPlantAt(world, x, y, z)) return false;
   if (!player.canPlayerEdit(x, y, z, 0, item)) return false;
   else {
     if (!player.capabilities.isCreativeMode) --item.stackSize;
     world.setBlock(x, y, z, ChromaBlocks.PLANT.getBlockInstance(), item.getItemDamage() % 16, 3);
     ReikaSoundHelper.playPlaceSound(world, x, y, z, Blocks.grass);
     return true;
   }
 }
  @Override
  public void updateEntity(World world, int x, int y, int z, int meta) {
    super.updateEntity(world, x, y, z, meta);

    if (!world.isRemote && this.getEnergy(CrystalElement.GREEN) >= 200) {
      int n = this.getNumberAttempts();
      for (int i = 0; i < n; i++) {
        Coordinate c = this.getRandomPosition(world, x, y, z);
        CropType crop = this.getCropAt(world, c);
        if (crop != null && crop.isRipe(world, c.xCoord, c.yCoord, c.zCoord)) {
          int fortune = this.getFortune();
          ArrayList<ItemStack> li = crop.getDrops(world, c.xCoord, c.yCoord, c.zCoord, fortune);
          if (fortune < 3) {
            CropMethods.removeOneSeed(crop, li);
          }
          ReikaItemHelper.dropItems(world, c.xCoord + 0.5, c.yCoord + 0.5, c.zCoord + 0.5, li);
          crop.setHarvested(world, c.xCoord, c.yCoord, c.zCoord);
          ReikaSoundHelper.playBreakSound(world, x, y, z, c.getBlock(world));
          this.drainEnergy(CrystalElement.GREEN, 200);
          this.drainEnergy(CrystalElement.PURPLE, 50);
          this.sendParticles(c);
          break;
        }
      }
    }
  }
 public void rotate() {
   if (this.isRotateable() && !this.areLasersInPlay()) {
     facing = facing.getRotation(true);
     ReikaSoundHelper.playSoundAtBlock(
         worldObj, xCoord, yCoord, zCoord, "random.click", 0.4F, 0.5F);
     worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
   }
 }
  @Override
  public void updateEntity(World world, int x, int y, int z, int meta) {
    if (!world.isRemote && this.isFissile() && rand.nextInt(20) == 0)
      world.spawnEntityInWorld(new EntityNeutron(world, x, y, z, this.getRandomDirection()));
    // ReikaInventoryHelper.clearInventory(this);
    // ReikaInventoryHelper.addToIInv(ReactorItems.FUEL.getStackOf(), this);
    this.feed();

    tempTimer.update();
    if (tempTimer.checkCap()) {
      this.updateTemperature(world, x, y, z);
    }
    // ReikaJavaLibrary.pConsole(temperature);
    if (temperature > CLADDING) {
      if (rand.nextInt(20) == 0) ReikaSoundHelper.playSoundAtBlock(world, x, y, z, "random.fizz");
      ReikaParticleHelper.SMOKE.spawnAroundBlockWithOutset(world, x, y, z, 9, 0.0625);
    } else if (temperature > 500 && ReikaRandomHelper.doWithChance(20)) {
      if (rand.nextInt(20) == 0) ReikaSoundHelper.playSoundAtBlock(world, x, y, z, "random.fizz");
      ReikaParticleHelper.SMOKE.spawnAroundBlockWithOutset(world, x, y, z, 4, 0.0625);
    }
  }
Example #7
0
  @Override
  public void overheat(World world, int x, int y, int z) {
    BlockArray blocks = new BlockArray();
    MachineRegistry m = this.getMachine();
    blocks.recursiveAddWithMetadata(world, x, y, z, m.getBlock(), m.getMachineMetadata());

    for (int i = 0; i < blocks.getSize(); i++) {
      Coordinate c = blocks.getNthBlock(i);
      ReikaSoundHelper.playSoundAtBlock(
          world, c.xCoord, c.yCoord, c.zCoord, "random.fizz", 0.4F, 1);
      ReikaParticleHelper.LAVA.spawnAroundBlock(world, c.xCoord, c.yCoord, c.zCoord, 36);
      c.setBlock(world, Blocks.flowing_lava);
    }
  }
 public void notifyPlayerOfProgression(EntityPlayer ep, ProgressElement p) {
   if (ep.worldObj.isRemote) {
     ChromaOverlays.instance.addProgressionNote(p);
     ReikaSoundHelper.playClientSound(ChromaSounds.GAINPROGRESS, ep, 1, 1);
   } else if (ep instanceof EntityPlayerMP) {
     ReikaPacketHelper.sendDataPacket(
         ChromatiCraft.packetChannel,
         ChromaPackets.PROGRESSNOTE.ordinal(),
         (EntityPlayerMP) ep,
         this.getID(p));
     if (ChromaOptions.PROGRESSNOTIFY.getState()) {
       if (ChromaOptions.PROGRESSNOTIFY_SELF.getState()) ChromaAux.notifyServerPlayers(ep, p);
       else ChromaAux.notifyServerPlayersExcept(ep, p);
     }
   }
 }
 private void dropTieredResource(
     World world, int x, int y, int z, int dx, int dy, int dz, Block id, int meta2) {
   Collection<ItemStack> li =
       ((BlockTieredResource) id).getHarvestResources(world, dx, dy, dz, 10, this.getPlacer());
   this.dropItems(world, x, y, z, li);
   this.getFillerBlock(world, dx, dy, dz, id, meta2).place(world, dx, dy, dz);
   ReikaSoundHelper.playBreakSound(world, dx, dy, dz, id);
   ReikaPacketHelper.sendDataPacket(
       DragonAPIInit.packetChannel,
       PacketIDs.BREAKPARTICLES.ordinal(),
       world,
       dx,
       dy,
       dz,
       Block.getIdFromBlock(id),
       meta2);
 }
  @Override
  public final void keyTyped(char c, int key) {
    super.keyTyped(c, key);

    if (ModList.NEI.isLoaded() && key == NEIClientConfig.getKeyBinding("gui.recipe")) {
      int x = ReikaGuiAPI.instance.getMouseRealX();
      int y = ReikaGuiAPI.instance.getMouseRealY();
      int j = (width - xSize) / 2;
      int k = (height - ySize) / 2;
      if (x >= j && y >= k && x < j + xSize && y < k + ySize) {
        ItemStack is = ReikaGuiAPI.instance.getItemRenderAt(x, y);
        if (is != null) {
          ReikaSoundHelper.playClientSound(ChromaSounds.GUICLICK, player, 0.33F, 1);
          if (!MinecraftForge.EVENT_BUS.post(new NEIRecipeCheckEvent(null, is)))
            codechicken.nei.recipe.GuiCraftingRecipe.openRecipeGui("item", is);
        }
      }
    }
  }
  private void cutBlock(World world, int x, int y, int z, Coordinate c, Material mat) {
    // ReikaItemHelper.dropItems(world, dropx, y-0.25, dropz, dropBlocks.getDrops(world, c.xCoord,
    // c.yCoord, c.zCoord, dropmeta, 0));
    this.dropBlocks(world, c.xCoord, c.yCoord, c.zCoord);
    c.setBlock(world, Blocks.air);
    ReikaSoundHelper.playBreakSound(world, c.xCoord, c.yCoord, c.zCoord, Blocks.log);

    if (mat == Material.leaves)
      world.playSoundEffect(x + 0.5, y + 0.5, z + 0.5, "dig.grass", 0.5F + rand.nextFloat(), 1F);
    else world.playSoundEffect(x + 0.5, y + 0.5, z + 0.5, "dig.wood", 0.5F + rand.nextFloat(), 1F);
    if (tree.getTreeType() == ModWoodList.SLIME
        && c.getBlock(world) == tree.getTreeType().getLogID()) {
      jam++;
      jamColor =
          0xff000000
              | ReikaColorAPI.mixColors(
                  ModWoodList.SLIME.logColor, 0xffffff, (float) jam / MAX_JAM);
    }
  }
 private void dropBlock(
     World world, int x, int y, int z, int dx, int dy, int dz, Block id, int meta2) {
   if (this.silkTouch()) {
     this.dropItems(world, x, y, z, ReikaJavaLibrary.makeListFrom(new ItemStack(id, 1, meta2)));
   } else {
     this.dropItems(world, x, y, z, id.getDrops(world, dx, dy, dz, meta2, 0));
   }
   this.getFillerBlock(world, dx, dy, dz, id, meta2).place(world, dx, dy, dz);
   ReikaSoundHelper.playBreakSound(world, dx, dy, dz, id);
   ReikaPacketHelper.sendDataPacket(
       DragonAPIInit.packetChannel,
       PacketIDs.BREAKPARTICLES.ordinal(),
       world,
       dx,
       dy,
       dz,
       Block.getIdFromBlock(id),
       meta2);
 }
  @Override
  public void updateEntity(World world, int x, int y, int z, int meta) {
    if (rand.nextInt(20) == 0) this.sickenMobs(world, x, y, z);

    this.decayWaste(this.getAccelerationFactor(world, x, y, z));

    if (!world.isRemote) this.feed();

    if (world.provider.isHellWorld
        || ReikaWorldHelper.getAmbientTemperatureAt(world, x, y, z) > 100) {
      if (this.hasWaste()) {
        ReikaParticleHelper.SMOKE.spawnAroundBlock(world, x, y, z, 3);
        if (rand.nextInt(4) == 0) ReikaSoundHelper.playSoundAtBlock(world, x, y, z, "random.fizz");
        if (rand.nextInt(200) == 0) {
          world.setBlockToAir(x, y, z);
          world.newExplosion(null, x + 0.5, y + 0.5, y + 0.5, 4F, true, true);
        }
      }
    }
  }
Example #14
0
  @Override
  public final void updateEntity(World world, int x, int y, int z, int meta) {
    super.updateEntity(world, x, y, z, meta);

    // if (ModList.BCFACTORY.isLoaded() && ModList.REACTORCRAFT.isLoaded()) { //Only if, since need
    // a way to pipe it
    if (this.contains(FluidRegistry.getFluid("uranium hexafluoride"))
        || this.contains(FluidRegistry.getFluid("hydrofluoric acid"))) {
      ReikaSoundHelper.playSoundAtBlock(world, x, y, z, "random.fizz");
      for (int i = 0; i < 6; i++) {
        ForgeDirection dir = dirs[i];
        int dx = x + dir.offsetX;
        int dy = y + dir.offsetY;
        int dz = z + dir.offsetZ;
        MachineRegistry m = MachineRegistry.getMachine(world, dx, dy, dz);
        if (m == MachineRegistry.PIPE) {
          TileEntityPipe p = (TileEntityPipe) world.getTileEntity(dx, dy, dz);
          p.setFluid(liquid);
          p.addFluid(5);
          // ReikaParticleHelper.SMOKE.spawnAroundBlock(world, dx, dy, dz, 8);
        }
      }
      world.setBlockToAir(x, y, z);
      ReikaParticleHelper.SMOKE.spawnAroundBlock(world, x, y, z, 8);
    }
    // }

    if (rand.nextInt(60) == 0) {
      ReikaWorldHelper.temperatureEnvironment(world, x, y, z, this.getTemperature());
    }

    if (liquid != null) {
      int temp = liquid.getTemperature(worldObj, xCoord, yCoord, zCoord);
      temperature = temp > 750 ? temp - 425 : temp - 273;
      if (temperature > this.getMaxTemperature()) {
        this.overheat(worldObj, xCoord, yCoord, zCoord);
      }
    } else {
      temperature = ReikaWorldHelper.getAmbientTemperatureAt(world, x, y, z);
    }
  }
 @Override
 public void onBlockDestroyedByPlayer(World world, int x, int y, int z, int meta) {
   ForgeDirection dir = this.getDirectionFromMeta(meta);
   ForgeDirection left = ReikaDirectionHelper.getLeftBy90(dir);
   int r = 0; // some way to make bigger on demand...?
   int d = 64;
   for (int i = -r; i <= r; i++) {
     for (int j = -r; j <= r; j++) {
       for (int k = -d; k <= d; k++) {
         int dx = x + left.offsetX * i + dir.offsetX * k;
         int dy = y + j;
         int dz = z + left.offsetZ * i + dir.offsetZ * k;
         Block id = world.getBlock(dx, dy, dz);
         if (id == this) {
           ReikaSoundHelper.playBreakSound(world, dx, dy, dz, this);
           world.setBlockToAir(dx, dy, dz);
           world.markBlockForUpdate(dx, dy, dz);
         }
       }
     }
   }
 }
 @Override
 public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity e) {
   TileEntity tile = world.getTileEntity(x, y, z);
   if (tile instanceof TileEntityCrystalPortal && !world.isRemote) {
     TileEntityCrystalPortal te = (TileEntityCrystalPortal) tile;
     if (e instanceof EntityPlayer) {
       if (te.complete) {
         EntityPlayer ep = (EntityPlayer) e;
         if (te.canPlayerUse(ep)) {
           int dim = te.getTargetDimension();
           ReikaEntityHelper.transferEntityToDimension(e, dim, new ChromaTeleporter(dim));
           ProgressStage.DIMENSION.stepPlayerTo(ep);
           ReikaSoundHelper.broadcastSound(
               ChromaSounds.GOTODIM, ChromatiCraft.packetChannel, 1, 1);
         } else {
           this.denyEntity(e);
         }
       } else {
         this.denyEntity(e);
       }
     }
   }
 }
 @Override
 public void updateEntity(World world, int x, int y, int z, int meta) {
   super.updateTileEntity();
   tickcount++;
   this.readPower(false);
   this.getIOSides(world, x, y, z, meta);
   if (power >= MINPOWER && torque >= MINTORQUE) {
     if (tickcount >= this.getOperationTime()) {
       this.process(world, x, y, z, meta);
       tickcount = 0;
     }
     int hx = x + step * facing.offsetX;
     int hy = y + step * facing.offsetY;
     int hz = z + step * facing.offsetZ;
     Block b = world.getBlock(hx, hy, hz);
     if (b != Blocks.air) {
       ReikaParticleHelper.CRITICAL.spawnAroundBlock(world, hx, hy, hz, 4);
       ReikaSoundHelper.playStepSound(
           world, hx, hy, hz, b, 0.5F + rand.nextFloat(), 0.5F * rand.nextFloat());
       // ReikaSoundHelper.playSoundAtBlock(world, hx, hy, hz, "dig.stone", );
     }
   }
 }
 public void grind(World world, int mx, int my, int mz, int x, int y, int z, int meta) {
   if (this.processBlock(world, x, y, z)) {
     if (this.isBedrock(world, x, y, z)) {
       world.playSoundEffect(
           x + 0.5D, y + 0.5D, z + 0.5D, "dig.stone", 0.5F, rand.nextFloat() * 0.4F + 0.8F);
       world.setBlock(x, y, z, BlockRegistry.BEDROCKSLICE.getBlockInstance(), 0, 3);
     } else {
       int rockmetadata = world.getBlockMetadata(x, y, z);
       if (rockmetadata < 15) {
         world.playSoundEffect(
             x + 0.5D, y + 0.5D, z + 0.5D, "dig.stone", 0.5F, rand.nextFloat() * 0.4F + 0.8F);
         world.setBlockMetadataWithNotify(x, y, z, rockmetadata + 1, 3);
       } else {
         world.playSoundEffect(
             x + 0.5D, y + 0.5D, z + 0.5D, "mob.blaze.hit", 0.5F, rand.nextFloat() * 0.4F + 0.8F);
         ItemStack is = this.getDrops(world, x, y, z);
         world.setBlockToAir(x, y, z);
         if (!this.chestCheck(world, x, y, z, is)) {
           if (this.isInventoryFull()) ReikaItemHelper.dropItem(world, dropx, dropy, dropz, is);
           else ReikaInventoryHelper.addOrSetStack(is, inv, 0);
         }
         RotaryAchievements.BEDROCKBREAKER.triggerAchievement(this.getPlacer());
         MinecraftForge.EVENT_BUS.post(new BedrockDigEvent(this, x, y, z));
         if (!world.isRemote) this.incrementStep(world, mx, my, mz);
       }
     }
   } else {
     Block b = world.getBlock(x, y, z);
     if (b != Blocks.air && b.getBlockHardness(world, x, y, z) >= 0) {
       ReikaSoundHelper.playBreakSound(world, x, y, z, b);
       if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT)
         ReikaRenderHelper.spawnDropParticles(world, x, y, z, b, world.getBlockMetadata(x, y, z));
       world.setBlockToAir(x, y, z);
     }
     if (!world.isRemote) this.incrementStep(world, mx, my, mz);
   }
 }
  @Override
  protected void mouseClicked(int x, int y, int button) {
    super.mouseClicked(x, y, button);

    int j = (width - xSize) / 2;
    int k = (height - ySize) / 2;
    int minx = 120;
    int miny = 24;
    int w = 36;
    int maxx = minx + w;
    int maxy = miny + w;
    if (mode == AspectMode.DEMAND) {
      if (api.isMouseInBox(j + minx, j + maxx, k + miny, k + maxy)) {
        // Minecraft.getMinecraft().thePlayer.playSound("random.click", 1, 1);
        ReikaSoundHelper.playClientSound(ChromaSounds.GUICLICK, player, 1, 1);
        clickDelay = 90;
        ReikaPacketHelper.sendStringPacket(
            ChromatiCraft.packetChannel,
            ChromaPackets.ASPECT.ordinal(),
            this.getActive().getTag(),
            tile);
      }
    }
  }
 public void melt(World world, int x, int y, int z) {
   ReikaSoundHelper.playSoundAtBlock(world, x, y, z, "random.fizz");
   ReikaParticleHelper.LAVA.spawnAroundBlock(world, x, y, z, 12);
   world.setBlock(x, y, z, Blocks.flowing_lava);
 }