Skip to content

Commit

Permalink
Fix spawn egg for 1.11+
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed May 12, 2017
1 parent 1703ac0 commit 477fad5
Showing 1 changed file with 7 additions and 3 deletions.
Expand Up @@ -7,6 +7,8 @@
import net.aufdemrand.denizencore.objects.properties.Property;
import net.aufdemrand.denizencore.tags.Attribute;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.inventory.meta.SpawnEggMeta;

public class ItemSpawnEgg implements Property {

Expand Down Expand Up @@ -49,7 +51,7 @@ public String getAttribute(Attribute attribute) {
// Also works for mob spawners.
// -->
if (attribute.startsWith("spawn_egg_entity")) {
return new Element(item.getItemStack().getDurability())
return new Element(((SpawnEggMeta) item.getItemStack().getItemMeta()).getSpawnedType().getTypeId())
.getAttribute(attribute.fulfill(1));
}

Expand All @@ -59,7 +61,7 @@ public String getAttribute(Attribute attribute) {

@Override
public String getPropertyString() {
return String.valueOf(item.getItemStack().getDurability());
return String.valueOf(((SpawnEggMeta) item.getItemStack().getItemMeta()).getSpawnedType().getTypeId());
}

@Override
Expand All @@ -82,7 +84,9 @@ public void adjust(Mechanism mechanism) {
// -->

if (mechanism.matches("spawn_egg")) {
item.getItemStack().setDurability((short) (mechanism.getValue().asInt()));
SpawnEggMeta sem = (SpawnEggMeta) item.getItemStack().getItemMeta();
sem.setSpawnedType(EntityType.fromId(mechanism.getValue().asInt()));
item.getItemStack().setItemMeta(sem);
}
}
}

0 comments on commit 477fad5

Please sign in to comment.