AbandonedCampStructurePools .java

net.minecraft.data.worldgen.AbandonedCampStructurePools (class): members: CAMP_DEFAULT_IDENTIFIER_TEMPLATE, NUM_OF_BIOME_SPECIFIC_CAMPSITES, NUM_OF_TENTS.

net.minecraft.data.worldgenclass226 linescommon12.0 KB

API Surface (2)

void bootstrap(final BootstrapContext<StructureTemplatePool> context)
record AbandonedCampStructure(ResourceKey<StructureTemplatePool> campStructureDirectory, ResourceKey<StructureTemplatePool> tentStructureDirectory, String name)

Fields & Constants (30)

BAMBOO_JUNGLE
BIRCH_FOREST
CHERRY_GROVE
DAPPLED_FOREST
FLOWER_FOREST
FOREST
MEADOW
OLD_GROWTH_BIRCH_FOREST
OLD_GROWTH_PINE_TAIGA
OLD_GROWTH_SPRUCE_TAIGA
PALE_GARDEN
SAVANNA
SNOWY_TAIGA
SPARSE_JUNGLE
SWAMP
TAIGA
WINDSWEPT_FOREST
WOODED_BADLANDS
TENT_IDENTIFIER_TEMPLATE
CAMP_BIOME_IDENTIFIER_TEMPLATE
CAMP_DEFAULT_IDENTIFIER_TEMPLATE
NUM_OF_BIOME_SPECIFIC_CAMPSITES
NUM_OF_DEFAULT_CAMPSITES
NUM_OF_TENTS
BIOME_VARIANTS
DEFAULT_CAMP_TYPES
context
empty
identifierTemplate
tentStructureDirectory

String literals (78)

"abandoned_camp/camp/bamboo_jungle"
"abandoned_camp/tent/bamboo_jungle"
"bamboo_jungle"
"abandoned_camp/camp/birch_forest"
"abandoned_camp/tent/birch_forest"
"birch_forest"
"abandoned_camp/camp/cherry_grove"
"abandoned_camp/tent/cherry_grove"
"cherry_grove"
"abandoned_camp/camp/dappled_forest"
"abandoned_camp/tent/dappled_forest"
"dappled_forest"
"abandoned_camp/camp/flower_forest"
"abandoned_camp/tent/flower_forest"
"flower_forest"
"abandoned_camp/camp/forest"
"abandoned_camp/tent/forest"
"forest"
"abandoned_camp/camp/meadow"
"abandoned_camp/tent/meadow"
"meadow"
"abandoned_camp/camp/old_growth_birch_forest"
"abandoned_camp/tent/old_growth_birch_forest"
"old_growth_birch_forest"

Full Source

