Skip to content

Commit

Permalink
fix hunter camp spawning
Browse files Browse the repository at this point in the history
by not using data generation
  • Loading branch information
Cheaterpaul committed Sep 24, 2023
1 parent 8cf688f commit 18d4c9a
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 19 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"placement": {
"type": "minecraft:random_spread",
"salt": 897234698,
"separation": 9,
"spacing": 48
"separation": 8,
"spacing": 32
},
"structures": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"placement": {
"type": "minecraft:random_spread",
"salt": 823476514,
"separation": 9,
"separation": 15,
"spacing": 48
},
"structures": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"placement": {
"type": "minecraft:random_spread",
"salt": 1937195837,
"separation": 8,
"separation": 10,
"spacing": 32
},
"structures": [
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/de/teamlapen/vampirism/core/ModFeatures.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,12 @@ static void register(IEventBus bus) {
public static void createStructures(BootstapContext<Structure> context) {
HolderGetter<Biome> lookup = context.lookup(Registries.BIOME);

context.register(ModFeatures.HUNTER_CAMP, new HunterCampStructure(StructuresAccessor.structure(lookup.getOrThrow(ModTags.Biomes.HasStructure.HUNTER_TENT), TerrainAdjustment.BEARD_THIN)));
context.register(ModFeatures.VAMPIRE_HUT, new VampireHutStructure(StructuresAccessor.structure(lookup.getOrThrow(ModTags.Biomes.HasStructure.VAMPIRE_HUT), TerrainAdjustment.NONE)));
context.register(ModFeatures.HUNTER_OUTPOST, new HunterOutpostStructure(new Structure.StructureSettings(lookup.getOrThrow(ModTags.Biomes.HasStructure.HUNTER_OUTPOST), Map.of(MobCategory.MONSTER, new StructureSpawnOverride(StructureSpawnOverride.BoundingBoxType.STRUCTURE, WeightedRandomList.create(new MobSpawnSettings.SpawnerData(ModEntities.HUNTER.get(), 60, 1, 2), new MobSpawnSettings.SpawnerData(ModEntities.ADVANCED_HUNTER.get(), 20, 1, 1)))) , GenerationStep.Decoration.SURFACE_STRUCTURES,TerrainAdjustment.BEARD_BOX)));
context.register(ModFeatures.VAMPIRE_ALTAR, new VampireAltarStructure(StructuresAccessor.structure(lookup.getOrThrow(ModTags.Biomes.HasStructure.VAMPIRE_ALTAR), TerrainAdjustment.BEARD_BOX)));

// it is currently not possible to create a not holder in datagen see https://github.com/MinecraftForge/MinecraftForge/issues/9629
// this file is not generated, but added through the main source set
// context.register(ModFeatures.HUNTER_CAMP, new HunterCampStructure(StructuresAccessor.structure(new AndHolderSet<>(List.of(lookup.getOrThrow(ModTags.Biomes.HasStructure.HUNTER_TENT), new NotHolderSet<>(context.registryLookup(Registries.BIOME).orElseThrow(),lookup.getOrThrow(ModTags.Biomes.IS_FACTION_BIOME)))), TerrainAdjustment.BEARD_THIN)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import net.minecraft.world.level.levelgen.feature.stateproviders.BlockStateProvider;
import net.minecraft.world.level.levelgen.feature.trunkplacers.StraightTrunkPlacer;
import net.minecraft.world.level.levelgen.placement.*;
import net.minecraft.world.level.levelgen.structure.BuiltinStructureSets;
import net.minecraft.world.level.levelgen.structure.Structure;
import net.minecraft.world.level.levelgen.structure.StructureSet;
import net.minecraft.world.level.levelgen.structure.pieces.StructurePieceType;
Expand Down Expand Up @@ -174,10 +175,13 @@ public static void createBiomeModifier(BootstapContext<BiomeModifier> context) {

public static void createStructureSets(BootstapContext<StructureSet> context) {
HolderGetter<Structure> structureLookup = context.lookup(Registries.STRUCTURE);
context.register(HUNTER_CAMP, new StructureSet(structureLookup.getOrThrow(ModFeatures.HUNTER_CAMP), new RandomSpreadStructurePlacement(9, 4, RandomSpreadType.LINEAR, 1724616580)));
context.register(VAMPIRE_HUT, new StructureSet(structureLookup.getOrThrow(ModFeatures.VAMPIRE_HUT), new RandomSpreadStructurePlacement(32, 8, RandomSpreadType.LINEAR, 1937195837)));
context.register(VAMPIRE_ALTAR, new StructureSet(structureLookup.getOrThrow(ModFeatures.VAMPIRE_ALTAR), new RandomSpreadStructurePlacement(48, 9, RandomSpreadType.LINEAR, 823476514)));
context.register(OUTPOST, new StructureSet(structureLookup.getOrThrow(ModFeatures.HUNTER_OUTPOST), new RandomSpreadStructurePlacement(48, 9, RandomSpreadType.LINEAR, 897234698)));
HolderGetter<StructureSet> structureSetLookup = context.lookup(Registries.STRUCTURE_SET);
var villageSet = structureSetLookup.getOrThrow(BuiltinStructureSets.VILLAGES);
// hunter camp holder is not available in data generation see ModFeatures#createStructures
// context.register(HUNTER_CAMP, new StructureSet(structureLookup.getOrThrow(ModFeatures.HUNTER_CAMP), new RandomSpreadStructurePlacement(Vec3i.ZERO, StructurePlacement.FrequencyReductionMethod.DEFAULT, 1.0F, 1724616580, Optional.of(new StructurePlacement.ExclusionZone(villageSet,2)),9, 4, RandomSpreadType.LINEAR)));
context.register(VAMPIRE_HUT, new StructureSet(structureLookup.getOrThrow(ModFeatures.VAMPIRE_HUT), new RandomSpreadStructurePlacement(32, 10, RandomSpreadType.LINEAR, 1937195837)));
context.register(VAMPIRE_ALTAR, new StructureSet(structureLookup.getOrThrow(ModFeatures.VAMPIRE_ALTAR), new RandomSpreadStructurePlacement(48, 15, RandomSpreadType.LINEAR, 823476514)));
context.register(OUTPOST, new StructureSet(structureLookup.getOrThrow(ModFeatures.HUNTER_OUTPOST), new RandomSpreadStructurePlacement(32, 8, RandomSpreadType.LINEAR, 897234698)));
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package de.teamlapen.vampirism.world.gen.structure.vampirealtar;

import de.teamlapen.vampirism.REFERENCE;
import de.teamlapen.vampirism.api.VampirismAPI;
import de.teamlapen.vampirism.core.ModBlocks;
import de.teamlapen.vampirism.core.ModEntities;
import de.teamlapen.vampirism.core.ModLootTables;
Expand Down Expand Up @@ -62,9 +63,11 @@ protected void handleDataMarker(@NotNull String pName, @NotNull BlockPos pPos, @
}
case "entity" -> {
pLevel.removeBlock(pPos, false);
AdvancedVampireEntity advancedVampireEntity = ModEntities.ADVANCED_VAMPIRE.get().create(pLevel.getLevel());
advancedVampireEntity.setPos(pPos.getX() + 0.5, pPos.getY(), pPos.getZ() + 0.5);
pLevel.addFreshEntity(advancedVampireEntity);
if (!VampirismAPI.sundamageRegistry().hasSunDamage(pLevel, pPos)) {
AdvancedVampireEntity advancedVampireEntity = ModEntities.ADVANCED_VAMPIRE.get().create(pLevel.getLevel());
advancedVampireEntity.setPos(pPos.getX() + 0.5, pPos.getY(), pPos.getZ() + 0.5);
pLevel.addFreshEntity(advancedVampireEntity);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"type": "vampirism:hunter_camp",
"biomes": {
"type": "forge:and",
"values": [
"#vampirism:has_structure/hunter_tent",
{
"type": "forge:not",
"value": "#vampirism:has_faction"
}
]
},
"spawn_overrides": {},
"step": "surface_structures",
"terrain_adaptation": "beard_thin"
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"placement": {
"type": "minecraft:random_spread",
"exclusion_zone": {
"chunk_count": 2,
"other_set": "minecraft:villages"
},
"salt": 1724616580,
"separation": 4,
"spacing": 9
Expand Down

0 comments on commit 18d4c9a

Please sign in to comment.