use of org.bukkit.craftbukkit.v1_12_R1.Overridden in project Mohist by MohistMC.
the class CraftMetaItem method clone.
@Overridden
@Override
public CraftMetaItem clone() {
try {
CraftMetaItem clone = (CraftMetaItem) super.clone();
if (this.lore != null) {
clone.lore = new ArrayList<String>(this.lore);
}
clone.customModelData = this.customModelData;
clone.blockData = this.blockData;
if (this.enchantments != null) {
clone.enchantments = new LinkedHashMap<Enchantment, Integer>(this.enchantments);
}
if (this.hasAttributeModifiers()) {
clone.attributeModifiers = LinkedHashMultimap.create(this.attributeModifiers);
}
clone.persistentDataContainer = new CraftPersistentDataContainer(this.persistentDataContainer.getRaw(), DATA_TYPE_REGISTRY);
clone.hideFlag = this.hideFlag;
clone.unbreakable = this.unbreakable;
clone.damage = this.damage;
clone.version = this.version;
return clone;
} catch (CloneNotSupportedException e) {
throw new Error(e);
}
}
use of org.bukkit.craftbukkit.v1_12_R1.Overridden in project PaperDev by Kamillaova.
the class CraftMetaItem method serialize.
@Overridden
ImmutableMap.Builder<String, Object> serialize(ImmutableMap.Builder<String, Object> builder) {
if (hasDisplayName()) {
builder.put(NAME.BUKKIT, displayName);
}
if (hasLocalizedName()) {
builder.put(LOCNAME.BUKKIT, locName);
}
if (hasLore()) {
builder.put(LORE.BUKKIT, ImmutableList.copyOf(lore));
}
serializeEnchantments(enchantments, builder, ENCHANTMENTS);
if (hasRepairCost()) {
builder.put(REPAIR.BUKKIT, repairCost);
}
List<String> hideFlags = new ArrayList<String>();
for (ItemFlag hideFlagEnum : getItemFlags()) {
hideFlags.add(hideFlagEnum.name());
}
if (!hideFlags.isEmpty()) {
builder.put(HIDEFLAGS.BUKKIT, hideFlags);
}
if (isUnbreakable()) {
builder.put(UNBREAKABLE.BUKKIT, unbreakable);
}
final Map<String, NBTBase> internalTags = new HashMap<String, NBTBase>(unhandledTags);
serializeInternal(internalTags);
if (!internalTags.isEmpty()) {
NBTTagCompound internal = new NBTTagCompound();
for (Map.Entry<String, NBTBase> e : internalTags.entrySet()) {
internal.set(e.getKey(), e.getValue());
}
try {
ByteArrayOutputStream buf = new ByteArrayOutputStream();
NBTCompressedStreamTools.a(internal, buf);
builder.put("internal", Base64.encodeBase64String(buf.toByteArray()));
} catch (IOException ex) {
Logger.getLogger(CraftMetaItem.class.getName()).log(Level.SEVERE, null, ex);
}
}
return builder;
}
use of org.bukkit.craftbukkit.v1_12_R1.Overridden in project Magma-1.16.x by magmafoundation.
the class CraftMetaItem method applyToItem.
@Overridden
void applyToItem(CompoundNBT itemTag) {
if (hasDisplayName()) {
setDisplayTag(itemTag, NAME.NBT, StringNBT.valueOf(displayName));
}
if (hasLocalizedName()) {
setDisplayTag(itemTag, LOCNAME.NBT, StringNBT.valueOf(locName));
}
if (lore != null) {
setDisplayTag(itemTag, LORE.NBT, createStringList(lore));
}
if (hasCustomModelData()) {
itemTag.putInt(CUSTOM_MODEL_DATA.NBT, customModelData);
}
if (hasBlockData()) {
itemTag.put(BLOCK_DATA.NBT, blockData);
}
if (hideFlag != 0) {
itemTag.putInt(HIDEFLAGS.NBT, hideFlag);
}
applyEnchantments(enchantments, itemTag, ENCHANTMENTS);
applyModifiers(attributeModifiers, itemTag, ATTRIBUTES);
if (hasRepairCost()) {
itemTag.putInt(REPAIR.NBT, repairCost);
}
if (isUnbreakable()) {
itemTag.putBoolean(UNBREAKABLE.NBT, unbreakable);
}
if (hasDamage()) {
itemTag.putInt(DAMAGE.NBT, damage);
}
for (Map.Entry<String, INBT> e : unhandledTags.entrySet()) {
itemTag.put(e.getKey(), e.getValue());
}
if (!persistentDataContainer.isEmpty()) {
CompoundNBT bukkitCustomCompound = new CompoundNBT();
Map<String, INBT> rawPublicMap = persistentDataContainer.getRaw();
for (Map.Entry<String, INBT> nbtBaseEntry : rawPublicMap.entrySet()) {
bukkitCustomCompound.put(nbtBaseEntry.getKey(), nbtBaseEntry.getValue());
}
itemTag.put(BUKKIT_CUSTOM_TAG.NBT, bukkitCustomCompound);
}
}
use of org.bukkit.craftbukkit.v1_12_R1.Overridden in project Magma-1.16.x by magmafoundation.
the class CraftMetaItem method clone.
@Overridden
@Override
public CraftMetaItem clone() {
try {
CraftMetaItem clone = (CraftMetaItem) super.clone();
if (this.lore != null) {
clone.lore = new ArrayList<String>(this.lore);
}
clone.customModelData = this.customModelData;
clone.blockData = this.blockData;
if (this.enchantments != null) {
clone.enchantments = new LinkedHashMap<Enchantment, Integer>(this.enchantments);
}
if (this.hasAttributeModifiers()) {
clone.attributeModifiers = LinkedHashMultimap.create(this.attributeModifiers);
}
clone.persistentDataContainer = new CraftPersistentDataContainer(this.persistentDataContainer.getRaw(), DATA_TYPE_REGISTRY);
clone.hideFlag = this.hideFlag;
clone.unbreakable = this.unbreakable;
clone.damage = this.damage;
clone.version = this.version;
return clone;
} catch (CloneNotSupportedException e) {
throw new Error(e);
}
}
use of org.bukkit.craftbukkit.v1_12_R1.Overridden in project LoliServer by Loli-Server.
the class CraftMetaItem method applyToItem.
@Overridden
void applyToItem(CompoundNBT itemTag) {
if (hasDisplayName()) {
setDisplayTag(itemTag, NAME.NBT, StringNBT.valueOf(displayName));
}
if (hasLocalizedName()) {
setDisplayTag(itemTag, LOCNAME.NBT, StringNBT.valueOf(locName));
}
if (lore != null) {
setDisplayTag(itemTag, LORE.NBT, createStringList(lore));
}
if (hasCustomModelData()) {
itemTag.putInt(CUSTOM_MODEL_DATA.NBT, customModelData);
}
if (hasBlockData()) {
itemTag.put(BLOCK_DATA.NBT, blockData);
}
if (hideFlag != 0) {
itemTag.putInt(HIDEFLAGS.NBT, hideFlag);
}
applyEnchantments(enchantments, itemTag, ENCHANTMENTS);
applyModifiers(attributeModifiers, itemTag, ATTRIBUTES);
if (hasRepairCost()) {
itemTag.putInt(REPAIR.NBT, repairCost);
}
if (isUnbreakable()) {
itemTag.putBoolean(UNBREAKABLE.NBT, unbreakable);
}
if (hasDamage()) {
itemTag.putInt(DAMAGE.NBT, damage);
}
for (Map.Entry<String, INBT> e : unhandledTags.entrySet()) {
itemTag.put(e.getKey(), e.getValue());
}
if (!persistentDataContainer.isEmpty()) {
CompoundNBT bukkitCustomCompound = new CompoundNBT();
Map<String, INBT> rawPublicMap = persistentDataContainer.getRaw();
for (Map.Entry<String, INBT> nbtBaseEntry : rawPublicMap.entrySet()) {
bukkitCustomCompound.put(nbtBaseEntry.getKey(), nbtBaseEntry.getValue());
}
itemTag.put(BUKKIT_CUSTOM_TAG.NBT, bukkitCustomCompound);
}
}
Aggregations