Esempio n. 1
0
  public ChunkCache(World worldIn, BlockPos p_i45746_2_, BlockPos p_i45746_3_, int p_i45746_4_) {
    this.worldObj = worldIn;
    this.chunkX = p_i45746_2_.getX() - p_i45746_4_ >> 4;
    this.chunkZ = p_i45746_2_.getZ() - p_i45746_4_ >> 4;
    int var5 = p_i45746_3_.getX() + p_i45746_4_ >> 4;
    int var6 = p_i45746_3_.getZ() + p_i45746_4_ >> 4;
    this.chunkArray = new Chunk[var5 - this.chunkX + 1][var6 - this.chunkZ + 1];
    this.hasExtendedLevels = true;
    int var7;
    int var8;

    for (var7 = this.chunkX; var7 <= var5; ++var7) {
      for (var8 = this.chunkZ; var8 <= var6; ++var8) {
        this.chunkArray[var7 - this.chunkX][var8 - this.chunkZ] =
            worldIn.getChunkFromChunkCoords(var7, var8);
      }
    }

    for (var7 = p_i45746_2_.getX() >> 4; var7 <= p_i45746_3_.getX() >> 4; ++var7) {
      for (var8 = p_i45746_2_.getZ() >> 4; var8 <= p_i45746_3_.getZ() >> 4; ++var8) {
        Chunk var9 = this.chunkArray[var7 - this.chunkX][var8 - this.chunkZ];

        if (var9 != null && !var9.getAreLevelsEmpty(p_i45746_2_.getY(), p_i45746_3_.getY())) {
          this.hasExtendedLevels = false;
        }
      }
    }
  }
 public Chunk provideChunk(int par1, int par2) {
   this.rand.setSeed(par1 * 341873128712L + par2 * 132897987541L);
   byte[] var3 = new byte[32768];
   generateTerrain(par1, par2, var3);
   this.biomesForGeneration =
       this.worldObj
           .getWorldChunkManager()
           .loadBlockGeneratorData(this.biomesForGeneration, par1 * 16, par2 * 16, 16, 16);
   replaceBlocksForBiome(par1, par2, var3, this.biomesForGeneration);
   this.caveGenerator.generate(this, this.worldObj, par1, par2, var3);
   this.ravineGenerator.generate(this, this.worldObj, par1, par2, var3);
   if (this.mapFeaturesEnabled) {
     this.mineshaftGenerator.generate(this, this.worldObj, par1, par2, var3);
     this.villageGenerator.generate(this, this.worldObj, par1, par2, var3);
     this.strongholdGenerator.generate(this, this.worldObj, par1, par2, var3);
     this.scatteredFeatureGenerator.generate(this, this.worldObj, par1, par2, var3);
   }
   Chunk var4 = new Chunk(this.worldObj, var3, par1, par2);
   byte[] var5 = var4.getBiomeArray();
   for (int var6 = 0; var6 < var5.length; var6++) {
     var5[var6] = ((byte) this.biomesForGeneration[var6].biomeID);
   }
   var4.generateSkylightMap();
   return var4;
 }
Esempio n. 3
0
 @Inject(method = "trySpawnGolem", at = @At("HEAD"), cancellable = true)
 private void checkChunkBeforeTrySpawnGolem(World world, BlockPos pos, CallbackInfo callbackInfo) {
   final Chunk chunk = world.getChunkFromBlockCoords(pos);
   if (chunk == null || chunk.isEmpty() || !chunk.isTerrainPopulated()) {
     callbackInfo.cancel();
   }
 }
 // Simplified for speed by:
 //		- assuming we won't use it to add a TileEntity to the same place repeatedly -> no iterating
 // over all TEs
 //		- not checking World.field_147481_N (we know we're called from a TE's update())
 public static void unsafeAddSpectre(World w, int x, int y, int z, TileEntity te) {
   w.addedTileEntityList.add(te);
   Chunk chunk = w.getChunkFromChunkCoords(x >> 4, z >> 4);
   if (chunk != null) {
     chunk.func_150812_a(x & 15, y, z & 15, te);
   }
 }
  @Override
  public Chunk provideChunk(int par1, int par2) {
    this.rand.setSeed(par1 * 341873128712L + par2 * 132897987541L);
    final Block[] ids = new Block[32768 * 2];
    final byte[] meta = new byte[32768 * 2];
    this.generateTerrain(par1, par2, ids, meta);
    this.createCraters(par1, par2, ids, meta);
    this.biomesForGeneration =
        this.worldObj
            .getWorldChunkManager()
            .loadBlockGeneratorData(this.biomesForGeneration, par1 * 16, par2 * 16, 16, 16);
    this.replaceBlocksForBiome(par1, par2, ids, meta, this.biomesForGeneration);

    if (this.worldGenerators == null) {
      this.worldGenerators = this.getWorldGenerators();
    }

    for (MapGenBaseMeta generator : this.worldGenerators) {
      generator.generate(this, this.worldObj, par1, par2, ids, meta);
    }

    this.onChunkProvide(par1, par2, ids, meta);

    final Chunk var4 = new Chunk(this.worldObj, ids, meta, par1, par2);
    final byte[] var5 = var4.getBiomeArray();

    for (int var6 = 0; var6 < var5.length; ++var6) {
      var5[var6] = (byte) this.biomesForGeneration[var6].biomeID;
    }

    var4.generateSkylightMap();
    return var4;
  }
