Fix item sections and palettes tab

This commit is contained in:
PepperCode1 2022-07-12 15:43:42 -07:00
parent 1ec63c1511
commit 8b28c03699
5 changed files with 17 additions and 17 deletions

View file

@ -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<MillstoneBlock> 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"))

View file

@ -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();

View file

@ -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

View file

@ -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<CreateRegistrate> {
@Override
protected <R extends IForgeRegistryEntry<R>, T extends R> RegistryEntry<T> accept(String name,
Class<? super R> type, Builder<R, T, ?, ?> builder, NonNullSupplier<? extends T> creator,
ResourceKey<? extends Registry<R>> type, Builder<R, T, ?, ?> builder, NonNullSupplier<? extends T> creator,
NonNullFunction<RegistryObject<T>, ? extends RegistryEntry<T>> entryFactory) {
RegistryEntry<T> ret = super.accept(name, type, builder, creator, entryFactory);
sectionLookup.put(ret, currentSection());
@ -103,8 +105,8 @@ public class CreateRegistrate extends AbstractRegistrate<CreateRegistrate> {
}
public <R extends IForgeRegistryEntry<R>> Collection<RegistryEntry<R>> getAll(AllSections section,
Class<? super R> registryType) {
return this.<R>getAll(registryType)
ResourceKey<? extends Registry<R>> registryType) {
return this.getAll(registryType)
.stream()
.filter(e -> getSection(e) == section)
.collect(Collectors.toList());

View file

@ -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<ItemStack> items, boolean specialItems) {
Minecraft mc = Minecraft.getInstance();
ItemRenderer itemRenderer = mc.getItemRenderer();
ClientLevel world = mc.level;
ItemRenderer itemRenderer = Minecraft.getInstance().getItemRenderer();
for (RegistryEntry<? extends Item> 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<RegistryEntry<Block>> 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<RegistryEntry<Item>> getItems() {
return getSections().stream()
.flatMap(s -> Create.registrate()
.getAll(s, Item.class)
.getAll(s, Registry.ITEM_REGISTRY)
.stream())
.collect(Collectors.toList());
}