Skip to content

Commit

Permalink
Update to 1.20.2
Browse files Browse the repository at this point in the history
  • Loading branch information
IotaBread committed Oct 8, 2023
1 parent 6e7bba8 commit 0c9f90f
Show file tree
Hide file tree
Showing 21 changed files with 99 additions and 138 deletions.
13 changes: 4 additions & 9 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ plugins {
alias libs.plugins.fabric.loom
alias libs.plugins.minotaur
alias libs.plugins.cursegradle
alias libs.plugins.loom.quiltflower
id 'maven-publish'
}

Expand Down Expand Up @@ -79,18 +78,14 @@ jar {
}
}

quiltflower {
addToRuntimeClasspath.set(true)
}

modrinth {
token = project.hasProperty('modrinth_token') ? project.property('modrinth_token') : System.getenv('MODRINTH_TOKEN')
projectId = '1E2sq1cp'
versionNumber = project.version
versionName = "VTDownloader ${project.mod_version} for Minecraft 1.20.1"
versionName = "VTDownloader ${project.mod_version} for Minecraft 1.20.2"
uploadFile = remapJar
changelog = "A changelog can be found at https://github.com/IotaBread/VTDownloader/releases/tag/${project.mod_version}"
gameVersions = ['1.20.1']
gameVersions = ['1.20.2']
loaders = ['fabric', 'quilt']
}