Esempio n. 6
0
  @Override
  public void processCommand(ICommandSender sender, String[] params) {
    MinecraftServer server = MinecraftServer.getServer();
    EntityPlayerMP player = getCommandSenderAsPlayer(sender);
    WorldServer world =
        server.worldServerForDimension(player.getEntityWorld().provider.dimensionId);

    if (!TFCOptions.enableDebugMode) {
      TFC_Core.sendInfoMessage(player, new ChatComponentText("Debug Mode Required"));
      return;
    }

    if (params.length == 0) {
      TFC_Core.sendInfoMessage(player, new ChatComponentText("Stripping Chunk"));
      Chunk chunk = world.getChunkFromBlockCoords((int) player.posX, (int) player.posZ);
      for (int x = 0; x < 16; x++) {
        for (int z = 0; z < 16; z++) {
          for (int y = 0; y < 256; y++) {
            Block id = chunk.getBlock(x, y, z);
            if (id != TFCBlocks.Ore
                && id != TFCBlocks.Ore2
                && id != TFCBlocks.Ore3
                && id != Blocks.bedrock)
              world.setBlock(
                  x + (chunk.xPosition * 16), y, z + (chunk.zPosition * 16), Blocks.air, 0, 2);
          }
        }
      }

      TFC_Core.sendInfoMessage(player, new ChatComponentText("Stripping Chunk Complete"));
    } else if (params.length == 1) {
      TFC_Core.sendInfoMessage(
          player,
          new ChatComponentText(
              "Stripping Chunks Within a Radius of " + Integer.parseInt(params[0])));
      int radius = Integer.parseInt(params[0]);
      for (int i = -radius; i <= radius; i++) {
        for (int k = -radius; k <= radius; k++) {
          Chunk chunk =
              world.getChunkFromBlockCoords(
                  (int) player.posX + (i * 16), (int) player.posZ + (k * 16));
          for (int x = 0; x < 16; x++) {
            for (int z = 0; z < 16; z++) {
              for (int y = 0; y < 256; y++) {
                Block id = chunk.getBlock(x, y, z);
                if (id != TFCBlocks.Ore
                    && id != TFCBlocks.Ore2
                    && id != TFCBlocks.Ore3
                    && id != Blocks.bedrock)
                  world.setBlock(
                      x + (chunk.xPosition * 16), y, z + (chunk.zPosition * 16), Blocks.air, 0, 2);
              }
            }
          }
        }
      }

      TFC_Core.sendInfoMessage(player, new ChatComponentText("Stripping Chunk Complete"));
    }
  }
  public Chunk provideChunk(int i, int j) {
    field_913_j.setSeed((long) i * 0x4f9939f508L + (long) j * 0x1ef1565bd5L);
    byte abyte0[] = new byte[32768];
    field_4179_v =
        worldObj_16
            .getWorldChunkManager()
            .loadBlockGeneratorData(field_4179_v, i * 16, j * 16, 16, 16);
    double ad[] = BWG4WorldChunkManager.temperature;
    generateTerrain(i, j, abyte0, field_4179_v, ad);
    replaceBlocksForBiome(i, j, abyte0, field_4179_v);
    field_902_u.generate(this, worldObj_16, i, j, abyte0);

    if (mapFeaturesEnabled) {
      strongholdGenerator.generate(this, worldObj_16, i, j, abyte0);
    }

    Chunk chunk = new Chunk(worldObj_16, abyte0, i, j);
    byte abyte1[] = chunk.getBiomeArray();

    for (int k = 0; k < abyte1.length; k++) {
      abyte1[k] = (byte) field_4179_v[k].biomeID;
    }

    chunk.generateSkylightMap();
    return chunk;
  }
  @Override
  public Chunk provideChunk(int chunkX, int chunkZ) {
    rand.setSeed(chunkX * 341873128712L + chunkZ * 132897987541L);

    biomesForGeneration =
        worldObj
            .getBiomeProvider()
            .loadBlockGeneratorData(biomesForGeneration, chunkX * 16, chunkZ * 16, 16, 16);

    ChunkPrimer primer = new ChunkPrimer();

    setBlocksInChunk(primer);

    caveGenerator.generate(worldObj, chunkX, chunkZ, primer);

    if (CavelandConfig.generateRiver) {
      ravineGenerator.generate(worldObj, chunkX, chunkZ, primer);
    }

    replaceBiomeBlocks(chunkX, chunkZ, primer);

    Chunk chunk = new Chunk(worldObj, primer, chunkX, chunkZ);
    byte[] biomeArray = chunk.getBiomeArray();

    for (int i = 0; i < biomeArray.length; ++i) {
      biomeArray[i] = (byte) Biome.getIdForBiome(biomesForGeneration[i]);
    }

    chunk.resetRelightChecks();

    return chunk;
  }
  @Override
  public Chunk provideChunk(int par1, int par2) {
    this.rand.setSeed(par1 * 341873128712L + par2 * 132897987541L);
    final short[] ids = new short[32768 * 2];
    final byte[] meta = new byte[32768 * 2];
    this.generateTerrain(par1, par2, ids, meta);
    this.biomesForGeneration =
        this.worldObj
            .getWorldChunkManager()
            .loadBlockGeneratorData(this.biomesForGeneration, par1 * 16, par2 * 16, 16, 16);
    this.createCraters(par1, par2, ids, meta);
    this.replaceBlocksForBiome(par1, par2, ids, meta, this.biomesForGeneration);
    this.caveGenerator.generate(this, this.worldObj, par1, par2, ids, meta);
    this.dungeonGenerator.generateUsingArrays(
        this.worldObj, this.worldObj.getSeed(), par1 * 16, 25, par2 * 16, par1, par2, ids, meta);

    final Chunk var4 = new Chunk(this.worldObj, ids, meta, par1, par2);

    // if (!var4.isTerrainPopulated &&
    // GCCoreConfigManager.disableExternalModGen)
    // {
    // var4.isTerrainPopulated = true;
    // }

    var4.generateSkylightMap();
    return var4;
  }
