Skip to content

Commit

Permalink
Merge pull request #44 from dxxxxy/hotfix-may-23
Browse files Browse the repository at this point in the history
Essential Mod v1.3.2.4 - May 23, 2024
  • Loading branch information
dxxxxy authored May 24, 2024
2 parents b9c2e10 + 115e835 commit b4d1b28
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 25 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# EssentialCosmeticsUnlocker
**Client-side only** patch that allows you to unlock ALL cosmetics (+ emotes) in the Essential mod. Works on every version of Essential MC (1.8.9 - 1.20.4).
**Client-side only** patch that allows you to unlock ALL cosmetics (+ emotes) in the Essential mod. Works on every version of Essential MC (1.8.9 - 1.20.6).

![](https://img.shields.io/badge/COMPATIBILITY-∞-0?style=for-the-badge)
![](https://img.shields.io/github/downloads/DxxxxY/EssentialCosmeticsUnlocker/total?style=for-the-badge)
Expand All @@ -11,25 +11,25 @@ Grab the .jar you need from the [Releases](https://github.com/DxxxxY/EssentialCo
- Efficient, single class and light-weight thanks to mixins.
- Unlock ALL cosmetics and emotes (including developer).
- Universally compatible with any version (view [Compatibility](#compatibility) table).
- Saves equipped cosmetics to config file located in your `LocalAppData`.
- Saves equipped cosmetics to config file located in `AppData/Roaming/ecu`.
- Loads equipped cosmetics from config file when you toggle the `Hide/Show My Cosmetics` button.
- Dumps cosmetic data in your `LocalAppData` (texture, geometry) when opening the game. Useful for those looking to replicate the cosmetics in their own projects.
- Dumps cosmetic data in `AppData/Roaming/ecu` (texture, geometry) when opening the game. Useful for those looking to replicate the cosmetics in their own projects.

## Compatibility
Feel free to contribute to this table with a PR and a convincing screenshot. Only the major versions are tested as it takes time to do it manually.

| MC Major Version | Forge | Fabric* | Last Checked (dd/mm/yyyy) |
|------------------|--------------|--------------------|---------------------------|
| 1.8 | `✔️ works`^ | `⬛ not applicable` | 27/04/2024 |
| 1.12 | `✔️ works`^️ | `⬛ not applicable` | 27/04/2024 |
| 1.8 | `✔️ works`^ | `⬛ not applicable` | 24/05/2024 |
| 1.12 | `✔️ works`^️ | `⬛ not applicable` | |
| | | | |
| 1.16 | `✔️ works` | `✔️ works` | |
| 1.17 | `✔️ works`| `✔️ works` | |
| 1.18 | `✔️ works`| `✔️ works` | |
| 1.19 | `✔️ works`| `✔️ works` | |
| 1.20 | `✔️ works` | `✔️ works` | 27/04/2024 |
| 1.20 | `✔️ works` | `✔️ works` | 24/05/2024 |

Last Essential version checked: **v1.3.1.3**
Last Essential version checked: **v1.3.2.4**

Tested with downloads from [essential website](https://essential.gg/downloads).

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ plugins {
apply plugin: "net.minecraftforge.gradle.forge"
apply plugin: "org.spongepowered.mixin"

version = "1.3.0"
version = "1.4.0"
group = "dreamys.studio.ecu" //http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "ecu" //name of the output jar

Expand Down
Binary file modified libs/essential.mock.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
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.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
Expand All @@ -28,13 +30,14 @@ public abstract class MixinCosmeticsManager {
public Map<CosmeticSlot, String> map = new HashMap<>();

@Shadow
public abstract @NotNull CosmeticsData getCosmeticsData();
@Final
private @NotNull EquippedCosmeticsManager equippedCosmeticsManager;

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

@Shadow
private boolean ownCosmeticsVisible;
public abstract boolean getOwnCosmeticsVisible();

@Overwrite
public @NotNull State<Set<String>> getUnlockedCosmetics() {
Expand All @@ -46,7 +49,12 @@ public void CosmeticManager(ConnectionManager connectionManager, File baseDir, C
//load config
try {
System.out.println("[EssentialCosmeticsUnlocker] Loading config");
Scanner sc = new Scanner(new File(System.getenv("LOCALAPPDATA"), "ecu.txt"));

//create if doesnt exist
File configFile = new File(new File(System.getenv("APPDATA"), "ecu"), "ecu.txt");
configFile.getParentFile().mkdirs();

Scanner sc = new Scanner(configFile);

while (sc.hasNextLine()) {
String[] line = sc.nextLine().split("=");
Expand All @@ -63,18 +71,18 @@ public void CosmeticManager(ConnectionManager connectionManager, File baseDir, C

@Inject(method = "resetState", at = @At("TAIL"))
public void resetState(CallbackInfo ci) {
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 (ownCosmeticsVisible) return;
if (getOwnCosmeticsVisible()) return;
Notifications.INSTANCE.push("EssentialCosmeticsUnlocker", "Loaded cosmetics from config.");
setEquippedCosmetics(UUIDUtil.getClientUUID(), map);
equippedCosmeticsManager.update(UUIDUtil.getClientUUID(), map, Collections.emptyMap());
}

@Overwrite
public @NotNull ImmutableMap<CosmeticSlot, String> getEquippedCosmetics() {
public @NotNull Map<CosmeticSlot, String> getEquippedCosmetics() {
ImmutableMap<CosmeticSlot, String> result = ImmutableMap.copyOf(map);
return result != null ? result : ImmutableMap.of();
}
Expand All @@ -87,7 +95,7 @@ public void updateEquippedCosmetic(CosmeticSlot slot, String cosmeticId, Callbac
//save config
try {
System.out.println("[EssentialCosmeticsUnlocker] Saving config");
PrintWriter pw = new PrintWriter(new File(System.getenv("LOCALAPPDATA"), "ecu.txt"));
PrintWriter pw = new PrintWriter(new File(new File(System.getenv("APPDATA"), "ecu"), "ecu.txt"));

for (Map.Entry<CosmeticSlot, String> entry : map.entrySet()) {
pw.println(entry.getKey().getId() + "=" + entry.getValue());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,21 @@ public void onHandle(ConnectionManager connectionManager, ServerCosmeticsPopulat
try {
Gson gson = new Gson();
List<Cosmetic> cosmetics = new ArrayList<>();
File file = new File(System.getenv("LOCALAPPDATA"), "ecu.dump.txt");
File dumpFile = new File(new File(System.getenv("APPDATA"), "ecu"), "dump.txt");
dumpFile.getParentFile().mkdirs();

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

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

//dump the list to file
System.out.println("[EssentialCosmeticsUnlocker] Dumping cosmetics to file...");
PrintWriter pw = new PrintWriter(new FileOutputStream(file, true));
PrintWriter pw = new PrintWriter(new FileOutputStream(dumpFile, true));
pw.println(new Gson().toJson(cosmetics));
pw.close();
System.out.println("[EssentialCosmeticsUnlocker] Dumped cosmetics to file!");
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"schemaVersion": 1,
"id": "ecu",
"version": "1.3.0",
"version": "1.4.0",
"name": "EssentialCosmeticsUnlocker",
"description": "Client-side only patch that allows you to unlock ALL cosmetics (+ emotes) in the Essential mod. Works on every version of Essential MC (1.8.9 - 1.20.4).",
"description": "Client-side only patch that allows you to unlock ALL cosmetics (+ emotes) in the Essential mod. Works on every version of Essential MC (1.8.9 - 1.20.6).",
"authors": ["dxxxxy"],
"license": "GPL-3.0",
"environment": "*",
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/modid.info
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[{
"modid": "ecu",
"name": "EssentialCosmeticsUnlocker",
"description": "Client-side only patch that allows you to unlock ALL cosmetics (+ emotes) in the Essential mod. Works on every version of Essential MC (1.8.9 - 1.20.4).",
"version": "1.3.0",
"description": "Client-side only patch that allows you to unlock ALL cosmetics (+ emotes) in the Essential mod. Works on every version of Essential MC (1.8.9 - 1.20.6).",
"version": "1.4.0",
"authorList": ["dxxxxy"],
}]

0 comments on commit b4d1b28

Please sign in to comment.