Skip to content

Commit

Permalink
reload world screen after closing browse page
Browse files Browse the repository at this point in the history
  • Loading branch information
DeDiamondPro committed Oct 3, 2024
1 parent 8de09d2 commit 53bd8b6
Show file tree
Hide file tree
Showing 12 changed files with 63 additions and 10 deletions.
2 changes: 1 addition & 1 deletion root.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ preprocess {
val fabric12006 = createNode("1.20.6-fabric", 12006, "yarn")
val fabric12101 = createNode("1.21.1-fabric", 12101, "yarn")

forge11202.link(forge10809)
forge11202.link(forge10809, file("versions/1.8.9-forge-1.12.2-forge"))
forge11602.link(forge11202, file("versions/1.12.2-forge-1.16.2-forge"))
forge11801.link(fabric11801)
forge11902.link(fabric11902)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* This file is part of Resourcify
* Copyright (C) 2024 DeDiamondPro
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License Version 3 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package dev.dediamondpro.resourcify.mixins;

import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.GuiSelectWorld;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;

@Mixin(GuiSelectWorld.class)
public interface WorldSelectionScreenAccessor {
@Accessor(
//#if MC >= 11202
//$$ "prevScreen"
//#else
"parentScreen"
//#endif
)
GuiScreen getParentScreen();
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import dev.dediamondpro.resourcify.elements.TextIcon
import dev.dediamondpro.resourcify.gui.ConfirmLinkScreen
import dev.dediamondpro.resourcify.gui.PaginatedScreen
import dev.dediamondpro.resourcify.gui.projectpage.components.MemberCard
import dev.dediamondpro.resourcify.mixins.WorldSelectionScreenAccessor
import dev.dediamondpro.resourcify.platform.Platform
import dev.dediamondpro.resourcify.services.IProject
import dev.dediamondpro.resourcify.services.IService
Expand All @@ -39,10 +40,10 @@ import gg.essential.elementa.dsl.*
import gg.essential.elementa.font.DefaultFonts
import gg.essential.universal.ChatColor
import gg.essential.universal.UDesktop
import net.minecraft.client.gui.GuiSelectWorld
import java.awt.Color
import java.io.File
import java.net.URI
import java.net.URL
import java.util.concurrent.CompletableFuture

class ProjectScreen(
Expand Down Expand Up @@ -327,4 +328,12 @@ class ProjectScreen(
}
}
}

override fun afterInitialization() {
// Required since world selection screen doesn't automatically update
if (type == ProjectType.WORLD) {
forwardScreens.replaceAll { if (it is GuiSelectWorld) GuiSelectWorld((it as WorldSelectionScreenAccessor).parentScreen) else it }
backScreens.replaceAll { if (it is GuiSelectWorld) GuiSelectWorld((it as WorldSelectionScreenAccessor).parentScreen) else it }
}
}
}
3 changes: 2 additions & 1 deletion src/main/resources/forge.mixins.resourcify.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"OptifineGuiShadersMixin",
"PackScreenAccessor",
"ReloadableResourceManagerMixin",
"AycyResourcePackManagerMixin"
"AycyResourcePackManagerMixin",
"WorldSelectionScreenAccessor"
]
}
3 changes: 2 additions & 1 deletion versions/1.12.2-forge-1.16.2-forge
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
net.minecraft.resources.IResourceManager net.minecraft.client.resources.IResourceManager
net.minecraft.resources.SimpleReloadableResourceManager net.minecraft.client.resources.SimpleReloadableResourceManager
net.minecraft.client.gui.screen.PackScreen net.minecraft.client.gui.GuiScreenResourcePacks
net.minecraft.client.gui.screen.Screen net.minecraft.client.gui.GuiScreen
net.minecraft.client.gui.screen.Screen net.minecraft.client.gui.GuiScreen
net.minecraft.client.gui.screen.WorldSelectionScreen net.minecraft.client.gui.GuiWorldSelection
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"OptifineGuiShadersAccessor",
"OptifineGuiShadersMixin",
"PackScreenAccessor",
"ReloadableResourceManagerMixin"
"ReloadableResourceManagerMixin",
"WorldSelectionScreenAccessor"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"client": [
"ScreenMixin",
"PackScreenAccessor",
"AbstractResourcePackAccessor"
"AbstractResourcePackAccessor",
"WorldSelectionScreenAccessor"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"client": [
"ScreenMixin",
"PackScreenAccessor",
"AbstractResourcePackAccessor"
"AbstractResourcePackAccessor",
"WorldSelectionScreenAccessor"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"ScreenMixin",
"PackScreenAccessor",
"AbstractResourcePackAccessor",
"ResourcePackOrganizerAccessor"
"ResourcePackOrganizerAccessor",
"WorldSelectionScreenAccessor"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"ScreenMixin",
"PackScreenAccessor",
"AbstractResourcePackAccessor",
"ResourcePackOrganizerAccessor"
"ResourcePackOrganizerAccessor",
"WorldSelectionScreenAccessor"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"ScreenMixin",
"PackScreenAccessor",
"AbstractResourcePackAccessor",
"ResourcePackOrganizerAccessor"
"ResourcePackOrganizerAccessor",
"WorldSelectionScreenAccessor"
]
}
1 change: 1 addition & 0 deletions versions/1.8.9-forge-1.12.2-forge
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
net.minecraft.client.gui.GuiWorldSelection net.minecraft.client.gui.GuiSelectWorld

0 comments on commit 53bd8b6

Please sign in to comment.