Skip to content

Commit 55e97e1

Browse files
committed
Removed wavey capes, fixes to cosmetic gui and handler and fix to a chat formatting issue
1 parent 8ddecfa commit 55e97e1

File tree

23 files changed

+60
-2569
lines changed

23 files changed

+60
-2569
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ mod_id = hysentials
99
mod_version = 1.3.2-beta1
1010
dev_version = 1.3.0-dev
1111

12-
dev = false
12+
dev = true
1313

1414
loom.platform = forge
1515

src/main/java/llc/redstone/hysentials/config/hysentialmods/CosmeticConfig.java

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,6 @@ public class CosmeticConfig extends Config {
2727
)
2828
public static boolean disableCustomCapes = false;
2929

30-
@Switch(
31-
name = "Wind Effect",
32-
category = "Comsetics",
33-
subcategory = "Capes",
34-
description = "Will give the capes a windy effect making it look like they are blowing in the wind."
35-
)
36-
public static boolean windEffect = true;
37-
38-
@Dropdown(
39-
name = "Cape Animation",
40-
category = "Comsetics",
41-
subcategory = "Capes",
42-
description = "Which animation the capes should render with.",
43-
options = {"Blocky Animation", "Silky Animation"}
44-
)
45-
public static int blockyCapes = 0;
46-
4730
public CosmeticConfig() {
4831
super(new Mod("Cosmetics", ModType.UTIL_QOL, "/assets/hysentials/mods/cosmetics.png", 244, 80), "hysentials-cosmetic.json");
4932
initialize();

src/main/java/llc/redstone/hysentials/cosmetics/capes/CapeHandler.java

Lines changed: 51 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,46 @@
11
package llc.redstone.hysentials.cosmetics.capes;
22

3+
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
4+
import com.mojang.authlib.properties.Property;
5+
import llc.redstone.hysentials.config.hysentialmods.CosmeticConfig;
36
import llc.redstone.hysentials.cosmetic.CosmeticManager;
47
import llc.redstone.hysentials.schema.HysentialsSchema;
58
import llc.redstone.hysentials.websocket.Socket;
69
import net.minecraft.client.Minecraft;
10+
import net.minecraft.client.network.NetworkPlayerInfo;
711
import net.minecraft.client.renderer.texture.DynamicTexture;
12+
import net.minecraft.client.resources.SkinManager;
813
import net.minecraft.util.ResourceLocation;
914
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
1015
import net.minecraftforge.fml.common.gameevent.TickEvent;
16+
import net.minecraftforge.fml.relauncher.ReflectionHelper;
1117

1218
import java.awt.image.BufferedImage;
1319
import java.io.InputStream;
20+
import java.lang.reflect.Field;
21+
import java.util.ArrayList;
1422
import java.util.HashMap;
23+
import java.util.List;
1524
import java.util.UUID;
1625

1726
public class CapeHandler {
1827
public static HashMap<UUID, Integer> tickMap = new HashMap<>();
19-
public static HashMap<UUID, DynamicTexture> textureMap = new HashMap<>();
20-
public static HashMap<UUID, String> resourceMap = new HashMap<>();
28+
public static HashMap<String, ResourceLocation> resourceList = new HashMap<>();
29+
30+
private Field capeLocationField;
31+
public CapeHandler() {
32+
try {
33+
capeLocationField = ReflectionHelper.findField(NetworkPlayerInfo.class, "locationCape", "field_178862_f");
34+
capeLocationField.setAccessible(true);
35+
} catch (Exception e) {
36+
e.printStackTrace();
37+
}
38+
39+
}
2140
@SubscribeEvent
2241
public void onTickEvent(TickEvent.ClientTickEvent event) {
2342
if (event.phase != TickEvent.Phase.END) return;
43+
if (CosmeticConfig.disableCustomCapes) return;
2444
try {
2545
for (String id : Socket.cachedUsers.keySet()) {
2646
UUID uuid = UUID.fromString(id);
@@ -31,7 +51,6 @@ public void onTickEvent(TickEvent.ClientTickEvent event) {
3151
String name = cosmetic.getName();
3252
if (CosmeticManager.hasCosmetic(uuid, name) || CosmeticManager.isPreviewing(uuid, name)) {
3353
ResourceLocation location = new ResourceLocation(cosmetic.getResource());
34-
resourceMap.put(uuid, cosmetic.getResource());
3554
try {
3655
InputStream stream = Minecraft.getMinecraft().mcDefaultResourcePack.getInputStream(location);
3756
if (stream == null) {
@@ -51,7 +70,19 @@ public void onTickEvent(TickEvent.ClientTickEvent event) {
5170
tickMap.put(uuid, tick);
5271
BufferedImage frameImage = image.getSubimage(0, frame * 32, 64, 32);
5372
DynamicTexture texture = new DynamicTexture(frameImage);
54-
textureMap.put(uuid, texture);
73+
String frameString = (frames > 1 ? "_" + frame : "");
74+
if (!resourceList.containsKey(name + frameString)) {
75+
resourceList.put(name + frameString, Minecraft.getMinecraft().getTextureManager().getDynamicTextureLocation(name + frameString, texture));
76+
}
77+
ResourceLocation capeResource = resourceList.get(name + frameString);
78+
if (Minecraft.getMinecraft().getNetHandler() == null || capeResource == null) return;
79+
80+
NetworkPlayerInfo info = Minecraft.getMinecraft().getNetHandler().getPlayerInfo(uuid);
81+
if (info != null) {
82+
ResourceLocation loc = (ResourceLocation) capeLocationField.get(info);
83+
capeLocationField.set(info, capeResource);
84+
}
85+
5586
stream.close();
5687
} catch (Exception e) {
5788
e.printStackTrace();
@@ -60,9 +91,22 @@ public void onTickEvent(TickEvent.ClientTickEvent event) {
6091
}
6192
}
6293
if (!wearingCape) {
63-
tickMap.remove(uuid);
64-
textureMap.remove(uuid);
65-
resourceMap.remove(uuid);
94+
NetworkPlayerInfo info = Minecraft.getMinecraft().getNetHandler().getPlayerInfo(uuid);
95+
if (tickMap.containsKey(uuid)) {
96+
tickMap.remove(uuid);
97+
if (info == null) return;
98+
Minecraft.getMinecraft().getSkinManager().loadProfileTextures(info.getGameProfile(), new SkinManager.SkinAvailableCallback() {
99+
public void skinAvailable(MinecraftProfileTexture.Type typeIn, ResourceLocation location, MinecraftProfileTexture profileTexture) {
100+
if (typeIn == MinecraftProfileTexture.Type.CAPE) {
101+
try {
102+
capeLocationField.set(info, location);
103+
} catch (Exception e) {
104+
e.printStackTrace();
105+
}
106+
}
107+
}
108+
}, true);
109+
}
66110
}
67111
}
68112
} catch (Exception e) {

src/main/java/llc/redstone/hysentials/cosmetics/capes/CapeHolder.java

Lines changed: 0 additions & 53 deletions
This file was deleted.

src/main/java/llc/redstone/hysentials/cosmetics/capes/CapeMovement.java

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/main/java/llc/redstone/hysentials/cosmetics/capes/CustomCapeRenderLayer.java

Lines changed: 0 additions & 182 deletions
This file was deleted.

0 commit comments

Comments
 (0)