Jump to content

Recommended Posts

Posted

Hi community,

I'm trying to replace all Stone, Dirt und Grass Blocks in my new Dimension with my own ones.

But It won't work. I just took the old Chunkprovider and changed the things I wanted to have.

The whole thing doesn't ever produce an error, neither in eclipse nor ingame. It just doesn't place my blocks...

Here are my important methods:

The generate terrain from my chunkprovider:

 

  Reveal hidden contents

 

 

And my biome file:

 

  Reveal hidden contents

 

 

Would be awesome to get some help on this one...

Greets Alasar

Posted

Okay,

can't I create some kind of own byte array?

I mean, other people managed it too and I don't see anything in their sourcecode...

 

Edit: it doesn't work either with other Blocks from vanilla...

Posted

this code allowed me to replace all stone blocks in specific biome above a certain height.

 

  
byte var38 = par3ArrayOfByte[var17];
                    int var99 = var10.biomeID;
                    if (var99 == 28){
//if height is greater than 60 and blocks are stone, replace with custom block                  
  if (var16 > 60 && var38 == Block.stone.blockID)
                    {
                    	par3ArrayOfByte[var17] = (byte)mod.customblock.blockID;
}
}

Posted

Sounds good,

I put that assignment at the end of the generate method and put the vanilla stone back:

 

  Reveal hidden contents

 

But now It still doesn't work...

Posted

I think you have to push the code two brackets down. try this

 

 public void replaceBlocksForBiome(int par1, int par2, byte[] par3ArrayOfByte, BiomeGenBase[] par4ArrayOfBiomeGenBase)
    {
        byte var5 = 63;
        double var6 = 0.03125D;
        this.stoneNoise = this.noiseGen4.generateNoiseOctaves(this.stoneNoise, par1 * 16, par2 * 16, 0, 16, 16, 1, var6 * 2.0D, var6 * 2.0D, var6 * 2.0D);

        for (int var8 = 0; var8 < 16; ++var8)
        {
            for (int var9 = 0; var9 < 16; ++var9)
            {
                BiomeGenBase var10 = par4ArrayOfBiomeGenBase[var9 + var8 * 16];
                float var11 = var10.getFloatTemperature();
                int var12 = (int)(this.stoneNoise[var8 + var9 * 16] / 3.0D + 3.0D + this.rand.nextDouble() * 0.25D);
                int var13 = -1;
                byte var14 = var10.topBlock;
                byte var15 = var10.fillerBlock;

                for (int var16 = 127; var16 >= 0; --var16)
                {
                    int var17 = (var9 * 16 + var8) * 128 + var16;

                    if (var16 <= 0 + this.rand.nextInt(5))
                    {
                        par3ArrayOfByte[var17] = (byte)Block.bedrock.blockID;
                    }
                    else
                    {
                        byte var18 = par3ArrayOfByte[var17];

                        if (var18 == 0)
                        {
                            var13 = -1;
                        }
                        else if (var18 != Block.stone.blockID)
                        {
                            if (var13 == -1)
                            {
                                if (var12 == 0)
                                {
                                    var14 = 0;
                                    var15 = (byte)Block.stone.blockID;
                                }
                                else if (var16 >= var5 - 4 && var16 <= var5 + 1)
                                {
                                    var14 = var10.topBlock;
                                    var15 = var10.fillerBlock;
                                }

                                if (var16 < var5 && var14 == 0)
                                {
                                    if (var11 < 0.15F)
                                    {
                                        var14 = (byte)Block.ice.blockID;
                                    }
                                    else
                                    {
                                        var14 = (byte)Block.waterStill.blockID;
                                    }
                                }

                                var13 = var12;

                                if (var16 >= var5 - 1)
                                {
                                    par3ArrayOfByte[var17] = var14;
                                }
                                else
                                {
                                    par3ArrayOfByte[var17] = var15;
                                }
                            }
                            else if (var13 > 0)
                            {
                                --var13;
                                par3ArrayOfByte[var17] = var15;

                                if (var13 == 0 && var15 == Block.sand.blockID)
                                {
                                    var13 = this.rand.nextInt(4);
                                    var15 = (byte)Block.sandStone.blockID;
                                }
                            }
}
                }
                       
                            byte var38 = par3ArrayOfByte[var17];
                            int var99 = var10.biomeID;
                            if (var99 == 28){
        //if height is greater than 60 and blocks are stone, replace with custom block                 
          if (var16 > 60 && var38 == Block.stone.blockID)
                            {
                             par3ArrayOfByte[var17] = (byte)TVMain.amStone.blockID;
                            }
                            }
                       
                }
            }
        }
       
    }

 

 

Posted

It didn't work, so I tried with the original Chungenerator instead of using my own one.

So it generated this:

width=204 height=120https://lh3.googleusercontent.com/-Qk7J5GnFEog/URKnP5ehsfI/AAAAAAAAAHw/SWs4tRoiIaU/h120/2013-02-06_19.49.09.png[/img]So now I'm completly at my limits with Java and my teacher couldn't help me either :)

Somehow it doesn't use my own chunkgenerator which I registred in the Worldprovider:

 

  Reveal hidden contents

 

 

And it's obviously still not generating my stone.

Thanks for the help until now though...

Posted

If you are using my exact code you need to specify the biome ID you want the code to work for, or you can take out the if biomeID check, then it will do it for all the biomes.  If you want paste your code here Ill take a look at it.

 

The way I got a custom chunk provider to work was I created a World type that overrides the default world type, or you can create a completely new world type, then you would create a new class like WorldTypeVoid and that is where you would specify the custom chunkprovider

Posted

World Type is like Default, Large Biomes, Flat.  You can add one or overwrite one.

 

I havent dug deep into dimensions but you dont need to create a new world type to add your own dimension and use a custom chunk generator for the dimension, but if you want to use a custom chunk provider for the overworld you probably have to go the worldtype route.

Posted

OLD CODE

public IChunkProvider getChunkProvider()

{

 

  return new ChunkProviderTheVoid(worldObj, worldObj.getSeed(), false);

 

}

ITS NOW

public IChunkProvider createChunkGenerator()

{

 

  return new ChunkProviderTheVoid(worldObj, worldObj.getSeed(), false);

 

}

...

Posted

Chunkprovider:

 

  Reveal hidden contents

 

Portal Block:

 

  Reveal hidden contents

 

Posted

I'll take a look I just got in after being away all weekend.  Im not sure why signs would be generated, what happens when you change your block your looking to place there with like gold ore just as a test.

Posted

Somehow it does something very weird:

It takes the Id, ignores the first digit, and subtracts 7.

My stone= 575 ----> Sign wall.

Vanilla blocks work fine

Posted

That would be the byte limitation that was discussed earlier. The byte type can only store a number as large as 255 (technically -128 to 127, but Minecraft starts at 0 instead). This means that when you cast your int blockID to a byte, it does funny things.

 

I assume you could alter the code to use ints (or shorts) instead of bytes, but that would not only be hard for you to do if you don't understand the code, it would also make the code less efficient (ints take up 4 times more memory space than bytes, shorts take 2 times more).

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.