fix token sync
This commit is contained in:
64
build.gradle
64
build.gradle
@@ -1,9 +1,13 @@
|
||||
|
||||
plugins {
|
||||
id 'java-library'
|
||||
id 'eclipse'
|
||||
id 'idea'
|
||||
id 'maven-publish'
|
||||
id 'net.neoforged.gradle.userdev' version '7.0.165'
|
||||
id 'net.neoforged.moddev' version '2.0.80'
|
||||
id 'net.darkhax.curseforgegradle' version '[1.1.24,)'
|
||||
id "at.stnwtr.gradle-secrets-plugin" version "1.0.1"
|
||||
id "com.modrinth.minotaur" version "2.+"
|
||||
}
|
||||
|
||||
version = mod_version
|
||||
@@ -17,37 +21,53 @@ base {
|
||||
archivesName = mod_id
|
||||
}
|
||||
|
||||
java {
|
||||
withSourcesJar()
|
||||
}
|
||||
|
||||
java.toolchain.languageVersion = JavaLanguageVersion.of(21)
|
||||
|
||||
minecraft.accessTransformers.file rootProject.file('src/main/resources/META-INF/accesstransformer.cfg')
|
||||
sourceSets {
|
||||
client {}
|
||||
server {}
|
||||
data {}
|
||||
common {}
|
||||
}
|
||||
|
||||
runs {
|
||||
configureEach {
|
||||
systemProperty 'forge.logging.markers', 'REGISTRIES'
|
||||
systemProperty 'forge.logging.console.level', 'debug'
|
||||
modSource project.sourceSets.main
|
||||
}
|
||||
neoForge {
|
||||
// We currently only support NeoForge versions later than 21.0.x
|
||||
// See https://projects.neoforged.net/neoforged/neoforge for the latest updates
|
||||
version = "${neo_version}"
|
||||
|
||||
// Validate AT files and raise errors when they have invalid targets
|
||||
// This option is false by default, but turning it on is recommended
|
||||
//validateAccessTransformers = true
|
||||
accessTransformers.from "./src/main/resources/META-INF/accesstransformer.cfg"
|
||||
|
||||
runs {
|
||||
client {
|
||||
systemProperty 'forge.enabledGameTestNamespaces', project.mod_id
|
||||
}
|
||||
server {
|
||||
systemProperty 'forge.enabledGameTestNamespaces', project.mod_id
|
||||
}
|
||||
gameTestServer {
|
||||
systemProperty 'forge.enabledGameTestNamespaces', project.mod_id
|
||||
client()
|
||||
}
|
||||
data {
|
||||
data()
|
||||
|
||||
programArguments.addAll '--mod', project.mod_id, '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath()
|
||||
|
||||
}
|
||||
server {
|
||||
server()
|
||||
}
|
||||
}
|
||||
|
||||
mods {
|
||||
"${mod_id}" {
|
||||
sourceSet sourceSets.main
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets.main.resources { srcDir 'src/generated/resources' }
|
||||
|
||||
|
||||
dependencies {
|
||||
implementation "net.neoforged:neoforge:${neo_version}"
|
||||
}
|
||||
|
||||
tasks.withType(ProcessResources).configureEach {
|
||||
var replaceProperties = [
|
||||
minecraft_version : minecraft_version, minecraft_version_range: minecraft_version_range,
|
||||
@@ -83,10 +103,6 @@ tasks.withType(JavaCompile).configureEach {
|
||||
|
||||
if (lljij.toBoolean()) jarJar.enable()
|
||||
|
||||
java {
|
||||
withSourcesJar()
|
||||
}
|
||||
|
||||
jar {
|
||||
manifest {
|
||||
attributes([
|
||||
|
||||
@@ -8,9 +8,11 @@ org.gradle.debug=false
|
||||
neogradle.subsystems.parchment.minecraftVersion=1.20.6
|
||||
neogradle.subsystems.parchment.mappingsVersion=2024.06.02
|
||||
|
||||
org.gradle.configuration-cache=false
|
||||
|
||||
minecraft_version=1.21.1
|
||||
minecraft_version_range=[1.21.1,1.22)
|
||||
neo_version=21.1.93
|
||||
neo_version=21.1.143
|
||||
neo_version_range=[21.1.4,)
|
||||
loader_version_range=[2,)
|
||||
|
||||
@@ -18,7 +20,7 @@ loader_version_range=[2,)
|
||||
mod_id=l2core
|
||||
mod_name=L2Core
|
||||
mod_license=LGPL-2.1
|
||||
mod_version=3.0.8+8
|
||||
mod_version=3.0.8+15
|
||||
mod_group_id=dev.xkmc
|
||||
mod_authors=lcy0x1
|
||||
mod_description=Core Library mod for all L2 mods
|
||||
|
||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,6 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
|
||||
networkTimeout=10000
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
@@ -7,5 +7,5 @@ pluginManagement {
|
||||
}
|
||||
|
||||
plugins {
|
||||
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.5.0'
|
||||
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.8.0'
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
// 1.21 2024-07-25T11:38:15.636395 Registrate Provider for l2core [Registries, Data Maps, Recipes, Advancements, Loot Tables, Tags (blocks), Tags (items), Tags (fluids), Tags (entity_types), generic_server_provider, Blockstates, Item models, Lang (en_us/en_ud), generic_client_provider, Tags (mob_effect), Tags (attribute), Tags (enchantment)]
|
||||
7fd8a37c6437c7cab27c53dbc0df73ececc1cd44 assets/l2core/lang/en_ud.json
|
||||
18ae34417262501a3c00959390185e01ffb2ae7c assets/l2core/lang/en_us.json
|
||||
// 1.21.1 2025-07-26T01:42:31.138209 Registrate Provider for l2core [Registries, Data Maps, Recipes, Advancements, Loot Tables, Tags (blocks), Tags (items), Tags (fluids), Tags (entity_types), generic_server_provider, Blockstates, Item models, Lang (en_us/en_ud), generic_client_provider, Tags (mob_effect), Tags (attribute), Tags (enchantment)]
|
||||
72a986cabe624a799bdb74cc1b5e67dd6f80baed assets/l2core/lang/en_ud.json
|
||||
9eab006827655c8a83941f5d9c71681a1244378c assets/l2core/lang/en_us.json
|
||||
35133e95f1c8fdd7a1c21afcc231fc0bffefb9a8 data/l2core/tags/mob_effect/tracked_effects.json
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
"l2core.configuration.addEnchantmentDescription": "suoıʇdıɹɔsǝᗡ ʇuǝɯʇuɐɥɔuƎ ppⱯ",
|
||||
"l2core.configuration.addEnchantmentDescription.tooltip": "SʎⱯMꞀⱯ 'ʎꞀNO‾⟘ℲIHS 'ƎꞀᗺⱯSIᗡ :sǝnןɐΛ pǝʍoןןⱯ",
|
||||
"l2core.configuration.overlayZVal": "ʎɐןɹǝʌo ɹǝʇɔɐɹɐɥɔ ɯǝʇı ɟo ʇɥbıǝɥ ǝɥ⟘",
|
||||
"l2core.configuration.overlayZVal.tooltip": "000000Ɩ ~ 000000Ɩ- :ǝbuɐᴚ",
|
||||
"l2core.configuration.overlayZVal.tooltip": "000000Ɩ ~ 000000Ɩ- :ǝbuɐᴚ \n0ϛᄅ :ʇןnɐɟǝᗡ ",
|
||||
"l2core.configuration.renderOverlayIcons": "sǝıʇıʇuǝ uo suoɔı ʎɐןɹǝʌo ɹǝpuǝᴚ",
|
||||
"l2core.configuration.renderOverlayIcons.tooltip": "",
|
||||
"l2core.configuration.section.l2configs.l2core.client.toml": "uoıʇɐɹnbıɟuoƆ ʇuǝıןƆ ǝɹoƆᄅꞀ",
|
||||
"l2core.configuration.section.l2configs.l2core.client.toml.title": "uoıʇɐɹnbıɟuoƆ ʇuǝıןƆ ǝɹoƆᄅꞀ",
|
||||
"l2core.configuration.title": "uoıʇɐɹnbıɟuoƆ ǝɹoƆᄅꞀ",
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
"l2core.configuration.addEnchantmentDescription": "Add Enchantment Descriptions",
|
||||
"l2core.configuration.addEnchantmentDescription.tooltip": "Allowed Values: DISABLE, SHIFT_ONLY, ALWAYS",
|
||||
"l2core.configuration.overlayZVal": "The height of item character overlay",
|
||||
"l2core.configuration.overlayZVal.tooltip": "Range: -1000000 ~ 1000000",
|
||||
"l2core.configuration.overlayZVal.tooltip": " Default: 250\n Range: -1000000 ~ 1000000",
|
||||
"l2core.configuration.renderOverlayIcons": "Render overlay icons on entities",
|
||||
"l2core.configuration.renderOverlayIcons.tooltip": "",
|
||||
"l2core.configuration.section.l2configs.l2core.client.toml": "L2Core Client Configuration",
|
||||
"l2core.configuration.section.l2configs.l2core.client.toml.title": "L2Core Client Configuration",
|
||||
"l2core.configuration.title": "L2Core Configuration",
|
||||
|
||||
@@ -2,14 +2,17 @@ package dev.xkmc.l2core.capability.conditionals;
|
||||
|
||||
import dev.xkmc.l2core.init.L2LibReg;
|
||||
import dev.xkmc.l2core.util.Proxy;
|
||||
import dev.xkmc.l2serial.serialization.codec.PacketCodec;
|
||||
import dev.xkmc.l2serial.util.Wrappers;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
|
||||
public class ClientDataHandler {
|
||||
|
||||
public static <T extends ConditionalToken> void handle(TokenKey<T> key, T token) {
|
||||
public static <T extends ConditionalToken> void handle(TokenKey<T> key, byte[] data) {
|
||||
Player player = Proxy.getClientPlayer();
|
||||
if (player == null) return;
|
||||
var buf = PacketCodec.decode(player.registryAccess(), data);
|
||||
T token = Wrappers.cast(PacketCodec.from(buf, ConditionalToken.class, null));
|
||||
ConditionalToken old = L2LibReg.CONDITIONAL.type().getOrCreate(player).data.put(key, token);
|
||||
if (token instanceof NetworkSensitiveToken<?> t) {
|
||||
t.onSync(Wrappers.cast(old), player);
|
||||
|
||||
@@ -10,7 +10,7 @@ public interface NetworkSensitiveToken<T extends ConditionalToken> {
|
||||
void onSync(@Nullable T old, Player player);
|
||||
|
||||
default void sync(TokenKey<T> key, T token, ServerPlayer sp) {
|
||||
L2Core.PACKET_HANDLER.toClientPlayer(TokenToClient.of(key, token), sp);
|
||||
L2Core.PACKET_HANDLER.toClientPlayer(TokenToClient.of(sp.registryAccess(), key, token), sp);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,20 +1,23 @@
|
||||
package dev.xkmc.l2core.capability.conditionals;
|
||||
|
||||
import dev.xkmc.l2serial.network.SerialPacketBase;
|
||||
import dev.xkmc.l2serial.serialization.codec.PacketCodec;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public record TokenToClient(ResourceLocation id, ConditionalToken token)
|
||||
public record TokenToClient(ResourceLocation id, byte[] data)
|
||||
implements SerialPacketBase<TokenToClient> {
|
||||
|
||||
public static <T extends ConditionalToken> TokenToClient of(TokenKey<T> key, T token) {
|
||||
return new TokenToClient(key.asLocation(), token);
|
||||
public static <T extends ConditionalToken> TokenToClient of(RegistryAccess access, TokenKey<T> key, T token) {
|
||||
var data = PacketCodec.toBytes(access, token, ConditionalToken.class, e -> true);
|
||||
return new TokenToClient(key.asLocation(), data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(@Nullable Player player) {
|
||||
ClientDataHandler.handle(TokenKey.of(id), token);
|
||||
ClientDataHandler.handle(TokenKey.of(id), data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import net.minecraft.server.level.ServerPlayer;
|
||||
import net.neoforged.bus.api.EventPriority;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.fml.common.EventBusSubscriber;
|
||||
import net.neoforged.neoforge.event.entity.EntityJoinLevelEvent;
|
||||
import net.neoforged.neoforge.event.entity.player.PlayerEvent;
|
||||
import net.neoforged.neoforge.event.tick.PlayerTickEvent;
|
||||
|
||||
@@ -25,6 +26,13 @@ public class BaseCapabilityEvents {
|
||||
for (PlayerCapabilityHolder<?> holder : PlayerCapabilityHolder.INTERNAL_MAP.values()) {
|
||||
ServerPlayer e = (ServerPlayer) event.getEntity();
|
||||
holder.getOrCreate(e).onClone(e, event.isWasDeath());
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.LOW)
|
||||
public static void onPlayerJoinLevel(EntityJoinLevelEvent event) {
|
||||
if (!(event.getEntity() instanceof ServerPlayer e)) return;
|
||||
for (PlayerCapabilityHolder<?> holder : PlayerCapabilityHolder.INTERNAL_MAP.values()) {
|
||||
holder.network.toClient(e);
|
||||
holder.network.toTracking(e);
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import dev.xkmc.l2core.base.effects.ClientEffectCap;
|
||||
import dev.xkmc.l2core.base.effects.EffectToClient;
|
||||
import dev.xkmc.l2core.base.effects.api.*;
|
||||
import dev.xkmc.l2core.init.L2Core;
|
||||
import dev.xkmc.l2core.init.L2CoreConfig;
|
||||
import dev.xkmc.l2core.init.L2LibReg;
|
||||
import dev.xkmc.l2core.util.Proxy;
|
||||
import net.minecraft.Util;
|
||||
@@ -83,7 +84,11 @@ public class ClientEffectRenderEvents {
|
||||
@SubscribeEvent
|
||||
public static void levelRenderLast(RenderLevelStageEvent event) {
|
||||
if (event.getStage() != RenderLevelStageEvent.Stage.AFTER_WEATHER) return;
|
||||
|
||||
if (ICONS.isEmpty()) return;
|
||||
if (!L2CoreConfig.CLIENT.renderOverlayIcons.get()) {
|
||||
ICONS.clear();
|
||||
return;
|
||||
}
|
||||
DUMMY.setupRenderState();
|
||||
DUMMY.clearRenderState();
|
||||
MultiBufferSource.BufferSource buffers = Minecraft.getInstance().renderBuffers().bufferSource();
|
||||
|
||||
@@ -10,6 +10,7 @@ public class L2CoreConfig {
|
||||
|
||||
public final ModConfigSpec.IntValue overlayZVal;
|
||||
public final ModConfigSpec.EnumValue<ClientEventHandler.EnchDesc> addEnchantmentDescription;
|
||||
public final ModConfigSpec.BooleanValue renderOverlayIcons;
|
||||
|
||||
Client(Builder builder) {
|
||||
markL2();
|
||||
@@ -17,6 +18,8 @@ public class L2CoreConfig {
|
||||
.defineInRange("overlayZVal", 250, -1000000, 1000000);
|
||||
addEnchantmentDescription = builder.text("Add Enchantment Descriptions")
|
||||
.defineEnum("addEnchantmentDescription", ClientEventHandler.EnchDesc.ALWAYS);
|
||||
renderOverlayIcons = builder.text("Render overlay icons on entities")
|
||||
.define("renderOverlayIcons", true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import dev.xkmc.l2core.init.L2Core;
|
||||
import dev.xkmc.l2core.init.reg.simple.Val;
|
||||
import dev.xkmc.l2core.util.ConfigInit;
|
||||
import dev.xkmc.l2serial.serialization.custom_handler.CodecHandler;
|
||||
import dev.xkmc.l2serial.serialization.custom_handler.Handlers;
|
||||
import dev.xkmc.l2serial.util.ModContainerHack;
|
||||
import dev.xkmc.l2serial.util.Wrappers;
|
||||
import net.minecraft.client.particle.ParticleEngine;
|
||||
@@ -21,7 +22,6 @@ import net.minecraft.client.particle.ParticleProvider;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.particles.ParticleOptions;
|
||||
import net.minecraft.core.particles.ParticleType;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.codec.ByteBufCodecs;
|
||||
@@ -146,6 +146,7 @@ public class L2Registrate extends AbstractRegistrate<L2Registrate> {
|
||||
cons.accept(ans);
|
||||
var reg = ans.create();
|
||||
new CodecHandler<>(Wrappers.cast(cls), reg.byNameCodec(), ByteBufCodecs.fromCodecWithRegistries(reg.byNameCodec()));
|
||||
Handlers.registerReg(Wrappers.cast(cls), key);
|
||||
OneTimeEventReceiver.addModListener(this, NewRegistryEvent.class, (e) -> e.register(reg));
|
||||
return new RegistryInstance<>(reg, key);
|
||||
}
|
||||
@@ -246,13 +247,6 @@ public class L2Registrate extends AbstractRegistrate<L2Registrate> {
|
||||
before = e.id;
|
||||
}
|
||||
}
|
||||
for (var e : BuiltInRegistries.CREATIVE_MODE_TAB.entrySet()) {
|
||||
var id = e.getKey().location();
|
||||
if (known(id) || known(e.getValue())) {
|
||||
continue;
|
||||
}
|
||||
b.withTabsAfter(id);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean known(ResourceLocation id) {
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package dev.xkmc.l2core.mixin;
|
||||
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
@Mixin(CreativeModeTab.class)
|
||||
public class CreativeModeTabMixin {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
CreativeModeTab tab = (CreativeModeTab) (Object) this;
|
||||
var key = BuiltInRegistries.CREATIVE_MODE_TAB.getKey(tab);
|
||||
return key == null ? "[Unregistered]" : key.toString();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import net.minecraft.MethodsReturnNonnullByDefault;
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||
import net.minecraft.network.codec.StreamCodec;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.item.crafting.Ingredient;
|
||||
import net.minecraft.world.item.crafting.SmithingTransformRecipe;
|
||||
|
||||
@@ -14,7 +15,7 @@ import javax.annotation.ParametersAreNonnullByDefault;
|
||||
@MethodsReturnNonnullByDefault
|
||||
public abstract class AbstractSmithingRecipe<T extends AbstractSmithingRecipe<T>> extends SmithingTransformRecipe {
|
||||
|
||||
public static final Ingredient TEMPLATE_PLACEHOLDER = Ingredient.EMPTY;
|
||||
public static final Ingredient TEMPLATE_PLACEHOLDER = Ingredient.of(Items.PAPER);
|
||||
|
||||
public AbstractSmithingRecipe(Ingredient template, Ingredient base, Ingredient addition, ItemStack result) {
|
||||
super(template, base, addition, result);
|
||||
|
||||
@@ -6,5 +6,7 @@
|
||||
"l2core.configuration.overlayZVal.tooltip": "默认值:250",
|
||||
"l2core.configuration.section.l2configs.l2core.client.toml": "莱特兰核心 - 客户端配置",
|
||||
"l2core.configuration.section.l2configs.l2core.client.toml.title": "莱特兰核心 - 客户端配置",
|
||||
"l2core.configuration.title": "莱特兰核心 - 配置"
|
||||
"l2core.configuration.title": "莱特兰核心 - 配置",
|
||||
"l2core.configuration.renderOverlayIcons": "实体图标显示",
|
||||
"l2core.configuration.renderOverlayIcons.tooltip": ""
|
||||
}
|
||||
@@ -4,6 +4,7 @@
|
||||
"package": "dev.xkmc.l2core.mixin",
|
||||
"compatibilityLevel": "JAVA_21",
|
||||
"mixins": [
|
||||
"CreativeModeTabMixin"
|
||||
],
|
||||
"client": [
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user