} else {
return false;
}
}
CompoundMap nbtData = item.getNBTData();
if (nbtData == null) {
nbtData = new CompoundMap();
}
List<CompoundTag> enchantments = new ArrayList<CompoundTag>();
if (nbtData.get("ench") instanceof ListTag<?>) {
enchantments = new ArrayList<CompoundTag>(((ListTag<CompoundTag>) nbtData.get("ench")).getValue());
}
CompoundMap map = new CompoundMap();
map.put(new ShortTag("id", (short) enchantment.getId()));
map.put(new ShortTag("lvl", (short) powerLevel));
enchantments.add(new CompoundTag(null, map));
nbtData.put(new ListTag<CompoundTag>("ench", CompoundTag.class, enchantments));
item.setNBTData(nbtData);
return true;
}