Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Attachments are not synced on player creation

オープン
#261 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

この issue はまだ評価されていません。

説明

1.21.x bug
Minecraft version

1.21.1

Describe the bug

When a new player is created, e.g. upon join, dimension change, or respawn, attachments are not synced. Attachments do sync properly when setAttached/removeAttached is called.

Steps to reproduce
  1. Create a fabric mod with the following mod initializer
@SuppressWarnings("UnstableApiUsage")
public class BugDemo implements ModInitializer {
	public static final String MOD_ID = "bugdemo";

	public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);

	public static final AttachmentType<Unit> TEST = AttachmentRegistry.create(ResourceLocation.fromNamespaceAndPath(MOD_ID, "test"), builder -> builder
			.persistent(Unit.CODEC)
			.syncWith(StreamCodec.unit(Unit.INSTANCE), AttachmentSyncPredicate.targetOnly())
			.copyOnDeath()
	);

	@Override
	public void onInitialize() {
		UseItemCallback.EVENT.register((player, world, hand) -> {
			var stack = player.getItemInHand(hand);

			if (stack.is(Items.BLAZE_ROD)) {
				if (world.isClientSide()) return InteractionResultHolder.success(stack);

				player.setAttached(TEST, Unit.INSTANCE);

				return InteractionResultHolder.success(stack);
			}

			if (stack.is(Items.STICK)) {
                LOGGER.info(
                        "{} {} attachment",
                        world.isClientSide() ? "client" : "server",
                        player.hasAttached(TEST) ? "has" : "does not have"
                );
                return InteractionResultHolder.success(stack);
            }

			return InteractionResultHolder.pass(stack);
        });
	}
}
  1. Run the mod on fabric.
  2. Use the blaze rod to set the attachment.
  3. Recreate the player by relogging, respawning, or changing dimensions.
  4. Use the stick. The log will show
[17:06:29] [Render thread/INFO] (bugdemo) client has attachment
[17:06:29] [Server thread/INFO] (bugdemo) server has attachment
  1. Run the mod on neoforge with connector & ffapi.
  2. Repeat steps 3-5. The log will show
[17:13:56] [Render thread/INFO] [bugdemo/]: client does not have attachment
[17:13:56] [Server thread/INFO] [bugdemo/]: server has attachment
  1. Use the blaze rod to re-set the attachment, then use the stick. The log will show
[17:18:53] [Render thread/INFO] [bugdemo/]: client has attachment
[17:18:53] [Server thread/INFO] [bugdemo/]: server has attachment

The expected behavior is that when the player is recreated, the server and client will both see the attachment.

Logs

No response

Additional context

Possibly related to FFAPI 2.2.0 using neoforge api for attachment sync.

主要言語
Java
スター
181
フォーク
41
平均マージ
19日 17時間
マージ済み PR(30日)
1

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

Sinytra/ForgifiedFabricAPI のほかの issue

Sinytra/ForgifiedFabricAPI の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。