@Override
  public void updateEntity(World world, int x, int y, int z, int meta) {
    super.updateTileEntity();
    this.getIOSidesDefault(world, x, y, z, meta);
    this.getPower(false);

    // ReikaJavaLibrary.pConsole((omega-MINSPEED)+":"+dur);
    timer.setCap(this.getOperationTime());

    tempTimer.update();
    if (tempTimer.checkCap()) this.updateTemperature(world, x, y, z, meta);

    if (!worldObj.isRemote) {
      int n = this.getNumberConsecutiveOperations();
      for (int i = 0; i < n; i++) this.doOperation(n > 1);

      freezeTick = timer.getTick();
    }

    sound.update();
    if (omega > 0) {
      if (sound.checkCap())
        SoundRegistry.FAN.playSoundAtBlock(
            world, x, y, z, RotaryAux.isMuffled(this) ? 0.1F : 0.4F, 0.6F);
    }
  }
Esempio n. 2
0
  @Override
  public void updateEntity(World world, int x, int y, int z, int meta) {
    super.updateTileEntity();
    int temp = (int) (15 * this.getArraySize() * this.getArrayOverallBrightness());
    for (int i = -3; i <= 3; i++) {
      for (int j = -3; j <= 3; j++) {
        if (ConfigRegistry.BLOCKDAMAGE.getState()) {
          ReikaWorldHelper.temperatureEnvironment(world, x + i, y + 1, z + j, Math.min(temp, 1750));
          if (temp >= 1500) {
            this.delete();
            world.setBlock(x, y, z, Blocks.flowing_lava);
          }
        }
        AxisAlignedBB above =
            AxisAlignedBB.getBoundingBox(x + i, y + 1, z + j, x + i + 1, y + 2, z + j + 1);
        List<EntityLivingBase> in = world.getEntitiesWithinAABB(EntityLivingBase.class, above);
        for (EntityLivingBase e : in) {
          if (temp > 400) e.setFire(3);
        }
      }
    }
    if (world.getBlock(x, y - 1, z) == Blocks.air
        || MachineRegistry.getMachine(world, x, y - 1, z) != this.getMachine()) {
      // ReikaJavaLibrary.pConsole("TOWER: "+this.getTowerHeight()+";  SIZE: "+this.getArraySize());
      this.generatePower(world, x, y, z);
    } else {
      write = null;
    }
    if (world.getBlock(x, y + 1, z) != Blocks.air) return;

    mirrorTimer.update();
    if (mirrorTimer.checkCap()) {
      if (solarBlocks.isEmpty()) {
        lightMultiplier = 0;
        solarBlocks.recursiveAdd(world, x, y, z, this.getTileEntityBlockID());
        numberMirrors = solarBlocks.getSize();
        while (solarBlocks.getSize() > 0) {
          Coordinate c = solarBlocks.getNextAndMoveOn();
          MachineRegistry m = MachineRegistry.getMachine(world, c.xCoord, c.yCoord, c.zCoord);
          if (m == MachineRegistry.MIRROR) {
            TileEntityMirror te =
                (TileEntityMirror) world.getTileEntity(c.xCoord, c.yCoord, c.zCoord);
            te.targetloc = new Coordinate(x, y, z);
            float light = te.getLightLevel();
            lightMultiplier += light;
          } else numberMirrors--;
        }
        lightMultiplier /= 15F;
        lightMultiplier /= numberMirrors;
      }
    }

    if (write != null) {
      this.basicPowerReceiver();
    }
  }
 private void doOperation(boolean multiple) {
   if (!tank.isEmpty()) {
     ItemStack toMake = RecipesCrystallizer.getRecipes().getFreezingResult(tank.getFluid());
     // ReikaJavaLibrary.pConsole(timer.getTick()+"/"+timer.getCap()+":"+toMake);
     if (this.canOperate(toMake)) {
       timer.update();
       if (multiple || timer.checkCap()) {
         this.make(toMake);
       }
     } else timer.reset();
   } else timer.reset();
 }
  @Override
  public void updateEntity(World world, int x, int y, int z, int meta) {
    super.updateTileEntity();
    this.getPowerBelow();

    timer.update();
    if (timer.checkCap()) this.updateTemperature(world, x, y, z, meta);
    if (temperature > this.getMeltingTemperature()) energy += power;
    else energy *= 0.85;

    // ReikaJavaLibrary.pConsole(this.getMeltingTemperature()+":"+energy/20F/MELT_ENERGY,
    // Side.SERVER);

    tickcount++;
    if (omega > 0 && power > 0) {
      if (tickcount > 98) {
        SoundRegistry.FRICTION.playSoundAtBlock(
            world, x, y, z, RotaryAux.isMuffled(this) ? 0.1F : 0.5F, 0.5F);
        tickcount = 0;
      }
      world.spawnParticle(
          "crit",
          x + rand.nextDouble(),
          y,
          z + rand.nextDouble(),
          -0.2 + 0.4 * rand.nextDouble(),
          0.4 * rand.nextDouble(),
          -0.2 + 0.4 * rand.nextDouble());
    }

    for (int i = 0; i < inv.length; i++) {
      ItemStack is = inv[i];
      if (is != null) {
        FluidStack fs = RecipesLavaMaker.getRecipes().getMelting(is);
        long melt_energy = RecipesLavaMaker.getRecipes().getMeltingEnergy(is);
        // ReikaJavaLibrary.pConsole(energy/20L+":"+melt_energy, Side.SERVER);
        if (fs != null) {
          if (this.canMake(fs) && energy >= melt_energy * 20) {
            tank.addLiquid(fs.amount, fs.getFluid());
            ReikaInventoryHelper.decrStack(i, inv);
            energy -= melt_energy * 20;
            return;
          }
        }
      }
    }
  }
  @Override
  public void updateEntity(World world, int x, int y, int z, int meta) {
    if (!PowerTransferHelper.checkPowerFrom(this, ForgeDirection.DOWN)
        && !PowerTransferHelper.checkPowerFrom(this, ForgeDirection.UP)) {
      this.noInputMachine();
    }

    if (power >= MINPOWER && torque >= MINTORQUE) {
      timer.setCap(Math.max(1, 20 - 2 * (int) ReikaMathLibrary.logbase(omega, 2)));
      timer.update();
      Extraction e = this.getExtraction(world, x, y, z);
      if (e != null) {
        if (timer.checkCap() && e.canPerform(world, x, y, z)) {
          this.harvest(e, world, x, y, z);
        }
      } else {
        timer.reset();
      }
    }
  }
  @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);
    }
  }
Esempio n. 7
0
 private void playSound(World world, int x, int y, int z) {
   if (sound.checkCap()) {
     SoundRegistry.BELT.playSoundAtBlock(world, x, y, z, 0.6F, 1F);
   }
 }