Esempio n. 10
0
  public static S21PacketChunkData.Extracted func_179756_a(
      Chunk p_179756_0_, boolean p_179756_1_, boolean p_179756_2_, int p_179756_3_) {
    ExtendedBlockStorage[] aextendedblockstorage = p_179756_0_.getBlockStorageArray();
    S21PacketChunkData.Extracted s21packetchunkdata$extracted = new S21PacketChunkData.Extracted();
    List<ExtendedBlockStorage> list = Lists.<ExtendedBlockStorage>newArrayList();

    for (int i = 0; i < aextendedblockstorage.length; ++i) {
      ExtendedBlockStorage extendedblockstorage = aextendedblockstorage[i];

      if (extendedblockstorage != null
          && (!p_179756_1_ || !extendedblockstorage.isEmpty())
          && (p_179756_3_ & 1 << i) != 0) {
        s21packetchunkdata$extracted.dataSize |= 1 << i;
        list.add(extendedblockstorage);
      }
    }

    s21packetchunkdata$extracted.data =
        new byte
            [func_180737_a(
                Integer.bitCount(s21packetchunkdata$extracted.dataSize), p_179756_2_, p_179756_1_)];
    int j = 0;

    for (ExtendedBlockStorage extendedblockstorage1 : list) {
      char[] achar = extendedblockstorage1.getData();

      for (char c0 : achar) {
        s21packetchunkdata$extracted.data[j++] = (byte) (c0 & 255);
        s21packetchunkdata$extracted.data[j++] = (byte) (c0 >> 8 & 255);
      }
    }

    for (ExtendedBlockStorage extendedblockstorage2 : list) {
      j =
          func_179757_a(
              extendedblockstorage2.getBlocklightArray().getData(),
              s21packetchunkdata$extracted.data,
              j);
    }

    if (p_179756_2_) {
      for (ExtendedBlockStorage extendedblockstorage3 : list) {
        j =
            func_179757_a(
                extendedblockstorage3.getSkylightArray().getData(),
                s21packetchunkdata$extracted.data,
                j);
      }
    }

    if (p_179756_1_) {
      func_179757_a(p_179756_0_.getBiomeArray(), s21packetchunkdata$extracted.data, j);
    }

    return s21packetchunkdata$extracted;
  }
 public void setBiome(
     int biome,
     Vector3f loc) { // not quite working yet, the client needs to reload to see the change
   byte[] bytes = new byte[16 * 16];
   for (int i = 0; i < bytes.length; i++) {
     bytes[i] = (byte) biome;
   }
   Chunk chk = _world.getChunkFromBlockCoords((int) loc.getX(), (int) loc.getZ());
   chk.setBiomeArray(bytes);
   chk.setChunkModified();
 }
Esempio n. 12
0
  /**
   * Will return back a chunk, if it doesn't exist and its not a MP client it will generates all the
   * blocks for the specified chunk from the map seed and chunk seed
   */
  @Override
  public Chunk provideChunk(int par1, int par2) {
    long time = System.currentTimeMillis();
    this.rand.setSeed((long) par1 * 341873128712L + (long) par2 * 132897987541L);
    short[] abyte = new short[32768];
    this.generateTerrain(par1, par2, abyte);
    this.biomesForGeneration =
        this.worldObj
            .getWorldChunkManager()
            .loadBlockGeneratorData(this.biomesForGeneration, par1 * 16, par2 * 16, 16, 16);
    // this.biomesForGeneration = new BiomeGenBase[] {BiomeGenBase.desert};
    this.replaceBlocksForBiome(par1, par2, abyte, this.biomesForGeneration);
    // this.caveGenerator.generate((IChunkProvider)this, this.worldObj, par1, par2, abyte);
    // this.ravineGenerator.generate(this, this.worldObj, par1, par2, abyte);

    if (this.mapFeaturesEnabled) {
      // this.mineshaftGenerator.generate(this, this.worldObj, par1, par2, abyte);
      // this.villageGenerator.generate(this, this.worldObj, par1, par2, abyte);
      // this.strongholdGenerator.generate(this, this.worldObj, par1, par2, abyte);
      // this.scatteredFeatureGenerator.generate(this, this.worldObj, par1, par2, abyte);
    }

    /*short[] ashort = new short[32768];
    int yMax = 32768/256;
    for(int x = 0; x < 16; x++)
    {
    	for(int z = 0; z < 16; z++)
    	{
    		for(int y = 0; y < yMax; y++)
    		{
                int idx = y << 8 | z << 4 | x;
                int ido = x << 11 | z << 7 | y;
                ashort[idx] = abyte[ido];
    		}
    	}
    }*/

    Chunk chunk = new Chunk(this.worldObj, abyte, new byte[32768], par1, par2);
    byte[] abyte1 = chunk.getBiomeArray();

    for (int k = 0; k < abyte1.length; ++k) {
      abyte1[k] = (byte) this.biomesForGeneration[k].biomeID;
    }

    chunk.generateSkylightMap();
    // System.out.println("Providing Chunk: " + (System.currentTimeMillis() - time) + "ms");
    return chunk;
  }
Esempio n. 13
0
  @Override
  public void populate(IChunkProvider ichunkprovider, int i, int j) {

    Chunk chunk = this.provideChunk(i, j);
    if (!chunk.isTerrainPopulated) {
      chunk.isTerrainPopulated = true;

      if (ichunkprovider != null) {
        ichunkprovider.populate(ichunkprovider, i, j);
        for (Object decorator : decorators) {
          ((ILandDecorator) decorator).generate(landWorld, random, i, j, this);
        }
        chunk.setChunkModified();
      }
    }
  }
Esempio n. 14
0
 @Override
 public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5) {
   if (!world.isRemote) {
     if (entity != null) {
       Chunk chunk =
           world.getChunkFromBlockCoords(
               MathHelper.floor_double(entity.posX), MathHelper.floor_double(entity.posZ));
       int previousDamage = stack.getItemDamage();
       stack.setItemDamage(chunk.getRandomWithSeed(987234911L).nextInt(10) == 0 ? 1 : 0);
       if (previousDamage != stack.getItemDamage() && previousDamage == 0) {
         world.playSoundAtEntity(entity, "openblocks:slimalyzer.signal", 1F, 1F);
       }
     } else {
       stack.setItemDamage(0);
     }
   }
 }
Esempio n. 15
0
 public S21PacketChunkData(Chunk chunkIn, boolean p_i45196_2_, int p_i45196_3_) {
   this.chunkX = chunkIn.xPosition;
   this.chunkZ = chunkIn.zPosition;
   this.field_149279_g = p_i45196_2_;
   this.extractedData =
       func_179756_a(
           chunkIn, p_i45196_2_, !chunkIn.getWorld().provider.getHasNoSky(), p_i45196_3_);
 }
Esempio n. 16
0
  public boolean LocationIsValidSpawn(Chunk world, int i, int j, int k) {
    int blockID = world.getBlockID(i, j, k);

    if (blockID == 0) {
      return true;
    }

    return false;
  }
 @Override
 public void write(ByteBuf out) {
   out.writeInt(worldId);
   out.writeInt(chunk.xPosition);
   out.writeInt(chunk.zPosition);
   out.writeInt(pos.x);
   out.writeShort(pos.y);
   out.writeInt(pos.z);
   out.writeBytes(chunk.getBiomeArray());
 }
Esempio n. 18
0
  public IBlockState getBlockState(BlockPos pos) {
    if (pos.getY() >= 0 && pos.getY() < 256) {
      int var2 = (pos.getX() >> 4) - this.chunkX;
      int var3 = (pos.getZ() >> 4) - this.chunkZ;

      if (var2 >= 0
          && var2 < this.chunkArray.length
          && var3 >= 0
          && var3 < this.chunkArray[var2].length) {
        Chunk var4 = this.chunkArray[var2][var3];

        if (var4 != null) {
          return var4.getBlockState(pos);
        }
      }
    }

    return Blocks.air.getDefaultState();
  }
 @Override
 public void executeClient(EntityPlayer thePlayer) {
   if (thePlayer.worldObj.provider.dimensionId == worldId) {
     chunk = thePlayer.worldObj.getChunkFromChunkCoords(xPos, zPos);
     if (chunk.isChunkLoaded) {
       chunk.setBiomeArray(array);
       AdvancedRocketry.proxy.spawnParticle(
           "smallLazer", thePlayer.worldObj, pos.x, pos.y, pos.z, 0, 0, 0);
     }
   }
 }
  @Override
  public Chunk provideChunk(int i, int j) {
    this.rand.setSeed(i * 341873128712L + j * 132897987541L);
    byte[] var3 = new byte[32768];
    this.biomesForGeneration =
        this.worldObj
            .getWorldChunkManager()
            .loadBlockGeneratorData(this.biomesForGeneration, i * 16, j * 16, 16, 16);
    this.generateTerrain(i, j, var3, this.biomesForGeneration, this.generatedTemperatures);
    this.replaceBlocksForBiome(i, j, var3, this.biomesForGeneration);
    this.caveGenerator.generate(this, this.worldObj, i, j, var3);
    Chunk var4 = new Chunk(this.worldObj, var3, i, j);
    byte[] var5 = var4.getBiomeArray();

    for (int var6 = 0; var6 < var5.length; ++var6) {
      var5[var6] = (byte) this.biomesForGeneration[var6].biomeID;
    }

    var4.generateSkylightMap();
    return var4;
  }
