@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();
    }
  }
 public void getLiq(World world, int x, int y, int z, int metadata) {
   int oldLevel = 0;
   if (liquidLevel < CAPACITY) {
     if (MachineRegistry.getMachine(world, x + 1, y, z) == MachineRegistry.PIPE) {
       TileEntityPipe tile = (TileEntityPipe) world.getBlockTileEntity(x + 1, y, z);
       if (tile != null && (tile.liquidID == liquidID || liquidID == -1) && tile.liquidLevel > 0) {
         liquidID = tile.liquidID;
         oldLevel = tile.liquidLevel;
         tile.liquidLevel =
             ReikaMathLibrary.extrema(tile.liquidLevel - tile.liquidLevel / 4 - 1, 0, "max");
         liquidLevel = ReikaMathLibrary.extrema(liquidLevel + oldLevel / 4 + 1, 0, "max");
       }
     }
     if (MachineRegistry.getMachine(world, x - 1, y, z) == MachineRegistry.PIPE) {
       TileEntityPipe tile = (TileEntityPipe) world.getBlockTileEntity(x - 1, y, z);
       if (tile != null && (tile.liquidID == liquidID || liquidID == -1) && tile.liquidLevel > 0) {
         liquidID = tile.liquidID;
         oldLevel = tile.liquidLevel;
         tile.liquidLevel =
             ReikaMathLibrary.extrema(tile.liquidLevel - tile.liquidLevel / 4 - 1, 0, "max");
         liquidLevel = ReikaMathLibrary.extrema(liquidLevel + oldLevel / 4 + 1, 0, "max");
       }
     }
     if (MachineRegistry.getMachine(world, x, y - 1, z) == MachineRegistry.PIPE) {
       TileEntityPipe tile = (TileEntityPipe) world.getBlockTileEntity(x, y - 1, z);
       if (tile != null && (tile.liquidID == liquidID || liquidID == -1) && tile.liquidLevel > 0) {
         liquidID = tile.liquidID;
         oldLevel = tile.liquidLevel;
         tile.liquidLevel =
             ReikaMathLibrary.extrema(tile.liquidLevel - tile.liquidLevel / 4 - 1, 0, "max");
         liquidLevel = ReikaMathLibrary.extrema(liquidLevel + oldLevel / 4 + 1, 0, "max");
       }
     }
     if (MachineRegistry.getMachine(world, x, y, z + 1) == MachineRegistry.PIPE) {
       TileEntityPipe tile = (TileEntityPipe) world.getBlockTileEntity(x, y, z + 1);
       if (tile != null && (tile.liquidID == liquidID || liquidID == -1) && tile.liquidLevel > 0) {
         liquidID = tile.liquidID;
         oldLevel = tile.liquidLevel;
         tile.liquidLevel =
             ReikaMathLibrary.extrema(tile.liquidLevel - tile.liquidLevel / 4 - 1, 0, "max");
         liquidLevel = ReikaMathLibrary.extrema(liquidLevel + oldLevel / 4 + 1, 0, "max");
       }
     }
     if (MachineRegistry.getMachine(world, x, y, z - 1) == MachineRegistry.PIPE) {
       TileEntityPipe tile = (TileEntityPipe) world.getBlockTileEntity(x, y, z - 1);
       if (tile != null && (tile.liquidID == liquidID || liquidID == -1) && tile.liquidLevel > 0) {
         liquidID = tile.liquidID;
         oldLevel = tile.liquidLevel;
         tile.liquidLevel =
             ReikaMathLibrary.extrema(tile.liquidLevel - tile.liquidLevel / 4 - 1, 0, "max");
         liquidLevel = ReikaMathLibrary.extrema(liquidLevel + oldLevel / 4 + 1, 0, "max");
       }
     }
   }
 }
