-
-
Notifications
You must be signed in to change notification settings - Fork 35
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Minecraft version
1.21.1
Describe the bug
When you call removeAttached for a data attachment, it is not synced to the client, making the client think the data is still attached.
Steps to reproduce
- Create a 1.21.1 fabric mod with the following initializer, which is intended to toggle the attachment by using a stick and print to the log every second if the client sees the data attached:
@SuppressWarnings("UnstableApiUsage")
public class AttachmentTest implements ModInitializer {
public static final String MOD_ID = "attachmenttest";
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
public static final AttachmentType<Unit> TEST = AttachmentRegistry.create(
ResourceLocation.fromNamespaceAndPath(MOD_ID, "test"),
builder -> builder.syncWith(StreamCodec.unit(Unit.INSTANCE), AttachmentSyncPredicate.all())
);
@Override
public void onInitialize() {
UseItemCallback.EVENT.register((player, world, hand) -> {
var stack = player.getItemInHand(hand);
if (!stack.is(Items.STICK)) return InteractionResultHolder.pass(stack);
if (world.isClientSide) return InteractionResultHolder.success(stack);
if (player.hasAttached(TEST)) {
LOGGER.info("Removed attachment");
player.removeAttached(TEST);
} else {
LOGGER.info("Set Attachment");
player.setAttached(TEST, Unit.INSTANCE);
}
return InteractionResultHolder.success(stack);
});
ClientTickEvents.END_WORLD_TICK.register(world -> {
if (Minecraft.getInstance().player.hasAttached(TEST) && world.getGameTime() % 20 == 0)
LOGGER.info("Currently attached");
});
}
}- Test the mod in fabric. The message correctly stops getting printed when the stick is used to remove the attachment.
- Test the mod with connector & ffapi. The message keeps getting printed even after the stick is used to remove the attachment.
Logs
Additional context
Using Connector 2.0.0 beta 12, FFAPI 0.115.6+2.1.4+1.21.1, and Neoforge 21.1.216
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working