use of org.spongepowered.api.data.value.mutable.PatternListValue in project SpongeCommon by SpongePowered.
the class ShieldBannerDataProcessor method set.
@Override
public boolean set(ItemStack itemStack, Map<Key<?>, Object> keyValues) {
if (itemStack.getTagCompound() == null) {
itemStack.setTagCompound(new NBTTagCompound());
}
final NBTTagCompound tagCompound = ItemStackUtil.getTagCompound(itemStack);
final NBTTagCompound blockEntity = new NBTTagCompound();
final DyeColor baseColor = (DyeColor) keyValues.get(Keys.BANNER_BASE_COLOR);
final PatternListValue patternLayers = (PatternListValue) keyValues.get(Keys.BANNER_PATTERNS);
if (!patternLayers.isEmpty()) {
final NBTTagList patterns = new NBTTagList();
for (PatternLayer layer : patternLayers) {
NBTTagCompound compound = new NBTTagCompound();
compound.setString(NbtDataUtil.BANNER_PATTERN_ID, ((BannerPattern) (Object) layer.getShape()).getHashname());
compound.setInteger(NbtDataUtil.BANNER_PATTERN_COLOR, ((EnumDyeColor) (Object) layer.getColor()).getDyeDamage());
patterns.appendTag(compound);
}
blockEntity.setTag(NbtDataUtil.BANNER_PATTERNS, patterns);
}
blockEntity.setInteger(NbtDataUtil.BANNER_BASE, ((EnumDyeColor) (Object) baseColor).getDyeDamage());
tagCompound.setTag(NbtDataUtil.BLOCK_ENTITY_TAG, blockEntity);
return true;
}
Aggregations