コード例 #1
0
  @Override
  public void forceChunkLoading(int chunkX, int chunkZ) {
    if (ticket == null) return;

    // System.out.println("loading chunks for miner");

    Set<ChunkCoordIntPair> chunks = getChunksAround(chunkX, chunkZ, 3);

    for (ChunkCoordIntPair chunk : chunks) {
      ForgeChunkManager.forceChunk(this.ticket, chunk);
    }

    ChunkCoordIntPair myChunk = new ChunkCoordIntPair(chunkX, chunkZ);
    ForgeChunkManager.forceChunk(this.ticket, myChunk);
    ForgeChunkManager.reorderChunk(this.ticket, myChunk);
  }
コード例 #2
0
 public void forceChunkRangeOnTicket(Ticket ticket) {
   NBTTagCompound nbt = ticket.getModData();
   int minX = nbt.getInteger("rangeMinX");
   int minZ = nbt.getInteger("rangeMinZ");
   int maxX = nbt.getInteger("rangeMaxX");
   int maxZ = nbt.getInteger("rangeMaxZ");
   int chunkX = xCoord >> 4;
   int chunkZ = zCoord >> 4;
   for (int i = minX; i <= maxX; i++)
     for (int j = minZ; j <= maxZ; j++) {
       int x = chunkX + i, z = chunkZ + j;
       // System.out.printf("BaseChunkLoadingTE.forceChunkRangeOnTicket: forcing chunk (%d; %d,
       // %d)\n",
       // worldObj.provider.dimensionId, x, z);
       ForgeChunkManager.forceChunk(ticket, new ChunkCoordIntPair(x, z));
     }
 }
コード例 #3
0
  /**
   * Checks to see if the situation for firing the laser exists... and changes the state accordingly
   */
  public void checkCanRun() {
    // Laser requires lense, redstone power, not be jammed, and be in orbit and energy to function
    if (!worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)
        || glassPanel == null
        || storage.getEnergyStored()
            == 0 /*|| !(this.worldObj.provider instanceof IOrbitDimension)*/) {
      if (laserSat.isAlive()) {
        laserSat.deactivateLaser();
      }

      isRunning = false;
    } else if (!laserSat.isAlive()
        && !finished
        && !laserSat.getJammed()
        && worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)
        && canMachineSeeEarth()) {

      // Laser will be on at this point
      int orbitDimId =
          0; // =
             // WorldUtil.getProviderForName(((IOrbitDimension)this.worldObj.provider).getPlanetToOrbit()).dimensionId;
      WorldServer orbitWorld = DimensionManager.getWorld(orbitDimId);

      if (ticket == null) {
        ticket =
            ForgeChunkManager.requestTicket(AdvancedRocketry.instance, this.worldObj, Type.NORMAL);
        if (ticket != null)
          ForgeChunkManager.forceChunk(
              ticket,
              new ChunkCoordIntPair(
                  this.xCoord / 16 - (this.xCoord < 0 ? 1 : 0),
                  this.zCoord / 16 - (this.zCoord < 0 ? 1 : 0)));
      }

      isRunning = laserSat.activateLaser(orbitWorld, laserX, laserZ);
    }

    if (!this.worldObj.isRemote)
      PacketHandler.sendToNearby(
          new PacketMachine(this, (byte) 2),
          this.xCoord,
          this.yCoord,
          this.zCoord,
          128,
          this.worldObj.provider.dimensionId);
  }
コード例 #4
0
  void initTicket() {
    if (Platform.isClient()) {
      return;
    }

    this.ct = ForgeChunkManager.requestTicket(AppEng.instance(), this.worldObj, Type.NORMAL);

    if (this.ct == null) {
      MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
      if (server != null) {
        List<EntityPlayerMP> pl = server.getConfigurationManager().playerEntityList;
        for (EntityPlayerMP p : pl) {
          p.addChatMessage(new ChatComponentText("Can't chunk load.."));
        }
      }
      return;
    }

    AELog.info("New Ticket " + this.ct.toString());
    ForgeChunkManager.forceChunk(
        this.ct, new ChunkCoordIntPair(this.xCoord >> 4, this.zCoord >> 4));
  }