2020-05-23 14:02:38 +02:00
|
|
|
package com.simibubi.create.content.palettes;
|
2020-05-13 01:11:07 +02:00
|
|
|
|
2020-05-23 14:02:38 +02:00
|
|
|
import static com.simibubi.create.foundation.data.CreateRegistrate.connectedTextures;
|
2020-05-21 00:15:02 +02:00
|
|
|
|
2020-05-13 01:11:07 +02:00
|
|
|
import com.google.common.collect.ImmutableList;
|
2020-05-24 03:12:18 +02:00
|
|
|
import com.simibubi.create.AllColorHandlers;
|
2020-05-13 01:11:07 +02:00
|
|
|
import com.simibubi.create.Create;
|
2020-05-23 14:02:38 +02:00
|
|
|
import com.simibubi.create.foundation.data.CreateRegistrate;
|
2020-05-15 01:23:27 +02:00
|
|
|
import com.simibubi.create.foundation.utility.Lang;
|
2020-05-13 01:11:07 +02:00
|
|
|
import com.tterrag.registrate.builders.BlockBuilder;
|
|
|
|
import com.tterrag.registrate.util.entry.BlockEntry;
|
2020-05-15 01:23:27 +02:00
|
|
|
import com.tterrag.registrate.util.nullness.NonNullSupplier;
|
2020-05-13 01:11:07 +02:00
|
|
|
|
|
|
|
import net.minecraft.block.Block;
|
|
|
|
import net.minecraft.client.renderer.RenderType;
|
|
|
|
|
|
|
|
public class PalettesVariantEntry {
|
|
|
|
|
|
|
|
public ImmutableList<BlockEntry<? extends Block>> registeredBlocks;
|
2020-05-15 01:23:27 +02:00
|
|
|
public ImmutableList<BlockEntry<? extends Block>> registeredPartials;
|
2020-05-13 01:11:07 +02:00
|
|
|
|
2020-05-15 01:23:27 +02:00
|
|
|
public PalettesVariantEntry(PaletteStoneVariants variant, PaletteBlockPatterns[] patterns,
|
|
|
|
NonNullSupplier<? extends Block> initialProperties) {
|
2020-05-13 01:11:07 +02:00
|
|
|
|
2020-05-15 01:23:27 +02:00
|
|
|
String name = Lang.asId(variant.name());
|
2020-05-13 01:11:07 +02:00
|
|
|
ImmutableList.Builder<BlockEntry<? extends Block>> registeredBlocks = ImmutableList.builder();
|
2020-05-15 01:23:27 +02:00
|
|
|
ImmutableList.Builder<BlockEntry<? extends Block>> registeredPartials = ImmutableList.builder();
|
2020-05-13 01:11:07 +02:00
|
|
|
for (PaletteBlockPatterns pattern : patterns) {
|
|
|
|
|
2020-05-15 04:32:36 +02:00
|
|
|
CreateRegistrate registrate = Create.registrate();
|
|
|
|
BlockBuilder<? extends Block, CreateRegistrate> builder =
|
2020-05-15 01:23:27 +02:00
|
|
|
registrate.block(pattern.createName(name), pattern.getBlockFactory())
|
2020-05-24 03:12:18 +02:00
|
|
|
.initialProperties(initialProperties)
|
2020-05-13 01:11:07 +02:00
|
|
|
.blockstate(pattern.getBlockStateGenerator()
|
2020-05-15 01:23:27 +02:00
|
|
|
.apply(pattern)
|
|
|
|
.apply(name)::accept);
|
2020-05-13 01:11:07 +02:00
|
|
|
|
2020-05-14 01:23:15 +02:00
|
|
|
if (pattern.isTranslucent())
|
|
|
|
builder.addLayer(() -> RenderType::getTranslucent);
|
2020-05-24 03:12:18 +02:00
|
|
|
if (pattern.hasFoliage())
|
2020-05-28 01:29:26 +02:00
|
|
|
builder.onRegister(CreateRegistrate.blockColors(() -> AllColorHandlers::getGrassyBlock));
|
2020-05-15 01:23:27 +02:00
|
|
|
pattern.createCTBehaviour(variant)
|
2020-05-28 01:29:26 +02:00
|
|
|
.ifPresent(b -> builder.onRegister(connectedTextures(b)));
|
2020-05-15 01:23:27 +02:00
|
|
|
|
2020-05-24 03:12:18 +02:00
|
|
|
if (pattern.hasFoliage())
|
|
|
|
builder.item()
|
2020-05-28 01:29:26 +02:00
|
|
|
.onRegister(CreateRegistrate.itemColors(() -> AllColorHandlers::getGrassyItem))
|
|
|
|
.build();
|
2020-05-24 03:12:18 +02:00
|
|
|
else
|
|
|
|
builder.simpleItem();
|
|
|
|
|
|
|
|
BlockEntry<? extends Block> block = builder.register();
|
2020-05-15 01:23:27 +02:00
|
|
|
registeredBlocks.add(block);
|
|
|
|
|
|
|
|
for (PaletteBlockPartial<? extends Block> partialBlock : pattern.getPartials())
|
|
|
|
registeredPartials.add(partialBlock.create(name, pattern, block)
|
|
|
|
.register());
|
2020-05-13 01:11:07 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
this.registeredBlocks = registeredBlocks.build();
|
2020-05-15 01:23:27 +02:00
|
|
|
this.registeredPartials = registeredPartials.build();
|
2020-05-13 01:11:07 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|