Jump to content

[1.10.2] Custom Dimension


abused_master

Recommended Posts

Hey all, so today i was working on a mod thats sole purpose was a new dimension, but ran into some problems, minecraft starts up just fine but creating a world crashed, Crash Report:

http://pastebin.com/tNFjthiY

Code:

ChunkProvider:

public class CaveChunkProvider implements IChunkGenerator {

    public static final int FLOOR_HEIGHT = 62;
    public static final int CEILING_HEIGHT = 120;
    static int seedOffset = 0;
    static ImmutableSet<OreGenEvent.GenerateMinable.EventType> bannedOres = ImmutableSet.of(OreGenEvent.GenerateMinable.EventType.DIRT, OreGenEvent.GenerateMinable.EventType.GRAVEL, OreGenEvent.GenerateMinable.EventType.ANDESITE, OreGenEvent.GenerateMinable.EventType.DIORITE, OreGenEvent.GenerateMinable.EventType.GRANITE);
    private final World worldObj;

    static
    {
        MinecraftForge.ORE_GEN_BUS.register(CaveChunkProvider.class);
    }

    private final List<MapGenStructure> structureGenerators = Lists.newArrayList();
    private final List<MapGenBase> generators = Lists.newArrayList();
    Random random = new Random();
    GenStates[] nextState;
    Biome[] biomes = null;
    private WorldGenLakes waterLakeGenerator;
    private WorldGenLakes lavaLakeGenerator;

    public CaveChunkProvider(World worldIn, long seed)
    {
        int length = GenStates.values().length;
        this.nextState = new GenStates[length - 1];
        System.arraycopy(GenStates.values(), 1, this.nextState, 0, length - 1);

        this.worldObj = worldIn;

        this.structureGenerators.add(new MapGenScatteredFeature());
        this.structureGenerators.add(new MapGenMineshaft());

        this.generators.add(TerrainGen.getModdedMapGen(new MapGenCaves(), InitMapGenEvent.EventType.CAVE));
        this.generators.add(TerrainGen.getModdedMapGen(new MapGenRavine(), InitMapGenEvent.EventType.RAVINE));

        this.waterLakeGenerator = new WorldGenLakes(Blocks.WATER);
        this.lavaLakeGenerator = new WorldGenLakes(Blocks.LAVA);
    }

    @SubscribeEvent
    public static void preventOres(OreGenEvent.GenerateMinable event)
    {
        OreGenEvent.GenerateMinable.EventType type = event.getType();
    }

    @Nonnull
    public Chunk provideChunk(int x, int z)
    {
        ChunkPrimer chunkprimer = new ChunkPrimer();

        this.random.setSeed(this.worldObj.getSeed() + (x >> 2) * 65535 + (z >> 2));

        int spire_x = (x >> 2) * 64 + (8 + this.random.nextInt(48)) - x * 16;
        int spire_z = (z >> 2) * 64 + (8 + this.random.nextInt(48)) - z * 16;

        this.random.setSeed(x * 341873128712L + z * 132897987541L);
        GenStates[] values = GenStates.values();
        for (int dx = 0; dx < 16; dx++) {
            for (int dz = 0; dz < 16; dz++)
            {
                int rs = (spire_x - dx) * (spire_x - dx) + (spire_z - dz) * (spire_z - dz);

                double spire_dist = rs < 256 ? Math.sqrt(rs) : Double.MAX_VALUE;

                GenStates curState = GenStates.FLOOR_BEDROCK;
                for (int dy = 0; dy < 256; dy++)
                {
                    IBlockState state = curState.state;
                    if ((curState == GenStates.AIR) &&
                            (rs < 256))
                    {
                        int m = Math.min(dy - 62, 120 - dy);
                        double t = spire_dist;
                        if (m < 9) {
                            t -= Math.sqrt(9 - m);
                        }
                        if ((t <= 4.0D) || ((t <= 5.0D) && (this.random.nextBoolean()))) {
                            state = Blocks.COBBLESTONE.getDefaultState();
                        }
                    }
                    if (dy >= 253) {
                        state = Blocks.BEDROCK.getDefaultState();
                    }
                    chunkprimer.setBlockState(dx, dy, dz, state);
                    boolean advance;
                    switch (curState)
                    {
                        case FLOOR_BEDROCK:
                            advance = (dy > 2) || ((dy > 0) && (this.random.nextBoolean()));
                            break;
                        case GROUND:
                            advance = (dy >= 64) || ((dy >= 62) && (this.random.nextInt(4) != 0));
                            break;
                        case AIR:
                            advance = (dy >= 90) && ((dy >= 120) || (this.random.nextInt(1 + 2 * (120 - dy) * (120 - dy)) == 0));
                            break;
                        case CEILING:
                            advance = (dy >= 120) && (this.random.nextInt(40) == 0);
                            break;
                        case CEILING_STONE:
                            advance = dy >= 253;

                            break;
                        case CEILING_BEDROCK:
                            advance = false;
                            break;
                        default:
                            throw new RuntimeException("Invalid State " + curState);
                    }
                    if (advance) {
                        curState = values[(curState.ordinal() + 1)];
                    }
                }
            }
        }
        for (MapGenBase generator : this.generators) {
            generator.generate(this.worldObj, x, z, chunkprimer);
        }
        for (MapGenBase mapgenbase : this.structureGenerators) {
            mapgenbase.generate(this.worldObj, x, z, chunkprimer);
        }
        for (int dx = 0; dx < 16; dx++) {
            for (int dz = 0; dz < 16; dz++) {
                for (int dy = 62; dy < 65; dy++) {
                    if (chunkprimer.getBlockState(dx, dy, dz) == Blocks.STONE.getDefaultState()) {
                        chunkprimer.setBlockState(dx, dy, dz, Blocks.COBBLESTONE.getDefaultState());
                    }
                }
            }
        }
        Chunk chunk = new Chunk(this.worldObj, chunkprimer, x, z);

        this.biomes = this.worldObj.getBiomeProvider().getBiomesForGeneration(this.biomes, x * 16, z * 16, 16, 16);
        byte[] biomeIDs = chunk.getBiomeArray();
        for (int l = 0; l < biomeIDs.length; l++) {
            biomeIDs[l] = ((byte)Biome.getIdForBiome(this.biomes[l]));
        }
        chunk.generateSkylightMap();
        return chunk;
    }

