mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-11-09 19:44:40 +01:00
Remove PalettesRegistrate, can't have multiple datagens for same output
This commit is contained in:
parent
02d052ed44
commit
7f07a4af6e
16 changed files with 156 additions and 186 deletions
|
@ -6,7 +6,7 @@
|
|||
"entries": [
|
||||
{
|
||||
"type": "minecraft:item",
|
||||
"name": "minecraft:air"
|
||||
"name": "create:belt_funnel"
|
||||
}
|
||||
],
|
||||
"conditions": [
|
||||
|
|
|
@ -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<Block> {
|
||||
|
||||
|
@ -464,7 +462,7 @@ public enum AllBlocks implements NonNullSupplier<Block> {
|
|||
for (AllBlocks block : values())
|
||||
if (block.get() instanceof IHaveColorHandler)
|
||||
blockColors.register(((IHaveColorHandler) block.get()).getColorHandler(), block.get());
|
||||
for (RegistryEntry<Block> registryEntry : Create.palettesRegistrate()
|
||||
for (RegistryEntry<Block> registryEntry : Create.registrate()
|
||||
.getAll(Block.class)) {
|
||||
Block blockEntry = registryEntry.get();
|
||||
if (blockEntry instanceof IHaveColorHandler) {
|
||||
|
|
|
@ -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<OxidizingBlock> 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();
|
||||
|
||||
|
|
|
@ -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<CreateRegistrate> registrate = CreateRegistrate.lazy(ID);
|
||||
private static final NonNullLazyValue<PalettesRegistrate> 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);
|
||||
}
|
||||
|
|
|
@ -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<RegistryEntry<Block>> getBlocks() {
|
||||
return Create.registrate().getAll(Block.class);
|
||||
protected EnumSet<Sections> getSections() {
|
||||
return EnumSet.complementOf(EnumSet.of(Sections.PALETTES));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -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<RegistryEntry<Block>> getBlocks();
|
||||
protected Collection<RegistryEntry<Block>> getBlocks() {
|
||||
return getSections().stream()
|
||||
.flatMap(s -> Create.registrate().getAll(s, Block.class).stream())
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
protected EnumSet<Sections> getSections() {
|
||||
return EnumSet.allOf(Sections.class);
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void addItems(NonNullList<ItemStack> items, boolean specialItems) {
|
||||
|
|
|
@ -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<CreateRegistrate> {
|
||||
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<CreateRegistrate> {
|
||||
|
||||
public static NonNullLazyValue<CreateRegistrate> 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<RegistryEntry<?>, Sections> sectionLookup = new IdentityHashMap<>();
|
||||
private Sections section;
|
||||
|
||||
public CreateRegistrate startSection(Sections section) {
|
||||
this.section = section;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Sections currentSection() {
|
||||
return section;
|
||||
}
|
||||
|
||||
@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,
|
||||
NonNullFunction<RegistryObject<T>, ? extends RegistryEntry<T>> entryFactory) {
|
||||
RegistryEntry<T> 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 <R extends IForgeRegistryEntry<R>> Collection<RegistryEntry<R>> getAll(Sections section, Class<? super R> registryType) {
|
||||
return this.<R>getAll(registryType).stream()
|
||||
.filter(e -> getSection(e) == section)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/* Palettes */
|
||||
|
||||
public <T extends Block> BlockBuilder<T, CreateRegistrate> baseBlock(String name,
|
||||
NonNullFunction<Properties, T> factory, NonNullSupplier<Block> 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 <T extends Block> NonNullUnaryOperator<BlockBuilder<T, CreateRegistrate>> 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));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<S extends CreateRegistrateBase<S>> extends AbstractRegistrate<S> {
|
||||
|
||||
protected CreateRegistrateBase(String modid, NonNullSupplier<ItemGroup> creativeTab) {
|
||||
super(modid);
|
||||
registerEventListeners(FMLJavaModLoadingContext.get()
|
||||
.getModEventBus());
|
||||
itemGroup(creativeTab);
|
||||
}
|
||||
|
||||
/* Section Tracking */
|
||||
|
||||
private static Map<RegistryEntry<?>, Sections> sectionLookup = new IdentityHashMap<>();
|
||||
private Sections section;
|
||||
|
||||
public void startSection(Sections section) {
|
||||
this.section = section;
|
||||
}
|
||||
|
||||
public Sections currentSection() {
|
||||
return section;
|
||||
}
|
||||
|
||||
@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,
|
||||
NonNullFunction<RegistryObject<T>, ? extends RegistryEntry<T>> entryFactory) {
|
||||
RegistryEntry<T> 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);
|
||||
}
|
||||
}
|
|
@ -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<WindowBlock> woodenWindowBlock(WoodType woodType) {
|
||||
return woodenWindowBlock(woodType, () -> RenderType::getCutoutMipped);
|
||||
|
@ -114,7 +114,7 @@ public class WindowGen {
|
|||
ResourceLocation topTexture, Supplier<Supplier<RenderType>> renderType) {
|
||||
NonNullBiConsumer<DataGenContext<Block, GlassPaneBlock>, RegistrateBlockstateProvider> stateProvider =
|
||||
(c, p) -> p.paneBlock(c.get(), sideTexture, topTexture);
|
||||
NonNullUnaryOperator<BlockBuilder<GlassPaneBlock, PalettesRegistrate>> connectedTextures = b -> b;
|
||||
NonNullUnaryOperator<BlockBuilder<GlassPaneBlock, CreateRegistrate>> connectedTextures = b -> b;
|
||||
return glassPane(name, sideTexture, topTexture, GlassPaneBlock::new, renderType, connectedTextures,
|
||||
stateProvider);
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ public class WindowGen {
|
|||
private static BlockEntry<ConnectedGlassPaneBlock> connectedGlassPane(String name, CTSpriteShiftEntry ctshift,
|
||||
ResourceLocation sideTexture, ResourceLocation itemSideTexture, ResourceLocation topTexture,
|
||||
Supplier<Supplier<RenderType>> renderType) {
|
||||
NonNullUnaryOperator<BlockBuilder<ConnectedGlassPaneBlock, PalettesRegistrate>> connectedTextures =
|
||||
NonNullUnaryOperator<BlockBuilder<ConnectedGlassPaneBlock, CreateRegistrate>> 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 <G extends GlassPaneBlock> BlockEntry<G> glassPane(String name, ResourceLocation sideTexture,
|
||||
ResourceLocation topTexture, NonNullFunction<Properties, G> factory, Supplier<Supplier<RenderType>> renderType,
|
||||
NonNullUnaryOperator<BlockBuilder<G, PalettesRegistrate>> connectedTextures,
|
||||
NonNullUnaryOperator<BlockBuilder<G, CreateRegistrate>> connectedTextures,
|
||||
NonNullBiConsumer<DataGenContext<Block, G>, RegistrateBlockstateProvider> stateProvider) {
|
||||
name += "_pane";
|
||||
|
||||
|
|
|
@ -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)),
|
||||
|
|
|
@ -12,7 +12,7 @@ public class CountedOreFeature extends OreFeature<CountRangeConfig> {
|
|||
|
||||
private ConfigInt clusterCount;
|
||||
|
||||
public CountedOreFeature(NonNullSupplier<Block> block, int clusterSize, int clusterCount) {
|
||||
public CountedOreFeature(NonNullSupplier<? extends Block> block, int clusterSize, int clusterCount) {
|
||||
super(block, clusterSize);
|
||||
this.clusterCount = i(clusterCount, 0, "clusterCount");
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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<B extends Block> {
|
|||
this.name = name;
|
||||
}
|
||||
|
||||
public @NonnullType BlockBuilder<B, PalettesRegistrate> create(String variantName, PaletteBlockPatterns pattern,
|
||||
public @NonnullType BlockBuilder<B, CreateRegistrate> create(String variantName, PaletteBlockPatterns pattern,
|
||||
Supplier<? extends Block> 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<B extends Block> {
|
|||
return pattern.toLocation(variantName, pattern.getTextureForPartials());
|
||||
}
|
||||
|
||||
protected BlockBuilder<B, PalettesRegistrate> transformBlock(BlockBuilder<B, PalettesRegistrate> builder,
|
||||
protected BlockBuilder<B, CreateRegistrate> transformBlock(BlockBuilder<B, CreateRegistrate> builder,
|
||||
String variantName, PaletteBlockPatterns pattern) {
|
||||
getBlockTags().forEach(builder::tag);
|
||||
return builder;
|
||||
}
|
||||
|
||||
protected ItemBuilder<BlockItem, BlockBuilder<B, PalettesRegistrate>> transformItem(
|
||||
ItemBuilder<BlockItem, BlockBuilder<B, PalettesRegistrate>> builder, String variantName,
|
||||
protected ItemBuilder<BlockItem, BlockBuilder<B, CreateRegistrate>> transformItem(
|
||||
ItemBuilder<BlockItem, BlockBuilder<B, CreateRegistrate>> builder, String variantName,
|
||||
PaletteBlockPatterns pattern) {
|
||||
getItemTags().forEach(builder::tag);
|
||||
return builder;
|
||||
|
@ -172,8 +173,8 @@ public abstract class PaletteBlockPartial<B extends Block> {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected ItemBuilder<BlockItem, BlockBuilder<WallBlock, PalettesRegistrate>> transformItem(
|
||||
ItemBuilder<BlockItem, BlockBuilder<WallBlock, PalettesRegistrate>> builder, String variantName,
|
||||
protected ItemBuilder<BlockItem, BlockBuilder<WallBlock, CreateRegistrate>> transformItem(
|
||||
ItemBuilder<BlockItem, BlockBuilder<WallBlock, CreateRegistrate>> builder, String variantName,
|
||||
PaletteBlockPatterns pattern) {
|
||||
builder.model((c, p) -> p.wallInventory(c.getName(), getMainTexture(variantName, pattern)));
|
||||
return super.transformItem(builder, variantName, pattern);
|
||||
|
|
|
@ -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<RegistryEntry<Block>> getBlocks() {
|
||||
return Create.palettesRegistrate()
|
||||
.getAll(Block.class);
|
||||
protected EnumSet<Sections> getSections() {
|
||||
return EnumSet.of(Sections.PALETTES);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -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<PalettesRegistrate> {
|
||||
|
||||
protected PalettesRegistrate(String modid) {
|
||||
super(modid, () -> Create.palettesCreativeTab);
|
||||
}
|
||||
|
||||
public static NonNullLazyValue<PalettesRegistrate> lazy(String modid) {
|
||||
return new NonNullLazyValue<>(() -> new PalettesRegistrate(modid));
|
||||
}
|
||||
|
||||
public <T extends Block> BlockBuilder<T, PalettesRegistrate> baseBlock(String name,
|
||||
NonNullFunction<Properties, T> factory, NonNullSupplier<Block> 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 <T extends Block> NonNullUnaryOperator<BlockBuilder<T, PalettesRegistrate>> 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));
|
||||
}
|
||||
}
|
|
@ -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<BlockEntry<? extends Block>> registeredPartials = ImmutableList.builder();
|
||||
for (PaletteBlockPatterns pattern : patterns) {
|
||||
|
||||
PalettesRegistrate registrate = Create.palettesRegistrate();
|
||||
BlockBuilder<? extends Block, PalettesRegistrate> builder =
|
||||
CreateRegistrate registrate = Create.registrate();
|
||||
BlockBuilder<? extends Block, CreateRegistrate> builder =
|
||||
registrate.block(pattern.createName(name), pattern.getBlockFactory())
|
||||
.blockstate(pattern.getBlockStateGenerator()
|
||||
.apply(pattern)
|
||||
|
|
Loading…
Reference in a new issue