mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-28 16:06:48 +01:00
ColorRegistrate
- Added support for Block & ItemColors in CreateRegistrate - Updated forge and removed obsolete warning suppressions - Fixed mossy & overgrown block items not having their foliage layer coloured
This commit is contained in:
parent
61aab48cdb
commit
e9c26eed0a
18 changed files with 180 additions and 72 deletions
|
@ -95,7 +95,7 @@ configurations {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
minecraft 'net.minecraftforge:forge:1.15.2-31.2.0'
|
minecraft 'net.minecraftforge:forge:1.15.2-31.2.3'
|
||||||
|
|
||||||
def registrate = "com.tterrag.registrate:Registrate:MC1.15.2-0.0.3.11"
|
def registrate = "com.tterrag.registrate:Registrate:MC1.15.2-0.0.3.11"
|
||||||
implementation fg.deobf(registrate)
|
implementation fg.deobf(registrate)
|
||||||
|
|
|
@ -1419,8 +1419,8 @@ cb315814960850b5080598b89ee94c833b5048f7 data\create\loot_tables\blocks\limeston
|
||||||
8db1e3f0dac48b91a4839206a7d5a88cef415fdc data\create\loot_tables\blocks\limestone_cobblestone_stairs.json
|
8db1e3f0dac48b91a4839206a7d5a88cef415fdc data\create\loot_tables\blocks\limestone_cobblestone_stairs.json
|
||||||
92fb16606f289ad33860270d098fad2522b24e09 data\create\loot_tables\blocks\limestone_cobblestone_wall.json
|
92fb16606f289ad33860270d098fad2522b24e09 data\create\loot_tables\blocks\limestone_cobblestone_wall.json
|
||||||
371115e5ceb08c07a9ab2371509960c31e0baa8a data\create\loot_tables\blocks\limestone_pillar.json
|
371115e5ceb08c07a9ab2371509960c31e0baa8a data\create\loot_tables\blocks\limestone_pillar.json
|
||||||
205f5899101262f31f5c1a88bb7d954918d08d04 data\create\loot_tables\blocks\linked_extractor.json
|
dac789cf53b00eed34308848b5e267b7ccec090c data\create\loot_tables\blocks\linked_extractor.json
|
||||||
205f5899101262f31f5c1a88bb7d954918d08d04 data\create\loot_tables\blocks\linked_transposer.json
|
7af5a13c9e10903b11732fbc01ae3299328216f0 data\create\loot_tables\blocks\linked_transposer.json
|
||||||
90ddf7b5c3b61758a4ad12a1e6ef16fe6ebf7794 data\create\loot_tables\blocks\mechanical_bearing.json
|
90ddf7b5c3b61758a4ad12a1e6ef16fe6ebf7794 data\create\loot_tables\blocks\mechanical_bearing.json
|
||||||
e93872a90e4f4642a003539e7db28fdacfdcd114 data\create\loot_tables\blocks\mechanical_crafter.json
|
e93872a90e4f4642a003539e7db28fdacfdcd114 data\create\loot_tables\blocks\mechanical_crafter.json
|
||||||
b12efeeef5682966016ce6ea2d171eecd33d9667 data\create\loot_tables\blocks\mechanical_mixer.json
|
b12efeeef5682966016ce6ea2d171eecd33d9667 data\create\loot_tables\blocks\mechanical_mixer.json
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
"entries": [
|
"entries": [
|
||||||
{
|
{
|
||||||
"type": "minecraft:item",
|
"type": "minecraft:item",
|
||||||
"name": "minecraft:air"
|
"name": "create:linked_extractor"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"conditions": [
|
"conditions": [
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
"entries": [
|
"entries": [
|
||||||
{
|
{
|
||||||
"type": "minecraft:item",
|
"type": "minecraft:item",
|
||||||
"name": "minecraft:air"
|
"name": "create:linked_transposer"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"conditions": [
|
"conditions": [
|
||||||
|
|
99
src/main/java/com/simibubi/create/AllColorHandlers.java
Normal file
99
src/main/java/com/simibubi/create/AllColorHandlers.java
Normal file
|
@ -0,0 +1,99 @@
|
||||||
|
package com.simibubi.create;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.renderer.color.BlockColors;
|
||||||
|
import net.minecraft.client.renderer.color.IBlockColor;
|
||||||
|
import net.minecraft.client.renderer.color.IItemColor;
|
||||||
|
import net.minecraft.client.renderer.color.ItemColors;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.IItemProvider;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.GrassColors;
|
||||||
|
import net.minecraft.world.ILightReader;
|
||||||
|
import net.minecraft.world.biome.BiomeColors;
|
||||||
|
|
||||||
|
public class AllColorHandlers {
|
||||||
|
|
||||||
|
private static Map<Block, IBlockColor> coloredBlocks = new HashMap<>();
|
||||||
|
private static Map<IItemProvider, IItemColor> coloredItems = new HashMap<>();
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
|
public static IBlockColor getGrassyBlock() {
|
||||||
|
return new BlockColor(
|
||||||
|
(state, world, pos, layer) -> pos != null && world != null ? BiomeColors.getGrassColor(world, pos)
|
||||||
|
: GrassColors.get(0.5D, 1.0D));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IItemColor getGrassyItem() {
|
||||||
|
return new ItemColor((stack, layer) -> GrassColors.get(0.5D, 1.0D));
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
|
public static void register(Block block, IBlockColor color) {
|
||||||
|
coloredBlocks.put(block, color);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void register(IItemProvider item, IItemColor color) {
|
||||||
|
coloredItems.put(item, color);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void registerColorHandlers() {
|
||||||
|
BlockColors blockColors = Minecraft.getInstance()
|
||||||
|
.getBlockColors();
|
||||||
|
ItemColors itemColors = Minecraft.getInstance()
|
||||||
|
.getItemColors();
|
||||||
|
|
||||||
|
coloredBlocks.forEach((block, color) -> blockColors.register(color, block));
|
||||||
|
coloredItems.forEach((item, color) -> itemColors.register(color, item));
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
|
private static class ItemColor implements IItemColor {
|
||||||
|
|
||||||
|
private Function function;
|
||||||
|
|
||||||
|
@FunctionalInterface
|
||||||
|
interface Function {
|
||||||
|
int apply(ItemStack stack, int layer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemColor(Function function) {
|
||||||
|
this.function = function;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getColor(ItemStack stack, int layer) {
|
||||||
|
return function.apply(stack, layer);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class BlockColor implements IBlockColor {
|
||||||
|
|
||||||
|
private Function function;
|
||||||
|
|
||||||
|
@FunctionalInterface
|
||||||
|
interface Function {
|
||||||
|
int apply(BlockState state, ILightReader world, BlockPos pos, int layer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockColor(Function function) {
|
||||||
|
this.function = function;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getColor(BlockState state, ILightReader world, BlockPos pos, int layer) {
|
||||||
|
return function.apply(state, world, pos, layer);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -12,7 +12,6 @@ import com.simibubi.create.content.schematics.ClientSchematicLoader;
|
||||||
import com.simibubi.create.content.schematics.client.SchematicAndQuillHandler;
|
import com.simibubi.create.content.schematics.client.SchematicAndQuillHandler;
|
||||||
import com.simibubi.create.content.schematics.client.SchematicHandler;
|
import com.simibubi.create.content.schematics.client.SchematicHandler;
|
||||||
import com.simibubi.create.foundation.ResourceReloadHandler;
|
import com.simibubi.create.foundation.ResourceReloadHandler;
|
||||||
import com.simibubi.create.foundation.block.IHaveColorHandler;
|
|
||||||
import com.simibubi.create.foundation.block.render.CustomBlockModels;
|
import com.simibubi.create.foundation.block.render.CustomBlockModels;
|
||||||
import com.simibubi.create.foundation.block.render.SpriteShifter;
|
import com.simibubi.create.foundation.block.render.SpriteShifter;
|
||||||
import com.simibubi.create.foundation.item.IHaveCustomItemModel;
|
import com.simibubi.create.foundation.item.IHaveCustomItemModel;
|
||||||
|
@ -21,12 +20,10 @@ import com.simibubi.create.foundation.tileEntity.behaviour.linked.LinkRenderer;
|
||||||
import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.ScrollValueRenderer;
|
import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.ScrollValueRenderer;
|
||||||
import com.simibubi.create.foundation.utility.SuperByteBufferCache;
|
import com.simibubi.create.foundation.utility.SuperByteBufferCache;
|
||||||
import com.simibubi.create.foundation.utility.outliner.Outliner;
|
import com.simibubi.create.foundation.utility.outliner.Outliner;
|
||||||
import com.tterrag.registrate.util.entry.RegistryEntry;
|
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.BlockModelShapes;
|
import net.minecraft.client.renderer.BlockModelShapes;
|
||||||
import net.minecraft.client.renderer.color.BlockColors;
|
|
||||||
import net.minecraft.client.renderer.model.IBakedModel;
|
import net.minecraft.client.renderer.model.IBakedModel;
|
||||||
import net.minecraft.client.renderer.model.ModelResourceLocation;
|
import net.minecraft.client.renderer.model.ModelResourceLocation;
|
||||||
import net.minecraft.inventory.container.PlayerContainer;
|
import net.minecraft.inventory.container.PlayerContainer;
|
||||||
|
@ -77,7 +74,7 @@ public class CreateClient {
|
||||||
AllTileEntities.registerRenderers();
|
AllTileEntities.registerRenderers();
|
||||||
AllItems.registerColorHandlers();
|
AllItems.registerColorHandlers();
|
||||||
AllEntityTypes.registerRenderers();
|
AllEntityTypes.registerRenderers();
|
||||||
registerColorHandlers();
|
AllColorHandlers.registerColorHandlers();
|
||||||
|
|
||||||
IResourceManager resourceManager = Minecraft.getInstance()
|
IResourceManager resourceManager = Minecraft.getInstance()
|
||||||
.getResourceManager();
|
.getResourceManager();
|
||||||
|
@ -171,19 +168,6 @@ public class CreateClient {
|
||||||
swapModels(modelRegistry, location, factory);
|
swapModels(modelRegistry, location, factory);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
|
||||||
protected static void registerColorHandlers() {
|
|
||||||
BlockColors blockColors = Minecraft.getInstance()
|
|
||||||
.getBlockColors();
|
|
||||||
for (RegistryEntry<Block> registryEntry : Create.registrate()
|
|
||||||
.getAll(Block.class)) {
|
|
||||||
Block blockEntry = registryEntry.get();
|
|
||||||
if (blockEntry instanceof IHaveColorHandler) {
|
|
||||||
blockColors.register(((IHaveColorHandler) blockEntry).getColorHandler(), blockEntry);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static CustomBlockModels getCustomBlockModels() {
|
public static CustomBlockModels getCustomBlockModels() {
|
||||||
if (customBlockModels == null)
|
if (customBlockModels == null)
|
||||||
|
|
|
@ -25,7 +25,6 @@ import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.Rotation;
|
import net.minecraft.util.Rotation;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public class SawTileEntityRenderer extends SafeTileEntityRenderer<SawTileEntity> {
|
public class SawTileEntityRenderer extends SafeTileEntityRenderer<SawTileEntity> {
|
||||||
|
|
||||||
public SawTileEntityRenderer(TileEntityRendererDispatcher dispatcher) {
|
public SawTileEntityRenderer(TileEntityRendererDispatcher dispatcher) {
|
||||||
|
|
|
@ -17,7 +17,6 @@ import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraftforge.items.IItemHandlerModifiable;
|
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||||
import net.minecraftforge.items.ItemStackHandler;
|
import net.minecraftforge.items.ItemStackHandler;
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public class BasinTileEntityRenderer extends SafeTileEntityRenderer<BasinTileEntity> {
|
public class BasinTileEntityRenderer extends SafeTileEntityRenderer<BasinTileEntity> {
|
||||||
|
|
||||||
public BasinTileEntityRenderer(TileEntityRendererDispatcher dispatcher) {
|
public BasinTileEntityRenderer(TileEntityRendererDispatcher dispatcher) {
|
||||||
|
|
|
@ -17,7 +17,6 @@ import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public class SandPaperItemRenderer extends ItemStackTileEntityRenderer {
|
public class SandPaperItemRenderer extends ItemStackTileEntityRenderer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -25,7 +25,6 @@ import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.HandSide;
|
import net.minecraft.util.HandSide;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public class BlockzapperItemRenderer extends ZapperItemRenderer {
|
public class BlockzapperItemRenderer extends ZapperItemRenderer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -16,7 +16,6 @@ import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.HandSide;
|
import net.minecraft.util.HandSide;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public class TerrainzapperItemRenderer extends ZapperItemRenderer {
|
public class TerrainzapperItemRenderer extends ZapperItemRenderer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,22 +0,0 @@
|
||||||
package com.simibubi.create.content.palettes;
|
|
||||||
|
|
||||||
import com.simibubi.create.foundation.block.IHaveColorHandler;
|
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.client.renderer.color.IBlockColor;
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
|
||||||
|
|
||||||
public class MossyBlock extends Block implements IHaveColorHandler {
|
|
||||||
|
|
||||||
public MossyBlock(Properties p_i48440_1_) {
|
|
||||||
super(p_i48440_1_);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
|
||||||
public IBlockColor getColorHandler() {
|
|
||||||
return new StandardFoliageColorHandler();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -57,14 +57,14 @@ public class PaletteBlockPatterns {
|
||||||
.textures("pillar", "pillar_end"),
|
.textures("pillar", "pillar_end"),
|
||||||
|
|
||||||
MOSSY = create("mossy", Prefix).blockStateFactory(p -> p::cubeAllButMossy)
|
MOSSY = create("mossy", Prefix).blockStateFactory(p -> p::cubeAllButMossy)
|
||||||
.block(MossyBlock::new)
|
|
||||||
.textures("bricks", "mossy")
|
.textures("bricks", "mossy")
|
||||||
.useTranslucentLayer(),
|
.useTranslucentLayer()
|
||||||
|
.withFoliage(),
|
||||||
|
|
||||||
OVERGROWN = create("overgrown", Prefix).blockStateFactory(p -> p::cubeAllButMossy)
|
OVERGROWN = create("overgrown", Prefix).blockStateFactory(p -> p::cubeAllButMossy)
|
||||||
.block(MossyBlock::new)
|
|
||||||
.textures("bricks", "overgrown")
|
.textures("bricks", "overgrown")
|
||||||
.useTranslucentLayer()
|
.useTranslucentLayer()
|
||||||
|
.withFoliage()
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -81,6 +81,7 @@ public class PaletteBlockPatterns {
|
||||||
private String[] textures;
|
private String[] textures;
|
||||||
private String id;
|
private String id;
|
||||||
private boolean isTranslucent;
|
private boolean isTranslucent;
|
||||||
|
private boolean hasFoliage;
|
||||||
private Optional<Function<PaletteStoneVariants, ConnectedTextureBehaviour>> ctBehaviour;
|
private Optional<Function<PaletteStoneVariants, ConnectedTextureBehaviour>> ctBehaviour;
|
||||||
|
|
||||||
private IPatternBlockStateGenerator blockStateGenerator;
|
private IPatternBlockStateGenerator blockStateGenerator;
|
||||||
|
@ -98,6 +99,7 @@ public class PaletteBlockPatterns {
|
||||||
pattern.nameType = nameType;
|
pattern.nameType = nameType;
|
||||||
pattern.partials = partials;
|
pattern.partials = partials;
|
||||||
pattern.isTranslucent = false;
|
pattern.isTranslucent = false;
|
||||||
|
pattern.hasFoliage = false;
|
||||||
pattern.blockFactory = Block::new;
|
pattern.blockFactory = Block::new;
|
||||||
pattern.textures = new String[] { name };
|
pattern.textures = new String[] { name };
|
||||||
pattern.blockStateGenerator = p -> p::cubeAll;
|
pattern.blockStateGenerator = p -> p::cubeAll;
|
||||||
|
@ -111,6 +113,10 @@ public class PaletteBlockPatterns {
|
||||||
public boolean isTranslucent() {
|
public boolean isTranslucent() {
|
||||||
return isTranslucent;
|
return isTranslucent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasFoliage() {
|
||||||
|
return hasFoliage;
|
||||||
|
}
|
||||||
|
|
||||||
public NonNullFunction<Properties, ? extends Block> getBlockFactory() {
|
public NonNullFunction<Properties, ? extends Block> getBlockFactory() {
|
||||||
return blockFactory;
|
return blockFactory;
|
||||||
|
@ -150,6 +156,11 @@ public class PaletteBlockPatterns {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private PaletteBlockPatterns withFoliage() {
|
||||||
|
hasFoliage = true;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
private PaletteBlockPatterns connectedTextures(Function<PaletteStoneVariants, ConnectedTextureBehaviour> factory) {
|
private PaletteBlockPatterns connectedTextures(Function<PaletteStoneVariants, ConnectedTextureBehaviour> factory) {
|
||||||
this.ctBehaviour = Optional.of(factory);
|
this.ctBehaviour = Optional.of(factory);
|
||||||
return this;
|
return this;
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.simibubi.create.content.palettes;
|
||||||
import static com.simibubi.create.foundation.data.CreateRegistrate.connectedTextures;
|
import static com.simibubi.create.foundation.data.CreateRegistrate.connectedTextures;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import com.simibubi.create.AllColorHandlers;
|
||||||
import com.simibubi.create.Create;
|
import com.simibubi.create.Create;
|
||||||
import com.simibubi.create.foundation.data.CreateRegistrate;
|
import com.simibubi.create.foundation.data.CreateRegistrate;
|
||||||
import com.simibubi.create.foundation.utility.Lang;
|
import com.simibubi.create.foundation.utility.Lang;
|
||||||
|
@ -29,18 +30,26 @@ public class PalettesVariantEntry {
|
||||||
CreateRegistrate registrate = Create.registrate();
|
CreateRegistrate registrate = Create.registrate();
|
||||||
BlockBuilder<? extends Block, CreateRegistrate> builder =
|
BlockBuilder<? extends Block, CreateRegistrate> builder =
|
||||||
registrate.block(pattern.createName(name), pattern.getBlockFactory())
|
registrate.block(pattern.createName(name), pattern.getBlockFactory())
|
||||||
|
.initialProperties(initialProperties)
|
||||||
.blockstate(pattern.getBlockStateGenerator()
|
.blockstate(pattern.getBlockStateGenerator()
|
||||||
.apply(pattern)
|
.apply(pattern)
|
||||||
.apply(name)::accept);
|
.apply(name)::accept);
|
||||||
|
|
||||||
if (pattern.isTranslucent())
|
if (pattern.isTranslucent())
|
||||||
builder.addLayer(() -> RenderType::getTranslucent);
|
builder.addLayer(() -> RenderType::getTranslucent);
|
||||||
|
if (pattern.hasFoliage())
|
||||||
|
builder.transform(CreateRegistrate.blockColors(() -> AllColorHandlers::getGrassyBlock));
|
||||||
pattern.createCTBehaviour(variant)
|
pattern.createCTBehaviour(variant)
|
||||||
.ifPresent(b -> builder.transform(connectedTextures(b)));
|
.ifPresent(b -> builder.transform(connectedTextures(b)));
|
||||||
|
|
||||||
BlockEntry<? extends Block> block = builder.initialProperties(initialProperties)
|
if (pattern.hasFoliage())
|
||||||
.simpleItem()
|
builder.item()
|
||||||
.register();
|
.transform(CreateRegistrate.itemColors(() -> AllColorHandlers::getGrassyItem)::apply)
|
||||||
|
.build();
|
||||||
|
else
|
||||||
|
builder.simpleItem();
|
||||||
|
|
||||||
|
BlockEntry<? extends Block> block = builder.register();
|
||||||
registeredBlocks.add(block);
|
registeredBlocks.add(block);
|
||||||
|
|
||||||
for (PaletteBlockPartial<? extends Block> partialBlock : pattern.getPartials())
|
for (PaletteBlockPartial<? extends Block> partialBlock : pattern.getPartials())
|
||||||
|
|
|
@ -15,7 +15,6 @@ import net.minecraft.util.Direction;
|
||||||
import net.minecraftforge.client.model.data.EmptyModelData;
|
import net.minecraftforge.client.model.data.EmptyModelData;
|
||||||
import net.minecraftforge.client.model.data.IModelData;
|
import net.minecraftforge.client.model.data.IModelData;
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public class WrappedBakedModel implements IBakedModel {
|
public class WrappedBakedModel implements IBakedModel {
|
||||||
|
|
||||||
protected IBakedModel template;
|
protected IBakedModel template;
|
||||||
|
|
|
@ -4,8 +4,10 @@ import java.util.Collection;
|
||||||
import java.util.IdentityHashMap;
|
import java.util.IdentityHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
import java.util.function.Supplier;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import com.simibubi.create.AllColorHandlers;
|
||||||
import com.simibubi.create.CreateClient;
|
import com.simibubi.create.CreateClient;
|
||||||
import com.simibubi.create.content.AllSections;
|
import com.simibubi.create.content.AllSections;
|
||||||
import com.simibubi.create.foundation.block.connected.CTModel;
|
import com.simibubi.create.foundation.block.connected.CTModel;
|
||||||
|
@ -13,6 +15,7 @@ import com.simibubi.create.foundation.block.connected.ConnectedTextureBehaviour;
|
||||||
import com.tterrag.registrate.AbstractRegistrate;
|
import com.tterrag.registrate.AbstractRegistrate;
|
||||||
import com.tterrag.registrate.builders.BlockBuilder;
|
import com.tterrag.registrate.builders.BlockBuilder;
|
||||||
import com.tterrag.registrate.builders.Builder;
|
import com.tterrag.registrate.builders.Builder;
|
||||||
|
import com.tterrag.registrate.builders.ItemBuilder;
|
||||||
import com.tterrag.registrate.util.NonNullLazyValue;
|
import com.tterrag.registrate.util.NonNullLazyValue;
|
||||||
import com.tterrag.registrate.util.entry.RegistryEntry;
|
import com.tterrag.registrate.util.entry.RegistryEntry;
|
||||||
import com.tterrag.registrate.util.nullness.NonNullFunction;
|
import com.tterrag.registrate.util.nullness.NonNullFunction;
|
||||||
|
@ -21,6 +24,10 @@ import com.tterrag.registrate.util.nullness.NonNullUnaryOperator;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.Block.Properties;
|
import net.minecraft.block.Block.Properties;
|
||||||
|
import net.minecraft.client.renderer.color.IBlockColor;
|
||||||
|
import net.minecraft.client.renderer.color.IItemColor;
|
||||||
|
import net.minecraft.item.BlockItem;
|
||||||
|
import net.minecraft.util.IItemProvider;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
import net.minecraftforge.fml.DistExecutor;
|
import net.minecraftforge.fml.DistExecutor;
|
||||||
|
@ -35,8 +42,9 @@ public class CreateRegistrate extends AbstractRegistrate<CreateRegistrate> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static NonNullLazyValue<CreateRegistrate> lazy(String modid) {
|
public static NonNullLazyValue<CreateRegistrate> lazy(String modid) {
|
||||||
return new NonNullLazyValue<>(() -> new CreateRegistrate(modid)
|
return new NonNullLazyValue<>(
|
||||||
.registerEventListeners(FMLJavaModLoadingContext.get().getModEventBus()));
|
() -> new CreateRegistrate(modid).registerEventListeners(FMLJavaModLoadingContext.get()
|
||||||
|
.getModEventBus()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Section Tracking */
|
/* Section Tracking */
|
||||||
|
@ -55,8 +63,8 @@ public class CreateRegistrate extends AbstractRegistrate<CreateRegistrate> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected <R extends IForgeRegistryEntry<R>, T extends R> RegistryEntry<T> accept(String name,
|
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,
|
Class<? super R> type, Builder<R, T, ?, ?> builder, NonNullSupplier<? extends T> creator,
|
||||||
NonNullFunction<RegistryObject<T>, ? extends RegistryEntry<T>> entryFactory) {
|
NonNullFunction<RegistryObject<T>, ? extends RegistryEntry<T>> entryFactory) {
|
||||||
RegistryEntry<T> ret = super.accept(name, type, builder, creator, entryFactory);
|
RegistryEntry<T> ret = super.accept(name, type, builder, creator, entryFactory);
|
||||||
sectionLookup.put(ret, currentSection());
|
sectionLookup.put(ret, currentSection());
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -79,15 +87,17 @@ public class CreateRegistrate extends AbstractRegistrate<CreateRegistrate> {
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.orElse(AllSections.UNASSIGNED);
|
.orElse(AllSections.UNASSIGNED);
|
||||||
}
|
}
|
||||||
|
|
||||||
public <R extends IForgeRegistryEntry<R>> Collection<RegistryEntry<R>> getAll(AllSections section, Class<? super R> registryType) {
|
public <R extends IForgeRegistryEntry<R>> Collection<RegistryEntry<R>> getAll(AllSections section,
|
||||||
return this.<R>getAll(registryType).stream()
|
Class<? super R> registryType) {
|
||||||
.filter(e -> getSection(e) == section)
|
return this.<R>getAll(registryType)
|
||||||
.collect(Collectors.toList());
|
.stream()
|
||||||
|
.filter(e -> getSection(e) == section)
|
||||||
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Palettes */
|
/* Palettes */
|
||||||
|
|
||||||
public <T extends Block> BlockBuilder<T, CreateRegistrate> baseBlock(String name,
|
public <T extends Block> BlockBuilder<T, CreateRegistrate> baseBlock(String name,
|
||||||
NonNullFunction<Properties, T> factory, NonNullSupplier<Block> propertiesFrom) {
|
NonNullFunction<Properties, T> factory, NonNullSupplier<Block> propertiesFrom) {
|
||||||
return super.block(name, factory).initialProperties(propertiesFrom)
|
return super.block(name, factory).initialProperties(propertiesFrom)
|
||||||
|
@ -101,7 +111,21 @@ public class CreateRegistrate extends AbstractRegistrate<CreateRegistrate> {
|
||||||
|
|
||||||
public static <T extends Block> NonNullUnaryOperator<BlockBuilder<T, CreateRegistrate>> connectedTextures(
|
public static <T extends Block> NonNullUnaryOperator<BlockBuilder<T, CreateRegistrate>> connectedTextures(
|
||||||
ConnectedTextureBehaviour behavior) {
|
ConnectedTextureBehaviour behavior) {
|
||||||
return b -> b.onRegister(entry -> DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> registerModel(entry, behavior)));
|
return b -> b.onRegister(entry -> onClient(() -> () -> registerModel(entry, behavior)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T extends Block> NonNullUnaryOperator<BlockBuilder<T, CreateRegistrate>> blockColors(
|
||||||
|
Supplier<Supplier<IBlockColor>> colorFunc) {
|
||||||
|
return b -> b.onRegister(entry -> onClient(() -> () -> registerBlockColor(entry, colorFunc)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static NonNullUnaryOperator<ItemBuilder<? extends BlockItem, ?>> itemColors(
|
||||||
|
Supplier<Supplier<IItemColor>> colorFunc) {
|
||||||
|
return b -> b.onRegister(entry -> onClient(() -> () -> registerItemColor(entry, colorFunc)));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static void onClient(Supplier<Runnable> toRun) {
|
||||||
|
DistExecutor.runWhenOn(Dist.CLIENT, toRun);
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
|
@ -109,4 +133,17 @@ public class CreateRegistrate extends AbstractRegistrate<CreateRegistrate> {
|
||||||
CreateClient.getCustomBlockModels()
|
CreateClient.getCustomBlockModels()
|
||||||
.register(entry.delegate, model -> new CTModel(model, behavior));
|
.register(entry.delegate, model -> new CTModel(model, behavior));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OnlyIn(Dist.CLIENT)
|
||||||
|
private static void registerBlockColor(Block entry, Supplier<Supplier<IBlockColor>> colorFunc) {
|
||||||
|
AllColorHandlers.register(entry, colorFunc.get()
|
||||||
|
.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
@OnlyIn(Dist.CLIENT)
|
||||||
|
private static void registerItemColor(IItemProvider entry, Supplier<Supplier<IItemColor>> colorFunc) {
|
||||||
|
AllColorHandlers.register(entry, colorFunc.get()
|
||||||
|
.get());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,6 @@ import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.tags.BlockTags;
|
import net.minecraft.tags.BlockTags;
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public class ValueBoxRenderer {
|
public class ValueBoxRenderer {
|
||||||
|
|
||||||
public static void renderItemIntoValueBox(ItemStack filter, MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) {
|
public static void renderItemIntoValueBox(ItemStack filter, MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) {
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
{
|
|
||||||
"parent": "create:block/schematic_table"
|
|
||||||
}
|
|
Loading…
Reference in a new issue