Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Right click Curios item does not handle client side. #141

Closed
SihenZhang opened this issue Jun 3, 2021 · 0 comments
Closed

Right click Curios item does not handle client side. #141

SihenZhang opened this issue Jun 3, 2021 · 0 comments
Assignees
Labels
type: bug Something isn't working

Comments

@SihenZhang
Copy link

SihenZhang commented Jun 3, 2021

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.
@SihenZhang SihenZhang added the type: bug Something isn't working label Jun 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants