Search in sources :

Example 1 with CompoundTag

use of com.denizenscript.denizen.nms.util.jnbt.CompoundTag in project Denizen-For-Bukkit by DenizenScript.

the class ItemFrameInvisible method isInvisible.

public boolean isInvisible() {
    CompoundTag compoundTag = NMSHandler.getItemHelper().getNbtData(item.getItemStack());
    if (compoundTag == null) {
        return false;
    }
    CompoundTag entTag = (CompoundTag) compoundTag.getValue().get("EntityTag");
    if (entTag == null) {
        return false;
    }
    byte b = entTag.getByte("Invisible");
    return b == 1;
}
Also used : CompoundTag(com.denizenscript.denizen.nms.util.jnbt.CompoundTag)

Example 2 with CompoundTag

use of com.denizenscript.denizen.nms.util.jnbt.CompoundTag in project Denizen-For-Bukkit by DenizenScript.

the class BlockHelperImpl method getNbtData.

@Override
public CompoundTag getNbtData(Block block) {
    BlockEntity te = ((CraftWorld) block.getWorld()).getHandle().getTileEntity(new BlockPos(block.getX(), block.getY(), block.getZ()), true);
    if (te != null) {
        net.minecraft.nbt.CompoundTag compound = new net.minecraft.nbt.CompoundTag();
        te.save(compound);
        return CompoundTagImpl.fromNMSTag(compound);
    }
    return null;
}
Also used : BlockPos(net.minecraft.core.BlockPos) CompoundTag(com.denizenscript.denizen.nms.util.jnbt.CompoundTag) BlockEntity(net.minecraft.world.level.block.entity.BlockEntity)

Example 3 with CompoundTag

use of com.denizenscript.denizen.nms.util.jnbt.CompoundTag in project Denizen-For-Bukkit by DenizenScript.

the class PacketHelperImpl method showBannerUpdate.

@Override
public void showBannerUpdate(Player player, Location location, DyeColor base, List<Pattern> patterns) {
    List<CompoundTag> nbtPatterns = new ArrayList<>();
    for (Pattern pattern : patterns) {
        nbtPatterns.add(NMSHandler.getInstance().createCompoundTag(new HashMap<>()).createBuilder().putInt("Color", pattern.getColor().getDyeData()).putString("Pattern", pattern.getPattern().getIdentifier()).build());
    }
    CompoundTag compoundTag = NMSHandler.getBlockHelper().getNbtData(location.getBlock()).createBuilder().put("Patterns", new JNBTListTag(CompoundTag.class, nbtPatterns)).build();
    showTileEntityData(player, location, 3, compoundTag);
}
Also used : Pattern(org.bukkit.block.banner.Pattern) JNBTListTag(com.denizenscript.denizen.nms.util.jnbt.JNBTListTag) CompoundTag(com.denizenscript.denizen.nms.util.jnbt.CompoundTag)

Example 4 with CompoundTag

use of com.denizenscript.denizen.nms.util.jnbt.CompoundTag in project Denizen-For-Bukkit by DenizenScript.

the class PacketHelperImpl method showBannerUpdate.

@Override
public void showBannerUpdate(Player player, Location location, DyeColor base, List<Pattern> patterns) {
    List<CompoundTag> nbtPatterns = new ArrayList<>();
    for (Pattern pattern : patterns) {
        nbtPatterns.add(NMSHandler.getInstance().createCompoundTag(new HashMap<>()).createBuilder().putInt("Color", pattern.getColor().getDyeData()).putString("Pattern", pattern.getPattern().getIdentifier()).build());
    }
    CompoundTag compoundTag = NMSHandler.getBlockHelper().getNbtData(location.getBlock()).createBuilder().put("Patterns", new JNBTListTag(CompoundTag.class, nbtPatterns)).build();
    showTileEntityData(player, location, 3, compoundTag);
}
Also used : Pattern(org.bukkit.block.banner.Pattern) JNBTListTag(com.denizenscript.denizen.nms.util.jnbt.JNBTListTag) CompoundTag(com.denizenscript.denizen.nms.util.jnbt.CompoundTag)

Example 5 with CompoundTag

use of com.denizenscript.denizen.nms.util.jnbt.CompoundTag in project Denizen-For-Bukkit by DenizenScript.

the class ItemScriptHelper method getItemScriptContainer.

public static ItemScriptContainer getItemScriptContainer(ItemStack item) {
    if (item == null) {
        return null;
    }
    CompoundTag tag = NMSHandler.getItemHelper().getNbtData(item);
    String scriptName = tag.getString("DenizenItemScript");
    if (scriptName != null && !scriptName.equals("")) {
        return item_scripts.get(scriptName);
    }
    // TODO: Legacy hashed format
    String nbt = tag.getString("Denizen Item Script");
    if (nbt != null && !nbt.equals("")) {
        return item_scripts_by_hash_id.get(nbt);
    }
    return null;
}
Also used : CompoundTag(com.denizenscript.denizen.nms.util.jnbt.CompoundTag)

Aggregations

CompoundTag (com.denizenscript.denizen.nms.util.jnbt.CompoundTag)7 JNBTListTag (com.denizenscript.denizen.nms.util.jnbt.JNBTListTag)3 Pattern (org.bukkit.block.banner.Pattern)3 ByteTag (com.denizenscript.denizen.nms.util.jnbt.ByteTag)1 Tag (com.denizenscript.denizen.nms.util.jnbt.Tag)1 ItemTag (com.denizenscript.denizen.objects.ItemTag)1 ObjectTag (com.denizenscript.denizencore.objects.ObjectTag)1 ElementTag (com.denizenscript.denizencore.objects.core.ElementTag)1 LinkedHashMap (java.util.LinkedHashMap)1 BlockPos (net.minecraft.core.BlockPos)1 BlockEntity (net.minecraft.world.level.block.entity.BlockEntity)1