[Change] Use new CreativeTab API

This commit is contained in:
Frank 2023-06-08 08:47:39 +02:00
parent 66ed66c04a
commit 7468307b2c
3 changed files with 34 additions and 108 deletions

View file

@ -1,115 +1,30 @@
package org.betterx.betterend.tab;
import org.betterx.bclib.behaviours.interfaces.*;
import org.betterx.bclib.creativetab.BCLCreativeTab;
import org.betterx.bclib.creativetab.BCLCreativeTabManager;
import org.betterx.betterend.BetterEnd;
import org.betterx.betterend.registry.EndBlocks;
import org.betterx.betterend.registry.EndItems;
import org.betterx.worlds.together.tag.v3.CommonBlockTags;
import org.betterx.worlds.together.tag.v3.CommonItemTags;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceKey;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup;
import java.util.stream.Collectors;
public class CreativeTabs {
public static final CreativeModeTab TAB_BLOCKS;
public static final CreativeModeTab TAB_ITEMS;
public static final CreativeModeTab TAB_PLANTS;
public static final ResourceKey<CreativeModeTab> TAB_ITEMS_KEY = ResourceKey.create(
Registries.CREATIVE_MODE_TAB,
BetterEnd.makeID("item_tab")
);
public static final ResourceKey<CreativeModeTab> TAB_BLOCKS_KEY = ResourceKey.create(
Registries.CREATIVE_MODE_TAB,
BetterEnd.makeID("block_tab")
);
public static final ResourceKey<CreativeModeTab> TAB_PLANTS_KEY = ResourceKey.create(
Registries.CREATIVE_MODE_TAB,
BetterEnd.makeID("plant_tab")
);
public static void register() {
Registry.register(
BuiltInRegistries.CREATIVE_MODE_TAB,
TAB_ITEMS_KEY,
TAB_ITEMS
);
Registry.register(
BuiltInRegistries.CREATIVE_MODE_TAB,
TAB_BLOCKS_KEY,
TAB_BLOCKS
);
Registry.register(
BuiltInRegistries.CREATIVE_MODE_TAB,
TAB_PLANTS_KEY,
TAB_PLANTS
);
}
static {
TAB_BLOCKS = FabricItemGroup
.builder()
.icon(() -> new ItemStack(EndBlocks.END_MYCELIUM))
.title(Component.translatable("itemGroup.betterend.blocks"))
.displayItems((featureFlagSet, output) -> output.acceptAll(EndBlocks.getModBlockItems()
.stream()
.map(b -> new ItemStack(b, 1))
.collect(Collectors.toList())))
.build();
TAB_ITEMS = FabricItemGroup
.builder()
.title(Component.translatable("itemGroup.betterend.items"))
.icon(() -> new ItemStack(EndItems.ETERNAL_CRYSTAL))
.displayItems((featureFlagSet, output) -> output.acceptAll(EndItems.getModItems()
.stream()
.map(b -> new ItemStack(b, 1))
.collect(Collectors.toList())))
.build();
TAB_PLANTS = FabricItemGroup
.builder()
.title(Component.translatable("itemGroup.betterend.plants"))
.icon(() -> new ItemStack(EndBlocks.FILALUX_LANTERN))
.displayItems((featureFlagSet, output) -> {
output.acceptAll(EndItems.getModItems()
.stream()
.map(b -> new ItemStack(b, 1))
.filter(s -> s.is(CommonItemTags.COMPOSTABLE)
|| s.is(CommonItemTags.LEAVES)
|| s.is(CommonItemTags.SAPLINGS)
|| s.is(CommonItemTags.SEEDS))
.collect(Collectors.toList()));
output.acceptAll(EndBlocks.getModBlocks()
.stream()
.filter(b -> b.asItem() != null && b.asItem() != Items.AIR)
.filter(b -> b instanceof BehaviourVine
|| b instanceof BehaviourLeaves
|| b instanceof BehaviourPlant
|| b instanceof BehaviourWaterPlant
|| b instanceof BehaviourSeed
|| b instanceof BehaviourSapling
|| b instanceof BehaviourCompostable
|| b.defaultBlockState().is(CommonBlockTags.WATER_PLANT)
|| b.defaultBlockState().is(CommonBlockTags.PLANT)
|| b.defaultBlockState().is(CommonBlockTags.SEEDS)
|| b.defaultBlockState().is(CommonBlockTags.SAPLINGS)
|| b.defaultBlockState().is(CommonBlockTags.LEAVES))
.map(b -> new ItemStack(b, 1))
.collect(Collectors.toList()));
})
.build();
BCLCreativeTabManager.create(BetterEnd.MOD_ID)
.createTab("nature")
.setPredicate(item -> BCLCreativeTab.NATURE.contains(item)
// || item == NetherItems.AGAVE_LEAF
// || item == NetherItems.BLACK_APPLE
// || item == NetherBlocks.MAGMA_FLOWER.asItem()
// || item == NetherBlocks.MAT_RUBEUS.getBlockItem(NetherSlots.CONE)
// || item == NetherBlocks.MAT_WILLOW.getBlockItem(WillowMaterial.BLOCK_TORCH)
)
.setIcon(EndBlocks.FILALUX_LANTERN)
.build()
.createBlockTab(EndBlocks.END_MYCELIUM)
.build()
.createItemsTab(EndItems.ETERNAL_CRYSTAL)
.build()
.processBCLRegistry()
.register();
}
}