Esempio n. 21
0
  private int getTopBlock(World world, int x, int z) {
    Chunk chunk = world.getChunkFromBlockCoords(x, z);
    int y = chunk.getTopFilledSegment() + 15;

    int trimmedX = x & 15;
    int trimmedZ = z & 15;

    for (; y > 0; --y) {
      Block block = chunk.getBlock(trimmedX, y, trimmedZ);

      if (block.isAir(world, x, y, z)) {
        continue;
      }

      if (block instanceof BlockStaticLiquid) {
        return y;
      }

      if (block instanceof BlockFluidBase) {
        return y;
      }

      if (block instanceof IFluidBlock) {
        return y;
      }

      if (!block.getMaterial().blocksMovement()) {
        continue;
      }

      if (block instanceof BlockFlower) {
        continue;
      }

      return y - 1;
    }

    return -1;
  }
  @Override
  public Chunk provideChunk(int x, int z) {
    rand.setSeed((long) x * 0x4f9939f508L + (long) z * 0x1ef1565bd5L);
    Block blocks[] = new Block[16 * dimension.heightLimit * 16];
    Arrays.fill(blocks, Blocks.air);
    byte meta[] = new byte[16 * dimension.heightLimit * 16];

    biomesForGeneration =
        worldObj
            .getWorldChunkManager()
            .getBiomesForGeneration(biomesForGeneration, x * 4 - 2, z * 4 - 2, 10, 10);

    for (TerrainLayer layer : dimension.terrainLayers) {
      generateTerrain(x, z, blocks, layer);
    }

    biomesForGeneration =
        worldObj
            .getWorldChunkManager()
            .loadBlockGeneratorData(biomesForGeneration, x * 16, z * 16, 16, 16);
    for (TerrainLayer layer : dimension.terrainLayers) {
      replaceBlocksForBiome(x, z, blocks, meta, biomesForGeneration, layer);
    }
    // caveGenerator.generate(this, worldObj, x, z, ids);
    // ravineGenerator.generate(this, worldObj, x, z, ids);
    Chunk chunk = new Chunk(worldObj, blocks, meta, x, z);

    byte[] biomes = chunk.getBiomeArray();

    for (int k = 0; k < biomes.length; ++k) {
      biomes[k] = (byte) this.biomesForGeneration[k].biomeID;
    }

    chunk.generateSkylightMap();
    if (dimension == Dimension.nether) {
      chunk.resetRelightChecks();
    }
    return chunk;
  }
  /**
   * Will return back a chunk, if it doesn't exist and its not a MP client it will generates all the
   * blocks for the specified chunk from the map seed and chunk seed
   */
  public Chunk provideChunk(int p_73154_1_, int p_73154_2_) {
    this.hellRNG.setSeed((long) p_73154_1_ * 341873128712L + (long) p_73154_2_ * 132897987541L);
    Block[] var3 = new Block[32768];
    this.func_147419_a(p_73154_1_, p_73154_2_, var3);
    this.func_147418_b(p_73154_1_, p_73154_2_, var3);
    this.netherCaveGenerator.func_151539_a(this, this.worldObj, p_73154_1_, p_73154_2_, var3);
    this.genNetherBridge.func_151539_a(this, this.worldObj, p_73154_1_, p_73154_2_, var3);
    Chunk var4 = new Chunk(this.worldObj, var3, p_73154_1_, p_73154_2_);
    BiomeGenBase[] var5 =
        this.worldObj
            .getWorldChunkManager()
            .loadBlockGeneratorData(
                (BiomeGenBase[]) null, p_73154_1_ * 16, p_73154_2_ * 16, 16, 16);
    byte[] var6 = var4.getBiomeArray();

    for (int var7 = 0; var7 < var6.length; ++var7) {
      var6[var7] = (byte) var5[var7].biomeID;
    }

    var4.resetRelightChecks();
    return var4;
  }
Esempio n. 24
0
 @Override
 public void render() {
   String biomeLabel = "Biome: ";
   BlockPos tempPos =
       new BlockPos(
           Minecraft.getMinecraft().thePlayer.posX, 20, Minecraft.getMinecraft().thePlayer.posZ);
   Chunk tempChunk = Minecraft.getMinecraft().theWorld.getChunkFromBlockCoords(tempPos);
   String biome =
       tempChunk.getBiome(tempPos, Minecraft.getMinecraft().theWorld.getWorldChunkManager())
           .biomeName;
   width =
       Render2DUtils.stringLength(biomeLabel)
           + Render2DUtils.stringLength(String.valueOf(biome))
           + 4;
   height = 12;
   Render2DUtils.drawRectangleWithOutline(x, y, width, height, color, outlineColor, thickness);
   Render2DUtils.drawShadowedFont(biomeLabel, x + 2, y + 2, Color.colorToHex(textLabelColor));
   Render2DUtils.drawShadowedFont(
       String.valueOf(biome),
       x + 2 + Render2DUtils.stringLength(biomeLabel),
       y + 2,
       Color.colorToHex(textValueColor));
 }
