Skip to content

Commit

Permalink
adjustments to allow structures to specify needed biome size
Browse files Browse the repository at this point in the history
added "needed_space" to the json format for jigsaws. This allows specifying how many blocks around the chosen location must be the correct biome. This has been implemented in the ocean village, with a distance of 32 blocks, to prevent cases of it spawning in the edge of a beach.
  • Loading branch information
Thutmose committed Dec 5, 2021
1 parent d51ba56 commit 966c55a
Show file tree
Hide file tree
Showing 4 changed files with 204,778 additions and 10 deletions.
11 changes: 11 additions & 0 deletions src/main/java/pokecube/core/database/worldgen/WorldgenHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,20 @@ private static DataResult<JigSawConfig> decodeConfig(final String encoded)
public String name;
public String root;
public int offset = 1;

// This is max depth of the structure, ie how many times it can add new
// jigsaws onto a previous part.
public int size = 4;

// These are for the rarity of the structure
public int distance = 8;
public int separation = 4;

// This defines if we need all biomes in the checked area to match. if
// this is -1, it will allow spawn if any biome matches, otherwise it
// will require all biomes to match within this number of blocks.
public int needed_space = -1;

public String type = "";
public String biomeType = "none";
public SpawnRule spawn;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ public class CustomJigsawStructure extends NoiseAffectingStructureFeature<Jigsaw
PokecubeCore.LOGGER.info("Setting spawn to {} {}, professor at {}", spos, localSpawn,
localTrader);
PokecubeSerializer.getInstance().setPlacedSpawn();
sworld.getServer().execute(() ->
{
sworld.getServer().execute(() -> {
sworld.setDefaultSpawnPos(spos, 0);
});
piece.placedSpawn = false;
Expand All @@ -121,8 +120,7 @@ public class CustomJigsawStructure extends NoiseAffectingStructureFeature<Jigsaw

public CustomJigsawStructure(final Codec<JigsawConfig> codec)
{
super(codec, (context) ->
{
super(codec, (context) -> {
JigsawConfig config = context.config();

boolean validContext = false;
Expand All @@ -132,11 +130,22 @@ public CustomJigsawStructure(final Codec<JigsawConfig> codec)
final int x = context.chunkPos().getBlockX(7);
final int z = context.chunkPos().getBlockZ(7);
final BlockPos pos = new BlockPos(x, chunkGenerator.getSeaLevel(), z);
Set<Biome> biomes = context.biomeSource().getBiomesWithin(pos.getX(), pos.getY(), pos.getZ(), 16,

int dist = context.config().struct_config.needed_space;
boolean any = dist == -1;
if (any) dist = 1;

Set<Biome> biomes = context.biomeSource().getBiomesWithin(pos.getX(), pos.getY(), pos.getZ(), dist,
chunkGenerator.climateSampler());

if (!any) validContext = !biomes.isEmpty();

for (Biome b : biomes)
{
validContext = validContext || config.struct_config._matcher.checkBiome(BiomeDatabase.getKey(b));
if (any)
validContext = validContext || config.struct_config._matcher.checkBiome(BiomeDatabase.getKey(b));
else
validContext = validContext && config.struct_config._matcher.checkBiome(BiomeDatabase.getKey(b));
}
if (!validContext)
{
Expand Down
136 changes: 136 additions & 0 deletions src/main/resources/data/pokecube_legends/structures/village_ocean.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
{
"pools": [
{
"name":"pokecube_legends:village/ocean/town_centers",
"rigid":true,
"ignoreAir":false,
"options":[
"pokecube_legends:village/ocean/town_centers/center_1;{\"extra\":{\"markers_to_air\":true}}"
]
},
{
"name":"pokecube_legends:village/ocean/town_centers/bottom_1",
"rigid":true,
"ignoreAir":false,
"options":[
"pokecube_legends:village/ocean/town_centers/bottom_1;{\"extra\":{\"markers_to_air\":true}}"
]
},
{
"name":"pokecube_legends:village/ocean/town_centers/bottom_2",
"rigid":true,
"ignoreAir":false,
"options":[
"pokecube_legends:village/ocean/town_centers/bottom_2;{\"extra\":{\"markers_to_air\":true}}"
]
},
{
"name":"pokecube_legends:village/ocean/terminators",
"rigid":true,
"options":[
"pokecube_legends:village/ocean/terminators/terminator_01"
]
},
{
"name":"pokecube_legends:village/ocean/streets",
"rigid":true,
"ignoreAir":false,
"options":[
"pokecube_legends:village/ocean/streets/road_1;{\"weight\":3,\"extra\":{\"markers_to_air\":true}}",
"pokecube_legends:village/ocean/streets/road_2;{\"weight\":5,\"extra\":{\"markers_to_air\":true}}",
"pokecube_legends:village/ocean/streets/road_close;{\"weight\":2,\"extra\":{\"markers_to_air\":true}}"
]
},
{
"name":"pokecube_legends:village/ocean/pokecenter/path",
"rigid":true,
"options":[
"pokecube_legends:village/ocean/pokecenter/path"
]
},
{
"name":"pokecube_legends:village/ocean/gym/path",
"rigid":true,
"options":[
"pokecube_legends:village/ocean/gym/path"
]
},
{
"name":"pokecube_legends:village/ocean/gym/aether_path",
"rigid":true,
"options":[
"pokecube_legends:village/ocean/gym/aether_path"
]
},
{
"name":"pokecube_legends:village/ocean/room",
"rigid":true,
"options":[
"pokecube_legends:village/ocean/room/room_1;{\"weight\":5}",
"pokecube_legends:village/ocean/room/room_2;{\"weight\":5}",
"pokecube_legends:village/ocean/room/room_3;{\"weight\":5}",
"pokecube_legends:village/ocean/room/room_4;{\"weight\":5}"
]
},
{
"name":"pokecube_legends:village/ocean/room_base",
"rigid":true,
"options":[
"pokecube_legends:village/ocean/room_base/room_1;{\"weight\":5}",
"pokecube_legends:village/ocean/room_base/room_2;{\"weight\":3}"
]
},
{
"name":"pokecube_legends:village/ocean/top",
"rigid":true,
"options":[
"pokecube_legends:village/ocean/top/aether_top_1",
"pokecube_legends:village/ocean/top/aether_top_2"
]
},
{
"name":"pokecube_legends:village/ocean/houses",
"ignoreAir":false,
"rigid":true,
"options":[
"pokecube_legends:village/ocean/houses/house_close;{\"weight\":3,\"extra\":{\"markers_to_air\":true}}",
"pokecube_legends:village/ocean/houses/house_1;{\"weight\":8,\"extra\":{\"markers_to_air\":true}}",
"pokecube_legends:village/ocean/houses/house_2;{\"weight\":8,\"extra\":{\"markers_to_air\":true}}",
"pokecube_legends:village/ocean/houses/house_3;{\"weight\":8,\"extra\":{\"markers_to_air\":true}}",
"pokecube_legends:village/ocean/houses/house_4;{\"weight\":8,\"extra\":{\"markers_to_air\":true}}",
"pokecube_legends:village/ocean/houses/house_5;{\"weight\":6,\"extra\":{\"markers_to_air\":true}}",
"pokecube_legends:village/ocean/pokecenter/center_01;{\"flag\":\"pokecenter\"}",
"pokecube_legends:village/ocean/gym/aether_base;{\"flag\":\"gym\"}"
]
}
],
"jigsaws": [
{
"name":"pokecube_legends:village/ocean",
"root":"pokecube_legends:village/ocean/town_centers",
"chance":1,
"distance":32,
"separation":12,
"size":6,
"priority":10,
"biomeType":"beach",
"base_under":false,
"needed_space": 32,
"needed_once":[
"pokecenter",
"gym"
],
"dimBlacklist":[
"the_nether",
"the_end"
],
"spawn":{
"values":{
"biomes":"warm_ocean",
"typesBlacklist":"cold",
"categoryBlacklist":"the_end,nether,icy,beach"
}
}
}
]
}
Loading

0 comments on commit 966c55a

Please sign in to comment.