Started by
Kane
on
Topic category: Help with Minecraft modding (Java Edition)
"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?
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);
}
@#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:
@#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...
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);
@#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
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);
}
@#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...
@#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");
}
@#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?
@#2.2.1.1 Can I see the whole code?
@#2.2.1.1.1 http://s000.tinyupload.com/index.php?file_id=79472857823843097900
here it is, since it's quite long I've decided to upload it so you can download it
@#2.2.1.1.1.1 Try add this import: import net.minecraft.tileentity.*;
@#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?
@#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/