mirror of
https://github.com/architectury/architectury-api.git
synced 2026-03-28 03:56:59 -05:00
Support 1.18.2 while maintaining compatibility with 1.18, we will see if we can maintain this structure
This commit is contained in:
@@ -6,7 +6,7 @@ buildscript {
|
||||
|
||||
plugins {
|
||||
id "architectury-plugin" version "3.4-SNAPSHOT"
|
||||
id "dev.architectury.loom" version "0.10.0-SNAPSHOT" apply false
|
||||
id "dev.architectury.loom" version "0.11.0-SNAPSHOT" apply false
|
||||
id "org.cadixdev.licenser" version "0.6.1"
|
||||
id "com.matthewprenger.cursegradle" version "1.4.0" apply false
|
||||
id "maven-publish"
|
||||
|
||||
@@ -37,6 +37,7 @@ import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyVariable;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
|
||||
@Unique
|
||||
@@ -70,11 +71,6 @@ public abstract class MixinMinecraft {
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "startAttack", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/player/LocalPlayer;resetAttackStrengthTicker()V", ordinal = 0))
|
||||
private void leftClickAir(CallbackInfo ci) {
|
||||
InteractionEvent.CLIENT_LEFT_CLICK_AIR.invoker().click(player, InteractionHand.MAIN_HAND);
|
||||
}
|
||||
|
||||
@ModifyVariable(
|
||||
method = "setScreen",
|
||||
at = @At(value = "FIELD",
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* This file is part of architectury.
|
||||
* Copyright (C) 2020, 2021, 2022 architectury
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
package dev.architectury.mixin.fabric.client;
|
||||
|
||||
import dev.architectury.event.events.common.InteractionEvent;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Unique
|
||||
@Mixin(Minecraft.class)
|
||||
public abstract class MixinMinecraft118 {
|
||||
@Shadow
|
||||
@Nullable
|
||||
public LocalPlayer player;
|
||||
|
||||
@Inject(method = "startAttack", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/player/LocalPlayer;resetAttackStrengthTicker()V", ordinal = 0))
|
||||
private void leftClickAir(CallbackInfo ci) {
|
||||
InteractionEvent.CLIENT_LEFT_CLICK_AIR.invoker().click(player, InteractionHand.MAIN_HAND);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* This file is part of architectury.
|
||||
* Copyright (C) 2020, 2021, 2022 architectury
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
package dev.architectury.mixin.fabric.client;
|
||||
|
||||
import dev.architectury.event.events.common.InteractionEvent;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Unique
|
||||
@Mixin(Minecraft.class)
|
||||
public class MixinMinecraft1182 {
|
||||
@Shadow
|
||||
@Nullable
|
||||
public LocalPlayer player;
|
||||
|
||||
@Inject(method = "startAttack", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/player/LocalPlayer;resetAttackStrengthTicker()V", ordinal = 0))
|
||||
private void leftClickAir(CallbackInfoReturnable<Boolean> ci) {
|
||||
InteractionEvent.CLIENT_LEFT_CLICK_AIR.invoker().click(player, InteractionHand.MAIN_HAND);
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,9 @@
|
||||
package dev.architectury.plugin.fabric;
|
||||
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.fabricmc.loader.api.SemanticVersion;
|
||||
import net.fabricmc.loader.api.Version;
|
||||
import net.fabricmc.loader.api.VersionParsingException;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
|
||||
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
|
||||
@@ -42,6 +45,28 @@ public class ArchitecturyMixinPlugin implements IMixinConfigPlugin {
|
||||
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
|
||||
if ("dev.architectury.mixin.fabric.client.MixinEffectInstance".equals(mixinClassName)) {
|
||||
return !FabricLoader.getInstance().isModLoaded("satin");
|
||||
} else if ("dev.architectury.mixin.fabric.client.MixinMinecraft118".equals(mixinClassName)) {
|
||||
Version minecraft = FabricLoader.getInstance().getModContainer("minecraft").get().getMetadata().getVersion();
|
||||
// is below 1.18.2
|
||||
Version version = null;
|
||||
try {
|
||||
version = SemanticVersion.parse("1.18.2-");
|
||||
} catch (VersionParsingException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
return minecraft.compareTo(version) < 0;
|
||||
} else if ("dev.architectury.mixin.fabric.client.MixinMinecraft1182".equals(mixinClassName)) {
|
||||
Version minecraft = FabricLoader.getInstance().getModContainer("minecraft").get().getMetadata().getVersion();
|
||||
// is 1.18.2 or above
|
||||
Version version = null;
|
||||
try {
|
||||
version = SemanticVersion.parse("1.18.2-");
|
||||
} catch (VersionParsingException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
return minecraft.compareTo(version) >= 0;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
"client.MixinIntegratedServer",
|
||||
"client.MixinKeyboardHandler",
|
||||
"client.MixinMinecraft",
|
||||
"client.MixinMinecraft118",
|
||||
"client.MixinMinecraft1182",
|
||||
"client.MixinMouseHandler",
|
||||
"client.MixinMultiPlayerGameMode",
|
||||
"client.MixinScreen",
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
org.gradle.jvmargs=-Xmx3G
|
||||
org.gradle.daemon=false
|
||||
|
||||
forgeEnabled=true
|
||||
forgeEnabled=false
|
||||
|
||||
minecraft_version=1.18
|
||||
supported_version=1.18(.1)
|
||||
minecraft_version=22w03a
|
||||
supported_version=1.18.2 (22w03a)
|
||||
|
||||
cf_type=release
|
||||
|
||||
@@ -13,8 +13,8 @@ archives_base_name_snapshot=architectury-snapshot
|
||||
base_version=3.4
|
||||
maven_group=dev.architectury
|
||||
|
||||
fabric_loader_version=0.12.8
|
||||
fabric_api_version=0.44.0+1.18
|
||||
fabric_loader_version=0.12.12
|
||||
fabric_api_version=0.46.2+1.18
|
||||
mod_menu_version=3.0.0
|
||||
|
||||
forge_version=38.0.17
|
||||
|
||||
@@ -14,9 +14,9 @@ if (JavaVersion.current().ordinal() + 1 < 17) {
|
||||
|
||||
include("common")
|
||||
include("fabric")
|
||||
include("forge")
|
||||
//include("forge")
|
||||
include("testmod-common")
|
||||
include("testmod-fabric")
|
||||
include("testmod-forge")
|
||||
//include("testmod-forge")
|
||||
|
||||
rootProject.name = "architectury"
|
||||
|
||||
Reference in New Issue
Block a user