use of net.minecraft.util.Identifier in project frame-fabric by moddingplayground.
the class AbstractLootTableGenerator method accept.
@SuppressWarnings("ConstantConditions")
@Override
public void accept(BiConsumer<Identifier, LootTable.Builder> biConsumer) {
this.generate();
Set<Identifier> set = Sets.newHashSet();
Registry<T> registry = this.getRegistry();
Iterable<T> objects = registry.stream().filter(obj -> registry.getId(obj).getNamespace().equals(this.modId))::iterator;
for (T obj : objects) {
Identifier id = ((ObjectLootTableAccess) obj).access_getLootTableId();
this.testObject(id, obj);
if (id != LootTables.EMPTY && set.add(id)) {
LootTable.Builder builder = this.map.remove(id);
if (builder == null) {
throw new IllegalStateException(String.format("Missing loottable '%s' for '%s'", id, registry.getId(obj)));
}
biConsumer.accept(id, builder);
}
}
this.map.forEach(biConsumer);
}
use of net.minecraft.util.Identifier in project frame-fabric by moddingplayground.
the class FrameBannerPatternConversions method makeData.
/**
* Parses the given NBT data into a list of {@link FrameBannerPatternData} objects.
*
* @param nbt a nullable {@link NbtList} with Frame banner pattern data
*/
public static List<FrameBannerPatternData> makeData(NbtList nbt) {
List<FrameBannerPatternData> res = new ArrayList<>();
if (nbt != null) {
for (NbtElement t : nbt) {
NbtCompound patternNbt = (NbtCompound) t;
FrameBannerPattern pattern = FrameBannerPatterns.REGISTRY.get(new Identifier(patternNbt.getString("Pattern")));
if (pattern != null) {
DyeColor color = DyeColor.byId(patternNbt.getInt("Color"));
int index = patternNbt.getInt("Index");
res.add(new FrameBannerPatternData(pattern, color, index));
}
}
}
return res;
}
use of net.minecraft.util.Identifier in project frame-fabric by moddingplayground.
the class BannerBlockEntityMixin method frame_setBannerPatternNbt.
@Override
public void frame_setBannerPatternNbt(NbtList nbt) {
frame_bannerPatternsTag = nbt;
if (frame_bannerPatternsTag != null) {
// validate NBT data, removing and/or resetting invalid data
for (Iterator<NbtElement> itr = frame_bannerPatternsTag.iterator(); itr.hasNext(); ) {
NbtCompound element = (NbtCompound) itr.next();
Identifier id = Identifier.tryParse(element.getString("Pattern"));
int colorId = element.getInt("Color");
int index = element.getInt("Index");
if (id == null || !FrameBannerPatterns.REGISTRY.getIds().contains(id)) {
itr.remove();
} else {
int rtColorId = DyeColor.byId(colorId).getId();
if (rtColorId != colorId) {
element.putInt("Color", rtColorId);
}
if (index < 0) {
element.putInt("Index", 0);
}
}
}
// the Java API requires that this sort be stable
frame_bannerPatternsTag.sort(comparingInt(t -> ((NbtCompound) t).getInt("Index")));
}
}
use of net.minecraft.util.Identifier in project frame-fabric by moddingplayground.
the class FrameBlocksTest method register.
private static Block register(String id, Block block) {
Identifier identifier = new Identifier("frame-blocks-test", id);
Registry.register(Registry.ITEM, identifier, new BlockItem(block, new FabricItemSettings().group(ItemGroup.BUILDING_BLOCKS)));
return Registry.register(Registry.BLOCK, identifier, block);
}
use of net.minecraft.util.Identifier in project frame-fabric by moddingplayground.
the class BannerItemMixin method frame_addBannerPatternLine.
@Unique
private static void frame_addBannerPatternLine(NbtCompound nbt, List<Text> lines) {
Identifier id = Identifier.tryParse(nbt.getString("Pattern"));
DyeColor color = DyeColor.byId(nbt.getInt("Color"));
if (id != null) {
FrameBannerPattern pattern = FrameBannerPatterns.REGISTRY.get(id);
if (pattern != null)
pattern.addPatternLine(lines, color);
}
}
Aggregations