Skip to content

Commit

Permalink
Merge pull request #52 from YoungSoulluoS/1.21.3-again
Browse files Browse the repository at this point in the history
1.21.3 & fixes
  • Loading branch information
enjarai authored Nov 17, 2024
2 parents ea08dba + dafdbf8 commit 9abbcba
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 44 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '1.7-SNAPSHOT'
id 'fabric-loom' version '1.8-SNAPSHOT'
id 'maven-publish'
id 'me.fallenbreath.yamlang' version '1.3.1'
id "me.modmuss50.mod-publish-plugin" version "0.4.4"
Expand Down
18 changes: 9 additions & 9 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@ org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://fabricmc.net/use
minecraft_version=1.21
yarn_mappings=1.21+build.2
loader_version=0.15.11
minecraft_version=1.21.3
yarn_mappings=1.21.3+build.2
loader_version=0.16.9

# Mod Properties
mod_version=2.5.3
mod_version=2.6.0
maven_group=nl.enjarai
archives_base_name=recursive-resources

publish_target_min=1.21
publish_target_max=1.21
publish_target_min=1.21.3
publish_target_max=1.21.3
mod_modrinth=CcL3MXyI
mod_curseforge=674907
mod_github=enjarai/recursive-resources
git_branch=master

fabric_version=0.100.3+1.21
fabric_version=0.107.3+1.21.3
# https://modrinth.com/mod/modmenu/versions
modmenu_version=11.0.0
modmenu_version=12.0.0-beta.1
shared_resources_version=1.8.0
cicada_version=0.8.0+1.21-and-above
cicada_version=0.9.1+1.21.2-and-above
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,24 @@ public FolderedResourcePackScreen(Screen parent, ResourcePackManager packManager

@Override
protected void init() {

addDrawableChild(
ButtonWidget.builder(folderView ? VIEW_FOLDER : VIEW_FLAT, btn -> {
folderView = !folderView;
btn.setMessage(folderView ? VIEW_FOLDER : VIEW_FLAT);

refresh();
customAvailablePacks.setScrollAmount(0.0);
})
.dimensions(ButtonWidget.DEFAULT_WIDTH, ButtonWidget.DEFAULT_HEIGHT, ButtonWidget.DEFAULT_WIDTH, ButtonWidget.DEFAULT_HEIGHT)
.build()
);

searchField = addDrawableChild(new TextFieldWidget(
textRenderer, width / 2 - 179, height - 46, 150, 18, searchField, Text.of("")));
searchField.setFocusUnlocked(true);
searchField.setChangedListener(listProcessor::setFilter);

super.init();

// Replacing the available pack list with our custom implementation
Expand All @@ -97,45 +115,60 @@ protected void init() {

// Also make the selected packs title clickable to unload them
((FolderedPackListWidget) customSelectedPacks).recursiveresources$setTitleClickable(SELECTED_PACKS_TITLE_HOVER, null, () -> {
for (ResourcePackEntry entry : List.copyOf(customSelectedPacks.children())) {
for (ResourcePackEntry entry : Lists.reverse(List.copyOf(customSelectedPacks.children()))) {
if ((this.currentFolderMeta.containsEntry(entry, this.currentFolder) || currentFolder.equals(ROOT_FOLDER)) && entry.pack.canBeDisabled()) {
entry.pack.disable();
}
}
});

selectedPackList = customSelectedPacks;

listProcessor.pauseCallback();
listProcessor.setSorter(currentSorter == null ? (currentSorter = ResourcePackListProcessor.sortAZ) : currentSorter);
listProcessor.setFilter(searchField.getText());
listProcessor.resumeCallback();

this.refreshWidgetPositions();
}

@Override
protected void refreshWidgetPositions() {
super.refreshWidgetPositions();

this.moveButtons();

this.availablePackList.setDimensions(200, layout.getContentHeight() - 20);
this.availablePackList.refreshScroll();
this.selectedPackList.setDimensions(200, layout.getContentHeight() - 20);
this.selectedPackList.refreshScroll();
}

public void moveButtons() {
findButton(OPEN_PACK_FOLDER).ifPresent(btn -> {
btn.setX(width / 2 + 35);
btn.setY(height - 48);
});

findButton(DONE).ifPresent(btn -> {
btn.setX(width / 2 + 35);
btn.setY(height - 26);
if (btn instanceof ButtonWidget button) {
button.onPress = btn2 -> applyAndClose();
}
});

/*
addDrawableChild(
ButtonWidget.builder(folderView ? VIEW_FOLDER : VIEW_FLAT, btn -> {
folderView = !folderView;
btn.setMessage(folderView ? VIEW_FOLDER : VIEW_FLAT);
refresh();
customAvailablePacks.setScrollAmount(0.0);
})
.dimensions(ButtonWidget.DEFAULT_WIDTH, ButtonWidget.DEFAULT_HEIGHT, ButtonWidget.DEFAULT_WIDTH, ButtonWidget.DEFAULT_WIDTH)
.build()
);
searchField = addDrawableChild(new TextFieldWidget(
textRenderer, width / 2 - 179, height - 46, 154, 16, searchField, Text.of("")));
searchField.setFocusUnlocked(true);
searchField.setChangedListener(listProcessor::setFilter);
addDrawableChild(searchField);
*/

listProcessor.pauseCallback();
listProcessor.setSorter(currentSorter == null ? (currentSorter = ResourcePackListProcessor.sortAZ) : currentSorter);
//listProcessor.setFilter(searchField.getText());
listProcessor.resumeCallback();

findButton(VIEW_FOLDER).ifPresent(btn -> {
btn.setX(width / 2 - 190);
btn.setY(height - 26);
});

findButton(VIEW_FLAT).ifPresent(btn -> {
btn.setX(width / 2 - 190);
btn.setY(height - 26);
});

searchField.setX((width / 2 - 190));
searchField.setY(height - 46);
}

private Optional<ClickableWidget> findButton(Text text) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package nl.enjarai.recursiveresources.gui;

import com.google.common.collect.Lists;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.pack.PackListWidget;
import net.minecraft.client.gui.screen.pack.PackListWidget.ResourcePackEntry;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import net.minecraft.util.Identifier;
Expand Down Expand Up @@ -84,7 +86,9 @@ public boolean mouseClicked(double mouseX, double mouseY, int button) {
return true;
}

ownerScreen.moveToFolder(this.isUp ? this.rootFolder : this.folder);
if (!this.widget.scrolling) {
ownerScreen.moveToFolder(this.isUp ? this.rootFolder : this.folder);
}
return true;
}

Expand All @@ -101,20 +105,20 @@ public void render(DrawContext context, int index, int y, int x, int entryWidth,

int relativeMouseX = mouseX - x;

context.drawTexture(WIDGETS_TEXTURE, x, y, getChildren().isEmpty() ? 32.0F : 0.0F, relativeMouseX < 32 ? 32.0F : 0.0F, 32, 32, 256, 256);
context.drawTexture(RenderLayer::getGuiTextured, WIDGETS_TEXTURE, x, y, getChildren().isEmpty() ? 32.0F : 0.0F, relativeMouseX < 32 ? 32.0F : 0.0F, 32, 32, 256, 256);
}
}

public void enableChildren() {
for (ResourcePackEntry entry : getChildren()) {
for (ResourcePackEntry entry : Lists.reverse(List.copyOf(getChildren()))) {
if (entry.pack.canBeEnabled()) {
entry.pack.enable();
}
}
}

public void disableChildren() {
for (ResourcePackEntry entry : List.copyOf(this.selectedList.children())) {
for (ResourcePackEntry entry : Lists.reverse(List.copyOf(this.selectedList.children()))) {
if (this.meta.containsEntry(entry, this.folder) && entry.pack.canBeDisabled()) {
entry.pack.disable();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package nl.enjarai.recursiveresources.mixin;

import com.llamalad7.mixinextras.injector.WrapWithCondition;
import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
import com.llamalad7.mixinextras.sugar.Share;
import com.llamalad7.mixinextras.sugar.ref.LocalIntRef;
import net.minecraft.client.MinecraftClient;
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"accessWidener": "recursiveresources.accesswidener",

"depends": {
"minecraft": ">=1.21",
"minecraft": ">=1.21.3",
"fabric-api": "*",
"cicada": ">=0.8.0 <1.0.0",
"fabricloader": ">=0.15"
Expand Down
5 changes: 5 additions & 0 deletions src/main/resources/recursiveresources.accesswidener
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ accessible field net/minecraft/client/gui/screen/pack/PackScreen selected

accessible field net/minecraft/client/gui/screen/Screen children Ljava/util/List;

accessible field net/minecraft/client/gui/screen/pack/PackScreen layout Lnet/minecraft/client/gui/widget/ThreePartsLayoutWidget;

accessible method net/minecraft/client/gui/screen/pack/PackScreen updatePackLists ()V
extendable method net/minecraft/client/gui/screen/pack/PackScreen updatePackLists ()V

Expand All @@ -30,5 +32,8 @@ accessible field net/minecraft/client/gui/screen/pack/ResourcePackOrganizer$

accessible field net/minecraft/resource/DirectoryResourcePack root Ljava/nio/file/Path;

# For scrolling fix
accessible field net/minecraft/client/gui/widget/EntryListWidget scrolling Z

# NEW!
accessible class net/minecraft/resource/ZipResourcePack$ZipFileWrapper

0 comments on commit 9abbcba

Please sign in to comment.