Merge branch 'main' of github.com-quiqueck:paulevsGitch/BCLib

This commit is contained in:
Frank 2021-12-05 11:31:18 +01:00
commit 6adbe5dd04
5 changed files with 30 additions and 9 deletions

View file

@ -11,7 +11,7 @@ loader_version= 0.12.8
fabric_version = 0.44.0+1.18 fabric_version = 0.44.0+1.18
# Mod Properties # Mod Properties
mod_version = 1.0.1 mod_version = 1.0.2
maven_group = ru.bclib maven_group = ru.bclib
archives_base_name = bclib archives_base_name = bclib

View file

@ -1,4 +1,4 @@
package ru.bclib.mixin.common; package ru.bclib.mixin.client;
import net.minecraft.client.gui.screens.worldselection.WorldPreset; import net.minecraft.client.gui.screens.worldselection.WorldPreset;
import net.minecraft.core.Registry; import net.minecraft.core.Registry;

View file

@ -1,19 +1,41 @@
package ru.bclib.mixin.common; package ru.bclib.mixin.common;
import joptsimple.ArgumentAcceptingOptionSpec;
import joptsimple.OptionParser;
import joptsimple.OptionSet;
import net.minecraft.server.Main; import net.minecraft.server.Main;
import net.minecraft.server.dedicated.DedicatedServerSettings;
import net.minecraft.world.level.storage.LevelStorageSource; import net.minecraft.world.level.storage.LevelStorageSource;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyArg; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import ru.bclib.api.LifeCycleAPI; import ru.bclib.api.LifeCycleAPI;
import ru.bclib.api.datafixer.DataFixerAPI; import ru.bclib.api.datafixer.DataFixerAPI;
import java.io.File;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Optional;
@Mixin(Main.class) @Mixin(Main.class)
abstract public class MainMixin { abstract public class MainMixin {
@ModifyArg(method="main", at=@At(value="INVOKE_ASSIGN", target="Lnet/minecraft/world/level/storage/LevelStorageSource$LevelStorageAccess;getSummary()Lnet/minecraft/world/level/storage/LevelSummary;")) @Inject(method="main", at=@At(value="INVOKE", target="Lnet/minecraft/world/level/storage/LevelStorageSource;createDefault(Ljava/nio/file/Path;)Lnet/minecraft/world/level/storage/LevelStorageSource;"))
private static LevelStorageSource.LevelStorageAccess bclib_callServerFix(LevelStorageSource.LevelStorageAccess session){ private static void bclib_callServerFix(String[] args, CallbackInfo ci){
DataFixerAPI.fixData(session, false, (didFix)->{/* not called when showUI==false */}); OptionParser parser = new OptionParser();
ArgumentAcceptingOptionSpec<String> optionUniverse = parser.accepts("universe").withRequiredArg().defaultsTo(".", new String[0]);
ArgumentAcceptingOptionSpec<String> optionWorld = parser.accepts("world").withRequiredArg();
OptionSet options = parser.parse(args);
Path settingPath = Paths.get("server.properties", new String[0]);
DedicatedServerSettings settings = new DedicatedServerSettings(settingPath);
File file = new File(options.valueOf(optionUniverse));
String levelID = Optional.ofNullable(options.valueOf(optionWorld)).orElse(settings.getProperties().levelName);
LevelStorageSource levelStorageSource = LevelStorageSource.createDefault(file.toPath());
DataFixerAPI.fixData(levelStorageSource, levelID, false, (didFix)->{/* not called when showUI==false */});
LifeCycleAPI._runBeforeLevelLoad(); LifeCycleAPI._runBeforeLevelLoad();
return session;
} }
} }

View file

@ -14,7 +14,7 @@
"ModelBakeryMixin", "ModelBakeryMixin",
"MinecraftMixin", "MinecraftMixin",
"GameMixin", "GameMixin",
"GameMixin" "WorldPresetMixin"
], ],
"injectors": { "injectors": {
"defaultRequire": 1 "defaultRequire": 1

View file

@ -34,7 +34,6 @@
"shears.SheepMixin", "shears.SheepMixin",
"PortalShapeMixin", "PortalShapeMixin",
"ServerLevelMixin", "ServerLevelMixin",
"WorldPresetMixin",
"AnvilBlockMixin", "AnvilBlockMixin",
"AnvilMenuMixin", "AnvilMenuMixin",
"TagLoaderMixin", "TagLoaderMixin",