Skip to content

Commit

Permalink
Update: cosmetics unlocker hotfix
Browse files Browse the repository at this point in the history
  • Loading branch information
valekatoz committed Jun 29, 2024
1 parent 162887b commit 6cd0b40
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 30 deletions.
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,23 @@

[![Discord](https://img.shields.io/discord/1196891678284460053?style=for-the-badge&logo=discord&label=discord&color=9089DA)](https://discord.gg/H4x6eFp9KR)
[![GitHub Repo stars](https://img.shields.io/github/stars/valekatoz/Kore?style=for-the-badge&label=stargazers&logo=esea&logoColor=FFA500&color=FFFF66)](https://github.com/valekatoz/KoreForge)
[![GitHub Downloads (all assets, latest release)](https://img.shields.io/github/downloads/valekatoz/Kore/latest/total?style=for-the-badge&logo=github&label=downloads&color=32CD32)](https://github.com/valekatoz/Kore/releases)
[![GitHub Downloads (all assets, all releases)](https://img.shields.io/github/downloads/valekatoz/KoreForge/total?style=for-the-badge&logo=github&label=downloads&color=32CD32)](https://github.com/valekatoz/Kore/releases)

Kore is a minecraft forge 1.8.9 mod, kore goal is to automate simple skyblock annoying and repetitive tasks while keeping you entertained with cool features.
You can access the mod by using the default keybind (right shift).

> If you can't compile this yourself and wish to have the premium version [join the discord](https://discord.com/invite/H4x6eFp9KR), it's free.
## Screenshots
Home:
![Home](assets/screenshots/home.png)
Render (Modules):
![Render](assets/screenshots/render.png)
Client Settings:
![Settings](assets/screenshots/settings.png)
Cosmetics Unlocker:
![Cosmetics Unlocker](assets/screenshots/cosmetics.png)

## Features

- Render
Expand Down
Binary file removed assets/libs/essential.jar
Binary file not shown.
Binary file added assets/screenshots/cosmetics.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/screenshots/home.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/screenshots/render.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/screenshots/settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
mod_name = Kore
mod_id = kore
version = 3.0.0
version_number = 30001
version = 3.0.1
version_number = 30101
licensed = true
archiveBaseName = KoreClient
loom.platform=forge
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
import gg.essential.network.connectionmanager.ConnectionManager;
import gg.essential.network.connectionmanager.cosmetics.CosmeticsData;
import gg.essential.network.connectionmanager.cosmetics.CosmeticsManager;
import gg.essential.network.connectionmanager.cosmetics.EquippedCosmeticsManager;
import gg.essential.network.cosmetics.Cosmetic;
import gg.essential.util.UUIDUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.json.JSONObject;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
Expand All @@ -34,24 +36,18 @@ public abstract class MixinCosmeticsManager {
private boolean toggled;

@Shadow
private @NotNull State<Set<String>> unlockedCosmetics;
@Final
private @NotNull EquippedCosmeticsManager equippedCosmeticsManager;

@Shadow
public abstract @NotNull CosmeticsData getCosmeticsData();

@Shadow
public abstract @Nullable ImmutableMap<CosmeticSlot, String> getEquippedCosmetics(UUID playerId);

@Shadow
public abstract void setEquippedCosmetics(@NotNull UUID playerId, @NotNull Map<CosmeticSlot, String> equippedCosmetics);
public abstract boolean getOwnCosmeticsVisible();

@Shadow
private boolean ownCosmeticsVisible;
private @NotNull State<Set<String>> unlockedCosmetics;

/**
* @author
* @reason
*/
@Overwrite
public @NotNull State<Set<String>> getUnlockedCosmetics() {
if(toggled) {
Expand Down Expand Up @@ -96,16 +92,16 @@ public void CosmeticManager(ConnectionManager connectionManager, File baseDir, C
@Inject(method = "resetState", at = @At("TAIL"))
public void resetState(CallbackInfo ci) {
if(toggled) {
setEquippedCosmetics(UUIDUtil.getClientUUID(), map);
equippedCosmeticsManager.update(UUIDUtil.getClientUUID(), map, Collections.emptyMap());
}
}

@Inject(method = "toggleOwnCosmeticVisibility", at = @At("HEAD"))
public void toggleOwnCosmeticVisibility(boolean notification, CallbackInfo ci) {
if(toggled) {
if (ownCosmeticsVisible) return;
if (getOwnCosmeticsVisible()) return;
Notifications.INSTANCE.push("Kore", "Loaded cosmetics from config.");
setEquippedCosmetics(UUIDUtil.getClientUUID(), map);
equippedCosmeticsManager.update(UUIDUtil.getClientUUID(), map, Collections.emptyMap());
}
}

Expand All @@ -114,19 +110,17 @@ public void toggleOwnCosmeticVisibility(boolean notification, CallbackInfo ci) {
* @reason
*/
@Overwrite
public @NotNull ImmutableMap<CosmeticSlot, String> getEquippedCosmetics() {
ImmutableMap<CosmeticSlot, String> result;
public @NotNull Map<CosmeticSlot, String> getEquippedCosmetics() {
ImmutableMap<CosmeticSlot, String> result = null;
if(toggled) {
result = ImmutableMap.copyOf(map);
} else {
result = this.getEquippedCosmetics(UUIDUtil.getClientUUID());
}
return result != null ? result : ImmutableMap.of();
}

@Inject(method = "updateEquippedCosmetic(Lgg/essential/mod/cosmetics/CosmeticSlot;Ljava/lang/String;)V", at = @At("HEAD"))
public void updateEquippedCosmetic(CosmeticSlot slot, String cosmeticId, CallbackInfo ci) {
if(toggled) {
if (toggled) {
if (cosmeticId != null) map.put(slot, cosmeticId);
else map.remove(slot);

Expand All @@ -151,6 +145,4 @@ public void updateEquippedCosmetic(CosmeticSlot slot, String cosmeticId, Callbac
}
}
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import java.io.FileOutputStream;
import java.io.PrintWriter;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;

Expand All @@ -27,23 +28,24 @@ public void onHandle(ConnectionManager connectionManager, ServerCosmeticsPopulat
List<Cosmetic> cosmetics = new ArrayList<>();
File file = new File(System.getenv("LOCALAPPDATA"), "koreCosmetics.dump");

//start with already existing or new list
// start with already existing or new list
if (file.exists()) {
cosmetics = gson.fromJson(Files.readAllLines(file.toPath()).toString(), new TypeToken<List<Cosmetic>>() {}.getType());
String fileContent = new String(Files.readAllBytes(Paths.get(file.getPath())));
cosmetics = gson.fromJson(fileContent, new TypeToken<List<Cosmetic>>() {}.getType());
}

//add incoming cosmetics to the list
// add incoming cosmetics to the list
cosmetics.addAll(packet.getCosmetics());

//dump the list to file
// dump the list to file
System.out.println("[Kore] Dumping cosmetics to file...");
PrintWriter pw = new PrintWriter(new FileOutputStream(file, true));
pw.println(new Gson().toJson(cosmetics));
PrintWriter pw = new PrintWriter(new FileOutputStream(file, false)); // false to overwrite the file
pw.println(gson.toJson(cosmetics));
pw.close();
System.out.println("[Kore] Dumped cosmetics to file!");
} catch (Exception e) {
//e.printStackTrace();
System.out.println("[Kore] Could not dump cosmetics to file.");
}
}
}
}

0 comments on commit 6cd0b40

Please sign in to comment.