Example #3
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 int getBottomOfTower() {
   int y = yCoord;
   while (MachineRegistry.getMachine(worldObj, xCoord, y, zCoord) == MachineRegistry.SOLARTOWER) {
     y--;
   }
   return y + 1;
 }
 @Override
 public boolean canConnectToPipe(MachineRegistry m) {
   return m.isStandardPipe()
       || m == MachineRegistry.HOSE
       || m == MachineRegistry.FUELLINE
       || m == MachineRegistry.VALVE;
 }
 public int getTopOfTower() {
   int y = yCoord;
   while (MachineRegistry.getMachine(worldObj, xCoord, y, zCoord) == MachineRegistry.SOLARTOWER) {
     y++;
   }
   return y - 1;
 }
 public static RotaryTERenderer instantiateRenderer(MachineRegistry m) {
   try {
     RotaryTERenderer r = (RotaryTERenderer) Class.forName(m.getRenderer()).newInstance();
     if (addRender(m, r)) return r;
     else return renders.get(overrides.get(m));
   } catch (InstantiationException e) {
     e.printStackTrace();
     throw new RuntimeException("Tried to call nonexistent render " + m.getRenderer() + "!");
   } catch (IllegalAccessException e) {
     e.printStackTrace();
     throw new RuntimeException("Tried to call illegal render " + m.getRenderer() + "!");
   } catch (ClassNotFoundException e) {
     e.printStackTrace();
     throw new RegistrationException(
         RotaryCraft.instance, "No class found for Renderer " + m.getRenderer() + "!");
   }
 }
 public void resetOther() {
   if (!isEmitting) {
     MachineRegistry m = MachineRegistry.getMachine(worldObj, target[0], target[1], target[2]);
     if (m == MachineRegistry.BELT) {
       TileEntityBeltHub te =
           (TileEntityBeltHub) worldObj.getBlockTileEntity(target[0], target[1], target[2]);
       te.reset();
     }
   } else {
     MachineRegistry m = MachineRegistry.getMachine(worldObj, source[0], source[1], source[2]);
     if (m == MachineRegistry.BELT) {
       TileEntityBeltHub te =
           (TileEntityBeltHub) worldObj.getBlockTileEntity(source[0], source[1], source[2]);
       te.reset();
     }
   }
 }
 public void getTowerWater(World world, int x, int y, int z) {
   int water = tank.getLevel();
   int cy = y + 1;
   while (MachineRegistry.getMachine(world, x, cy, z) == MachineRegistry.SOLARTOWER) {
     TileEntitySolar tile = (TileEntitySolar) (world.getTileEntity(x, cy, z));
     water += tile.tank.getLevel();
     tile.tank.empty();
     cy++;
   }
   tank.setContents(water, FluidRegistry.WATER);
 }
 @SubscribeEvent
 public void noItemEntityPush(EntityPushOutOfBlocksEvent evt) {
   Entity e = evt.entity;
   if (e instanceof EntityItem) {
     int x = MathHelper.floor_double(e.posX);
     int y = MathHelper.floor_double(e.posY);
     int z = MathHelper.floor_double(e.posZ);
     MachineRegistry m = MachineRegistry.getMachine(e.worldObj, x, y, z);
     if (m == MachineRegistry.RESERVOIR) {
       evt.setCanceled(true);
     }
   }
 }
 public boolean shouldRenderBelt() {
   if (isEmitting) {
     MachineRegistry m = MachineRegistry.getMachine(worldObj, source[0], source[1], source[2]);
     return m == MachineRegistry.BELT && this.canConnect(source[0], source[1], source[2]);
   } else {
     if (target[0] != Integer.MIN_VALUE
         && target[1] != Integer.MIN_VALUE
         && target[2] != Integer.MIN_VALUE)
       // return MachineRegistry.getMachine(worldObj, target[0], target[1], target[2]) ==
       // MachineRegistry.BELT;
       return this.canConnect(target[0], target[1], target[2]);
     return false;
   }
 }
 private void copyPower() {
   MachineRegistry m = MachineRegistry.getMachine(worldObj, source[0], source[1], source[2]);
   // ReikaJavaLibrary.pConsole(Arrays.toString(source));
   if (m == MachineRegistry.BELT && this.canConnect(source[0], source[1], source[2])) {
     TileEntityBeltHub tile =
         (TileEntityBeltHub) worldObj.getBlockTileEntity(source[0], source[1], source[2]);
     omega = this.getSlipOmega(tile.omega);
     torque = Math.min(this.getMaxTorque(), tile.torque);
     power = tile.power;
   } else {
     if (omega > 0) omega--;
     else torque = 0;
     power = omega * torque;
   }
 }
Example #13
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 boolean canConnectToPipe(MachineRegistry m) {
   return m.isStandardPipe();
 }
