diff --git a/build.gradle b/build.gradle index a018657f..99e814e0 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 41dfb879..48c0a02c 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 b6a3c7d0..77e0ca4f 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 @@ import java.util.function.Consumer; 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 final class ClientSetup { // 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 final class ClientSetup { } } - @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 5ab8c79c..45743513 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 @@ public abstract class AbstractMachineInventoryScreen 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 f2807e41..d0a5be6b 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 final class Sprite { } 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 397b5009..b64bd6d3 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 @@ package li.cil.oc2.common.bus.device; 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 @@ public final class DeviceTypes { 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 2d48177c..00000000 --- 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 59c036e3..5f6ac126 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 @@ public final class Terminal { 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 d5bbf95b..3e9d9541 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