Skip to content

Commit

Permalink
Backported to 1.21.3
Browse files Browse the repository at this point in the history
  • Loading branch information
GrahamKracker committed Dec 22, 2024
1 parent 7e7020b commit 12fd40b
Show file tree
Hide file tree
Showing 18 changed files with 46 additions and 99 deletions.
6 changes: 5 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ group = project.maven_group
repositories {
// Add repositories to retrieve artifacts from in here.
// You should only use this when depending on other mods because
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
// Loom adds the essential maven repositories to download Minecraft and libraries from aut omatically.
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
// for more information about repositories.
flatDir {
Expand Down Expand Up @@ -132,6 +132,8 @@ repositories {
includeGroup "net.azureaaron"
}
}

maven { url = "https://pkgs.dev.azure.com/djtheredstoner/DevAuth/_packaging/public/maven/v1" }
}

dependencies {
Expand Down Expand Up @@ -194,6 +196,8 @@ dependencies {

// Apache Commons Text
include implementation("org.apache.commons:commons-text:${project.commons_text_version}")

modRuntimeOnly "me.djtheredstoner:DevAuth-fabric:1.2.1"
}

loom {
Expand Down
14 changes: 7 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
org.gradle.jvmargs=-Xmx1G -Dfile.encoding=UTF-8 -Duser.language=en -Duser.country=US
org.gradle.parallel=true

# Fabric Properties (https://fabricmc.net/versions.html)
## 1.21.4
minecraft_version=1.21.4
yarn_mappings=1.21.4+build.1
# Fabric Properties (https://fabricmc.net/versions.html)
## 1.21.3
minecraft_version=1.21.3
yarn_mappings=1.21.3+build.2
loader_version=0.16.9

#Fabric api
## 1.21.4
fabric_api_version=0.111.0+1.21.4
## 1.21.3
fabric_api_version=0.112.1+1.21.3

# Minecraft Mods
## YACL (https://github.com/isXander/YetAnotherConfigLib)
yacl_version=3.6.2+1.21.4
yacl_version=3.6.1+1.21.2
## HM API (https://github.com/AzureAaron/hm-api)
hm_api_version=1.0.1+1.21.2
## Mod Menu (https://modrinth.com/mod/modmenu/versions)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
@Mixin(InGameOverlayRenderer.class)
public class InGameOverlayRendererMixin {

@ModifyArg(method = "renderFireOverlay", index = 2, at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/VertexConsumer;vertex(Lorg/joml/Matrix4f;FFF)Lnet/minecraft/client/render/VertexConsumer;"))
@ModifyArg(method = "renderFireOverlay", index = 2, at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/BufferBuilder;vertex(Lorg/joml/Matrix4f;FFF)Lnet/minecraft/client/render/VertexConsumer;"))
private static float configureFlameHeight(float y) {
return y - (0.5f - ((float) SkyblockerConfigManager.get().uiAndVisuals.flameOverlay.flameHeight / 200.0f));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
import java.awt.Color;
import java.util.Set;

import net.minecraft.client.texture.PlayerSkinTexture;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
Expand All @@ -19,11 +22,13 @@
import de.hysky.skyblocker.utils.Utils;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.texture.NativeImage;
import net.minecraft.client.texture.PlayerSkinTextureDownloader;
import net.minecraft.util.math.ColorHelper;

@Mixin(PlayerSkinTextureDownloader.class)
public class PlayerSkinTextureDownloaderMixin {
@Mixin(PlayerSkinTexture.class)
public class PlayerSkinTextureMixin {
@Shadow
@Final
private String url;
@Unique
private static final Set<String> STRIP_DE_FACTO_TRANSPARENT_PIXELS = Set.of(
"4f3b91b6aa7124f30ed4ad1b2bb012a82985a33640555e18e792f96af8f58ec6", /*Titanium Necklace*/
Expand All @@ -33,9 +38,9 @@ public class PlayerSkinTextureDownloaderMixin {
private static final float BRIGHTNESS_THRESHOLD = 0.1f;

@Inject(method = "remapTexture", at = @At("HEAD"))
private static void skyblocker$determineSkinSource(NativeImage image, String uri, CallbackInfoReturnable<NativeImage> cir, @Share("isSkyblockSkinTexture") LocalBooleanRef isSkyblockSkinTexture) {
private void skyblocker$determineSkinSource(NativeImage image, CallbackInfoReturnable<NativeImage> cir, @Share("isSkyblockSkinTexture") LocalBooleanRef isSkyblockSkinTexture) {
if (SkyblockerConfigManager.get().uiAndVisuals.dontStripSkinAlphaValues && (Utils.isOnSkyblock() || MinecraftClient.getInstance().currentScreen instanceof ProfileViewerScreen)) {
String skinTextureHash = PlayerHeadHashCache.getSkinHash(uri);
String skinTextureHash = PlayerHeadHashCache.getSkinHash(this.url);
int skinHash = skinTextureHash.hashCode();
isSkyblockSkinTexture.set(PlayerHeadHashCache.contains(skinHash));

Expand All @@ -46,8 +51,8 @@ public class PlayerSkinTextureDownloaderMixin {
}
}

@WrapWithCondition(method = "remapTexture", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/texture/PlayerSkinTextureDownloader;stripAlpha(Lnet/minecraft/client/texture/NativeImage;IIII)V"))
private static boolean skyblocker$dontStripAlphaValues(NativeImage image, int x1, int y1, int x2, int y2, @Share("isSkyblockSkinTexture") LocalBooleanRef isSkyblockSkinTexture) {
@WrapWithCondition(method = "remapTexture", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/texture/PlayerSkinTexture;stripAlpha(Lnet/minecraft/client/texture/NativeImage;IIII)V"))
private boolean skyblocker$dontStripAlphaValues(NativeImage image, int x1, int y1, int x2, int y2, @Share("isSkyblockSkinTexture") LocalBooleanRef isSkyblockSkinTexture) {
return !isSkyblockSkinTexture.get();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public ChatRuleConfigEntry(int chatRuleIndex) {
.build();

deleteButton = ButtonWidget.builder(Text.translatable("selectServer.delete"), a -> {
oldScrollAmount = getScrollY();
oldScrollAmount = getScrollAmount();
client.setScreen(new ConfirmScreen(this::deleteEntry, Text.translatable("skyblocker.config.chat.chatRules.screen.deleteQuestion"), Text.translatable("skyblocker.config.chat.chatRules.screen.deleteWarning", chatRule.getName()), Text.translatable("selectServer.deleteButton"), ScreenTexts.CANCEL));
})
.size(50, 20)
Expand Down Expand Up @@ -155,7 +155,7 @@ private void deleteEntry(boolean confirmedAction) {
}

client.setScreen(screen);
setScrollY(oldScrollAmount);
setScrollAmount(oldScrollAmount);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,14 +280,4 @@ public List<? extends Element> children() {

@Override
protected void appendClickableNarrations(NarrationMessageBuilder builder) {}

@Override
protected int getContentsHeightWithPadding() {
return 0;
}

@Override
protected double getDeltaYPerScroll() {
return 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,16 @@ public class OptionDropdownWidget extends ElementListWidget<OptionDropdownWidget
private float animationProgress = 0f;

public OptionDropdownWidget(PartyFinderScreen screen, Text name, @Nullable Option selectedOption, int x, int y, int width, int height, int slotId) {
super(screen.getClient(), width, height, y, 15, 25);
super(screen.getClient(), width, height, y, 15);
this.screen = screen;
this.slotId = slotId;
setX(x);
this.name = name;
this.selectedOption = selectedOption;
}

private boolean clickedHeader(int x, int y) {
@Override
protected boolean clickedHeader(int x, int y) {
if (!(x >= 0 && y >= 10 && x < getWidth() && y < 26)) return false;
if (screen.isWaitingForServer()) return false;
if (isOpen) {
Expand Down Expand Up @@ -75,7 +76,7 @@ public boolean mouseClicked(double mouseX, double mouseY, int button) {

if (super.mouseClicked(mouseX, mouseY, button)) return true;

if (clickedHeader((int) (mouseX - (double) (this.getX() + this.width / 2 - this.getRowWidth() / 2)), (int) (mouseY - (double) this.getY()) + (int) this.getScrollY() - 4)) {
if (clickedHeader((int) (mouseX - (double) (this.getX() + this.width / 2 - this.getRowWidth() / 2)), (int) (mouseY - (double) this.getY()) + (int) this.getScrollAmount() - 4)) {
return true;
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public void renderWidget(DrawContext context, int mouseX, int mouseY, float delt
if (children().isEmpty()) {
Text string = Text.translatable("skyblocker.partyFinder.loadingError");
TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer;
context.drawWrappedText(textRenderer, string, getRowLeft(), getY() + 10, getRowWidth(), 0xFFFFFFFF, false);
context.drawTextWrapped(textRenderer, string, getRowLeft(), getY() + 10, getRowWidth(), 0xFFFFFFFF);
} else super.renderWidget(context, mouseX, mouseY, delta);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,14 +266,4 @@ public void setGood(boolean good) {

@Override
protected void appendClickableNarrations(NarrationMessageBuilder builder) {}

@Override
protected int getContentsHeightWithPadding() {
return 0;
}

@Override
protected double getDeltaYPerScroll() {
return 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,5 @@ public void setY(int y) {
super.setY(y);
textFieldWidget.setY(getY());
}

@Override
protected int getContentsHeightWithPadding() {
return 0;
}

@Override
protected double getDeltaYPerScroll() {
return 0;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -324,14 +324,4 @@ public void setOnChange(Consumer<Color> onChange) {
this.onChange = onChange;
}
}

@Override
protected int getContentsHeightWithPadding() {
return 0;
}

@Override
protected double getDeltaYPerScroll() {
return 0;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package de.hysky.skyblocker.skyblock.item;

import com.mojang.logging.LogUtils;
import de.hysky.skyblocker.annotations.Init;
import de.hysky.skyblocker.config.SkyblockerConfigManager;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
Expand All @@ -19,19 +20,20 @@ public static void init() {
GLFW.GLFW_KEY_H,
"key.categories.skyblocker"
));

}

public static boolean isLocked(int slot) {
return SkyblockerConfigManager.get().general.lockedSlots.contains(slot);
}

public static void handleInputEvents(ClientPlayerEntity player) {
while (hotbarSlotLock.wasPressed()) {
while (hotbarSlotLock.wasPressed()) {
List<Integer> lockedSlots = SkyblockerConfigManager.get().general.lockedSlots;
int selected = player.getInventory().selectedSlot;
if (!isLocked(player.getInventory().selectedSlot)) lockedSlots.add(selected);
else lockedSlots.remove(Integer.valueOf(selected));
SkyblockerConfigManager.save();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ protected void init() {
GridWidget.Adder adder = gridWidget.createAdder(2);
buttonDelete = ButtonWidget.builder(Text.translatable("selectServer.deleteButton"), button -> {
if (client != null && shortcutsConfigListWidget.getSelectedOrNull() instanceof ShortcutsConfigListWidget.ShortcutEntry shortcutEntry) {
scrollAmount = shortcutsConfigListWidget.getScrollY();
scrollAmount = shortcutsConfigListWidget.getScrollAmount();
client.setScreen(new ConfirmScreen(this::deleteEntry, Text.translatable("skyblocker.shortcuts.deleteQuestion"), Text.stringifiedTranslatable("skyblocker.shortcuts.deleteWarning", shortcutEntry), Text.translatable("selectServer.deleteButton"), ScreenTexts.CANCEL));
}
}).build();
Expand All @@ -74,7 +74,7 @@ private void deleteEntry(boolean confirmedAction) {
shortcutsConfigListWidget.removeEntry(shortcutEntry);
}
client.setScreen(this); // Re-inits the screen and keeps the old instance of ShortcutsConfigListWidget
shortcutsConfigListWidget.setScrollY(scrollAmount);
shortcutsConfigListWidget.setScrollAmount(scrollAmount);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public void renderWidget(DrawContext context, int mouseX, int mouseY, float delt
if (!children().isEmpty()) addEntry(SEPARATOR);
parent.getCustomWidgetEntries().forEach(this::addEntry);
}
setScrollY(getScrollY());
setScrollAmount(getScrollAmount());
}
super.renderWidget(context, mouseX, mouseY, delta);
WidgetsListEntry hoveredEntry = getHoveredEntry();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ public WidgetOptionsScrollable() {
}

@Override
protected int getContentsHeightWithPadding() {
protected int getContentsHeight() {
return height;
}

Expand All @@ -401,7 +401,7 @@ protected boolean isNotVisible(int i, int j) {
}

@Override
protected void renderWidget(DrawContext context, int mouseX, int mouseY, float delta) {
protected void renderContents(DrawContext context, int mouseX, int mouseY, float delta) {
height = 0;
for (ClickableWidget widget : widgets) {
widget.setX(getX() + 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,16 +111,6 @@ public boolean mouseClicked(double mouseX, double mouseY, int button) {
return super.mouseClicked(mouseX, mouseY, button);
}

@Override
protected int getContentsHeightWithPadding() {
return getHeight();
}

@Override
protected double getDeltaYPerScroll() {
return 0;
}

// container widget doesn't make it go to children anymore cuz WHY NOT
@Override
public boolean mouseScrolled(double mouseX, double mouseY, double horizontalAmount, double verticalAmount) {
Expand Down Expand Up @@ -152,27 +142,12 @@ public int getRowWidth() {
return getWidth() - 5; // 1 for scrollbar
}

// Custom scrollbar


@Override
protected void drawScrollbar(DrawContext context) {
if (this.overflows()) {
int i = this.getScrollbarX();
int j = this.getScrollbarThumbHeight();
int k = this.getScrollbarThumbY();
// Modified from DrawContext#drawVerticalLine
context.fill(i, k + 1, i + 2, k + j, -1);
}
}

@Override
protected int getScrollbarX() {
return getRowLeft() + getRowWidth();
}

// Visible

@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
if (!visible) return false;
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@
"accessWidener": "skyblocker.accesswidener",
"depends": {
"fabricloader": ">=0.16.9",
"fabric-api": ">=0.111.0+1.21.4",
"yet_another_config_lib_v3": ">=3.6.2+1.21.4",
"fabric-api": ">=0.106.1+1.21.3",
"yet_another_config_lib_v3": ">=3.6.1+1.21.2",
"hm-api": ">=1.0.1+1.21.2",
"minecraft": "~1.21.4",
"minecraft": "1.21.3",
"java": ">=21"
},
"conflicts": {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/skyblocker.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"PlayerInventoryMixin",
"PlayerListHudMixin",
"PlayerSkinProviderMixin",
"PlayerSkinTextureDownloaderMixin",
"PlayerSkinTextureMixin",
"RenderFishMixin",
"RenderLayerMultiPhaseMixin",
"RenderPhaseDepthTestMixin",
Expand Down

0 comments on commit 12fd40b

Please sign in to comment.