-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adjusted backported changes to 1.18.2
- Loading branch information
Showing
5 changed files
with
141 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
src/main/java/com/majruszsdifficulty/world/BiomeLoader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
package com.majruszsdifficulty.world; | ||
|
||
import com.majruszsdifficulty.Registries; | ||
import net.minecraft.world.entity.EntityType; | ||
import net.minecraft.world.entity.MobCategory; | ||
import net.minecraft.world.level.biome.Biome; | ||
import net.minecraft.world.level.biome.MobSpawnSettings; | ||
import net.minecraft.world.level.levelgen.GenerationStep; | ||
import net.minecraftforge.common.world.BiomeGenerationSettingsBuilder; | ||
import net.minecraftforge.common.world.MobSpawnSettingsBuilder; | ||
import net.minecraftforge.event.world.BiomeLoadingEvent; | ||
import net.minecraftforge.eventbus.api.EventPriority; | ||
import net.minecraftforge.eventbus.api.SubscribeEvent; | ||
import net.minecraftforge.fml.common.Mod; | ||
|
||
@Mod.EventBusSubscriber | ||
public class BiomeLoader { | ||
@SubscribeEvent( priority = EventPriority.HIGH ) | ||
public static void onLoad( BiomeLoadingEvent event ) { | ||
Biome.BiomeCategory category = event.getCategory(); | ||
MobSpawnSettingsBuilder spawnInfoBuilder = event.getSpawns(); | ||
BiomeGenerationSettingsBuilder generationSettingsBuilder = event.getGeneration(); | ||
|
||
if( doBiomeCategoryBelongsToOverworld( category ) ) { | ||
addOverworldEntities( spawnInfoBuilder ); | ||
addOverworldStructures( generationSettingsBuilder ); | ||
} else if( doBiomeCategoryBelongsToNether( category ) ) { | ||
addNetherEntities( spawnInfoBuilder ); | ||
} else if( doBiomeCategoryBelongsToTheEnd( category ) ) { | ||
addEndEntities( spawnInfoBuilder ); | ||
addEndStructures( generationSettingsBuilder ); | ||
addEndOres( generationSettingsBuilder ); | ||
} | ||
} | ||
|
||
static void addOverworldEntities( MobSpawnSettingsBuilder spawnInfoBuilder ) { | ||
addFreshEntity( spawnInfoBuilder, MobCategory.MONSTER, EntityType.ILLUSIONER, 20, 1, 2 ); | ||
addFreshEntity( spawnInfoBuilder, MobCategory.MONSTER, Registries.TANK.get(), 3, 1, 1 ); | ||
} | ||
|
||
static void addOverworldStructures( BiomeGenerationSettingsBuilder generationSettingsBuilder ) {} | ||
|
||
static void addNetherEntities( MobSpawnSettingsBuilder spawnInfoBuilder ) {} | ||
|
||
protected static void addEndEntities( MobSpawnSettingsBuilder spawnInfoBuilder ) {} | ||
|
||
protected static void addEndStructures( BiomeGenerationSettingsBuilder generationSettingsBuilder ) {} | ||
|
||
protected static void addEndOres( BiomeGenerationSettingsBuilder generationSettingsBuilder ) { | ||
generationSettingsBuilder.addFeature( GenerationStep.Decoration.UNDERGROUND_ORES, Registries.INFESTED_END_STONE_PLACED.getHolder().get() ); | ||
generationSettingsBuilder.addFeature( GenerationStep.Decoration.UNDERGROUND_ORES, Registries.ENDERIUM_ORE_SMALL_PLACED.getHolder().get() ); | ||
generationSettingsBuilder.addFeature( GenerationStep.Decoration.UNDERGROUND_ORES, Registries.ENDERIUM_ORE_LARGE_PLACED.getHolder().get() ); | ||
} | ||
|
||
protected static boolean doBiomeCategoryBelongsToOverworld( Biome.BiomeCategory category ) { | ||
boolean isTaiga = category == Biome.BiomeCategory.TAIGA; | ||
boolean isExtremeHills = category == Biome.BiomeCategory.EXTREME_HILLS; | ||
boolean isJungle = category == Biome.BiomeCategory.JUNGLE; | ||
boolean isMesa = category == Biome.BiomeCategory.MESA; | ||
boolean isPlains = category == Biome.BiomeCategory.PLAINS; | ||
boolean isSavanna = category == Biome.BiomeCategory.SAVANNA; | ||
boolean isIcy = category == Biome.BiomeCategory.ICY; | ||
boolean isBeach = category == Biome.BiomeCategory.BEACH; | ||
boolean isForest = category == Biome.BiomeCategory.FOREST; | ||
boolean isOcean = category == Biome.BiomeCategory.OCEAN; | ||
boolean isDesert = category == Biome.BiomeCategory.DESERT; | ||
boolean isRiver = category == Biome.BiomeCategory.RIVER; | ||
boolean isSwamp = category == Biome.BiomeCategory.SWAMP; | ||
boolean isMushroom = category == Biome.BiomeCategory.MUSHROOM; | ||
|
||
return isTaiga || isExtremeHills || isJungle || isMesa || isPlains || isSavanna || isIcy || isBeach || isForest || isOcean || isDesert || isRiver || isSwamp || isMushroom; | ||
} | ||
|
||
protected static boolean doBiomeCategoryBelongsToNether( Biome.BiomeCategory category ) { | ||
return category == Biome.BiomeCategory.NETHER; | ||
} | ||
|
||
protected static boolean doBiomeCategoryBelongsToTheEnd( Biome.BiomeCategory category ) { | ||
return category == Biome.BiomeCategory.THEEND; | ||
} | ||
|
||
private static void addFreshEntity( MobSpawnSettingsBuilder spawnInfoBuilder, MobCategory classification, EntityType< ? > entityType, int weight, | ||
int minimumCount, int maximumCount | ||
) { | ||
MobSpawnSettings.SpawnerData spawners = new MobSpawnSettings.SpawnerData( entityType, weight, minimumCount, maximumCount ); | ||
|
||
spawnInfoBuilder.addSpawn( classification, spawners ); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
src/main/java/com/majruszsdifficulty/world/WorldGenHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.majruszsdifficulty.world; | ||
|
||
import net.minecraft.core.Holder; | ||
import net.minecraft.data.worldgen.placement.PlacementUtils; | ||
import net.minecraft.world.level.block.Block; | ||
import net.minecraft.world.level.block.Blocks; | ||
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; | ||
import net.minecraft.world.level.levelgen.feature.Feature; | ||
import net.minecraft.world.level.levelgen.feature.configurations.OreConfiguration; | ||
import net.minecraft.world.level.levelgen.placement.BiomeFilter; | ||
import net.minecraft.world.level.levelgen.placement.CountPlacement; | ||
import net.minecraft.world.level.levelgen.placement.InSquarePlacement; | ||
import net.minecraft.world.level.levelgen.placement.PlacedFeature; | ||
import net.minecraft.world.level.levelgen.structure.templatesystem.BlockMatchTest; | ||
import net.minecraftforge.registries.RegistryObject; | ||
|
||
import java.util.List; | ||
|
||
public class WorldGenHelper { | ||
public static ConfiguredFeature< ?, ? > getConfigured( Block targetBlock, RegistryObject< ? extends Block > block, int count, | ||
float airExposureDiscardChance | ||
) { | ||
List< OreConfiguration.TargetBlockState > target = List.of( OreConfiguration.target( new BlockMatchTest( targetBlock ), block.get() | ||
.defaultBlockState() ) ); | ||
return new ConfiguredFeature<>( Feature.ORE, new OreConfiguration( target, count, airExposureDiscardChance ) ); | ||
} | ||
|
||
public static ConfiguredFeature< ?, ? > getEndConfigured( RegistryObject< ? extends Block > block, int count, float airExposureDiscardChance ) { | ||
return getConfigured( Blocks.END_STONE, block, count, airExposureDiscardChance ); | ||
} | ||
|
||
public static PlacedFeature getEndPlaced( RegistryObject< ConfiguredFeature< ?, ? > > configuredFeature, int count ) { | ||
Holder< ConfiguredFeature< ?, ? > > holder = configuredFeature.getHolder().get(); | ||
return new PlacedFeature( holder, List.of( CountPlacement.of( count ), InSquarePlacement.spread(), PlacementUtils.FULL_RANGE, BiomeFilter.biome() ) ); | ||
} | ||
} |
6 changes: 0 additions & 6 deletions
6
src/main/resources/data/majruszsdifficulty/forge/biome_modifier/end_ores_modifier.json
This file was deleted.
Oops, something went wrong.
18 changes: 0 additions & 18 deletions
18
src/main/resources/data/majruszsdifficulty/forge/biome_modifier/overworld_mobs_modifier.json
This file was deleted.
Oops, something went wrong.