Пример #1
0
 @Override
 protected int doTick(TileEntity te, FluidStack fs) {
   if (rand.nextInt(3) == 0) {
     AxisAlignedBB box = ReikaAABBHelper.getBlockAABB(te.xCoord, te.yCoord, te.zCoord);
     List<EntityItem> li = te.worldObj.getEntitiesWithinAABB(EntityItem.class, box);
     for (EntityItem ei : li) {
       PoolRecipe pr = PoolRecipes.instance.getPoolRecipe(ei, li, false);
       if (pr != null) {
         if (ei.worldObj.isRemote) {
           for (int i = 0; i < ACCEL_FACTOR; i++) {
             ChromaFX.poolRecipeParticles(ei);
           }
         } else if (ei.ticksExisted > 20
             && rand.nextInt(20 / ACCEL_FACTOR) == 0
             && (ei.ticksExisted >= 600
                 || rand.nextInt((600 - ei.ticksExisted) / ACCEL_FACTOR) == 0)) {
           PoolRecipes.instance.makePoolRecipe(ei, pr);
           return 1000;
         }
         break;
       }
       ei.lifespan = Integer.MAX_VALUE;
     }
   }
   return 0;
 }
 private void sickenMobs(World world, int x, int y, int z) {
   int r = this.getRange();
   AxisAlignedBB box = ReikaAABBHelper.getBlockAABB(x, y, z).expand(r, r, r);
   List<EntityLivingBase> li = world.getEntitiesWithinAABB(EntityLivingBase.class, box);
   for (EntityLivingBase e : li) {
     if (!RadiationEffects.instance.hasHazmatSuit(e)) {
       double dd = ReikaMathLibrary.py3d(e.posX - x - 0.5, e.posY - y - 0.5, e.posZ - z - 0.5);
       if (ReikaWorldHelper.canBlockSee(world, x, y, z, e.posX, e.posY, e.posZ, dd)) {
         RadiationEffects.instance.applyEffects(e, RadiationIntensity.LOWLEVEL);
       }
     }
   }
 }
Пример #3
0
 @Override
 public AxisAlignedBB getRenderBoundingBox() {
   /*
   AxisAlignedBB box = ReikaAABBHelper.getBlockAABB(xCoord, yCoord, zCoord);
   ForgeDirection dir = this.getBeltDirection();
   int a = this.getDistanceToTarget();
   box.maxX += a*dir.offsetX;
   box.maxX -= a*dir.offsetX;
   box.maxY += a*dir.offsetY;
   box.maxY -= a*dir.offsetY;
   box.maxZ += a*dir.offsetZ;
   box.maxZ -= a*dir.offsetZ;*/
   // return AxisAlignedBB.getAABBPool().getAABB(box.minX, box.minY, box.minZ, box.maxX, box.maxY,
   // box.maxZ);
   // return INFINITE_EXTENT_AABB;
   int a = this.getDistanceToTarget();
   return ReikaAABBHelper.getBlockAABB(xCoord, yCoord, zCoord).expand(a, a, a);
 }
 private boolean getEntities(World world, int x, int y, int z) {
   int[][] pos =
       new int[][] {
         {-5, 5, -9},
         {-5, 5, 9},
         {5, 5, -9},
         {5, 5, 9},
         {-9, 5, -5},
         {-9, 5, 5},
         {9, 5, -5},
         {9, 5, 5}
       };
   for (int i = 0; i < pos.length; i++) {
     int[] loc = pos[i];
     AxisAlignedBB box = ReikaAABBHelper.getBlockAABB(x + loc[0], y + loc[1], z + loc[2]);
     if (world.getEntitiesWithinAABB(EntityEnderCrystal.class, box).size() != 1) return false;
   }
   return true;
 }
Пример #5
0
 @Override
 protected int doTick(TileEntity te, FluidStack fs) {
   int dye = fs.tag != null ? fs.tag.getInteger("berries") : 0;
   CrystalElement e = dye > 0 ? CrystalElement.elements[fs.tag.getInteger("element")] : null;
   AxisAlignedBB box = ReikaAABBHelper.getBlockAABB(te.xCoord, te.yCoord, te.zCoord);
   List<EntityItem> li = te.worldObj.getEntitiesWithinAABB(EntityItem.class, box);
   boolean flag = false;
   for (EntityItem ei : li) {
     ItemStack is = ei.getEntityItem();
     if (!te.worldObj.isRemote
         && rand.nextInt(5) == 0
         && dye < TileEntityChroma.BERRY_SATURATION
         && ChromaItems.BERRY.matchWith(is)
         && (e == null || is.getItemDamage() == e.ordinal())) {
       e = CrystalElement.elements[is.getItemDamage()];
       if (fs.tag == null) fs.tag = new NBTTagCompound();
       fs.tag.setInteger("element", e.ordinal());
       while (dye < TileEntityChroma.BERRY_SATURATION && is.stackSize > 0) {
         dye = fs.tag.getInteger("berries") + 1;
         fs.tag.setInteger("berries", dye);
         is.stackSize--;
       }
       if (is.stackSize <= 0) ei.setDead();
       flag = true;
     } else if (e != null
         && is.getItemDamage() == e.ordinal()
         && ChromaItems.SHARD.matchWith(is)
         && dye == TileEntityChroma.BERRY_SATURATION) {
       boolean done = false;
       for (int i = 0; i < ACCEL_FACTOR && !done; i++) {
         done = ItemCrystalShard.tickShardCharging(ei, e, te.xCoord, te.yCoord, te.zCoord);
       }
       if (!te.worldObj.isRemote && done) {
         fs.tag = null;
         return 200;
       }
     }
   }
   if (flag && e != null) fs.tag.setInteger("renderColor", BlockActiveChroma.getColor(e, dye));
   return 0;
 }
 @Override
 public AxisAlignedBB getRenderBoundingBox() {
   return ReikaAABBHelper.getBlockAABB(xCoord, yCoord, zCoord).expand(8, 8, 8);
 }
  @Override
  public void updateEntity(World world, int x, int y, int z, int meta) {
    super.updateEntity(world, x, y, z, meta);

    if (DragonAPICore.debugtest) {
      if (!hasMultiblock) {
        CrystalElement e = CrystalElement.randomElement();
        FilledBlockArray b = ChromaStructures.getPylonStructure(world, x, y - 9, z, e);
        b.place();
        // world.setBlock(x, y+9, z, this.getTile().getBlock(), this.getTile().getBlockMetadata(),
        // 3);
        // TileEntityCrystalPylon te = (TileEntityCrystalPylon)world.getTileEntity(x, y+9, z);
        color = e;
        hasMultiblock = true;
        this.syncAllData(true);
      }
    }

    if (hasMultiblock) {
      // ReikaJavaLibrary.pConsole(energy, Side.SERVER, color == CrystalElement.BLUE);

      int max = this.getCapacity();
      if (world.getTotalWorldTime() != lastWorldTick) {
        this.charge(world, x, y, z, max);
        lastWorldTick = world.getTotalWorldTime();
      }
      energy = Math.min(energy, max);

      if (world.isRemote) {
        this.spawnParticle(world, x, y, z);
      }

      if (!world.isRemote && rand.nextInt(80) == 0) {
        int r = 8 + rand.nextInt(8);
        AxisAlignedBB box = ReikaAABBHelper.getBlockAABB(x, y, z).expand(r, r, r);
        List<EntityLivingBase> li = world.getEntitiesWithinAABB(EntityLivingBase.class, box);
        for (EntityLivingBase e : li) {
          boolean attack = !e.isDead && e.getHealth() > 0;
          if (e instanceof EntityPlayer) {
            EntityPlayer ep = (EntityPlayer) e;
            attack =
                attack && !ep.capabilities.isCreativeMode && !Chromabilities.PYLON.enabledOn(ep);
          } else if (e instanceof EntityBallLightning) {
            attack = ((EntityBallLightning) e).getElement() != color;
          }
          if (attack) {
            this.attackEntity(e);
            this.sendClientAttack(this, e);
          }
        }
      }

      float f = this.isEnhanced() ? 1.125F : 1;

      if (TileEntityCrystalPylon.TUNED_PYLONS)
        f *= CrystalMusicManager.instance.getDingPitchScale(color);

      if (this.getTicksExisted() % (int) (72 / f) == 0) {
        ChromaSounds.POWER.playSoundAtBlock(this, 1, f);
      }

      int n = this.isEnhanced() ? 24 : 36;
      if (world.isRemote && rand.nextInt(n) == 0) {
        this.spawnLightning(world, x, y, z);
      }

      if (!world.isRemote
          && ChromaOptions.BALLLIGHTNING.getState()
          && energy >= this.getCapacity() / 2
          && rand.nextInt(24000) == 0
          && this.isChunkLoaded()) {
        world.spawnEntityInWorld(
            new EntityBallLightning(world, color, x + 0.5, y + 0.5, z + 0.5)
                .setPylon()
                .setNoDrops());
      }
    }
  }
 @Override
 public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) {
   return ReikaAABBHelper.getSizedBlockAABB(x, y, z, this.getSize(world, x, y, z));
 }