mirror of
https://github.com/dragonruler1000/hdm-mod.git
synced 2025-06-29 00:19:32 -05:00
Introduce custom DustHouse structure and update mod configuration
Added a new DustHouse structure with associated registration logic and configuration settings. Updated `gradle.properties`, introduced `accesstransformer.cfg`, and added JSON and NBT files for structure generation. Fixed typo in gradle daemon setting. Signed-off-by: dragonruler1000 <github@me.minecraftchest2.us>
This commit is contained in:
parent
15b1027f9b
commit
bcd5a40813
7 changed files with 226 additions and 1 deletions
|
@ -1,5 +1,5 @@
|
||||||
org.gradle.jvmargs=-Xmx3G
|
org.gradle.jvmargs=-Xmx3G
|
||||||
org.gradle.daemon=true
|
org.gradle.daemon=flase
|
||||||
# The Minecraft version must agree with the Forge version to get a valid artifact
|
# The Minecraft version must agree with the Forge version to get a valid artifact
|
||||||
minecraft_version=1.16.5
|
minecraft_version=1.16.5
|
||||||
# The Minecraft version range can use any release version of Minecraft as bounds.
|
# The Minecraft version range can use any release version of Minecraft as bounds.
|
||||||
|
|
|
@ -22,6 +22,7 @@ import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import us.minecraftchest2.hdm_mod.block.ModBlocks;
|
import us.minecraftchest2.hdm_mod.block.ModBlocks;
|
||||||
import us.minecraftchest2.hdm_mod.item.ModItems;
|
import us.minecraftchest2.hdm_mod.item.ModItems;
|
||||||
|
import us.minecraftchest2.hdm_mod.world.structure.ModStructures;
|
||||||
//import us.minecraftchest2.hdm_mod.init.ItemInit;
|
//import us.minecraftchest2.hdm_mod.init.ItemInit;
|
||||||
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
@ -41,6 +42,8 @@ public class Hdm_mod {
|
||||||
ModItems.register(modEventBus1);
|
ModItems.register(modEventBus1);
|
||||||
ModBlocks.register(modEventBus1);
|
ModBlocks.register(modEventBus1);
|
||||||
|
|
||||||
|
ModStructures.register(modEventBus1);
|
||||||
|
|
||||||
modEventBus1.addListener(this::setup);
|
modEventBus1.addListener(this::setup);
|
||||||
// Register the enqueueIMC method for modloading
|
// Register the enqueueIMC method for modloading
|
||||||
modEventBus1.addListener(this::enqueueIMC);
|
modEventBus1.addListener(this::enqueueIMC);
|
||||||
|
|
|
@ -0,0 +1,113 @@
|
||||||
|
package us.minecraftchest2.hdm_mod.world.structure;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import net.minecraft.util.registry.WorldGenRegistries;
|
||||||
|
import net.minecraft.world.gen.feature.NoFeatureConfig;
|
||||||
|
import net.minecraft.world.gen.feature.structure.Structure;
|
||||||
|
import net.minecraft.world.gen.settings.DimensionStructuresSettings;
|
||||||
|
import net.minecraft.world.gen.settings.StructureSeparationSettings;
|
||||||
|
import net.minecraftforge.eventbus.api.IEventBus;
|
||||||
|
import net.minecraftforge.fml.RegistryObject;
|
||||||
|
import net.minecraftforge.registries.DeferredRegister;
|
||||||
|
import net.minecraftforge.registries.ForgeRegistries;
|
||||||
|
import us.minecraftchest2.hdm_mod.Hdm_mod;
|
||||||
|
import us.minecraftchest2.hdm_mod.world.structure.structures.DustHouseStructure;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class ModStructures {
|
||||||
|
public static final DeferredRegister<Structure<?>> STRUCTURES =
|
||||||
|
DeferredRegister.create(ForgeRegistries.STRUCTURE_FEATURES, Hdm_mod.MOD_ID);
|
||||||
|
|
||||||
|
public static final RegistryObject<Structure<NoFeatureConfig>> HOUSE =
|
||||||
|
STRUCTURES.register("house", DustHouseStructure::new);
|
||||||
|
|
||||||
|
/* average distance apart in chunks between spawn attempts */
|
||||||
|
/* minimum distance apart in chunks between spawn attempts. MUST BE LESS THAN ABOVE VALUE*/
|
||||||
|
/* this modifies the seed of the structure so no two structures always spawn over each-other.
|
||||||
|
Make this large and unique. */
|
||||||
|
public static void setupStructures() {
|
||||||
|
setupMapSpacingAndLand(HOUSE.get(),
|
||||||
|
new StructureSeparationSettings(100,50, 1234567890),
|
||||||
|
true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the provided structure to the registry, and adds the separation settings.
|
||||||
|
* The rarity of the structure is determined based on the values passed into
|
||||||
|
* this method in the structureSeparationSettings argument.
|
||||||
|
* This method is called by setupStructures above.
|
||||||
|
**/
|
||||||
|
public static <F extends Structure<?>> void setupMapSpacingAndLand(F structure, StructureSeparationSettings structureSeparationSettings,
|
||||||
|
boolean transformSurroundingLand) {
|
||||||
|
//add our structures into the map in Structure class
|
||||||
|
Structure.NAME_STRUCTURE_BIMAP.put(structure.getRegistryName().toString(), structure);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Whether surrounding land will be modified automatically to conform to the bottom of the structure.
|
||||||
|
* Basically, it adds land at the base of the structure like it does for Villages and Outposts.
|
||||||
|
* Doesn't work well on structure that have pieces stacked vertically or change in heights.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
if (transformSurroundingLand) {
|
||||||
|
Structure.field_236384_t_ = ImmutableList.<Structure<?>>builder()
|
||||||
|
.addAll(Structure.field_236384_t_)
|
||||||
|
.add(structure)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This is the map that holds the default spacing of all structures.
|
||||||
|
* Always add your structure to here so that other mods can utilize it if needed.
|
||||||
|
*
|
||||||
|
* However, while it does propagate the spacing to some correct dimensions from this map,
|
||||||
|
* it seems it doesn't always work for code made dimensions as they read from this list beforehand.
|
||||||
|
*
|
||||||
|
* Instead, we will use the WorldEvent.Load event in ModWorldEvents to add the structure
|
||||||
|
* spacing from this list into that dimension or to do dimension blacklisting properly.
|
||||||
|
* We also use our entry in DimensionStructuresSettings.DEFAULTS in WorldEvent.Load as well.
|
||||||
|
*
|
||||||
|
* DEFAULTS requires AccessTransformer (See resources/META-INF/accesstransformer.cfg)
|
||||||
|
*/
|
||||||
|
DimensionStructuresSettings.field_236191_b_ =
|
||||||
|
ImmutableMap.<Structure<?>, StructureSeparationSettings>builder()
|
||||||
|
.putAll(DimensionStructuresSettings.field_236191_b_)
|
||||||
|
.put(structure, structureSeparationSettings)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* There are very few mods that relies on seeing your structure in the
|
||||||
|
* noise settings registry before the world is made.
|
||||||
|
*
|
||||||
|
* You may see some mods add their spacings to DimensionSettings.BUILTIN_OVERWORLD instead of the
|
||||||
|
* NOISE_GENERATOR_SETTINGS loop below but that field only applies for the default overworld and
|
||||||
|
* won't add to other worldtypes or dimensions (like amplified or Nether).
|
||||||
|
* So yeah, don't do DimensionSettings.BUILTIN_OVERWORLD. Use the NOISE_GENERATOR_SETTINGS loop
|
||||||
|
* below instead if you must.
|
||||||
|
*/
|
||||||
|
WorldGenRegistries.NOISE_SETTINGS.getEntries().forEach(settings -> {
|
||||||
|
Map<Structure<?>, StructureSeparationSettings> structureMap =
|
||||||
|
settings.getValue().getStructures().func_236195_a_();
|
||||||
|
/*
|
||||||
|
* Pre-caution in case a mod makes the structure map immutable like datapacks do.
|
||||||
|
* I take no chances myself. You never know what another mods does...
|
||||||
|
*
|
||||||
|
* structureConfig requires AccessTransformer (See resources/META-INF/accesstransformer.cfg)
|
||||||
|
*/
|
||||||
|
if (structureMap instanceof ImmutableMap) {
|
||||||
|
Map<Structure<?>, StructureSeparationSettings> tempMap = new HashMap<>(structureMap);
|
||||||
|
tempMap.put(structure, structureSeparationSettings);
|
||||||
|
settings.getValue().getStructures().func_236195_a_();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
structureMap.put(structure, structureSeparationSettings);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void register(IEventBus eventBus) {
|
||||||
|
STRUCTURES.register(eventBus);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,90 @@
|
||||||
|
package us.minecraftchest2.hdm_mod.world.structure.structures;
|
||||||
|
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import net.minecraft.util.SharedSeedRandom;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.ChunkPos;
|
||||||
|
import net.minecraft.util.math.MutableBoundingBox;
|
||||||
|
import net.minecraft.util.registry.DynamicRegistries;
|
||||||
|
import net.minecraft.util.registry.Registry;
|
||||||
|
import net.minecraft.world.IBlockReader;
|
||||||
|
import net.minecraft.world.biome.Biome;
|
||||||
|
import net.minecraft.world.biome.provider.BiomeProvider;
|
||||||
|
import net.minecraft.world.gen.ChunkGenerator;
|
||||||
|
import net.minecraft.world.gen.GenerationStage;
|
||||||
|
import net.minecraft.world.gen.Heightmap;
|
||||||
|
import net.minecraft.world.gen.feature.NoFeatureConfig;
|
||||||
|
import net.minecraft.world.gen.feature.jigsaw.JigsawManager;
|
||||||
|
import net.minecraft.world.gen.feature.structure.AbstractVillagePiece;
|
||||||
|
import net.minecraft.world.gen.feature.structure.Structure;
|
||||||
|
import net.minecraft.world.gen.feature.structure.StructureStart;
|
||||||
|
import net.minecraft.world.gen.feature.structure.VillageConfig;
|
||||||
|
import net.minecraft.world.gen.feature.template.TemplateManager;
|
||||||
|
import org.apache.logging.log4j.Level;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import us.minecraftchest2.hdm_mod.Hdm_mod;
|
||||||
|
|
||||||
|
public class DustHouseStructure extends Structure<NoFeatureConfig> {
|
||||||
|
public DustHouseStructure() {
|
||||||
|
super(NoFeatureConfig.CODEC);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public GenerationStage.Decoration getDecorationStage() {
|
||||||
|
return GenerationStage.Decoration.SURFACE_STRUCTURES;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean func_230363_a_(ChunkGenerator chunkGenerator, BiomeProvider biomeSource,
|
||||||
|
long seed, SharedSeedRandom chunkRandom, int chunkX, int chunkZ,
|
||||||
|
Biome biome, ChunkPos chunkPos, NoFeatureConfig featureConfig) {
|
||||||
|
BlockPos centerOfChunk = new BlockPos((chunkX << 4) + 7, 0, (chunkZ << 4) + 7);
|
||||||
|
int landHeight = chunkGenerator.getHeight(centerOfChunk.getX(), centerOfChunk.getZ(),
|
||||||
|
Heightmap.Type.WORLD_SURFACE_WG);
|
||||||
|
|
||||||
|
IBlockReader columnOfBlocks = chunkGenerator.func_230348_a_(centerOfChunk.getX(), centerOfChunk.getZ());
|
||||||
|
BlockState topBlock = columnOfBlocks.getBlockState(centerOfChunk.up(landHeight));
|
||||||
|
|
||||||
|
return topBlock.getFluidState().isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IStartFactory<NoFeatureConfig> getStartFactory() {
|
||||||
|
return DustHouseStructure.Start::new;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Start extends StructureStart<NoFeatureConfig> {
|
||||||
|
public Start(Structure<NoFeatureConfig> structureIn, int chunkX, int chunkZ,
|
||||||
|
MutableBoundingBox mutableBoundingBox, int referenceIn, long seedIn) {
|
||||||
|
super(structureIn, chunkX, chunkZ, mutableBoundingBox, referenceIn, seedIn);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override // generatePieces
|
||||||
|
public void func_230364_a_(DynamicRegistries dynamicRegistryManager, ChunkGenerator chunkGenerator,
|
||||||
|
TemplateManager templateManagerIn, int chunkX, int chunkZ, Biome biomeIn,
|
||||||
|
NoFeatureConfig config) {
|
||||||
|
// Turns the chunk coordinates into actual coordinates we can use. (Gets center of that chunk)
|
||||||
|
int x = (chunkX << 4) + 7;
|
||||||
|
int z = (chunkZ << 4) + 7;
|
||||||
|
BlockPos blockpos = new BlockPos(x, 0, z);
|
||||||
|
|
||||||
|
//addpieces()
|
||||||
|
JigsawManager.func_242837_a(dynamicRegistryManager,
|
||||||
|
new VillageConfig(() -> dynamicRegistryManager.getRegistry(Registry.JIGSAW_POOL_KEY)
|
||||||
|
.getOrDefault(new ResourceLocation(Hdm_mod.MOD_ID, "house/start_pool")),
|
||||||
|
10), AbstractVillagePiece::new, chunkGenerator, templateManagerIn,
|
||||||
|
blockpos, this.components, this.rand,false,true);
|
||||||
|
|
||||||
|
this.components.forEach(piece -> piece.offset(0, 1, 0));
|
||||||
|
this.components.forEach(piece -> piece.getBoundingBox().minY -= 1);
|
||||||
|
|
||||||
|
this.recalculateStructureSize();
|
||||||
|
|
||||||
|
LogManager.getLogger().log(Level.DEBUG, "House at " +
|
||||||
|
this.components.get(0).getBoundingBox().minX + " " +
|
||||||
|
this.components.get(0).getBoundingBox().minY + " " +
|
||||||
|
this.components.get(0).getBoundingBox().minZ);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
4
src/main/resources/META-INF/accesstransformer.cfg
Normal file
4
src/main/resources/META-INF/accesstransformer.cfg
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
public-f net.minecraft.world.gen.feature.structure.Structure field_236384_t_ #LAND_TRANSFORMING_STRUCTURES
|
||||||
|
public-f net.minecraft.world.gen.settings.DimensionStructuresSettings field_236191_b_ #DEFAULT_STRUCTURE_CONFIGS
|
||||||
|
public-f net.minecraft.world.gen.FlatGenerationSettings field_202247_j #STRUCTURES
|
||||||
|
public-f net.minecraft.world.gen.settings.DimensionStructuresSettings field_236193_d_ #structures
|
BIN
src/main/resources/data/hdm_mod/structures/dust_house.nbt
Normal file
BIN
src/main/resources/data/hdm_mod/structures/dust_house.nbt
Normal file
Binary file not shown.
|
@ -0,0 +1,15 @@
|
||||||
|
{
|
||||||
|
"name": "tutorialmod:house/start_pool",
|
||||||
|
"fallback": "minecraft:empty",
|
||||||
|
"elements": [
|
||||||
|
{
|
||||||
|
"weight": 1,
|
||||||
|
"element": {
|
||||||
|
"location": "tutorialmod:house",
|
||||||
|
"processors": "minecraft:empty",
|
||||||
|
"projection": "rigid",
|
||||||
|
"element_type": "minecraft:single_pool_element"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue