Search in sources :

Example 41 with org.bukkit.craftbukkit.v1_18_R1.block

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());
}
Also used : WoolCarpetBlock(net.minecraft.world.level.block.WoolCarpetBlock) WoolCarpetBlock(net.minecraft.world.level.block.WoolCarpetBlock) Block(net.minecraft.world.level.block.Block) CraftItemStack(org.bukkit.craftbukkit.v1_18_R1.inventory.CraftItemStack) ItemStack(net.minecraft.world.item.ItemStack)

Example 42 with org.bukkit.craftbukkit.v1_18_R1.block

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);
}
Also used : Item(net.minecraft.world.item.Item) ResourceLocation(net.minecraft.resources.ResourceLocation) Block(net.minecraft.world.level.block.Block) CraftItemStack(org.bukkit.craftbukkit.v1_18_R1.inventory.CraftItemStack) ItemStack(org.bukkit.inventory.ItemStack) CompoundTag(net.minecraft.nbt.CompoundTag)

Example 43 with org.bukkit.craftbukkit.v1_18_R1.block

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());
}
Also used : WoolCarpetBlock(net.minecraft.world.level.block.WoolCarpetBlock) WoolCarpetBlock(net.minecraft.world.level.block.WoolCarpetBlock) Block(net.minecraft.world.level.block.Block) CraftItemStack(org.bukkit.craftbukkit.v1_18_R1.inventory.CraftItemStack) ItemStack(net.minecraft.world.item.ItemStack)

Aggregations

Block (net.minecraft.server.v1_10_R1.Block)7 Block (net.minecraft.server.v1_11_R1.Block)7 Block (net.minecraft.server.v1_12_R1.Block)7 BlockPosition (net.minecraft.server.v1_10_R1.BlockPosition)6 BlockPosition (net.minecraft.server.v1_11_R1.BlockPosition)6 BlockPosition (net.minecraft.server.v1_12_R1.BlockPosition)6 Block (net.minecraft.server.v1_8_R3.Block)6 PathPoint (net.minecraft.server.v1_11_R1.PathPoint)4 BlockPosition (net.minecraft.server.v1_8_R3.BlockPosition)4 Block (net.minecraft.world.level.block.Block)4 ArrayList (java.util.ArrayList)3 MutableBlockPosition (net.minecraft.server.v1_10_R1.BlockPosition.MutableBlockPosition)3 PathPoint (net.minecraft.server.v1_10_R1.PathPoint)3 MutableBlockPosition (net.minecraft.server.v1_11_R1.BlockPosition.MutableBlockPosition)3 MutableBlockPosition (net.minecraft.server.v1_12_R1.BlockPosition.MutableBlockPosition)3 PathPoint (net.minecraft.server.v1_12_R1.PathPoint)3 PathPoint (net.minecraft.server.v1_8_R3.PathPoint)3 CraftItemStack (org.bukkit.craftbukkit.v1_18_R1.inventory.CraftItemStack)3 FallingBlock (org.bukkit.entity.FallingBlock)3 FakeBlock (com.denizenscript.denizen.utilities.blocks.FakeBlock)2