Example #15
0
 protected void doRenderMachine(double x, double y, HandbookEntry he) {
   HandbookRegistry h = (HandbookRegistry) he;
   MachineRegistry m = h.getMachine();
   if (m == null) return;
   MaterialRegistry[] mats = MaterialRegistry.values();
   TileEntity te = m.createTEInstanceForRender(0);
   int timeStep = (int) ((System.nanoTime() / SECOND) % mats.length);
   int r = (int) (System.nanoTime() / 20000000) % 360;
   float variable = 0;
   if (h.isEngine() && h != HandbookRegistry.SOLAR) {
     // ((TileEntityEngine)te).type = EngineType.engineList[h.getOffset()];
     // variable = -1000F*(h.getOffset()+1);
     EngineType type = EngineType.engineList[h.getOffset()];
     te = type.getTEInstanceForRender();
     ((TileEntityEngine) te).setType(type.getCraftedProduct());
   }
   if (h == HandbookRegistry.SHAFT) {
     variable = -1000F * (timeStep + 1);
   }
   if (h == HandbookRegistry.FLYWHEEL) {
     int tick = (int) ((System.nanoTime() / SECOND) % RotaryNames.getNumberFlywheelTypes());
     variable = 500 - 1000F * (tick + 1);
   }
   if (h == HandbookRegistry.GEARBOX) {
     variable = -1000F * (timeStep + 1);
   }
   if (h == HandbookRegistry.WORM) {
     variable = -1000F;
   }
   if (h == HandbookRegistry.CVT) {
     variable = -2000F;
   }
   if (h == HandbookRegistry.COIL) {
     int tick = (int) ((System.nanoTime() / SECOND) % 2);
     if (tick == 1) ((TileEntityAdvancedGear) te).setBedrock(true);
     variable = -3000F;
   }
   double sc = 48;
   GL11.glPushMatrix();
   if (m.hasModel() && !m.isPipe()) {
     double dx = x;
     double dy = y + 21;
     double dz = 0;
     GL11.glTranslated(dx, dy, dz);
     GL11.glScaled(sc, -sc, sc);
     GL11.glRotatef(renderq, 1, 0, 0);
     GL11.glRotatef(r, 0, 1, 0);
     TileEntityRendererDispatcher.instance.renderTileEntityAt(te, -0.5, 0, -0.5, variable);
   } else {
     double dx = x;
     double dy = y;
     double dz = 0;
     GL11.glTranslated(dx, dy, dz);
     GL11.glScaled(sc, -sc, sc);
     GL11.glRotatef(renderq, 1, 0, 0);
     GL11.glRotatef(r, 0, 1, 0);
     ReikaTextureHelper.bindTerrainTexture();
     rb.renderBlockAsItem(m.getBlock(), m.getBlockMetadata(), 1);
   }
   GL11.glPopMatrix();
 }
  @SubscribeEvent(priority = EventPriority.LOWEST, receiveCanceled = true)
  public void preventDisallowOfCrucialBlocks(BlockEvent ev) {
    Class c = ev.getClass();
    boolean place = c.getSimpleName().contains("BlockPlaceEvent");
    World world = ev.world;
    int x = ev.x;
    int y = ev.y;
    int z = ev.z;
    if (ev.block == null) return;
    Block id = ev.block;
    int meta = ev.blockMetadata;
    MachineRegistry m = MachineRegistry.getMachineFromIDandMetadata(id, meta);
    if (place) { // Bukkit Block Place Event
      if (m != null) {
        if (ConfigRegistry.ALLOWBAN.getState()) {
          if (m.isCrucial()) {
            if (m.canBeDisabledInOverworld()
                && ReikaWorldHelper.otherDimensionsExist()
                && world.provider.dimensionId == 0) {
              if (ev.isCanceled())
                RotaryCraft.logger.log(
                    "Something successfully cancelled the placement of "
                        + m
                        + ". This ban applies to the overworld only!");
            } else {
              if (ev.isCanceled())
                RotaryCraft.logger.log(
                    "Something tried to cancel the placement of "
                        + m
                        + ". This machine is essential and its placement may not be disallowed.");
              ev.setCanceled(false);
            }
          } else {
            if (ev.isCanceled())
              RotaryCraft.logger.log(
                  "Something successfully cancelled the placement of "
                      + m
                      + ". Unless this machine really needs to be disabled, it is recommended you remove this placement ban.");
          }
        } else {
          if (ev.isCanceled())
            RotaryCraft.logger.log(
                "Something tried to cancel the placement of "
                    + m
                    + ". This is permissible, but you must change the configs to allow it.");
          ev.setCanceled(false);
        }
      }
    }

    if (ConfigRegistry.LOGBLOCKS.getState()) {
      if (m != null) {
        EntityPlayer ep =
            (EntityPlayer)
                ReikaWorldHelper.getClosestLivingEntityOfClass(
                    EntityPlayer.class, world, x + 0.5, y + 0.5, z + 0.5, 6);
        String s = place ? "placed" : "removed";
        String name = ep != null ? ep.getCommandSenderName() : "<No Player>";
        RotaryCraft.logger.log(
            "A "
                + m.getName()
                + " was "
                + s
                + " by "
                + name
                + " at "
                + x
                + ", "
                + y
                + ", "
                + z
                + " in world dimension "
                + world.provider.dimensionId);
      }
    }
  }
 @SubscribeEvent
 public void burnLubricantHose(BlockConsumedByFireEvent evt) {
   if (MachineRegistry.getMachine(evt.world, evt.x, evt.y, evt.z) == MachineRegistry.HOSE) {
     ((TileEntityHose) evt.world.getTileEntity(evt.x, evt.y, evt.z)).burn();
   }
 }
 @Override
 public boolean onItemUse(
     ItemStack is,
     EntityPlayer ep,
     World world,
     int x,
     int y,
     int z,
     int side,
     float par8,
     float par9,
     float par10) {
   if (!ReikaWorldHelper.softBlocks(world, x, y, z)
       && world.getBlockMaterial(x, y, z) != Material.water
       && world.getBlockMaterial(x, y, z) != Material.lava) {
     if (side == 0) --y;
     if (side == 1) ++y;
     if (side == 2) --z;
     if (side == 3) ++z;
     if (side == 4) --x;
     if (side == 5) ++x;
     this.clearBlocks(world, x, y, z);
     int id = world.getBlockId(x, y, z);
     if (ReikaBlockHelper.isPortalBlock(world, x, y, z)) {
       TileEntityShaft sha = new TileEntityShaft();
       sha.setBlockMetadata(RotaryAux.get6SidedMetadataFromPlayerLook(ep));
       sha.getIOSides(world, x, y, z, sha.getBlockMetadata());
       sha.xCoord = x;
       sha.yCoord = y;
       sha.zCoord = z;
       int dx = sha.getReadDirection().offsetX;
       int dy = sha.getReadDirection().offsetY;
       int dz = sha.getReadDirection().offsetZ;
       MachineRegistry m = MachineRegistry.getMachine(world, dx, dy, dz);
       if (m == MachineRegistry.SHAFT) {
         TileEntityShaft te = (TileEntityShaft) world.getBlockTileEntity(dx, dy, dz);
         if (te.isWritingToCoordinate(x, y, z)) {
           world.setBlock(
               dx,
               dy,
               dz,
               MachineRegistry.PORTALSHAFT.getBlockID(),
               MachineRegistry.PORTALSHAFT.getMachineMetadata(),
               3);
           TileEntityPortalShaft ps = new TileEntityPortalShaft();
           world.setBlockTileEntity(dx, dy, dz, ps);
           ps.setBlockMetadata(te.getBlockMetadata());
           ps.setPortalType(world, x, y, z);
           ps.material = te.getShaftType();
         }
       }
     }
     if (!ReikaWorldHelper.softBlocks(world, x, y, z)
         && world.getBlockMaterial(x, y, z) != Material.water
         && world.getBlockMaterial(x, y, z) != Material.lava) return false;
   }
   this.clearBlocks(world, x, y, z);
   AxisAlignedBB box = AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1);
   List inblock = world.getEntitiesWithinAABB(EntityLivingBase.class, box);
   if (inblock.size() > 0) return false;
   if (!ep.canPlayerEdit(x, y, z, 0, is)) return false;
   else {
     if (!ep.capabilities.isCreativeMode) --is.stackSize;
     world.setBlock(x, y, z, MachineRegistry.SHAFT.getBlockID(), is.getItemDamage(), 3);
     if (is.getItemDamage() == RotaryNames.getNumberShaftTypes() - 1) {
       TileEntityShaft sha = (TileEntityShaft) world.getBlockTileEntity(x, y, z);
       if (sha != null) {
         // sha.type = MaterialRegistry.STEEL;
         sha.setBlockMetadata(6 + RotaryAux.get4SidedMetadataFromPlayerLook(ep));
       }
       return true;
     }
     TileEntityShaft sha = (TileEntityShaft) world.getBlockTileEntity(x, y, z);
     if (sha != null) {
       world.playSoundEffect(x + 0.5, y + 0.5, z + 0.5, "step.stone", 1F, 1.5F);
       // sha.type = MaterialRegistry.setType(is.getItemDamage());
     }
   }
   TileEntityShaft sha = (TileEntityShaft) world.getBlockTileEntity(x, y, z);
   sha.setBlockMetadata(RotaryAux.get6SidedMetadataFromPlayerLook(ep));
   sha.placer = ep.getEntityName();
   if (RotaryAux.shouldSetFlipped(world, x, y, z)) {
     sha.isFlipped = true;
   }
   return true;
 }
