Skip to content

Commit

Permalink
next
Browse files Browse the repository at this point in the history
  • Loading branch information
KrLite committed Dec 30, 2023
1 parent 8174248 commit 86e314a
Show file tree
Hide file tree
Showing 6 changed files with 602 additions and 596 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import me.shedaniel.rei.api.common.entry.type.EntryType;
import me.shedaniel.rei.api.common.entry.type.VanillaEntryTypes;
import me.shedaniel.rei.api.common.util.EntryIngredients;
import net.krlite.rei_collapsible_entries.util.ModPredicate;
import net.minecraft.block.Blocks;
import net.minecraft.item.Items;
import net.minecraft.registry.Registries;
Expand All @@ -29,20 +30,13 @@ public void registerCollapsibleEntries(CollapsibleEntryRegistry registry) {

types: {
// Fluids
registry.group(
MC.id("fluids"),
col(MC.id("fluids")),
entryStack -> entryStack.getType() == VanillaEntryTypes.FLUID
);
MC.buildColumn("fluids")
.predicate(ModPredicate.type(VanillaEntryTypes.FLUID))
.register(registry);

// Spawn eggs
registry.group(
MC.id("spawn_eggs"),
col(MC.id("spawn_eggs")),
entryStack ->
entryStack.getIdentifier() != null
&& entryStack.getIdentifier().getPath().endsWith("spawn_egg")
);
MC.buildColumn("spawn_eggs")
.predicate(ModPredicate.trailing("spawn_egg"));
}

tags: {
Expand All @@ -52,6 +46,8 @@ public void registerCollapsibleEntries(CollapsibleEntryRegistry registry) {
}).forEach(tag -> registerCollapsibleEntryFromTag(registry, C, tag));

// Glass blocks
C.buildColumn("glass_blocks")

registry.group(
C.id("glass_blocks"),
tag(C.id("glass_blocks")),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package net.krlite.rei_collapsible_entries.util;

import me.shedaniel.rei.api.client.registry.entry.CollapsibleEntryRegistry;
import me.shedaniel.rei.api.common.entry.EntryStack;
import me.shedaniel.rei.api.common.util.EntryIngredients;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
Expand All @@ -15,7 +14,6 @@

import java.util.Arrays;
import java.util.Objects;
import java.util.function.Predicate;

public enum ModEntry {
C("c"),
Expand Down Expand Up @@ -77,8 +75,8 @@ public boolean checkContains(@NotNull Item item) {
* @param paths The identifier's paths.
* @return The tagged text.
*/
public Text tag(String... paths) {
return convertToTranslatableText("tag", id(paths));
public Text tagged(String... paths) {
return convertToTranslatableText("tagged", id(paths));
}

/**
Expand All @@ -88,12 +86,16 @@ public Text tag(String... paths) {
* @param paths The identifier's paths.
* @return The coled text.
*/
public Text col(String... paths) {
return convertToTranslatableText("col", id(paths));
public Text column(String... paths) {
return convertToTranslatableText("column", id(paths));
}

public ModPredicateBuilder build(String... paths) {
return new ModPredicateBuilder(id(paths), col(paths), ModPredicate.pass());
public ModPredicateBuilder buildColumn(String... paths) {
return new ModPredicateBuilder(id(paths), column(paths), ModPredicate.pass());
}

public ModPredicateBuilder buildTagged(String... paths) {
return new ModPredicateBuilder(id(paths), tagged(paths), ModPredicate.pass());
}

/**
Expand All @@ -108,7 +110,7 @@ public void registerCollapsibleEntryFromTag(
) {
registry.group(
id(tagPaths),
tag(tagPaths),
tagged(tagPaths),
EntryIngredients.ofItemTag(asItemTag(tagPaths))
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,19 @@ static ModPredicate leading(String... paths) {
&& entryStack.getIdentifier().getPath().startsWith(ModEntry.joinAll(paths));
}

static ModPredicate leadingOnly(String... paths) {
return (ModPredicate) leading(paths).and(full(paths).negate());
}

static ModPredicate trailing(String... paths) {
return entryStack -> entryStack.getIdentifier() != null
&& entryStack.getIdentifier().getPath().endsWith(ModEntry.joinAll(paths));
}

static ModPredicate trailingOnly(String... paths) {
return (ModPredicate) trailing(paths).and(full(paths).negate());
}

static ModPredicate tag(String... paths) {
return entryStack -> entryStack.getTagsFor().anyMatch(tag -> tag.id().getPath().equals(ModEntry.joinAll(paths)));
}
Expand Down
Loading

0 comments on commit 86e314a

Please sign in to comment.