Skip to content

Commit

Permalink
Merge pull request #40 from Oxeus/1.21-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
enjarai authored Jun 24, 2024
2 parents 5d343e4 + c74f97d commit d731860
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 59 deletions.
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
id 'fabric-loom' version '1.6-SNAPSHOT'
id 'fabric-loom' version '1.7-SNAPSHOT'
id 'maven-publish'
id 'me.fallenbreath.yamlang' version '1.2.1'
id 'me.fallenbreath.yamlang' version '1.3.1'
}

sourceCompatibility = JavaVersion.VERSION_21
Expand Down Expand Up @@ -53,7 +53,7 @@ version = "$version+$minecraft_version"
// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
tasks.withType(JavaCompile) {
tasks.withType(JavaCompile).configureEach {
options.encoding = "UTF-8"
}

Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ org.gradle.jvmargs=-Xmx1G

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

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

fabric_version=0.97.8+1.20.6
fabric_version=0.100.3+1.21
# https://modrinth.com/mod/modmenu/versions
modmenu_version=10.0.0-beta.1
modmenu_version=11.0.0
shared_resources_version=1.8.0
cicada_version=0.7.2+1.20.5-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.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
1 change: 0 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
pluginManagement {
repositories {
jcenter()
maven { url "https://maven.fabricmc.net/" }
maven { url "https://maven.enjarai.nl/mirrors"}
mavenCentral()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ public void registerConversations(ConversationManager conversationManager) {
}

public static Identifier id(String path) {
return new Identifier(MOD_ID, path);
return Identifier.of(MOD_ID, path);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public class FolderedResourcePackScreen extends PackScreen {

private PackListWidget originalAvailablePacks;
private PackListWidget customAvailablePacks;
private PackListWidget originalSelectedPackList;
private PackListWidget customSelectedPacks;
private TextFieldWidget searchField;

private Path currentFolder = ROOT_FOLDER;
Expand All @@ -71,42 +73,12 @@ public FolderedResourcePackScreen(Screen parent, ResourcePackManager packManager
protected void init() {
super.init();

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

findButton(DONE).ifPresent(btn -> {
btn.setX(width / 2 + 25);
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(width / 2 - 179, height - 26, 154, 20)
.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);

// Replacing the available pack list with our custom implementation
originalAvailablePacks = availablePackList;
addDrawableChild(customAvailablePacks = new PackListWidget(client, this,
originalAvailablePacks.getWidth(), originalAvailablePacks.getHeight(), availablePackList.title));
customAvailablePacks.setPosition(originalAvailablePacks.getX(), originalAvailablePacks.getY());
remove(originalAvailablePacks);
addDrawableChild(customAvailablePacks = new PackListWidget(client, this, 200, height, availablePackList.title));
customAvailablePacks.setPosition(width / 2 - 204, originalAvailablePacks.getY());
// Make the title of the available packs selector clickable to load all packs
((FolderedPackListWidget) customAvailablePacks).recursiveresources$setTitleClickable(AVAILABLE_PACKS_TITLE_HOVER, null, () -> {
for (ResourcePackEntry entry : Lists.reverse(List.copyOf(availablePackList.children()))) {
Expand All @@ -117,18 +89,52 @@ protected void init() {
});
availablePackList = customAvailablePacks;

originalSelectedPackList = selectedPackList;
remove(originalSelectedPackList);
addDrawableChild(customSelectedPacks = new PackListWidget(client, this,
selectedPackList.getWidth(), selectedPackList.getHeight(), selectedPackList.title));
customSelectedPacks.setPosition(selectedPackList.getX(), selectedPackList.getY());

// Also make the selected packs title clickable to unload them
((FolderedPackListWidget) selectedPackList).recursiveresources$setTitleClickable(SELECTED_PACKS_TITLE_HOVER, null, () -> {
for (ResourcePackEntry entry : List.copyOf(selectedPackList.children())) {
((FolderedPackListWidget) customSelectedPacks).recursiveresources$setTitleClickable(SELECTED_PACKS_TITLE_HOVER, null, () -> {
for (ResourcePackEntry entry : List.copyOf(customSelectedPacks.children())) {
if (entry.pack.canBeDisabled()) {
entry.pack.disable();
}
}
});

selectedPackList = customSelectedPacks;

findButton(DONE).ifPresent(btn -> {
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.setFilter(searchField.getText());
listProcessor.resumeCallback();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ public int sortEntry(PackListWidget.ResourcePackEntry entry, Path folder) {

public boolean containsEntry(PackListWidget.ResourcePackEntry entry, Path folder) {
Path pack;
Path packParent = EMPTY_PATH;

if (entry.pack.getSource() instanceof FolderedPackSource folderedPackSource) {
pack = folderedPackSource.file();
Expand All @@ -140,10 +141,10 @@ public boolean containsEntry(PackListWidget.ResourcePackEntry entry, Path folder
if (fsPath == null) return false;

pack = EMPTY_PATH.resolve(fsPath.getFileName());
packParent = fsPath.getParent() != null ? fsPath.getParent() : EMPTY_PATH;
}

Path relativePath = relativiseRelativePath(folder, pack);
Path packParent = pack.getParent() != null ? pack.getParent() : EMPTY_PATH;
return folder.equals(packParent) || packs().contains(relativePath);
return packs().contains(relativePath) || packParent.endsWith(folder);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ private static Identifier loadCustomIcon(Path icon, Path relativeFolder) {
// Ensure the path only contains "a-z0-9_.-" characters
relativePath = relativePath.toLowerCase().replaceAll("[^a-zA-Z0-9_.-]", "_");

Identifier id = new Identifier("recursiveresources", "textures/gui/custom_folders/" + relativePath + "icon.png");
Identifier id = RecursiveResources.id("textures/gui/custom_folders/" + relativePath + "/" + icon.getFileName());
MinecraftClient.getInstance().getTextureManager().registerTexture(id, new NativeImageBackedTexture(NativeImage.read(stream)));
return id;
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,17 @@ public void addPack(File fileOrFolder, Consumer<ResourcePackProfile> profileAdde

if (fileOrFolder.isDirectory()) {
info = ResourcePackProfile.create(
new ResourcePackInfo(name, Text.literal(displayName), ResourcePackSource.NONE, Optional.empty()),
new DirectoryResourcePack.DirectoryBackedFactory(fileOrFolder.toPath()),
ResourceType.CLIENT_RESOURCES,
new ResourcePackPosition(false, InsertionPosition.TOP, false)
new ResourcePackInfo(name, Text.literal(displayName), ResourcePackSource.NONE, Optional.empty()),
new DirectoryResourcePack.DirectoryBackedFactory(fileOrFolder.toPath()),
ResourceType.CLIENT_RESOURCES,
new ResourcePackPosition(false, InsertionPosition.TOP, false)
);
} else {
info = ResourcePackProfile.create(
new ResourcePackInfo(name, Text.literal(displayName), ResourcePackSource.NONE, Optional.empty()),
new ZipResourcePack.ZipBackedFactory(fileOrFolder),
ResourceType.CLIENT_RESOURCES,
new ResourcePackPosition(false, InsertionPosition.TOP, false)
new ResourcePackInfo(name, Text.literal(displayName), ResourcePackSource.NONE, Optional.empty()),
new ZipResourcePack.ZipBackedFactory(fileOrFolder),
ResourceType.CLIENT_RESOURCES,
new ResourcePackPosition(false, InsertionPosition.TOP, false)
);
}

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.20.5",
"minecraft": ">=1.21",
"fabric-api": "*",
"cicada": "*",
"fabricloader": ">=0.15"
Expand Down

0 comments on commit d731860

Please sign in to comment.