A while ago, Jeb posted the very first image of strongholds, And they seem to generate on the surface and fitting really good with the terrain. I tried modding it, but I never got them to fit that good into the terrain like the image, so I was wondering if anyone has the skills to do it?
If you look closely at the surface levels blocks of the structure, it appears to have generated such that only solid terrain blocks were replaced by the structure and nothing was placed above the initial surface level. This could be implemented by means of a custom structure iterator that ignores air and only replaces existing solid blocks. An offset to start generating a few blocks below the surface level would also be needed.
Safe to say, I can't think of any well known mods that generate structures this way, so there is an untapped novelty here.
If you look closely at the surface levels blocks of the structure, it appears to have generated such that only solid terrain blocks were replaced by the structure and nothing was placed above the initial surface level. This could be implemented by means of a custom structure iterator that ignores air and only replaces existing solid blocks. An offset to start generating a few blocks below the surface level would also be needed.
Safe to say, I can't think of any well known mods that generate structures this way, so there is an untapped novelty here.
This is pretty much how the game used to (I don't play newer versions, only 1.6.4) generate strongholds, at least the walls, which only replaced non-air blocks (though anything inside, like chests, bookshelves, etc, as well as the entire portal room, were always placed, as seen on a Superflat world; with a few changes all blocks above sea level could be made to only replace non-air blocks (below sea level only walls would be affected), aside from the all-important portal room, which could be made to always be below sea level by adding a check for the altitude when it comes to add the piece).
I'd assume that the code for Beta 1.8 is essentially the same as that for 1.6.4 so any of those versions can be used in a backport mod (1.6.4 added structure saving, which is not necessary for strongholds (or if you never plan to update, it ensures that e.g. eyes of ender and any structure-specific mobs continue to find/spawn in old structures if they change locations), though for most of the structure classes it is just a couple methods); for example, I made strongholds always replace blocks by overriding the following methods, with one method shown to indicate what the overridden flag value does (note that not every method used to place blocks has such a check so you'd need to override them with custom code):
abstract class ComponentStronghold extends StructureComponent
{
// Allows strongholds to generate underwater
protected boolean isLiquidInStructureBoundingBox(World par1World, StructureBoundingBox par2StructureBoundingBox)
{
return false;
}
// The following 5 methods are overridden to set the "don't overwrite air" flag to false
protected void fillWithBlocks(World par1World, StructureBoundingBox par2StructureBoundingBox, int par3, int par4, int par5, int par6, int par7, int par8, int par9, int par10, boolean par11)
{
super.fillWithBlocks(par1World, par2StructureBoundingBox, par3, par4, par5, par6, par7, par8, par9, par10, false);
}
protected void fillWithMetadataBlocks(World par1World, StructureBoundingBox par2StructureBoundingBox, int par3, int par4, int par5, int par6, int par7, int par8, int par9, int par10, int par11, int par12, boolean par13)
{
super.fillWithMetadataBlocks(par1World, par2StructureBoundingBox, par3, par4, par5, par6, par7, par8, par9, par10, par11, par12, false);
}
protected void fillWithRandomizedBlocks(World par1World, StructureBoundingBox par2StructureBoundingBox, int par3, int par4, int par5, int par6, int par7, int par8, boolean par9, Random par10Random, StructurePieceBlockSelector par11StructurePieceBlockSelector)
{
super.fillWithRandomizedBlocks(par1World, par2StructureBoundingBox, par3, par4, par5, par6, par7, par8, false, par10Random, par11StructurePieceBlockSelector);
}
protected void randomlyFillWithBlocks(World par1World, StructureBoundingBox par2StructureBoundingBox, Random par3Random, float par4, int par5, int par6, int par7, int par8, int par9, int par10, int par11, int par12, boolean par13)
{
super.randomlyFillWithBlocks(par1World, par2StructureBoundingBox, par3Random, par4, par5, par6, par7, par8, par9, par10, par11, par12, false);
}
protected void randomlyRareFillWithBlocks(World par1World, StructureBoundingBox par2StructureBoundingBox, int par3, int par4, int par5, int par6, int par7, int par8, int par9, boolean par10)
{
super.randomlyRareFillWithBlocks(par1World, par2StructureBoundingBox, par3, par4, par5, par6, par7, par8, par9, false);
}
}
public abstract class StructureComponent
{
/**
* arguments: (World worldObj, StructureBoundingBox structBB, int minX, int minY, int minZ, int maxX, int maxY, int
* maxZ, int placeBlockId, int replaceBlockId, boolean alwaysreplace)
*/
protected void fillWithBlocks(World par1World, StructureBoundingBox par2StructureBoundingBox, int par3, int par4, int par5, int par6, int par7, int par8, int par9, int par10, boolean par11)
{
for (int var12 = par4; var12 <= par7; ++var12)
{
for (int var13 = par3; var13 <= par6; ++var13)
{
for (int var14 = par5; var14 <= par8; ++var14)
{
if (!par11 || this.getBlockIdAtCurrentPosition(par1World, var13, var12, var14, par2StructureBoundingBox) != 0)
{
if (var12 != par4 && var12 != par7 && var13 != par3 && var13 != par6 && var14 != par5 && var14 != par8)
{
this.placeBlockAtCurrentPosition(par1World, par10, 0, var13, var12, var14, par2StructureBoundingBox);
}
else
{
this.placeBlockAtCurrentPosition(par1World, par9, 0, var13, var12, var14, par2StructureBoundingBox);
}
}
}
}
}
}
}
(note that the MCP comment is incorrect; "alwaysreplace" is set to false, not true, if you always want to replace blocks)
This is the method the game uses to set the altitude of an underground structure (mineshafts and strongholds) and how I modified it; by default the last parameter is set to 10, resulting in a maximum altitude of y=53 (or 52 due to nextInt(n) returning n - 1. Structures can also possibly go higher if they are tall enough; there are a few known seeds with surface strongholds, such as "Dossier"):
public abstract class StructureStart
{
protected void markAvailableHeight(World par1World, Random par2Random, int par3)
{
int var4 = 63 - par3;
int var5 = this.boundingBox.getYSize() + 1;
if (var5 < var4)
{
var5 += par2Random.nextInt(var4 - var5);
}
int var6 = var5 - this.boundingBox.maxY;
this.boundingBox.offset(0, var6, 0);
Iterator var7 = this.components.iterator();
while (var7.hasNext())
{
StructureComponent var8 = (StructureComponent)var7.next();
var8.getBoundingBox().offset(0, var6, 0);
}
}
}
// This is how I modified it in my "triple height terrain" mod to get mineshafts to generate higher up; if the offset is set
// to 0 then the maximum altitude is sea level and if it is negative it is higher (63 - -90 = 153)
int offset = (par1World.getWorldInfo().getTerrainType() == WorldType.THT ? -45 - par2Random.nextInt(2) * 45 : 10);
this.markAvailableHeight(par1World, par2Random, offset);
// This is how I set the altitude of mesa mineshafts in TMCW, which always generate above sea level (the vanilla method
// randomly offsets them up to the max so they may not be at the surface)
private static final int NORMAL_MINESHAFT_ALTITUDE = 53;
private static final int MESA_MINESHAFT_ALTITUDE = 68;
protected void markAvailableHeight(Random64 par2Random, boolean isSurfaceMesa)
{
int var6;
// Surface mesa mineshafts use the same method 1.10 uses for mesa mineshafts to set the y-offset
if (isSurfaceMesa)
{
var6 = MESA_MINESHAFT_ALTITUDE - this.boundingBox.maxY + this.boundingBox.getYSize() / 2;
}
else
{
// Normal mineshafts
int var5 = this.boundingBox.getYSize() + 1;
if (var5 < NORMAL_MINESHAFT_ALTITUDE) var5 += par2Random.nextInt(NORMAL_MINESHAFT_ALTITUDE - var5);
var6 = var5 - this.boundingBox.maxY;
}
this.boundingBox.offset(0, var6, 0);
Iterator var7 = this.components.iterator();
while (var7.hasNext())
{
MineshaftComponent var8 = (MineshaftComponent)var7.next();
var8.offset(0, var6, 0);
}
}
To ensure that portal rooms never generate above sea level you can add a check to the following method, returning null if the top of the bounding box is above sea level (if the game fails to add a portal room by the time the whole structure has been built it will recreate it from scratch until one has been added):
I added "var7.maxY < seaLevel", where seaLevel would be the desired height limit (might be configurable instead of a hard limit; be sure that it is not set as to cause an infinite loop due to never being able to add one):
public class ComponentStrongholdPortalRoom extends ComponentStronghold
{
public static ComponentStrongholdPortalRoom findValidPlacement(List par0List, Random par1Random, int par2, int par3, int par4, int par5, int par6)
{
StructureBoundingBox var7 = StructureBoundingBox.getComponentToAddBoundingBox(par2, par3, par4, -4, -1, 0, 11, 8, 16, par5);
return var7.maxY < seaLevel && canStrongholdGoDeeper(var7) && StructureComponent.findIntersecting(par0List, var7) == null ? new ComponentStrongholdPortalRoom(par6, par1Random, var7, par5) : null;
}
}
Few months ago I tried exactly the thing you described. But there are more things to it. The room itself should generate deeper into the ground, and only the walls try to fit with the terrain. Also backporting strongholds was impossible and I tried it multiple times, I can never get it to work. I never found out how to make the room to sink into the ground while walls to stand with the terrain noisemap.
A while ago, Jeb posted the very first image of strongholds, And they seem to generate on the surface and fitting really good with the terrain. I tried modding it, but I never got them to fit that good into the terrain like the image, so I was wondering if anyone has the skills to do it?
https://external-preview.redd.it/nHMGP8P4mTkJueA5Zs4otrbsD5u6UfafV64pgtmCgDY.jpg?auto=webp&s=3962675b53649693168d6436be22b225b7333656
If you look closely at the surface levels blocks of the structure, it appears to have generated such that only solid terrain blocks were replaced by the structure and nothing was placed above the initial surface level. This could be implemented by means of a custom structure iterator that ignores air and only replaces existing solid blocks. An offset to start generating a few blocks below the surface level would also be needed.
Safe to say, I can't think of any well known mods that generate structures this way, so there is an untapped novelty here.
I second this - specially on Fabric/Quilt.
If you speak Portuguese and play Minecraft: Java Edition like me, join my rabbit hole on Discord!
This is pretty much how the game used to (I don't play newer versions, only 1.6.4) generate strongholds, at least the walls, which only replaced non-air blocks (though anything inside, like chests, bookshelves, etc, as well as the entire portal room, were always placed, as seen on a Superflat world; with a few changes all blocks above sea level could be made to only replace non-air blocks (below sea level only walls would be affected), aside from the all-important portal room, which could be made to always be below sea level by adding a check for the altitude when it comes to add the piece).
I'd assume that the code for Beta 1.8 is essentially the same as that for 1.6.4 so any of those versions can be used in a backport mod (1.6.4 added structure saving, which is not necessary for strongholds (or if you never plan to update, it ensures that e.g. eyes of ender and any structure-specific mobs continue to find/spawn in old structures if they change locations), though for most of the structure classes it is just a couple methods); for example, I made strongholds always replace blocks by overriding the following methods, with one method shown to indicate what the overridden flag value does (note that not every method used to place blocks has such a check so you'd need to override them with custom code):
(note that the MCP comment is incorrect; "alwaysreplace" is set to false, not true, if you always want to replace blocks)
This is the method the game uses to set the altitude of an underground structure (mineshafts and strongholds) and how I modified it; by default the last parameter is set to 10, resulting in a maximum altitude of y=53 (or 52 due to nextInt(n) returning n - 1. Structures can also possibly go higher if they are tall enough; there are a few known seeds with surface strongholds, such as "Dossier"):
To ensure that portal rooms never generate above sea level you can add a check to the following method, returning null if the top of the bounding box is above sea level (if the game fails to add a portal room by the time the whole structure has been built it will recreate it from scratch until one has been added):
TheMasterCaver's First World - possibly the most caved-out world in Minecraft history - includes world download.
TheMasterCaver's World - my own version of Minecraft largely based on my views of how the game should have evolved since 1.6.4.
Why do I still play in 1.6.4?
Few months ago I tried exactly the thing you described. But there are more things to it. The room itself should generate deeper into the ground, and only the walls try to fit with the terrain. Also backporting strongholds was impossible and I tried it multiple times, I can never get it to work. I never found out how to make the room to sink into the ground while walls to stand with the terrain noisemap.
Here are few images of my attempts:
As you can see it looks HORRIBLE......