mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-04 23:06:05 +00:00
Forge actually loads to worlds now
This commit is contained in:
@@ -53,11 +53,13 @@ import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.registry.WorldSettingsImport;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.BiomeGenerationSettings;
|
||||
import net.minecraft.world.gen.GenerationStage;
|
||||
import net.minecraft.world.gen.feature.ConfiguredFeature;
|
||||
import net.minecraft.world.gen.feature.Feature;
|
||||
import net.minecraft.world.gen.feature.Features;
|
||||
import net.minecraft.world.gen.feature.IFeatureConfig;
|
||||
import net.minecraft.world.gen.feature.NoFeatureConfig;
|
||||
@@ -93,7 +95,7 @@ import java.util.Map;
|
||||
@Mod("terra")
|
||||
@Mod.EventBusSubscriber(modid = "terra", bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||
public class TerraForgePlugin implements TerraPlugin {
|
||||
public static final PopulatorFeature POPULATOR_FEATURE = new PopulatorFeature(NoFeatureConfig.CODEC);
|
||||
public static final PopulatorFeature POPULATOR_FEATURE = (PopulatorFeature) new PopulatorFeature(NoFeatureConfig.CODEC).setRegistryName("terra", "terra");
|
||||
public static final ConfiguredFeature<?, ?> POPULATOR_CONFIGURED_FEATURE = POPULATOR_FEATURE.configured(IFeatureConfig.NONE).decorated(DecoratedPlacement.NOPE.configured(NoPlacementConfig.INSTANCE));
|
||||
|
||||
private static TerraForgePlugin INSTANCE;
|
||||
@@ -135,10 +137,6 @@ public class TerraForgePlugin implements TerraPlugin {
|
||||
public TerraForgePlugin() {
|
||||
if(INSTANCE != null) throw new IllegalStateException("Only one TerraPlugin instance may exist.");
|
||||
INSTANCE = this;
|
||||
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||
modEventBus.addListener(this::setup);
|
||||
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
public static TerraForgePlugin getInstance() {
|
||||
@@ -151,7 +149,12 @@ public class TerraForgePlugin implements TerraPlugin {
|
||||
|
||||
@SubscribeEvent
|
||||
public static void register(RegistryEvent.Register<Biome> event) {
|
||||
INSTANCE.registry.forEach(pack -> pack.getBiomeRegistry().forEach((id, biome) -> event.getRegistry().register(createBiome(biome)))); // Register all Terra biomes.
|
||||
INSTANCE.setup(); // Setup now because we need the biomes, and this event happens after blocks n stuff
|
||||
INSTANCE.registry.forEach(pack -> pack.getBiomeRegistry().forEach((id, biome) -> {
|
||||
Biome minecraftBiome = createBiome(biome);
|
||||
INSTANCE.logger().info("Registering biome " + minecraftBiome.getRegistryName());
|
||||
event.getRegistry().register(minecraftBiome);
|
||||
})); // Register all Terra biomes.
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@@ -160,6 +163,11 @@ public class TerraForgePlugin implements TerraPlugin {
|
||||
event.getRegistry().register(TerraLevelType.FORGE_WORLD_TYPE);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerPop(RegistryEvent.Register<Feature<?>> event) {
|
||||
event.getRegistry().register(POPULATOR_FEATURE);
|
||||
}
|
||||
|
||||
private static Biome createBiome(BiomeBuilder biome) {
|
||||
BiomeTemplate template = biome.getTemplate();
|
||||
Map<String, Integer> colors = template.getColors();
|
||||
@@ -204,10 +212,10 @@ public class TerraForgePlugin implements TerraPlugin {
|
||||
.specialEffects(vanilla.getSpecialEffects())
|
||||
.mobSpawnSettings(vanilla.getMobSettings())
|
||||
.generationSettings(generationSettings.build())
|
||||
.build();
|
||||
.build().setRegistryName("terra", createBiomeID(template.getPack(), template.getID()));
|
||||
}
|
||||
|
||||
public void setup(FMLCommonSetupEvent event) {
|
||||
public void setup() {
|
||||
this.dataFolder = Paths.get("config", "Terra").toFile();
|
||||
saveDefaultConfig();
|
||||
config.load(this);
|
||||
@@ -223,9 +231,6 @@ public class TerraForgePlugin implements TerraPlugin {
|
||||
|
||||
logger.info("Loaded packs.");
|
||||
|
||||
Registry.register(Registry.CHUNK_GENERATOR, new ResourceLocation("terra:terra"), ForgeChunkGeneratorWrapper.CODEC);
|
||||
Registry.register(Registry.BIOME_SOURCE, new ResourceLocation("terra:terra"), TerraBiomeSource.CODEC);
|
||||
|
||||
CommandManager manager = new TerraCommandManager(this);
|
||||
try {
|
||||
CommandUtil.registerAll(manager);
|
||||
|
||||
@@ -9,6 +9,8 @@ import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.gen.ChunkGenerator;
|
||||
import net.minecraft.world.gen.DimensionSettings;
|
||||
import net.minecraftforge.common.world.ForgeWorldType;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
public class TerraLevelType implements ForgeWorldType.IChunkGeneratorFactory {
|
||||
public static final TerraLevelType TERRA_LEVEL_TYPE = new TerraLevelType();
|
||||
|
||||
@@ -10,7 +10,6 @@ import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.registry.RegistryLookupCodec;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.gen.feature.StructureFeature;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -34,6 +34,7 @@ public class ForgeBlockData implements BlockData {
|
||||
|
||||
@Override
|
||||
public String getAsString() {
|
||||
|
||||
/*
|
||||
StringBuilder data = new StringBuilder(Registry.BLOCK.getId(delegate.getBlock()).toString());
|
||||
if(!delegate.getProperties().isEmpty()) {
|
||||
|
||||
Reference in New Issue
Block a user