From 4442131efb5ec09a27c246c34467bcaf76d195df Mon Sep 17 00:00:00 2001 From: Morphan1 Date: Fri, 13 Feb 2015 20:02:12 -0500 Subject: [PATCH] Allow Skull blocks to have their skin set correctly Oops, forgot this bit somehow --- .../aufdemrand/denizen/objects/dLocation.java | 21 +++++++++++++++---- .../properties/item/ItemSkullskin.java | 2 +- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/main/java/net/aufdemrand/denizen/objects/dLocation.java b/src/main/java/net/aufdemrand/denizen/objects/dLocation.java index 9e0bbd25dc..82f43c2815 100644 --- a/src/main/java/net/aufdemrand/denizen/objects/dLocation.java +++ b/src/main/java/net/aufdemrand/denizen/objects/dLocation.java @@ -3,6 +3,7 @@ import com.google.common.collect.Iterables; import com.mojang.authlib.GameProfile; import net.aufdemrand.denizen.Settings; +import net.aufdemrand.denizen.objects.properties.item.ItemSkullskin; import net.aufdemrand.denizen.utilities.entity.DenizenEntityType; import net.aufdemrand.denizencore.objects.*; import net.aufdemrand.denizencore.objects.notable.Notable; @@ -1608,10 +1609,22 @@ && getBlock().getState() instanceof CreatureSpawner) { // // --> if (mechanism.matches("skull_skin") && getBlock().getState() instanceof Skull) { - Skull state = ((Skull)getBlock().getState()); - if (!state.setOwner(value.asString())) - dB.echoError("Failed to set skull_skin!"); - state.update(true); + dList list = mechanism.getValue().asType(dList.class); + String idString = list.get(0); + GameProfile profile; + if (idString.contains("-")) { + UUID uuid = UUID.fromString(idString); + profile = new GameProfile(uuid, null); + } + else { + profile = new GameProfile(null, idString); + } + profile = ItemSkullskin.fillGameProfile(profile); + if (list.size() > 1) { + profile.getProperties().put("textures", new com.mojang.authlib.properties.Property("value", list.get(1))); + } + ((TileEntitySkull) ((CraftWorld) getWorld()).getTileEntityAt(getBlockX(), getBlockY(), getBlockZ())) + .setGameProfile(profile); } // <--[mechanism] diff --git a/src/main/java/net/aufdemrand/denizen/objects/properties/item/ItemSkullskin.java b/src/main/java/net/aufdemrand/denizen/objects/properties/item/ItemSkullskin.java index 57be9836c0..f0986e7e64 100644 --- a/src/main/java/net/aufdemrand/denizen/objects/properties/item/ItemSkullskin.java +++ b/src/main/java/net/aufdemrand/denizen/objects/properties/item/ItemSkullskin.java @@ -162,7 +162,7 @@ public void adjust(Mechanism mechanism) { } - private static GameProfile fillGameProfile(GameProfile gameProfile) { + public static GameProfile fillGameProfile(GameProfile gameProfile) { if(gameProfile != null) { GameProfile gameProfile1 = null; if (gameProfile.getName() != null) {