use of com.denizenscript.denizen.nms.util.jnbt.CompoundTag in project Denizen-For-Bukkit by DenizenScript.
the class ItemFrameInvisible method adjust.
public void adjust(Mechanism mechanism) {
// -->
if (mechanism.matches("invisible") && mechanism.requireBoolean()) {
CompoundTag compoundTag = NMSHandler.getItemHelper().getNbtData(item.getItemStack());
Map<String, Tag> result = new LinkedHashMap<>(compoundTag.getValue());
CompoundTag entityTag = (CompoundTag) result.get("EntityTag");
Map<String, Tag> entMap;
if (entityTag != null) {
entMap = new LinkedHashMap<>(entityTag.getValue());
} else {
entMap = new LinkedHashMap<>();
}
if (mechanism.getValue().asBoolean()) {
entMap.put("Invisible", new ByteTag((byte) 1));
} else {
entMap.remove("Invisible");
}
if (entMap.isEmpty()) {
result.remove("EntityTag");
} else {
result.put("EntityTag", NMSHandler.getInstance().createCompoundTag(entMap));
}
compoundTag = NMSHandler.getInstance().createCompoundTag(result);
item.setItemStack(NMSHandler.getItemHelper().setNbtData(item.getItemStack(), 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);
}
Aggregations