Skip to content

Commit

Permalink
Merge branch 'gui'
Browse files Browse the repository at this point in the history
  • Loading branch information
TimeBather committed Dec 2, 2024
2 parents 599c8b9 + 5609ddb commit a411153
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
5 changes: 5 additions & 0 deletions src/main/java/kasuga/lib/core/menu/base/BindingClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,9 @@ public static void closeInstance(UUID id){

}

public static void provideObject(UUID id, String key, Object value){
KasugaLib.STACKS.GUI.orElseThrow().getInstanceById(id).ifPresent((instance)->{
instance.putContextObject(key, value);
});
}
}
16 changes: 11 additions & 5 deletions src/main/java/kasuga/lib/core/menu/base/GuiMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.DistExecutor;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
import java.util.*;
import java.util.function.Supplier;

public class GuiMenu {
UUID id;
Expand All @@ -32,6 +30,7 @@ public class GuiMenu {
private boolean isGuiInstanceCreated = false;
private UUID serverId;
private boolean connectionFailure = false;
private HashMap<String, Supplier<Object>> providers = new HashMap<>();

protected GuiMenu(GuiMenuType<?> type) {
this.id = UUID.randomUUID();
Expand All @@ -50,8 +49,15 @@ protected void createGuiInstance(){
System.out.println("[Notice] GUI Instance Created");
isGuiInstanceCreated = true;
DistExecutor.unsafeRunWhenOn(Dist.CLIENT,
()->()-> BindingClient.createInstance(this,this.id,binding.sourceCodeLocation)
()->()-> {
BindingClient.createInstance(this,this.id,binding.sourceCodeLocation);
providers.forEach((key,value)->{
BindingClient.provideObject(this.id, key, value.get());
});
}
);


}

protected void closeGuiInstance(){
Expand Down

0 comments on commit a411153

Please sign in to comment.