Compare commits

...

No commits in common. "master" and "1.20" have entirely different histories.
master ... 1.20

20 changed files with 439 additions and 58 deletions

5
.gitattributes vendored Normal file
View File

@ -0,0 +1,5 @@
* text eol=lf
*.bat text eol=crlf
*.jar binary
*.class binary
*.png binary

View File

@ -1,58 +0,0 @@
# EnchantmentDoNotConflict (附魔不冲突)
<img width="512" src="title_full.png">
## 注意事项
- 主分支 master 仅存储一些文档 阅读代码请切换分支
- 1.20.* 升级到 1.21 需要删除配置文件
- 仅服务端模组 客户端安装无效
- 客户端安装仅适配其他附魔模组
- 单人游戏有效
## 仓库列表
- 这个是仓库Fabirc版本的
- 仓库[NeoForge](https://git.mingliqiye.com/MinecraftMod/EnchantmentDoNotConflictNeoForge)版本
- 仓库[Forge](https://git.mingliqiye.com/MinecraftMod/EnchantmentDoNotConflictForge)版本
## 支持的版本 Fabric
- 1.20 意外支持 (1.20.1)
- 1.20.2 意外支持 (1.20.3 1.20.4)
- 1.20.5 意外支持 (1.20.6)
- 1.21 意外支持(1.21.1 1.21.2 1.21.3 1.21.4 1.21.5 1.21.6 1.21.7)
## 支持的版本 [Forge](https://git.mingliqiye.com/MinecraftMod/EnchantmentDoNotConflictForge)
- 1.20 意外支持 (1.20.1)
- 1.20.2 意外支持 (1.20.3 1.20.4)
- 1.20.6 Forge 废弃 API FMLJavaModLoadingContext.get().getModEventBus();
- 1.21 意外支持 (1.21.1 1.21.3 1.21.4 1.21.5) Forge 你 API不是说废弃了吗 怎么这版本不废弃了?
- 1.21.6 意外支持 (1.21.7) 又改APi Forge 女娲
## 支持的版本 [NeoForge](https://git.mingliqiye.com/MinecraftMod/EnchantmentDoNotConflictNeoForge)
- 1.20.5 意外支持 (1.20.6)
- 1.21 意外支持(1.21.1 1.21.2 1.21.3 1.21.4 1.21.5 1.21.6 1.21.7)
## 游戏版本日志
### 1.20.2 ++ PlayerManager::onPlayerConnect 签名修改
- 由于麻将改了签名
- net.minecraft.server.PlayerManager::onPlayerConnect(ClientConnection connection, ServerPlayerEntity player) Old
- net.minecraft.server.PlayerManager::onPlayerConnect(ClientConnection connection, ServerPlayerEntity player, ConnectedClientData clientData) New
- 主版本 1.20.1
- 发行 1.20.2 - 1.20.4
### 1.20.5 ++ 服务端客户端通信大改
- 主版本 1.20.5
- 发行 1.20.5 - 1.20.6
### 1.21 ++ 数据驱动模式的附魔
- 由于麻将大改附魔系统 现在变为了 数据包模式的 我是用内置类实现的不冲突
- 后续大家想要添加模组的附魔不冲突的话请看这 分支[1.21](https://git.mingliqiye.com/MinecraftMod/EnchantmentDoNotConflict/src/branch/1.21)
## 下载
- [Fabric](https://git.mingliqiye.com/MinecraftMod/EnchantmentDoNotConflict/releases)
- [NeoForge](https://git.mingliqiye.com/MinecraftMod/EnchantmentDoNotConflictNeoForge/releases)
- [Forge](https://git.mingliqiye.com/MinecraftMod/EnchantmentDoNotConflictForge/releases)
## 适配其他模组
- 服务器和客户端 都安装 本模组 即可
- [Enchanting Infuser](https://modrinth.com/mod/enchanting-infuser)
- <img src="bc7a632b-e68a-4c23-85a6-2d6aa51b6254.png">

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

68
build.gradle Normal file
View File

@ -0,0 +1,68 @@
plugins {
id 'fabric-loom' version '1.10.5'
id 'maven-publish'
}
version = "${project.minecraft_version}-${project.mod_version}"
group = project.maven_group
base {
archivesName = project.archives_base_name
}
dependencies {
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.minecraft_version}+${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}+${project.minecraft_version}"
}
processResources {
inputs.property "version", project.version
inputs.property "minecraft_version", project.minecraft_version
inputs.property "loader_version", project.loader_version
filteringCharset "UTF-8"
filesMatching("fabric.mod.json") {
expand "version": project.version,
"minecraft_version": project.minecraft_version,
"loader_version": project.loader_version
}
}
def targetJavaVersion = 17
tasks.withType(JavaCompile).configureEach {
it.options.encoding = "UTF-8"
if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {
it.options.release.set(targetJavaVersion)
}
}
java {
def javaVersion = JavaVersion.toVersion(targetJavaVersion)
if (JavaVersion.current() < javaVersion) {
toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
}
withSourcesJar()
}
jar {
from("LICENSE") {
rename { "${project.archivesBaseName}_${it}" }
}
}
publishing {
publications {
create("mavenJava", MavenPublication) {
artifactId = project.archives_base_name
from components.java
}
}
repositories {
maven {
name= "Disk"
url = uri("D:/git/maven-repository-raw")
}
}
}

7
gradle.properties Normal file
View File

@ -0,0 +1,7 @@
minecraft_version=1.20
yarn_mappings=build.1
loader_version=0.16.10
mod_version=1.3
maven_group=com.mingliqiye.minecraft.enchantment.conflict
archives_base_name=enchantmentdoesnotconflict
fabric_version=0.83.0

View File

@ -0,0 +1 @@
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.1-bin.zip

11
settings.gradle Normal file
View File

@ -0,0 +1,11 @@
pluginManagement {
repositories {
maven {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'
}
gradlePluginPortal()
}
}
rootProject.name= "${archives_base_name}-${minecraft_version}-${mod_version}"

View File

@ -0,0 +1,13 @@
package com.mingliqiye.minecraft.enchantment.conflict;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
import net.minecraft.server.MinecraftServer;
public class Mod implements ModInitializer {
public static String MOD_ID = "enchantmentdoesnotconflict";
@Override
public void onInitialize() {
}
}

View File

@ -0,0 +1,11 @@
package com.mingliqiye.minecraft.enchantment.conflict.client;
import com.mingliqiye.minecraft.enchantment.conflict.network.NetworkHandler;
import net.fabricmc.api.ClientModInitializer;
public class ModClient implements ClientModInitializer {
@Override
public void onInitializeClient() {
NetworkHandler.registerReceivers();
}
}

View File

@ -0,0 +1,109 @@
package com.mingliqiye.minecraft.enchantment.conflict.config;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.mojang.logging.LogUtils;
import net.fabricmc.loader.api.FabricLoader;
import org.slf4j.Logger;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import static com.mingliqiye.minecraft.enchantment.conflict.Mod.MOD_ID;
public class ModConfig {
private static final Path CONFIG_PATH =
FabricLoader.getInstance().getConfigDir().resolve(MOD_ID + ".json");
private static final Gson GSON =
new GsonBuilder().setPrettyPrinting().serializeNulls().create();
private static ModConfig instance;
private boolean allowDamageEnchantment = true;
private boolean allowInfinityEnchantment = true;
private boolean allowPiercingEnchantment = true;
private boolean allowProtectionEnchantment = true;
public ModConfig() {
}
public static ModConfig getInstance() {
return ModConfig.instance;
}
public static void setInstance(ModConfig instance) {
ModConfig.instance = instance;
}
public static ModConfig load() {
try {
if (Files.exists(CONFIG_PATH)) {
return GSON.fromJson(Files.newBufferedReader(CONFIG_PATH),
ModConfig.class);
}
} catch (IOException e) {
e.printStackTrace();
}
ModConfig modConfig = new ModConfig();
setInstance(modConfig);
save();
return modConfig;
}
public static void save() {
try {
Files.writeString(CONFIG_PATH, GSON.toJson(instance));
} catch (IOException e) {
e.printStackTrace();
}
}
static {
setInstance(load());
}
public boolean isAllowDamageEnchantment() {
return allowDamageEnchantment;
}
public void setAllowDamageEnchantment(boolean allowDamageEnchantment) {
this.allowDamageEnchantment = allowDamageEnchantment;
}
public boolean isAllowInfinityEnchantment() {
return allowInfinityEnchantment;
}
public void setAllowInfinityEnchantment(boolean allowInfinityEnchantment) {
this.allowInfinityEnchantment = allowInfinityEnchantment;
}
public boolean isAllowPiercingEnchantment() {
return allowPiercingEnchantment;
}
public void setAllowPiercingEnchantment(boolean allowPiercingEnchantment) {
this.allowPiercingEnchantment = allowPiercingEnchantment;
}
public boolean isAllowProtectionEnchantment() {
return allowProtectionEnchantment;
}
public void setAllowProtectionEnchantmentMixin(
boolean allowProtectionEnchantmentMixin
) {
this.allowProtectionEnchantment = allowProtectionEnchantmentMixin;
}
public String toString() {
return this.getClass().getName() + "(" + "allowDamageEnchantment" +
"=" + allowDamageEnchantment + "," +
"allowInfinityEnchantment" + "=" + allowInfinityEnchantment +
"," + "allowPiercingEnchantment" + "=" +
allowPiercingEnchantment + "," +
"allowProtectionEnchantment" + "=" +
allowProtectionEnchantment + ")";
}
}

View File

@ -0,0 +1,26 @@
package com.mingliqiye.minecraft.enchantment.conflict.mixin;
import com.mingliqiye.minecraft.enchantment.conflict.config.ModConfig;
import net.minecraft.enchantment.DamageEnchantment;
import net.minecraft.enchantment.Enchantment;
import org.jetbrains.annotations.NotNull;
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.CallbackInfoReturnable;
@Mixin(DamageEnchantment.class)
public abstract class DamageEnchantmentMixin {
@Inject(method = "canAccept", at = @At("HEAD"), cancellable = true)
private void canAccept(
@NotNull Enchantment enchantment,
@NotNull CallbackInfoReturnable<Boolean> cir
) {
if (enchantment instanceof DamageEnchantment) {
cir.setReturnValue(ModConfig.getInstance().isAllowDamageEnchantment());
}
}
}

View File

@ -0,0 +1,26 @@
package com.mingliqiye.minecraft.enchantment.conflict.mixin;
import com.mingliqiye.minecraft.enchantment.conflict.config.ModConfig;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.InfinityEnchantment;
import net.minecraft.enchantment.MendingEnchantment;
import org.jetbrains.annotations.NotNull;
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.CallbackInfoReturnable;
@Mixin(InfinityEnchantment.class)
public abstract class InfinityEnchantmentMixin {
@Inject(method = "canAccept", at = @At("HEAD"), cancellable = true)
private void canAccept(
@NotNull Enchantment enchantment,
@NotNull CallbackInfoReturnable<Boolean> cir
) {
if (enchantment instanceof MendingEnchantment) {
cir.setReturnValue(ModConfig.getInstance().isAllowInfinityEnchantment());
}
}
}

View File

@ -0,0 +1,26 @@
package com.mingliqiye.minecraft.enchantment.conflict.mixin;
import com.mingliqiye.minecraft.enchantment.conflict.config.ModConfig;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.Enchantments;
import net.minecraft.enchantment.PiercingEnchantment;
import org.jetbrains.annotations.NotNull;
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.CallbackInfoReturnable;
@Mixin(PiercingEnchantment.class)
public abstract class PiercingEnchantmentMixin {
@Inject(method = "canAccept", at = @At("HEAD"), cancellable = true)
private void canAccept(
@NotNull Enchantment enchantment,
@NotNull CallbackInfoReturnable<Boolean> cir
) {
if (enchantment == Enchantments.MULTISHOT) {
cir.setReturnValue(ModConfig.getInstance().isAllowPiercingEnchantment());
}
}
}

View File

@ -0,0 +1,23 @@
package com.mingliqiye.minecraft.enchantment.conflict.mixin;
import com.mingliqiye.minecraft.enchantment.conflict.config.ModConfig;
import com.mingliqiye.minecraft.enchantment.conflict.network.NetworkHandler;
import net.minecraft.network.ClientConnection;
import net.minecraft.server.PlayerManager;
import net.minecraft.server.network.ServerPlayerEntity;
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;
@Mixin(PlayerManager.class)
public abstract class PlayerManagerMixin {
@Inject(method = "onPlayerConnect" ,at = @At("RETURN"))
private void onPlayerConnect(
ClientConnection connection, ServerPlayerEntity player,
CallbackInfo ci
){
NetworkHandler.sendConfigToClient(player);
}
}

View File

@ -0,0 +1,26 @@
package com.mingliqiye.minecraft.enchantment.conflict.mixin;
import com.mingliqiye.minecraft.enchantment.conflict.config.ModConfig;
import net.minecraft.enchantment.ProtectionEnchantment;
import net.minecraft.enchantment.Enchantment;
import org.jetbrains.annotations.NotNull;
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.CallbackInfoReturnable;
@Mixin(ProtectionEnchantment.class)
public abstract class ProtectionEnchantmentMixin {
@Inject(method = "canAccept", at = @At("HEAD"), cancellable = true)
private void onCheckCompatibility(
@NotNull Enchantment enchantment,
@NotNull CallbackInfoReturnable<Boolean> cir
) {
if (enchantment instanceof ProtectionEnchantment) {
cir.setReturnValue(ModConfig.getInstance().isAllowProtectionEnchantment());
}
}
}

View File

@ -0,0 +1,40 @@
package com.mingliqiye.minecraft.enchantment.conflict.network;
import com.google.gson.Gson;
import com.mingliqiye.minecraft.enchantment.conflict.config.ModConfig;
import com.mojang.logging.LogUtils;
import io.netty.buffer.Unpooled;
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.util.Identifier;
import com.mingliqiye.minecraft.enchantment.conflict.Mod;
import org.slf4j.Logger;
public class NetworkHandler {
public static final Identifier CONFIG_PACKET_ID = new Identifier(Mod.MOD_ID, "config_packet");
public static final Gson GSON = new Gson();
private static final Logger LOGGER = LogUtils.getLogger();
public static void sendConfigToClient(ServerPlayerEntity player) {
PacketByteBuf buf = new PacketByteBuf(Unpooled.buffer());
buf.writeString(GSON.toJson(ModConfig.getInstance()));
ServerPlayNetworking.send(player, NetworkHandler.CONFIG_PACKET_ID, buf);
LOGGER.info("Send Player({}) Server {} config {}", player.getName().getString(), Mod.MOD_ID,
ModConfig.getInstance());
}
public static void registerReceivers() {
ClientPlayNetworking.registerGlobalReceiver(NetworkHandler.CONFIG_PACKET_ID,
(client, handler, buf, responseSender) -> {
ModConfig configData = GSON.fromJson(buf.readString(), ModConfig.class);
client.execute(() -> {
ModConfig.setInstance(configData);
LOGGER.info("Load Server {} config {}", Mod.MOD_ID, configData);
});
});
}
}

View File

Before

Width:  |  Height:  |  Size: 67 KiB

After

Width:  |  Height:  |  Size: 67 KiB

View File

@ -0,0 +1,19 @@
{
"required": true,
"minVersion": "0.8",
"package": "com.mingliqiye.minecraft.enchantment.conflict.mixin",
"compatibilityLevel": "JAVA_17",
"mixins": [
"DamageEnchantmentMixin",
"InfinityEnchantmentMixin",
"PiercingEnchantmentMixin",
"PlayerManagerMixin",
"ProtectionEnchantmentMixin"
],
"injectors": {
"defaultRequire": 1
},
"overwrites": {
"requireAnnotations": true
}
}

View File

@ -0,0 +1,28 @@
{
"schemaVersion": 1,
"id": "enchantmentdoesnotconflict",
"version": "${version}",
"name": "enchantmentDoesNotConflict",
"description": "移除一些附魔冲突",
"authors": [],
"contact": {},
"license": "Apache-2.0",
"icon": "assets/enchantmentdoesnotconflict/icon.png",
"environment": "*",
"entrypoints": {
"client": [
"com.mingliqiye.minecraft.enchantment.conflict.client.ModClient"
],
"main": [
"com.mingliqiye.minecraft.enchantment.conflict.Mod"
]
},
"mixins": [
"enchantmentdoesnotconflict.mixins.json"
],
"depends": {
"fabricloader": "*",
"fabric": "*",
"minecraft": ">=1.20 <=1.20.1"
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 218 KiB