Big Structure help

Started by Kane on

Topic category: Help with modding (Java Edition)

Last seen on 12:58, 23. Sep 2019
Joined Aug 2014
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Big Structure help

"Schematic you try to import is bigger than 1600 blocks...[]. If you can code, you can fix this by splitting method in smaller ones...[]"

Ok, How can I do it?

Last seen on 17:17, 10. Jan 2024
Joined Aug 2013
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
You have something like: 
Tue, 07/05/2016 - 20:55

You have something like:


 

    public void generateSurface(World world, Random random, int i2, int k2){

int i = i2 + random.nextInt(15);
int k = k2 + random.nextInt(15);
BlockPos pos = new BlockPos(i,0,k);
int chunkX = i >> 4;
int chunkZ = k >> 4;
int height = world.getChunkFromChunkCoords(chunkX, chunkZ).getHeight(pos);

int j = height-1;
if(world.getBlockState(new BlockPos(i,j+1,k)).getBlock()==mcreator_dryGround.block){

if(world.getBiomeGenForCoords(new BlockPos(i, j, k)).biomeName == "Wasteland_Forest") {


if((random.nextInt(1000000)+1)<=500000){
boolean place = true;

if(place){
world.setBlockState(new BlockPos(i+0, j+2, k+0), Block.getBlockById(17).getStateFromMeta(0), 3);
world.setBlockState(new BlockPos(i+0, j+3, k+0), Block.getBlockById(17).getStateFromMeta(0), 3);
world.setBlockState(new BlockPos(i+0, j+4, k+0), Block.getBlockById(17).getStateFromMeta(0), 3);
world.setBlockState(new BlockPos(i+0, j+5, k+0), Block.getBlockById(17).getStateFromMeta(0), 3);
}
}

}
}
}


So you must put part of the "setBlock" statements to a another void , and call the void from the first one , so it would be something like this:
 

    public void generateSurface(World world, Random random, int i2, int k2){

int i = i2 + random.nextInt(15);
int k = k2 + random.nextInt(15);
BlockPos pos = new BlockPos(i,0,k);
int chunkX = i >> 4;
int chunkZ = k >> 4;
int height = world.getChunkFromChunkCoords(chunkX, chunkZ).getHeight(pos);

int j = height-1;
if(world.getBlockState(new BlockPos(i,j+1,k)).getBlock()==mcreator_dryGround.block){

if(world.getBiomeGenForCoords(new BlockPos(i, j, k)).biomeName == "Wasteland_Forest") {


if((random.nextInt(1000000)+1)<=500000){
boolean place = true;

if(place){
world.setBlockState(new BlockPos(i+0, j+2, k+0), Block.getBlockById(17).getStateFromMeta(0), 3);
world.setBlockState(new BlockPos(i+0, j+3, k+0), 

gen2(world,i,j,k);
}
}

}
}
}

public void gen2(World world,int i2, int k2){

Block.getBlockById(17).getStateFromMeta(0), 3);
world.setBlockState(new BlockPos(i+0, j+4, k+0), Block.getBlockById(17).getStateFromMeta(0), 3);
world.setBlockState(new BlockPos(i+0, j+5, k+0), Block.getBlockById(17).getStateFromMeta(0), 3);
}

Last seen on 12:58, 23. Sep 2019
Joined Aug 2014
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
RE:You have something like: 
Tue, 07/05/2016 - 23:41

@#1 Is it that easy? I thought I have to create another "structure gen" and continue the code there and connect them in some way.

So I just have to add "public void gen2(World world,int i2, int k2){" + all the remaining blocks below?

And If I have to split it more than once, do I just have to change "gen2" with "gen3" etc.?

It looks so... weird (?) D:

Last seen on 12:58, 23. Sep 2019
Joined Aug 2014
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
RE:You have something like: 
Wed, 07/06/2016 - 19:23

@#1 ok I tried but... the structure misses some blocks (the ones that I've splitted)

Here's the code :


