use of com.lothrazar.cyclic.net.PacketItemToggle in project Cyclic by Lothrazar.
the class ClientInputEvents method onMouseEvent.
@SubscribeEvent(priority = EventPriority.HIGH)
public void onMouseEvent(ScreenEvent.MouseClickedEvent.Pre event) {
if (event.getScreen() == null || !(event.getScreen() instanceof AbstractContainerScreen<?>)) {
return;
}
AbstractContainerScreen<?> gui = (AbstractContainerScreen<?>) event.getScreen();
boolean rightClickDown = event.getButton() == 1;
try {
if (rightClickDown && gui.getSlotUnderMouse() != null) {
Slot slotHit = gui.getSlotUnderMouse();
if (!slotHit.getItem().isEmpty()) {
ItemStack maybeCharm = slotHit.getItem();
if (maybeCharm.getItem() instanceof IHasClickToggle) {
PacketRegistry.INSTANCE.sendToServer(new PacketItemToggle(slotHit.index));
event.setCanceled(true);
// UtilSound.playSound(ModCyclic.proxy.getClientPlayer(), SoundEvents.UI_BUTTON_CLICK);
} else if (maybeCharm.getItem() instanceof ItemStorageBag) {
PacketRegistry.INSTANCE.sendToServer(new PacketItemGui(slotHit.index));
event.setCanceled(true);
}
}
}
} catch (Exception e) {
// array out of bounds, or we are in a strange third party GUI that doesnt have slots like this
// EXAMPLE: mod.chiselsandbits.bitbag.BagGui
ModCyclic.LOGGER.error("click error", e);
// so this fixes ithttps://github.com/PrinceOfAmber/Cyclic/issues/410
}
}
Aggregations