Skip to content

Instantly share code, notes, and snippets.

@Andromander
Last active May 3, 2019 13:35
Show Gist options
  • Save Andromander/d66023a4152cc0abfd980487f13b47c9 to your computer and use it in GitHub Desktop.
Save Andromander/d66023a4152cc0abfd980487f13b47c9 to your computer and use it in GitHub Desktop.
package androsa.gaiadimension.world.gen;
import androsa.gaiadimension.registry.GDBlocks;
import net.minecraft.block.Block;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.gen.feature.WorldGenerator;
import java.util.Random;
public class GDGenBismuthSpire extends WorldGenerator {
private final int startHeight;
public GDGenBismuthSpire(int startHeightIn) {
//super(false);
this.startHeight = startHeightIn;
}
@Override
public boolean generate(World worldIn, Random rand, BlockPos position) {
for (int cx = 0; cx < 3; cx++) {
for (int cz = 0; cz < 3; cz++) {
BlockPos pos = position.add(cx - 1, 0, cz - 1);
if (worldIn.isBlockLoaded(pos)) {
Block blockBelow = worldIn.getBlockState(pos.down()).getBlock();
if (blockBelow != GDBlocks.murky_grass) {
return false;
}
}
}
int height = startHeight + rand.nextInt(4);
//int heightA = height - rand.nextInt(4) - 2;
//int heightD = height / 2 - (rand.nextInt(5) - 2);
//int heightE = rand.nextInt(3) + 1;
for (int x = -2; x <= 2; x++) {
for (int z = -2; z <= 2; x++) {
//if (Math.abs(x) != 2 || Math.abs(z) != 2) {
//Center pillar
if (x == 0 && z == 0) {
for (int my = 0; my < height; my++) {
worldIn.setBlockState(position.up(my), GDBlocks.impure_rock.getDefaultState());
}
}
/*
//Directly adjacent to center pillar
else if ((Math.abs(x) == 1 && Math.abs(z) == 0) || (Math.abs(x) == 0 && Math.abs(z) == 1)) {
for (int ay = 0; ay < heightA; ay++) {
worldIn.setBlockState(position.add(x, ay, z), GDBlocks.impure_rock.getDefaultState());
}
}
//Diagonal from the center pillar
else if (Math.abs(x) == 1 && Math.abs(z) == 1) {
for (int dy = 0; dy < heightD; dy++) {
worldIn.setBlockState(position.add(x, dy, z), GDBlocks.impure_rock.getDefaultState());
}
}
//Anything else that wasn't covered
else {
worldIn.setBlockState(position.add(x, heightE, z), GDBlocks.impure_rock.getDefaultState());
}*/
// }
}
}
}
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment