Curios API (Forge/NeoForge)

Curios API (Forge/NeoForge)

140M Downloads

Right click Curios item does not handle client side.

SihenZhang opened this issue ยท 0 comments

commented

Versions (Be specific, do not write "latest"):

  • Curios: 1.16.5-4.0.5.1
  • Forge/Fabric: forge-1.16.5-36.1.24

Observed Behavior:

When right click a Curios item, Curios will not handle the client logic because only on the server side, the event will be canceled.

if (!player.world.isRemote) {
Map<String, ICurioStacksHandler> curios = handler.getCurios();
for (Map.Entry<String, ICurioStacksHandler> entry : curios.entrySet()) {
IDynamicStackHandler stackHandler = entry.getValue().getStacks();
for (int i = 0; i < stackHandler.getSlots(); i++) {
String id = entry.getKey();
SlotContext slotContext = new SlotContext(id, player, i);
if (curiosHelper.isStackValid(slotContext, stack) && curio.canEquip(id, player) &&
curio.canEquipFromUse(slotContext)) {
ItemStack present = stackHandler.getStackInSlot(i);
if (present.isEmpty()) {
stackHandler.setStackInSlot(i, stack.copy());
curio.onEquipFromUse(slotContext);
if (!player.isCreative()) {
int count = stack.getCount();
stack.shrink(count);
}
evt.setCancellationResult(ActionResultType.SUCCESS);
evt.setCanceled(true);
return;
}
}
}
}
}

So if a Curios item overrides the use(in MCP is onItemRightClick) method, it causes the method to be called at the client.
For example, a helmet, which is also a Curios item, will be equipped to both the Curios slot and the Armor slot when right click, but the Armor slot one is fake.
In survival mode, it seems to be equipped to the Armor slot
In survival mode, it seems to be equipped to the Armor slot.
But it is equipped to the Curios slot, the Armor slot one is fake
But it is equipped to the Curios slot, the Armor slot one is fake.

Expected Behavior:

On the client side, you can also cancel the RightClickItem event. The Cancellation Result should be ActionResultType.sidedSuccess(player.world.isClientSide())(in MCP is ActionResultType.func_233537_a_(player.world.isRemote()))

Steps to Reproduce:

  1. I have made a test mod that uses MojMap so that you can easily find the problem. Here is the main class. https://gist.github.com/SihenZhang/bb6ebaee1bbea390ad600bbe1a158021
  2. Identifier examplemod:test_item as head.
  3. Just start the game and try to right click examplemod:test_item in survival mode.