-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
356 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
src/main/java/dqu/additionaladditions/misc/CreativeAdder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package dqu.additionaladditions.misc; | ||
|
||
import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroupEntries; | ||
import net.minecraft.world.level.ItemLike; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.function.Supplier; | ||
|
||
public enum CreativeAdder { | ||
|
||
TOOLS_AND_UTILITIES(), | ||
INGREDIENTS(), | ||
BUILDING_BLOCKS(), | ||
REDSTONE_BLOCKS(), | ||
FOOD_AND_DRINKS(), | ||
FUNCTIONAL_BLOCKS(), | ||
COMBAT(); | ||
|
||
private final List<CreativeEntry> entries = new ArrayList<>(); | ||
|
||
CreativeAdder() {} | ||
|
||
public void add(Supplier<Boolean> condition, ItemLike after, ItemLike... items) { | ||
CreativeEntry entry = new CreativeEntry(condition, false, after, items); | ||
this.entries.add(entry); | ||
} | ||
|
||
public void addBefore(Supplier<Boolean> condition, ItemLike after, ItemLike... items) { | ||
CreativeEntry entry = new CreativeEntry(condition, true, after, items); | ||
this.entries.add(entry); | ||
} | ||
|
||
public void pushAllTo(FabricItemGroupEntries content) { | ||
for (CreativeEntry entry : entries) { | ||
if (entry.condition.get()) { | ||
if (entry.before) { | ||
content.addBefore(entry.anchor, entry.items); | ||
} else { | ||
content.addAfter(entry.anchor, entry.items); | ||
} | ||
} | ||
} | ||
} | ||
|
||
private record CreativeEntry(Supplier<Boolean> condition, boolean before, ItemLike anchor, ItemLike... items) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.