-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1f732b4
commit 614f419
Showing
11 changed files
with
190 additions
and
2 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
6 changes: 6 additions & 0 deletions
6
common/src/main/java/com/unrealdinnerbone/jamd/JamdConfig.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,6 @@ | ||
package com.unrealdinnerbone.jamd; | ||
|
||
import java.util.List; | ||
|
||
public record JamdConfig(boolean dynamicOreAddition, List<String> blackListedOres, List<String> addValues) { | ||
} |
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 |
---|---|---|
|
@@ -26,4 +26,6 @@ protected Codec<? extends ChunkGenerator> codec() { | |
public int getMinY() { | ||
return -64; | ||
} | ||
|
||
|
||
} |
File renamed without changes.
3 changes: 3 additions & 0 deletions
3
forge/src/generated/resources/data/jamd/forge/biome_modifier/add_self.json
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,3 @@ | ||
{ | ||
"type": "jamd:jamd" | ||
} |
52 changes: 52 additions & 0 deletions
52
forge/src/main/java/com/unrealdinnerbone/jamd/JAMDDataForge.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,52 @@ | ||
package com.unrealdinnerbone.jamd; | ||
|
||
import com.unrealdinnerbone.jamd.biome.JAMDBiomeModifier; | ||
import net.minecraft.core.Holder; | ||
import net.minecraft.core.HolderLookup; | ||
import net.minecraft.core.RegistrySetBuilder; | ||
import net.minecraft.core.registries.BuiltInRegistries; | ||
import net.minecraft.core.registries.Registries; | ||
import net.minecraft.data.DataProvider; | ||
import net.minecraft.data.PackOutput; | ||
import net.minecraft.data.worldgen.BootstapContext; | ||
import net.minecraft.resources.ResourceKey; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.world.level.biome.Biome; | ||
import net.minecraftforge.common.data.DatapackBuiltinEntriesProvider; | ||
import net.minecraftforge.common.world.BiomeModifier; | ||
import net.minecraftforge.common.world.ForgeBiomeModifiers; | ||
import net.minecraftforge.data.event.GatherDataEvent; | ||
import net.minecraftforge.registries.ForgeRegistries; | ||
|
||
import java.util.Set; | ||
import java.util.concurrent.CompletableFuture; | ||
|
||
public class JAMDDataForge | ||
{ | ||
|
||
private static final ResourceKey<BiomeModifier> ADD_SELF = ResourceKey.create(ForgeRegistries.Keys.BIOME_MODIFIERS, new ResourceLocation(JAMD.MOD_ID, "add_mekenism")); | ||
|
||
private static final RegistrySetBuilder builder = new RegistrySetBuilder() | ||
.add(ForgeRegistries.Keys.BIOME_MODIFIERS, JAMDDataForge::createBiomeModifiers); | ||
|
||
public static void onData(GatherDataEvent event) { | ||
event.getGenerator().addProvider(event.includeServer(), (DataProvider.Factory<BiomeModifiers>) output -> new BiomeModifiers(output, event.getLookupProvider())); | ||
|
||
} | ||
|
||
private static void createBiomeModifiers(BootstapContext<BiomeModifier> bootstapContext) { | ||
bootstapContext.register(ADD_SELF, JAMDBiomeModifier.INSTANCE); | ||
} | ||
|
||
private static class BiomeModifiers extends DatapackBuiltinEntriesProvider | ||
{ | ||
|
||
public BiomeModifiers(PackOutput output, CompletableFuture<HolderLookup.Provider> registries) | ||
{ | ||
super(output, registries, builder, Set.of(JAMD.MOD_ID)); | ||
} | ||
} | ||
|
||
|
||
|
||
} |
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 |
---|---|---|
@@ -1,11 +1,13 @@ | ||
package com.unrealdinnerbone.jamd; | ||
|
||
import net.minecraftforge.fml.common.Mod; | ||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; | ||
|
||
@Mod(JAMD.MOD_ID) | ||
public class JAMDForge { | ||
|
||
public JAMDForge() { | ||
JAMD.init(); | ||
FMLJavaModLoadingContext.get().getModEventBus().addListener(JAMDDataForge::onData); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
forge/src/main/java/com/unrealdinnerbone/jamd/JAMDForgeRegistry.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,28 @@ | ||
package com.unrealdinnerbone.jamd; | ||
|
||
import com.mojang.serialization.Codec; | ||
import com.unrealdinnerbone.jamd.biome.JAMDBiomeModifier; | ||
import com.unrealdinnerbone.trenzalore.api.platform.services.IRegistry; | ||
import com.unrealdinnerbone.trenzalore.api.registry.RegistryEntry; | ||
import com.unrealdinnerbone.trenzalore.api.registry.RegistryFactory; | ||
import com.unrealdinnerbone.trenzalore.api.registry.RegistryObjects; | ||
import net.minecraftforge.common.world.BiomeModifier; | ||
import net.minecraftforge.registries.ForgeRegistries; | ||
|
||
import java.util.List; | ||
|
||
public class JAMDForgeRegistry implements IRegistry { | ||
private static final RegistryObjects<Codec<? extends BiomeModifier>> BIOME_MODIFERS = RegistryFactory.create(ForgeRegistries.Keys.BIOME_MODIFIER_SERIALIZERS); | ||
|
||
public static final RegistryEntry<Codec<JAMDBiomeModifier>> BIOME_MODIFER = BIOME_MODIFERS.register(JAMD.MOD_ID, () -> Codec.unit(JAMDBiomeModifier.INSTANCE)); | ||
|
||
@Override | ||
public List<RegistryObjects<?>> getRegistryObjects() { | ||
return List.of(BIOME_MODIFERS); | ||
} | ||
|
||
@Override | ||
public String getModID() { | ||
return JAMD.MOD_ID; | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
forge/src/main/java/com/unrealdinnerbone/jamd/biome/JAMDBiomeModifier.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,63 @@ | ||
package com.unrealdinnerbone.jamd.biome; | ||
|
||
import com.mojang.logging.LogUtils; | ||
import com.mojang.serialization.Codec; | ||
import com.unrealdinnerbone.jamd.JAMD; | ||
import com.unrealdinnerbone.jamd.JAMDForgeRegistry; | ||
import com.unrealdinnerbone.jamd.JAMDRegistry; | ||
import com.unrealdinnerbone.jamd.JamdConfig; | ||
import net.minecraft.core.Holder; | ||
import net.minecraft.core.HolderLookup; | ||
import net.minecraft.core.registries.Registries; | ||
import net.minecraft.data.registries.VanillaRegistries; | ||
import net.minecraft.world.level.biome.Biome; | ||
import net.minecraft.world.level.levelgen.GenerationStep; | ||
import net.minecraft.world.level.levelgen.feature.OreFeature; | ||
import net.minecraft.world.level.levelgen.placement.PlacedFeature; | ||
import net.minecraftforge.common.world.BiomeModifier; | ||
import net.minecraftforge.common.world.ModifiableBiomeInfo; | ||
import org.slf4j.Logger; | ||
|
||
import java.util.List; | ||
|
||
public class JAMDBiomeModifier implements BiomeModifier | ||
{ | ||
public static final JAMDBiomeModifier INSTANCE = new JAMDBiomeModifier(); | ||
|
||
private static final Logger LOGGER = LogUtils.getLogger(); | ||
|
||
@Override | ||
public void modify(Holder<Biome> biome, Phase phase, ModifiableBiomeInfo.BiomeInfo.Builder builder) { | ||
if (phase == Phase.MODIFY && biome.is(JAMDRegistry.Keys.BIOME)) { | ||
JamdConfig config = JAMD.CONFIG.get(); | ||
if(config.dynamicOreAddition()) { | ||
HolderLookup.RegistryLookup<PlacedFeature> placedFeatureRegistryLookup = VanillaRegistries.createLookup().lookup(Registries.PLACED_FEATURE).orElseThrow(); | ||
placedFeatureRegistryLookup.listElements().forEach(placedFeature -> { | ||
PlacedFeature s = placedFeature.get(); | ||
boolean isOreFeature = s.feature().get().feature() instanceof OreFeature; | ||
boolean isBlacklisted = config.blackListedOres().contains(placedFeature.key().location().toString()); | ||
boolean isWhiteListed = config.addValues().contains(placedFeature.key().location().toString()); | ||
if(isBlacklisted && isWhiteListed) { | ||
LOGGER.warn("Ore Feature: " + placedFeature.key() + " is both blacklisted and whitelisted. This is not allowed"); | ||
}else { | ||
if (isWhiteListed || (isOreFeature && !isBlacklisted)) { | ||
List<Holder<PlacedFeature>> features = builder.getGenerationSettings().getFeatures(GenerationStep.Decoration.UNDERGROUND_ORES); | ||
if (features.stream().noneMatch(holder -> holder.is(placedFeature.key()))) { | ||
LOGGER.debug("Adding Ore Feature: " + placedFeature.key()); | ||
builder.getGenerationSettings().addFeature(GenerationStep.Decoration.UNDERGROUND_ORES, placedFeature); | ||
} else { | ||
LOGGER.debug("Skipping ore feature as it already exists: " + placedFeature.key()); | ||
} | ||
} | ||
|
||
} | ||
}); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public Codec<? extends BiomeModifier> codec() { | ||
return JAMDForgeRegistry.BIOME_MODIFER.get(); | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
...sources/META-INF/services/com.unrealdinnerbone.trenzalore.api.platform.services.IRegistry
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,2 @@ | ||
com.unrealdinnerbone.jamd.JAMDRegistry | ||
com.unrealdinnerbone.jamd.JAMDForgeRegistry |
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