use of net.minecraft.util.registry.Registry 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.registry.Registry in project meteor-client by MeteorDevelopment.
the class LeftRightListSettingScreen method initWidgets.
private void initWidgets(Registry<T> registry) {
// Left (all)
WTable left = abc(pairs -> registry.forEach(t -> {
if (skipValue(t) || collection.contains(t))
return;
int words = Utils.search(getValueName(t), filterText);
if (words > 0)
pairs.add(new Pair<>(t, words));
}), true, t -> {
addValue(registry, t);
T v = getAdditionalValue(t);
if (v != null)
addValue(registry, v);
});
if (left.cells.size() > 0)
table.add(theme.verticalSeparator()).expandWidgetY();
// Right (selected)
abc(pairs -> {
for (T value : collection) {
if (skipValue(value))
continue;
int words = Utils.search(getValueName(value), filterText);
if (words > 0)
pairs.add(new Pair<>(value, words));
}
}, false, t -> {
removeValue(registry, t);
T v = getAdditionalValue(t);
if (v != null)
removeValue(registry, v);
});
}
use of net.minecraft.util.registry.Registry in project Client by MatHax.
the class LeftRightListSettingScreen method initWidgets.
private void initWidgets(Registry<T> registry) {
// Left (all)
WTable left = abc(pairs -> registry.forEach(t -> {
if (skipValue(t) || collection.contains(t))
return;
int words = Utils.search(getValueName(t), filterText);
if (words > 0)
pairs.add(new Pair<>(t, words));
}), true, t -> {
addValue(registry, t);
T v = getAdditionalValue(t);
if (v != null)
addValue(registry, v);
});
if (left.cells.size() > 0)
table.add(theme.verticalSeparator()).expandWidgetY();
// Right (selected)
abc(pairs -> {
for (T value : collection) {
if (skipValue(value))
continue;
int words = Utils.search(getValueName(value), filterText);
if (words > 0)
pairs.add(new Pair<>(value, words));
}
}, false, t -> {
removeValue(registry, t);
T v = getAdditionalValue(t);
if (v != null)
removeValue(registry, v);
});
}
use of net.minecraft.util.registry.Registry in project EdenClient by HahaOO7.
the class ContainerInfo method onOpenInventory.
private void onOpenInventory(List<ItemStack> itemStacks) {
if (lastInteractedBlock == null)
return;
// smallest only chests and shulkerboxes!
if (itemStacks.size() < 27)
return;
ChunkPos cp = new ChunkPos(new BlockPos(lastInteractedBlock));
Registry<Block> registry = PlayerUtils.getPlayer().world.getRegistryManager().get(BlockTags.SHULKER_BOXES.registry());
Map<Item, List<ItemStack>> items = itemStacks.stream().flatMap(stack -> registry.containsId(Registry.BLOCK.getId(Block.getBlockFromItem(stack.getItem()))) ? mapShulkerBox(stack) : Stream.of(stack)).collect(Collectors.groupingBy(ItemStack::getItem));
items.remove(Items.AIR);
Map<Item, Integer> counts = new HashMap<>();
items.forEach((item, stacks) -> counts.put(item, stacks.stream().mapToInt(ItemStack::getCount).sum()));
ItemList list = new ItemList();
list.addAll(counts.keySet());
list.sort(Comparator.comparingInt(i -> -counts.get(i)));
ChestMap map = chunkMap.computeIfAbsent(cp, chunkPos -> new ChestMap());
if (list.isEmpty())
map.remove(lastInteractedBlock);
else
map.put(lastInteractedBlock, list);
}
use of net.minecraft.util.registry.Registry in project EdenClient by HahaOO7.
the class AutoSell method registerCommand.
private void registerCommand(String cmd) {
LiteralArgumentBuilder<ClientCommandSource> node = literal(cmd);
node.then(literal("toggle").executes(c -> {
enabled = !enabled;
sendModMessage(enabled ? "AutoSell enabled" : "AutoSell disabled");
return 1;
}));
node.then(literal("clear").executes(c -> {
autoSellItems.clear();
sendModMessage("Removed all entries");
return 1;
}));
node.then(literal("list").executes(c -> {
sendModMessage(autoSellItems.toString());
return 1;
}));
DefaultedRegistry<Item> registry = Registry.ITEM;
for (Item item : registry) {
node.then(literal("add").then(literal(registry.getId(item).toString().replace("minecraft:", "")).executes(c -> {
autoSellItems.add(item);
sendModMessage("Added /sell " + item.getName().getString());
return 1;
})));
}
node.then(literal("remove").then(argument("item", StringArgumentType.greedyString()).suggests(this::suggestRemoveItems).executes(c -> {
Optional<Item> opt = Registry.ITEM.getOrEmpty(new Identifier(c.getArgument("item", String.class).replace(" ", "_")));
if (opt.isEmpty()) {
sendModMessage("No item with this name exists.");
return 1;
}
if (autoSellItems.remove(opt.get()))
sendModMessage("Removed /sell " + opt.get().getName().getString());
else {
sendModMessage("Couldn't remove /sell " + opt.get().getName().getString() + " because it wasn't in your sell list.");
}
return 1;
})));
node.then(literal("stats").executes(c -> {
ClientPlayerEntity entityPlayer = PlayerUtils.getPlayer();
entityPlayer.sendChatMessage("/esellstatstracker global");
return 1;
}));
node.executes(c -> {
sendModMessage("/autosell clear");
sendModMessage("/autosell list");
sendModMessage("/autosell toggle");
sendModMessage("/autosell add");
sendModMessage("/autosell remove");
return 1;
});
register(node, "AutoSell allows for automatic selling of items in any kind of command-accessible public server shop.", "It will always toggle when your inventory is full and execute the sell-command. You can select the items you want to sell yourself.");
}
Aggregations