diff --git a/src/generated/resources/data/create/loot_tables/blocks/belt_funnel.json b/src/generated/resources/data/create/loot_tables/blocks/belt_funnel.json index 78793172c..2015decf2 100644 --- a/src/generated/resources/data/create/loot_tables/blocks/belt_funnel.json +++ b/src/generated/resources/data/create/loot_tables/blocks/belt_funnel.json @@ -6,7 +6,7 @@ "entries": [ { "type": "minecraft:item", - "name": "minecraft:air" + "name": "create:belt_funnel" } ], "conditions": [ diff --git a/src/main/java/com/simibubi/create/AllBlocks.java b/src/main/java/com/simibubi/create/AllBlocks.java index aa7ae13f2..181132c0b 100644 --- a/src/main/java/com/simibubi/create/AllBlocks.java +++ b/src/main/java/com/simibubi/create/AllBlocks.java @@ -9,7 +9,6 @@ import com.simibubi.create.foundation.block.IHaveColorHandler; import com.simibubi.create.foundation.block.ProperStairsBlock; import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.data.ITaggable; -import com.simibubi.create.foundation.world.OxidizingBlock; import com.simibubi.create.modules.Sections; import com.simibubi.create.modules.contraptions.CasingBlock; import com.simibubi.create.modules.contraptions.components.actors.DrillBlock; @@ -98,7 +97,6 @@ import net.minecraft.tags.BlockTags; import net.minecraft.tags.Tag; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.common.ToolType; public enum AllBlocks implements NonNullSupplier { @@ -464,7 +462,7 @@ public enum AllBlocks implements NonNullSupplier { for (AllBlocks block : values()) if (block.get() instanceof IHaveColorHandler) blockColors.register(((IHaveColorHandler) block.get()).getColorHandler(), block.get()); - for (RegistryEntry registryEntry : Create.palettesRegistrate() + for (RegistryEntry registryEntry : Create.registrate() .getAll(Block.class)) { Block blockEntry = registryEntry.get(); if (blockEntry instanceof IHaveColorHandler) { diff --git a/src/main/java/com/simibubi/create/AllBlocksNew.java b/src/main/java/com/simibubi/create/AllBlocksNew.java index fdfbe4860..2d1adfceb 100644 --- a/src/main/java/com/simibubi/create/AllBlocksNew.java +++ b/src/main/java/com/simibubi/create/AllBlocksNew.java @@ -34,7 +34,8 @@ import net.minecraftforge.common.ToolType; public class AllBlocksNew { - private static final CreateRegistrate REGISTRATE = Create.registrate(); + private static final CreateRegistrate REGISTRATE = Create.registrate() + .itemGroup(() -> Create.baseCreativeTab); static { REGISTRATE.startSection(SCHEMATICS); @@ -138,6 +139,7 @@ public class AllBlocksNew { public static final BlockEntry COPPER_SHINGLES = REGISTRATE.block("copper_shingles", p -> new OxidizingBlock(p, 1 / 32f)) .initialProperties(() -> Blocks.IRON_BLOCK) + .simpleItem() .recipe((ctx, prov) -> prov.square(DataIngredient.tag(forgeItemTag("plates/copper")), ctx, true)) .register(); diff --git a/src/main/java/com/simibubi/create/Create.java b/src/main/java/com/simibubi/create/Create.java index 74e2e4c50..012ae5be0 100644 --- a/src/main/java/com/simibubi/create/Create.java +++ b/src/main/java/com/simibubi/create/Create.java @@ -13,7 +13,6 @@ import com.simibubi.create.modules.contraptions.TorquePropagator; import com.simibubi.create.modules.logistics.RedstoneLinkNetworkHandler; import com.simibubi.create.modules.palettes.AllPaletteBlocks; import com.simibubi.create.modules.palettes.PalettesItemGroup; -import com.simibubi.create.modules.palettes.PalettesRegistrate; import com.simibubi.create.modules.schematics.ServerSchematicLoader; import com.tterrag.registrate.util.NonNullLazyValue; @@ -50,7 +49,6 @@ public class Create { public static ServerLagger lagger; private static final NonNullLazyValue registrate = CreateRegistrate.lazy(ID); - private static final NonNullLazyValue palettesRegistrate = PalettesRegistrate.lazy(ID); public Create() { IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); @@ -109,10 +107,6 @@ public class Create { return registrate.get(); } - public static PalettesRegistrate palettesRegistrate() { - return palettesRegistrate.get(); - } - public static ResourceLocation asResource(String path) { return new ResourceLocation(ID, path); } diff --git a/src/main/java/com/simibubi/create/CreateItemGroup.java b/src/main/java/com/simibubi/create/CreateItemGroup.java index 64318e0e2..fa02f7267 100644 --- a/src/main/java/com/simibubi/create/CreateItemGroup.java +++ b/src/main/java/com/simibubi/create/CreateItemGroup.java @@ -1,10 +1,9 @@ package com.simibubi.create; -import java.util.Collection; +import java.util.EnumSet; -import com.tterrag.registrate.util.entry.RegistryEntry; +import com.simibubi.create.modules.Sections; -import net.minecraft.block.Block; import net.minecraft.item.ItemStack; public class CreateItemGroup extends CreateItemGroupBase { @@ -14,8 +13,8 @@ public class CreateItemGroup extends CreateItemGroupBase { } @Override - protected Collection> getBlocks() { - return Create.registrate().getAll(Block.class); + protected EnumSet getSections() { + return EnumSet.complementOf(EnumSet.of(Sections.PALETTES)); } @Override diff --git a/src/main/java/com/simibubi/create/CreateItemGroupBase.java b/src/main/java/com/simibubi/create/CreateItemGroupBase.java index 866db5ca3..6b8f01a0d 100644 --- a/src/main/java/com/simibubi/create/CreateItemGroupBase.java +++ b/src/main/java/com/simibubi/create/CreateItemGroupBase.java @@ -1,7 +1,10 @@ package com.simibubi.create; import java.util.Collection; +import java.util.EnumSet; +import java.util.stream.Collectors; +import com.simibubi.create.modules.Sections; import com.tterrag.registrate.util.entry.RegistryEntry; import net.minecraft.block.Block; @@ -42,7 +45,15 @@ public abstract class CreateItemGroupBase extends ItemGroup { } } - protected abstract Collection> getBlocks(); + protected Collection> getBlocks() { + return getSections().stream() + .flatMap(s -> Create.registrate().getAll(s, Block.class).stream()) + .collect(Collectors.toList()); + } + + protected EnumSet getSections() { + return EnumSet.allOf(Sections.class); + } @OnlyIn(Dist.CLIENT) public void addItems(NonNullList items, boolean specialItems) { diff --git a/src/main/java/com/simibubi/create/foundation/registrate/CreateRegistrate.java b/src/main/java/com/simibubi/create/foundation/registrate/CreateRegistrate.java index 53f3f0e39..92842cff6 100644 --- a/src/main/java/com/simibubi/create/foundation/registrate/CreateRegistrate.java +++ b/src/main/java/com/simibubi/create/foundation/registrate/CreateRegistrate.java @@ -1,25 +1,112 @@ package com.simibubi.create.foundation.registrate; -import com.simibubi.create.Create; +import java.util.Collection; +import java.util.IdentityHashMap; +import java.util.Map; +import java.util.Map.Entry; +import java.util.stream.Collectors; + +import com.simibubi.create.CreateClient; +import com.simibubi.create.foundation.block.connected.CTModel; +import com.simibubi.create.foundation.block.connected.ConnectedTextureBehaviour; +import com.simibubi.create.modules.Sections; +import com.tterrag.registrate.AbstractRegistrate; +import com.tterrag.registrate.builders.BlockBuilder; +import com.tterrag.registrate.builders.Builder; import com.tterrag.registrate.util.NonNullLazyValue; +import com.tterrag.registrate.util.entry.RegistryEntry; +import com.tterrag.registrate.util.nullness.NonNullFunction; +import com.tterrag.registrate.util.nullness.NonNullSupplier; +import com.tterrag.registrate.util.nullness.NonNullUnaryOperator; -public class CreateRegistrate extends CreateRegistrateBase { +import net.minecraft.block.Block; +import net.minecraft.block.Block.Properties; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraftforge.fml.DistExecutor; +import net.minecraftforge.fml.RegistryObject; +import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; +import net.minecraftforge.registries.IForgeRegistryEntry; - /** - * Create a new {@link CreateRegistrate} and register event listeners for - * registration and data generation. Used in lieu of adding side-effects to - * constructor, so that alternate initialization strategies can be done in - * subclasses. - * - * @param modid The mod ID for which objects will be registered - * @return The {@link CreateRegistrate} instance - */ - public CreateRegistrate(String modid) { - super(modid, () -> Create.baseCreativeTab); - } +public class CreateRegistrate extends AbstractRegistrate { public static NonNullLazyValue lazy(String modid) { - return new NonNullLazyValue<>(() -> new CreateRegistrate(modid)); + return new NonNullLazyValue<>(() -> new CreateRegistrate(modid) + .registerEventListeners(FMLJavaModLoadingContext.get().getModEventBus())); + } + + protected CreateRegistrate(String modid) { + super(modid); } + /* Section Tracking */ + + private static Map, Sections> sectionLookup = new IdentityHashMap<>(); + private Sections section; + + public CreateRegistrate startSection(Sections section) { + this.section = section; + return this; + } + + public Sections currentSection() { + return section; + } + + @Override + protected , T extends R> RegistryEntry accept(String name, + Class type, Builder builder, NonNullSupplier creator, + NonNullFunction, ? extends RegistryEntry> entryFactory) { + RegistryEntry ret = super.accept(name, type, builder, creator, entryFactory); + sectionLookup.put(ret, currentSection()); + return ret; + } + + public void addToSection(RegistryEntry entry, Sections section) { + sectionLookup.put(entry, section); + } + + public Sections getSection(RegistryEntry entry) { + return sectionLookup.getOrDefault(entry, Sections.UNASSIGNED); + } + + public Sections getSection(IForgeRegistryEntry entry) { + return sectionLookup.entrySet() + .stream() + .filter(e -> e.getKey() + .get() == entry) + .map(Entry::getValue) + .findFirst() + .orElse(Sections.UNASSIGNED); + } + + public > Collection> getAll(Sections section, Class registryType) { + return this.getAll(registryType).stream() + .filter(e -> getSection(e) == section) + .collect(Collectors.toList()); + } + + /* Palettes */ + + public BlockBuilder baseBlock(String name, + NonNullFunction factory, NonNullSupplier propertiesFrom) { + return super.block(name, factory).initialProperties(propertiesFrom) + .blockstate((c, p) -> { + final String location = "block/palettes/" + c.getName() + "/plain"; + p.simpleBlock(c.get(), p.models() + .cubeAll(c.getName(), p.modLoc(location))); + }) + .simpleItem(); + } + + public NonNullUnaryOperator> connectedTextures( + ConnectedTextureBehaviour behavior) { + return b -> b.onRegister(entry -> DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> registerModel(entry, behavior))); + } + + @OnlyIn(Dist.CLIENT) + private void registerModel(Block entry, ConnectedTextureBehaviour behavior) { + CreateClient.getCustomBlockModels() + .register(entry.delegate, model -> new CTModel(model, behavior)); + } } diff --git a/src/main/java/com/simibubi/create/foundation/registrate/CreateRegistrateBase.java b/src/main/java/com/simibubi/create/foundation/registrate/CreateRegistrateBase.java deleted file mode 100644 index b379190b5..000000000 --- a/src/main/java/com/simibubi/create/foundation/registrate/CreateRegistrateBase.java +++ /dev/null @@ -1,67 +0,0 @@ -package com.simibubi.create.foundation.registrate; - -import java.util.IdentityHashMap; -import java.util.Map; -import java.util.Map.Entry; - -import com.simibubi.create.modules.Sections; -import com.tterrag.registrate.AbstractRegistrate; -import com.tterrag.registrate.builders.Builder; -import com.tterrag.registrate.util.entry.RegistryEntry; -import com.tterrag.registrate.util.nullness.NonNullFunction; -import com.tterrag.registrate.util.nullness.NonNullSupplier; - -import net.minecraft.item.ItemGroup; -import net.minecraftforge.fml.RegistryObject; -import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; -import net.minecraftforge.registries.IForgeRegistryEntry; - -public class CreateRegistrateBase> extends AbstractRegistrate { - - protected CreateRegistrateBase(String modid, NonNullSupplier creativeTab) { - super(modid); - registerEventListeners(FMLJavaModLoadingContext.get() - .getModEventBus()); - itemGroup(creativeTab); - } - - /* Section Tracking */ - - private static Map, Sections> sectionLookup = new IdentityHashMap<>(); - private Sections section; - - public void startSection(Sections section) { - this.section = section; - } - - public Sections currentSection() { - return section; - } - - @Override - protected , T extends R> RegistryEntry accept(String name, - Class type, Builder builder, NonNullSupplier creator, - NonNullFunction, ? extends RegistryEntry> entryFactory) { - RegistryEntry ret = super.accept(name, type, builder, creator, entryFactory); - sectionLookup.put(ret, currentSection()); - return ret; - } - - public void addToSection(RegistryEntry entry, Sections section) { - sectionLookup.put(entry, section); - } - - public Sections getSection(RegistryEntry entry) { - return sectionLookup.getOrDefault(entry, Sections.UNASSIGNED); - } - - public Sections getSection(IForgeRegistryEntry entry) { - return sectionLookup.entrySet() - .stream() - .filter(e -> e.getKey() - .get() == entry) - .map(Entry::getValue) - .findFirst() - .orElse(Sections.UNASSIGNED); - } -} diff --git a/src/main/java/com/simibubi/create/foundation/utility/data/WindowGen.java b/src/main/java/com/simibubi/create/foundation/utility/data/WindowGen.java index 1a16a2d55..0a11e9e38 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/data/WindowGen.java +++ b/src/main/java/com/simibubi/create/foundation/utility/data/WindowGen.java @@ -3,16 +3,16 @@ package com.simibubi.create.foundation.utility.data; import java.util.function.Function; import java.util.function.Supplier; -import com.simibubi.create.Create; import com.simibubi.create.AllSpriteShifts; +import com.simibubi.create.Create; import com.simibubi.create.foundation.block.connected.CTSpriteShiftEntry; import com.simibubi.create.foundation.block.connected.ConnectedTextureBehaviour; import com.simibubi.create.foundation.block.connected.GlassPaneCTBehaviour; import com.simibubi.create.foundation.block.connected.HorizontalCTBehaviour; +import com.simibubi.create.foundation.registrate.CreateRegistrate; import com.simibubi.create.modules.palettes.ConnectedGlassBlock; import com.simibubi.create.modules.palettes.ConnectedGlassPaneBlock; import com.simibubi.create.modules.palettes.GlassPaneBlock; -import com.simibubi.create.modules.palettes.PalettesRegistrate; import com.simibubi.create.modules.palettes.WindowBlock; import com.tterrag.registrate.builders.BlockBuilder; import com.tterrag.registrate.providers.DataGenContext; @@ -32,7 +32,7 @@ import net.minecraftforge.client.model.generators.ModelFile; public class WindowGen { - private static final PalettesRegistrate REGISTRATE = Create.palettesRegistrate(); + private static final CreateRegistrate REGISTRATE = Create.registrate(); public static BlockEntry woodenWindowBlock(WoodType woodType) { return woodenWindowBlock(woodType, () -> RenderType::getCutoutMipped); @@ -114,7 +114,7 @@ public class WindowGen { ResourceLocation topTexture, Supplier> renderType) { NonNullBiConsumer, RegistrateBlockstateProvider> stateProvider = (c, p) -> p.paneBlock(c.get(), sideTexture, topTexture); - NonNullUnaryOperator> connectedTextures = b -> b; + NonNullUnaryOperator> connectedTextures = b -> b; return glassPane(name, sideTexture, topTexture, GlassPaneBlock::new, renderType, connectedTextures, stateProvider); } @@ -122,7 +122,7 @@ public class WindowGen { private static BlockEntry connectedGlassPane(String name, CTSpriteShiftEntry ctshift, ResourceLocation sideTexture, ResourceLocation itemSideTexture, ResourceLocation topTexture, Supplier> renderType) { - NonNullUnaryOperator> connectedTextures = + NonNullUnaryOperator> connectedTextures = REGISTRATE.connectedTextures(new GlassPaneCTBehaviour(ctshift)); String CGPparents = "block/connected_glass_pane/"; String prefix = name + "_pane_"; @@ -152,7 +152,7 @@ public class WindowGen { private static BlockEntry glassPane(String name, ResourceLocation sideTexture, ResourceLocation topTexture, NonNullFunction factory, Supplier> renderType, - NonNullUnaryOperator> connectedTextures, + NonNullUnaryOperator> connectedTextures, NonNullBiConsumer, RegistrateBlockstateProvider> stateProvider) { name += "_pane"; diff --git a/src/main/java/com/simibubi/create/foundation/world/AllWorldFeatures.java b/src/main/java/com/simibubi/create/foundation/world/AllWorldFeatures.java index ed9a4e833..c29376532 100644 --- a/src/main/java/com/simibubi/create/foundation/world/AllWorldFeatures.java +++ b/src/main/java/com/simibubi/create/foundation/world/AllWorldFeatures.java @@ -8,7 +8,7 @@ import java.util.HashMap; import java.util.Map; import java.util.Optional; -import com.simibubi.create.AllBlocks; +import com.simibubi.create.AllBlocksNew; import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.modules.palettes.AllPaletteBlocks; @@ -20,11 +20,11 @@ import net.minecraftforge.registries.ForgeRegistries; public enum AllWorldFeatures { - COPPER_ORE(new CountedOreFeature(AllBlocks.COPPER_ORE, 18, 2).between(40, 86)), - COPPER_ORE_OCEAN(new CountedOreFeature(AllBlocks.COPPER_ORE, 15, 4).between(20, 55).inBiomes(OCEAN)), + COPPER_ORE(new CountedOreFeature(AllBlocksNew.COPPER_ORE, 18, 2).between(40, 86)), + COPPER_ORE_OCEAN(new CountedOreFeature(AllBlocksNew.COPPER_ORE, 15, 4).between(20, 55).inBiomes(OCEAN)), - ZINC_ORE(new CountedOreFeature(AllBlocks.ZINC_ORE, 14, 4).between(15, 70)), - ZINC_ORE_DESERT(new CountedOreFeature(AllBlocks.ZINC_ORE, 17, 5).between(10, 85).inBiomes(DESERT)), + ZINC_ORE(new CountedOreFeature(AllBlocksNew.ZINC_ORE, 14, 4).between(15, 70)), + ZINC_ORE_DESERT(new CountedOreFeature(AllBlocksNew.ZINC_ORE, 17, 5).between(10, 85).inBiomes(DESERT)), LIMESTONE(new ChanceOreFeature(AllPaletteBlocks.LIMESTONE, 128, 1 / 32f).between(30, 70)), WEATHERED_LIMESTONE(new ChanceOreFeature(AllPaletteBlocks.WEATHERED_LIMESTONE, 128, 1 / 32f).between(10, 30)), diff --git a/src/main/java/com/simibubi/create/foundation/world/CountedOreFeature.java b/src/main/java/com/simibubi/create/foundation/world/CountedOreFeature.java index 609bc0af0..0bf98ec02 100644 --- a/src/main/java/com/simibubi/create/foundation/world/CountedOreFeature.java +++ b/src/main/java/com/simibubi/create/foundation/world/CountedOreFeature.java @@ -12,7 +12,7 @@ public class CountedOreFeature extends OreFeature { private ConfigInt clusterCount; - public CountedOreFeature(NonNullSupplier block, int clusterSize, int clusterCount) { + public CountedOreFeature(NonNullSupplier block, int clusterSize, int clusterCount) { super(block, clusterSize); this.clusterCount = i(clusterCount, 0, "clusterCount"); } diff --git a/src/main/java/com/simibubi/create/modules/palettes/AllPaletteBlocks.java b/src/main/java/com/simibubi/create/modules/palettes/AllPaletteBlocks.java index 28cee7fd9..3357858cb 100644 --- a/src/main/java/com/simibubi/create/modules/palettes/AllPaletteBlocks.java +++ b/src/main/java/com/simibubi/create/modules/palettes/AllPaletteBlocks.java @@ -7,12 +7,14 @@ import static com.simibubi.create.foundation.utility.data.WindowGen.framedGlassP import static com.simibubi.create.foundation.utility.data.WindowGen.woodenWindowBlock; import static com.simibubi.create.foundation.utility.data.WindowGen.woodenWindowPane; -import com.simibubi.create.Create; import com.simibubi.create.AllSpriteShifts; +import com.simibubi.create.Create; import com.simibubi.create.foundation.block.connected.HorizontalCTBehaviour; import com.simibubi.create.foundation.block.connected.StandardCTBehaviour; +import com.simibubi.create.foundation.registrate.CreateRegistrate; import com.simibubi.create.foundation.utility.data.BlockStateGen; import com.simibubi.create.foundation.utility.data.WindowGen; +import com.simibubi.create.modules.Sections; import com.tterrag.registrate.providers.DataGenContext; import com.tterrag.registrate.providers.RegistrateBlockstateProvider; import com.tterrag.registrate.util.entry.BlockEntry; @@ -28,7 +30,9 @@ import net.minecraft.util.ResourceLocation; public class AllPaletteBlocks { - private static final PalettesRegistrate REGISTRATE = Create.palettesRegistrate(); + private static final CreateRegistrate REGISTRATE = Create.registrate() + .itemGroup(() -> Create.palettesCreativeTab) + .startSection(Sections.PALETTES); // Windows and Glass diff --git a/src/main/java/com/simibubi/create/modules/palettes/PaletteBlockPartial.java b/src/main/java/com/simibubi/create/modules/palettes/PaletteBlockPartial.java index 96ba191a8..1eb35b7fa 100644 --- a/src/main/java/com/simibubi/create/modules/palettes/PaletteBlockPartial.java +++ b/src/main/java/com/simibubi/create/modules/palettes/PaletteBlockPartial.java @@ -4,6 +4,7 @@ import java.util.Arrays; import java.util.function.Supplier; import com.simibubi.create.Create; +import com.simibubi.create.foundation.registrate.CreateRegistrate; import com.tterrag.registrate.builders.BlockBuilder; import com.tterrag.registrate.builders.ItemBuilder; import com.tterrag.registrate.providers.DataGenContext; @@ -39,11 +40,11 @@ public abstract class PaletteBlockPartial { this.name = name; } - public @NonnullType BlockBuilder create(String variantName, PaletteBlockPatterns pattern, + public @NonnullType BlockBuilder create(String variantName, PaletteBlockPatterns pattern, Supplier block) { String patternName = pattern.createName(variantName); String blockName = patternName + "_" + this.name; - return Create.palettesRegistrate() + return Create.registrate() .block(blockName, p -> createBlock(block)) .blockstate((c, p) -> generateData(c, p, variantName, pattern, block)) .transform(b -> transformBlock(b, variantName, pattern)) @@ -56,14 +57,14 @@ public abstract class PaletteBlockPartial { return pattern.toLocation(variantName, pattern.getTextureForPartials()); } - protected BlockBuilder transformBlock(BlockBuilder builder, + protected BlockBuilder transformBlock(BlockBuilder builder, String variantName, PaletteBlockPatterns pattern) { getBlockTags().forEach(builder::tag); return builder; } - protected ItemBuilder> transformItem( - ItemBuilder> builder, String variantName, + protected ItemBuilder> transformItem( + ItemBuilder> builder, String variantName, PaletteBlockPatterns pattern) { getItemTags().forEach(builder::tag); return builder; @@ -172,8 +173,8 @@ public abstract class PaletteBlockPartial { } @Override - protected ItemBuilder> transformItem( - ItemBuilder> builder, String variantName, + protected ItemBuilder> transformItem( + ItemBuilder> builder, String variantName, PaletteBlockPatterns pattern) { builder.model((c, p) -> p.wallInventory(c.getName(), getMainTexture(variantName, pattern))); return super.transformItem(builder, variantName, pattern); diff --git a/src/main/java/com/simibubi/create/modules/palettes/PalettesItemGroup.java b/src/main/java/com/simibubi/create/modules/palettes/PalettesItemGroup.java index 959d86d96..7b6f03c98 100644 --- a/src/main/java/com/simibubi/create/modules/palettes/PalettesItemGroup.java +++ b/src/main/java/com/simibubi/create/modules/palettes/PalettesItemGroup.java @@ -1,12 +1,10 @@ package com.simibubi.create.modules.palettes; -import java.util.Collection; +import java.util.EnumSet; -import com.simibubi.create.Create; import com.simibubi.create.CreateItemGroupBase; -import com.tterrag.registrate.util.entry.RegistryEntry; +import com.simibubi.create.modules.Sections; -import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import net.minecraft.util.NonNullList; @@ -17,9 +15,8 @@ public class PalettesItemGroup extends CreateItemGroupBase { } @Override - protected Collection> getBlocks() { - return Create.palettesRegistrate() - .getAll(Block.class); + protected EnumSet getSections() { + return EnumSet.of(Sections.PALETTES); } @Override diff --git a/src/main/java/com/simibubi/create/modules/palettes/PalettesRegistrate.java b/src/main/java/com/simibubi/create/modules/palettes/PalettesRegistrate.java deleted file mode 100644 index da49109c2..000000000 --- a/src/main/java/com/simibubi/create/modules/palettes/PalettesRegistrate.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.simibubi.create.modules.palettes; - -import com.simibubi.create.Create; -import com.simibubi.create.CreateClient; -import com.simibubi.create.foundation.block.connected.CTModel; -import com.simibubi.create.foundation.block.connected.ConnectedTextureBehaviour; -import com.simibubi.create.foundation.registrate.CreateRegistrateBase; -import com.simibubi.create.modules.Sections; -import com.tterrag.registrate.builders.BlockBuilder; -import com.tterrag.registrate.util.NonNullLazyValue; -import com.tterrag.registrate.util.nullness.NonNullFunction; -import com.tterrag.registrate.util.nullness.NonNullSupplier; -import com.tterrag.registrate.util.nullness.NonNullUnaryOperator; - -import net.minecraft.block.Block; -import net.minecraft.block.Block.Properties; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.fml.DistExecutor; - -public class PalettesRegistrate extends CreateRegistrateBase { - - protected PalettesRegistrate(String modid) { - super(modid, () -> Create.palettesCreativeTab); - } - - public static NonNullLazyValue lazy(String modid) { - return new NonNullLazyValue<>(() -> new PalettesRegistrate(modid)); - } - - public BlockBuilder baseBlock(String name, - NonNullFunction factory, NonNullSupplier propertiesFrom) { - return super.block(name, factory).initialProperties(propertiesFrom) - .blockstate((c, p) -> { - final String location = "block/palettes/" + c.getName() + "/plain"; - p.simpleBlock(c.get(), p.models() - .cubeAll(c.getName(), p.modLoc(location))); - }) - .simpleItem(); - } - - @Override - public Sections currentSection() { - return Sections.PALETTES; - } - - public NonNullUnaryOperator> connectedTextures( - ConnectedTextureBehaviour behavior) { - return b -> b.onRegister(entry -> DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> registerModel(entry, behavior))); - } - - @OnlyIn(Dist.CLIENT) - private void registerModel(Block entry, ConnectedTextureBehaviour behavior) { - CreateClient.getCustomBlockModels() - .register(entry.delegate, model -> new CTModel(model, behavior)); - } -} diff --git a/src/main/java/com/simibubi/create/modules/palettes/PalettesVariantEntry.java b/src/main/java/com/simibubi/create/modules/palettes/PalettesVariantEntry.java index ce8d0ae15..b28f6cfba 100644 --- a/src/main/java/com/simibubi/create/modules/palettes/PalettesVariantEntry.java +++ b/src/main/java/com/simibubi/create/modules/palettes/PalettesVariantEntry.java @@ -2,6 +2,7 @@ package com.simibubi.create.modules.palettes; import com.google.common.collect.ImmutableList; import com.simibubi.create.Create; +import com.simibubi.create.foundation.registrate.CreateRegistrate; import com.simibubi.create.foundation.utility.Lang; import com.tterrag.registrate.builders.BlockBuilder; import com.tterrag.registrate.util.entry.BlockEntry; @@ -23,8 +24,8 @@ public class PalettesVariantEntry { ImmutableList.Builder> registeredPartials = ImmutableList.builder(); for (PaletteBlockPatterns pattern : patterns) { - PalettesRegistrate registrate = Create.palettesRegistrate(); - BlockBuilder builder = + CreateRegistrate registrate = Create.registrate(); + BlockBuilder builder = registrate.block(pattern.createName(name), pattern.getBlockFactory()) .blockstate(pattern.getBlockStateGenerator() .apply(pattern)