This commit is contained in:
Vaern 2022-04-15 21:14:11 -07:00
parent 9152678320
commit b32d6bb5a1
2 changed files with 74 additions and 35 deletions

View File

@ -3,6 +3,7 @@ package com.hbm.world.worldgen;
import java.util.Random; import java.util.Random;
import com.hbm.blocks.ModBlocks; import com.hbm.blocks.ModBlocks;
import com.hbm.lib.HbmChestContents;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
@ -27,6 +28,8 @@ public class ComponentNTMFeatures {
/** Sandstone Ruin 1 */ /** Sandstone Ruin 1 */
public static class NTMHouse1 extends ComponentNTMFeatures.Feature { public static class NTMHouse1 extends ComponentNTMFeatures.Feature {
private boolean hasPlacedChest = false;
private static ComponentNTMFeatures.Sandstone RandomSandstone = new ComponentNTMFeatures.Sandstone(); private static ComponentNTMFeatures.Sandstone RandomSandstone = new ComponentNTMFeatures.Sandstone();
/** Constructor for this feature; takes coordinates for bounding box */ /** Constructor for this feature; takes coordinates for bounding box */
@ -37,11 +40,13 @@ public class ComponentNTMFeatures {
@Override @Override
protected void func_143012_a(NBTTagCompound nbt) { protected void func_143012_a(NBTTagCompound nbt) {
super.func_143012_a(nbt); super.func_143012_a(nbt);
nbt.setBoolean("hasChest", hasPlacedChest);
} }
@Override @Override
protected void func_143011_b(NBTTagCompound nbt) { protected void func_143011_b(NBTTagCompound nbt) {
super.func_143011_b(nbt); super.func_143011_b(nbt);
this.hasPlacedChest = nbt.getBoolean("hasChest");
} }
/** /**
@ -50,7 +55,7 @@ public class ComponentNTMFeatures {
@Override @Override
public boolean addComponentParts(World world, Random rand, StructureBoundingBox box) { public boolean addComponentParts(World world, Random rand, StructureBoundingBox box) {
/* /*
* Places block at current position. Dependent on coordinate mode, i.e. will allow for random rotation * Places block at current position. Dependent on coordinate mode, i.e. will allow for random rotation, so use this instead of setBlock!
* this.placeBlockAtCurrentPosition(world, block, minX, metadata, x, y, z, box); * this.placeBlockAtCurrentPosition(world, block, minX, metadata, x, y, z, box);
* Fills an area with air, self-explanatory. * Fills an area with air, self-explanatory.
* this.fillWithAir(world, box, minX, minY, minZ, maxX, maxY, maxZ); * this.fillWithAir(world, box, minX, minY, minZ, maxX, maxY, maxZ);
@ -61,32 +66,62 @@ public class ComponentNTMFeatures {
* Fills an area with randomized blocks, self-explanatory. * Fills an area with randomized blocks, self-explanatory.
* this.fillWithRandomizedBlocks(world, box, minX, minY, minZ, maxX, maxY, maxZ, alwaysReplace, rand, StructureComponent.blockSelector); * this.fillWithRandomizedBlocks(world, box, minX, minY, minZ, maxX, maxY, maxZ, alwaysReplace, rand, StructureComponent.blockSelector);
* (BlockSelector is basically a list of blocks that can be randomly picked, except that it can actually be weighted) * (BlockSelector is basically a list of blocks that can be randomly picked, except that it can actually be weighted)
* Replaces any air or water blocks with this block down to a certain y. Useful for foundations * Replaces any air or water blocks with this block down. Useful for foundations
* this.func_151554_b(world, block, metadata, x, fillDownToY, z, box * this.func_151554_b(world, block, metadata, x, startAtY, z, box
* Fills an area with blocks randomly - look into randLimit? * Fills an area with blocks randomly - look into randLimit?
* this.randomlyFillWithBlocks(world, box, rand, randLimit, minX, minY, minZ, maxX, maxY, maxZ, blockToPlace, blockToReplace, alwaysReplace); * this.randomlyFillWithBlocks(world, box, rand, randLimit, minX, minY, minZ, maxX, maxY, maxZ, blockToPlace, blockToReplace, alwaysReplace);
*/ */
//TODO: func_74935_a is suspect. It seems to be necessary to prevent the structure from spawning at y 0, but it also prevents all spawns. System.out.println("" + this.boundingBox.minX + ", " + this.boundingBox.minY + ", " + this.boundingBox.minZ);
//System.out.println("" + this.boundingBox.minX + ", " + this.boundingBox.minY + ", " + this.boundingBox.minZ);
if(!this.func_74935_a(world, box, this.boundingBox.minY)) { if(!this.func_74935_a(world, box, this.boundingBox.minY)) {
return false; return false;
} }
//System.out.println("Hpos: " + this.hpos + "; minY:" + this.boundingBox.minY); //System.out.println("Hpos: " + this.hpos + "; minY:" + this.boundingBox.minY);
for(byte i = 0; i < scatteredFeatureSizeX; i++) { for(byte i = 0; i < this.featureSizeX + 1; i++) {
for(byte j = 0; j < scatteredFeatureSizeZ; j++) { for(byte j = 0; j < this.featureSizeZ + 1; j++) {
this.func_151554_b(world, Blocks.sandstone, 0, i, -1, j, box); this.func_151554_b(world, Blocks.sandstone, 0, i, -1, j, box);
} }
} }
this.fillWithBlocks(world, box, 0, 0, 0, scatteredFeatureSizeX, 0, scatteredFeatureSizeZ, Blocks.sandstone, Blocks.air, false); //this.fillWithBlocks(world, box, 0, 0, 0, scatteredFeatureSizeX, 0, scatteredFeatureSizeZ, Blocks.sandstone, Blocks.air, false);
this.fillWithRandomizedBlocks(world, box, 0, 1, 0, scatteredFeatureSizeX, 3, 0, false, rand, RandomSandstone); System.out.print(this.coordBaseMode);
this.fillWithRandomizedBlocks(world, box, 0, 1, 0, 0, 2, scatteredFeatureSizeZ, false, rand, RandomSandstone); //Walls
this.fillWithRandomizedBlocks(world, box, 0, 1, scatteredFeatureSizeZ, scatteredFeatureSizeX, 2, 0, false, rand, RandomSandstone); this.fillWithRandomizedBlocks(world, box, 0, 0, 0, featureSizeX, 0, 0, false, rand, RandomSandstone); //Back Wall
this.fillWithRandomizedBlocks(world, box, 0, 1, 0, 1, 1, 0, false, rand, RandomSandstone);
this.placeBlockAtCurrentPosition(world, Blocks.fence, 0, 2, 1, 0, box);
this.fillWithRandomizedBlocks(world, box, 3, 1, 0, 5, 1, 0, false, rand, RandomSandstone);
this.placeBlockAtCurrentPosition(world, Blocks.fence, 0, 6, 1, 0, box);
this.placeBlockAtCurrentPosition(world, Blocks.fence, 0, 7, 1, 0, box);
this.fillWithRandomizedBlocks(world, box, featureSizeX - 1, 1, 0, featureSizeX, 1, 0, false, rand, RandomSandstone);
this.fillWithRandomizedBlocks(world, box, 0, 2, 0, featureSizeX - 2, 2, 0, false, rand, RandomSandstone);
this.fillWithRandomizedBlocks(world, box, 0, 0, 0, 0, 1, featureSizeZ, false, rand, RandomSandstone); //Left Wall
this.placeBlockAtCurrentPosition(world, Blocks.stone_slab, 1, 0, 2, 1, box);
this.fillWithMetadataBlocks(world, box, 0, 2, 3, 0, 2, featureSizeZ, Blocks.stone_slab, 1, Blocks.air, 0, false);
this.fillWithRandomizedBlocks(world, box, 1, 0, featureSizeZ, 1, 1, featureSizeZ, false, rand, RandomSandstone); //Front Wall
this.fillWithRandomizedBlocks(world, box, 3, 0, featureSizeZ, featureSizeX, 1, featureSizeZ, false, rand, RandomSandstone);
this.fillWithRandomizedBlocks(world, box, 1, 2, featureSizeZ, 3, 2, featureSizeZ, false, rand, RandomSandstone);
this.fillWithMetadataBlocks(world, box, 4, 2, featureSizeZ, 5, 2, featureSizeZ, Blocks.stone_slab, 1, Blocks.air, 0, false);
this.placeBlockAtCurrentPosition(world, Blocks.stone_slab, 1, featureSizeX - 2, 2, featureSizeZ, box);
this.fillWithRandomizedBlocks(world, box, featureSizeX, 0, 0, featureSizeX, 0, featureSizeZ, false, rand, RandomSandstone); //Right Wall
this.randomlyFillWithBlocks(world, box, rand, 0.65F, featureSizeX, 1, 1, featureSizeX, 1, featureSizeZ - 1, Blocks.sand, Blocks.air, false);
//System.out.println("Successful spawn"); this.fillWithRandomizedBlocks(world, box, 4, 0, 1, 4, 1, 3, false, rand, RandomSandstone);
this.placeBlockAtCurrentPosition(world, ModBlocks.reinforced_sand, 0, 4, 0, 4, box);
//Loot/Sand
this.placeBlockAtCurrentPosition(world, ModBlocks.crate_weapon, 0, 1, 0, 1, box);
if(!this.hasPlacedChest)
this.hasPlacedChest = this.generateStructureChestContents(world, box, rand, 3, 0, 1, HbmChestContents.getLoot(1), rand.nextInt(2) + 8); //Make sure to redo that class kek
this.fillWithBlocks(world, box, 5, 0, 1, 6, 0, 1, ModBlocks.crate, Blocks.air, false);
this.placeBlockAtCurrentPosition(world, Blocks.sand, 0, 7, 0, 1, box);
if(rand.nextFloat() <= 0.075)
this.placeBlockAtCurrentPosition(world, ModBlocks.crate_metal, 0, 7, 0, featureSizeX - 2, box);
this.randomlyFillWithBlocks(world, box, rand, 0.25F, 1, 0, 2, 3, 0, featureSizeZ - 1, Blocks.sand, Blocks.air, false);
this.randomlyFillWithBlocks(world, box, rand, 0.25F, 5, 0, 2, featureSizeX - 1, 0, featureSizeZ - 1, Blocks.sand, Blocks.air, false);
System.out.println("Successful spawn");
return true; return true;
} }
@ -100,58 +135,61 @@ public class ComponentNTMFeatures {
/** Selects blocks */ /** Selects blocks */
@Override @Override
public void selectBlocks(Random rand, int p_75062_2_, int p_75062_3_, int p_75062_4_, boolean p_75062_5_) { public void selectBlocks(Random rand, int p_75062_2_, int p_75062_3_, int p_75062_4_, boolean p_75062_5_) {
if(rand.nextFloat() < 0.6F) { float chance = rand.nextFloat();
this.field_151562_a = Blocks.sandstone;
} else if (rand.nextFloat() < 0.4F ) {
this.field_151562_a = ModBlocks.reinforced_sand;
}
this.field_151562_a = Blocks.sand; if(chance > 0.6F) {
this.field_151562_a = Blocks.sandstone;
} else if (chance < 0.5F ) {
this.field_151562_a = ModBlocks.reinforced_sand;
} else {
this.field_151562_a = Blocks.sand;
}
} }
} }
abstract static class Feature extends StructureComponent { abstract static class Feature extends StructureComponent {
/** The size of the bounding box for this feature in the X axis */ /** The size of the bounding box for this feature in the X axis */
protected int scatteredFeatureSizeX; protected int featureSizeX;
/** The size of the bounding box for this feature in the Y axis */ /** The size of the bounding box for this feature in the Y axis */
protected int scatteredFeatureSizeY; protected int featureSizeY;
/** The size of the bounding box for this feature in the Z axis */ /** The size of the bounding box for this feature in the Z axis */
protected int scatteredFeatureSizeZ; protected int featureSizeZ;
/** Average height? */ /** Average height? */
protected int hpos = -1; protected int hpos = -1;
protected Feature(Random rand, int minX, int minY, int minZ, int maxX, int maxY, int maxZ ) { protected Feature(Random rand, int minX, int minY, int minZ, int maxX, int maxY, int maxZ ) {
super(0); super(0);
this.scatteredFeatureSizeX = maxX; this.featureSizeX = maxX;
this.scatteredFeatureSizeY = maxY; this.featureSizeY = maxY;
this.scatteredFeatureSizeZ = maxZ; this.featureSizeZ = maxZ;
this.coordBaseMode = rand.nextInt(4); this.coordBaseMode = rand.nextInt(4);
switch(this.coordBaseMode) { switch(this.coordBaseMode) {
case 0:
case 2: case 2:
this.boundingBox = new StructureBoundingBox(minX, minY, minZ, minX + maxX - 1, minY + maxY - 1, minZ + maxZ - 1); //TODO: Temporary fix. For whatever reason, North (2) and East (3) seems to improperly mirror structures, but not having it will mess North up; must look into.
this.boundingBox = new StructureBoundingBox(minX, minY, minZ, minX + maxZ - 1, minY + maxY - 1, minZ + maxX - 1);
break; break;
default: default:
this.boundingBox = new StructureBoundingBox(minX, minY, minZ, minX + maxZ - 1, minY + maxY - 1, minZ + maxX - 1); this.boundingBox = new StructureBoundingBox(minX, minY, minZ, minX + maxX - 1, minY + maxY - 1, minZ + maxZ - 1);
} }
} }
/** Set to NBT */ /** Set to NBT */
protected void func_143012_a(NBTTagCompound nbt) { protected void func_143012_a(NBTTagCompound nbt) {
nbt.setInteger("Width", this.scatteredFeatureSizeX); nbt.setInteger("Width", this.featureSizeX);
nbt.setInteger("Height", this.scatteredFeatureSizeY); nbt.setInteger("Height", this.featureSizeY);
nbt.setInteger("Depth", this.scatteredFeatureSizeZ); nbt.setInteger("Depth", this.featureSizeZ);
nbt.setInteger("HPos", this.hpos); nbt.setInteger("HPos", this.hpos);
} }
/** Get from NBT */ /** Get from NBT */
protected void func_143011_b(NBTTagCompound nbt) { protected void func_143011_b(NBTTagCompound nbt) {
this.scatteredFeatureSizeX = nbt.getInteger("Width"); this.featureSizeX = nbt.getInteger("Width");
this.scatteredFeatureSizeY = nbt.getInteger("Height"); this.featureSizeY = nbt.getInteger("Height");
this.scatteredFeatureSizeZ = nbt.getInteger("Depth"); this.featureSizeZ = nbt.getInteger("Depth");
this.hpos = nbt.getInteger("HPos"); this.hpos = nbt.getInteger("HPos");
} }

View File

@ -13,6 +13,7 @@ import scala.actors.threadpool.Arrays;
public class MapGenNTMFeatures extends MapGenStructure { public class MapGenNTMFeatures extends MapGenStructure {
//TODO: Figure out why structures spawn so close to eachother. Occasionally, four will spawn in the same orientation and position within a chunk of eachother.
private static List biomelist = Arrays.asList(new BiomeGenBase[] {BiomeGenBase.ocean, BiomeGenBase.river, BiomeGenBase.frozenOcean, BiomeGenBase.frozenRiver, BiomeGenBase.deepOcean}); private static List biomelist = Arrays.asList(new BiomeGenBase[] {BiomeGenBase.ocean, BiomeGenBase.river, BiomeGenBase.frozenOcean, BiomeGenBase.frozenRiver, BiomeGenBase.deepOcean});
/** Maximum distance between structures */ /** Maximum distance between structures */
private int maxDistanceBetweenScatteredFeatures; private int maxDistanceBetweenScatteredFeatures;
@ -20,8 +21,8 @@ public class MapGenNTMFeatures extends MapGenStructure {
private int minDistanceBetweenScatteredFeatures; private int minDistanceBetweenScatteredFeatures;
public MapGenNTMFeatures() { public MapGenNTMFeatures() {
this.maxDistanceBetweenScatteredFeatures = 16; this.maxDistanceBetweenScatteredFeatures = 24;
this.minDistanceBetweenScatteredFeatures = 6; this.minDistanceBetweenScatteredFeatures = 8;
} }
/** String ID for this MapGen */ /** String ID for this MapGen */