Exemplo n.º 1
0
  public void addAspect(AspectType type, Aspect aspect, int value) {
    if (isSaturated) return;

    double increasedSaturation = getSaturation(type, aspect);
    addSaturation(aspect, increasedSaturation);
    owningNode.getAspectsBase().add(aspect, value);

    ResearchHelper.distributeResearch(
        Gadomancy.MODID.toUpperCase() + ".GROWING_GROWTH",
        owningNode.getWorldObj(),
        owningNode.xCoord,
        owningNode.yCoord,
        owningNode.zCoord,
        6);

    computeOverallSaturation();
  }
Exemplo n.º 2
0
  public boolean updateBehavior(boolean needUpdate) {
    if (fixedNode != null && owningNode.ticksExisted % 3 == 0) {
      if (owningNode.getWorldObj().getBlock(fixedNode.xCoord, fixedNode.yCoord, fixedNode.zCoord)
              != RegisteredBlocks.blockNode
          || owningNode
                  .getWorldObj()
                  .getTileEntity(fixedNode.xCoord, fixedNode.yCoord, fixedNode.zCoord)
              == null
          || fixedNode.isInvalid()) {
        fixedNode = null;
        return needUpdate;
      }
      AspectList currentAspects = fixedNode.getAspects();
      AspectList baseAspects = fixedNode.getAspectsBase();
      if (baseAspects.getAspects().length == 0) {
        int x = fixedNode.xCoord;
        int y = fixedNode.yCoord;
        int z = fixedNode.zCoord;
        removeFixedNode(x, y, z);
        return needUpdate;
      }
      Aspect a =
          baseAspects
              .getAspects()[owningNode.getWorldObj().rand.nextInt(baseAspects.getAspects().length)];
      if (baseAspects.getAmount(a) > 0) {
        if (baseAspects.reduce(a, 1)) {
          World world = owningNode.getWorldObj();
          int fx = fixedNode.xCoord;
          int fy = fixedNode.yCoord;
          int fz = fixedNode.zCoord;
          int ox = owningNode.xCoord;
          int oy = owningNode.yCoord;
          int oz = owningNode.zCoord;
          currentAspects.reduce(a, 1);

          ResearchHelper.distributeResearch(
              Gadomancy.MODID.toUpperCase() + ".GROWING_ATTACK",
              owningNode.getWorldObj(),
              owningNode.xCoord,
              owningNode.yCoord,
              owningNode.zCoord,
              16);

          EntityAspectOrb aspectOrb =
              new EntityAspectOrb(world, fx + 0.5D, fy + 0.5D, fz + 0.5D, a, 1);
          Vec3 dir =
              Vec3.createVectorHelper(fx + 0.5D, fy + 0.5D, fz + 0.5D)
                  .subtract(Vec3.createVectorHelper(ox + 0.5D, oy + 0.5D, oz + 0.5D))
                  .normalize();
          dir.addVector(randOffset(), randOffset(), randOffset()).normalize();
          aspectOrb.setVelocity(dir.xCoord, dir.yCoord, dir.zCoord);
          fixedNode.getWorldObj().spawnEntityInWorld(aspectOrb);

          NetworkRegistry.TargetPoint point =
              new NetworkRegistry.TargetPoint(
                  world.provider.dimensionId, ox + 0.5F, oy + 0.5F, oz + 0.5F, 32);
          PacketTCNodeBolt bolt =
              new PacketTCNodeBolt(
                  ox + 0.5F, oy + 0.5F, oz + 0.5F, fx + 0.5F, fy + 0.5F, fz + 0.5F, 0, false);
          PacketHandler.INSTANCE.sendToAllAround(bolt, point);

          PacketAnimationAbsorb packet = new PacketAnimationAbsorb(ox, oy, oz, fx, fy, fz, 7);
          PacketHandler.INSTANCE.sendToAllAround(packet, point);

          world.markBlockForUpdate(fx, fy, fz);
          fixedNode.markDirty();
          needUpdate = true;
        } else {
          if (baseAspects.size() <= 1) {
            int x = fixedNode.xCoord;
            int y = fixedNode.yCoord;
            int z = fixedNode.zCoord;
            removeFixedNode(x, y, z);
            needUpdate = true;
          }
          baseAspects.remove(a);
          currentAspects.remove(a);
          return needUpdate;
        }
      } else {
        if (baseAspects.size() <= 1) {
          int x = fixedNode.xCoord;
          int y = fixedNode.yCoord;
          int z = fixedNode.zCoord;
          removeFixedNode(x, y, z);
          needUpdate = true;
        }
        baseAspects.remove(a);
        currentAspects.remove(a);
        return needUpdate;
      }
    }
    return needUpdate;
  }