From 8b28c0369996032f4831b8b760aafc174f6dd004 Mon Sep 17 00:00:00 2001 From: PepperCode1 <44146161+PepperCode1@users.noreply.github.com> Date: Tue, 12 Jul 2022 15:43:42 -0700 Subject: [PATCH] Fix item sections and palettes tab --- src/main/java/com/simibubi/create/AllBlocks.java | 8 ++++---- src/main/java/com/simibubi/create/Create.java | 2 +- .../create/content/palettes/AllPaletteBlocks.java | 2 +- .../create/foundation/data/CreateRegistrate.java | 8 +++++--- .../foundation/item/CreateItemGroupBase.java | 14 ++++++-------- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/simibubi/create/AllBlocks.java b/src/main/java/com/simibubi/create/AllBlocks.java index fc288dde4..2ae37cec3 100644 --- a/src/main/java/com/simibubi/create/AllBlocks.java +++ b/src/main/java/com/simibubi/create/AllBlocks.java @@ -241,12 +241,12 @@ import com.tterrag.registrate.util.entry.BlockEntry; import net.minecraft.client.renderer.RenderType; import net.minecraft.core.Direction.Axis; import net.minecraft.core.Direction.AxisDirection; +import net.minecraft.core.Registry; import net.minecraft.data.recipes.ShapelessRecipeBuilder; import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.BlockTags; import net.minecraft.tags.ItemTags; import net.minecraft.world.item.DyeColor; -import net.minecraft.world.item.Item; import net.minecraft.world.item.Rarity; import net.minecraft.world.item.enchantment.Enchantments; import net.minecraft.world.level.block.Block; @@ -570,7 +570,7 @@ public class AllBlocks { .transform(axeOrPickaxe()) .transform(BuilderTransformers.cuckooClock()) .lang("Cuckoo Clock") - .onRegisterAfter(Item.class, c -> TooltipHelper.referTo(c, CUCKOO_CLOCK)) + .onRegisterAfter(Registry.ITEM_REGISTRY, c -> TooltipHelper.referTo(c, CUCKOO_CLOCK)) .register(); public static final BlockEntry MILLSTONE = REGISTRATE.block("millstone", MillstoneBlock::new) @@ -1337,7 +1337,7 @@ public class AllBlocks { .unlockedBy("has_seat", RegistrateRecipeProvider.has(AllItemTags.SEATS.tag)) .save(p, Create.asResource("crafting/kinetics/" + c.getName() + "_from_other_seat")); }) - .onRegisterAfter(Item.class, v -> TooltipHelper.referTo(v, "block.create.brown_seat")) + .onRegisterAfter(Registry.ITEM_REGISTRY, v -> TooltipHelper.referTo(v, "block.create.brown_seat")) .tag(AllBlockTags.SEATS.tag) .item() .tag(AllItemTags.SEATS.tag) @@ -1953,7 +1953,7 @@ public class AllBlocks { .withExistingParent(colourName + "_toolbox", p.modLoc("block/toolbox/block")) .texture("0", p.modLoc("block/toolbox/" + colourName))); }) - .onRegisterAfter(Item.class, v -> TooltipHelper.referTo(v, "block.create.toolbox")) + .onRegisterAfter(Registry.ITEM_REGISTRY, v -> TooltipHelper.referTo(v, "block.create.toolbox")) .tag(AllBlockTags.TOOLBOXES.tag) .item(UncontainableBlockItem::new) .model((c, p) -> p.withExistingParent(colourName + "_toolbox", p.modLoc("block/toolbox/item")) diff --git a/src/main/java/com/simibubi/create/Create.java b/src/main/java/com/simibubi/create/Create.java index 481edf9aa..7fda0fa65 100644 --- a/src/main/java/com/simibubi/create/Create.java +++ b/src/main/java/com/simibubi/create/Create.java @@ -73,7 +73,7 @@ public class Create { .create(); public static final CreativeModeTab BASE_CREATIVE_TAB = new CreateItemGroup(); -// public static final CreativeModeTab PALETTES_CREATIVE_TAB = new PalettesItemGroup(); + public static final CreativeModeTab PALETTES_CREATIVE_TAB = new PalettesItemGroup(); public static final ServerSchematicLoader SCHEMATIC_RECEIVER = new ServerSchematicLoader(); public static final RedstoneLinkNetworkHandler REDSTONE_LINK_NETWORK_HANDLER = new RedstoneLinkNetworkHandler(); diff --git a/src/main/java/com/simibubi/create/content/palettes/AllPaletteBlocks.java b/src/main/java/com/simibubi/create/content/palettes/AllPaletteBlocks.java index e249b9956..228a820b4 100644 --- a/src/main/java/com/simibubi/create/content/palettes/AllPaletteBlocks.java +++ b/src/main/java/com/simibubi/create/content/palettes/AllPaletteBlocks.java @@ -31,7 +31,7 @@ import net.minecraftforge.common.Tags; public class AllPaletteBlocks { private static final CreateRegistrate REGISTRATE = Create.registrate() - .creativeModeTab(() -> Create.BASE_CREATIVE_TAB) // Change back when creative tabs in Registrate are fixed + .creativeModeTab(() -> Create.PALETTES_CREATIVE_TAB) .startSection(AllSections.PALETTES); // Windows and Glass diff --git a/src/main/java/com/simibubi/create/foundation/data/CreateRegistrate.java b/src/main/java/com/simibubi/create/foundation/data/CreateRegistrate.java index ddbff1f86..9a0e26718 100644 --- a/src/main/java/com/simibubi/create/foundation/data/CreateRegistrate.java +++ b/src/main/java/com/simibubi/create/foundation/data/CreateRegistrate.java @@ -30,6 +30,8 @@ import com.tterrag.registrate.util.nullness.NonNullFunction; import com.tterrag.registrate.util.nullness.NonNullSupplier; import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.core.Registry; +import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.BlockTags; import net.minecraft.world.entity.Entity; @@ -77,7 +79,7 @@ public class CreateRegistrate extends AbstractRegistrate { @Override protected , T extends R> RegistryEntry accept(String name, - Class type, Builder builder, NonNullSupplier creator, + ResourceKey> type, Builder builder, NonNullSupplier creator, NonNullFunction, ? extends RegistryEntry> entryFactory) { RegistryEntry ret = super.accept(name, type, builder, creator, entryFactory); sectionLookup.put(ret, currentSection()); @@ -103,8 +105,8 @@ public class CreateRegistrate extends AbstractRegistrate { } public > Collection> getAll(AllSections section, - Class registryType) { - return this.getAll(registryType) + ResourceKey> registryType) { + return this.getAll(registryType) .stream() .filter(e -> getSection(e) == section) .collect(Collectors.toList()); diff --git a/src/main/java/com/simibubi/create/foundation/item/CreateItemGroupBase.java b/src/main/java/com/simibubi/create/foundation/item/CreateItemGroupBase.java index c930d46db..56f6ae566 100644 --- a/src/main/java/com/simibubi/create/foundation/item/CreateItemGroupBase.java +++ b/src/main/java/com/simibubi/create/foundation/item/CreateItemGroupBase.java @@ -9,10 +9,10 @@ import com.simibubi.create.content.AllSections; import com.tterrag.registrate.util.entry.RegistryEntry; import net.minecraft.client.Minecraft; -import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.renderer.entity.ItemRenderer; import net.minecraft.client.resources.model.BakedModel; import net.minecraft.core.NonNullList; +import net.minecraft.core.Registry; import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.CreativeModeTab; import net.minecraft.world.item.Item; @@ -25,7 +25,7 @@ import net.minecraftforge.api.distmarker.OnlyIn; public abstract class CreateItemGroupBase extends CreativeModeTab { public CreateItemGroupBase(String id) { - super(getGroupCountSafe(), Create.ID + "." + id); + super(Create.ID + "." + id); } @Override @@ -48,16 +48,14 @@ public abstract class CreateItemGroupBase extends CreativeModeTab { @OnlyIn(Dist.CLIENT) public void addItems(NonNullList items, boolean specialItems) { - Minecraft mc = Minecraft.getInstance(); - ItemRenderer itemRenderer = mc.getItemRenderer(); - ClientLevel world = mc.level; + ItemRenderer itemRenderer = Minecraft.getInstance().getItemRenderer(); for (RegistryEntry entry : getItems()) { Item item = entry.get(); if (item instanceof BlockItem) continue; ItemStack stack = new ItemStack(item); - BakedModel model = itemRenderer.getModel(stack, world, null, 0); + BakedModel model = itemRenderer.getModel(stack, null, null, 0); if (model.isGui3d() != specialItems) continue; item.fillItemCategory(this, items); @@ -67,7 +65,7 @@ public abstract class CreateItemGroupBase extends CreativeModeTab { protected Collection> getBlocks() { return getSections().stream() .flatMap(s -> Create.registrate() - .getAll(s, Block.class) + .getAll(s, Registry.BLOCK_REGISTRY) .stream()) .collect(Collectors.toList()); } @@ -75,7 +73,7 @@ public abstract class CreateItemGroupBase extends CreativeModeTab { protected Collection> getItems() { return getSections().stream() .flatMap(s -> Create.registrate() - .getAll(s, Item.class) + .getAll(s, Registry.ITEM_REGISTRY) .stream()) .collect(Collectors.toList()); }