use of org.bukkit.craftbukkit.v1_18_R1.block in project MyPet by xXKeyleXx.
the class EntityMyLlama method updateVisuals.
@Override
public void updateVisuals() {
this.getEntityData().set(CHEST_WATCHER, getMyPet().hasChest());
this.getEntityData().set(AGE_WATCHER, getMyPet().isBaby());
if (getMyPet().hasDecor()) {
ItemStack is = CraftItemStack.asNMSCopy(getMyPet().getDecor());
Block block = Block.byItem(is.getItem());
int color = block instanceof WoolCarpetBlock ? ((WoolCarpetBlock) block).getColor().getId() : 0;
this.getEntityData().set(COLOR_WATCHER, color);
} else {
this.getEntityData().set(COLOR_WATCHER, -1);
}
this.getEntityData().set(VARIANT_WATCHER, getMyPet().getVariant());
}
use of org.bukkit.craftbukkit.v1_18_R1.block in project MyPet by xXKeyleXx.
the class ConfigItem method load.
@Override
public void load(MaterialHolder material, String data) {
ResourceLocation key = new ResourceLocation(material.getId());
Item item = Registry.ITEM.get(key);
// TODO AIR now?
if (item == null) {
Block block = Registry.BLOCK.get(key);
item = block.asItem();
}
if (item == null) {
return;
}
net.minecraft.world.item.ItemStack is = new net.minecraft.world.item.ItemStack(item, 1);
if (data != null) {
CompoundTag tag = null;
String nbtString = data.trim();
if (nbtString.startsWith("{") && nbtString.endsWith("}")) {
try {
tag = TagParser.parseTag(nbtString);
} catch (Exception e) {
MyPetApi.getLogger().warning("Error" + ChatColor.RESET + " in config: " + ChatColor.UNDERLINE + e.getLocalizedMessage() + ChatColor.RESET + " caused by:");
MyPetApi.getLogger().warning(item.getDescriptionId() + " " + nbtString);
}
if (tag != null) {
is.setTag(tag);
}
}
}
this.item = CraftItemStack.asCraftMirror(is);
}
use of org.bukkit.craftbukkit.v1_18_R1.block in project MyPet by xXKeyleXx.
the class EntityMyTraderLlama method updateVisuals.
@Override
public void updateVisuals() {
this.getEntityData().set(CHEST_WATCHER, getMyPet().hasChest());
this.getEntityData().set(AGE_WATCHER, getMyPet().isBaby());
if (getMyPet().hasDecor()) {
ItemStack is = CraftItemStack.asNMSCopy(getMyPet().getDecor());
Block block = Block.byItem(is.getItem());
int color = block instanceof WoolCarpetBlock ? ((WoolCarpetBlock) block).getColor().getId() : 0;
this.getEntityData().set(COLOR_WATCHER, color);
} else {
this.getEntityData().set(COLOR_WATCHER, -1);
}
this.getEntityData().set(VARIANT_WATCHER, getMyPet().getVariant());
}
Aggregations