Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
ee6dbc9e84 | |||
f6b511a8bf |
40
build.gradle
40
build.gradle
@ -2,7 +2,7 @@ plugins {
|
|||||||
id 'eclipse'
|
id 'eclipse'
|
||||||
id 'idea'
|
id 'idea'
|
||||||
id 'maven-publish'
|
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'
|
id 'org.spongepowered.mixin' version '0.7.38'
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -13,6 +13,7 @@ base {
|
|||||||
archivesName = mod_id
|
archivesName = mod_id
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
|
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'}"
|
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' }
|
sourceSets.main.resources { srcDir 'src/generated/resources' }
|
||||||
repositories {
|
repositories {}
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
|
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,
|
forge_version : forge_version, forge_version_range: forge_version_range,
|
||||||
loader_version_range: loader_version_range,
|
loader_version_range: loader_version_range,
|
||||||
mod_id : mod_id, mod_name: mod_name, mod_license: mod_license,
|
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]
|
mod_authors : mod_authors, mod_description: mod_description]
|
||||||
processResources {
|
processResources {
|
||||||
inputs.properties replaceProperties
|
inputs.properties replaceProperties
|
||||||
@ -98,19 +98,22 @@ mixin {
|
|||||||
config "${mod_id}.mixins.json"
|
config "${mod_id}.mixins.json"
|
||||||
}
|
}
|
||||||
|
|
||||||
java{
|
java {
|
||||||
withSourcesJar()
|
withSourcesJar()
|
||||||
}
|
}
|
||||||
|
|
||||||
jar {
|
jar {
|
||||||
manifest {
|
manifest {
|
||||||
attributes(["Specification-Title" : mod_id,
|
attributes([
|
||||||
"Specification-Vendor" : mod_authors,
|
"Specification-Title" : mod_id,
|
||||||
"Specification-Version" : "1",
|
"Specification-Vendor" : mod_authors,
|
||||||
"Implementation-Title" : project.name,
|
"Specification-Version" : "1",
|
||||||
"Implementation-Version" : project.jar.archiveVersion,
|
"Implementation-Title" : project.name,
|
||||||
"Implementation-Vendor" : mod_authors,
|
"Implementation-Version" : project.jar.archiveVersion,
|
||||||
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")])
|
"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 {
|
publishing {
|
||||||
publications {
|
publications {
|
||||||
mavenJava(MavenPublication) {
|
register('mavenJava', MavenPublication) {
|
||||||
artifact jar
|
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 {
|
tasks.withType(JavaCompile).configureEach {
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
minecraft_version=1.20
|
org.gradle.jvmargs=-Xmx4096m -Xms2048m -XX:MaxMetaspaceSize=1024m
|
||||||
minecraft_version_range=[1.20,1.20.2)
|
systemProp.file.encoding=UTF-8
|
||||||
forge_version=46.0.14
|
minecraft_version=1.20.2
|
||||||
forge_version_range=[45,)
|
minecraft_version_range=[1.20,2.20.5)
|
||||||
loader_version_range=[45,)
|
forge_version=48.1.0
|
||||||
|
forge_version_range=[47,)
|
||||||
|
loader_version_range=[47,)
|
||||||
mapping_channel=official
|
mapping_channel=official
|
||||||
mapping_version=1.20
|
mapping_version=1.20.2
|
||||||
mod_id=enchantmentdoesnotconflict
|
mod_id=enchantmentdoesnotconflict
|
||||||
mod_name=EnchantmentDoNotConflictForge
|
mod_name=EnchantmentDoNotConflictForge
|
||||||
mod_license=Apache License 2.0
|
mod_license=Apache License 2.0
|
||||||
|
@ -78,5 +78,14 @@ public class ModConfig {
|
|||||||
public void setAllowProtectionEnchantment(boolean allowProtectionEnchantment) {
|
public void setAllowProtectionEnchantment(boolean allowProtectionEnchantment) {
|
||||||
this.allowProtectionEnchantment = allowProtectionEnchantment;
|
this.allowProtectionEnchantment = allowProtectionEnchantment;
|
||||||
}
|
}
|
||||||
|
public String toString() {
|
||||||
|
return this.getClass().getName() + "(" + "allowDamageEnchantment" +
|
||||||
|
"=" + allowDamageEnchantment + "," +
|
||||||
|
"allowInfinityEnchantment" + "=" + allowInfinityEnchantment +
|
||||||
|
"," + "allowPiercingEnchantment" + "=" +
|
||||||
|
allowPiercingEnchantment + "," +
|
||||||
|
"allowProtectionEnchantment" + "=" +
|
||||||
|
allowProtectionEnchantment + ")";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,16 +2,19 @@ package com.mingliqiye.minecraft.enchantment.conflict.network;
|
|||||||
|
|
||||||
import com.mingliqiye.minecraft.enchantment.conflict.EnchantmentDoNotConflictForge;
|
import com.mingliqiye.minecraft.enchantment.conflict.EnchantmentDoNotConflictForge;
|
||||||
import com.mingliqiye.minecraft.enchantment.conflict.network.message.ConfigMessage;
|
import com.mingliqiye.minecraft.enchantment.conflict.network.message.ConfigMessage;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraftforge.network.NetworkRegistry;
|
import net.minecraftforge.network.Channel;
|
||||||
import net.minecraftforge.network.simple.SimpleChannel;
|
import net.minecraftforge.network.ChannelBuilder;
|
||||||
|
import net.minecraftforge.network.SimpleChannel;
|
||||||
|
|
||||||
public class ChannelHander {
|
public class ChannelHander {
|
||||||
private static final String PROTOCOL_VERSION = "1.0";
|
public static final SimpleChannel CONFIG_CHANNEL_INSTANCE =
|
||||||
public static final SimpleChannel CONFIG_CHANNEL_INSTANCE = NetworkRegistry.newSimpleChannel(
|
ChannelBuilder.named("%s:%s".formatted(EnchantmentDoNotConflictForge.MODID, "config_channel")).networkProtocolVersion(1).clientAcceptedVersions(
|
||||||
new ResourceLocation(EnchantmentDoNotConflictForge.MODID, "config_channel"), () -> PROTOCOL_VERSION,
|
Channel.VersionTest.ACCEPT_MISSING // 允许客户端没有该频道
|
||||||
PROTOCOL_VERSION::equals,(v)->true);
|
.or(Channel.VersionTest.exact(1)))
|
||||||
|
.serverAcceptedVersions(
|
||||||
|
Channel.VersionTest.exact(1))
|
||||||
|
.simpleChannel();
|
||||||
public static final int CONFIG_SYNC = 0;
|
public static final int CONFIG_SYNC = 0;
|
||||||
|
|
||||||
public static void sendConfig(ServerPlayer player) {
|
public static void sendConfig(ServerPlayer player) {
|
||||||
|
@ -6,12 +6,11 @@ import com.mingliqiye.minecraft.enchantment.conflict.config.ModConfig;
|
|||||||
import com.mojang.logging.LogUtils;
|
import com.mojang.logging.LogUtils;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
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 net.minecraftforge.network.PacketDistributor;
|
||||||
import org.slf4j.Logger;
|
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_CHANNEL_INSTANCE;
|
||||||
import static com.mingliqiye.minecraft.enchantment.conflict.network.ChannelHander.CONFIG_SYNC;
|
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();
|
private static final Gson GSON = new Gson();
|
||||||
|
|
||||||
public static void register() {
|
public static void register() {
|
||||||
CONFIG_CHANNEL_INSTANCE.registerMessage(CONFIG_SYNC, ConfigMessage.class, ConfigMessage::encode,
|
CONFIG_CHANNEL_INSTANCE.messageBuilder(ConfigMessage.class, CONFIG_SYNC, NetworkDirection.PLAY_TO_CLIENT)
|
||||||
ConfigMessage::decode, ConfigMessage::handle);
|
.decoder(ConfigMessage::decode).encoder(ConfigMessage::encode).consumerMainThread(ConfigMessage::handle).add();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void encode(ConfigMessage configMessage, FriendlyByteBuf byteBuf) {
|
public static void encode(ConfigMessage configMessage, FriendlyByteBuf byteBuf) {
|
||||||
@ -35,16 +34,16 @@ public record ConfigMessage(ModConfig.ConfigItem data) {
|
|||||||
|
|
||||||
public static void send(ServerPlayer player) {
|
public static void send(ServerPlayer player) {
|
||||||
ModConfig.ConfigItem configItem = ModConfig.getInstance();
|
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,
|
LOGGER.info("Send Server Config {} to {} data={}", EnchantmentDoNotConflictForge.MODID,
|
||||||
player.getName().getString(), configItem);
|
player.getName().getString(), configItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void handle(ConfigMessage configMessage, Supplier<NetworkEvent.Context> ctx) {
|
public static void handle(ConfigMessage configMessage, CustomPayloadEvent.Context ctx) {
|
||||||
ctx.get().enqueueWork(() -> {
|
ctx.enqueueWork(() -> {
|
||||||
ModConfig.setInstance(configMessage.data());
|
ModConfig.setInstance(configMessage.data());
|
||||||
LOGGER.info("Load Server Config {} data={}", EnchantmentDoNotConflictForge.MODID, configMessage.data());
|
LOGGER.info("Load Server Config {} data={}", EnchantmentDoNotConflictForge.MODID, configMessage.data());
|
||||||
});
|
});
|
||||||
ctx.get().setPacketHandled(true);
|
ctx.setPacketHandled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user