Compare commits

...

2 Commits
1.20 ... 1.20.2

Author SHA1 Message Date
ee6dbc9e84
Update build.gradle 2025-07-16 23:39:20 +08:00
f6b511a8bf
add 1.20.2 1.20.3 1.20.4 2025-07-16 11:28:51 +08:00
5 changed files with 60 additions and 37 deletions

View File

@ -2,7 +2,7 @@ plugins {
id 'eclipse'
id 'idea'
id 'maven-publish'
id 'net.minecraftforge.gradle' version '[6.0,6.2)'
id 'net.minecraftforge.gradle' version '[6.0.16,6.2)'
id 'org.spongepowered.mixin' version '0.7.38'
}
@ -13,6 +13,7 @@ base {
archivesName = mod_id
}
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}"
@ -69,8 +70,7 @@ minecraft {
}
}
sourceSets.main.resources { srcDir 'src/generated/resources' }
repositories {
}
repositories {}
dependencies {
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
@ -82,7 +82,7 @@ def replaceProperties = [minecraft_version : minecraft_version, minecraft_vers
forge_version : forge_version, forge_version_range: forge_version_range,
loader_version_range: loader_version_range,
mod_id : mod_id, mod_name: mod_name, mod_license: mod_license,
mod_version: mod_version,
mod_version : mod_version,
mod_authors : mod_authors, mod_description: mod_description]
processResources {
inputs.properties replaceProperties
@ -98,19 +98,22 @@ mixin {
config "${mod_id}.mixins.json"
}
java{
java {
withSourcesJar()
}
jar {
manifest {
attributes(["Specification-Title" : mod_id,
"Specification-Vendor" : mod_authors,
"Specification-Version" : "1",
"Implementation-Title" : project.name,
"Implementation-Version" : project.jar.archiveVersion,
"Implementation-Vendor" : mod_authors,
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")])
attributes([
"Specification-Title" : mod_id,
"Specification-Vendor" : mod_authors,
"Specification-Version" : "1",
"Implementation-Title" : project.name,
"Implementation-Version" : project.jar.archiveVersion,
"Implementation-Vendor" : mod_authors,
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
"MixinConfigs" : "${mod_id}.mixins.json"
])
}
}
@ -120,11 +123,18 @@ jar.finalizedBy('reobfJar')
publishing {
publications {
mavenJava(MavenPublication) {
artifact jar
register('mavenJava', MavenPublication) {
from components.java
groupId = mod_group_id
artifactId = mod_id
}
}
repositories {
maven {
name= "Disk"
url = uri("D:/git/maven-repository-raw")
}
}
repositories {}
}
tasks.withType(JavaCompile).configureEach {

View File

@ -1,10 +1,12 @@
minecraft_version=1.20
minecraft_version_range=[1.20,1.20.2)
forge_version=46.0.14
forge_version_range=[45,)
loader_version_range=[45,)
org.gradle.jvmargs=-Xmx4096m -Xms2048m -XX:MaxMetaspaceSize=1024m
systemProp.file.encoding=UTF-8
minecraft_version=1.20.2
minecraft_version_range=[1.20,2.20.5)
forge_version=48.1.0
forge_version_range=[47,)
loader_version_range=[47,)
mapping_channel=official
mapping_version=1.20
mapping_version=1.20.2
mod_id=enchantmentdoesnotconflict
mod_name=EnchantmentDoNotConflictForge
mod_license=Apache License 2.0

View File

@ -78,5 +78,14 @@ public class ModConfig {
public void setAllowProtectionEnchantment(boolean allowProtectionEnchantment) {
this.allowProtectionEnchantment = allowProtectionEnchantment;
}
public String toString() {
return this.getClass().getName() + "(" + "allowDamageEnchantment" +
"=" + allowDamageEnchantment + "," +
"allowInfinityEnchantment" + "=" + allowInfinityEnchantment +
"," + "allowPiercingEnchantment" + "=" +
allowPiercingEnchantment + "," +
"allowProtectionEnchantment" + "=" +
allowProtectionEnchantment + ")";
}
}
}

View File

@ -2,16 +2,19 @@ package com.mingliqiye.minecraft.enchantment.conflict.network;
import com.mingliqiye.minecraft.enchantment.conflict.EnchantmentDoNotConflictForge;
import com.mingliqiye.minecraft.enchantment.conflict.network.message.ConfigMessage;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerPlayer;
import net.minecraftforge.network.NetworkRegistry;
import net.minecraftforge.network.simple.SimpleChannel;
import net.minecraftforge.network.Channel;
import net.minecraftforge.network.ChannelBuilder;
import net.minecraftforge.network.SimpleChannel;
public class ChannelHander {
private static final String PROTOCOL_VERSION = "1.0";
public static final SimpleChannel CONFIG_CHANNEL_INSTANCE = NetworkRegistry.newSimpleChannel(
new ResourceLocation(EnchantmentDoNotConflictForge.MODID, "config_channel"), () -> PROTOCOL_VERSION,
PROTOCOL_VERSION::equals,(v)->true);
public static final SimpleChannel CONFIG_CHANNEL_INSTANCE =
ChannelBuilder.named("%s:%s".formatted(EnchantmentDoNotConflictForge.MODID, "config_channel")).networkProtocolVersion(1).clientAcceptedVersions(
Channel.VersionTest.ACCEPT_MISSING // 允许客户端没有该频道
.or(Channel.VersionTest.exact(1)))
.serverAcceptedVersions(
Channel.VersionTest.exact(1))
.simpleChannel();
public static final int CONFIG_SYNC = 0;
public static void sendConfig(ServerPlayer player) {

View File

@ -6,12 +6,11 @@ import com.mingliqiye.minecraft.enchantment.conflict.config.ModConfig;
import com.mojang.logging.LogUtils;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.server.level.ServerPlayer;
import net.minecraftforge.network.NetworkEvent;
import net.minecraftforge.event.network.CustomPayloadEvent;
import net.minecraftforge.network.NetworkDirection;
import net.minecraftforge.network.PacketDistributor;
import org.slf4j.Logger;
import java.util.function.Supplier;
import static com.mingliqiye.minecraft.enchantment.conflict.network.ChannelHander.CONFIG_CHANNEL_INSTANCE;
import static com.mingliqiye.minecraft.enchantment.conflict.network.ChannelHander.CONFIG_SYNC;
@ -21,8 +20,8 @@ public record ConfigMessage(ModConfig.ConfigItem data) {
private static final Gson GSON = new Gson();
public static void register() {
CONFIG_CHANNEL_INSTANCE.registerMessage(CONFIG_SYNC, ConfigMessage.class, ConfigMessage::encode,
ConfigMessage::decode, ConfigMessage::handle);
CONFIG_CHANNEL_INSTANCE.messageBuilder(ConfigMessage.class, CONFIG_SYNC, NetworkDirection.PLAY_TO_CLIENT)
.decoder(ConfigMessage::decode).encoder(ConfigMessage::encode).consumerMainThread(ConfigMessage::handle).add();
}
public static void encode(ConfigMessage configMessage, FriendlyByteBuf byteBuf) {
@ -35,16 +34,16 @@ public record ConfigMessage(ModConfig.ConfigItem data) {
public static void send(ServerPlayer player) {
ModConfig.ConfigItem configItem = ModConfig.getInstance();
CONFIG_CHANNEL_INSTANCE.send(PacketDistributor.PLAYER.with(() -> player), new ConfigMessage(configItem));
CONFIG_CHANNEL_INSTANCE.send(new ConfigMessage(configItem),PacketDistributor.PLAYER.with(player));
LOGGER.info("Send Server Config {} to {} data={}", EnchantmentDoNotConflictForge.MODID,
player.getName().getString(), configItem);
}
public static void handle(ConfigMessage configMessage, Supplier<NetworkEvent.Context> ctx) {
ctx.get().enqueueWork(() -> {
public static void handle(ConfigMessage configMessage, CustomPayloadEvent.Context ctx) {
ctx.enqueueWork(() -> {
ModConfig.setInstance(configMessage.data());
LOGGER.info("Load Server Config {} data={}", EnchantmentDoNotConflictForge.MODID, configMessage.data());
});
ctx.get().setPacketHandled(true);
ctx.setPacketHandled(true);
}
}