Example #19
0
  @Override
  public void onImpact(MovingObjectPosition mov) {
    if (mov != null
        && MachineRegistry.getMachine(worldObj, mov.blockX, mov.blockY, mov.blockZ)
            == MachineRegistry.RAILGUN) {
      this.setDead();
      return;
    }
    if (isDead) return;
    World world = worldObj;
    double x = posX;
    double y = posY;
    double z = posZ;
    int x0 = (int) x;
    int y0 = (int) y;
    int z0 = (int) z;
    EntityLiving el;
    Entity ent;
    // ReikaChatHelper.writeCoords(world, x, y, z);
    // ReikaChatHelper.writeBlockAtCoords(world, x0, y0, z0);
    world.spawnParticle("hugeexplosion", x0, y0, z0, 0, 0, 0);
    for (int i = -3; i <= 3; i++) {
      for (int j = -3; j <= 3; j++) {
        for (int k = -3; k <= 3; k++) {
          if (i * j * k < 9 && i * j * k > -9) {
            if (ConfigRegistry.BLOCKDAMAGE.getState()) {
              int id = world.getBlockId(x0 + i, y0 + j, z0 + k);
              if (ReikaWorldHelper.softBlocks(id)
                  && !ReikaWorldHelper.isLiquidSourceBlock(worldObj, x0 + i, y0 + j, z0 + k))
                ReikaWorldHelper.recursiveBreakWithinSphere(
                    world, x0 + i, y0 + j, z0 + k, id, -1, x0 + i, y0 + j, z0 + k, 5);
              if (power >= 1) {
                ReikaWorldHelper.recursiveBreakWithinSphere(
                    world,
                    x0 + i,
                    y0 + j,
                    z0 + k,
                    Block.leaves.blockID,
                    -1,
                    x0 + i,
                    y0 + j,
                    z0 + k,
                    5);
                ReikaWorldHelper.recursiveBreakWithinSphere(
                    world,
                    x0 + i,
                    y0 + j,
                    z0 + k,
                    Block.plantRed.blockID,
                    -1,
                    x0 + i,
                    y0 + j,
                    z0 + k,
                    5);
                ReikaWorldHelper.recursiveBreakWithinSphere(
                    world,
                    x0 + i,
                    y0 + j,
                    z0 + k,
                    Block.plantYellow.blockID,
                    -1,
                    x0 + i,
                    y0 + j,
                    z0 + k,
                    5);
                ReikaWorldHelper.recursiveBreakWithinSphere(
                    world,
                    x0 + i,
                    y0 + j,
                    z0 + k,
                    Block.reed.blockID,
                    -1,
                    x0 + i,
                    y0 + j,
                    z0 + k,
                    5);
                ReikaWorldHelper.recursiveBreakWithinSphere(
                    world,
                    x0 + i,
                    y0 + j,
                    z0 + k,
                    Block.waterlily.blockID,
                    -1,
                    x0 + i,
                    y0 + j,
                    z0 + k,
                    5);
                ReikaWorldHelper.recursiveBreakWithinSphere(
                    world,
                    x0 + i,
                    y0 + j,
                    z0 + k,
                    Block.mushroomBrown.blockID,
                    -1,
                    x0 + i,
                    y0 + j,
                    z0 + k,
                    5);
                ReikaWorldHelper.recursiveBreakWithinSphere(
                    world,
                    x0 + i,
                    y0 + j,
                    z0 + k,
                    Block.mushroomRed.blockID,
                    -1,
                    x0 + i,
                    y0 + j,
                    z0 + k,
                    5);
                ReikaWorldHelper.recursiveBreakWithinSphere(
                    world,
                    x0 + i,
                    y0 + j,
                    z0 + k,
                    Block.sapling.blockID,
                    -1,
                    x0 + i,
                    y0 + j,
                    z0 + k,
                    5);
                ReikaWorldHelper.recursiveBreakWithinSphere(
                    world,
                    x0 + i,
                    y0 + j,
                    z0 + k,
                    Block.web.blockID,
                    -1,
                    x0 + i,
                    y0 + j,
                    z0 + k,
                    5);
                ReikaWorldHelper.recursiveBreakWithinSphere(
                    world,
                    x0 + i,
                    y0 + j,
                    z0 + k,
                    Block.cactus.blockID,
                    -1,
                    x0 + i,
                    y0 + j,
                    z0 + k,
                    5);
                ReikaWorldHelper.recursiveBreakWithinSphere(
                    world,
                    x0 + i,
                    y0 + j,
                    z0 + k,
                    Block.flowerPot.blockID,
                    -1,
                    x0 + i,
                    y0 + j,
                    z0 + k,
                    5);
              }
              if (power >= 2) {
                ReikaWorldHelper.recursiveBreakWithinSphere(
                    world,
                    x0 + i,
                    y0 + j,
                    z0 + k,
                    Block.glass.blockID,
                    -1,
                    x0 + i,
                    y0 + j,
                    z0 + k,
                    5);
                ReikaWorldHelper.recursiveBreakWithinSphere(
                    world,
                    x0 + i,
                    y0 + j,
                    z0 + k,
                    Block.thinGlass.blockID,
                    -1,
                    x0 + i,
                    y0 + j,
                    z0 + k,
                    5);
                ReikaWorldHelper.recursiveBreakWithinSphere(
                    world,
                    x0 + i,
                    y0 + j,
                    z0 + k,
                    Block.glowStone.blockID,
                    -1,
                    x0 + i,
                    y0 + j,
                    z0 + k,
                    5);
                ReikaWorldHelper.recursiveBreakWithinSphere(
                    world,
                    x0 + i,
                    y0 + j,
                    z0 + k,
                    Block.mushroomCapRed.blockID,
                    -1,
                    x0 + i,
                    y0 + j,
                    z0 + k,
                    5);
                ReikaWorldHelper.recursiveBreakWithinSphere(
                    world,
                    x0 + i,
                    y0 + j,
                    z0 + k,
                    Block.mushroomCapBrown.blockID,
                    -1,
                    x0 + i,
                    y0 + j,
                    z0 + k,
                    5);
                ReikaWorldHelper.recursiveBreakWithinSphere(
                    world,
                    x0 + i,
                    y0 + j,
                    z0 + k,
                    Block.ladder.blockID,
                    -1,
                    x0 + i,
                    y0 + j,
                    z0 + k,
                    5);
                ReikaWorldHelper.recursiveBreakWithinSphere(
                    world,
                    x0 + i,
                    y0 + j,
                    z0 + k,
                    Block.signPost.blockID,
                    -1,
                    x0 + i,
                    y0 + j,
                    z0 + k,
                    5);
                ReikaWorldHelper.recursiveBreakWithinSphere(
                    world,
                    x0 + i,
                    y0 + j,
                    z0 + k,
                    Block.signWall.blockID,
                    -1,
                    x0 + i,
                    y0 + j,
                    z0 + k,
                    5);
              }
              if (power >= 3) {
                ReikaWorldHelper.recursiveBreakWithinSphere(
                    world,
                    x0 + i,
                    y0 + j,
                    z0 + k,
                    Block.wood.blockID,
                    -1,
                    x0 + i,
                    y0 + j,
                    z0 + k,
                    5);
                ReikaWorldHelper.recursiveBreakWithinSphere(
                    world,
                    x0 + i,
                    y0 + j,
                    z0 + k,
                    Block.planks.blockID,
                    -1,
                    x0 + i,
                    y0 + j,
                    z0 + k,
                    5);
                ReikaWorldHelper.recursiveBreakWithinSphere(
                    world,
                    x0 + i,
                    y0 + j,
                    z0 + k,
                    Block.fence.blockID,
                    -1,
                    x0 + i,
                    y0 + j,
                    z0 + k,
                    5);
                ReikaWorldHelper.recursiveBreakWithinSphere(
                    world,
                    x0 + i,
                    y0 + j,
                    z0 + k,
                    Block.cloth.blockID,
                    -1,
                    x0 + i,
                    y0 + j,
                    z0 + k,
                    5);
                ReikaWorldHelper.recursiveBreakWithinSphere(
                    world,
                    x0 + i,
                    y0 + j,
                    z0 + k,
                    Block.workbench.blockID,
                    -1,
                    x0 + i,
                    y0 + j,
                    z0 + k,
                    5);
                ReikaWorldHelper.recursiveBreakWithinSphere(
                    world,
                    x0 + i,
                    y0 + j,
                    z0 + k,
                    Block.doorWood.blockID,
                    -1,
                    x0 + i,
                    y0 + j,
                    z0 + k,
                    5);
                ReikaWorldHelper.recursiveBreakWithinSphere(
                    world,
                    x0 + i,
                    y0 + j,
                    z0 + k,
                    Block.netherrack.blockID,
                    -1,
                    x0 + i,
                    y0 + j,
                    z0 + k,
                    5);
              }
              if (power >= 4) {
                ReikaWorldHelper.recursiveBreakWithinSphere(
                    world,
                    x0 + i,
                    y0 + j,
                    z0 + k,
                    Block.sand.blockID,
                    -1,
                    x0 + i,
                    y0 + j,
                    z0 + k,
                    5);
                ReikaWorldHelper.recursiveBreakWithinSphere(
                    world,
                    x0 + i,
                    y0 + j,
                    z0 + k,
                    Block.gravel.blockID,
                    -1,
                    x0 + i,
                    y0 + j,
                    z0 + k,
                    5);
                ReikaWorldHelper.recursiveBreakWithinSphere(
                    world,
                    x0 + i,
                    y0 + j,
                    z0 + k,
                    Block.blockClay.blockID,
                    -1,
                    x0 + i,
                    y0 + j,
                    z0 + k,
                    5);
                ReikaWorldHelper.recursiveBreakWithinSphere(
                    world,
                    x0 + i,
                    y0 + j,
                    z0 + k,
                    Block.slowSand.blockID,
                    -1,
                    x0 + i,
                    y0 + j,
                    z0 + k,
                    5);
              }
              if (power >= 3) {
                // ReikaWorldHelper.recursiveBreakWithinSphere(world, x0+i, y0+j, z0+k,
                // Block.grass.blockID, -1, x0+i, y0+j, z0+k, 5);
                // ReikaWorldHelper.recursiveFillWithinSphere(world, x0+i, y0+j-7, z0+k,
                // Block.grass.blockID, -1, Block.dirt.blockID, 0, x0+i, y0+j-7, z0+k, 5);
                if (id == Block.grass.blockID) {
                  if (power >= 5) {
                    Block.blocksList[id].dropBlockAsItem(world, x0 + i, y0 + j, z0 + k, 0, 0);
                    ReikaWorldHelper.legacySetBlockWithNotify(world, x0 + i, y0 + j, z0 + k, 0);
                  } else
                    ReikaWorldHelper.legacySetBlockWithNotify(
                        world, x0 + i, y0 + j, z0 + k, Block.dirt.blockID);
                }
                world.markBlockForUpdate(x0 + i, y0 + j, z0 + k);
                if (id == Block.dirt.blockID) {
                  int meta = world.getBlockMetadata(x0 + i, y0 + j, z0 + k);
                  if (meta >= 3 || (meta > 3 - (power - 6) && power > 6)) {
                    Block.blocksList[id].dropBlockAsItem(world, x0 + i, y0 + j, z0 + k, 0, 0);
                    ReikaWorldHelper.legacySetBlockWithNotify(world, x0 + i, y0 + j, z0 + k, 0);
                  } else
                    ReikaWorldHelper.legacySetBlockMetadataWithNotify(
                        world, x0 + i, y0 + j, z0 + k, meta + 1);
                }
              }
              if (power >= 5) {
                if (id == Block.stone.blockID) {
                  int meta = world.getBlockMetadata(x0 + i, y0 + j, z0 + k);
                  if (meta >= 2 || (meta > 2 - (power - 8) && power > 8)) {
                    if (power <= 12)
                      ReikaWorldHelper.legacySetBlockWithNotify(
                          world, x0 + i, y0 + j, z0 + k, Block.cobblestone.blockID);
                    else {
                      Block.blocksList[id].dropBlockAsItem(world, x0 + i, y0 + j, z0 + k, 0, 0);
                      ReikaWorldHelper.legacySetBlockWithNotify(world, x0 + i, y0 + j, z0 + k, 0);
                    }
                  } else
                    ReikaWorldHelper.legacySetBlockMetadataWithNotify(
                        world, x0 + i, y0 + j, z0 + k, meta + 1);
                }
                if (id == Block.cobblestone.blockID
                    || id == Block.cobblestoneWall.blockID
                    || id == Block.cobblestoneMossy.blockID) {
                  int meta = world.getBlockMetadata(x0 + i, y0 + j, z0 + k);
                  if (meta >= 3 || (meta > 3 - (power - 8) && power > 8)) {
                    Block.blocksList[id].dropBlockAsItem(world, x0 + i, y0 + j, z0 + k, 0, 0);
                    ReikaWorldHelper.legacySetBlockWithNotify(world, x0 + i, y0 + j, z0 + k, 0);
                  } else
                    ReikaWorldHelper.legacySetBlockMetadataWithNotify(
                        world, x0 + i, y0 + j, z0 + k, meta + 1);
                }
              }
              if (power == 14) {
                for (int n = 1; n < Block.blocksList.length; n++) {
                  if (Block.blocksList[n] != null
                      && n != MachineRegistry.RAILGUN.getBlockID()
                      && ReikaMathLibrary.isValueOutsideBounds(7, 11, n)) {
                    ReikaWorldHelper.recursiveBreakWithinSphere(
                        world, x0 + i, y0 + j, z0 + k, n, -1, x0 + i, y0 + j, z0 + k, 3);
                  }
                }
              }
              if (power == 15) {
                for (int n = 1; n < Block.blocksList.length; n++) {
                  if (Block.blocksList[n] != null
                      && n != MachineRegistry.RAILGUN.getBlockID()
                      && ReikaMathLibrary.isValueOutsideBounds(7, 11, n)) {
                    ReikaWorldHelper.recursiveBreakWithinSphere(
                        world, x0 + i, y0 + j, z0 + k, n, -1, x0 + i, y0 + j, z0 + k, 6);
                  }
                }
              }
            }

            AxisAlignedBB splash = AxisAlignedBB.getBoundingBox(x, y, z, x, y, z).expand(3, 3, 3);
            // world.createExplosion(this, x, y, z, 3F, false);
            List dmgd = world.getEntitiesWithinAABB(Entity.class, splash);
            for (int l = 0; l < dmgd.size(); l++) {
              ent = (Entity) dmgd.get(l);
              if (ent instanceof EntityLiving) {
                el = (EntityLiving) ent;
                this.applyAttackEffectsToEntity(world, el);
              } else if (ent instanceof EntityEnderCrystal
                  || ent instanceof EntityPainting
                  || ent instanceof EntityItemFrame) // Will not target but will destroy
              ent.attackEntityFrom(DamageSource.generic, this.getAttackDamage());
            }
          }
          for (int m = 0; m < 2; m++) {
            world.spawnParticle(
                "lava",
                x - 1 + 2 * rand.nextFloat() + i,
                y - 1.5 + rand.nextFloat() + j,
                z - 1 + 2 * rand.nextFloat() + k,
                0,
                0,
                0);
          }
        }
      }
    }
    this.setDead();
    // ent.attackEntityFrom(DamageSource.outOfWorld, el.getHealth()*(1+el.getTotalArmorValue()));
  }
Example #20
0
 @Override
 public void onUpdate() {
   ticksExisted++;
   boolean hit = false;
   int id = worldObj.getBlockId((int) posX, (int) posY, (int) posZ);
   MachineRegistry m = MachineRegistry.getMachine(worldObj, posX, posY, posZ);
   List mobs =
       worldObj.getEntitiesWithinAABB(EntityLiving.class, this.getBoundingBox().expand(1, 1, 1));
   // ReikaJavaLibrary.pConsole("ID: "+id+" and "+mobs.size()+" mobs");
   hit =
       (mobs.size() > 0
           || (m != MachineRegistry.RAILGUN && id != 0 && !ReikaWorldHelper.softBlocks(id)));
   // ReikaJavaLibrary.pConsole(hit+"   by "+id+"  or mobs "+mobs.size());
   if (ReikaWorldHelper.softBlocks(id)
       && !ReikaMathLibrary.isValueInsideBoundsIncl(8, 11, id)
       && ConfigRegistry.BLOCKDAMAGE.getState())
     ReikaWorldHelper.recursiveBreakWithinSphere(
         worldObj, (int) posX, (int) posY, (int) posZ, id, -1, (int) posX, (int) posY, (int) posZ,
         4);
   if (hit) {
     // ReikaChatHelper.write("HIT  @  "+ticksExisted+"  by "+(mobs.size() > 0));
     this.onImpact(null);
     if (power < 15) this.setDead();
     return;
   }
   // ReikaChatHelper.write(this.ticksExisted);
   for (float i = -0.2F; i <= 0.2; i += 0.2F)
     worldObj.createExplosion(this, posX + i, posY + i, posZ + i, 0F, false);
   // worldObj.spawnParticle("hugeexplosion", posX, posY, posZ, 0, 0, 0);
   if (!worldObj.isRemote
       && (shootingEntity != null && shootingEntity.isDead
           || !worldObj.blockExists((int) posX, (int) posY, (int) posZ))) this.setDead();
   else {
     if (ticksExisted > 80 && !worldObj.isRemote) this.onImpact(null);
     this.onEntityUpdate();
     Vec3 var15 = worldObj.getWorldVec3Pool().getVecFromPool(posX, posY, posZ);
     Vec3 var2 =
         worldObj
             .getWorldVec3Pool()
             .getVecFromPool(posX + motionX, posY + motionY, posZ + motionZ);
     MovingObjectPosition var3 = worldObj.rayTraceBlocks(var15, var2);
     var15 = worldObj.getWorldVec3Pool().getVecFromPool(posX, posY, posZ);
     var2 =
         worldObj
             .getWorldVec3Pool()
             .getVecFromPool(posX + motionX, posY + motionY, posZ + motionZ);
     if (var3 != null)
       var2 =
           worldObj
               .getWorldVec3Pool()
               .getVecFromPool(var3.hitVec.xCoord, var3.hitVec.yCoord, var3.hitVec.zCoord);
     Entity var4 = null;
     List var5 =
         worldObj.getEntitiesWithinAABBExcludingEntity(
             this, boundingBox.addCoord(motionX, motionY, motionZ).expand(1.0D, 1.0D, 1.0D));
     double var6 = 0.0D;
     for (int var8 = 0; var8 < var5.size(); ++var8) {
       Entity var9 = (Entity) var5.get(var8);
       if (var9.canBeCollidedWith() && (!var9.isEntityEqual(shootingEntity))) {
         float var10 = 0.3F;
         AxisAlignedBB var11 = var9.boundingBox.expand(var10, var10, var10);
         MovingObjectPosition var12 = var11.calculateIntercept(var15, var2);
         if (var12 != null) {
           double var13 = var15.distanceTo(var12.hitVec);
           if (var13 < var6 || var6 == 0.0D) {
             var4 = var9;
             var6 = var13;
           }
         }
       }
     }
     if (var4 != null) var3 = new MovingObjectPosition(var4);
     if (var3 != null) this.onImpact(var3);
     posX += motionX;
     posY += motionY;
     posZ += motionZ;
     if (this.isInWater()) {
       worldObj.createExplosion(this, posX, posY, posZ, 3F, false);
       for (int var19 = 0; var19 < 4; ++var19) {
         float var18 = 0.25F;
         worldObj.spawnParticle(
             "bubble",
             posX - motionX * var18,
             posY - motionY * var18,
             posZ - motionZ * var18,
             motionX,
             motionY,
             motionZ);
       }
     }
     this.setPosition(posX, posY, posZ);
   }
 }