TRUE 0.102.0 PARITY!!!!
Actaully adds ore generation Actually adds natural spawning Change requirePower to default to false
This commit is contained in:
@@ -2,8 +2,10 @@ package net.cmr.jurassicrevived;
|
||||
|
||||
import dev.architectury.platform.forge.EventBuses;
|
||||
import net.cmr.jurassicrevived.client.config.JRClothConfigScreens;
|
||||
import net.cmr.jurassicrevived.worldgen.ForgeBiomeModifiers;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.ConfigScreenHandler;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.fml.DistExecutor;
|
||||
import net.minecraftforge.fml.ModLoadingContext;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
@@ -13,30 +15,26 @@ import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
@Mod(Constants.MOD_ID)
|
||||
public class JRMod {
|
||||
|
||||
@SuppressWarnings({"deprecation", "removal"})
|
||||
public JRMod() {
|
||||
@SuppressWarnings({"deprecation", "removal"})
|
||||
public JRMod() {
|
||||
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||
|
||||
// This method is invoked by the Forge mod loader when it is ready
|
||||
// to load your mod. You can access Forge and Common code in this
|
||||
// project.
|
||||
EventBuses.registerModEventBus(Constants.MOD_ID, modEventBus);
|
||||
ForgeBiomeModifiers.register(modEventBus);
|
||||
|
||||
EventBuses.registerModEventBus(Constants.MOD_ID, FMLJavaModLoadingContext.get().getModEventBus());
|
||||
|
||||
// Use Forge to bootstrap the Common mod.
|
||||
CommonClass.init();
|
||||
CommonClass.init();
|
||||
|
||||
DistExecutor.safeRunWhenOn(Dist.CLIENT, () -> CommonClientClass::init);
|
||||
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::clientSetup);
|
||||
modEventBus.addListener(this::clientSetup);
|
||||
|
||||
ModLoadingContext.get().registerExtensionPoint(
|
||||
ConfigScreenHandler.ConfigScreenFactory.class,
|
||||
() -> new ConfigScreenHandler.ConfigScreenFactory(
|
||||
(mc, parent) -> JRClothConfigScreens.create(parent)
|
||||
)
|
||||
(mc, parent) -> JRClothConfigScreens.create(parent)
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void clientSetup(FMLClientSetupEvent event) {
|
||||
event.enqueueWork(CommonClientClass::registerScreens);
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ public final class JRClothConfigScreens {
|
||||
|
||||
general.addEntry(
|
||||
eb.startBooleanToggle(Component.literal("Require Power"), cfg.requirePower)
|
||||
.setDefaultValue(true)
|
||||
.setDefaultValue(false)
|
||||
.setTooltip(Component.literal("When disabled, machines do not consume power, hide power bars, and energy pipes do not connect to machines."))
|
||||
.setSaveConsumer(v -> cfg.requirePower = v)
|
||||
.requireRestart()
|
||||
|
||||
@@ -40,5 +40,6 @@ public class DataGenerators {
|
||||
)
|
||||
));
|
||||
generator.addProvider(event.includeServer(), new ForgeRecipeProvider(packOutput));
|
||||
generator.addProvider(event.includeServer(), new ModWorldgenProvider(packOutput));
|
||||
}
|
||||
}
|
||||
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
package net.cmr.jurassicrevived.worldgen;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import net.cmr.jurassicrevived.config.JRConfigManager;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.HolderSet;
|
||||
import net.minecraft.world.entity.MobCategory;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.biome.MobSpawnSettings;
|
||||
import net.minecraftforge.common.world.BiomeModifier;
|
||||
import net.minecraftforge.common.world.ModifiableBiomeInfo;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public final class ConditionalAddSpawnsBiomeModifier implements BiomeModifier {
|
||||
public static final Codec<ConditionalAddSpawnsBiomeModifier> CODEC = RecordCodecBuilder.create(instance ->
|
||||
instance.group(
|
||||
Biome.LIST_CODEC.fieldOf("biomes").forGetter(ConditionalAddSpawnsBiomeModifier::biomes),
|
||||
MobSpawnSettings.SpawnerData.CODEC.listOf().fieldOf("spawners").forGetter(ConditionalAddSpawnsBiomeModifier::spawners)
|
||||
).apply(instance, ConditionalAddSpawnsBiomeModifier::new)
|
||||
);
|
||||
|
||||
private final HolderSet<Biome> biomes;
|
||||
private final List<MobSpawnSettings.SpawnerData> spawners;
|
||||
|
||||
public ConditionalAddSpawnsBiomeModifier(HolderSet<Biome> biomes, List<MobSpawnSettings.SpawnerData> spawners) {
|
||||
this.biomes = biomes;
|
||||
this.spawners = spawners;
|
||||
}
|
||||
|
||||
public HolderSet<Biome> biomes() {
|
||||
return biomes;
|
||||
}
|
||||
|
||||
public List<MobSpawnSettings.SpawnerData> spawners() {
|
||||
return spawners;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modify(@NotNull Holder<Biome> biome, @NotNull Phase phase, @NotNull ModifiableBiomeInfo.BiomeInfo.Builder builder) {
|
||||
if (phase != Phase.ADD) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!JRConfigManager.get().naturallySpawning) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!biomes.contains(biome)) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (MobSpawnSettings.SpawnerData spawner : spawners) {
|
||||
builder.getMobSpawnSettings().addSpawn(MobCategory.CREATURE, spawner);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Codec<? extends BiomeModifier> codec() {
|
||||
return ForgeBiomeModifiers.CONDITIONAL_ADD_SPAWNS.get();
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package net.cmr.jurassicrevived.worldgen;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
import net.cmr.jurassicrevived.Constants;
|
||||
import net.minecraftforge.common.world.BiomeModifier;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
|
||||
public final class ForgeBiomeModifiers {
|
||||
private ForgeBiomeModifiers() {
|
||||
}
|
||||
|
||||
public static final DeferredRegister<Codec<? extends BiomeModifier>> BIOME_MODIFIER_SERIALIZERS =
|
||||
DeferredRegister.create(ForgeRegistries.Keys.BIOME_MODIFIER_SERIALIZERS, Constants.MOD_ID);
|
||||
|
||||
public static final RegistryObject<Codec<ConditionalAddSpawnsBiomeModifier>> CONDITIONAL_ADD_SPAWNS =
|
||||
BIOME_MODIFIER_SERIALIZERS.register("conditional_add_spawns", () -> ConditionalAddSpawnsBiomeModifier.CODEC);
|
||||
|
||||
public static void register(IEventBus eventBus) {
|
||||
BIOME_MODIFIER_SERIALIZERS.register(eventBus);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user