Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.8] Dimensions, Generating A Structure Once (SOLVED)


Born2Code
 Share

Recommended Posts

SOLVED

----------

Problem: I had a block where when you bump into it, it takes you inside of it, I added a new dimension for this but couldn't figure out how to generate the interior only once in the dimension.

 

Solution: In whatever your teleporting method is, either an item, colliding with block, etc... whereever you change the player's dimension is where you need to do the generation. Just use entity.getEntityWorld() to get the world, AFTER you change dimensions, then you will have the "dimension's world". Then use that world to do all of the structure creation.

 

Link to comment
Share on other sites

I'm not sure if worlds have nbt but you could generate the structure once with an IWorldGenerator and then create a tag that says the structure has been built so it doesn't keep rebuilding it. Then again I've never really messed around with a chunk provider so I have no idea if this is possible.

The proud(ish) developer of Ancients

Link to comment
Share on other sites

Don't think it would work. I added a dummy variable to hold whether or not it's been built and based on that add the block.

 

private boolean built = false;

 

if(built == false)

{

  addblockstuffhere

  built = true;

}

Link to comment
Share on other sites

Oh, yes, sorry. Forgot to include that in last post ??? It doesn't work, it just doesn't add anything, but... I did another test, I had a counter variable, that increased every time that method was called and was printed out. When I first entered my dimension it was being increased without stopping until a certain point.. then it only increased as a moved towards un-generates terrain.

Link to comment
Share on other sites

If it's easier, I could also just have it generate a cube of air and then build the structure inside. But I also couldn't get that working, as I keep getting index out of bound errors.

Post your current code.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Link to comment
Share on other sites

Here..

 

    public void func_180520_a(int p_180520_1_, int p_180520_2_, ChunkPrimer primer)

    {

        for(int x = 0; x < 100; x++)

        {

            for(int z = 0; z < 100; z++)

            {

                primer.setBlockState(x, 100, z, Blocks.air.getDefaultState());

            }

        }

 

        primer.setBlockState(0, 100, 0, Blocks.end_stone.getDefaultState());

    }

 

Link to comment
Share on other sites

Here..

 

    public void func_180520_a(int p_180520_1_, int p_180520_2_, ChunkPrimer primer)

    {

        for(int x = 0; x < 100; x++)

        {

            for(int z = 0; z < 100; z++)

            {

                primer.setBlockState(x, 100, z, Blocks.air.getDefaultState());

            }

        }

 

        primer.setBlockState(0, 100, 0, Blocks.end_stone.getDefaultState());

    }

1. You should post the full code, not just a method.

2. Post the crash report together.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Link to comment
Share on other sites

Generating a cube of air and my structure inside forever was just a quick though, I would prefer the OP answered instead.

 

ChunkProvider

 

 

public class MYCHUNKPROVIDER implements IChunkProvider

{

    private Random endRNG;

    private NoiseGeneratorOctaves noiseGen1;

    private NoiseGeneratorOctaves noiseGen2;

    private NoiseGeneratorOctaves noiseGen3;

    public NoiseGeneratorOctaves noiseGen4;

    public NoiseGeneratorOctaves noiseGen5;

    private World endWorld;

    private double[] densities;

    /** The biomes that are used to generate the chunk */

    private BiomeGenBase[] biomesForGeneration;

    double[] noiseData1;

    double[] noiseData2;

    double[] noiseData3;

    double[] noiseData4;

    double[] noiseData5;

    private static final String __OBFID = "CL_00000397";

 

    public MYCHUNKPROVIDER(World worldIn, long p_i2007_2_)

    {

        this.endWorld = worldIn;

        this.endRNG = new Random(p_i2007_2_);

        this.noiseGen1 = new NoiseGeneratorOctaves(this.endRNG, 16);

        this.noiseGen2 = new NoiseGeneratorOctaves(this.endRNG, 16);

        this.noiseGen3 = new NoiseGeneratorOctaves(this.endRNG, 8);

        this.noiseGen4 = new NoiseGeneratorOctaves(this.endRNG, 10);

        this.noiseGen5 = new NoiseGeneratorOctaves(this.endRNG, 16);

 

        NoiseGenerator[] noiseGens = {noiseGen1, noiseGen2, noiseGen3, noiseGen4, noiseGen5};

        noiseGens = TerrainGen.getModdedNoiseGenerators(worldIn, this.endRNG, noiseGens);

        this.noiseGen1 = (NoiseGeneratorOctaves)noiseGens[0];

        this.noiseGen2 = (NoiseGeneratorOctaves)noiseGens[1];

        this.noiseGen3 = (NoiseGeneratorOctaves)noiseGens[2];

        this.noiseGen4 = (NoiseGeneratorOctaves)noiseGens[3];

        this.noiseGen5 = (NoiseGeneratorOctaves)noiseGens[4];

    }

 

 

