Skip to content

Commit

Permalink
fix inventory render shortcut injection not being cancellable
Browse files Browse the repository at this point in the history
  • Loading branch information
gliscowo committed May 23, 2022
1 parent 28b9605 commit cde7dad
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ minecraft_version=1.18.2
yarn_mappings=1.18.2+build.2
loader_version=0.13.3
# Mod Properties
mod_version=0.2.12
mod_version=0.2.13
maven_group=com.glisco
archives_base_name=isometric-renders
# Dependencies
Expand All @@ -21,4 +21,4 @@ worldmesher_version=0.2.6+1.18
exo_version=0.1.4+1.18

# https://maven.wispforest.io/io/wispforest/owo-lib/
owo_version=0.5.4+1.18
owo_version=0.5.4+1.18
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@ protected HandledScreenMixin(Text title) {
super(title);
}

@Inject(method = "keyPressed", at = @At("HEAD"))
@Inject(method = "keyPressed", at = @At("HEAD"), cancellable = true)
public void renderInventory(int keyCode, int scanCode, int modifiers, CallbackInfoReturnable<Boolean> cir) {
if (keyCode != GLFW.GLFW_KEY_F12) return;

if (Screen.hasControlDown()) {
client.setScreen(new BatchIsometricBlockRenderScreen(IsometricRenderHelper.extractBlocks(handler.slots.stream().map(Slot::getStack).collect(Collectors.toList())), "inventory"));
cir.cancel();
cir.setReturnValue(false);
} else if (Screen.hasAltDown()) {
client.setScreen(new BatchIsometricItemRenderScreen(handler.slots.stream().map(Slot::getStack).iterator(), "inventory"));
cir.cancel();
cir.setReturnValue(false);
} else if (Screen.hasShiftDown()) {
IsometricRenderHelper.renderItemAtlas("inventory", handler.slots.stream().map(Slot::getStack).filter(itemStack -> !itemStack.isEmpty()).collect(Collectors.toList()), true);
cir.cancel();
cir.setReturnValue(false);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class IsometricChannel extends ExoCommandChannel {

public IsometricChannel() {
addCommand("open-screen", (port, arguments) -> {
RenderSystem.recordRenderCall(() -> MinecraftClient.getInstance().setScreen(new IsometricRenderScreen()));
MinecraftClient.getInstance().execute(() -> MinecraftClient.getInstance().setScreen(new IsometricRenderScreen()));
return Exo.OK_RESPONSE;
});

Expand All @@ -32,7 +32,6 @@ public IsometricChannel() {
setupItem(client.getItemRenderer().getModel(stack, null, null, 0).hasDepth());
IsometricRenderPresets.setupItemStackRender(screen, stack);

screen.setExportCallback(file -> send("exported#" + id + "#" + file.getAbsolutePath(), port));
screen.setExportCallback(file -> send(Exo.join("exported", id.toString(), file.getAbsolutePath()), port));
screen.scheduleCapture();
client.setScreen(screen);
Expand Down

0 comments on commit cde7dad

Please sign in to comment.