Merge branch 'release-2.4.4' into develop
This commit is contained in:
@@ -32,8 +32,6 @@ import org.apache.commons.io.FileUtils;
|
|||||||
|
|
||||||
//#if MC>=11400
|
//#if MC>=11400
|
||||||
import net.minecraft.client.options.Option;
|
import net.minecraft.client.options.Option;
|
||||||
import net.minecraft.resource.ResourcePackProvider;
|
|
||||||
import net.minecraft.resource.ResourcePackProfile;
|
|
||||||
import net.minecraft.util.thread.ReentrantThreadExecutor;
|
import net.minecraft.util.thread.ReentrantThreadExecutor;
|
||||||
//#endif
|
//#endif
|
||||||
|
|
||||||
@@ -185,14 +183,6 @@ public class ReplayMod implements
|
|||||||
}
|
}
|
||||||
//#endif
|
//#endif
|
||||||
|
|
||||||
//#if MC>=11400
|
|
||||||
// Not needed on fabric, using MixinModResourcePackUtil instead. Could in theory also use it on 1.13 but it already works as is.
|
|
||||||
//#else
|
|
||||||
//#if MC>=11400
|
|
||||||
//$$ DeferredWorkQueue.runLater(() -> MCVer.getMinecraft().getResourcePackList().addPackFinder(new LangResourcePack.Finder()));
|
|
||||||
//#endif
|
|
||||||
//#endif
|
|
||||||
|
|
||||||
// Register all RM modules
|
// Register all RM modules
|
||||||
modules.add(this);
|
modules.add(this);
|
||||||
modules.add(new ReplayModRecording(this));
|
modules.add(new ReplayModRecording(this));
|
||||||
@@ -235,6 +225,7 @@ public class ReplayMod implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static final DirectoryResourcePack jGuiResourcePack;
|
public static final DirectoryResourcePack jGuiResourcePack;
|
||||||
|
public static final String JGUI_RESOURCE_PACK_NAME = "replaymod_jgui";
|
||||||
static { // Note: even preInit is too late and we'd have to issue another resource reload
|
static { // Note: even preInit is too late and we'd have to issue another resource reload
|
||||||
jGuiResourcePack = initJGuiResourcePack();
|
jGuiResourcePack = initJGuiResourcePack();
|
||||||
}
|
}
|
||||||
@@ -246,6 +237,15 @@ public class ReplayMod implements
|
|||||||
}
|
}
|
||||||
//noinspection UnnecessaryLocalVariable
|
//noinspection UnnecessaryLocalVariable
|
||||||
DirectoryResourcePack jGuiResourcePack = new DirectoryResourcePack(folder) {
|
DirectoryResourcePack jGuiResourcePack = new DirectoryResourcePack(folder) {
|
||||||
|
@Override
|
||||||
|
//#if MC>=11400
|
||||||
|
public String getName() {
|
||||||
|
//#else
|
||||||
|
//$$ public String getPackName() {
|
||||||
|
//#endif
|
||||||
|
return JGUI_RESOURCE_PACK_NAME;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected InputStream openFile(String resourceName) throws IOException {
|
protected InputStream openFile(String resourceName) throws IOException {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -1,40 +0,0 @@
|
|||||||
//#if FABRIC>=1
|
|
||||||
package com.replaymod.core.mixin;
|
|
||||||
|
|
||||||
import com.replaymod.core.ReplayMod;
|
|
||||||
import com.replaymod.core.versions.LangResourcePack;
|
|
||||||
import net.fabricmc.fabric.api.resource.ModResourcePack;
|
|
||||||
import net.fabricmc.fabric.impl.resource.loader.ModResourcePackUtil;
|
|
||||||
import net.fabricmc.loader.api.FabricLoader;
|
|
||||||
import net.fabricmc.loader.api.ModContainer;
|
|
||||||
import net.minecraft.resource.ResourcePack;
|
|
||||||
import net.minecraft.resource.ResourceType;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Mixin(value = ModResourcePackUtil.class, remap = false)
|
|
||||||
public class MixinModResourcePackUtil {
|
|
||||||
@Inject(method = "appendModResourcePacks", at = @At("RETURN"), remap = false)
|
|
||||||
private static void injectRMLangPack(List<ResourcePack> packList, ResourceType type, CallbackInfo ci) {
|
|
||||||
if (type != ResourceType.CLIENT_RESOURCES) return;
|
|
||||||
|
|
||||||
for (int i = 0; i < packList.size(); i++) {
|
|
||||||
ResourcePack pack = packList.get(i);
|
|
||||||
if (pack instanceof ModResourcePack && ((ModResourcePack) pack).getFabricModMetadata().getId().equals(ReplayMod.MOD_ID)) {
|
|
||||||
ModContainer container = FabricLoader.getInstance().getModContainer(ReplayMod.MOD_ID).orElseThrow(IllegalAccessError::new);
|
|
||||||
packList.add(i, new LangResourcePack(container.getRootPath()));
|
|
||||||
if (ReplayMod.jGuiResourcePack != null) {
|
|
||||||
packList.add(i, ReplayMod.jGuiResourcePack);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new IllegalStateException("Could not find ReplayMod resource pack.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//#endif
|
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
//#if FABRIC>=1
|
||||||
|
package com.replaymod.core.mixin;
|
||||||
|
|
||||||
|
import net.minecraft.client.gui.screen.pack.PackListWidget;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
//#if MC>=11600
|
||||||
|
import net.minecraft.client.gui.screen.pack.PackScreen;
|
||||||
|
import net.minecraft.client.gui.screen.pack.ResourcePackOrganizer;
|
||||||
|
//#else
|
||||||
|
//$$ import net.minecraft.client.resource.ClientResourcePackProfile;
|
||||||
|
//#endif
|
||||||
|
|
||||||
|
//#if MC>=11600
|
||||||
|
@Mixin(PackScreen.class)
|
||||||
|
//#else
|
||||||
|
//$$ @Mixin(ResourcePackListWidget.class)
|
||||||
|
//#endif
|
||||||
|
public abstract class Mixin_HideDynamicResourcePacks {
|
||||||
|
//#if MC>=11600
|
||||||
|
@Inject(method = "method_29672", at = @At("HEAD"), cancellable = true)
|
||||||
|
private void hideInternalPacks(PackListWidget packListWidget, ResourcePackOrganizer.Pack pack, CallbackInfo info) {
|
||||||
|
//#else
|
||||||
|
//$$ @Inject(method = "add", at = @At("HEAD"), cancellable = true)
|
||||||
|
//$$ private void hideInternalPacks(ResourcePackListWidget.ResourcePackEntry entry, CallbackInfo info) {
|
||||||
|
//$$ ClientResourcePackProfile pack = entry.getPack();
|
||||||
|
//#endif
|
||||||
|
String name = pack.getDisplayName().asString();
|
||||||
|
if (name.equals("replaymod_lang") || name.equals("replaymod_jgui")) {
|
||||||
|
info.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//#endif
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
//#if FABRIC>=1
|
||||||
|
package com.replaymod.core.mixin;
|
||||||
|
|
||||||
|
import com.replaymod.core.ReplayMod;
|
||||||
|
import com.replaymod.core.versions.LangResourcePack;
|
||||||
|
import net.minecraft.client.resource.ClientBuiltinResourcePackProvider;
|
||||||
|
import net.minecraft.resource.ResourcePackProfile;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
//#if MC>=11600
|
||||||
|
import net.minecraft.resource.ResourcePackSource;
|
||||||
|
//#else
|
||||||
|
//$$ import java.util.Map;
|
||||||
|
//#endif
|
||||||
|
|
||||||
|
@Mixin(ClientBuiltinResourcePackProvider.class)
|
||||||
|
public class Mixin_RegisterDynamicResourcePacks {
|
||||||
|
@Inject(method = "register", at = @At("RETURN"))
|
||||||
|
//#if MC>=11600
|
||||||
|
private void registerReplayMod(Consumer<ResourcePackProfile> consumer, ResourcePackProfile.Factory factory, CallbackInfo ci) {
|
||||||
|
//#else
|
||||||
|
//$$ private <T extends ResourcePackProfile> void registerReplayMod(Map<String, T> map, ResourcePackProfile.Factory<T> factory, CallbackInfo ci) {
|
||||||
|
//$$ Consumer<T> consumer = (pack) -> map.put(pack.getName(), pack);
|
||||||
|
//#endif
|
||||||
|
|
||||||
|
consumer.accept(ResourcePackProfile.of(
|
||||||
|
LangResourcePack.NAME,
|
||||||
|
true,
|
||||||
|
LangResourcePack::new,
|
||||||
|
factory,
|
||||||
|
ResourcePackProfile.InsertionPosition.BOTTOM
|
||||||
|
//#if MC>=11600
|
||||||
|
, ResourcePackSource.PACK_SOURCE_BUILTIN
|
||||||
|
//#endif
|
||||||
|
));
|
||||||
|
|
||||||
|
if (ReplayMod.jGuiResourcePack != null) {
|
||||||
|
consumer.accept(ResourcePackProfile.of(
|
||||||
|
ReplayMod.JGUI_RESOURCE_PACK_NAME,
|
||||||
|
true,
|
||||||
|
() -> ReplayMod.jGuiResourcePack,
|
||||||
|
factory,
|
||||||
|
ResourcePackProfile.InsertionPosition.BOTTOM
|
||||||
|
//#if MC>=11600
|
||||||
|
, ResourcePackSource.PACK_SOURCE_BUILTIN
|
||||||
|
//#endif
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//#endif
|
||||||
@@ -27,6 +27,12 @@ import java.util.regex.Matcher;
|
|||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
//#if FABRIC>=1
|
||||||
|
import net.fabricmc.loader.api.FabricLoader;
|
||||||
|
import net.fabricmc.loader.api.ModContainer;
|
||||||
|
//#else
|
||||||
|
//#endif
|
||||||
|
|
||||||
//#if MC>=11400
|
//#if MC>=11400
|
||||||
//#else
|
//#else
|
||||||
//$$ import net.minecraft.resources.IPackFinder;
|
//$$ import net.minecraft.resources.IPackFinder;
|
||||||
@@ -42,7 +48,7 @@ import java.util.stream.Collectors;
|
|||||||
*/
|
*/
|
||||||
public class LangResourcePack extends AbstractFileResourcePack {
|
public class LangResourcePack extends AbstractFileResourcePack {
|
||||||
private static final Gson GSON = new Gson();
|
private static final Gson GSON = new Gson();
|
||||||
private static final String NAME = "replaymod_lang";
|
public static final String NAME = "replaymod_lang";
|
||||||
private static final Pattern JSON_FILE_PATTERN = Pattern.compile("^assets/" + ReplayMod.MOD_ID + "/lang/([a-z][a-z])_([a-z][a-z]).json$");
|
private static final Pattern JSON_FILE_PATTERN = Pattern.compile("^assets/" + ReplayMod.MOD_ID + "/lang/([a-z][a-z])_([a-z][a-z]).json$");
|
||||||
private static final Pattern LANG_FILE_NAME_PATTERN = Pattern.compile("^([a-z][a-z])_([a-z][a-z]).lang$");
|
private static final Pattern LANG_FILE_NAME_PATTERN = Pattern.compile("^([a-z][a-z])_([a-z][a-z]).lang$");
|
||||||
|
|
||||||
@@ -51,9 +57,15 @@ public class LangResourcePack extends AbstractFileResourcePack {
|
|||||||
private static final String FABRIC_KEY_FORMAT = "key." + ReplayMod.MOD_ID + ".%s";
|
private static final String FABRIC_KEY_FORMAT = "key." + ReplayMod.MOD_ID + ".%s";
|
||||||
|
|
||||||
private final Path basePath;
|
private final Path basePath;
|
||||||
public LangResourcePack(Path basePath) {
|
public LangResourcePack() {
|
||||||
super(new File(NAME));
|
super(new File(NAME));
|
||||||
this.basePath = basePath;
|
|
||||||
|
//#if FABRIC>=1
|
||||||
|
ModContainer container = FabricLoader.getInstance().getModContainer(ReplayMod.MOD_ID).orElseThrow(IllegalAccessError::new);
|
||||||
|
this.basePath = container.getRootPath();
|
||||||
|
//#else
|
||||||
|
//$$ this.basePath = null; // stub
|
||||||
|
//#endif
|
||||||
}
|
}
|
||||||
//#else
|
//#else
|
||||||
//$$ public LangResourcePack() {
|
//$$ public LangResourcePack() {
|
||||||
|
|||||||
@@ -8,7 +8,8 @@
|
|||||||
"AbstractButtonWidgetAccessor",
|
"AbstractButtonWidgetAccessor",
|
||||||
"Mixin_ContextualKeyBindings",
|
"Mixin_ContextualKeyBindings",
|
||||||
"MixinGameRenderer",
|
"MixinGameRenderer",
|
||||||
"MixinModResourcePackUtil",
|
"Mixin_HideDynamicResourcePacks",
|
||||||
|
"Mixin_RegisterDynamicResourcePacks",
|
||||||
//#endif
|
//#endif
|
||||||
//#if MC>=11400
|
//#if MC>=11400
|
||||||
"MixinKeyboardListener",
|
"MixinKeyboardListener",
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
2.4.3
|
2.4.4
|
||||||
|
|||||||
Reference in New Issue
Block a user