generated from Anvil-Dev/ArchitecturyExampleMod
-
Notifications
You must be signed in to change notification settings - Fork 1
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
5 changed files
with
138 additions
and
13 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
75 changes: 75 additions & 0 deletions
75
common/src/main/java/dev/anvilcraft/lib/registrator/builder/CreativeModeTabBuilder.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,75 @@ | ||
package dev.anvilcraft.lib.registrator.builder; | ||
|
||
import dev.anvilcraft.lib.registrator.AbstractRegistrator; | ||
import dev.anvilcraft.lib.registrator.entry.RegistryEntry; | ||
import dev.architectury.injectables.annotations.ExpectPlatform; | ||
import net.minecraft.core.registries.BuiltInRegistries; | ||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.world.item.CreativeModeTab; | ||
import net.minecraft.world.item.ItemStack; | ||
|
||
import java.util.function.Consumer; | ||
import java.util.function.Supplier; | ||
|
||
public abstract class CreativeModeTabBuilder extends EntryBuilder<CreativeModeTab> { | ||
protected final RegistryEntry<CreativeModeTab> tab = new RegistryEntry<>() { | ||
}; | ||
protected final CreativeModeTab.Builder builder; | ||
|
||
protected CreativeModeTabBuilder(AbstractRegistrator registrator, String id, CreativeModeTab.Builder builder) { | ||
super(registrator, id); | ||
this.builder = builder; | ||
} | ||
|
||
@ExpectPlatform | ||
public static CreativeModeTabBuilder create(AbstractRegistrator registrator, String id, Consumer<CreativeModeTab.Builder> consumer) { | ||
throw new AssertionError(); | ||
} | ||
|
||
public CreativeModeTabBuilder title(Component title) { | ||
this.builder.title(title); | ||
return this; | ||
} | ||
|
||
public CreativeModeTabBuilder icon(Supplier<ItemStack> icon) { | ||
this.builder.icon(icon); | ||
return this; | ||
} | ||
|
||
public CreativeModeTabBuilder displayItems(CreativeModeTab.DisplayItemsGenerator displayItemsGenerator) { | ||
this.builder.displayItems(displayItemsGenerator); | ||
return this; | ||
} | ||
|
||
public CreativeModeTabBuilder alignedRight() { | ||
this.builder.alignedRight(); | ||
return this; | ||
} | ||
|
||
public CreativeModeTabBuilder hideTitle() { | ||
this.builder.hideTitle(); | ||
return this; | ||
} | ||
|
||
public CreativeModeTabBuilder noScrollBar() { | ||
this.builder.noScrollBar(); | ||
return this; | ||
} | ||
|
||
public CreativeModeTabBuilder backgroundSuffix(String backgroundSuffix) { | ||
this.builder.backgroundSuffix(backgroundSuffix); | ||
return this; | ||
} | ||
|
||
@Override | ||
public CreativeModeTab build() { | ||
this.tab.set(this.builder.build()); | ||
return this.tab.get(); | ||
} | ||
|
||
@Override | ||
public RegistryEntry<CreativeModeTab> register() { | ||
this.registrator.addBuilder(BuiltInRegistries.CREATIVE_MODE_TAB, this); | ||
return this.tab; | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...c/main/java/dev/anvilcraft/lib/registrator/builder/fabric/CreativeModeTabBuilderImpl.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,21 @@ | ||
package dev.anvilcraft.lib.registrator.builder.fabric; | ||
|
||
import dev.anvilcraft.lib.registrator.AbstractRegistrator; | ||
import dev.anvilcraft.lib.registrator.builder.CreativeModeTabBuilder; | ||
import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup; | ||
import net.minecraft.world.item.CreativeModeTab; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.function.Consumer; | ||
|
||
public class CreativeModeTabBuilderImpl extends CreativeModeTabBuilder { | ||
protected CreativeModeTabBuilderImpl(AbstractRegistrator registrator, String id) { | ||
super(registrator, id, FabricItemGroup.builder()); | ||
} | ||
|
||
public static @NotNull CreativeModeTabBuilder create(AbstractRegistrator registrator, String id, @NotNull Consumer<CreativeModeTab.Builder> consumer) { | ||
CreativeModeTabBuilderImpl builder = new CreativeModeTabBuilderImpl(registrator, id); | ||
consumer.accept(builder.builder); | ||
return builder; | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...rc/main/java/dev/anvilcraft/lib/registrator/builder/forge/CreativeModeTabBuilderImpl.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,20 @@ | ||
package dev.anvilcraft.lib.registrator.builder.forge; | ||
|
||
import dev.anvilcraft.lib.registrator.AbstractRegistrator; | ||
import dev.anvilcraft.lib.registrator.builder.CreativeModeTabBuilder; | ||
import net.minecraft.world.item.CreativeModeTab; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.function.Consumer; | ||
|
||
public class CreativeModeTabBuilderImpl extends CreativeModeTabBuilder { | ||
protected CreativeModeTabBuilderImpl(AbstractRegistrator registrator, String id) { | ||
super(registrator, id, CreativeModeTab.builder()); | ||
} | ||
|
||
public static @NotNull CreativeModeTabBuilder create(AbstractRegistrator registrator, String id, @NotNull Consumer<CreativeModeTab.Builder> consumer) { | ||
CreativeModeTabBuilderImpl builder = new CreativeModeTabBuilderImpl(registrator, id); | ||
consumer.accept(builder.builder); | ||
return builder; | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...rc/main/java/dev/anvilcraft/lib/registrator/builder/forge/CreativeModeTabBuilderImpl.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,20 @@ | ||
package dev.anvilcraft.lib.registrator.builder.forge; | ||
|
||
import dev.anvilcraft.lib.registrator.AbstractRegistrator; | ||
import dev.anvilcraft.lib.registrator.builder.CreativeModeTabBuilder; | ||
import net.minecraft.world.item.CreativeModeTab; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.function.Consumer; | ||
|
||
public class CreativeModeTabBuilderImpl extends CreativeModeTabBuilder { | ||
protected CreativeModeTabBuilderImpl(AbstractRegistrator registrator, String id) { | ||
super(registrator, id, CreativeModeTab.builder()); | ||
} | ||
|
||
public static @NotNull CreativeModeTabBuilder create(AbstractRegistrator registrator, String id, @NotNull Consumer<CreativeModeTab.Builder> consumer) { | ||
CreativeModeTabBuilderImpl builder = new CreativeModeTabBuilderImpl(registrator, id); | ||
consumer.accept(builder.builder); | ||
return builder; | ||
} | ||
} |