mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-06-17 22:31:52 +00:00
Revert "remove unneeded lifecycle mixins"
This reverts commit af90088505.
This commit is contained in:
@@ -19,18 +19,8 @@ package com.dfsek.terra.fabric;
|
|||||||
|
|
||||||
import cloud.commandframework.execution.CommandExecutionCoordinator;
|
import cloud.commandframework.execution.CommandExecutionCoordinator;
|
||||||
import cloud.commandframework.fabric.FabricServerCommandManager;
|
import cloud.commandframework.fabric.FabricServerCommandManager;
|
||||||
|
|
||||||
import com.dfsek.terra.api.event.events.platform.PlatformInitializationEvent;
|
|
||||||
import com.dfsek.terra.fabric.generation.TerraGeneratorType;
|
|
||||||
import com.dfsek.terra.fabric.mixin.access.GeneratorTypeAccessor;
|
|
||||||
import com.dfsek.terra.fabric.util.FabricUtil;
|
|
||||||
|
|
||||||
import net.fabricmc.api.EnvType;
|
|
||||||
import net.fabricmc.api.ModInitializer;
|
import net.fabricmc.api.ModInitializer;
|
||||||
import net.fabricmc.loader.api.FabricLoader;
|
|
||||||
import net.minecraft.client.world.GeneratorType;
|
|
||||||
import net.minecraft.server.command.ServerCommandSource;
|
import net.minecraft.server.command.ServerCommandSource;
|
||||||
import net.minecraft.text.LiteralText;
|
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.registry.Registry;
|
import net.minecraft.util.registry.Registry;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@@ -59,20 +49,7 @@ public class FabricEntryPoint implements ModInitializer {
|
|||||||
@Override
|
@Override
|
||||||
public void onInitialize() {
|
public void onInitialize() {
|
||||||
logger.info("Initializing Terra Fabric mod...");
|
logger.info("Initializing Terra Fabric mod...");
|
||||||
|
|
||||||
FabricEntryPoint.getPlatform().getEventManager().callEvent(new PlatformInitializationEvent());
|
|
||||||
|
|
||||||
if(FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT) {
|
|
||||||
FabricEntryPoint.getPlatform().getConfigRegistry().forEach(pack -> {
|
|
||||||
final GeneratorType generatorType = new TerraGeneratorType(pack);
|
|
||||||
//noinspection ConstantConditions
|
|
||||||
((GeneratorTypeAccessor) generatorType).setDisplayName(new LiteralText("Terra:" + pack.getID()));
|
|
||||||
GeneratorTypeAccessor.getValues().add(1, generatorType);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
FabricUtil.registerBiomes();
|
|
||||||
|
|
||||||
FabricServerCommandManager<CommandSender> manager = new FabricServerCommandManager<>(
|
FabricServerCommandManager<CommandSender> manager = new FabricServerCommandManager<>(
|
||||||
CommandExecutionCoordinator.simpleCoordinator(),
|
CommandExecutionCoordinator.simpleCoordinator(),
|
||||||
serverCommandSource -> (CommandSender) serverCommandSource,
|
serverCommandSource -> (CommandSender) serverCommandSource,
|
||||||
|
|||||||
+15
-1
@@ -42,7 +42,10 @@ public class TerraBiomeSource extends BiomeSource {
|
|||||||
.stream(pack.getBiomeProvider()
|
.stream(pack.getBiomeProvider()
|
||||||
.getBiomes()
|
.getBiomes()
|
||||||
.spliterator(), false)
|
.spliterator(), false)
|
||||||
.map(b -> biomes.entryOf(((ProtoPlatformBiome) b.getPlatformBiome()).getDelegate().getKey().orElseThrow())));
|
.map(b -> ((ProtoPlatformBiome) b.getPlatformBiome()).getDelegate()));
|
||||||
|
biomes.streamEntries().forEach(biomeReference -> {
|
||||||
|
System.out.println(biomeReference.getKey().orElseThrow());
|
||||||
|
});
|
||||||
/*
|
/*
|
||||||
A little (unfortunately, required) jank to watch out for:
|
A little (unfortunately, required) jank to watch out for:
|
||||||
|
|
||||||
@@ -70,6 +73,17 @@ public class TerraBiomeSource extends BiomeSource {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RegistryEntry<net.minecraft.world.biome.Biome> getBiome(int biomeX, int biomeY, int biomeZ, MultiNoiseSampler noiseSampler) {
|
public RegistryEntry<net.minecraft.world.biome.Biome> getBiome(int biomeX, int biomeY, int biomeZ, MultiNoiseSampler noiseSampler) {
|
||||||
|
/*return biomeRegistry
|
||||||
|
.getEntry(((ProtoPlatformBiome) pack
|
||||||
|
.getBiomeProvider()
|
||||||
|
.getBiome(biomeX << 2, biomeZ << 2, seed)
|
||||||
|
.getPlatformBiome())
|
||||||
|
.getDelegate()
|
||||||
|
.getKey()
|
||||||
|
.orElseThrow())
|
||||||
|
.orElseThrow();
|
||||||
|
|
||||||
|
*/
|
||||||
return biomeRegistry.entryOf(((ProtoPlatformBiome) pack
|
return biomeRegistry.entryOf(((ProtoPlatformBiome) pack
|
||||||
.getBiomeProvider()
|
.getBiomeProvider()
|
||||||
.getBiome(biomeX << 2, biomeZ << 2, seed)
|
.getBiome(biomeX << 2, biomeZ << 2, seed)
|
||||||
|
|||||||
+62
@@ -0,0 +1,62 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of Terra.
|
||||||
|
*
|
||||||
|
* Terra is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Terra is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Terra. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.dfsek.terra.fabric.mixin.lifecycle.client;
|
||||||
|
|
||||||
|
import com.dfsek.terra.fabric.util.FabricUtil;
|
||||||
|
|
||||||
|
import net.minecraft.client.MinecraftClient;
|
||||||
|
import net.minecraft.client.RunArgs;
|
||||||
|
import net.minecraft.client.world.GeneratorType;
|
||||||
|
import net.minecraft.text.LiteralText;
|
||||||
|
import net.minecraft.util.registry.DynamicRegistryManager;
|
||||||
|
import net.minecraft.util.registry.DynamicRegistryManager.Mutable;
|
||||||
|
import net.minecraft.util.registry.Registry;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.spongepowered.asm.mixin.Final;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
import com.dfsek.terra.api.event.events.platform.PlatformInitializationEvent;
|
||||||
|
import com.dfsek.terra.fabric.FabricEntryPoint;
|
||||||
|
import com.dfsek.terra.fabric.generation.TerraGeneratorType;
|
||||||
|
import com.dfsek.terra.fabric.mixin.access.GeneratorTypeAccessor;
|
||||||
|
|
||||||
|
|
||||||
|
@Mixin(MinecraftClient.class)
|
||||||
|
public class MinecraftClientMixin {
|
||||||
|
@Inject(method = "<init>", at = @At(value = "INVOKE",
|
||||||
|
target = "Lnet/minecraft/client/util/WindowProvider;createWindow" +
|
||||||
|
"(Lnet/minecraft/client/WindowSettings;Ljava/lang/String;Ljava/lang/String;)" +
|
||||||
|
"Lnet/minecraft/client/util/Window;",
|
||||||
|
// sorta arbitrary position, after mod init, before window opens
|
||||||
|
shift = At.Shift.BEFORE))
|
||||||
|
public void injectConstructor(RunArgs args, CallbackInfo callbackInfo) {
|
||||||
|
FabricEntryPoint.getPlatform().getEventManager().callEvent(new PlatformInitializationEvent());
|
||||||
|
FabricEntryPoint.getPlatform().getConfigRegistry().forEach(pack -> {
|
||||||
|
final GeneratorType generatorType = new TerraGeneratorType(pack);
|
||||||
|
//noinspection ConstantConditions
|
||||||
|
((GeneratorTypeAccessor) generatorType).setDisplayName(new LiteralText("Terra:" + pack.getID()));
|
||||||
|
GeneratorTypeAccessor.getValues().add(1, generatorType);
|
||||||
|
});
|
||||||
|
FabricUtil.registerBiomes();
|
||||||
|
}
|
||||||
|
}
|
||||||
+51
@@ -0,0 +1,51 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of Terra.
|
||||||
|
*
|
||||||
|
* Terra is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Terra is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Terra. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.dfsek.terra.fabric.mixin.lifecycle.server;
|
||||||
|
|
||||||
|
import com.dfsek.terra.fabric.util.FabricUtil;
|
||||||
|
|
||||||
|
import net.minecraft.server.Main;
|
||||||
|
import net.minecraft.util.registry.DynamicRegistryManager;
|
||||||
|
import net.minecraft.util.registry.DynamicRegistryManager.Mutable;
|
||||||
|
import net.minecraft.util.registry.Registry;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.spongepowered.asm.mixin.Final;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
import com.dfsek.terra.api.event.events.platform.PlatformInitializationEvent;
|
||||||
|
import com.dfsek.terra.fabric.FabricEntryPoint;
|
||||||
|
|
||||||
|
|
||||||
|
@Mixin(Main.class)
|
||||||
|
public class ServerMainMixin {
|
||||||
|
@Inject(method = "main([Ljava/lang/String;)V",
|
||||||
|
at = @At(value = "INVOKE",
|
||||||
|
target = "Lnet/minecraft/resource/ResourcePackManager;<init>(Lnet/minecraft/resource/ResourceType;[Lnet/minecraft/resource/ResourcePackProvider;)V") // after registry manager creation
|
||||||
|
)
|
||||||
|
private static void injectConstructor(String[] args, CallbackInfo ci) {
|
||||||
|
FabricEntryPoint.getPlatform().getEventManager().callEvent(
|
||||||
|
new PlatformInitializationEvent()); // Load during MinecraftServer construction, after other mods have registered blocks
|
||||||
|
// and stuff
|
||||||
|
FabricUtil.registerBiomes();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -20,7 +20,6 @@ package com.dfsek.terra.fabric.util;
|
|||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.registry.Registry;
|
import net.minecraft.util.registry.Registry;
|
||||||
import net.minecraft.util.registry.RegistryEntry;
|
import net.minecraft.util.registry.RegistryEntry;
|
||||||
import net.minecraft.util.registry.RegistryKey;
|
|
||||||
import net.minecraft.world.biome.Biome;
|
import net.minecraft.world.biome.Biome;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|||||||
@@ -36,10 +36,12 @@
|
|||||||
"lifecycle.RegistryMixin"
|
"lifecycle.RegistryMixin"
|
||||||
],
|
],
|
||||||
"client": [
|
"client": [
|
||||||
"access.GeneratorTypeAccessor"
|
"access.GeneratorTypeAccessor",
|
||||||
|
"lifecycle.client.MinecraftClientMixin"
|
||||||
],
|
],
|
||||||
"server": [
|
"server": [
|
||||||
"lifecycle.server.GeneratorOptionsMixin"
|
"lifecycle.server.GeneratorOptionsMixin",
|
||||||
|
"lifecycle.server.ServerMainMixin"
|
||||||
],
|
],
|
||||||
"injectors": {
|
"injectors": {
|
||||||
"defaultRequire": 1
|
"defaultRequire": 1
|
||||||
|
|||||||
Reference in New Issue
Block a user