コード例 #1
0
 public static BannerPattern fromNBT(List<CompoundTag> tag) {
   BannerPattern.Builder builder = BannerPattern.builder();
   for (CompoundTag layer : tag) {
     BannerPattern.LayerTexture type =
         BannerPattern.LayerTexture.getByCode(layer.getString("Pattern"));
     DyeColor color = DyeColor.getByDyeData((byte) layer.getInt("Color"));
     builder.layer(type, color);
   }
   return builder.build();
 }
コード例 #2
0
 public static List<CompoundTag> toNBT(BannerPattern pattern) {
   List<CompoundTag> patterns = new ArrayList<>();
   for (BannerPattern.BannerLayer layer : pattern.getLayers()) {
     CompoundTag layerTag = new CompoundTag();
     layerTag.putString("Pattern", layer.getTexture().getCode());
     layerTag.putInt("Color", layer.getColor().getDyeData());
     patterns.add(layerTag);
   }
   return patterns;
 }