From 372b6d29dc2ef3f8b4c44c7a1be7e04a1f60f1fa Mon Sep 17 00:00:00 2001 From: ticticboooom Date: Wed, 29 Jun 2022 13:57:25 +0100 Subject: [PATCH] repositioned a few BP gui elements --- .../client/container/BlueprintContainer.java | 13 +++++++------ .../mm/client/screen/BlueprintScreen.java | 19 ++++++++++++------- .../mods/mm/data/model/StructureModel.java | 2 ++ .../data/reload/StructureReloadListener.java | 3 ++- .../data/test/mm/machines/mystructure.json | 1 + .../data/test/mm/machines/struct.json | 1 + version.properties | 4 ++-- 7 files changed, 27 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/ticticboooom/mods/mm/client/container/BlueprintContainer.java b/src/main/java/com/ticticboooom/mods/mm/client/container/BlueprintContainer.java index e4aeee6..9ea79a4 100644 --- a/src/main/java/com/ticticboooom/mods/mm/client/container/BlueprintContainer.java +++ b/src/main/java/com/ticticboooom/mods/mm/client/container/BlueprintContainer.java @@ -23,12 +23,14 @@ public class BlueprintContainer extends Container { public BlueprintContainer(int windowId, PlayerInventory inv, PacketBuffer data) { super(MMContainerTypes.BLUEPRINT.get(), windowId); int index = 0; - for (int i = 0; i < 9; i++) { - addSlot(new BlueprintSlot(index, 41+ (i * 18), 111)); + for (int i = 0; i < 11; i++) { + addSlot(new BlueprintSlot(index, -35 + 1, -15 + (i * 18)+ 1)); index++; - } - for (int i = 0; i < 9; i++) { - addSlot(new BlueprintSlot(index, 41+ (i * 18), 129)); + addSlot(new BlueprintSlot(index, -35 + 18+ 1, -15 + (i * 18)+ 1)); + index++; + addSlot(new BlueprintSlot(index, -35 + (2 * 18)+ 1, -15 + (i * 18)+ 1)); + index++; + addSlot(new BlueprintSlot(index, -35 + (3 * 18)+ 1, -15 + (i * 18)+ 1)); index++; } } @@ -52,7 +54,6 @@ public class BlueprintContainer extends Container { } - @Override public boolean canInteractWith(PlayerEntity playerIn) { return true; diff --git a/src/main/java/com/ticticboooom/mods/mm/client/screen/BlueprintScreen.java b/src/main/java/com/ticticboooom/mods/mm/client/screen/BlueprintScreen.java index 55970b7..3c68137 100644 --- a/src/main/java/com/ticticboooom/mods/mm/client/screen/BlueprintScreen.java +++ b/src/main/java/com/ticticboooom/mods/mm/client/screen/BlueprintScreen.java @@ -15,6 +15,7 @@ import com.ticticboooom.mods.mm.setup.MMRegistries; import com.ticticboooom.mods.mm.structures.StructureKeyType; import com.ticticboooom.mods.mm.util.GuiBlockUtils; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.screen.inventory.ContainerScreen; import net.minecraft.client.renderer.BlockRendererDispatcher; import net.minecraft.client.renderer.IRenderTypeBuffer; @@ -78,9 +79,11 @@ public class BlueprintScreen extends ContainerScreen { Minecraft.getInstance().textureManager.bindTexture(STRUCTURE_BG); blit(matrixStack, guiLeft + 40, guiTop - 15, 0, 0, 162, 150); Minecraft.getInstance().textureManager.bindTexture(new ResourceLocation(Ref.MOD_ID, "textures/gui/slot_parts.png")); - for (int i = 0; i < 9; i++) { - blit(matrixStack, guiLeft + 40 + (i * 18), guiTop + 110, 0, 26, 18, 18); - blit(matrixStack, guiLeft + 40 + (i * 18), guiTop + 128, 0, 26, 18, 18); + for (int i = 0; i < 11; i++) { + blit(matrixStack, guiLeft -35, guiTop -15 + (i * 18), 0, 26, 18, 18); + blit(matrixStack, guiLeft -35 + 18, guiTop -15 + (i * 18), 0, 26, 18, 18); + blit(matrixStack, guiLeft -35 + (2*18), guiTop -15 + (i * 18), 0, 26, 18, 18); + blit(matrixStack, guiLeft -35 + (3*18), guiTop -15 + (i * 18), 0, 26, 18, 18); } GLScissor.enable(guiLeft + 40, guiTop - 15, 162, 120); @@ -106,6 +109,8 @@ public class BlueprintScreen extends ContainerScreen { GLScissor.disable(); renderItems(); renderActStructureButtons(x, y, matrixStack); + FontRenderer fontRenderer = Minecraft.getInstance().fontRenderer; + fontRenderer.drawString(matrixStack, screenContainer.structure.name.getString(),guiLeft + 40, guiTop + 110, 0x444444); prevMouseState = GLFW.glfwGetMouseButton(Minecraft.getInstance().getMainWindow().getHandle(), GLFW.GLFW_MOUSE_BUTTON_LEFT); } @@ -212,13 +217,13 @@ public class BlueprintScreen extends ContainerScreen { private void renderActStructureButtons(int x, int y, MatrixStack ms) { Minecraft mc = Minecraft.getInstance(); Minecraft.getInstance().textureManager.bindTexture(new ResourceLocation(Ref.MOD_ID, "textures/gui/slot_parts.png")); - blit(ms, guiLeft + 40, guiTop + 160, 0, 26, 18, 18); - blit(ms, guiLeft + 184, guiTop + 160, 0, 26, 18, 18); + blit(ms, guiLeft + 40, guiTop + 165, 0, 26, 18, 18); + blit(ms, guiLeft + 184, guiTop + 165, 0, 26, 18, 18); int mouseState = GLFW.glfwGetMouseButton(mc.getMainWindow().getHandle(), GLFW.GLFW_MOUSE_BUTTON_LEFT); if (mouseState == 1 & prevMouseState == 0) { - if (y >= guiTop + 160 && y <= guiTop + 160 + 18 && x >= guiLeft + 40 && x <= guiLeft + 40 + 18) { + if (y >= guiTop + 165 && y <= guiTop + 165 + 18 && x >= guiLeft + 40 && x <= guiLeft + 40 + 18) { screenContainer.rotateDisplayedStructureBackward(); - } else if (y >= guiTop + 160 && y <= guiTop + 160 + 18 && x >= guiLeft + 184 && x <= guiLeft + 184 + 18) { + } else if (y >= guiTop + 165 && y <= guiTop + 165 + 18 && x >= guiLeft + 184 && x <= guiLeft + 184 + 18) { screenContainer.rotateDisplayedStructureForward(); } } diff --git a/src/main/java/com/ticticboooom/mods/mm/data/model/StructureModel.java b/src/main/java/com/ticticboooom/mods/mm/data/model/StructureModel.java index 88d83e8..9dd347d 100644 --- a/src/main/java/com/ticticboooom/mods/mm/data/model/StructureModel.java +++ b/src/main/java/com/ticticboooom/mods/mm/data/model/StructureModel.java @@ -3,6 +3,7 @@ package com.ticticboooom.mods.mm.data.model; import com.ticticboooom.mods.mm.structures.StructureKeyTypeValue; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.text.ITextComponent; import java.util.List; import java.util.Map; @@ -16,6 +17,7 @@ public class StructureModel { public Map requiredPorts; public Map> portGroupings; public List positionedKeys; + public ITextComponent name; public static class Key { public Key(ResourceLocation type, StructureKeyTypeValue data){ diff --git a/src/main/java/com/ticticboooom/mods/mm/data/reload/StructureReloadListener.java b/src/main/java/com/ticticboooom/mods/mm/data/reload/StructureReloadListener.java index 49d5b33..0ede928 100644 --- a/src/main/java/com/ticticboooom/mods/mm/data/reload/StructureReloadListener.java +++ b/src/main/java/com/ticticboooom/mods/mm/data/reload/StructureReloadListener.java @@ -20,6 +20,7 @@ import net.minecraftforge.event.AddReloadListenerEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; +import javax.swing.text.html.parser.Parser; import java.util.*; @Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.FORGE) @@ -46,7 +47,7 @@ public class StructureReloadListener extends JsonReloadListener { private StructureModel parse(ResourceLocation key, JsonObject json) { StructureModel result = new StructureModel(); result.id = key; - + result.name = ParserUtils.parseTextComponent(json.get("name")); result.portGroupings = ParserUtils.parseOrDefault(json, "portGroupings", x -> { JsonObject obj = x.getAsJsonObject(); Map> res = new HashMap<>(); diff --git a/src/test/resources/data/test/mm/machines/mystructure.json b/src/test/resources/data/test/mm/machines/mystructure.json index c85bfec..4685fd9 100644 --- a/src/test/resources/data/test/mm/machines/mystructure.json +++ b/src/test/resources/data/test/mm/machines/mystructure.json @@ -3,6 +3,7 @@ "test:main", "test:second" ], + "name": "Bobs Uncle", "controllerSettings": { "facing": "west" }, diff --git a/src/test/resources/data/test/mm/machines/struct.json b/src/test/resources/data/test/mm/machines/struct.json index e13360c..1127e06 100644 --- a/src/test/resources/data/test/mm/machines/struct.json +++ b/src/test/resources/data/test/mm/machines/struct.json @@ -3,6 +3,7 @@ "test:main", "test:second" ], + "name": "bobs aunt", "controllerSettings": { "facing": "west" }, diff --git a/version.properties b/version.properties index d80be31..5c41975 100644 --- a/version.properties +++ b/version.properties @@ -1,2 +1,2 @@ -#Wed Jun 29 10:30:30 BST 2022 -VERSION_CODE=1865 +#Wed Jun 29 13:54:49 BST 2022 +VERSION_CODE=1898