From edc57728db2bde4b23e5afa8b1560477f3e4db14 Mon Sep 17 00:00:00 2001 From: Jackson Abney Date: Sat, 25 May 2024 01:38:10 -0800 Subject: [PATCH] A few rendering bugs fixed. --- build.gradle | 10 ++----- gradle/wrapper/gradle-wrapper.properties | 2 +- .../java/li/cil/oc2/client/ClientSetup.java | 18 +----------- .../gui/AbstractMachineInventoryScreen.java | 6 ++-- .../gui/AbstractModContainerScreen.java | 5 +++- .../oc2/client/gui/MachineTerminalWidget.java | 4 +-- .../li/cil/oc2/client/gui/util/GuiUtils.java | 7 ++--- .../li/cil/oc2/client/gui/widget/Sprite.java | 4 +-- .../oc2/common/bus/device/DeviceTypes.java | 11 +++++-- .../li/cil/oc2/common/mixin/AtlasAdder.java | 27 ------------------ .../java/li/cil/oc2/common/vm/Terminal.java | 4 +-- .../{gui/icon/card.png => item/card_slot.png} | Bin .../flash_memory_slot.png} | Bin .../icon/floppy.png => item/floppy_slot.png} | Bin .../hard_drive_slot.png} | Bin .../icon/memory.png => item/memory_slot.png} | Bin .../network_tunnel_slot.png} | Bin .../robot_module_slot.png} | Bin src/main/resources/mixins.oc2.json | 3 +- 19 files changed, 30 insertions(+), 71 deletions(-) delete mode 100644 src/main/java/li/cil/oc2/common/mixin/AtlasAdder.java rename src/main/resources/assets/oc2/textures/{gui/icon/card.png => item/card_slot.png} (100%) rename src/main/resources/assets/oc2/textures/{gui/icon/flash_memory.png => item/flash_memory_slot.png} (100%) rename src/main/resources/assets/oc2/textures/{gui/icon/floppy.png => item/floppy_slot.png} (100%) rename src/main/resources/assets/oc2/textures/{gui/icon/hard_drive.png => item/hard_drive_slot.png} (100%) rename src/main/resources/assets/oc2/textures/{gui/icon/memory.png => item/memory_slot.png} (100%) rename src/main/resources/assets/oc2/textures/{gui/icon/network_tunnel.png => item/network_tunnel_slot.png} (100%) rename src/main/resources/assets/oc2/textures/{gui/icon/robot_module.png => item/robot_module_slot.png} (100%) diff --git a/build.gradle b/build.gradle index a018657f4..99e814e07 100644 --- a/build.gradle +++ b/build.gradle @@ -1,13 +1,9 @@ -buildscript { - dependencies { - classpath group: 'org.spongepowered', name: 'mixingradle', version: '0.7.+' - } -} plugins { id "idea" id "maven-publish" - id "net.minecraftforge.gradle" version "5.1.73" + id 'net.minecraftforge.gradle' version '[6.0,6.2)' id "com.matthewprenger.cursegradle" version "1.4.0" + id 'org.spongepowered.mixin' version '0.7.+' } apply plugin: 'org.spongepowered.mixin' @@ -93,7 +89,7 @@ dependencies { minecraftLibrary "org.apache.commons:commons-collections4:4.4" implementation fg.deobf("curse.maven:markdownmanual-502485:4873115") - implementation fg.deobf("curse.maven:architectury-api-419699:4521273") + implementation fg.deobf("curse.maven:architectury-api-419699:5137938") compileOnly fg.deobf("mezz.jei:jei-1.20.1-common-api:15.3.0.4") compileOnly fg.deobf("mezz.jei:jei-1.20.1-forge-api:15.3.0.4") diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 41dfb8790..48c0a02ca 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/java/li/cil/oc2/client/ClientSetup.java b/src/main/java/li/cil/oc2/client/ClientSetup.java index b6a3c7d0d..77e0ca4f9 100644 --- a/src/main/java/li/cil/oc2/client/ClientSetup.java +++ b/src/main/java/li/cil/oc2/client/ClientSetup.java @@ -42,6 +42,7 @@ public final class ClientSetup { private static final Set sprites = new HashSet(); + private static boolean readyForSprites = false; @SubscribeEvent public static void handleSetupEvent(final FMLClientSetupEvent event) { @@ -67,16 +68,6 @@ public static void handleSetupEvent(final FMLClientSetupEvent event) { // We need to register this manually, because static init throws errors when running data generation. MinecraftForge.EVENT_BUS.register(ProjectorDepthRenderer.class); - - for (final DeviceType deviceType : DeviceTypes.DEVICE_TYPE_REGISTRY.get().getValues()) { - sprites.add(deviceType.getBackgroundIcon()); - } - - sprites.add(ComputerRenderer.OVERLAY_POWER_LOCATION); - sprites.add(ComputerRenderer.OVERLAY_STATUS_LOCATION); - sprites.add(ComputerRenderer.OVERLAY_TERMINAL_LOCATION); - - sprites.add(ChargerRenderer.EFFECT_LOCATION); }); } @@ -94,13 +85,6 @@ public void renderHotbar(RenderGuiOverlayEvent event) { } } - @ApiStatus.Internal - public static void collectSprites(ResourceLocation atlas, Consumer spriteConsumer) { - if(!Objects.equals(atlas, InventoryMenu.BLOCK_ATLAS)) return; - - sprites.forEach(spriteConsumer); - } - @SubscribeEvent public static void handleEntityRendererRegisterEvent(final EntityRenderersEvent.RegisterRenderers event) { event.registerEntityRenderer(Entities.ROBOT.get(), RobotRenderer::new); diff --git a/src/main/java/li/cil/oc2/client/gui/AbstractMachineInventoryScreen.java b/src/main/java/li/cil/oc2/client/gui/AbstractMachineInventoryScreen.java index 5ab8c79cf..457435136 100644 --- a/src/main/java/li/cil/oc2/client/gui/AbstractMachineInventoryScreen.java +++ b/src/main/java/li/cil/oc2/client/gui/AbstractMachineInventoryScreen.java @@ -125,9 +125,9 @@ protected void renderBg(final GuiGraphics graphics, final float partialTicks, fi protected void renderFg(final GuiGraphics graphics, final float partialTicks, final int mouseX, final int mouseY) { super.renderFg(graphics, partialTicks, mouseX, mouseY); - GuiUtils.renderMissingDeviceInfoIcon(graphics, this, DeviceTypes.FLASH_MEMORY, Sprites.WARN_ICON); - GuiUtils.renderMissingDeviceInfoIcon(graphics, this, DeviceTypes.MEMORY, Sprites.WARN_ICON); - GuiUtils.renderMissingDeviceInfoIcon(graphics, this, DeviceTypes.HARD_DRIVE, Sprites.INFO_ICON); + //GuiUtils.renderMissingDeviceInfoIcon(graphics, this, DeviceTypes.FLASH_MEMORY, Sprites.WARN_ICON); + //GuiUtils.renderMissingDeviceInfoIcon(graphics, this, DeviceTypes.MEMORY, Sprites.WARN_ICON); + //GuiUtils.renderMissingDeviceInfoIcon(graphics, this, DeviceTypes.HARD_DRIVE, Sprites.INFO_ICON); if (shouldRenderEnergyBar()) { final int x = leftPos - Sprites.SIDEBAR_2.width + 4; diff --git a/src/main/java/li/cil/oc2/client/gui/AbstractModContainerScreen.java b/src/main/java/li/cil/oc2/client/gui/AbstractModContainerScreen.java index 868294251..937a44f5c 100644 --- a/src/main/java/li/cil/oc2/client/gui/AbstractModContainerScreen.java +++ b/src/main/java/li/cil/oc2/client/gui/AbstractModContainerScreen.java @@ -4,6 +4,7 @@ import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.PoseStack; +import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.AbstractWidget; import net.minecraft.client.gui.components.Renderable; @@ -54,7 +55,9 @@ protected void renderTooltip(final GuiGraphics graphics, final int mouseX, final for (final Renderable widget : renderables) { if (widget instanceof AbstractWidget abstractWidget) { - //abstractWidget.renderToolTip(stack, mouseX, mouseY); + if(abstractWidget.getTooltip() == null) continue; + System.out.println(abstractWidget.getTooltip()); + graphics.renderTooltip(Minecraft.getInstance().font, abstractWidget.getTooltip().toCharSequence(Minecraft.getInstance()), mouseX, mouseY); } } } diff --git a/src/main/java/li/cil/oc2/client/gui/MachineTerminalWidget.java b/src/main/java/li/cil/oc2/client/gui/MachineTerminalWidget.java index 57e7c1d6e..9fb001eb6 100644 --- a/src/main/java/li/cil/oc2/client/gui/MachineTerminalWidget.java +++ b/src/main/java/li/cil/oc2/client/gui/MachineTerminalWidget.java @@ -69,8 +69,8 @@ public void render(final GuiGraphics graphics, final int mouseX, final int mouse rendererView = terminal.getRenderer(); } - //final Matrix4f projectionMatrix = orthographic(0, parent.width, 0, parent.height, -10, 10f); - final Matrix4f projectionMatrix = new Matrix4f().ortho(0, parent.width, 0, parent.height, -10, 10f); + final Matrix4f projectionMatrix = orthographic(0, parent.width, 0, parent.height, -10, 10f); + //final Matrix4f projectionMatrix = new Matrix4f().ortho(0, parent.width, 0, parent.height, -10, 10f); rendererView.render(terminalStack, projectionMatrix); } else { final Font font = getClient().font; diff --git a/src/main/java/li/cil/oc2/client/gui/util/GuiUtils.java b/src/main/java/li/cil/oc2/client/gui/util/GuiUtils.java index 0c6406466..d060f3e80 100644 --- a/src/main/java/li/cil/oc2/client/gui/util/GuiUtils.java +++ b/src/main/java/li/cil/oc2/client/gui/util/GuiUtils.java @@ -38,12 +38,9 @@ public final class GuiUtils { /////////////////////////////////////////////////////////////////// public static void renderMissingDeviceInfoIcon(final GuiGraphics graphics, final AbstractContainerScreen screen, final DeviceType type, final Sprite icon) { - graphics.pose().pushPose(); - graphics.pose().translate(0, 0, 100); - findFirstSlotOfTypeIfAllSlotsOfTypeEmpty(screen.getMenu(), type).ifPresent(slot -> icon.draw(graphics, + /*findFirstSlotOfTypeIfAllSlotsOfTypeEmpty(screen.getMenu(), type).ifPresent(slot -> icon.draw(graphics, screen.getGuiLeft() + slot.x - 1 + RELATIVE_ICON_POSITION, - screen.getGuiTop() + slot.y - 1 + RELATIVE_ICON_POSITION)); - graphics.pose().popPose(); + screen.getGuiTop() + slot.y - 1 + RELATIVE_ICON_POSITION));*/ } public static void renderMissingDeviceInfoTooltip(final GuiGraphics graphics, final AbstractContainerScreen screen, final int mouseX, final int mouseY, final DeviceType type) { diff --git a/src/main/java/li/cil/oc2/client/gui/widget/Sprite.java b/src/main/java/li/cil/oc2/client/gui/widget/Sprite.java index f2807e41f..d0a5be6b7 100644 --- a/src/main/java/li/cil/oc2/client/gui/widget/Sprite.java +++ b/src/main/java/li/cil/oc2/client/gui/widget/Sprite.java @@ -35,11 +35,11 @@ public void draw(final GuiGraphics graphics, final int x, final int y) { } public void draw(final GuiGraphics graphics, final int x, final int y, final int uOffset, final int vOffset) { - graphics.blit(texture.location, x, y, u0 + uOffset, v0 + vOffset, width, height); + graphics.blit(texture.location, x, y, u0 + uOffset, v0 + vOffset, width, height, texture.width, texture.height); } public void drawFillY(final GuiGraphics graphics, final int x, final int y, final float value) { final int h = (int) (this.height * Mth.clamp(value, 0, 1)); - graphics.blit(texture.location, x, y + (height - h), u0, v0 + (height - h), width, h); + graphics.blit(texture.location, x, y + (height - h), u0, v0 + (height - h), width, h, texture.width, texture.height); } } diff --git a/src/main/java/li/cil/oc2/common/bus/device/DeviceTypes.java b/src/main/java/li/cil/oc2/common/bus/device/DeviceTypes.java index 397b5009b..b64bd6d38 100644 --- a/src/main/java/li/cil/oc2/common/bus/device/DeviceTypes.java +++ b/src/main/java/li/cil/oc2/common/bus/device/DeviceTypes.java @@ -4,13 +4,19 @@ import li.cil.oc2.api.API; import li.cil.oc2.api.bus.device.DeviceType; +import li.cil.oc2.client.ClientSetup; import li.cil.oc2.common.bus.device.util.DeviceTypeImpl; import li.cil.oc2.common.tags.ItemTags; import li.cil.oc2.common.util.RegistryUtils; +import net.minecraft.client.Minecraft; import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.packs.repository.Pack; import net.minecraft.tags.TagKey; import net.minecraft.world.item.Item; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; +import net.minecraftforge.fml.loading.FMLEnvironment; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.IForgeRegistry; import net.minecraftforge.registries.RegistryBuilder; @@ -31,7 +37,6 @@ public final class DeviceTypes { public static void initialize() { DEVICE_TYPES.register(FMLJavaModLoadingContext.get().getModEventBus()); - register(ItemTags.DEVICES_MEMORY); register(ItemTags.DEVICES_HARD_DRIVE); register(ItemTags.DEVICES_FLASH_MEMORY); @@ -47,8 +52,10 @@ private static void register(final TagKey tag) { final String id = tag.location().getPath().replaceFirst("^devices/", ""); DEVICE_TYPES.register(id, () -> new DeviceTypeImpl( tag, - new ResourceLocation(API.MOD_ID, "gui/icon/" + id), + new ResourceLocation(API.MOD_ID, "item/" + id + "_slot"), text("gui.{mod}.device_type." + id) )); + + System.out.println("gui/icon/" + id); } } diff --git a/src/main/java/li/cil/oc2/common/mixin/AtlasAdder.java b/src/main/java/li/cil/oc2/common/mixin/AtlasAdder.java deleted file mode 100644 index 2d48177c1..000000000 --- a/src/main/java/li/cil/oc2/common/mixin/AtlasAdder.java +++ /dev/null @@ -1,27 +0,0 @@ -package li.cil.oc2.common.mixin; - -import li.cil.oc2.client.ClientSetup; -import net.minecraft.client.renderer.texture.atlas.SpriteResourceLoader; -import net.minecraft.client.renderer.texture.atlas.SpriteSource; -import net.minecraft.client.renderer.texture.atlas.sources.SingleFile; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.server.packs.resources.ResourceManager; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.ModifyVariable; - -import java.util.List; -import java.util.Optional; - -@Mixin(SpriteResourceLoader.class) -public class AtlasAdder { - @ModifyVariable( - method = "load(Lnet/minecraft/server/packs/resources/ResourceManager;Lnet/minecraft/resources/ResourceLocation;)Lnet/minecraft/client/renderer/texture/atlas/SpriteResourceLoader;", - at = @At("STORE"), - ordinal = 0 - ) - private static List appendSprites(List sprites, ResourceManager resourceManager, ResourceLocation atlas){ - ClientSetup.collectSprites(atlas, location -> sprites.add(new SingleFile(location, Optional.empty()))); - return sprites; - } -} diff --git a/src/main/java/li/cil/oc2/common/vm/Terminal.java b/src/main/java/li/cil/oc2/common/vm/Terminal.java index 59c036e38..5f6ac126c 100644 --- a/src/main/java/li/cil/oc2/common/vm/Terminal.java +++ b/src/main/java/li/cil/oc2/common/vm/Terminal.java @@ -818,10 +818,10 @@ private void validateLineCache() { BufferBuilder.RenderedBuffer rb = builder.end(); if (lines[row] == null) { - lines[row] = new VertexBuffer(VertexBuffer.Usage.STATIC); + lines[row] = new VertexBuffer(VertexBuffer.Usage.DYNAMIC); }else if (lines[row] != null) { lines[row].close(); - lines[row] = new VertexBuffer(VertexBuffer.Usage.STATIC); + lines[row] = new VertexBuffer(VertexBuffer.Usage.DYNAMIC); } if (!lines[row].isInvalid()){ diff --git a/src/main/resources/assets/oc2/textures/gui/icon/card.png b/src/main/resources/assets/oc2/textures/item/card_slot.png similarity index 100% rename from src/main/resources/assets/oc2/textures/gui/icon/card.png rename to src/main/resources/assets/oc2/textures/item/card_slot.png diff --git a/src/main/resources/assets/oc2/textures/gui/icon/flash_memory.png b/src/main/resources/assets/oc2/textures/item/flash_memory_slot.png similarity index 100% rename from src/main/resources/assets/oc2/textures/gui/icon/flash_memory.png rename to src/main/resources/assets/oc2/textures/item/flash_memory_slot.png diff --git a/src/main/resources/assets/oc2/textures/gui/icon/floppy.png b/src/main/resources/assets/oc2/textures/item/floppy_slot.png similarity index 100% rename from src/main/resources/assets/oc2/textures/gui/icon/floppy.png rename to src/main/resources/assets/oc2/textures/item/floppy_slot.png diff --git a/src/main/resources/assets/oc2/textures/gui/icon/hard_drive.png b/src/main/resources/assets/oc2/textures/item/hard_drive_slot.png similarity index 100% rename from src/main/resources/assets/oc2/textures/gui/icon/hard_drive.png rename to src/main/resources/assets/oc2/textures/item/hard_drive_slot.png diff --git a/src/main/resources/assets/oc2/textures/gui/icon/memory.png b/src/main/resources/assets/oc2/textures/item/memory_slot.png similarity index 100% rename from src/main/resources/assets/oc2/textures/gui/icon/memory.png rename to src/main/resources/assets/oc2/textures/item/memory_slot.png diff --git a/src/main/resources/assets/oc2/textures/gui/icon/network_tunnel.png b/src/main/resources/assets/oc2/textures/item/network_tunnel_slot.png similarity index 100% rename from src/main/resources/assets/oc2/textures/gui/icon/network_tunnel.png rename to src/main/resources/assets/oc2/textures/item/network_tunnel_slot.png diff --git a/src/main/resources/assets/oc2/textures/gui/icon/robot_module.png b/src/main/resources/assets/oc2/textures/item/robot_module_slot.png similarity index 100% rename from src/main/resources/assets/oc2/textures/gui/icon/robot_module.png rename to src/main/resources/assets/oc2/textures/item/robot_module_slot.png diff --git a/src/main/resources/mixins.oc2.json b/src/main/resources/mixins.oc2.json index d5bbf95bb..3e9d95416 100644 --- a/src/main/resources/mixins.oc2.json +++ b/src/main/resources/mixins.oc2.json @@ -10,8 +10,7 @@ "client": [ "FrustumMixin", "LevelRendererMixin", - "MinecraftMixin", - "AtlasAdder" + "MinecraftMixin" ], "injectors": { "defaultRequire": 1