UtilityBiome:Structures: Difference between revisions
UtilityBiome wiki |
UtilityBiome wiki |
||
| Line 21: | Line 21: | ||
</pre> | </pre> | ||
* <code>width()</code>, <code>height()</code>, <code>depth()</code>: size in x, y and z. | * <code>width()</code>, <code>height()</code>, <code>depth()</code>: size in x, y and z. | ||
* <code>cells()</code>: all blocks with their position relative to the corner (0, 0, 0). | * <code>cells()</code>: all blocks with their position relative to the corner (0, 0, 0). Each cell also carries its drop list (for loot containers) and its <code>Connected</code> family (for fences, walls and bars), or <code>null</code>. | ||
* <code>rotated(quarterTurns)</code>: rotated by 90° steps clockwise (seen from above), corner back at (0, 0). | * <code>rotated(quarterTurns)</code>: rotated by 90° steps clockwise (seen from above), corner back at (0, 0). Since 1.1.0 a rotation in the block key (such as <code>Yaw=90</code>) is turned with the positions, so stairs, doors and furniture keep facing the right way. In 1.0.0 only the positions turned. | ||
* A character that is not in the palette, or a blueprint without layers, throws when you call <code>build()</code>. | * A character that is not in the palette, or a blueprint without layers, throws when you call <code>build()</code>. | ||
=== Loot containers === | |||
Since 1.1.0. <code>loot(symbol, block, dropList)</code> puts a container into the palette that is filled from a drop list (<code>Server/Drops/...</code>, vanilla or your own): | |||
<pre> | |||
Blueprint camp = Blueprint.builder() | |||
.palette('W', "Wood_Softwood_Planks") | |||
.loot('C', "Furniture_Ancient_Chest_Small", "Zone1_Undead_Tier1") | |||
.layer("WWW", "WWW", "WWW") | |||
.layer(" C ", " ", " ") | |||
.build(); | |||
</pre> | |||
The content is rolled once, when the chunk is first loaded, the same way as in vanilla structures. The block must be a container (chest, barrel, pot ...). Any other block throws when the structure is placed, so nothing of it is applied. In your own placer the same is done with <code>ChunkAccess.setContainer</code> (see [[UtilityBiome:Chunk Features|Chunk Features]]). | |||
=== Fences, walls and bars === | |||
Since 1.1.0. <code>connected(symbol, family)</code> puts a fence, wall or bars into the palette whose shape follows from its neighbours. Draw them as one character, and Utility Biome picks the straight piece, corner, T junction or crossing with the right rotation. This is done again after every rotation of the blueprint. | |||
<pre> | |||
Blueprint pen = Blueprint.builder() | |||
.connected('F', Connected.fence("Wood_Softwood_Fence")) | |||
.layer("FFFF", "F F", "FFFF") | |||
.build(); | |||
</pre> | |||
{| class="wikitable" | |||
! Family !! Use | |||
|- | |||
| <code>Connected.fence(fence)</code> || A vanilla fence, for example <code>"Wood_Softwood_Fence"</code>. Corner, T and cross are states of the fence block. | |||
|- | |||
| <code>Connected.IRON_BARS</code> || Vanilla iron bars, with the corner as its own block. | |||
|- | |||
| <code>new Connected(straight, corner, tJunction, cross, anchors)</code> || Your own family from four block keys. | |||
|- | |||
| <code>family.anchoredTo(blocks...)</code> || The same family that also connects to other blocks, for example a post or a gravestone. | |||
|} | |||
* Only neighbours in the same layer and of the same family (or an anchor block) count. | |||
* A piece with one neighbour or none becomes a straight piece, pointing to the neighbour or east-west. | |||
== StructureFeature == | == StructureFeature == | ||
Latest revision as of 19:25, 10 November 2026
The package com.cyberpiratepenguin.utilitybiome.api.structure places small buildings and shapes with chunk features, without writing a placer from scratch.
Blueprint: a building described as text.StructureFeature: turns a blueprint into a chunk feature. Finding a site, rotation and foundation are handled for you.Structures,Shapes,Terrain: the building blocks, for your own placers.
A chunk feature only sees and writes its own chunk (32 × 32 blocks), so a structure has to fit into one chunk. For ready-made prefab files placed as rare structures through world-generation files, use ResourceSpec.prefabs on Build-Time Tools.
Blueprint
A blueprint is a stack of layers, bottom layer first. Each layer is a list of rows along z, each character in a row is one block along x, looked up in the palette.
- A space leaves the existing block unchanged.
- A dot
.sets air, for example to clear the inside of a hut.
Blueprint hut = Blueprint.builder()
.palette('W', "Wood_Softwood_Planks")
.palette('R', "Wood_Softwood_Roof")
.layer("WWW", "W.W", "WWW")
.layer("WWW", "W.W", "W W")
.layer("RRR", "RRR", "RRR")
.build();
width(),height(),depth(): size in x, y and z.cells(): all blocks with their position relative to the corner (0, 0, 0). Each cell also carries its drop list (for loot containers) and itsConnectedfamily (for fences, walls and bars), ornull.rotated(quarterTurns): rotated by 90° steps clockwise (seen from above), corner back at (0, 0). Since 1.1.0 a rotation in the block key (such asYaw=90) is turned with the positions, so stairs, doors and furniture keep facing the right way. In 1.0.0 only the positions turned.- A character that is not in the palette, or a blueprint without layers, throws when you call
build().
Loot containers
Since 1.1.0. loot(symbol, block, dropList) puts a container into the palette that is filled from a drop list (Server/Drops/..., vanilla or your own):
Blueprint camp = Blueprint.builder()
.palette('W', "Wood_Softwood_Planks")
.loot('C', "Furniture_Ancient_Chest_Small", "Zone1_Undead_Tier1")
.layer("WWW", "WWW", "WWW")
.layer(" C ", " ", " ")
.build();
The content is rolled once, when the chunk is first loaded, the same way as in vanilla structures. The block must be a container (chest, barrel, pot ...). Any other block throws when the structure is placed, so nothing of it is applied. In your own placer the same is done with ChunkAccess.setContainer (see Chunk Features).
Fences, walls and bars
Since 1.1.0. connected(symbol, family) puts a fence, wall or bars into the palette whose shape follows from its neighbours. Draw them as one character, and Utility Biome picks the straight piece, corner, T junction or crossing with the right rotation. This is done again after every rotation of the blueprint.
Blueprint pen = Blueprint.builder()
.connected('F', Connected.fence("Wood_Softwood_Fence"))
.layer("FFFF", "F F", "FFFF")
.build();
| Family | Use |
|---|---|
Connected.fence(fence) |
A vanilla fence, for example "Wood_Softwood_Fence". Corner, T and cross are states of the fence block.
|
Connected.IRON_BARS |
Vanilla iron bars, with the corner as its own block. |
new Connected(straight, corner, tJunction, cross, anchors) |
Your own family from four block keys. |
family.anchoredTo(blocks...) |
The same family that also connects to other blocks, for example a post or a gravestone. |
- Only neighbours in the same layer and of the same family (or an anchor block) count.
- A piece with one neighbour or none becomes a straight piece, pointing to the neighbour or east-west.
StructureFeature
UtilityBiomeAPI.registerChunkFeature(
StructureFeature.of("mymod:hut", hut)
.inBiomes("Zone1_Tier2/Tile.Plains_*")
.chance(0.02)
.foundation("Rock_Stone_Cobble")
.build());
| Setting | Default | Meaning |
|---|---|---|
inBiomes(globs...) |
all biomes | Same globs as for chunk features. |
chance(p) |
0.05 | Share of matching chunks that try to place the structure. |
order(n) |
10 | Run order among all chunk features. |
maxSlope(blocks) |
2 | Largest height difference allowed on the site. |
margin(blocks) |
3 | Distance to the chunk border and to anything built. |
sink(blocks) |
0 | How deep the structure is set into the ground. |
noRotation() |
rotate | Turns off the random rotation. |
allowNearBuildings() |
avoid | Also allow sites in or next to built things, for example for additions to ruins. |
airOnly() |
off | Only place blocks into air, so the terrain stays (half-buried ruins). |
foundation(block) |
natural | Fills below the bottom layer down to the ground with this block. |
What happens in each chunk:
- The blueprint is rotated at random (unless
noRotation()). - A flat site is searched: natural ground, no water, the slope within
maxSlope,marginblocks away from the chunk border and, unless allowed, from anything built or a settlement biome. If there is none, nothing is placed. - The blueprint is placed on the highest ground block of the site, lowered by
sink. - Below the bottom layer a foundation is filled down to the ground, at most 24 blocks: with the
foundationblock if set, otherwise with the natural ground block of each column (grass becomes dirt). Withsinkabove 0 and nofoundationblock, no foundation is added.
Structures
The steps above, for use in your own placer:
| Method | Purpose |
|---|---|
findFlatSite(chunk, width, depth, maxSlope, margin, avoidBuildings, random) |
A random suitable site (as Site(x, y, z), y = ground height), or empty.
|
fits(blueprint, x, y, z) |
Whether the blueprint fits into the chunk at that corner. |
place(chunk, blueprint, x, y, z, airOnly) |
Places the blueprint. Throws if it does not fit, which in a chunk feature means nothing is applied. |
naturalFoundation(chunk, blueprint, x, y, z) |
Foundation from the ground block of each column. |
foundation(chunk, blueprint, x, y, z, block) |
Foundation from a given block. |
Shapes
Basic shapes in chunk coordinates. Parts outside the chunk are skipped. With airOnly only air is replaced. Each method returns the number of blocks set.
| Method | Shape |
|---|---|
box(chunk, x0, y0, z0, x1, y1, z1, block, airOnly) |
Solid box, corners included. |
hollowBox(chunk, x0, y0, z0, x1, y1, z1, block) |
Walls, floor and ceiling of block, air inside.
|
ellipsoid(chunk, cx, cy, cz, rx, ry, rz, block, airOnly) |
Ellipsoid around a centre. |
cylinder(chunk, cx, y0, cz, y1, radius, block, airOnly) |
Upright cylinder. |
foundation(chunk, x, fromY, z, block) |
Fills downwards until the first solid block, at most 24 blocks. |
clearPlantAbove(chunk, x, y, z) |
Removes a plant, grass or bush above a block, so it does not float after digging. |
inside(x, y, z) |
Whether a position lies inside the chunk. |
Terrain
Hytale does not remember after generation where prefabs were placed, so Utility Biome recognises built things by their block names.
| Method | Purpose |
|---|---|
isNatural(block) |
Rock (except crystals) or soil, and nothing built. |
isBuilt(block) |
The block name contains a part such as Brick, Cobble, Plank, Stairs, Roof, Fence, Lantern, Chest, Furniture and similar. |
isSettlementBiome(name) |
The biome name contains Village, Town, City, Cities, Camp or Outpost. |
ground(chunk, x, z) |
Highest natural ground block of the column. Leaves, plants and built blocks do not count. |
nearBuilding(chunk, minX, minY, minZ, maxX, maxY, maxZ) |
Whether anything built stands in the box, or a corner of it lies in a settlement biome. |
Built things just across the chunk border cannot be seen, which is why a margin to the border is useful.