bb_KPOJlUK
Пользователь
- Сообщения
- 79
Я не понимаю как это сделать. Выдача головы с custom texture игроку работает отлично. Но мне нужно, чтобы после установки головы на поверхность и ломания выпадали вещи и т.д. Но у меня не получается это сделать. Пытаюсь проверить предмет с помощью if (b.getType() == Material.PLAYER_HEAD && b.hasMetadata("head")), но предметы не выпадают. Помогите пожалуйста.
Код:
Код:
Код:
public class Commands implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String s, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage(color_tag("&4Только игроки могут использовать команду!"));
return true;
}
if (!(sender.isOp())) {
sender.sendMessage(color_tag("&4У вас нет прав на выполнение этой команды"));
return true;
}
Player player = (Player) sender;
if (command.getName().equalsIgnoreCase("luckyblock")) {
ItemStack head = new ItemStack(Material.PLAYER_HEAD, 1, (short) 3);
NBTItem nbti = new NBTItem(head);
NBTCompound disp = nbti.addCompound("display");
disp.setString("Name", "LuckyBlock");
List<String> l = disp.getStringList("Lore");
l.add("Some lore");
NBTCompound skull = nbti.addCompound("SkullOwner");
skull.setString("Name", "LuckyBlock");
skull.setString("Id", "fce0323d-7f50-4317-9720-5f6b14cf78ea");
NBTListCompound texture = skull.addCompound("Properties").getCompoundList("textures").addCompound();
texture.setString("Signature", "XpRfRz6/vXE6ip7/vq+40H6W70GFB0yjG6k8hG4pmFdnJFR+VQhslE0gXX/i0OAGThcAVSIT+/W1685wUxNofAiy+EhcxGNxNSJkYfOgXEVHTCuugpr+EQCUBI6muHDKms3PqY8ECxdbFTUEuWxdeiJsGt9VjHZMmUukkGhk0IobjQS3hjQ44FiT1tXuUU86oAxqjlKFpXG/iXtpcoXa33IObSI1S3gCKzVPOkMGlHZqRqKKElB54I2Qo4g5CJ+noudIDTzxPFwEEM6XrbM0YBi+SOdRvTbmrlkWF+ndzVWEINoEf++2hkO0gfeCqFqSMHuklMSgeNr/YtFZC5ShJRRv7zbyNF33jZ5DYNVR+KAK9iLO6prZhCVUkZxb1/BjOze6aN7kyN01u3nurKX6n3yQsoQQ0anDW6gNLKzO/mCvoCEvgecjaOQarktl/xYtD4YvdTTlnAlv2bfcXUtc++3UPIUbzf/jpf2g2wf6BGomzFteyPDu4USjBdpeWMBz9PxVzlVpDAtBYClFH/PFEQHMDtL5Q+VxUPu52XlzlUreMHpLT9EL92xwCAwVBBhrarQQWuLjAQXkp3oBdw6hlX6Fj0AafMJuGkFrYzcD7nNr61l9ErZmTWnqTxkJWZfZxmYBsFgV35SKc8rkRSHBNjcdKJZVN4GA+ZQH5B55mi4=");
texture.setString("Value", "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNzlkMWVmNGMxNTNiZGU4YTdiMDhmOTJjMGM0Yjc5ZmRjMmZjYjU3ZjgzYTMxYTgyMjljNjJhYzc1ZjFmMGEzMSJ9fX0=");
NBTCompoundList attribute = nbti.getCompoundList("AttributeModifiers");
NBTListCompound mod1 = attribute.addCompound();
mod1.setInteger("Operation", 0);
mod1.setInteger("UUIDLeast", 59664);
mod1.setInteger("UUIDMost", 31453);
nbti.setInteger("HideFlags", 4);
nbti.setBoolean("Unbreakable", true);
head = nbti.getItem();
NBTCompound itemData = NBTItem.convertItemtoNBT(head);
player.getInventory().setItemInMainHand(new ItemStack(head));
}
return false;
}
@EventHandler
public void onBlockBreak(BlockBreakEvent e) {
ItemStack head = new ItemStack(Material.PLAYER_HEAD, 1, (short) 3);
NBTItem nbti = new NBTItem(head);
NBTCompound disp = nbti.addCompound("display");
disp.setString("Name", "LuckyBlock");
List<String> l = disp.getStringList("Lore");
l.add("Some lore");
NBTCompound skull = nbti.addCompound("SkullOwner");
skull.setString("Name", "LuckyBlock");
skull.setString("Id", "fce0323d-7f50-4317-9720-5f6b14cf78ea");
NBTListCompound texture = skull.addCompound("Properties").getCompoundList("textures").addCompound();
texture.setString("Signature", "XpRfRz6/vXE6ip7/vq+40H6W70GFB0yjG6k8hG4pmFdnJFR+VQhslE0gXX/i0OAGThcAVSIT+/W1685wUxNofAiy+EhcxGNxNSJkYfOgXEVHTCuugpr+EQCUBI6muHDKms3PqY8ECxdbFTUEuWxdeiJsGt9VjHZMmUukkGhk0IobjQS3hjQ44FiT1tXuUU86oAxqjlKFpXG/iXtpcoXa33IObSI1S3gCKzVPOkMGlHZqRqKKElB54I2Qo4g5CJ+noudIDTzxPFwEEM6XrbM0YBi+SOdRvTbmrlkWF+ndzVWEINoEf++2hkO0gfeCqFqSMHuklMSgeNr/YtFZC5ShJRRv7zbyNF33jZ5DYNVR+KAK9iLO6prZhCVUkZxb1/BjOze6aN7kyN01u3nurKX6n3yQsoQQ0anDW6gNLKzO/mCvoCEvgecjaOQarktl/xYtD4YvdTTlnAlv2bfcXUtc++3UPIUbzf/jpf2g2wf6BGomzFteyPDu4USjBdpeWMBz9PxVzlVpDAtBYClFH/PFEQHMDtL5Q+VxUPu52XlzlUreMHpLT9EL92xwCAwVBBhrarQQWuLjAQXkp3oBdw6hlX6Fj0AafMJuGkFrYzcD7nNr61l9ErZmTWnqTxkJWZfZxmYBsFgV35SKc8rkRSHBNjcdKJZVN4GA+ZQH5B55mi4=");
texture.setString("Value", "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNzlkMWVmNGMxNTNiZGU4YTdiMDhmOTJjMGM0Yjc5ZmRjMmZjYjU3ZjgzYTMxYTgyMjljNjJhYzc1ZjFmMGEzMSJ9fX0=");
NBTCompoundList attribute = nbti.getCompoundList("AttributeModifiers");
NBTListCompound mod1 = attribute.addCompound();
mod1.setInteger("Operation", 0);
mod1.setInteger("UUIDLeast", 59664);
mod1.setInteger("UUIDMost", 31453);
nbti.setInteger("HideFlags", 4);
nbti.setBoolean("Unbreakable", true);
head = nbti.getItem();
NBTCompound itemData = NBTItem.convertItemtoNBT(head);
Block b = e.getBlock();
if (b.getType() != Material.PLAYER_HEAD && b.hasMetadata("head")) {
return;
}
if (b.getType() == Material.PLAYER_HEAD && b.hasMetadata("head")) {
Location location = e.getBlock().getLocation().add(0.5, 0, 0.5);
Player p = e.getPlayer();
e.setCancelled(true);
e.getBlock().setType(Material.AIR);
double chance_percent = 0;
int random = ThreadLocalRandom.current().nextInt(100);
switch (random) {
...