package com.simibubi.create.modules.palettes; import com.google.common.collect.ImmutableList; import com.simibubi.create.Create; import com.simibubi.create.foundation.utility.Lang; import com.tterrag.registrate.builders.BlockBuilder; import com.tterrag.registrate.util.entry.BlockEntry; import com.tterrag.registrate.util.nullness.NonNullSupplier; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderType; public class PalettesVariantEntry { public ImmutableList> registeredBlocks; public ImmutableList> registeredPartials; public PalettesVariantEntry(PaletteStoneVariants variant, PaletteBlockPatterns[] patterns, NonNullSupplier initialProperties) { String name = Lang.asId(variant.name()); ImmutableList.Builder> registeredBlocks = ImmutableList.builder(); ImmutableList.Builder> registeredPartials = ImmutableList.builder(); for (PaletteBlockPatterns pattern : patterns) { PalettesRegistrate registrate = Create.palettesRegistrate(); BlockBuilder builder = registrate.block(pattern.createName(name), pattern.getBlockFactory()) .blockstate(pattern.getBlockStateGenerator() .apply(pattern) .apply(name)::accept); if (pattern.isTranslucent()) builder.addLayer(() -> RenderType::getTranslucent); pattern.createCTBehaviour(variant) .ifPresent(b -> { builder.transform(registrate.connectedTextures(b)); }); BlockEntry block = builder.initialProperties(initialProperties) .simpleItem() .register(); registeredBlocks.add(block); for (PaletteBlockPartial partialBlock : pattern.getPartials()) registeredPartials.add(partialBlock.create(name, pattern, block) .register()); } this.registeredBlocks = registeredBlocks.build(); this.registeredPartials = registeredPartials.build(); } }