mirror of
https://github.com/Creators-of-Create/Create.git
synced 2025-02-06 10:25:00 +01:00
Overclicked
- Fixed Schematic and Quill selection registering mouse clicks twice
This commit is contained in:
parent
97906cb4cc
commit
4985a521a4
3 changed files with 20 additions and 17 deletions
|
@ -98,40 +98,41 @@ public class SchematicAndQuillHandler {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onMouseInput(int button, boolean pressed) {
|
public boolean onMouseInput(int button, boolean pressed) {
|
||||||
if (!pressed || button != 1)
|
if (!pressed || button != 1)
|
||||||
return;
|
return false;
|
||||||
if (!isActive())
|
if (!isActive())
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
LocalPlayer player = Minecraft.getInstance().player;
|
LocalPlayer player = Minecraft.getInstance().player;
|
||||||
|
|
||||||
if (player.isShiftKeyDown()) {
|
if (player.isShiftKeyDown()) {
|
||||||
discard();
|
discard();
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (secondPos != null) {
|
if (secondPos != null) {
|
||||||
ScreenOpener.open(new SchematicPromptScreen());
|
ScreenOpener.open(new SchematicPromptScreen());
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selectedPos == null) {
|
if (selectedPos == null) {
|
||||||
Lang.translate("schematicAndQuill.noTarget")
|
Lang.translate("schematicAndQuill.noTarget")
|
||||||
.sendStatus(player);
|
.sendStatus(player);
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (firstPos != null) {
|
if (firstPos != null) {
|
||||||
secondPos = selectedPos;
|
secondPos = selectedPos;
|
||||||
Lang.translate("schematicAndQuill.secondPos")
|
Lang.translate("schematicAndQuill.secondPos")
|
||||||
.sendStatus(player);
|
.sendStatus(player);
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
firstPos = selectedPos;
|
firstPos = selectedPos;
|
||||||
Lang.translate("schematicAndQuill.firstPos")
|
Lang.translate("schematicAndQuill.firstPos")
|
||||||
.sendStatus(player);
|
.sendStatus(player);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void discard() {
|
public void discard() {
|
||||||
|
|
|
@ -243,23 +243,23 @@ public class SchematicHandler {
|
||||||
selectionScreen.renderPassive(poseStack, partialTicks);
|
selectionScreen.renderPassive(poseStack, partialTicks);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onMouseInput(int button, boolean pressed) {
|
public boolean onMouseInput(int button, boolean pressed) {
|
||||||
if (!active)
|
if (!active)
|
||||||
return;
|
return false;
|
||||||
if (!pressed || button != 1)
|
if (!pressed || button != 1)
|
||||||
return;
|
return false;
|
||||||
Minecraft mc = Minecraft.getInstance();
|
Minecraft mc = Minecraft.getInstance();
|
||||||
if (mc.player.isShiftKeyDown())
|
if (mc.player.isShiftKeyDown())
|
||||||
return;
|
return false;
|
||||||
if (mc.hitResult instanceof BlockHitResult) {
|
if (mc.hitResult instanceof BlockHitResult) {
|
||||||
BlockHitResult blockRayTraceResult = (BlockHitResult) mc.hitResult;
|
BlockHitResult blockRayTraceResult = (BlockHitResult) mc.hitResult;
|
||||||
BlockState clickedBlock = mc.level.getBlockState(blockRayTraceResult.getBlockPos());
|
BlockState clickedBlock = mc.level.getBlockState(blockRayTraceResult.getBlockPos());
|
||||||
if (AllBlocks.SCHEMATICANNON.has(clickedBlock))
|
if (AllBlocks.SCHEMATICANNON.has(clickedBlock))
|
||||||
return;
|
return false;
|
||||||
if (AllBlocks.DEPLOYER.has(clickedBlock))
|
if (AllBlocks.DEPLOYER.has(clickedBlock))
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
currentTool.getTool()
|
return currentTool.getTool()
|
||||||
.handleRightClick();
|
.handleRightClick();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,15 +45,17 @@ public class InputEvents {
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onMouseInput(InputEvent.MouseButton event) {
|
public static void onMouseInput(InputEvent.MouseButton.Pre event) {
|
||||||
if (Minecraft.getInstance().screen != null)
|
if (Minecraft.getInstance().screen != null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int button = event.getButton();
|
int button = event.getButton();
|
||||||
boolean pressed = !(event.getAction() == 0);
|
boolean pressed = !(event.getAction() == 0);
|
||||||
|
|
||||||
CreateClient.SCHEMATIC_HANDLER.onMouseInput(button, pressed);
|
if (CreateClient.SCHEMATIC_HANDLER.onMouseInput(button, pressed))
|
||||||
CreateClient.SCHEMATIC_AND_QUILL_HANDLER.onMouseInput(button, pressed);
|
event.setCanceled(true);
|
||||||
|
else if (CreateClient.SCHEMATIC_AND_QUILL_HANDLER.onMouseInput(button, pressed))
|
||||||
|
event.setCanceled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
|
|
Loading…
Reference in a new issue