mirror of
https://github.com/FabricMC/fabric.git
synced 2025-03-21 20:50:28 -04:00
Hopefully fix mod datapacks
This commit is contained in:
parent
dd263cca8b
commit
277876c741
5 changed files with 24 additions and 40 deletions
build.gradle
fabric-resource-loader-v0
|
@ -12,7 +12,7 @@ plugins {
|
|||
def ENV = System.getenv()
|
||||
|
||||
class Globals {
|
||||
static def baseVersion = "0.11.3"
|
||||
static def baseVersion = "0.11.4"
|
||||
static def mcVersion = "1.16-pre1"
|
||||
static def yarnVersion = "+build.1"
|
||||
}
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
archivesBaseName = "fabric-resource-loader-v0"
|
||||
version = getSubprojectVersion(project, "0.2.1")
|
||||
version = getSubprojectVersion(project, "0.2.2")
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package net.fabricmc.fabric.mixin.resource.loader;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyArg;
|
||||
|
||||
import net.minecraft.resource.ResourceType;
|
||||
import net.minecraft.server.Main;
|
||||
import net.minecraft.resource.ResourcePackProvider;
|
||||
|
||||
import net.fabricmc.fabric.impl.resource.loader.ModResourcePackCreator;
|
||||
|
||||
@Mixin(Main.class)
|
||||
public class MixinMinecraftServer {
|
||||
@ModifyArg(method = "main", at = @At(value = "INVOKE", target = "Lnet/minecraft/resource/ResourcePackManager;<init>(Lnet/minecraft/resource/ResourcePackProfile$class_5351;[Lnet/minecraft/resource/ResourcePackProvider;)V"))
|
||||
private static ResourcePackProvider[] appendFabricDataPacks(ResourcePackProvider[] packProviders) {
|
||||
return ArrayUtils.add(packProviders, new ModResourcePackCreator(ResourceType.SERVER_DATA));
|
||||
}
|
||||
}
|
|
@ -17,20 +17,41 @@
|
|||
package net.fabricmc.fabric.mixin.resource.loader;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Mutable;
|
||||
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.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import net.minecraft.resource.ResourcePack;
|
||||
import net.minecraft.resource.ResourcePackManager;
|
||||
import net.minecraft.resource.ResourcePackProfile;
|
||||
import net.minecraft.resource.ResourcePackProvider;
|
||||
import net.minecraft.resource.ResourceType;
|
||||
|
||||
import net.fabricmc.fabric.impl.resource.loader.ModResourcePackUtil;
|
||||
import net.fabricmc.fabric.impl.resource.loader.ModResourcePackCreator;
|
||||
|
||||
@Mixin(ResourcePackManager.class)
|
||||
public class MixinResourcePackManager {
|
||||
public class MixinResourcePackManager<T extends ResourcePackProfile> {
|
||||
@Shadow
|
||||
@Final
|
||||
@Mutable
|
||||
private Set<ResourcePackProvider> providers;
|
||||
|
||||
@Inject(method = "<init>", at = @At("RETURN"))
|
||||
public void construct(ResourcePackProfile.class_5351<T> arg, ResourcePackProvider[] resourcePackProviders, CallbackInfo info) {
|
||||
providers = new HashSet<>(providers);
|
||||
providers.add(new ModResourcePackCreator(ResourceType.SERVER_DATA));
|
||||
}
|
||||
|
||||
@Inject(method = "method_29211", at = @At("RETURN"), cancellable = true)
|
||||
public void method_29211(CallbackInfoReturnable<List<ResourcePack>> infoReturnable) {
|
||||
List<ResourcePack> list = new ArrayList<>(infoReturnable.getReturnValue());
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
"compatibilityLevel": "JAVA_8",
|
||||
"mixins": [
|
||||
"MixinKeyedResourceReloadListener$Server",
|
||||
"MixinMinecraftServer",
|
||||
"MixinReloadableResourceManagerImpl",
|
||||
"MixinDefaultResourcePack"
|
||||
],
|
||||
|
|
Loading…
Reference in a new issue