    public void populate(int x, int z)
    {
        BlockFalling.fallInstantly = true;
        int i = x * 16;
        int j = z * 16;
        BlockPos blockpos = new BlockPos(i, 0, j);
        Biome biome = this.worldObj.getBiomeForCoordsBody(new BlockPos(i + 16, 0, j + 16));
        boolean flag = false;
        this.random.setSeed(this.worldObj.getSeed());
        long k = this.random.nextLong() / 2L * 2L + 1L;
        long l = this.random.nextLong() / 2L * 2L + 1L;
        this.random.setSeed(x * k + z * l ^ this.worldObj.getSeed());
        ChunkPos chunkpos = new ChunkPos(x, z);

        ForgeEventFactory.onChunkPopulate(true, this, this.worldObj, this.random, x, z, false);
        for (MapGenStructure mapgenstructure : this.structureGenerators)
        {
            boolean flag1 = mapgenstructure.generateStructure(this.worldObj, this.random, chunkpos);
            if ((mapgenstructure instanceof MapGenVillage)) {
                flag |= flag1;
            }
        }
        if ((this.waterLakeGenerator != null) && (!flag) && (this.random.nextInt(4) == 0)) {
            this.waterLakeGenerator.generate(this.worldObj, this.random, blockpos.add(this.random.nextInt(16) + 8, this.random.nextInt(256), this.random.nextInt(16) + );
        }
        if ((this.lavaLakeGenerator != null) && (!flag) && (this.random.nextInt( == 0))
        {
            BlockPos blockpos1 = blockpos.add(this.random.nextInt(16) + 8, this.random.nextInt(this.random.nextInt(248) + , this.random.nextInt(16) + ;
        }
        for (int i1 = 0; i1 < 8; i1++) {
            new WorldGenDungeons().generate(this.worldObj, this.random, blockpos.add(this.random.nextInt(16) + 8, this.random.nextInt(256), this.random.nextInt(16) + );
        }
        for (int i2 = 0; i2 < 2; i2++)
        {
            seedOffset = i2;
            biome.decorate(this.worldObj, this.random, blockpos);
        }
        seedOffset = 0;

        ForgeEventFactory.onChunkPopulate(false, this, this.worldObj, this.random, x, z, flag);
        BlockFalling.fallInstantly = false;

        seedOffset = 1;
        GameRegistry.generateWorld(x, z, this.worldObj, this, this.worldObj.getChunkProvider());
        seedOffset = 0;
    }

    public boolean generateStructures(@Nonnull Chunk chunkIn, int x, int z)
    {
        return false;
    }

    @Nonnull
    public List<Biome.SpawnListEntry> getPossibleCreatures(@Nonnull EnumCreatureType creatureType, @Nonnull BlockPos pos)
    {
        Biome biome = this.worldObj.getBiomeForCoordsBody(pos);
        return biome.getSpawnableList(creatureType);
    }

    @Nullable
    public BlockPos getStrongholdGen(@Nonnull World worldIn, @Nonnull String structureName, @Nonnull BlockPos position)
    {
        return null;
    }

    public void recreateStructures(@Nonnull Chunk chunkIn, int x, int z)
    {
        for (MapGenStructure mapgenstructure : this.structureGenerators) {
            mapgenstructure.generate(this.worldObj, x, z, null);
        }
    }

    static enum GenStates
    {
        FLOOR_BEDROCK(Blocks.BEDROCK.getDefaultState()),  GROUND(Blocks.STONE.getDefaultState()),  AIR(Blocks.AIR.getDefaultState()),  CEILING(Blocks.COBBLESTONE.getDefaultState()),  CEILING_STONE(Blocks.STONE.getDefaultState()),  CEILING_BEDROCK(Blocks.BEDROCK.getDefaultState());

        final IBlockState state;

        private GenStates(IBlockState state)
        {
            this.state = state;
        }
    }

}

 

World Provider:

public class CaveWorldProvider extends OvercaveWorldProvider {

    static
    {
        MinecraftForge.EVENT_BUS.register(CaveWorldProvider.class);
    }

        public CaveWorldProvider()
    {
        super(OvercaveEntries.over_cave);
        this.isHellWorld = false;
        this.hasNoSky = true;
    }
    public long getSeed()
    {
        int i = CaveChunkProvider.seedOffset;
        if (i != 0) {
            return super.getSeed() * 31L + i;
        }
        return super.getSeed();
    }

    public int getHeight()
    {
        return 81;
    }

    public boolean canCoordinateBeSpawn(int x, int z)
    {
        return true;
    }

    public boolean canRespawnHere()
    {
        return true;
    }

    public boolean isSurfaceWorld()
    {
        return false;
    }

    public boolean isSkyColored()
    {
        return false;
    }

    public boolean doesXZShowFog(int x, int z)
    {
        return false;
    }

    @Nullable
    public float[] calcSunriseSunsetColors(float celestialAngle, float partialTicks)
    {
        return null;
    }

    @Nonnull
    public Vec3d getFogColor(float p_76562_1_, float p_76562_2_)
    {
        return new Vec3d(1.0E-5D, 1.0E-5D, 1.0E-5D);
    }

    public float calculateCelestialAngle(long par1, float par3)
    {
        int j = 18000;
        float f1 = (j + par3) / 24000.0F - 0.25F;
        if (f1 < 0.0F) {
            f1 += 1.0F;
        }
        if (f1 > 1.0F) {
            f1 -= 1.0F;
        }
        float f2 = f1;
        f1 = 1.0F - (float)((Math.cos(f1 * 3.141592653589793D) + 1.0D) / 2.0D);
        f1 = f2 + (f1 - f2) / 3.0F;
        return f1;
    }

    @Nonnull
    public IChunkGenerator createChunkGenerator()
    {
        return new CaveChunkProvider(this.worldObj, getSeed());
    }

    protected void generateLightBrightnessTable()
    {
        float f = 0.0F;
        for (int i = 0; i <= 15; i++)
        {
            float p = i / 15.0F;
            float f1 = 1.0F - p;
            this.lightBrightnessTable[i] = (p / (f1 * 3.0F + 1.0F));
            if (this.lightBrightnessTable[i] < 0.2F) {
                this.lightBrightnessTable[i] *= this.lightBrightnessTable[i] / 0.2F;
            }
        }
    }

}

OverCaveWorldProvider:

public class OvercaveWorldProvider extends WorldProvider {

    final DimensionEntry entry;

    public OvercaveWorldProvider(DimensionEntry entry)
    {
        this.entry = entry;
    }

    @Nonnull
    public DimensionType getDimensionType()
    {
        return (DimensionType) this.entry.value;
    }

}

 

Link to comment
Share on other sites

All I can say is, what's at VillageCollection.java:303 and why would your code cause it to be null.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.