From 13b82966989b929f79ad412492008e512ca62103 Mon Sep 17 00:00:00 2001 From: Vasco Lavos Date: Fri, 5 Apr 2024 18:28:44 +0100 Subject: [PATCH] Add programmer art config --- dependencies.properties | 2 +- .../handler/QuarkProgrammerArtHandler.java | 43 +++++++++++++++++++ .../quark/base/config/QuarkGeneralConfig.java | 3 ++ .../quark/base/proxy/ClientProxy.java | 36 +--------------- 4 files changed, 49 insertions(+), 35 deletions(-) create mode 100644 src/main/java/org/violetmoon/quark/base/client/handler/QuarkProgrammerArtHandler.java diff --git a/dependencies.properties b/dependencies.properties index d0221c7109..5a94dcd812 100644 --- a/dependencies.properties +++ b/dependencies.properties @@ -1,5 +1,5 @@ forge=47.1.3 -zeta=1.0-14.70 +zeta=1.0-15.72 jei=4712868 terrablender=1.20.1-3.0.0.169 flan=4819286 diff --git a/src/main/java/org/violetmoon/quark/base/client/handler/QuarkProgrammerArtHandler.java b/src/main/java/org/violetmoon/quark/base/client/handler/QuarkProgrammerArtHandler.java new file mode 100644 index 0000000000..dca05e20c1 --- /dev/null +++ b/src/main/java/org/violetmoon/quark/base/client/handler/QuarkProgrammerArtHandler.java @@ -0,0 +1,43 @@ +package org.violetmoon.quark.base.client.handler; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; + +import org.violetmoon.quark.base.Quark; +import org.violetmoon.quark.base.config.QuarkGeneralConfig; +import org.violetmoon.zeta.client.event.load.ZClientSetup; +import org.violetmoon.zeta.event.bus.LoadEvent; + +public class QuarkProgrammerArtHandler { + + @LoadEvent + public static void onClientSetup(ZClientSetup event) { + if(QuarkGeneralConfig.generateProgrammerArt) + copyProgrammerArtIfMissing(); + } + + private static void copyProgrammerArtIfMissing() { + File dir = new File(".", "resourcepacks"); + File target = new File(dir, "Quark Programmer Art.zip"); + + if(!target.exists()) + try { + dir.mkdirs(); + InputStream in = Quark.class.getResourceAsStream("/assets/quark/programmer_art.zip"); + FileOutputStream out = new FileOutputStream(target); + + byte[] buf = new byte[16384]; + int len; + while((len = in.read(buf)) > 0) + out.write(buf, 0, len); + + in.close(); + out.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + +} diff --git a/src/main/java/org/violetmoon/quark/base/config/QuarkGeneralConfig.java b/src/main/java/org/violetmoon/quark/base/config/QuarkGeneralConfig.java index a8e8b4e28f..0769d4550c 100644 --- a/src/main/java/org/violetmoon/quark/base/config/QuarkGeneralConfig.java +++ b/src/main/java/org/violetmoon/quark/base/config/QuarkGeneralConfig.java @@ -93,6 +93,9 @@ public class QuarkGeneralConfig { @Config(description = "The amount of slots the chest button system should seek when trying to figure out if a container should be eligible for them.") public static int chestButtonSlotTarget = 27; + @Config(description = "Set this to false to not generate the Quark Programmer Art resource pack") + public static boolean generateProgrammerArt = true; + private QuarkGeneralConfig() { // NO-OP } diff --git a/src/main/java/org/violetmoon/quark/base/proxy/ClientProxy.java b/src/main/java/org/violetmoon/quark/base/proxy/ClientProxy.java index 2c858daac5..8f18bcf941 100644 --- a/src/main/java/org/violetmoon/quark/base/proxy/ClientProxy.java +++ b/src/main/java/org/violetmoon/quark/base/proxy/ClientProxy.java @@ -1,9 +1,5 @@ package org.violetmoon.quark.base.proxy; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; import java.time.LocalDateTime; import java.time.Month; @@ -15,20 +11,15 @@ import org.violetmoon.quark.base.client.handler.ClientUtil; import org.violetmoon.quark.base.client.handler.InventoryButtonHandler; import org.violetmoon.quark.base.client.handler.ModelHandler; +import org.violetmoon.quark.base.client.handler.QuarkProgrammerArtHandler; import org.violetmoon.quark.base.handler.ContributorRewardHandler; import org.violetmoon.quark.base.handler.WoodSetHandler; import org.violetmoon.quark.mixin.mixins.client.accessor.AccessorMultiPlayerGameMode; -import org.violetmoon.zeta.client.TopLayerTooltipHandler; -import org.violetmoon.zeta.event.load.ZConfigChanged; -import org.violetmoon.zeta.network.message.C2SUpdateFlag; -import org.violetmoon.zeta.util.handler.RequiredModTooltipHandler; -import net.minecraft.ChatFormatting; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.player.LocalPlayer; import net.minecraft.core.RegistryAccess; -import net.minecraft.network.chat.Component; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.Player; @@ -54,6 +45,7 @@ public void start() { .subscribe(ModelHandler.class) //TODO: Make this especially not a singleton, move it into respective modules .subscribe(ContributorRewardHandler.Client.class) .subscribe(WoodSetHandler.Client.class) + .subscribe(QuarkProgrammerArtHandler.class) .subscribe(ClientUtil.class); Quark.ZETA.playBus @@ -65,8 +57,6 @@ public void start() { super.start(); //<- loads and initializes modules ModLoadingContext.get().registerExtensionPoint(ConfigScreenFactory.class, () -> new ConfigScreenFactory((minecraft, screen) -> new QuarkConfigHomeScreen(screen))); - - copyProgrammerArtIfMissing(); } @Override @@ -99,26 +89,4 @@ public float getVisualTime() { return QuarkClient.ZETA_CLIENT.hackilyGetCurrentClientLevelRegistryAccess(); } - private static void copyProgrammerArtIfMissing() { - File dir = new File(".", "resourcepacks"); - File target = new File(dir, "Quark Programmer Art.zip"); - - if(!target.exists()) - try { - dir.mkdirs(); - InputStream in = Quark.class.getResourceAsStream("/assets/quark/programmer_art.zip"); - FileOutputStream out = new FileOutputStream(target); - - byte[] buf = new byte[16384]; - int len; - while((len = in.read(buf)) > 0) - out.write(buf, 0, len); - - in.close(); - out.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - }