Add Item.Properties().arch$tab(CreativeModeTab)

This commit is contained in:
shedaniel
2022-10-23 19:24:39 +08:00
parent f73228fdd5
commit 93d0538f35
13 changed files with 300 additions and 25 deletions

View File

@@ -105,27 +105,27 @@ public class TestRegistries {
});
public static final RegistrySupplier<Item> TEST_ITEM = ITEMS.register("test_item", () ->
new Item(new Item.Properties()));
new Item(new Item.Properties().arch$tab(TestCreativeTabs.TEST_TAB)));
public static final RegistrySupplier<Item> TEST_EQUIPPABLE = ITEMS.register("test_eqippable", () ->
new EquippableTickingItem(new Item.Properties()));
new EquippableTickingItem(new Item.Properties().arch$tab(TestCreativeTabs.TEST_TAB)));
public static final RegistrySupplier<Item> TEST_EDIBLE = ITEMS.register("test_edible", () -> {
FoodProperties.Builder fpBuilder = new FoodProperties.Builder().nutrition(8).saturationMod(0.8F).meat();
FoodPropertiesHooks.effect(fpBuilder, () -> new MobEffectInstance(TEST_EFFECT.get(), 100), 1);
return new Item(new Item.Properties().food(fpBuilder.build()));
return new Item(new Item.Properties().food(fpBuilder.build()).arch$tab(TestCreativeTabs.TEST_TAB));
});
public static final RegistrySupplier<Item> TEST_SPAWN_EGG = ITEMS.register("test_spawn_egg", () ->
new ArchitecturySpawnEggItem(TestRegistries.TEST_ENTITY, 0xFF000000, 0xFFFFFFFF,
new Item.Properties()));
new Item.Properties().arch$tab(TestCreativeTabs.TEST_TAB)));
public static final RegistrySupplier<Item> TEST_SPAWN_EGG_2 = ITEMS.register("test_spawn_egg_2", () ->
new ArchitecturySpawnEggItem(TestRegistries.TEST_ENTITY_2, 0xFFFFFFFF, 0xFF000000,
new Item.Properties()));
new Item.Properties().arch$tab(TestCreativeTabs.TEST_TAB)));
public static final RegistrySupplier<Item> TEST_FLUID_BUCKET = ITEMS.register("test_fluid_bucket", () -> {
try {
// In example mod the forge class isn't being replaced, this is not required in mods depending on architectury
return (Item) Class.forName(!Platform.isForge() ? "dev.architectury.core.item.ArchitecturyBucketItem" : "dev.architectury.core.item.forge.imitator.ArchitecturyBucketItem")
.getDeclaredConstructor(Supplier.class, Item.Properties.class)
.newInstance(TestRegistries.TEST_FLUID, new Item.Properties());
.newInstance(TestRegistries.TEST_FLUID, new Item.Properties().arch$tab(TestCreativeTabs.TEST_TAB));
} catch (InstantiationException | ClassNotFoundException | NoSuchMethodException | InvocationTargetException |
IllegalAccessException e) {
throw new RuntimeException(e);
@@ -180,9 +180,9 @@ public class TestRegistries {
});
public static final RegistrySupplier<Item> TEST_BLOCK_ITEM = ITEMS.register("test_block", () ->
new BlockItem(TEST_BLOCK.get(), new Item.Properties()));
new BlockItem(TEST_BLOCK.get(), new Item.Properties().arch$tab(TestCreativeTabs.TEST_TAB)));
public static final RegistrySupplier<Item> COLLISION_BLOCK_ITEM = ITEMS.register("collision_block", () ->
new BlockItem(COLLISION_BLOCK.get(), new Item.Properties()));
new BlockItem(COLLISION_BLOCK.get(), new Item.Properties().arch$tab(TestCreativeTabs.TEST_TAB)));
public static final RegistrySupplier<EntityType<TestEntity>> TEST_ENTITY = ENTITY_TYPES.register("test_entity", TestEntity.TYPE);
public static final RegistrySupplier<EntityType<TestEntity>> TEST_ENTITY_2 = ENTITY_TYPES.register("test_entity_2", TestEntity.TYPE_2);

View File

@@ -28,14 +28,5 @@ import net.minecraft.world.item.ItemStack;
public class TestCreativeTabs {
public static final CreativeModeTab TEST_TAB = CreativeTabRegistry.create(new ResourceLocation(TestMod.MOD_ID, "test_tab"),
() -> new ItemStack(TestRegistries.TEST_ITEM.get()), (featureFlagSet, output) -> {
output.accept(TestRegistries.TEST_ITEM.get());
output.accept(TestRegistries.TEST_EQUIPPABLE.get());
output.accept(TestRegistries.TEST_EDIBLE.get());
output.accept(TestRegistries.TEST_SPAWN_EGG.get());
output.accept(TestRegistries.TEST_SPAWN_EGG_2.get());
output.accept(TestRegistries.TEST_FLUID_BUCKET.get());
output.accept(TestRegistries.TEST_BLOCK_ITEM.get());
output.accept(TestRegistries.COLLISION_BLOCK_ITEM.get());
});
() -> new ItemStack(TestRegistries.TEST_ITEM.get()));
}