Esempio n. 25
0
  // sync stuff
  public void callStage2(QueuedChunk queuedChunk, net.minecraft.world.chunk.Chunk chunk)
      throws RuntimeException {
    if (chunk == null) {
      // If the chunk loading failed just do it synchronously (may generate)
      queuedChunk.provider.originalLoadChunk(queuedChunk.x, queuedChunk.z);
      return;
    }

    queuedChunk.loader.loadEntities(
        queuedChunk.world, queuedChunk.compound.getCompoundTag("Level"), chunk);
    chunk.setLastSaveTime(queuedChunk.provider.worldObj.getTotalWorldTime());
    queuedChunk.provider.id2ChunkMap.add(
        ChunkCoordIntPair.chunkXZ2Int(queuedChunk.x, queuedChunk.z), chunk);
    queuedChunk.provider.loadedChunks.add(chunk);
    chunk.onChunkLoad();

    if (queuedChunk.provider.serverChunkGenerator != null) {
      queuedChunk.provider.serverChunkGenerator.recreateStructures(
          chunk, queuedChunk.x, queuedChunk.z);
    }

    chunk.populateChunk(queuedChunk.provider, queuedChunk.provider, queuedChunk.x, queuedChunk.z);
  }
Esempio n. 26
0
  /** Checks if the entity's current position is a valid location to spawn this entity. */
  public boolean getCanSpawnHere() {
    Chunk var1 =
        this.worldObj.getChunkFromBlockCoords(
            MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posZ));

    if (this.worldObj.getWorldInfo().getTerrainType() == WorldType.FLAT
        && this.rand.nextInt(4) != 1) {
      return false;
    } else {
      if (this.getSlimeSize() == 1 || this.worldObj.difficultySetting != EnumDifficulty.PEACEFUL) {
        BiomeGenBase var2 =
            this.worldObj.getBiomeGenForCoords(
                MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posZ));

        if (var2 == BiomeGenBase.swampland
            && this.posY > 50.0D
            && this.posY < 70.0D
            && this.rand.nextFloat() < 0.5F
            && this.rand.nextFloat() < this.worldObj.getCurrentMoonPhaseFactor()
            && this.worldObj.getBlockLightValue(
                    MathHelper.floor_double(this.posX),
                    MathHelper.floor_double(this.posY),
                    MathHelper.floor_double(this.posZ))
                <= this.rand.nextInt(8)) {
          return super.getCanSpawnHere();
        }

        if (this.rand.nextInt(10) == 0
            && var1.getRandomWithSeed(987234911L).nextInt(10) == 0
            && this.posY < 40.0D) {
          return super.getCanSpawnHere();
        }
      }

      return false;
    }
  }
Esempio n. 27
0
  /** Checks if the entity's current position is a valid location to spawn this entity. */
  public boolean getCanSpawnHere() {
    Chunk chunk =
        this.worldObj.getChunkFromBlockCoords(
            MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posZ));

    if (this.worldObj.getWorldInfo().getTerrainType().handleSlimeSpawnReduction(rand, worldObj)) {
      return false;
    } else {
      if (this.getSlimeSize() == 1 || this.worldObj.difficultySetting != EnumDifficulty.PEACEFUL) {
        BiomeGenBase biomegenbase =
            this.worldObj.getBiomeGenForCoords(
                MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posZ));

        if (biomegenbase == BiomeGenBaseCobalt.biomeswamp
            && this.posY > 50.0D
            && this.posY < 70.0D
            && this.rand.nextFloat() < 0.5F
            && this.rand.nextFloat() < this.worldObj.getCurrentMoonPhaseFactor()
            && this.worldObj.getBlockLightValue(
                    MathHelper.floor_double(this.posX),
                    MathHelper.floor_double(this.posY),
                    MathHelper.floor_double(this.posZ))
                <= this.rand.nextInt(8)) {
          return super.getCanSpawnHere();
        }

        if (this.rand.nextInt(10) == 0
            && chunk.getRandomWithSeed(987234911L).nextInt(10) == 0
            && this.posY < 40.0D) {
          return super.getCanSpawnHere();
        }
      }

      return false;
    }
  }
  public boolean myChunkSBIDWMT(Chunk c, int x, int y, int z, int blockId, int blockMeta) {
    int j1 = z << 4 | x;

    if (y >= c.precipitationHeightMap[j1] - 1) {
      c.precipitationHeightMap[j1] = -999;
    }

    // int k1 = c.heightMap[j1];
    int l1 = c.getBlockID(x, y, z);
    int i2 = c.getBlockMetadata(x, y, z);

    if (l1 == blockId && i2 == blockMeta) {
      return false;
    } else {
      ExtendedBlockStorage[] storageArrays = c.getBlockStorageArray();
      ExtendedBlockStorage extendedblockstorage = storageArrays[y >> 4];

      if (extendedblockstorage == null) {
        if (blockId == 0) {
          return false;
        }

        extendedblockstorage =
            storageArrays[y >> 4] =
                new ExtendedBlockStorage(y >> 4 << 4, !c.worldObj.provider.hasNoSky);
      }

      int j2 = c.xPosition * 16 + x;
      int k2 = c.zPosition * 16 + z;
      extendedblockstorage.setExtBlockID(x, y & 15, z, blockId);

      if (l1 != 0) {
        if (!c.worldObj.isRemote) {
          Block.blocksList[l1].breakBlock(c.worldObj, j2, y, k2, l1, i2);
        } else if (Block.blocksList[l1] != null && Block.blocksList[l1].hasTileEntity(i2)) {
          TileEntity te = worldObj.getBlockTileEntity(j2, y, k2);

          if (te != null && te.shouldRefresh(l1, blockId, i2, blockMeta, worldObj, j2, y, k2)) {
            c.worldObj.removeBlockTileEntity(j2, y, k2);
          }
        }
      }

      if (extendedblockstorage.getExtBlockID(x, y & 15, z) != blockId) {
        return false;
      } else {
        extendedblockstorage.setExtBlockMetadata(x, y & 15, z, blockMeta);
        // Removed light recalculations
        /*if (flag)
        {
        	c.generateSkylightMap();
        }
        else
        {
        	if (c.getBlockLightOpacity(par1, par2, par3) > 0)
        	{
        		if (par2 >= k1)
        		{
        			c.relightBlock(par1, par2 + 1, par3);
        		}
        	}
        	else if (par2 == k1 - 1)
        	{
        		c.relightBlock(par1, par2, par3);
        	}

        	c.propagateSkylightOcclusion(par1, par3);
        }*/
        TileEntity tileentity;

        if (blockId != 0) {
          if (Block.blocksList[blockId] != null
              && Block.blocksList[blockId].hasTileEntity(blockMeta)) {
            tileentity = c.getChunkBlockTileEntity(x, y, z);

            if (tileentity == null) {
              tileentity = Block.blocksList[blockId].createTileEntity(c.worldObj, blockMeta);
              c.worldObj.setBlockTileEntity(j2, y, k2, tileentity);
            }

            if (tileentity != null) {
              tileentity.updateContainingBlockInfo();
              tileentity.blockMetadata = blockMeta;
            }
          }
        }

        c.isModified = true;
        return true;
      }
    }
  }
  public static S21PacketChunkData.Extracted func_149269_a(
      Chunk p_149269_0_, boolean p_149269_1_, int p_149269_2_) {
    int j = 0;
    ExtendedBlockStorage[] aextendedblockstorage = p_149269_0_.getBlockStorageArray();
    int k = 0;
    S21PacketChunkData.Extracted extracted = new S21PacketChunkData.Extracted();
    byte[] abyte = field_149286_i;

    if (p_149269_1_) {
      p_149269_0_.sendUpdates = true;
    }

    int l;

    for (l = 0; l < aextendedblockstorage.length; ++l) {
      if (aextendedblockstorage[l] != null
          && (!p_149269_1_ || !aextendedblockstorage[l].isEmpty())
          && (p_149269_2_ & 1 << l) != 0) {
        extracted.field_150280_b |= 1 << l;

        if (aextendedblockstorage[l].getBlockMSBArray() != null) {
          extracted.field_150281_c |= 1 << l;
          ++k;
        }
      }
    }

    for (l = 0; l < aextendedblockstorage.length; ++l) {
      if (aextendedblockstorage[l] != null
          && (!p_149269_1_ || !aextendedblockstorage[l].isEmpty())
          && (p_149269_2_ & 1 << l) != 0) {
        byte[] abyte1 = aextendedblockstorage[l].getBlockLSBArray();
        System.arraycopy(abyte1, 0, abyte, j, abyte1.length);
        j += abyte1.length;
      }
    }

    NibbleArray nibblearray;

    for (l = 0; l < aextendedblockstorage.length; ++l) {
      if (aextendedblockstorage[l] != null
          && (!p_149269_1_ || !aextendedblockstorage[l].isEmpty())
          && (p_149269_2_ & 1 << l) != 0) {
        nibblearray = aextendedblockstorage[l].getMetadataArray();
        System.arraycopy(nibblearray.data, 0, abyte, j, nibblearray.data.length);
        j += nibblearray.data.length;
      }
    }

    for (l = 0; l < aextendedblockstorage.length; ++l) {
      if (aextendedblockstorage[l] != null
          && (!p_149269_1_ || !aextendedblockstorage[l].isEmpty())
          && (p_149269_2_ & 1 << l) != 0) {
        nibblearray = aextendedblockstorage[l].getBlocklightArray();
        System.arraycopy(nibblearray.data, 0, abyte, j, nibblearray.data.length);
        j += nibblearray.data.length;
      }
    }

    if (!p_149269_0_.worldObj.provider.hasNoSky) {
      for (l = 0; l < aextendedblockstorage.length; ++l) {
        if (aextendedblockstorage[l] != null
            && (!p_149269_1_ || !aextendedblockstorage[l].isEmpty())
            && (p_149269_2_ & 1 << l) != 0) {
          nibblearray = aextendedblockstorage[l].getSkylightArray();
          System.arraycopy(nibblearray.data, 0, abyte, j, nibblearray.data.length);
          j += nibblearray.data.length;
        }
      }
    }

    if (k > 0) {
      for (l = 0; l < aextendedblockstorage.length; ++l) {
        if (aextendedblockstorage[l] != null
            && (!p_149269_1_ || !aextendedblockstorage[l].isEmpty())
            && aextendedblockstorage[l].getBlockMSBArray() != null
            && (p_149269_2_ & 1 << l) != 0) {
          nibblearray = aextendedblockstorage[l].getBlockMSBArray();
          System.arraycopy(nibblearray.data, 0, abyte, j, nibblearray.data.length);
          j += nibblearray.data.length;
        }
      }
    }

    if (p_149269_1_) {
      byte[] abyte2 = p_149269_0_.getBiomeArray();
      System.arraycopy(abyte2, 0, abyte, j, abyte2.length);
      j += abyte2.length;
    }

    extracted.field_150282_a = new byte[j];
    System.arraycopy(abyte, 0, extracted.field_150282_a, 0, j);
    return extracted;
  }
  public Chunk getOrCreateChunk(int x, int z) {
    random.setSeed((long) x * 341873128712L + (long) z * 132897987541L);

    Chunk chunk;

    // Get default biome data for chunk
    CustomBiomeGrid biomegrid = new CustomBiomeGrid();
    biomegrid.biome = new BiomeGenBase[256];
    world.getWorldChunkManager().getBiomeGenAt(biomegrid.biome, x << 4, z << 4, 16, 16, false);

    // Try extended block method (1.2+)
    short[][] xbtypes =
        generator.generateExtBlockSections(
            CraftServer.instance().getWorld(world.provider.dimensionId),
            this.random,
            x,
            z,
            biomegrid);
    if (xbtypes != null) {
      chunk = new Chunk(this.world, x, z);

      ExtendedBlockStorage[] csect = chunk.getBlockStorageArray();
      int scnt = Math.min(csect.length, xbtypes.length);

      // Loop through returned sections
      for (int sec = 0; sec < scnt; sec++) {
        if (xbtypes[sec] == null) {
          continue;
        }
        byte[] secBlkID = new byte[4096]; // Allocate blk ID bytes
        byte[] secExtBlkID = (byte[]) null; // Delay getting extended ID nibbles
        short[] bdata = xbtypes[sec];
        // Loop through data, 2 blocks at a time
        for (int i = 0, j = 0; i < bdata.length; i += 2, j++) {
          short b1 = bdata[i];
          short b2 = bdata[i + 1];
          byte extb = (byte) ((b1 >> 8) | ((b2 >> 4) & 0xF0));

          secBlkID[i] = (byte) b1;
          secBlkID[(i + 1)] = (byte) b2;

          if (extb != 0) { // If extended block ID data
            if (secExtBlkID == null) { // Allocate if needed
              secExtBlkID = new byte[2048];
            }
            secExtBlkID[j] = extb;
          }
        }
        // Build chunk section
        csect[sec] = new ExtendedBlockStorage(sec << 4, false); // , secBlkID, secExtBlkID);
      }
    } else { // Else check for byte-per-block section data
      byte[][] btypes =
          generator.generateBlockSections(getWorld(world), this.random, x, z, biomegrid);

      if (btypes != null) {
        chunk = new Chunk(this.world, x, z);

        ExtendedBlockStorage[] csect = chunk.getBlockStorageArray();
        int scnt = Math.min(csect.length, btypes.length);

        for (int sec = 0; sec < scnt; sec++) {
          if (btypes[sec] == null) {
            continue;
          }
          csect[sec] = new ExtendedBlockStorage(sec << 4, false); // , btypes[sec], null);
        }
      } else { // Else, fall back to pre 1.2 method
        @SuppressWarnings("deprecation")
        byte[] types = generator.generate(getWorld(world), this.random, x, z);
        int ydim = types.length / 256;
        int scnt = ydim / 16;

        chunk = new Chunk(this.world, x, z); // Create empty chunk

        ExtendedBlockStorage[] csect = chunk.getBlockStorageArray();

        scnt = Math.min(scnt, csect.length);
        // Loop through sections
        for (int sec = 0; sec < scnt; sec++) {
          ExtendedBlockStorage cs = null; // Add sections when needed
          byte[] csbytes = (byte[]) null;

          for (int cy = 0; cy < 16; cy++) {
            int cyoff = cy | (sec << 4);

            for (int cx = 0; cx < 16; cx++) {
              int cxyoff = (cx * ydim * 16) + cyoff;

              for (int cz = 0; cz < 16; cz++) {
                byte blk = types[cxyoff + (cz * ydim)];

                if (blk != 0) { // If non-empty
                  if (cs == null) { // If no section yet, get one
                    cs = csect[sec] = new ExtendedBlockStorage(sec << 4, true);
                    csbytes = cs.getBlockLSBArray();
                  }
                  csbytes[(cy << 8) | (cz << 4) | cx] = blk;
                }
              }
            }
          }
          // If section built, finish prepping its state
          if (cs != null) {
            cs.getYLocation();
          }
        }
      }
    }
    // Set biome grid
    byte[] biomeIndex = chunk.getBiomeArray();
    for (int i = 0; i < biomeIndex.length; i++) {
      biomeIndex[i] = (byte) (biomegrid.biome[i].biomeID & 0xFF);
    }
    // Initialize lighting
    chunk.generateSkylightMap();

    return chunk;
  }