Skip to content

Commit

Permalink
fix: weird incompatibility issues
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelHillcox committed Apr 9, 2024
1 parent 79df17b commit a3f8c6f
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 31 deletions.
10 changes: 9 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,20 @@ subprojects {
dependencies {
minecraft "com.mojang:minecraft:${rootProject.minecraft_version}"
// The following line declares the mojmap mappings, you may use other mappings as well
mappings loom.officialMojangMappings()
mappings loom.layered() {
officialMojangMappings()
parchment("org.parchmentmc.data:parchment-1.20.1:2023.09.03@zip")
}
// The following line declares the yarn mappings you may select this one as well.
// mappings "net.fabricmc:yarn:1.19+build.4:v2"
}

repositories {
maven {
name = 'ParchmentMC'
url = 'https://maven.parchmentmc.org'
}

maven {
name = "Jared's maven"
url = "https://maven.blamejared.com/"
Expand Down
2 changes: 1 addition & 1 deletion common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ dependencies {
modCompileOnly("net.darkhax.tips:Tips-Forge-${minecraft_version}:${tips_version}")

modCompileOnly("curse.maven:creeperhost-minetogether-267172:5075809")
modCompileOnly("curse.maven:poly-576589:5199137")
modCompileOnly "net.creeperhost:polylib-fabric:2000.0.3-build.133"

modCompileOnlyApi("mezz.jei:jei-${minecraft_version}-common-api:${jei_version}")
modCompileOnlyApi("mezz.jei:jei-${minecraft_version}-gui:${jei_version}")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package dev.ftb.packcompanion.client.screen.pause.providers;

import com.mojang.blaze3d.systems.RenderSystem;
import dev.ftb.packcompanion.api.client.pause.AdditionalPauseProvider;
import dev.ftb.packcompanion.api.client.pause.AdditionalPauseTarget;
import dev.ftb.packcompanion.api.client.pause.ScreenHolder;
Expand All @@ -10,7 +9,6 @@
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.components.Tooltip;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import org.jetbrains.annotations.Nullable;
Expand All @@ -32,44 +30,71 @@ public class SupportPauseProvider implements AdditionalPauseProvider {

int xOffset = x;
if (!discordUrl.isEmpty()) {
screenWidgetCollection.addRenderableWidget(new IconButton(screen.unsafeScreenAccess(), xOffset, y, 20, 20, DISCORD_ICON, "ftbpackcompanion.tooltip.support_discord", button -> {
screenWidgetCollection.addRenderableWidget(new IconButton(xOffset, y, 20, 20, DISCORD_ICON, "ftbpackcompanion.tooltip.support_discord", button -> {
Util.getPlatform().openUri(discordUrl);
}));

xOffset += 24;
}

if (!githubUrl.isEmpty()) {
screenWidgetCollection.addRenderableWidget(new IconButton(screen.unsafeScreenAccess(), xOffset, y, 20, 20, GITHUB_ICON, "ftbpackcompanion.tooltip.support_github", button -> {
screenWidgetCollection.addRenderableWidget(new IconButton(xOffset, y, 20, 20, GITHUB_ICON, "ftbpackcompanion.tooltip.support_github", button -> {
Util.getPlatform().openUri(githubUrl);
}));
}

return screenWidgetCollection;
}

private static class IconButton extends Button {
public static class IconButton extends Button {
private final ResourceLocation icon;
private int textureSheetWidth = 16;
private int textureSheetHeight = 16;
private int uvx = 0;
private int uvy = 0;
private int textureWidth = 16;
private int textureHeight = 16;
private int hoverUVYOffset = 0;
private boolean hasBackground = true;

public IconButton(Screen screen, int i, int j, int k, int l, ResourceLocation icon, String langKey, OnPress onPress) {
super(i, j, k, l, Component.empty(), onPress, (c) -> Component.translatable(langKey));
public IconButton(int x, int y, int width, int height, ResourceLocation icon, String langKey, OnPress onPress) {
super(x, y, width, height, Component.empty(), onPress, (c) -> Component.translatable(langKey));
this.icon = icon;

this.setTooltip(Tooltip.create(Component.translatable(langKey)));
}

public IconButton(int x, int y, int width, int height, ResourceLocation icon, String langKey, OnPress onPress, int uvx, int uvy, int textureSheetWidth, int textureSheetHeight, int textureWidth, int textureHeight, int hoverUVYOffset, boolean hasBackground) {
super(x, y, width, height, Component.empty(), onPress, (c) -> Component.translatable(langKey));
this.icon = icon;

this.setTooltip(Tooltip.create(Component.translatable(langKey)));
this.uvx = uvx;
this.uvy = uvy;
this.textureSheetWidth = textureSheetWidth;
this.textureSheetHeight = textureSheetHeight;
this.hasBackground = hasBackground;
this.textureWidth = textureWidth;
this.textureHeight = textureHeight;
this.hoverUVYOffset = hoverUVYOffset;
}

@Override
public void renderWidget(GuiGraphics guiGraphics, int i, int j, float f) {
super.renderWidget(guiGraphics, i, j, f);

RenderSystem.setShaderTexture(0, icon);
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
var poseStack = guiGraphics.pose();
poseStack.pushPose();
poseStack.translate(this.getX() + 3, this.getY() + 3, 0);
poseStack.scale(.85f, .85f, 0);
guiGraphics.blit(icon, 0, 0, 0, 0, 16, 16, 16, 16);
poseStack.popPose();
if (hasBackground) {
poseStack.pushPose();
poseStack.translate(this.getX() + 3, this.getY() + 3, 0);
poseStack.scale(.85f, .85f, 0);
guiGraphics.blit(this.icon, 0, 0, uvx, uvy, textureWidth, textureHeight, textureSheetWidth, textureSheetHeight);
poseStack.popPose();
} else {
// ResourceLocation atlasLocation, int x, int y, int width, int height, float uOffset, float vOffset, int uWidth, int vHeight, int textureWidth, int textureHeight
var hoverOffset = this.isHovered() ? hoverUVYOffset : 0;
guiGraphics.blit(this.icon, this.getX(), this.getY(), uvx, uvy + hoverOffset, textureWidth, textureHeight, textureSheetWidth, textureSheetHeight);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,17 @@
import dev.ftb.packcompanion.api.client.pause.AdditionalPauseTarget;
import dev.ftb.packcompanion.api.client.pause.ScreenHolder;
import dev.ftb.packcompanion.api.client.pause.ScreenWidgetCollection;
import dev.ftb.packcompanion.client.screen.pause.providers.SupportPauseProvider;
import net.creeperhost.minetogether.Constants;
import net.creeperhost.minetogether.chat.gui.FriendChatGui;
import net.creeperhost.minetogether.chat.gui.PublicChatGui;
import net.creeperhost.minetogether.config.Config;
import net.creeperhost.minetogether.connect.ConnectHandler;
import net.creeperhost.minetogether.connect.gui.GuiShareToFriends;
import net.creeperhost.minetogether.gui.SettingGui;
import net.creeperhost.minetogether.polylib.gui.IconButton;
import net.creeperhost.polylib.client.modulargui.ModularGuiScreen;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.components.Tooltip;
import net.minecraft.client.gui.screens.PauseScreen;
import net.minecraft.client.server.IntegratedServer;
import net.minecraft.network.chat.Component;
Expand Down Expand Up @@ -44,20 +43,16 @@ public ScreenWidgetCollection init(AdditionalPauseTarget target, ScreenHolder sc
}

xOffset += 22;
IconButton settings = new IconButton(x - xOffset, y, 3, Constants.WIDGETS_SHEET, e -> Minecraft.getInstance().setScreen(new ModularGuiScreen(new SettingGui(), screen.unsafeScreenAccess())));
settings.setTooltip(Tooltip.create(Component.translatable("minetogether:gui.button.settings.info")));
collection.addRenderableWidget(settings);

xOffset += 22;
IconButton friendChat = new IconButton(x - xOffset, y, 7, Constants.WIDGETS_SHEET, e -> Minecraft.getInstance().setScreen(new ModularGuiScreen(new FriendChatGui(), screen.unsafeScreenAccess())));
friendChat.setTooltip(Tooltip.create(Component.translatable("minetogether:gui.button.friends.info")));
collection.addRenderableWidget(friendChat);
var newSettingsBtn = new SupportPauseProvider.IconButton(x - xOffset, y, 20, 20, Constants.WIDGETS_SHEET, "minetogether:gui.button.settings.info", e -> Minecraft.getInstance().setScreen(new ModularGuiScreen(new SettingGui(), screen.unsafeScreenAccess())), 60, 0, 256, 256, 20, 20, 20, false);
var newFriendChatBtn = new SupportPauseProvider.IconButton(x - xOffset - 22, y, 20, 20, Constants.WIDGETS_SHEET, "minetogether:gui.button.friends.info", e -> Minecraft.getInstance().setScreen(new ModularGuiScreen(new FriendChatGui(), screen.unsafeScreenAccess())), 140, 0, 256, 256, 20, 20, 20, false);

collection.addRenderableWidget(newSettingsBtn);
collection.addRenderableWidget(newFriendChatBtn);

if (Config.instance().chatEnabled) {
xOffset += 22;
IconButton publicChat = new IconButton(x - xOffset, y, 1, Constants.WIDGETS_SHEET, e -> Minecraft.getInstance().setScreen(new ModularGuiScreen(PublicChatGui.createGui(), screen.unsafeScreenAccess())));
publicChat.setTooltip(Tooltip.create(Component.translatable("minetogether:gui.button.global_chat.info")));
collection.addRenderableWidget(publicChat);
var newPublicChatBtn = new SupportPauseProvider.IconButton(x - xOffset - 44, y, 20, 20, Constants.WIDGETS_SHEET, "minetogether:gui.button.global_chat.info", e -> Minecraft.getInstance().setScreen(new ModularGuiScreen(PublicChatGui.createGui(), screen.unsafeScreenAccess())), 20, 0, 256, 256, 20, 20, 20, false);
collection.addRenderableWidget(newPublicChatBtn);
}

return collection;
Expand Down
2 changes: 1 addition & 1 deletion forge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ dependencies {
modRuntimeOnly("com.tterrag.registrate:Registrate:${registrate_version}")

modRuntimeOnly("curse.maven:creeperhost-minetogether-267172:5075809")
modRuntimeOnly("curse.maven:poly-576589:5199137")
modRuntimeOnly("curse.maven:poly-576589:5218944")

modCompileOnlyApi("mezz.jei:jei-${minecraft_version}-common-api:${jei_version}")
modCompileOnlyApi("mezz.jei:jei-${minecraft_version}-forge-api:${jei_version}")
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ enabled_platforms=fabric,forge

archives_base_name=ftb-pack-companion
# neo style version number
mod_version=20.1.0
mod_version=20.1.1
maven_group=dev.ftb.mods

architectury_version=9.2.14
Expand Down

0 comments on commit a3f8c6f

Please sign in to comment.