Skip to content

Commit

Permalink
Fix cape setup
Browse files Browse the repository at this point in the history
1.9 restructured it slightly, making the existing reflection technique
not work properly.
  • Loading branch information
Pokechu22 committed Mar 6, 2016
1 parent 79328ae commit d9abace
Showing 1 changed file with 6 additions and 17 deletions.
23 changes: 6 additions & 17 deletions src/wdl/CapeHandler.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package wdl;

import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
Expand All @@ -17,6 +16,7 @@
import org.apache.logging.log4j.Logger;

import com.mojang.authlib.GameProfile;
import com.mojang.authlib.minecraft.MinecraftProfileTexture;

/**
* Handles giving players capes.
Expand Down Expand Up @@ -118,22 +118,11 @@ private static void setupPlayer(AbstractClientPlayer player) {

private static void setPlayerCape(NetworkPlayerInfo info,
ResourceLocation cape) throws Exception {
boolean foundBefore = false;
Field capeField = null;
for (Field f : info.getClass().getDeclaredFields()) {
if (f.getType().equals(ResourceLocation.class)) {
//We're looking for the second such field.
if (foundBefore) {
capeField = f;
break;
} else {
foundBefore = true;
}
}
}
if (capeField != null) {
capeField.setAccessible(true);
capeField.set(info, cape);
@SuppressWarnings("unchecked")
Map<MinecraftProfileTexture.Type, ResourceLocation> map = ReflectionUtils
.stealAndGetField(info, Map.class);
if (!map.containsKey(MinecraftProfileTexture.Type.CAPE)) {
map.put(MinecraftProfileTexture.Type.CAPE, cape);
}
}

Expand Down

0 comments on commit d9abace

Please sign in to comment.