Expand All @@ -102,11 +97,11 @@ curseforge {
id = '432425'
changelog = "A changelog can be found at https://github.com/IotaBread/VTDownloader/releases/tag/${project.mod_version}"
releaseType = 'release'
addGameVersion '1.20.1'
addGameVersion '1.20.2'
addGameVersion 'Fabric'
addGameVersion 'Quilt'
mainArtifact(remapJar) {
displayName = "VTDownloader ${project.mod_version} for Minecraft 1.20.1"
displayName = "VTDownloader ${project.mod_version} for Minecraft 1.20.2"
}
afterEvaluate {
uploadTask.dependsOn('remapJar')
Expand Down
13 changes: 6 additions & 7 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[versions]
minecraft = "1.20.1"
quilt_mappings = "1.20.1+build.9"
fabric_loader = "0.14.21"
minecraft = "1.20.2"
quilt_mappings = "1.20.2+build.3"
fabric_loader = "0.14.22"

fabric_api = "0.84.0+1.20.1"
fabric_api = "0.89.3+1.20.2"

# Other mods
recursive_resources = "2.5.1+1.20"
recursive_resources = "2.5.2+1.20"

[libraries]
minecraft = { module = "com.mojang:minecraft", version.ref = "minecraft" }
Expand All @@ -18,7 +18,6 @@ fabric_api = { module = "net.fabricmc.fabric-api:fabric-api", version.ref = "fab
recursive_resources = { module = "nl.enjarai:recursive-resources", version.ref = "recursive_resources" }

[plugins]
fabric_loom = { id = "fabric-loom", version = "1.1-SNAPSHOT" }
fabric_loom = { id = "fabric-loom", version = "1.4-SNAPSHOT" }
minotaur = { id = "com.modrinth.minotaur", version = "2.8.4" }
cursegradle = { id = "com.matthewprenger.cursegradle", version = "1.4.0" }
loom_quiltflower = { id = "io.github.juuxel.loom-quiltflower", version = "1.8.+" }
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
6 changes: 3 additions & 3 deletions src/main/java/me/bymartrixx/vtd/VTDMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
import net.minecraft.client.texture.NativeImageBackedTexture;
import net.minecraft.client.texture.TextureManager;
import net.minecraft.resource.ResourceIoSupplier;
import net.minecraft.resource.pack.PackProfile;
import net.minecraft.resource.pack.ResourcePack;
import net.minecraft.resource.pack.ResourcePackProfile;
import net.minecraft.util.Identifier;
import net.minecraft.util.Pair;
import org.apache.http.HttpResponse;
Expand Down Expand Up @@ -277,9 +277,9 @@ public static Identifier getIconId(Pack pack) {
return new Identifier(MOD_ID, pack.getId().toLowerCase(Locale.ROOT));
}

public static CompletableFuture<List<String>> readResourcePackData(ResourcePackProfile profile) {
public static CompletableFuture<List<String>> readResourcePackData(PackProfile profile) {
return CompletableFuture.supplyAsync(() -> {
try (ResourcePack resourcePack = profile.createResourcePack()) {
try (ResourcePack resourcePack = profile.createPack()) {
ResourceIoSupplier<InputStream> fileStream = resourcePack.openRoot(Constants.SELECTED_PACKS_FILE);
try (InputStream stream = fileStream != null ? fileStream.get() : null){
if (stream != null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package me.bymartrixx.vtd.access;

import net.minecraft.resource.pack.ResourcePackProfile;
import net.minecraft.resource.pack.PackProfile;

public interface AbstractPackAccess {
ResourcePackProfile vtdownloader$getProfile();
PackProfile vtdownloader$getProfile();
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import net.minecraft.client.gui.screen.pack.PackScreen;

public interface PackListWidgetAccess {
public interface PackEntryListWidgetAccess {
boolean vtdownloader$isAvailablePackList();

int vtdownloader$getItemHeight();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.WarningScreen;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.gui.widget.button.ButtonWidget;
import net.minecraft.text.CommonTexts;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
Expand All @@ -23,9 +23,9 @@ protected UnsavedPackWarningScreen(VTDownloadScreen parent, Screen next) {

@Override
protected void initButtons(int textHeight) {
this.addDrawableChild(ButtonWidget.builder(CommonTexts.PROCEED, button -> this.client.setScreen(this.next))
this.addDrawableSelectableElement(ButtonWidget.builder(CommonTexts.PROCEED, button -> this.client.setScreen(this.next))
.positionAndSize(this.width / 2 - 155, 100 + textHeight, 150, 20).build());
this.addDrawableChild(ButtonWidget.builder(CommonTexts.BACK, button -> this.client.setScreen(this.parent))
this.addDrawableSelectableElement(ButtonWidget.builder(CommonTexts.BACK, button -> this.client.setScreen(this.parent))
.positionAndSize(this.width / 2 - 155 + 160, 100 + textHeight, 150, 20).build());
}
}
32 changes: 16 additions & 16 deletions src/main/java/me/bymartrixx/vtd/gui/VTDownloadScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.pack.ResourcePackOrganizer;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.resource.pack.ResourcePackProfile;
import net.minecraft.client.gui.widget.button.ButtonWidget;
import net.minecraft.resource.pack.PackProfile;
import net.minecraft.text.CommonTexts;
import net.minecraft.text.Text;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -244,7 +244,7 @@ private void showSharePopup(String code) {
private void readResourcePack() {
// #AbstractPack and its inheritors are private
if (this.pack != null && this.pack.getClass().isNestmateOf(ResourcePackOrganizer.Pack.class)) {
ResourcePackProfile profile = ((AbstractPackAccess) this.pack).vtdownloader$getProfile();
PackProfile profile = ((AbstractPackAccess) this.pack).vtdownloader$getProfile();

VTDMod.readResourcePackData(profile).whenCompleteAsync((selection, throwable) -> {
if (throwable != null) {
Expand Down Expand Up @@ -314,57 +314,57 @@ protected void init() {
this.width - SELECTED_PACKS_WIDTH, this.selectionHelper));

// Reload button
this.addDrawableChild(new ReloadButtonWidget(WIDGET_MARGIN, WIDGET_MARGIN,
this.addDrawableSelectableElement(new ReloadButtonWidget(WIDGET_MARGIN, WIDGET_MARGIN,
Constants.RESOURCE_PACK_RELOAD_TEXT, button -> this.reloadCategories()));

if (DEBUG_BUTTON) this.addDrawableChild(new DebugButtonWidget(WIDGET_MARGIN * 2 + ReloadButtonWidget.BUTTON_SIZE,
if (DEBUG_BUTTON) this.addDrawableSelectableElement(new DebugButtonWidget(WIDGET_MARGIN * 2 + ReloadButtonWidget.BUTTON_SIZE,
WIDGET_MARGIN, PLACEHOLDER_TEXT, button -> {
if (this.debugPopup != null) this.debugPopup.show(DEBUG_MESSAGE_TIME, PLACEHOLDER_TEXT);
}));

this.categorySelector = this.addDrawableChild(new CategorySelectionWidget(this, CATEGORY_SELECTOR_Y));
this.categorySelector = this.addDrawableSelectableElement(new CategorySelectionWidget(this, CATEGORY_SELECTOR_Y));
this.categorySelector.init(this.categories, this.currentCategory);

ExpandDrawerButtonWidget expandButton = this.addDrawable(new ExpandDrawerButtonWidget(this.width - ExpandDrawerButtonWidget.TAB_WIDTH,
SELECTED_PACKS_TOP_HEIGHT + SELECTED_PACKS_BUTTON_Y,
SELECTED_PACKS_WIDTH, e -> this.toggleSelectedPacksListExtended()));

// Handle clicks before the pack selector
this.sharePopup = this.addSelectableChild(new MessageScreenPopup(this.client, this,
this.sharePopup = this.addSelectableElement(new MessageScreenPopup(this.client, this,
this.width / 2, this.height / 2,
this.width / 2, (int) (this.height / 1.5), SHARE_TEXT));
this.errorPopup = this.addSelectableChild(new MessageScreenPopup(this.client, this,
this.errorPopup = this.addSelectableElement(new MessageScreenPopup(this.client, this,
this.width / 2, this.height / 2,
this.width / 2, (int) (this.height / 1.5), Constants.ERROR_TEXT));
if (DEBUG_BUTTON) this.debugPopup = this.addSelectableChild(new MessageScreenPopup(this.client, this,
if (DEBUG_BUTTON) this.debugPopup = this.addSelectableElement(new MessageScreenPopup(this.client, this,
this.width / 2, this.height / 2,
this.width / 2, (int) (this.height / 1.5), PLACEHOLDER_TEXT));

this.addSelectableChild(expandButton);
this.addSelectableChild(this.packSelector);
this.addSelectableChild(this.selectedPacksList);
this.addSelectableElement(expandButton);
this.addSelectableElement(this.packSelector);
this.addSelectableElement(this.selectedPacksList);

this.shareButton = this.addDrawableChild(ButtonWidget.builder(SHARE_TEXT, button -> this.share())
this.shareButton = this.addDrawableSelectableElement(ButtonWidget.builder(SHARE_TEXT, button -> this.share())
.position(this.leftWidth + SELECTED_PACKS_CENTER_X - SHARE_BUTTON_CENTER_X,
this.height - SELECTED_PACKS_BOTTOM_HEIGHT + WIDGET_MARGIN)
.size(SHARE_BUTTON_WIDTH, WIDGET_HEIGHT)
.build());

// noinspection ConstantConditions
this.packNameField = this.addDrawableChild(new PackNameTextFieldWidget(this.textRenderer,
this.packNameField = this.addDrawableSelectableElement(new PackNameTextFieldWidget(this.textRenderer,
this.width - DONE_BUTTON_WIDTH - WIDGET_MARGIN * 2 - DOWNLOAD_BUTTON_WIDTH - WIDGET_MARGIN - PACK_NAME_FIELD_WIDTH,
this.height - WIDGET_HEIGHT - WIDGET_MARGIN, PACK_NAME_FIELD_WIDTH,
WIDGET_HEIGHT, this.getPackName(), PACK_NAME_FIELD_TEXT,
this.client.getResourcePackDir(), this.defaultPackName));
this.packNameField.setChangedListener(s -> this.updateButtons());
this.packName = null; // Pack name should only be used once

this.downloadButton = this.addDrawableChild(new MutableMessageButtonWidget(
this.downloadButton = this.addDrawableSelectableElement(new MutableMessageButtonWidget(
this.width - DONE_BUTTON_WIDTH - WIDGET_MARGIN * 2 - DOWNLOAD_BUTTON_WIDTH,
this.height - WIDGET_HEIGHT - WIDGET_MARGIN, DOWNLOAD_BUTTON_WIDTH, WIDGET_HEIGHT, DOWNLOAD_TEXT,
button -> this.download()));

this.doneButton = this.addDrawableChild(ButtonWidget.builder(CommonTexts.DONE, button -> this.closeScreen())
this.doneButton = this.addDrawableSelectableElement(ButtonWidget.builder(CommonTexts.DONE, button -> this.closeScreen())
.position(this.width - DONE_BUTTON_WIDTH - WIDGET_MARGIN, this.height - WIDGET_HEIGHT - WIDGET_MARGIN)
.size(DONE_BUTTON_WIDTH, WIDGET_HEIGHT)
.build());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,21 @@
import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder;
import net.minecraft.client.gui.screen.narration.NarrationPart;
import net.minecraft.client.gui.widget.ClickableWidget;
import net.minecraft.client.gui.widget.ClickableWidgetStateTextures;
import net.minecraft.client.sound.PositionedSoundInstance;
import net.minecraft.client.sound.SoundManager;
import net.minecraft.sound.SoundEvents;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import org.lwjgl.glfw.GLFW;

// Doesn't extend ButtonWidget to allow dynamic positioning
public class CategoryButtonWidget implements Element, Selectable {
private static final int TEXTURE_HEIGHT = 20;
private static final int TEXTURE_V_OFFSET = 46;
private static final ClickableWidgetStateTextures TEXTURES = new ClickableWidgetStateTextures(
new Identifier("widget/button"), new Identifier("widget/button_disabled"), new Identifier("widget/button_highlighted")
);

private final Category category;
private final int width;
Expand Down Expand Up @@ -49,15 +54,10 @@ public void renderButton(GuiGraphics graphics, int x, int y) {

graphics.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);

int buttonCenter = this.width / 2;

int yImage = getYImage(this.isHoveredOrFocused());
int v = TEXTURE_V_OFFSET + yImage * TEXTURE_HEIGHT;
graphics.drawTexture(ClickableWidget.WIDGETS_TEXTURE, x, y, 0, v, buttonCenter, this.height);
graphics.drawTexture(ClickableWidget.WIDGETS_TEXTURE, x + buttonCenter, y, 200 - buttonCenter, v, buttonCenter, this.height);
graphics.drawGuiTexture(TEXTURES.getTexture(!this.selected, this.isHoveredOrFocused()), x, y, this.width, this.height);

int textColor = this.selected ? 0xA0A0A0 : 0xFFFFFF;
graphics.drawCenteredShadowedText(textRenderer, this.text, x + buttonCenter, y + (this.height - 8) / 2, textColor);
graphics.drawCenteredShadowedText(textRenderer, this.text, x + this.width / 2, y + (this.height - 8) / 2, textColor);
}

@Override
Expand Down Expand Up @@ -131,17 +131,6 @@ private boolean isHoveredOrFocused() {
return this.hovered || this.focused;
}

private int getYImage(boolean hovered) {
int y = 1;
if (selected) {
y = 0;
} else if (hovered) {
y = 2;
}

return y;
}

public boolean isSelected() {
return this.selected;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,8 @@ public boolean mouseDragged(double mouseX, double mouseY, int button, double del

// Only called if isMouseOver is true; from Screen#mouseScrolled
@Override
public boolean mouseScrolled(double mouseX, double mouseY, double amount) {
public boolean mouseScrolled(double mouseX, double mouseY, double horizontalAmount, double verticalAmount) {
double amount = Math.abs(horizontalAmount) > Math.abs(verticalAmount) ? horizontalAmount : verticalAmount;
this.setScrollAmount(this.getScrollAmount() - amount * BUTTON_WIDTH / 2);
return true;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package me.bymartrixx.vtd.gui.widget;

import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.gui.widget.button.ButtonWidget;
import net.minecraft.text.Text;

public class MutableMessageButtonWidget extends ButtonWidget {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder;
import net.minecraft.client.gui.screen.narration.NarrationPart;
import net.minecraft.client.gui.widget.ClickableWidget;
import net.minecraft.client.gui.widget.EntryListWidget;
import net.minecraft.client.gui.widget.list.EntryListWidget;
import net.minecraft.client.sound.PositionedSoundInstance;
import net.minecraft.client.sound.SoundManager;
import net.minecraft.sound.SoundEvents;
Expand Down Expand Up @@ -598,9 +598,9 @@ public String toString() {
}

public abstract static class CategoryButtonEntry extends AbstractEntry {
protected static final int TEXTURE_V = 66;
protected static final int BUTTON_HEIGHT = 20;
protected static final int BUTTON_HORIZONTAL_PADDING = 32;
protected static final Identifier TEXTURE = new Identifier("widget/button");

protected final Category category;
protected final Text name;
Expand Down Expand Up @@ -633,9 +633,8 @@ public boolean mouseClicked(double mouseX, double mouseY, int button) {

@Override
public void render(GuiGraphics graphics, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
graphics.drawNineSlicedTexture(ClickableWidget.WIDGETS_TEXTURE,
x + BUTTON_HORIZONTAL_PADDING, y + (entryHeight - BUTTON_HEIGHT) / 2, entryWidth - BUTTON_HORIZONTAL_PADDING * 2, BUTTON_HEIGHT,
20, 4, 200, 20, 0, TEXTURE_V);
graphics.drawGuiTexture(TEXTURE,
x + BUTTON_HORIZONTAL_PADDING, y + (entryHeight - BUTTON_HEIGHT) / 2, entryWidth - BUTTON_HORIZONTAL_PADDING * 2, BUTTON_HEIGHT);
graphics.drawCenteredShadowedText(this.client.textRenderer, this.name, x + entryWidth / 2, y + (entryHeight - this.client.textRenderer.fontHeight) / 2, 0xFFFFFF);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.gui.widget.button.ButtonWidget;
import net.minecraft.text.Text;

public class ReloadButtonWidget extends ButtonWidget {
Expand Down
Loading

0 comments on commit 0c9f90f

Please sign in to comment.