    public void func_180520_a(int p_180520_1_, int p_180520_2_, ChunkPrimer primer)

    {

        for(int x = 0; x < 100; x++)

        {

            for(int z = 0; z < 100; z++)

            {

                primer.setBlockState(x, 100, z, Blocks.air.getDefaultState());

            }

        }

 

        primer.setBlockState(0, 100, 0, Blocks.end_stone.getDefaultState());

    }

 

    public void func_180519_a(ChunkPrimer primer)

    {

 

    }

 

    private int chunkX=0, chunkZ=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

    */

    public Chunk provideChunk(int x, int z)

    {

        chunkX = x; chunkZ = z;

        this.endRNG.setSeed((long)x * 341873128712L + (long)z * 132897987541L);

        ChunkPrimer chunkprimer = new ChunkPrimer();

        this.biomesForGeneration = this.endWorld.getWorldChunkManager().loadBlockGeneratorData(this.biomesForGeneration, x * 16, z * 16, 16, 16);

        this.func_180520_a(x, z, chunkprimer);

        this.func_180519_a(chunkprimer);

        Chunk chunk = new Chunk(this.endWorld, chunkprimer, x, z);

        byte[] abyte = chunk.getBiomeArray();

 

        for (int k = 0; k < abyte.length; ++k)

        {

            abyte[k] = (byte)this.biomesForGeneration[k].biomeID;

        }

 

        chunk.generateSkylightMap();

        return chunk;

    }

 

    /**

    * generates a subset of the level's terrain data. Takes 7 arguments: the [empty] noise array, the position, and the

    * size.

    */

    private double[] initializeNoiseField(double[] p_73187_1_, int p_73187_2_, int p_73187_3_, int p_73187_4_, int p_73187_5_, int p_73187_6_, int p_73187_7_)

    {

        ChunkProviderEvent.InitNoiseField event = new ChunkProviderEvent.InitNoiseField(this, p_73187_1_, p_73187_2_, p_73187_3_, p_73187_4_, p_73187_5_, p_73187_6_, p_73187_7_);

        MinecraftForge.EVENT_BUS.post(event);

        if (event.getResult() == Result.DENY) return event.noisefield;

 

        if (p_73187_1_ == null)

        {

            p_73187_1_ = new double[p_73187_5_ * p_73187_6_ * p_73187_7_];

        }

 

        double d0 = 684.412D;

        double d1 = 684.412D;

        this.noiseData4 = this.noiseGen4.generateNoiseOctaves(this.noiseData4, p_73187_2_, p_73187_4_, p_73187_5_, p_73187_7_, 1.121D, 1.121D, 0.5D);

        this.noiseData5 = this.noiseGen5.generateNoiseOctaves(this.noiseData5, p_73187_2_, p_73187_4_, p_73187_5_, p_73187_7_, 200.0D, 200.0D, 0.5D);

        d0 *= 2.0D;

        this.noiseData1 = this.noiseGen3.generateNoiseOctaves(this.noiseData1, p_73187_2_, p_73187_3_, p_73187_4_, p_73187_5_, p_73187_6_, p_73187_7_, d0 / 80.0D, d1 / 160.0D, d0 / 80.0D);

        this.noiseData2 = this.noiseGen1.generateNoiseOctaves(this.noiseData2, p_73187_2_, p_73187_3_, p_73187_4_, p_73187_5_, p_73187_6_, p_73187_7_, d0, d1, d0);

        this.noiseData3 = this.noiseGen2.generateNoiseOctaves(this.noiseData3, p_73187_2_, p_73187_3_, p_73187_4_, p_73187_5_, p_73187_6_, p_73187_7_, d0, d1, d0);

        int k1 = 0;

 

        for (int l1 = 0; l1 < p_73187_5_; ++l1)

        {

            for (int i2 = 0; i2 < p_73187_7_; ++i2)

            {

                float f = (float)(l1 + p_73187_2_) / 1.0F;

                float f1 = (float)(i2 + p_73187_4_) / 1.0F;

                float f2 = 100.0F - MathHelper.sqrt_float(f * f + f1 * f1) * 8.0F;

 

                if (f2 > 80.0F)

                {

                    f2 = 80.0F;

                }

 

                if (f2 < -100.0F)

                {

                    f2 = -100.0F;

                }

 

                for (int j2 = 0; j2 < p_73187_6_; ++j2)

                {

                    double d2 = 0.0D;

                    double d3 = this.noiseData2[k1] / 512.0D;

                    double d4 = this.noiseData3[k1] / 512.0D;

                    double d5 = (this.noiseData1[k1] / 10.0D + 1.0D) / 2.0D;

 

                    if (d5 < 0.0D)

                    {

                        d2 = d3;

                    }

                    else if (d5 > 1.0D)

                    {

                        d2 = d4;

                    }

                    else

                    {

                        d2 = d3 + (d4 - d3) * d5;

                    }

 

                    d2 -= 8.0D;

                    d2 += (double)f2;

                    byte b0 = 2;

                    double d6;

 

                    if (j2 > p_73187_6_ / 2 - b0)

                    {

                        d6 = (double)((float)(j2 - (p_73187_6_ / 2 - b0)) / 64.0F);

                        d6 = MathHelper.clamp_double(d6, 0.0D, 1.0D);

                        d2 = d2 * (1.0D - d6) + -3000.0D * d6;

                    }

 

                    b0 = 8;

 

                    if (j2 < b0)

                    {

                        d6 = (double)((float)(b0 - j2) / ((float)b0 - 1.0F));

                        d2 = d2 * (1.0D - d6) + -30.0D * d6;

                    }

 

                    p_73187_1_[k1] = d2;

                    ++k1;

                }

            }

        }

 

        return p_73187_1_;

    }

 

    /**

    * Checks to see if a chunk exists at x, z

    */

    public boolean chunkExists(int x, int z)

    {

        return true;

    }

 

    /**

    * Populates chunk with ores etc etc

    */

    public void populate(IChunkProvider provider, int p_73153_2_, int p_73153_3_)

    {

        BlockFalling.fallInstantly = true;

 

        MinecraftForge.EVENT_BUS.post(new PopulateChunkEvent.Pre(provider, endWorld, endWorld.rand, p_73153_2_, p_73153_3_, false));

 

        BlockPos blockpos = new BlockPos(p_73153_2_ * 16, 0, p_73153_3_ * 16);

        this.endWorld.getBiomeGenForCoords(blockpos.add(16, 0, 16)).decorate(this.endWorld, this.endWorld.rand, blockpos);

 

        MinecraftForge.EVENT_BUS.post(new PopulateChunkEvent.Post(provider, endWorld, endWorld.rand, p_73153_2_, p_73153_3_, false));

        BlockFalling.fallInstantly = false;

    }

 

    public boolean func_177460_a(IChunkProvider p_177460_1_, Chunk p_177460_2_, int p_177460_3_, int p_177460_4_)

    {

        return false;

    }

 

    /**

    * Two modes of operation: if passed true, save all Chunks in one go.  If passed false, save up to two chunks.

    * Return true if all chunks have been saved.

    */

    public boolean saveChunks(boolean p_73151_1_, IProgressUpdate p_73151_2_)

    {

        return true;

    }

 

    /**

    * Save extra data not associated with any Chunk.  Not saved during autosave, only during world unload.  Currently

    * unimplemented.

    */

    public void saveExtraData() {}

 

    /**

    * Unloads chunks that are marked to be unloaded. This is not guaranteed to unload every such chunk.

    */

    public boolean unloadQueuedChunks()

    {

        return false;

    }

 

    /**

    * Returns if the IChunkProvider supports saving.

    */

    public boolean canSave()

    {

        return true;

    }

 

    /**

    * Converts the instance data to a readable string.

    */

    public String makeString()

    {

        return "RandomLevelSource";

    }

 

    public List func_177458_a(EnumCreatureType p_177458_1_, BlockPos p_177458_2_)

    {

        return this.endWorld.getBiomeGenForCoords(p_177458_2_).getSpawnableList(p_177458_1_);

    }

 

    public BlockPos getStrongholdGen(World worldIn, String p_180513_2_, BlockPos p_180513_3_)

    {

        return null;

    }

 

    public int getLoadedChunkCount()

    {

        return 0;

    }

 

    public void recreateStructures(Chunk p_180514_1_, int p_180514_2_, int p_180514_3_) {}

 

    public Chunk provideChunk(BlockPos blockPosIn)

    {

        return this.provideChunk(blockPosIn.getX() >> 4, blockPosIn.getZ() >> 4);

    }

}

 

 

Link to comment
Share on other sites

1. First remove this line:

private static final String __OBFID = "CL_00000397";

It is minecraft deobfuscation id, which is totally useless and unrelated with modding.

(+ Do not copy-paste code if you cant fully understand the code..)

2. Please rephrase your issue, I cant understand what is your problem.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Link to comment
Share on other sites

Here..

 

    public void func_180520_a(int p_180520_1_, int p_180520_2_, ChunkPrimer primer)

    {

        for(int x = 0; x < 100; x++)

        {

            for(int z = 0; z < 100; z++)

            {

                primer.setBlockState(x, 100, z, Blocks.air.getDefaultState());

            }

        }

 

        primer.setBlockState(0, 100, 0, Blocks.end_stone.getDefaultState());

    }

1. You should post the full code, not just a method.

2. Post the crash report together.

 

 

All I need, is an empty dimension, with one structure generated inside, that way when teleported there (working), I am teleported into that structure.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.