use of org.bukkit.material.Skull in project Glowstone by GlowstoneMC.
the class BlockSkull method placeBlock.
@Override
public void placeBlock(GlowPlayer player, GlowBlockState state, BlockFace face, ItemStack holding, Vector clickedLoc) {
super.placeBlock(player, state, face, holding, clickedLoc);
MaterialData data = state.getData();
if (!(data instanceof Skull)) {
warnMaterialData(Skull.class, data);
return;
}
Skull skull = (Skull) data;
skull.setFacingDirection(face);
}
use of org.bukkit.material.Skull in project Glowstone by GlowstoneMC.
the class BlockSkull method afterPlace.
@Override
public void afterPlace(GlowPlayer player, GlowBlock block, ItemStack holding, GlowBlockState oldState) {
GlowSkull skull = (GlowSkull) block.getState();
skull.setSkullType(getType(holding.getDurability()));
if (skull.getSkullType() == SkullType.PLAYER) {
SkullMeta meta = (SkullMeta) holding.getItemMeta();
if (meta != null) {
skull.setOwner(meta.getOwner());
}
}
MaterialData data = skull.getData();
if (!(data instanceof Skull)) {
warnMaterialData(Skull.class, data);
return;
}
Skull skullData = (Skull) data;
if (canRotate(skullData)) {
// Can be rotated
skull.setRotation(player.getFacing().getOppositeFace());
}
skull.update();
// Wither
for (int i = 0; i < 3; i++) {
if (WITHER_PATTERN.matches(block.getLocation().clone(), true, i, 0)) {
block.getWorld().spawnEntity(block.getLocation().clone().subtract(0, 2, 0), EntityType.WITHER);
break;
}
}
}
Aggregations