2020-08-05 22:10:05 +02:00
|
|
|
package com.simibubi.create.events;
|
|
|
|
|
|
|
|
import com.simibubi.create.CreateClient;
|
2021-09-16 04:10:34 +02:00
|
|
|
import com.simibubi.create.content.curiosities.toolbox.ToolboxHandlerClient;
|
2021-06-30 04:32:49 +02:00
|
|
|
import com.simibubi.create.content.logistics.item.LinkedControllerClientHandler;
|
2020-08-05 22:10:05 +02:00
|
|
|
import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringHandler;
|
|
|
|
import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.ScrollValueHandler;
|
|
|
|
|
|
|
|
import net.minecraft.client.Minecraft;
|
|
|
|
import net.minecraftforge.api.distmarker.Dist;
|
2021-06-30 04:32:49 +02:00
|
|
|
import net.minecraftforge.client.event.InputEvent.ClickInputEvent;
|
2020-08-05 22:10:05 +02:00
|
|
|
import net.minecraftforge.client.event.InputEvent.KeyInputEvent;
|
|
|
|
import net.minecraftforge.client.event.InputEvent.MouseInputEvent;
|
|
|
|
import net.minecraftforge.client.event.InputEvent.MouseScrollEvent;
|
|
|
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
|
|
|
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
|
|
|
|
2021-11-11 07:15:26 +01:00
|
|
|
@EventBusSubscriber(Dist.CLIENT)
|
2020-08-05 22:10:05 +02:00
|
|
|
public class InputEvents {
|
2021-04-08 19:22:11 +02:00
|
|
|
|
2020-08-05 22:10:05 +02:00
|
|
|
@SubscribeEvent
|
|
|
|
public static void onKeyInput(KeyInputEvent event) {
|
2021-07-15 11:32:03 +02:00
|
|
|
if (Minecraft.getInstance().screen != null)
|
2020-08-05 22:10:05 +02:00
|
|
|
return;
|
|
|
|
|
2021-11-11 07:15:26 +01:00
|
|
|
int key = event.getKey();
|
|
|
|
boolean pressed = !(event.getAction() == 0);
|
|
|
|
|
2021-05-23 03:00:10 +02:00
|
|
|
CreateClient.SCHEMATIC_HANDLER.onKeyInput(key, pressed);
|
2021-09-16 04:10:34 +02:00
|
|
|
ToolboxHandlerClient.onKeyInput(key, pressed);
|
2020-08-05 22:10:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@SubscribeEvent
|
|
|
|
public static void onMouseScrolled(MouseScrollEvent event) {
|
2021-07-15 11:32:03 +02:00
|
|
|
if (Minecraft.getInstance().screen != null)
|
2020-08-05 22:10:05 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
double delta = event.getScrollDelta();
|
|
|
|
// CollisionDebugger.onScroll(delta);
|
2021-05-23 03:00:10 +02:00
|
|
|
boolean cancelled = CreateClient.SCHEMATIC_HANDLER.mouseScrolled(delta)
|
2021-05-25 21:23:55 +02:00
|
|
|
|| CreateClient.SCHEMATIC_AND_QUILL_HANDLER.mouseScrolled(delta) || FilteringHandler.onScroll(delta)
|
|
|
|
|| ScrollValueHandler.onScroll(delta);
|
2020-08-05 22:10:05 +02:00
|
|
|
event.setCanceled(cancelled);
|
|
|
|
}
|
|
|
|
|
|
|
|
@SubscribeEvent
|
|
|
|
public static void onMouseInput(MouseInputEvent event) {
|
2021-07-15 11:32:03 +02:00
|
|
|
if (Minecraft.getInstance().screen != null)
|
2020-08-05 22:10:05 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
int button = event.getButton();
|
|
|
|
boolean pressed = !(event.getAction() == 0);
|
|
|
|
|
2021-05-23 03:00:10 +02:00
|
|
|
CreateClient.SCHEMATIC_HANDLER.onMouseInput(button, pressed);
|
|
|
|
CreateClient.SCHEMATIC_AND_QUILL_HANDLER.onMouseInput(button, pressed);
|
2020-08-05 22:10:05 +02:00
|
|
|
}
|
|
|
|
|
2021-06-30 04:32:49 +02:00
|
|
|
@SubscribeEvent
|
|
|
|
public static void onClickInput(ClickInputEvent event) {
|
2021-07-15 11:32:03 +02:00
|
|
|
if (Minecraft.getInstance().screen != null)
|
2021-06-30 04:32:49 +02:00
|
|
|
return;
|
2021-10-07 16:16:24 +02:00
|
|
|
|
|
|
|
if (event.getKeyBinding() == Minecraft.getInstance().options.keyPickItem) {
|
|
|
|
if (ToolboxHandlerClient.onPickItem())
|
|
|
|
event.setCanceled(true);
|
|
|
|
return;
|
|
|
|
}
|
2021-06-30 04:32:49 +02:00
|
|
|
|
|
|
|
if (event.isUseItem())
|
|
|
|
LinkedControllerClientHandler.deactivateInLectern();
|
|
|
|
}
|
|
|
|
|
2020-08-05 22:10:05 +02:00
|
|
|
}
|