add 1.20.2 1.20.3 1.20.4
This commit is contained in:
parent
07f069965b
commit
f6b511a8bf
@ -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'}"
|
||||
|
@ -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
|
||||
|
@ -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 + ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user