From 8fc86a433f4999799e17daf539015718fb8886a0 Mon Sep 17 00:00:00 2001 From: Quarris Date: Sat, 13 Aug 2022 15:40:43 +0000 Subject: [PATCH] JEI compat for the multi legend feature --- .../MachineStructureRecipeCategory.java | 47 ++++++++++++------- .../recipes/structures/test_multi_tags.json | 44 +++++++++++++++++ version.properties | 4 +- 3 files changed, 76 insertions(+), 19 deletions(-) create mode 100644 src/test/resources/data/mm/recipes/structures/test_multi_tags.json diff --git a/src/main/java/com/ticticboooom/mods/mm/client/jei/category/MachineStructureRecipeCategory.java b/src/main/java/com/ticticboooom/mods/mm/client/jei/category/MachineStructureRecipeCategory.java index daa4941..f57d13f 100644 --- a/src/main/java/com/ticticboooom/mods/mm/client/jei/category/MachineStructureRecipeCategory.java +++ b/src/main/java/com/ticticboooom/mods/mm/client/jei/category/MachineStructureRecipeCategory.java @@ -1,5 +1,7 @@ package com.ticticboooom.mods.mm.client.jei.category; +import com.google.common.collect.HashBasedTable; +import com.google.common.collect.Table; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; import com.ticticboooom.mods.mm.MM; @@ -64,7 +66,8 @@ public class MachineStructureRecipeCategory implements IRecipeCategory variantIndices = new HashMap<>(); + private Table variantIndices = HashBasedTable.create(); + private Map partIndices = new HashMap<>(); public MachineStructureRecipeCategory(IJeiHelpers helpers, ControllerBlock controller) { this.helpers = helpers; @@ -122,6 +125,7 @@ public class MachineStructureRecipeCategory implements IRecipeCategory x.getPos().getY() == sliceY).collect(Collectors.toList()); } - //float tx = 6.5f, ty = -5, tz = 10; - - if (GLFW.glfwGetMouseButton(mc.getMainWindow().getHandle(), GLFW.GLFW_MOUSE_BUTTON_LEFT) != 0 && GLFW.glfwGetKey(mc.getMainWindow().getHandle(), GLFW.GLFW_KEY_LEFT_SHIFT) != 0){ + if (GLFW.glfwGetMouseButton(mc.getMainWindow().getHandle(), GLFW.GLFW_MOUSE_BUTTON_LEFT) != 0 && GLFW.glfwGetKey(mc.getMainWindow().getHandle(), GLFW.GLFW_KEY_LEFT_SHIFT) != 0) { double relMoveX = mouseX - xLastMousePosition; double relMoveY = mouseY - yLastMousePosition; - prePos.add((float)relMoveX * 0.08f, (float)-relMoveY * 0.08f, 0); + prePos.add((float) relMoveX * 0.08f, (float) -relMoveY * 0.08f, 0); } Vector3f offset = new Vector3f(minX, -minY, minZ); // Align bottom back left corner block to be at the center @@ -194,16 +196,27 @@ public class MachineStructureRecipeCategory implements IRecipeCategory tag = BlockTags.getCollection().getTagByID(resourceLocation); - Integer index = this.variantIndices.get(model.getPos()); - Block block = tag.getAllElements().get(index); + Block block = tag.getAllElements().get(displayIndex); if (this.tickTimer == 0) { - this.variantIndices.put(model.getPos(), (index + 1) % tag.getAllElements().size()); + this.variantIndices.put(partIndex, model.getPos(), (displayIndex + 1) % tag.getAllElements().size()); } if (block != null) { @@ -232,10 +244,9 @@ public class MachineStructureRecipeCategory implements IRecipeCategory> ports = port.isInput() ? MMLoader.IPORT_BLOCKS : MMLoader.OPORT_BLOCKS; - Integer index = this.variantIndices.get(model.getPos()); - String controllerId = port.getControllerId().get(index); + String controllerId = port.getControllerId().get(displayIndex); if (this.tickTimer == 0) { - this.variantIndices.put(model.getPos(), (index + 1) % port.getControllerId().size()); + this.variantIndices.put(partIndex, model.getPos(), (displayIndex + 1) % port.getControllerId().size()); } String type = port.getType(); MachinePortBlock block = null; @@ -258,11 +269,13 @@ public class MachineStructureRecipeCategory implements IRecipeCategory reg : MMLoader.BLOCKS) { if (reg.get().getControllerId().equals(controller)) { diff --git a/src/test/resources/data/mm/recipes/structures/test_multi_tags.json b/src/test/resources/data/mm/recipes/structures/test_multi_tags.json new file mode 100644 index 0000000..4db7eb5 --- /dev/null +++ b/src/test/resources/data/mm/recipes/structures/test_multi_tags.json @@ -0,0 +1,44 @@ +{ + "type": "masterfulmachinery:machine_structure", + "id": "test_multi_tags", + "controllerId": "basic", + "name": "Test Multi Tags", + "layout": [ + [ + "12C34" + ] + ], + "legend": { + "1": { + "block": "minecraft:stone" + }, + "2": { + "tag": "minecraft:wool" + }, + "3": [ + { + "tag": "minecraft:logs" + }, + { + "tag": "minecraft:planks" + }, + { + "block": "minecraft:redstone_lamp", + "props": { + "lit": "true" + } + } + ], + "4": [ + { + "block": "minecraft:glowstone" + }, + { + "block": "minecraft:piston", + "props": { + "extended": "true" + } + } + ] + } +} diff --git a/version.properties b/version.properties index 13cabe4..da5f73f 100644 --- a/version.properties +++ b/version.properties @@ -1,2 +1,2 @@ -#Sat Aug 13 11:52:53 UTC 2022 -VERSION_CODE=1019 +#Sat Aug 13 15:30:13 UTC 2022 +VERSION_CODE=1041