public void generateSurface(World world, Random random, int i2, int k2) {
        int i = i2 + random.nextInt(15);
        int k = k2 + random.nextInt(15);
        int chunkX = i >> 4;
        int chunkZ = k >> 4;
        int height = world.getChunkFromChunkCoords(chunkX, chunkZ).getHeight(new BlockPos(i & 15, 0, k & 15));
        int j = height - 1;
        if ((random.nextInt(1000000) + 1) <= 10000) {
            boolean place = true;
            if (place) {
                world.setBlockState(new BlockPos(i + 2, j + 0, k + 5), Block.getBlockById(156).getStateFromMeta(4), 3);
                world.setBlockState(new BlockPos(i + 3, j + 0, k + 5), Block.getBlockById(156).getStateFromMeta(1), 3);
                world.setBlockState(new BlockPos(i + 5, j + 0, k + 5), Block.getBlockById(156).getStateFromMeta(0), 3);
                world.setBlockState(new BlockPos(i + 6, j + 0, k + 5), Block.getBlockById(156).getStateFromMeta(5), 3);
etc...
                world.setBlockState(new BlockPos(i + 7, j + 6, k + 8), Block.getBlockById(156).getStateFromMeta(1), 3);
                world.setBlockState(new BlockPos(i + 1, j + 6, k + 11), Block.getBlockById(156).getStateFromMeta(0), 3);
                world.setBlockState(new BlockPos(i + 2, j + 6, k + 11), Block.getBlockById(156).getStateFromMeta(5), 3);
            }
        }
    }
    public void generateSurface2(World world, Random random, int i2, int k2) {
        int i = i2 + random.nextInt(15);
        int k = k2 + random.nextInt(15);
        int chunkX = i >> 4;
        int chunkZ = k >> 4;
        int height = world.getChunkFromChunkCoords(chunkX, chunkZ).getHeight(new BlockPos(i & 15, 0, k & 15));
        int j = height - 1;
        if ((random.nextInt(1000000) + 1) <= 10000) {
            boolean place = true;
            if (place) {
                world.setBlockState(new BlockPos(i + 4, j + 6, k + 11), Block.getBlockById(44).getStateFromMeta(15), 3);
                world.setBlockState(new BlockPos(i + 6, j + 6, k + 11), Block.getBlockById(156).getStateFromMeta(4), 3);
etc...
                world.setBlockState(new BlockPos(i + 4, j + 8, k + 17), Block.getBlockById(156).getStateFromMeta(2), 3);
                world.setBlockState(new BlockPos(i + 4, j + 8, k + 18), Block.getBlockById(156).getStateFromMeta(3), 3);
            }
        }
    }

I get no errors, what I'm missing? and what should I use instead of "generateSurface2"?

I'm sure it's easy but...

Last seen on 17:17, 10. Jan 2024
Joined Aug 2013
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
You must put there only:
Wed, 07/06/2016 - 19:40

You must put there only:

 world.setBlockState(new BlockPos(i + 4, j + 6, k + 11), Block.getBlockById(44).getStateFromMeta(15), 3);
                world.setBlockState(new BlockPos(i + 6, j + 6, k + 11), Block.getBlockById(156).getStateFromMeta(4), 3);
etc...
                world.setBlockState(new BlockPos(i + 4, j + 8, k + 17), Block.getBlockById(156).getStateFromMeta(2), 3);
                world.setBlockState(new BlockPos(i + 4, j + 8, k + 18), Block.getBlockById(156).getStateFromMeta(3), 3);

Last seen on 12:58, 23. Sep 2019
Joined Aug 2014
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
RE:You must put there only:
Wed, 07/06/2016 - 21:39

