Added Screen to confirm Patches
This commit is contained in:
parent
c93c271bd4
commit
a247b17e7f
8 changed files with 384 additions and 26 deletions
|
@ -5,16 +5,19 @@ import net.minecraft.client.color.block.BlockColors;
|
|||
import net.minecraft.client.color.item.ItemColors;
|
||||
import net.minecraft.client.main.GameConfig;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.world.level.storage.LevelStorageSource;
|
||||
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.ModifyArg;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import ru.bclib.api.datafixer.DataFixerAPI;
|
||||
import ru.bclib.interfaces.CustomColorProvider;
|
||||
|
||||
@Mixin(Minecraft.class)
|
||||
public class MinecraftMixin {
|
||||
public abstract class MinecraftMixin {
|
||||
@Final
|
||||
@Shadow
|
||||
private BlockColors blockColors;
|
||||
|
@ -33,4 +36,51 @@ public class MinecraftMixin {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Shadow @Final private LevelStorageSource levelSource;
|
||||
@Shadow public abstract void loadLevel(String string);
|
||||
private final String BCLIB_RECURSION = "$@BCLIB:";
|
||||
|
||||
@Inject(method="loadLevel", cancellable = true, at=@At("HEAD"))
|
||||
private void bclib_callFixerOnLoad(String levelID, CallbackInfo ci){
|
||||
boolean recursiveCall = false;
|
||||
if (levelID.startsWith(BCLIB_RECURSION)) {
|
||||
levelID = levelID.substring(BCLIB_RECURSION.length());
|
||||
recursiveCall = true;
|
||||
}
|
||||
|
||||
final String recursiveLevelID = BCLIB_RECURSION + levelID;
|
||||
if (!recursiveCall && DataFixerAPI.fixData(this.levelSource, levelID, true, (appliedFixes)->{
|
||||
this.loadLevel(recursiveLevelID);
|
||||
})){
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@ModifyArg(method="loadLevel", at=@At(value="INVOKE", target="Lnet/minecraft/client/Minecraft;doLoadLevel(Ljava/lang/String;Lnet/minecraft/core/RegistryAccess$RegistryHolder;Ljava/util/function/Function;Lcom/mojang/datafixers/util/Function4;ZLnet/minecraft/client/Minecraft$ExperimentalDialogType;)V"))
|
||||
private String bclib_correctLevelID(String levelID){
|
||||
if (levelID.startsWith(BCLIB_RECURSION)) {
|
||||
levelID = levelID.substring(BCLIB_RECURSION.length());
|
||||
}
|
||||
|
||||
return levelID;
|
||||
}
|
||||
|
||||
|
||||
// @Inject(method="doLoadLevel", cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD, at=@At(value="INVOKE", target="Lnet/minecraft/client/Minecraft;makeServerStem(Lnet/minecraft/core/RegistryAccess$RegistryHolder;Ljava/util/function/Function;Lcom/mojang/datafixers/util/Function4;ZLnet/minecraft/world/level/storage/LevelStorageSource$LevelStorageAccess;)Lnet/minecraft/client/Minecraft$ServerStem;"))
|
||||
// private void bclib_onCallFixer(
|
||||
// String string,
|
||||
// RegistryHolder registryHolder,
|
||||
// Function<LevelStorageAccess, DataPackConfig> function,
|
||||
// Function4<LevelStorageAccess, RegistryHolder, ResourceManager, DataPackConfig, WorldData> function4,
|
||||
// boolean bl,
|
||||
// ExperimentalDialogType experimentalDialogType,
|
||||
// CallbackInfo ci,
|
||||
// LevelStorageSource.LevelStorageAccess levelStorageAccess) {
|
||||
//
|
||||
// DataFixerAPI.fixData(levelStorageAccess);
|
||||
// ci.cancel();
|
||||
//
|
||||
// }
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ import net.minecraft.server.MinecraftServer;
|
|||
import net.minecraft.server.ServerResources;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.storage.LevelResource;
|
||||
import net.minecraft.world.level.storage.LevelStorageSource;
|
||||
import net.minecraft.world.level.storage.WorldData;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
|
@ -17,11 +16,8 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
|||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
import ru.bclib.api.BiomeAPI;
|
||||
import ru.bclib.api.WorldDataAPI;
|
||||
import ru.bclib.api.datafixer.DataFixerAPI;
|
||||
import ru.bclib.recipes.BCLRecipeManager;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
@ -38,12 +34,14 @@ public class MinecraftServerMixin {
|
|||
@Final
|
||||
@Shadow
|
||||
protected WorldData worldData;
|
||||
|
||||
|
||||
@Inject(method="convertFromRegionFormatIfNeeded", at = @At("HEAD"))
|
||||
private static void bclib_applyPatches(LevelStorageSource.LevelStorageAccess session, CallbackInfo ci){
|
||||
File levelPath = session.getLevelPath(LevelResource.ROOT).toFile();
|
||||
|
||||
/*File levelPath = session.getLevelPath(LevelResource.ROOT).toFile();
|
||||
WorldDataAPI.load(new File(levelPath, "data"));
|
||||
DataFixerAPI.fixData(levelPath);
|
||||
DataFixerAPI.fixData(levelPath, session.getLevelId());*/
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue