Create/src/main/java/com/simibubi/create/events/InputEvents.java
PepperBell 795ef07b38 Fix Flywheel contraption lighting
- Fix some events being registered to the wrong event bus
- Organize some event registration
- Fully fix FluidRenderer
2021-11-10 22:15:26 -08:00

74 lines
2.4 KiB
Java

package com.simibubi.create.events;
import com.simibubi.create.CreateClient;
import com.simibubi.create.content.curiosities.toolbox.ToolboxHandlerClient;
import com.simibubi.create.content.logistics.item.LinkedControllerClientHandler;
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;
import net.minecraftforge.client.event.InputEvent.ClickInputEvent;
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;
@EventBusSubscriber(Dist.CLIENT)
public class InputEvents {
@SubscribeEvent
public static void onKeyInput(KeyInputEvent event) {
if (Minecraft.getInstance().screen != null)
return;
int key = event.getKey();
boolean pressed = !(event.getAction() == 0);
CreateClient.SCHEMATIC_HANDLER.onKeyInput(key, pressed);
ToolboxHandlerClient.onKeyInput(key, pressed);
}
@SubscribeEvent
public static void onMouseScrolled(MouseScrollEvent event) {
if (Minecraft.getInstance().screen != null)
return;
double delta = event.getScrollDelta();
// CollisionDebugger.onScroll(delta);
boolean cancelled = CreateClient.SCHEMATIC_HANDLER.mouseScrolled(delta)
|| CreateClient.SCHEMATIC_AND_QUILL_HANDLER.mouseScrolled(delta) || FilteringHandler.onScroll(delta)
|| ScrollValueHandler.onScroll(delta);
event.setCanceled(cancelled);
}
@SubscribeEvent
public static void onMouseInput(MouseInputEvent event) {
if (Minecraft.getInstance().screen != null)
return;
int button = event.getButton();
boolean pressed = !(event.getAction() == 0);
CreateClient.SCHEMATIC_HANDLER.onMouseInput(button, pressed);
CreateClient.SCHEMATIC_AND_QUILL_HANDLER.onMouseInput(button, pressed);
}
@SubscribeEvent
public static void onClickInput(ClickInputEvent event) {
if (Minecraft.getInstance().screen != null)
return;
if (event.getKeyBinding() == Minecraft.getInstance().options.keyPickItem) {
if (ToolboxHandlerClient.onPickItem())
event.setCanceled(true);
return;
}
if (event.isUseItem())
LinkedControllerClientHandler.deactivateInLectern();
}
}