@#2 I'm sorry to waste your time but, you said I have to put part of the "setBlock" statements to a another void, so I used basically the same of the first one adding a 2 (public void generateSurface2(World world, Random random, int i2, int k2) {), and all this:

 int i = i2 + random.nextInt(15);
        int k = k2 + random.nextInt(15);
        int chunkX = i >> 4;
        int chunkZ = k >> 4;
        int height = world.getChunkFromChunkCoords(chunkX, chunkZ).getHeight(new BlockPos(i & 15, 0, k & 15));
        int j = height - 1;
        if ((random.nextInt(1000000) + 1) <= 10000) {
            boolean place = true;
            if (place) {

it's necessary or if I put this:

public void generateSurface2(World world, Random random, int i2, int k2) {
        

                world.setBlockState(new BlockPos(i + 4, j + 6, k + 11), Block.getBlockById(44).getStateFromMeta(15), 3);
                world.setBlockState(new BlockPos(i + 6, j + 6, k + 11), Block.getBlockById(156).getStateFromMeta(4), 3);
etc..

 I get error

Quite surely I need to call the void from the first one but I don't know how :/

In your first comment you put this : gen2(world,i,j,k); at the end of the first void, is that the "call"? Because I did the same but i get error for all the string

 

Last seen on 17:17, 10. Jan 2024
Joined Aug 2013
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
You must have something like:
Wed, 07/06/2016 - 21:59

You must have something like:
 

public void generateSurface(World world, Random random, int i2, int k2) {
        int i = i2 + random.nextInt(15);
        int k = k2 + random.nextInt(15);
        int chunkX = i >> 4;
        int chunkZ = k >> 4;
        int height = world.getChunkFromChunkCoords(chunkX, chunkZ).getHeight(new BlockPos(i & 15, 0, k & 15));
        int j = height - 1;
        if ((random.nextInt(1000000) + 1) <= 10000) {
            boolean place = true;
            if (place) {
                world.setBlockState(new BlockPos(i + 2, j + 0, k + 5), Block.getBlockById(156).getStateFromMeta(4), 3);
                world.setBlockState(new BlockPos(i + 3, j + 0, k + 5), Block.getBlockById(156).getStateFromMeta(1), 3);
                world.setBlockState(new BlockPos(i + 5, j + 0, k + 5), Block.getBlockById(156).getStateFromMeta(0), 3);
                world.setBlockState(new BlockPos(i + 6, j + 0, k + 5), Block.getBlockById(156).getStateFromMeta(5), 3);
                world.setBlockState(new BlockPos(i + 7, j + 6, k + 8), Block.getBlockById(156).getStateFromMeta(1), 3);
                world.setBlockState(new BlockPos(i + 1, j + 6, k + 11), Block.getBlockById(156).getStateFromMeta(0), 3);
                world.setBlockState(new BlockPos(i + 2, j + 6, k + 11), Block.getBlockById(156).getStateFromMeta(5), 3);
                generateSurface2(world,i,j,k)
            }
        }
    }


    public void generateSurface2(World world,int i,int j, int k) {
      
                world.setBlockState(new BlockPos(i + 4, j + 6, k + 11), Block.getBlockById(44).getStateFromMeta(15), 3);
                world.setBlockState(new BlockPos(i + 6, j + 6, k + 11), Block.getBlockById(156).getStateFromMeta(4), 3);
                world.setBlockState(new BlockPos(i + 4, j + 8, k + 17), Block.getBlockById(156).getStateFromMeta(2), 3);
                world.setBlockState(new BlockPos(i + 4, j + 8, k + 18), Block.getBlockById(156).getStateFromMeta(3), 3);
            
        
    }

Last seen on 12:58, 23. Sep 2019
Joined Aug 2014
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
RE:You must put there only:
Wed, 07/06/2016 - 22:08

@#2 ok I did this: 

.....
world.setBlockState(new BlockPos(i + 1, j + 6, k + 11), Block.getBlockById(156).getStateFromMeta(0), 3);
                world.setBlockState(new BlockPos(i + 2, j + 6, k + 11), Block.getBlockById(156).getStateFromMeta(5), 3);
                generateSurface2(world,i,k);

            }
        }
    }

    public void generateSurface2(World world, int i2, int k2) {
          
          int i = i2;
          int k = k2;
       
          int chunkX = i >> 4;
          int chunkZ = k >> 4;
          int height = world.getChunkFromChunkCoords(chunkX, chunkZ).getHeight(new BlockPos(i & 15, 0, k & 15));

          int j = height - 0;
        

                world.setBlockState(new BlockPos(i + 4, j + 6, k + 11), Block.getBlockById(44).getStateFromMeta(15), 3);
                world.setBlockState(new BlockPos(i + 6, j + 6, k + 11), Block.getBlockById(156).getStateFromMeta(4), 3);
etc...

 

And it worked!

Thx a lot for your time Nuparo, I'd like to have you as a software on my computer X)

If I can ask you another little question: How can I get a skeleton spawner? I know its ID is 52:51, so i put this: 

world.setBlockState(new BlockPos(i + 4, j + 7, k + 8), Block.getBlockById(52).getStateFromMeta(51), 3); 

but I always get dumb piggy spawner...

Last seen on 17:17, 10. Jan 2024
Joined Aug 2013
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
RE:RE:You must put there only:
Thu, 07/07/2016 - 00:05

@#2.2 Hmm.. try something like:

 

 world.setBlockState(new BlockPos(i + 4, j + 7, k + 8), Blocks.mob_spawner.getDefaultState(), 2);
                        TileEntity tileentity = world.getTileEntity(new BlockPos(i + 4, j + 7, k + 8));

                        if (tileentity instanceof TileEntityMobSpawner)
                        {
                            ((TileEntityMobSpawner)tileentity).getSpawnerBaseLogic().setEntityName("Skeleton");
                        }

Last seen on 12:58, 23. Sep 2019
Joined Aug 2014
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
RE:RE:RE:You must put there only:
Thu, 07/07/2016 - 09:59

@#2.2.1 I get error for the TileEntity and TileEntityMobSpawner (cannot find symbol)

I tried to take a look to other similar codes but nothing works (they're probably outdated) and always get this error.

Do I have to import something?

Last seen on 17:17, 10. Jan 2024
Joined Aug 2013
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
RE:RE:RE:RE:You must put there only:
Thu, 07/07/2016 - 11:47

@#2.2.1.1 Can I see the whole code?

Last seen on 17:17, 10. Jan 2024
Joined Aug 2013
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
RE:RE:RE:RE:RE:RE:You must put there only:
Thu, 07/07/2016 - 19:28

@#2.2.1.1.1.1 Try add this import: import net.minecraft.tileentity.*;

Last seen on 12:58, 23. Sep 2019
Joined Aug 2014
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
RE:RE:RE:RE:RE:RE:RE:You must put there only:
Thu, 07/07/2016 - 21:40

@#2.2.1.1.1.1.1 Well... It's quite useless to say...

 

I LOVE YOU! It worked perfectly! just a little import and done! 

Thx really a lot man :)
 

If I may ask you, why this " .* " at the end of the import?

 
Last seen on 17:17, 10. Jan 2024
Joined Aug 2013
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
RE:RE:RE:RE:RE:RE:RE:RE:You must put there only:
Thu, 07/07/2016 - 22:07

@#2.2.1.1.1.1.1.1

The "*" means : "Import every class that is in this folder/class"

If you would need for example adding items in the chest , you would need propably only:

import net.minecraft.tileentity.TileEntityChest;

This means " Import class TileEntityChest , that have path net/minecraft/tileentity/

import net.minecraft.tileentity.*;

This means " Import every class, that have path net/minecraft/tileentity/