Merge branch 'main' of github.com-quiqueck:paulevsGitch/BCLib
This commit is contained in:
commit
8d6dc18ce2
2 changed files with 33 additions and 40 deletions
|
@ -3,7 +3,6 @@ package ru.bclib.mixin.common;
|
||||||
import com.mojang.authlib.GameProfileRepository;
|
import com.mojang.authlib.GameProfileRepository;
|
||||||
import com.mojang.authlib.minecraft.MinecraftSessionService;
|
import com.mojang.authlib.minecraft.MinecraftSessionService;
|
||||||
import com.mojang.datafixers.DataFixer;
|
import com.mojang.datafixers.DataFixer;
|
||||||
import net.fabricmc.loader.api.FabricLoader;
|
|
||||||
import net.minecraft.core.RegistryAccess.RegistryHolder;
|
import net.minecraft.core.RegistryAccess.RegistryHolder;
|
||||||
import net.minecraft.resources.ResourceKey;
|
import net.minecraft.resources.ResourceKey;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
@ -34,45 +33,44 @@ import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
@Mixin(MinecraftServer.class)
|
@Mixin(MinecraftServer.class)
|
||||||
public class MinecraftServerMixin {
|
public class MinecraftServerMixin {
|
||||||
@Shadow
|
@Shadow
|
||||||
private ServerResources resources;
|
private ServerResources resources;
|
||||||
|
|
||||||
@Final
|
|
||||||
@Shadow
|
|
||||||
private Map<ResourceKey<Level>, ServerLevel> levels;
|
|
||||||
|
|
||||||
@Final
|
|
||||||
@Shadow
|
|
||||||
protected WorldData worldData;
|
|
||||||
@Inject(method = "<init>*", at = @At("TAIL"))
|
|
||||||
private void bclib_onServerInit(Thread thread, RegistryHolder registryHolder, LevelStorageAccess levelStorageAccess, WorldData worldData, PackRepository packRepository, Proxy proxy, DataFixer dataFixer, ServerResources serverResources, MinecraftSessionService minecraftSessionService, GameProfileRepository gameProfileRepository, GameProfileCache gameProfileCache, ChunkProgressListenerFactory chunkProgressListenerFactory, CallbackInfo ci){
|
|
||||||
DataExchangeAPI.prepareServerside();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject(method="convertFromRegionFormatIfNeeded", at = @At("HEAD"))
|
@Final
|
||||||
private static void bclib_applyPatches(LevelStorageSource.LevelStorageAccess session, CallbackInfo ci){
|
@Shadow
|
||||||
|
private Map<ResourceKey<Level>, ServerLevel> levels;
|
||||||
|
|
||||||
|
@Final
|
||||||
|
@Shadow
|
||||||
|
protected WorldData worldData;
|
||||||
|
|
||||||
|
@Inject(method = "<init>*", at = @At("TAIL"))
|
||||||
|
private void bclib_onServerInit(Thread thread, RegistryHolder registryHolder, LevelStorageAccess levelStorageAccess, WorldData worldData, PackRepository packRepository, Proxy proxy, DataFixer dataFixer, ServerResources serverResources, MinecraftSessionService minecraftSessionService, GameProfileRepository gameProfileRepository, GameProfileCache gameProfileCache, ChunkProgressListenerFactory chunkProgressListenerFactory, CallbackInfo ci) {
|
||||||
|
DataExchangeAPI.prepareServerside();
|
||||||
|
}
|
||||||
|
|
||||||
|
@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"));
|
WorldDataAPI.load(new File(levelPath, "data"));
|
||||||
DataFixerAPI.fixData(levelPath, session.getLevelId());*/
|
DataFixerAPI.fixData(levelPath, session.getLevelId());*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Inject(method = "reloadResources", at = @At(value = "RETURN"), cancellable = true)
|
@Inject(method = "reloadResources", at = @At(value = "RETURN"), cancellable = true)
|
||||||
private void bclib_reloadResources(Collection<String> collection, CallbackInfoReturnable<CompletableFuture<Void>> info) {
|
private void bclib_reloadResources(Collection<String> collection, CallbackInfoReturnable<CompletableFuture<Void>> info) {
|
||||||
bclib_injectRecipes();
|
bclib_injectRecipes();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "loadLevel", at = @At(value = "RETURN"), cancellable = true)
|
@Inject(method = "loadLevel", at = @At(value = "RETURN"), cancellable = true)
|
||||||
private void bclib_loadLevel(CallbackInfo info) {
|
private void bclib_loadLevel(CallbackInfo info) {
|
||||||
bclib_injectRecipes();
|
bclib_injectRecipes();
|
||||||
BiomeAPI.initRegistry(MinecraftServer.class.cast(this));
|
BiomeAPI.initRegistry(MinecraftServer.class.cast(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void bclib_injectRecipes() {
|
private void bclib_injectRecipes() {
|
||||||
if (FabricLoader.getInstance().isModLoaded("kubejs")) {
|
RecipeManagerAccessor accessor = (RecipeManagerAccessor) resources.getRecipeManager();
|
||||||
RecipeManagerAccessor accessor = (RecipeManagerAccessor) resources.getRecipeManager();
|
accessor.bclib_setRecipes(BCLRecipeManager.getMap(accessor.bclib_getRecipes()));
|
||||||
accessor.bclib_setRecipes(BCLRecipeManager.getMap(accessor.bclib_getRecipes()));
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,11 +29,6 @@ public abstract class RecipeManagerMixin {
|
||||||
@Shadow
|
@Shadow
|
||||||
private Map<RecipeType<?>, Map<ResourceLocation, Recipe<?>>> recipes;
|
private Map<RecipeType<?>, Map<ResourceLocation, Recipe<?>>> recipes;
|
||||||
|
|
||||||
@Inject(method = "apply", at = @At(value = "RETURN"))
|
|
||||||
private void be_apply(Map<ResourceLocation, JsonElement> map, ResourceManager resourceManager, ProfilerFiller profiler, CallbackInfo info) {
|
|
||||||
recipes = BCLRecipeManager.getMap(recipes);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Shadow
|
@Shadow
|
||||||
private <C extends Container, T extends Recipe<C>> Map<ResourceLocation, Recipe<C>> byType(RecipeType<T> type) {
|
private <C extends Container, T extends Recipe<C>> Map<ResourceLocation, Recipe<C>> byType(RecipeType<T> type) {
|
||||||
return null;
|
return null;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue