mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-07 08:16:05 +00:00
use TerraPluginImpl over TerraFabricPlugin
This commit is contained in:
@@ -130,6 +130,10 @@ public abstract class AbstractTerraPlugin implements TerraPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
public CommandManager getManager() {
|
||||
return manager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Logger getDebugLogger() {
|
||||
return debugLogger.value();
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.dfsek.terra.api.world.generator.ChunkData;
|
||||
import com.dfsek.terra.api.world.generator.Chunkified;
|
||||
import com.dfsek.terra.api.world.generator.GeneratorWrapper;
|
||||
import com.dfsek.terra.api.world.generator.ChunkGenerator;
|
||||
import com.dfsek.terra.fabric.FabricEntryPoint;
|
||||
import com.dfsek.terra.fabric.TerraFabricPlugin;
|
||||
import com.dfsek.terra.fabric.block.FabricBlockState;
|
||||
import com.dfsek.terra.fabric.mixin.StructureAccessorAccessor;
|
||||
@@ -44,7 +45,7 @@ public class FabricChunkGeneratorWrapper extends net.minecraft.world.gen.chunk.C
|
||||
config -> config.group(
|
||||
Codec.STRING.fieldOf("pack")
|
||||
.forGetter(ConfigPack::getID)
|
||||
).apply(config, config.stable(TerraFabricPlugin.getInstance().getConfigRegistry()::get)));
|
||||
).apply(config, config.stable(FabricEntryPoint.getTerraPlugin().getConfigRegistry()::get)));
|
||||
|
||||
public static final Codec<FabricChunkGeneratorWrapper> CODEC = RecordCodecBuilder.create(
|
||||
instance -> instance.group(
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.dfsek.terra.fabric.generation;
|
||||
import com.dfsek.terra.api.config.ConfigPack;
|
||||
import com.dfsek.terra.api.world.biome.TerraBiome;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
import com.dfsek.terra.fabric.FabricEntryPoint;
|
||||
import com.dfsek.terra.fabric.TerraFabricPlugin;
|
||||
import com.dfsek.terra.fabric.util.FabricUtil;
|
||||
import com.mojang.serialization.Codec;
|
||||
@@ -19,7 +20,7 @@ import java.util.stream.Collectors;
|
||||
public class TerraBiomeSource extends BiomeSource {
|
||||
public static final Codec<ConfigPack> PACK_CODEC = (RecordCodecBuilder.create(config -> config.group(
|
||||
Codec.STRING.fieldOf("pack").forGetter(ConfigPack::getID)
|
||||
).apply(config, config.stable(TerraFabricPlugin.getInstance().getConfigRegistry()::get))));
|
||||
).apply(config, config.stable(FabricEntryPoint.getTerraPlugin().getConfigRegistry()::get))));
|
||||
public static final Codec<TerraBiomeSource> CODEC = RecordCodecBuilder.create(instance -> instance.group(
|
||||
RegistryLookupCodec.of(Registry.BIOME_KEY).forGetter(source -> source.biomeRegistry),
|
||||
Codec.LONG.fieldOf("seed").stable().forGetter(source -> source.seed),
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.dfsek.terra.fabric.generation;
|
||||
|
||||
import com.dfsek.terra.api.config.ConfigPack;
|
||||
import com.dfsek.terra.fabric.FabricEntryPoint;
|
||||
import com.dfsek.terra.fabric.TerraFabricPlugin;
|
||||
import com.dfsek.terra.fabric.event.BiomeRegistrationEvent;
|
||||
import net.fabricmc.api.EnvType;
|
||||
@@ -25,7 +26,7 @@ public class TerraGeneratorType extends GeneratorType {
|
||||
@Override
|
||||
public GeneratorOptions createDefaultOptions(DynamicRegistryManager.Impl registryManager, long seed, boolean generateStructures, boolean bonusChest) {
|
||||
GeneratorOptions options = super.createDefaultOptions(registryManager, seed, generateStructures, bonusChest);
|
||||
TerraFabricPlugin.getInstance().getEventManager().callEvent(new BiomeRegistrationEvent(registryManager)); // register biomes
|
||||
FabricEntryPoint.getTerraPlugin().getEventManager().callEvent(new BiomeRegistrationEvent(registryManager)); // register biomes
|
||||
return options;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.dfsek.terra.fabric.mixin;
|
||||
import com.dfsek.terra.api.command.exception.CommandException;
|
||||
import com.dfsek.terra.api.entity.CommandSender;
|
||||
import com.dfsek.terra.api.entity.Entity;
|
||||
import com.dfsek.terra.fabric.FabricEntryPoint;
|
||||
import com.dfsek.terra.fabric.TerraFabricPlugin;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
@@ -33,7 +34,7 @@ public abstract class CommandManagerMixin {
|
||||
|
||||
@Inject(method = "<init>", at = @At(value = "INVOKE", target = "Lcom/mojang/brigadier/CommandDispatcher;findAmbiguities(Lcom/mojang/brigadier/AmbiguityConsumer;)V", remap = false))
|
||||
private void injectTerraCommands(CommandManager.RegistrationEnvironment environment, CallbackInfo ci) {
|
||||
com.dfsek.terra.api.command.CommandManager manager = TerraFabricPlugin.getInstance().getManager();
|
||||
com.dfsek.terra.api.command.CommandManager manager = FabricEntryPoint.getTerraPlugin().getManager();
|
||||
int max = manager.getMaxArgumentDepth();
|
||||
RequiredArgumentBuilder<ServerCommandSource, String> arg = argument("arg" + (max - 1), StringArgumentType.word());
|
||||
for(int i = 0; i < max; i++) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.dfsek.terra.fabric.mixin;
|
||||
|
||||
import com.dfsek.terra.fabric.FabricEntryPoint;
|
||||
import com.dfsek.terra.fabric.TerraFabricPlugin;
|
||||
import com.dfsek.terra.fabric.generation.FabricChunkGeneratorWrapper;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
@@ -26,7 +27,7 @@ public abstract class ServerWorldMixin {
|
||||
public void injectConstructor(MinecraftServer server, Executor workerExecutor, LevelStorage.Session session, ServerWorldProperties properties, RegistryKey<World> registryKey, DimensionType dimensionType, WorldGenerationProgressListener worldGenerationProgressListener, ChunkGenerator chunkGenerator, boolean debugWorld, long l, List<Spawner> list, boolean bl, CallbackInfo ci) {
|
||||
if(chunkGenerator instanceof FabricChunkGeneratorWrapper) {
|
||||
((FabricChunkGeneratorWrapper) chunkGenerator).setWorld((ServerWorld) (Object) this);
|
||||
TerraFabricPlugin.getInstance().logger().info("Registered world " + this);
|
||||
FabricEntryPoint.getTerraPlugin().logger().info("Registered world " + this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.dfsek.terra.api.util.collection.MaterialSet;
|
||||
import com.dfsek.terra.api.vector.Vector3;
|
||||
import com.dfsek.terra.api.world.Tree;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
import com.dfsek.terra.fabric.FabricEntryPoint;
|
||||
import com.dfsek.terra.fabric.TerraFabricPlugin;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.registry.BuiltinRegistries;
|
||||
@@ -32,7 +33,7 @@ public abstract class ConfiguredFeatureMixin {
|
||||
@SuppressWarnings({"ConstantConditions", "try"})
|
||||
public boolean terra$plant(Vector3 l, World world, Random r) {
|
||||
String id = BuiltinRegistries.CONFIGURED_FEATURE.getId((ConfiguredFeature<?, ?>) (Object) this).toString();
|
||||
try(ProfileFrame ignore = TerraFabricPlugin.getInstance().getProfiler().profile("fabric_tree:" + id.toLowerCase(Locale.ROOT))) {
|
||||
try(ProfileFrame ignore = FabricEntryPoint.getTerraPlugin().getProfiler().profile("fabric_tree:" + id.toLowerCase(Locale.ROOT))) {
|
||||
StructureWorldAccess fabricWorldAccess = ((StructureWorldAccess) world);
|
||||
ChunkGenerator generatorWrapper = ((ServerWorldAccess) world).toServerWorld().getChunkManager().getChunkGenerator();
|
||||
return generate(fabricWorldAccess, generatorWrapper, r, new BlockPos(l.getBlockX(), l.getBlockY(), l.getBlockZ()));
|
||||
@@ -40,8 +41,8 @@ public abstract class ConfiguredFeatureMixin {
|
||||
}
|
||||
|
||||
public Set<BlockType> terra$getSpawnable() {
|
||||
return MaterialSet.get(TerraFabricPlugin.getInstance().getWorldHandle().createBlockData("minecraft:grass_block"),
|
||||
TerraFabricPlugin.getInstance().getWorldHandle().createBlockData("minecraft:podzol"),
|
||||
TerraFabricPlugin.getInstance().getWorldHandle().createBlockData("minecraft:mycelium"));
|
||||
return MaterialSet.get(FabricEntryPoint.getTerraPlugin().getWorldHandle().createBlockData("minecraft:grass_block"),
|
||||
FabricEntryPoint.getTerraPlugin().getWorldHandle().createBlockData("minecraft:podzol"),
|
||||
FabricEntryPoint.getTerraPlugin().getWorldHandle().createBlockData("minecraft:mycelium"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.dfsek.terra.fabric.mixin.implementations.block.state;
|
||||
import com.dfsek.terra.api.block.entity.MobSpawner;
|
||||
import com.dfsek.terra.api.block.entity.SerialState;
|
||||
import com.dfsek.terra.api.entity.EntityType;
|
||||
import com.dfsek.terra.fabric.FabricEntryPoint;
|
||||
import com.dfsek.terra.fabric.TerraFabricPlugin;
|
||||
import com.dfsek.terra.fabric.mixin.access.MobSpawnerLogicAccessor;
|
||||
import net.minecraft.block.BlockState;
|
||||
@@ -96,7 +97,7 @@ public abstract class MobSpawnerBlockEntityMixin extends BlockEntity {
|
||||
SerialState.parse(state).forEach((k, v) -> {
|
||||
switch(k) {
|
||||
case "type":
|
||||
terra$setSpawnedType(TerraFabricPlugin.getInstance().getWorldHandle().getEntity(v));
|
||||
terra$setSpawnedType(FabricEntryPoint.getTerraPlugin().getWorldHandle().getEntity(v));
|
||||
return;
|
||||
case "delay":
|
||||
terra$setDelay(Integer.parseInt(v));
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.dfsek.terra.fabric.mixin.lifecycle.client;
|
||||
|
||||
import com.dfsek.terra.fabric.FabricEntryPoint;
|
||||
import com.dfsek.terra.fabric.TerraFabricPlugin;
|
||||
import com.dfsek.terra.api.event.events.platform.PlatformInitializationEvent;
|
||||
import com.dfsek.terra.fabric.generation.TerraGeneratorType;
|
||||
@@ -19,8 +20,8 @@ public class MinecraftClientMixin {
|
||||
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) {
|
||||
TerraFabricPlugin.getInstance().getEventManager().callEvent(new PlatformInitializationEvent());
|
||||
TerraFabricPlugin.getInstance().getConfigRegistry().forEach(pack -> {
|
||||
FabricEntryPoint.getTerraPlugin().getEventManager().callEvent(new PlatformInitializationEvent());
|
||||
FabricEntryPoint.getTerraPlugin().getConfigRegistry().forEach(pack -> {
|
||||
final GeneratorType generatorType = new TerraGeneratorType(pack);
|
||||
//noinspection ConstantConditions
|
||||
((GeneratorTypeAccessor) generatorType).setTranslationKey(new LiteralText("Terra:" + pack.getID()));
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package com.dfsek.terra.fabric.mixin.lifecycle.server;
|
||||
|
||||
import com.dfsek.terra.api.config.ConfigPack;
|
||||
import com.dfsek.terra.fabric.FabricEntryPoint;
|
||||
import com.dfsek.terra.fabric.TerraFabricPlugin;
|
||||
import com.dfsek.terra.fabric.TerraPluginImpl;
|
||||
import com.dfsek.terra.fabric.event.BiomeRegistrationEvent;
|
||||
import com.dfsek.terra.fabric.generation.FabricChunkGeneratorWrapper;
|
||||
import com.dfsek.terra.fabric.generation.TerraBiomeSource;
|
||||
@@ -30,7 +32,7 @@ public abstract class GeneratorOptionsMixin {
|
||||
return;
|
||||
}
|
||||
|
||||
TerraFabricPlugin main = TerraFabricPlugin.getInstance();
|
||||
TerraPluginImpl main = FabricEntryPoint.getTerraPlugin();
|
||||
|
||||
String prop = properties.get("level-type").toString().trim();
|
||||
if(prop.startsWith("Terra")) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.dfsek.terra.fabric.mixin.lifecycle.server;
|
||||
|
||||
import com.dfsek.terra.fabric.FabricEntryPoint;
|
||||
import com.dfsek.terra.fabric.TerraFabricPlugin;
|
||||
import com.dfsek.terra.api.event.events.platform.PlatformInitializationEvent;
|
||||
import net.minecraft.server.Main;
|
||||
@@ -12,6 +13,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
public class ServerMainMixin {
|
||||
@Inject(method = "main([Ljava/lang/String;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/registry/DynamicRegistryManager;create()Lnet/minecraft/util/registry/DynamicRegistryManager$Impl;"))
|
||||
private static void injectConstructor(String[] args, CallbackInfo ci) {
|
||||
TerraFabricPlugin.getInstance().getEventManager().callEvent(new PlatformInitializationEvent()); // Load during MinecraftServer construction, after other mods have registered blocks and stuff
|
||||
FabricEntryPoint.getTerraPlugin().getEventManager().callEvent(new PlatformInitializationEvent()); // Load during MinecraftServer construction, after other mods have registered blocks and stuff
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ public final class FabricUtil {
|
||||
// BiomeTemplate template = biome.getTemplate();
|
||||
Map<String, Integer> colors = new HashMap<>(); // template.getColors();
|
||||
|
||||
TerraFabricPlugin.FabricAddon fabricAddon = TerraFabricPlugin.getInstance().getFabricAddon();
|
||||
//TerraFabricPlugin.FabricAddon fabricAddon = TerraFabricPlugin.getInstance().getFabricAddon();
|
||||
|
||||
Registry<Biome> biomeRegistry = registryManager.get(Registry.BIOME_KEY);
|
||||
Biome vanilla = ((ProtoBiome) (new ArrayList<>(biome.getVanillaBiomes().getContents()).get(0))).get(biomeRegistry);
|
||||
|
||||
Reference in New Issue
Block a user