View file

@ -642,8 +642,9 @@
"item.minecraft.splash_potion.effect.long_end_veil": "Wurftrank des Endschleiers",
"item.minecraft.tipped_arrow.effect.end_veil": "Pfeil des Endschleiers",
"item.minecraft.tipped_arrow.effect.long_end_veil": "Pfeil des Endschleiers",
"itemGroup.betterend.end_blocks": "Better End: Blöcke",
"itemGroup.betterend.end_items": "Better End: Items",
"itemGroup.betterend.blocks": "Better End: Blöcke",
"itemGroup.betterend.items": "Better End: Gegenstände",
"itemGroup.betterend.plants": "Better End: Pflanzen",
"message.betterend.fail_spawn": "§c§lDu musst 6 Bernsteinjuwele in der Hand halten, um deinen Einstiegspunkt zu setzen.",
"message.betterend.set_spawn": "§b§lWiedereinstiegspunkt gesetzt",
"tag.betterend.alloying_copper": "Kupfererze",
@ -659,5 +660,15 @@
"tag.betterend.pythadendron_logs": "Pythadendronstämme",
"tag.betterend.tenanea_logs": "Tenaneastämme",
"tag.betterend.thallasium_alloying": "Thallasiumerze",
"tag.betterend.umbrella_tree_logs": "Schirmbaumstämme"
"tag.betterend.umbrella_tree_logs": "Schirmbaumstämme",
"item.betterend.debug.village_loot": "Einfache Schätze [dev]",
"item.betterend.debug.village_bonus": "Super Schätze [dev]",
"item.betterend.debug.village_template": "Schätze mit Schmiedevorlagen [dev]",
"item.betterend.debug.jigsaw_entrance": "Hauseingang [dev]",
"item.betterend.debug.jigsaw_street_entrance": "Platzhalter - Hauseingang [dev]",
"item.betterend.debug.jigsaw_street": "Straßenstück [dev]",
"item.betterend.debug.jigsaw_street_deco": "Platzhalter - kleine Deko [dev]",
"item.betterend.debug.jigsaw_street_big_deco": "Platzhalter - große Deko [dev]",
"item.betterend.debug.jigsaw_big_deco": "Große Deko [dev]",
"item.betterend.debug.jigsaw_deco": "Kleine Deko [dev]"
}

View file

@ -873,7 +873,7 @@
"item.minecraft.tipped_arrow.effect.long_end_veil": "Arrow Of End Veil",
"itemGroup.betterend.blocks": "BetterEnd: Blocks",
"itemGroup.betterend.items": "BetterEnd: Items",
"itemGroup.betterend.plants": "BetterEnd: Plants",
"itemGroup.betterend.nature": "BetterEnd: Plants",
"message.betterend.anvil_damage": "§cDamage",
"message.betterend.fail_spawn": "§c§lYou need to hold 6 Amber Gems to set your spawn point",
"message.betterend.set_spawn": "§b§lYour spawn point is set here",