Migrate away from deprecated fabric-api modules
This commit is contained in:
@@ -279,9 +279,11 @@ dependencies {
|
||||
"resource-loader-v0",
|
||||
]
|
||||
if (mcVersion >= 11600) {
|
||||
fabricApiModules.remove("keybindings-v0")
|
||||
fabricApiModules.add("key-binding-api-v1")
|
||||
}
|
||||
if (mcVersion >= 11700) {
|
||||
fabricApiModules.remove("networking-v0")
|
||||
fabricApiModules.add("networking-api-v1")
|
||||
}
|
||||
fabricApiModules.each { module ->
|
||||
|
||||
@@ -14,7 +14,11 @@ import net.minecraft.util.crash.CrashException;
|
||||
|
||||
//#if FABRIC>=1
|
||||
import com.replaymod.core.versions.LangResourcePack;
|
||||
import net.fabricmc.fabric.api.client.keybinding.FabricKeyBinding;
|
||||
//#if MC>=11600
|
||||
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
|
||||
//#else
|
||||
//$$ import net.fabricmc.fabric.api.client.keybinding.FabricKeyBinding;
|
||||
//#endif
|
||||
import net.minecraft.client.util.InputUtil;
|
||||
import net.minecraft.util.Identifier;
|
||||
import static com.replaymod.core.ReplayMod.MOD_ID;
|
||||
@@ -35,8 +39,8 @@ import java.util.function.Supplier;
|
||||
|
||||
public class KeyBindingRegistry extends EventRegistrations {
|
||||
private static final String CATEGORY = "replaymod.title";
|
||||
//#if FABRIC>=1
|
||||
static { net.fabricmc.fabric.api.client.keybinding.KeyBindingRegistry.INSTANCE.addCategory(CATEGORY); }
|
||||
//#if FABRIC>=1 && MC<11600
|
||||
//$$ static { net.fabricmc.fabric.api.client.keybinding.KeyBindingRegistry.INSTANCE.addCategory(CATEGORY); }
|
||||
//#endif
|
||||
|
||||
private final Map<String, Binding> bindings = new HashMap<>();
|
||||
@@ -63,9 +67,15 @@ public class KeyBindingRegistry extends EventRegistrations {
|
||||
keyCode = -1;
|
||||
}
|
||||
Identifier id = new Identifier(MOD_ID, name.substring(LangResourcePack.LEGACY_KEY_PREFIX.length()));
|
||||
FabricKeyBinding fabricKeyBinding = FabricKeyBinding.Builder.create(id, InputUtil.Type.KEYSYM, keyCode, CATEGORY).build();
|
||||
net.fabricmc.fabric.api.client.keybinding.KeyBindingRegistry.INSTANCE.register(fabricKeyBinding);
|
||||
KeyBinding keyBinding = fabricKeyBinding;
|
||||
//#if MC>=11600
|
||||
String key = String.format("key.%s.%s", id.getNamespace(), id.getPath());
|
||||
KeyBinding keyBinding = new KeyBinding(key, InputUtil.Type.KEYSYM, keyCode, CATEGORY);
|
||||
KeyBindingHelper.registerKeyBinding(keyBinding);
|
||||
//#else
|
||||
//$$ FabricKeyBinding fabricKeyBinding = FabricKeyBinding.Builder.create(id, InputUtil.Type.KEYSYM, keyCode, CATEGORY).build();
|
||||
//$$ net.fabricmc.fabric.api.client.keybinding.KeyBindingRegistry.INSTANCE.register(fabricKeyBinding);
|
||||
//$$ KeyBinding keyBinding = fabricKeyBinding;
|
||||
//#endif
|
||||
//#else
|
||||
//$$ KeyBinding keyBinding = new KeyBinding(name, keyCode, CATEGORY);
|
||||
//$$ ClientRegistry.registerKeyBinding(keyBinding);
|
||||
|
||||
@@ -16,7 +16,11 @@ import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
//#if FABRIC>=1
|
||||
//#if MC>=11700
|
||||
//$$ import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
|
||||
//#else
|
||||
import net.fabricmc.fabric.api.network.ClientSidePacketRegistry;
|
||||
//#endif
|
||||
//#else
|
||||
//$$ import net.minecraftforge.fml.network.NetworkRegistry;
|
||||
//#endif
|
||||
@@ -68,7 +72,11 @@ public class ReplayModRecording implements Module {
|
||||
new GuiHandler(core).register();
|
||||
|
||||
//#if FABRIC>=1
|
||||
//#if MC>=11700
|
||||
//$$ ClientPlayNetworking.registerGlobalReceiver(Restrictions.PLUGIN_CHANNEL, (client, handler, buf, resp) -> {});
|
||||
//#else
|
||||
ClientSidePacketRegistry.INSTANCE.register(Restrictions.PLUGIN_CHANNEL, (packetContext, packetByteBuf) -> {});
|
||||
//#endif
|
||||
//#else
|
||||
//#if MC>=11400
|
||||
//$$ NetworkRegistry.newEventChannel(Restrictions.PLUGIN_CHANNEL, () -> "0", any -> true, any -> true);
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
"depends": {
|
||||
"fabricloader": ">=0.7.0",
|
||||
"fabric-networking-v0": "*",
|
||||
"fabric-keybindings-v0": "*",
|
||||
"fabric-key-binding-api-v1": "*",
|
||||
"fabric-resource-loader-v0": "*"
|
||||
},
|
||||
|
||||
|
||||
60
versions/1.15.2/src/main/resources/fabric.mod.json
Normal file
60
versions/1.15.2/src/main/resources/fabric.mod.json
Normal file
@@ -0,0 +1,60 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"id": "replaymod",
|
||||
"version": "${version}",
|
||||
|
||||
"name": "Replay Mod",
|
||||
"description": "A Mod which allows you to record, replay and share your Minecraft experience.",
|
||||
"authors": [
|
||||
"CrushedPixel",
|
||||
"johni0702"
|
||||
],
|
||||
"contact": {
|
||||
"homepage": "https://replaymod.com/",
|
||||
"sources": "https://github.com/ReplayMod/ReplayMod"
|
||||
},
|
||||
|
||||
"license": "GPL-3.0-or-later",
|
||||
"icon": "assets/replaymod/favicon_logo.png",
|
||||
|
||||
"environment": "client",
|
||||
"entrypoints": {
|
||||
"client": [
|
||||
"com.replaymod.core.ReplayModBackend"
|
||||
],
|
||||
"modmenu": [
|
||||
"com.replaymod.core.gui.ModMenuApiImpl"
|
||||
],
|
||||
"frex_flawless_frames": [
|
||||
"com.replaymod.render.utils.FlawlessFrames::registerConsumer"
|
||||
],
|
||||
"preLaunch": [
|
||||
"com.replaymod.core.DummyChainLoadEntryPoint"
|
||||
],
|
||||
"mm:early_risers": [
|
||||
"com.replaymod.core.ReplayModMMLauncher"
|
||||
]
|
||||
},
|
||||
"mixins": [
|
||||
"mixins.jgui.json",
|
||||
"mixins.nonmmlauncher.replaymod.json"
|
||||
],
|
||||
|
||||
"depends": {
|
||||
"fabricloader": ">=0.7.0",
|
||||
"fabric-networking-v0": "*",
|
||||
"fabric-keybindings-v0": "*",
|
||||
"fabric-resource-loader-v0": "*"
|
||||
},
|
||||
|
||||
"conflicts": {
|
||||
"iris": "<1.1.3"
|
||||
},
|
||||
|
||||
"custom": {
|
||||
"mm:early_risers": [
|
||||
"com.replaymod.core.ReplayModMMLauncher"
|
||||
],
|
||||
"modmenu:clientsideOnly": true
|
||||
}
|
||||
}
|
||||
60
versions/1.17/src/main/resources/fabric.mod.json
Normal file
60
versions/1.17/src/main/resources/fabric.mod.json
Normal file
@@ -0,0 +1,60 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"id": "replaymod",
|
||||
"version": "${version}",
|
||||
|
||||
"name": "Replay Mod",
|
||||
"description": "A Mod which allows you to record, replay and share your Minecraft experience.",
|
||||
"authors": [
|
||||
"CrushedPixel",
|
||||
"johni0702"
|
||||
],
|
||||
"contact": {
|
||||
"homepage": "https://replaymod.com/",
|
||||
"sources": "https://github.com/ReplayMod/ReplayMod"
|
||||
},
|
||||
|
||||
"license": "GPL-3.0-or-later",
|
||||
"icon": "assets/replaymod/favicon_logo.png",
|
||||
|
||||
"environment": "client",
|
||||
"entrypoints": {
|
||||
"client": [
|
||||
"com.replaymod.core.ReplayModBackend"
|
||||
],
|
||||
"modmenu": [
|
||||
"com.replaymod.core.gui.ModMenuApiImpl"
|
||||
],
|
||||
"frex_flawless_frames": [
|
||||
"com.replaymod.render.utils.FlawlessFrames::registerConsumer"
|
||||
],
|
||||
"preLaunch": [
|
||||
"com.replaymod.core.DummyChainLoadEntryPoint"
|
||||
],
|
||||
"mm:early_risers": [
|
||||
"com.replaymod.core.ReplayModMMLauncher"
|
||||
]
|
||||
},
|
||||
"mixins": [
|
||||
"mixins.jgui.json",
|
||||
"mixins.nonmmlauncher.replaymod.json"
|
||||
],
|
||||
|
||||
"depends": {
|
||||
"fabricloader": ">=0.7.0",
|
||||
"fabric-networking-api-v1": "*",
|
||||
"fabric-key-binding-api-v1": "*",
|
||||
"fabric-resource-loader-v0": "*"
|
||||
},
|
||||
|
||||
"conflicts": {
|
||||
"iris": "<1.1.3"
|
||||
},
|
||||
|
||||
"custom": {
|
||||
"mm:early_risers": [
|
||||
"com.replaymod.core.ReplayModMMLauncher"
|
||||
],
|
||||
"modmenu:clientsideOnly": true
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user