AbandonedCampStructurePools.java226 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.data.worldgen;
2
3
import com.google.common.collect.ImmutableList;
4
import com.mojang.datafixers.util.Pair;
5
import java.util.ArrayList;
6
import java.util.Collection;
7
import java.util.List;
8
import java.util.Locale;
9
import java.util.function.Function;
10
import net.minecraft.core.Holder;
11
import net.minecraft.core.HolderGetter;
12
import net.minecraft.core.registries.Registries;
13
import net.minecraft.data.worldgen.placement.TreePlacements;
14
import net.minecraft.data.worldgen.placement.VegetationPlacements;
15
import net.minecraft.resources.ResourceKey;
16
import net.minecraft.world.level.levelgen.placement.PlacedFeature;
17
import net.minecraft.world.level.levelgen.structure.pools.StructurePoolElement;
18
import net.minecraft.world.level.levelgen.structure.pools.StructureTemplatePool;
19
20
public class AbandonedCampStructurePools {
21
	public static final AbandonedCampStructurePools.AbandonedCampStructure BAMBOO_JUNGLE = new AbandonedCampStructurePools.AbandonedCampStructure(
22
		Pools.createKey("abandoned_camp/camp/bamboo_jungle"), Pools.createKey("abandoned_camp/tent/bamboo_jungle"), "bamboo_jungle"
23
	);
24
	public static final AbandonedCampStructurePools.AbandonedCampStructure BIRCH_FOREST = new AbandonedCampStructurePools.AbandonedCampStructure(
25
		Pools.createKey("abandoned_camp/camp/birch_forest"), Pools.createKey("abandoned_camp/tent/birch_forest"), "birch_forest"
26
	);
27
	public static final AbandonedCampStructurePools.AbandonedCampStructure CHERRY_GROVE = new AbandonedCampStructurePools.AbandonedCampStructure(
28
		Pools.createKey("abandoned_camp/camp/cherry_grove"), Pools.createKey("abandoned_camp/tent/cherry_grove"), "cherry_grove"
29
	);
30
	public static final AbandonedCampStructurePools.AbandonedCampStructure DAPPLED_FOREST = new AbandonedCampStructurePools.AbandonedCampStructure(
31
		Pools.createKey("abandoned_camp/camp/dappled_forest"), Pools.createKey("abandoned_camp/tent/dappled_forest"), "dappled_forest"
32
	);
33
	public static final AbandonedCampStructurePools.AbandonedCampStructure FLOWER_FOREST = new AbandonedCampStructurePools.AbandonedCampStructure(
34
		Pools.createKey("abandoned_camp/camp/flower_forest"), Pools.createKey("abandoned_camp/tent/flower_forest"), "flower_forest"
35
	);
36
	public static final AbandonedCampStructurePools.AbandonedCampStructure FOREST = new AbandonedCampStructurePools.AbandonedCampStructure(
37
		Pools.createKey("abandoned_camp/camp/forest"), Pools.createKey("abandoned_camp/tent/forest"), "forest"
38
	);
39
	public static final AbandonedCampStructurePools.AbandonedCampStructure MEADOW = new AbandonedCampStructurePools.AbandonedCampStructure(
40
		Pools.createKey("abandoned_camp/camp/meadow"), Pools.createKey("abandoned_camp/tent/meadow"), "meadow"
41
	);
42
	public static final AbandonedCampStructurePools.AbandonedCampStructure OLD_GROWTH_BIRCH_FOREST = new AbandonedCampStructurePools.AbandonedCampStructure(
43
		Pools.createKey("abandoned_camp/camp/old_growth_birch_forest"), Pools.createKey("abandoned_camp/tent/old_growth_birch_forest"), "old_growth_birch_forest"
44
	);
45
	public static final AbandonedCampStructurePools.AbandonedCampStructure OLD_GROWTH_PINE_TAIGA = new AbandonedCampStructurePools.AbandonedCampStructure(
46
		Pools.createKey("abandoned_camp/camp/old_growth_pine_taiga"), Pools.createKey("abandoned_camp/tent/old_growth_pine_taiga"), "old_growth_pine_taiga"
47
	);
48
	public static final AbandonedCampStructurePools.AbandonedCampStructure OLD_GROWTH_SPRUCE_TAIGA = new AbandonedCampStructurePools.AbandonedCampStructure(
49
		Pools.createKey("abandoned_camp/camp/old_growth_spruce_taiga"), Pools.createKey("abandoned_camp/tent/old_growth_spruce_taiga"), "old_growth_spruce_taiga"
50
	);
51
	public static final AbandonedCampStructurePools.AbandonedCampStructure PALE_GARDEN = new AbandonedCampStructurePools.AbandonedCampStructure(
52
		Pools.createKey("abandoned_camp/camp/pale_garden"), Pools.createKey("abandoned_camp/tent/pale_garden"), "pale_garden"
53
	);
54
	public static final AbandonedCampStructurePools.AbandonedCampStructure SAVANNA = new AbandonedCampStructurePools.AbandonedCampStructure(
55
		Pools.createKey("abandoned_camp/camp/savanna"), Pools.createKey("abandoned_camp/tent/savanna"), "savanna"
56
	);
57
	public static final AbandonedCampStructurePools.AbandonedCampStructure SNOWY_TAIGA = new AbandonedCampStructurePools.AbandonedCampStructure(
58
		Pools.createKey("abandoned_camp/camp/snowy_taiga"), Pools.createKey("abandoned_camp/tent/snowy_taiga"), "snowy_taiga"
59
	);
60
	public static final AbandonedCampStructurePools.AbandonedCampStructure SPARSE_JUNGLE = new AbandonedCampStructurePools.AbandonedCampStructure(
61
		Pools.createKey("abandoned_camp/camp/sparse_jungle"), Pools.createKey("abandoned_camp/tent/sparse_jungle"), "sparse_jungle"
62
	);
63
	public static final AbandonedCampStructurePools.AbandonedCampStructure SWAMP = new AbandonedCampStructurePools.AbandonedCampStructure(
64
		Pools.createKey("abandoned_camp/camp/swamp"), Pools.createKey("abandoned_camp/tent/swamp"), "swamp"
65
	);
66
	public static final AbandonedCampStructurePools.AbandonedCampStructure TAIGA = new AbandonedCampStructurePools.AbandonedCampStructure(
67
		Pools.createKey("abandoned_camp/camp/taiga"), Pools.createKey("abandoned_camp/tent/taiga"), "taiga"
68
	);
69
	public static final AbandonedCampStructurePools.AbandonedCampStructure WINDSWEPT_FOREST = new AbandonedCampStructurePools.AbandonedCampStructure(
70
		Pools.createKey("abandoned_camp/camp/windswept_forest"), Pools.createKey("abandoned_camp/tent/windswept_forest"), "windswept_forest"
71
	);
72
	public static final AbandonedCampStructurePools.AbandonedCampStructure WOODED_BADLANDS = new AbandonedCampStructurePools.AbandonedCampStructure(
73
		Pools.createKey("abandoned_camp/camp/wooded_badlands"), Pools.createKey("abandoned_camp/tent/wooded_badlands"), "wooded_badlands"
74
	);
75
	private static final String TENT_IDENTIFIER_TEMPLATE = "abandoned_camp/tent/%s/tent_%s_%d";
76
	private static final String CAMP_BIOME_IDENTIFIER_TEMPLATE = "abandoned_camp/camp/%s/campsite_%s_%d";
77
	private static final String CAMP_DEFAULT_IDENTIFIER_TEMPLATE = "abandoned_camp/camp/default/campsite_default_%s_%d";
78
	private static final int NUM_OF_BIOME_SPECIFIC_CAMPSITES = 4;
79
	private static final int NUM_OF_DEFAULT_CAMPSITES = 15;
80
	private static final int NUM_OF_TENTS = 10;
81
	private static final List<AbandonedCampStructurePools.AbandonedCampStructure> BIOME_VARIANTS = List.of(
82
		SAVANNA,
83
		FLOWER_FOREST,
84
		BIRCH_FOREST,
85
		FOREST,
86
		SNOWY_TAIGA,
87
		BAMBOO_JUNGLE,
88
		SPARSE_JUNGLE,
89
		CHERRY_GROVE,
90
		MEADOW,
91
		OLD_GROWTH_BIRCH_FOREST,
92
		OLD_GROWTH_SPRUCE_TAIGA,
93
		OLD_GROWTH_PINE_TAIGA,
94
		SWAMP,
95
		TAIGA,
96
		WINDSWEPT_FOREST,
97
		DAPPLED_FOREST,
98
		WOODED_BADLANDS,
99
		PALE_GARDEN
100
	);
101
	private static final List<String> DEFAULT_CAMP_TYPES = List.of("chest", "barrel", "special");
102
103
	public static void bootstrap(final BootstrapContext<StructureTemplatePool> context) {
104
		HolderGetter<StructureTemplatePool> pools = context.lookup(Registries.TEMPLATE_POOL);
105
		Holder<StructureTemplatePool> empty = pools.getOrThrow(Pools.EMPTY);
106
		bootstrapTrees(context, empty);
107
		bootstrapCampsitePools(context, empty);
108
	}
109
110
	private static void bootstrapTrees(final BootstrapContext<StructureTemplatePool> context, final Holder<StructureTemplatePool> empty) {
111
		registerTrees(
112
			context,
113
			empty,
114
			ImmutableList.of(
115
				Pair.of("acacia", TreePlacements.ACACIA_CHECKED),
116
				Pair.of("birch", TreePlacements.BIRCH_CHECKED),
117
				Pair.of("fancy_oak", TreePlacements.FANCY_OAK_CHECKED),
118
				Pair.of("oak", TreePlacements.OAK_CHECKED),
119
				Pair.of("spruce", TreePlacements.SPRUCE_CHECKED),
120
				Pair.of("thick_spruce", TreePlacements.MEGA_SPRUCE_CHECKED),
121
				Pair.of("yellow_poplar", TreePlacements.YELLOW_POPLAR),
122
				Pair.of("orange_poplar", TreePlacements.ORANGE_POPLAR),
123
				Pair.of("red_poplar", TreePlacements.RED_POPLAR),
124
				Pair.of("super_birch_bees", TreePlacements.SUPER_BIRCH_BEES_0002),
125
				Pair.of("spruce_on_snow", TreePlacements.SPRUCE_ON_SNOW),
126
				Pair.of("fancy_oak_bees", TreePlacements.FANCY_OAK_BEES_002),
127
				Pair.of("birch_bees", TreePlacements.BIRCH_BEES_002),
128
				Pair.of("pale_oak", TreePlacements.PALE_OAK_CHECKED),
129
				Pair.of("bamboo", VegetationPlacements.BAMBOO_IN_STRUCTURE),
130
				Pair.of("jungle", TreePlacements.JUNGLE_TREE_CHECKED),
131
				Pair.of("pine", TreePlacements.PINE_CHECKED),
132
				Pair.of("mega_pine", TreePlacements.MEGA_PINE_CHECKED),
133
				Pair.of("mega_jungle", TreePlacements.MEGA_JUNGLE_TREE_CHECKED),
134
				Pair.of("cherry", TreePlacements.CHERRY_CHECKED),
135
				Pair.of("cherry_bees", TreePlacements.CHERRY_BEES_005)
136
			)
137
		);
138
	}
139
140
	private static void registerTrees(
141
		final BootstrapContext<StructureTemplatePool> context,
142
		final Holder<StructureTemplatePool> empty,
143
		final Collection<Pair<String, ResourceKey<PlacedFeature>>> list
144
	) {
145
		HolderGetter<PlacedFeature> placedFeatures = context.lookup(Registries.PLACED_FEATURE);
146
147
		for (Pair<String, ResourceKey<PlacedFeature>> pair : list) {
148
			Pools.register(
149
				context,
150
				"abandoned_camp/trees/" + pair.getFirst(),
151
				new StructureTemplatePool(
152
					empty, ImmutableList.of(Pair.of(StructurePoolElement.feature(placedFeatures.getOrThrow(pair.getSecond())), 1)), StructureTemplatePool.Projection.RIGID
153
				)
154
			);
155
		}
156
	}
157
158
	private static void bootstrapCampsitePools(final BootstrapContext<StructureTemplatePool> context, final Holder<StructureTemplatePool> empty) {
159
		for (AbandonedCampStructurePools.AbandonedCampStructure biomeVariant : BIOME_VARIANTS) {
160
			registerTentPool(context, empty, biomeVariant);
161
			registerCampsitePool(context, empty, biomeVariant);
162
		}
163
	}
164
165
	private static void registerTentPool(
166
		final BootstrapContext<StructureTemplatePool> context,
167
		final Holder<StructureTemplatePool> empty,
168
		final AbandonedCampStructurePools.AbandonedCampStructure biomeVariant
169
	) {
170
		List<Pair<Function<StructureTemplatePool.Projection, ? extends StructurePoolElement>, Integer>> tentStructures = new ArrayList<>();
171
172
		for (int numOfTentVariants = 1; numOfTentVariants <= 10; numOfTentVariants++) {
173
			tentStructures.add(
174
				Pair.of(StructurePoolElement.legacy(getBiomeSpecificStructureName(biomeVariant, "abandoned_camp/tent/%s/tent_%s_%d", numOfTentVariants)), 1)
175
			);
176
		}
177
178
		Pools.register(
179
			context,
180
			biomeVariant.tentStructureDirectory.identifier().toShortString(),
181
			new StructureTemplatePool(empty, tentStructures, StructureTemplatePool.Projection.RIGID)
182
		);
183
	}
184
185
	private static void registerCampsitePool(
186
		final BootstrapContext<StructureTemplatePool> context,
187
		final Holder<StructureTemplatePool> empty,
188
		final AbandonedCampStructurePools.AbandonedCampStructure biomeVariant
189
	) {
190
		List<Pair<Function<StructureTemplatePool.Projection, ? extends StructurePoolElement>, Integer>> campsiteStructures = new ArrayList<>();
191
192
		for (String defaultCampSiteTypes : DEFAULT_CAMP_TYPES) {
193
			for (int numOfDefaultCampVariants = 1; numOfDefaultCampVariants <= 15; numOfDefaultCampVariants++) {
194
				campsiteStructures.add(Pair.of(StructurePoolElement.legacy(getDefaultCampsiteStructureName(defaultCampSiteTypes, numOfDefaultCampVariants)), 1));
195
			}
196
		}
197
198
		for (int numOfBiomeCampVariants = 1; numOfBiomeCampVariants <= 4; numOfBiomeCampVariants++) {
199
			campsiteStructures.add(
200
				Pair.of(StructurePoolElement.legacy(getBiomeSpecificStructureName(biomeVariant, "abandoned_camp/camp/%s/campsite_%s_%d", numOfBiomeCampVariants)), 1)
201
			);
202
		}
203
204
		Pools.register(
205
			context,
206
			biomeVariant.campStructureDirectory.identifier().toShortString(),
207
			new StructureTemplatePool(empty, campsiteStructures, StructureTemplatePool.Projection.RIGID)
208
		);
209
	}
210
211
	private static String getBiomeSpecificStructureName(
212
		final AbandonedCampStructurePools.AbandonedCampStructure biomeVariant, final String identifierTemplate, final int numOfTentVariants
213
	) {
214
		return String.format(Locale.ROOT, identifierTemplate, biomeVariant.name, biomeVariant.name, numOfTentVariants);
215
	}
216
217
	private static String getDefaultCampsiteStructureName(final String defaultCampSiteTypes, final int numOfDefaultCampVariants) {
218
		return String.format(Locale.ROOT, "abandoned_camp/camp/default/campsite_default_%s_%d", defaultCampSiteTypes, numOfDefaultCampVariants);
219
	}
220
221
	public record AbandonedCampStructure(
222
		ResourceKey<StructureTemplatePool> campStructureDirectory, ResourceKey<StructureTemplatePool> tentStructureDirectory, String name
223
	) {
224
	}
225
}
226

Decompiled Minecraft 26.3 source of AbandonedCampStructurePools (net/minecraft/data/worldgen/AbandonedCampStructurePools.java) with Mojang official mappings, stored verbatim on the site.