ExtrabiomesXL

ExtrabiomesXL

3M Downloads

Biome height causing issues in mystcraft

solidcoal opened this issue ยท 7 comments

commented

All of the biome heights in EBXL seem incredibly high, which is causing unusually high ages and, in some cases, crashes due to code, obviously, not being coded to expect height levels in excess of 128. The highest used in EBXL is 2.3F, which is almost twice the max value for Extreme hills.

commented

Please provide screenshots, logs, etc. that will explain the nature of the problem and why it is an Extrabiomes issue and not a Mystcraft issue.

commented

Further investigations (it's my mystcraft addon "aMCt" which caused/revealed this issue) showed thats its not an invalid height, it's a block id issue.

I'm using following code to get a biome-specific block for any biome:

public int getBlock( World worldObj, int x, int y, int z )
{
    if ( y < bedrockLimit )
        return bedrockID;
    BiomeGenBase biome = worldObj.getBiomeGenForCoords( x, z );
    if ( y == worldObj.getHeightValue( x, z ) )
        return biome.topBlock;
    return biome.fillerBlock;
}

Either topBlock or fillerBlock is holding a negative value (in my case -98) which will cause

worldObj.setBlock( x, y-1, z, blockageSelector.getBlock( worldObj, x, y-1, z ) );

to throw an IndexOutOfBoundsException (see below for an example). Coords used are within valid ranges (as can be seen in first line of log below):

for ( int x = posX; x < (posX+16); ++x )
{
    for ( int z = posZ; z < (posZ+16); ++z )
    {
        int maxheight = worldObj.getHeightValue( x, z );

        for ( int y = maxheight-1; y > 0; --y )
        {

with posX and posY being the values passed to "populate".

2012-10-08 22:20:20 [INFO] [aMCt] OOB! using x=-48, y=15, z=-16, blockid=-98
2012-10-08 22:20:20 [INFO] [STDERR] java.lang.ArrayIndexOutOfBoundsException: -98
2012-10-08 22:20:20 [INFO] [STDERR]     at wm.a(SourceFile:57)
2012-10-08 22:20:20 [INFO] [STDERR]     at wl.a(Chunk.java:645)
2012-10-08 22:20:20 [INFO] [STDERR]     at wl.a(Chunk.java:593)
2012-10-08 22:20:20 [INFO] [STDERR]     at up.b(World.java:461)
2012-10-08 22:20:20 [INFO] [STDERR]     at sillybits.core.sbUtils.addBarriers(sbUtils.java:312)
2012-10-08 22:20:20 [INFO] [STDERR]     at sillybits.amct.symbols.utils.TerrainGenRing$Populator.populate(TerrainGenRing.java:260)
2012-10-08 22:20:20 [INFO] [STDERR]     at xcompwiz.mystcraft.AgeController.populate(AgeController.java:400)
2012-10-08 22:20:20 [INFO] [STDERR]     at xcompwiz.mystcraft.ChunkProviderMyst.a(ChunkProviderMyst.java:168)
2012-10-08 22:20:20 [INFO] [STDERR]     at gq.a(ChunkProviderServer.java:225)
2012-10-08 22:20:20 [INFO] [STDERR]     at wl.a(Chunk.java:1183)
2012-10-08 22:20:20 [INFO] [STDERR]     at gq.c(ChunkProviderServer.java:125)
2012-10-08 22:20:20 [INFO] [STDERR]     at gq.d(ChunkProviderServer.java:138)
2012-10-08 22:20:20 [INFO] [STDERR]     at up.e(World.java:394)
2012-10-08 22:20:20 [INFO] [STDERR]     at up.a(World.java:299)
2012-10-08 22:20:20 [INFO] [STDERR]     at up.c(World.java:312)
2012-10-08 22:20:20 [INFO] [STDERR]     at up.b(World.java:286)
2012-10-08 22:20:20 [INFO] [STDERR]     at WorldProviderMyst.a(WorldProviderMyst.java:375)
2012-10-08 22:20:20 [INFO] [STDERR]     at WorldProviderMyst.verifySpawn(WorldProviderMyst.java:358)
2012-10-08 22:20:20 [INFO] [STDERR]     at WorldProviderMyst.getSpawnPoint(WorldProviderMyst.java:323)
2012-10-08 22:20:20 [INFO] [STDERR]     at up.E(World.java:3777)
2012-10-08 22:20:20 [INFO] [STDERR]     at MystLinkController.travelEntity(MystLinkController.java:40)
2012-10-08 22:20:20 [INFO] [STDERR]     at xcompwiz.mystcraft.TileEntityLinkbookStand.link(TileEntityLinkbookStand.java:76)
2012-10-08 22:20:20 [INFO] [STDERR]     at xcompwiz.mystcraft.TileEntityLinkbookStand.processMessageData(TileEntityLinkbookStand.java:60)
2012-10-08 22:20:20 [INFO] [STDERR]     at xcompwiz.mystcraft.MystcraftPacketHandler.sendMessage(MystcraftPacketHandler.java:353)
2012-10-08 22:20:20 [INFO] [STDERR]     at xcompwiz.mystcraft.MystcraftPacketHandler.onPacketData(MystcraftPacketHandler.java:78)
2012-10-08 22:20:20 [INFO] [STDERR]     at cpw.mods.fml.common.network.NetworkRegistry.handlePacket(NetworkRegistry.java:249)
2012-10-08 22:20:20 [INFO] [STDERR]     at cpw.mods.fml.common.network.NetworkRegistry.handleCustomPacket(NetworkRegistry.java:239)
2012-10-08 22:20:20 [INFO] [STDERR]     at cpw.mods.fml.common.network.FMLNetworkHandler.handlePacket250Packet(FMLNetworkHandler.java:78)
2012-10-08 22:20:20 [INFO] [STDERR]     at gz.a(NetServerHandler.java:1063)
2012-10-08 22:20:20 [INFO] [STDERR]     at ce.a(SourceFile:56)
2012-10-08 22:20:20 [INFO] [STDERR]     at bb.b(TcpConnection.java:441)
2012-10-08 22:20:20 [INFO] [STDERR]     at gz.d(NetServerHandler.java:80)
2012-10-08 22:20:20 [INFO] [STDERR]     at ha.b(NetworkListenThread.java:55)
2012-10-08 22:20:20 [INFO] [STDERR]     at fx.b(SourceFile:30)
2012-10-08 22:20:20 [INFO] [STDERR]     at net.minecraft.server.MinecraftServer.q(MinecraftServer.java:650)
2012-10-08 22:20:20 [INFO] [STDERR]     at ft.q(DedicatedServer.java:241)
2012-10-08 22:20:20 [INFO] [STDERR]     at net.minecraft.server.MinecraftServer.p(MinecraftServer.java:565)
2012-10-08 22:20:20 [INFO] [STDERR]     at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:471)
2012-10-08 22:20:20 [INFO] [STDERR]     at ep.run(SourceFile:539)
commented

It is a casting problem. Topblock and filler block are bytes not integers. this is why the custom blocks we put in the topblock and filler always have to have an id below 256.

If the biomes actually had negative numbers in those fields, Minecraft would crash during overworld terrain gen.

commented

To solve this, return

topblock & 255

and

fillerblock & 255

in getBlock and java will the do the conversion right. (the problem is that java interprets byte over 128 as two complement negatives and then casts them to integers.

commented

@SillyBits and I'd love to take a look at your addin ;)

commented

Gosh! Could have thought about such implicit conversions, always a pain :-/
Added those fixes and the code behaves as supposed, thanks for this enlightenment.

P.S. Regarding aMCt, the early alpha is available at: http://binarymage.com/forum/viewtopic.php?f=13&t=54

commented

No worries. and thanks! ๐Ÿ˜„