Registrate colors and organized item rendering
- Use Registrate's block and item color registration instead of running the events manually - Move utility color handler methods to foundation.utility - Move all item rendering classes to foundation.item.render - Move IBlockVertexColor from foundation.block to foundation.block.render - Remove unnecessary raw cast in CreateRegistrate
This commit is contained in:
parent
cecf2102cf
commit
2bada365b3
28 changed files with 73 additions and 147 deletions
|
@ -164,6 +164,7 @@ import com.simibubi.create.foundation.data.CreateRegistrate;
|
|||
import com.simibubi.create.foundation.data.ModelGen;
|
||||
import com.simibubi.create.foundation.data.SharedProperties;
|
||||
import com.simibubi.create.foundation.item.TooltipHelper;
|
||||
import com.simibubi.create.foundation.utility.ColorHandlers;
|
||||
import com.simibubi.create.foundation.utility.DyeHelper;
|
||||
import com.simibubi.create.foundation.worldgen.OxidizingBlock;
|
||||
import com.tterrag.registrate.providers.RegistrateRecipeProvider;
|
||||
|
@ -841,7 +842,7 @@ public class AllBlocks {
|
|||
.initialProperties(() -> Blocks.POWERED_RAIL)
|
||||
.blockstate(new ControllerRailGenerator()::generate)
|
||||
.addLayer(() -> RenderType::getCutoutMipped)
|
||||
.onRegister(CreateRegistrate.blockColors(() -> AllColorHandlers::getRedstonePower))
|
||||
.color(() -> ColorHandlers::getRedstonePower)
|
||||
.tag(BlockTags.RAILS)
|
||||
.item()
|
||||
.model((c, p) -> p.generated(c, Create.asResource("block/" + c.getName())))
|
||||
|
|
|
@ -1,64 +0,0 @@
|
|||
package com.simibubi.create;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.RedstoneWireBlock;
|
||||
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.state.properties.BlockStateProperties;
|
||||
import net.minecraft.util.IItemProvider;
|
||||
import net.minecraft.world.GrassColors;
|
||||
import net.minecraft.world.biome.BiomeColors;
|
||||
import net.minecraftforge.client.event.ColorHandlerEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
|
||||
public class AllColorHandlers {
|
||||
|
||||
private final Map<Block, IBlockColor> coloredBlocks = new HashMap<>();
|
||||
private final Map<IItemProvider, IItemColor> coloredItems = new HashMap<>();
|
||||
|
||||
//
|
||||
|
||||
public static IBlockColor getGrassyBlock() {
|
||||
return (state, world, pos, layer) -> pos != null && world != null ? BiomeColors.getGrassColor(world, pos)
|
||||
: GrassColors.get(0.5D, 1.0D);
|
||||
}
|
||||
|
||||
public static IItemColor getGrassyItem() {
|
||||
return (stack, layer) -> GrassColors.get(0.5D, 1.0D);
|
||||
}
|
||||
|
||||
public static IBlockColor getRedstonePower() {
|
||||
return (state, world, pos, layer) -> RedstoneWireBlock
|
||||
.getWireColor(pos != null && world != null ? state.get(BlockStateProperties.POWER_0_15) : 0);
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
public void register(Block block, IBlockColor color) {
|
||||
coloredBlocks.put(block, color);
|
||||
}
|
||||
|
||||
public void register(IItemProvider item, IItemColor color) {
|
||||
coloredItems.put(item, color);
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@SubscribeEvent
|
||||
public void registerBlockColors(ColorHandlerEvent.Block event) {
|
||||
BlockColors blockColors = event.getBlockColors();
|
||||
coloredBlocks.forEach((block, color) -> blockColors.register(color, block));
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void registerItemColors(ColorHandlerEvent.Item event) {
|
||||
ItemColors itemColors = event.getItemColors();
|
||||
coloredItems.forEach((item, color) -> itemColors.register(color, item));
|
||||
}
|
||||
|
||||
}
|
|
@ -129,7 +129,7 @@ public class AllItems {
|
|||
REGISTRATE.item("chromatic_compound", ChromaticCompoundItem::new)
|
||||
.properties(p -> p.rarity(Rarity.UNCOMMON))
|
||||
.model(AssetLookup.existingItemModel())
|
||||
.onRegister(CreateRegistrate.itemColors(() -> ChromaticCompoundColor::new))
|
||||
.color(() -> ChromaticCompoundColor::new)
|
||||
.register();
|
||||
|
||||
public static final ItemEntry<ShadowSteelItem> SHADOW_STEEL = REGISTRATE.item("shadow_steel", ShadowSteelItem::new)
|
||||
|
|
|
@ -20,8 +20,8 @@ import com.simibubi.create.foundation.block.render.CustomBlockModels;
|
|||
import com.simibubi.create.foundation.block.render.SpriteShifter;
|
||||
import com.simibubi.create.foundation.config.AllConfigs;
|
||||
import com.simibubi.create.foundation.gui.UIRenderHelper;
|
||||
import com.simibubi.create.foundation.item.CustomItemModels;
|
||||
import com.simibubi.create.foundation.item.CustomRenderedItems;
|
||||
import com.simibubi.create.foundation.item.render.CustomItemModels;
|
||||
import com.simibubi.create.foundation.item.render.CustomRenderedItems;
|
||||
import com.simibubi.create.foundation.ponder.content.PonderIndex;
|
||||
import com.simibubi.create.foundation.ponder.elements.WorldSectionElement;
|
||||
import com.simibubi.create.foundation.render.AllProgramSpecs;
|
||||
|
@ -74,12 +74,10 @@ public class CreateClient {
|
|||
private static CustomBlockModels customBlockModels;
|
||||
private static CustomItemModels customItemModels;
|
||||
private static CustomRenderedItems customRenderedItems;
|
||||
private static AllColorHandlers colorHandlers;
|
||||
private static CasingConnectivity casingConnectivity;
|
||||
|
||||
public static void addClientListeners(IEventBus modEventBus) {
|
||||
modEventBus.addListener(CreateClient::clientInit);
|
||||
modEventBus.register(getColorHandler());
|
||||
modEventBus.addListener(CreateClient::onTextureStitch);
|
||||
modEventBus.addListener(CreateClient::onModelRegistry);
|
||||
modEventBus.addListener(CreateClient::onModelBake);
|
||||
|
@ -196,12 +194,6 @@ public class CreateClient {
|
|||
return customBlockModels;
|
||||
}
|
||||
|
||||
public static AllColorHandlers getColorHandler() {
|
||||
if (colorHandlers == null)
|
||||
colorHandlers = new AllColorHandlers();
|
||||
return colorHandlers;
|
||||
}
|
||||
|
||||
public static CasingConnectivity getCasingConnectivity() {
|
||||
if (casingConnectivity == null)
|
||||
casingConnectivity = new CasingConnectivity();
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package com.simibubi.create.content.contraptions.wrench;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.simibubi.create.foundation.block.render.CustomRenderedItemModelRenderer;
|
||||
import com.simibubi.create.foundation.item.PartialItemModelRenderer;
|
||||
import com.simibubi.create.foundation.item.render.CustomRenderedItemModelRenderer;
|
||||
import com.simibubi.create.foundation.item.render.PartialItemModelRenderer;
|
||||
import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.ScrollValueHandler;
|
||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.simibubi.create.content.contraptions.wrench;
|
||||
|
||||
import com.simibubi.create.foundation.block.render.CustomRenderedItemModel;
|
||||
import com.simibubi.create.foundation.item.render.CustomRenderedItemModel;
|
||||
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.tileentity.ItemStackTileEntityRenderer;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package com.simibubi.create.content.curiosities.symmetry.client;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.simibubi.create.foundation.block.render.CustomRenderedItemModelRenderer;
|
||||
import com.simibubi.create.foundation.item.PartialItemModelRenderer;
|
||||
import com.simibubi.create.foundation.item.render.CustomRenderedItemModelRenderer;
|
||||
import com.simibubi.create.foundation.item.render.PartialItemModelRenderer;
|
||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.simibubi.create.content.curiosities.symmetry.client;
|
||||
|
||||
import com.simibubi.create.foundation.block.render.CustomRenderedItemModel;
|
||||
import com.simibubi.create.foundation.item.render.CustomRenderedItemModel;
|
||||
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.tileentity.ItemStackTileEntityRenderer;
|
||||
|
|
|
@ -2,8 +2,8 @@ package com.simibubi.create.content.curiosities.tools;
|
|||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.foundation.block.render.CustomRenderedItemModelRenderer;
|
||||
import com.simibubi.create.foundation.item.PartialItemModelRenderer;
|
||||
import com.simibubi.create.foundation.item.render.CustomRenderedItemModelRenderer;
|
||||
import com.simibubi.create.foundation.item.render.PartialItemModelRenderer;
|
||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||
import com.simibubi.create.foundation.utility.MatrixStacker;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.simibubi.create.content.curiosities.tools;
|
||||
|
||||
import com.simibubi.create.foundation.block.render.CustomRenderedItemModel;
|
||||
import com.simibubi.create.foundation.item.render.CustomRenderedItemModel;
|
||||
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.tileentity.ItemStackTileEntityRenderer;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.simibubi.create.content.curiosities.tools;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.simibubi.create.foundation.block.render.CustomRenderedItemModel;
|
||||
import com.simibubi.create.foundation.item.render.CustomRenderedItemModel;
|
||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package com.simibubi.create.content.curiosities.zapper;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.simibubi.create.foundation.block.render.CustomRenderedItemModel;
|
||||
import com.simibubi.create.foundation.block.render.CustomRenderedItemModelRenderer;
|
||||
import com.simibubi.create.foundation.item.PartialItemModelRenderer;
|
||||
import com.simibubi.create.foundation.item.render.CustomRenderedItemModel;
|
||||
import com.simibubi.create.foundation.item.render.CustomRenderedItemModelRenderer;
|
||||
import com.simibubi.create.foundation.item.render.PartialItemModelRenderer;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.FourWayBlock;
|
||||
|
|
|
@ -5,7 +5,7 @@ import static net.minecraft.util.math.MathHelper.clamp;
|
|||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.simibubi.create.content.curiosities.zapper.ZapperItemRenderer;
|
||||
import com.simibubi.create.foundation.item.PartialItemModelRenderer;
|
||||
import com.simibubi.create.foundation.item.render.PartialItemModelRenderer;
|
||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.simibubi.create.content.curiosities.zapper.terrainzapper;
|
||||
|
||||
import com.simibubi.create.foundation.block.render.CustomRenderedItemModel;
|
||||
import com.simibubi.create.foundation.item.render.CustomRenderedItemModel;
|
||||
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.tileentity.ItemStackTileEntityRenderer;
|
||||
|
|
|
@ -5,8 +5,8 @@ import java.util.Vector;
|
|||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.simibubi.create.AllItems;
|
||||
import com.simibubi.create.content.logistics.item.LinkedControllerClientHandler.Mode;
|
||||
import com.simibubi.create.foundation.block.render.CustomRenderedItemModelRenderer;
|
||||
import com.simibubi.create.foundation.item.PartialItemModelRenderer;
|
||||
import com.simibubi.create.foundation.item.render.CustomRenderedItemModelRenderer;
|
||||
import com.simibubi.create.foundation.item.render.PartialItemModelRenderer;
|
||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||
import com.simibubi.create.foundation.utility.MatrixStacker;
|
||||
import com.simibubi.create.foundation.utility.animation.LerpedFloat;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.simibubi.create.content.logistics.item;
|
||||
|
||||
import com.simibubi.create.foundation.block.render.CustomRenderedItemModel;
|
||||
import com.simibubi.create.foundation.item.render.CustomRenderedItemModel;
|
||||
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.tileentity.ItemStackTileEntityRenderer;
|
||||
|
|
|
@ -3,10 +3,10 @@ package com.simibubi.create.content.palettes;
|
|||
import static com.simibubi.create.foundation.data.CreateRegistrate.connectedTextures;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.simibubi.create.AllColorHandlers;
|
||||
import com.simibubi.create.AllTags;
|
||||
import com.simibubi.create.Create;
|
||||
import com.simibubi.create.foundation.data.CreateRegistrate;
|
||||
import com.simibubi.create.foundation.utility.ColorHandlers;
|
||||
import com.simibubi.create.foundation.utility.Lang;
|
||||
import com.tterrag.registrate.builders.BlockBuilder;
|
||||
import com.tterrag.registrate.util.DataIngredient;
|
||||
|
@ -41,7 +41,7 @@ public class PalettesVariantEntry {
|
|||
if (pattern == PaletteBlockPattern.COBBLESTONE)
|
||||
builder.item().tag(AllTags.AllItemTags.COBBLESTONE.tag);
|
||||
if (pattern.hasFoliage())
|
||||
builder.onRegister(CreateRegistrate.blockColors(() -> AllColorHandlers::getGrassyBlock));
|
||||
builder.color(() -> ColorHandlers::getGrassyBlock);
|
||||
pattern.createCTBehaviour(variant)
|
||||
.ifPresent(b -> builder.onRegister(connectedTextures(b)));
|
||||
|
||||
|
@ -53,7 +53,7 @@ public class PalettesVariantEntry {
|
|||
|
||||
if (pattern.hasFoliage())
|
||||
builder.item()
|
||||
.onRegister(CreateRegistrate.itemColors(() -> AllColorHandlers::getGrassyItem))
|
||||
.color(() -> ColorHandlers::getGrassyItem)
|
||||
.build();
|
||||
else
|
||||
builder.simpleItem();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.simibubi.create.content.palettes;
|
||||
|
||||
import com.simibubi.create.foundation.block.IBlockVertexColor;
|
||||
import com.simibubi.create.foundation.block.render.IBlockVertexColor;
|
||||
import com.simibubi.create.foundation.utility.ColorHelper;
|
||||
|
||||
public class ScoriaVertexColor implements IBlockVertexColor {
|
||||
|
|
|
@ -13,15 +13,15 @@ import net.minecraft.util.ResourceLocation;
|
|||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
||||
|
||||
@Mod.EventBusSubscriber
|
||||
@EventBusSubscriber
|
||||
public class ItemUseOverrides {
|
||||
|
||||
private static final Set<ResourceLocation> overrides = new HashSet<>();
|
||||
private static final Set<ResourceLocation> OVERRIDES = new HashSet<>();
|
||||
|
||||
public static void addBlock(Block block) {
|
||||
overrides.add(block.getRegistryName());
|
||||
OVERRIDES.add(block.getRegistryName());
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
@ -34,7 +34,7 @@ public class ItemUseOverrides {
|
|||
ResourceLocation id = state.getBlock()
|
||||
.getRegistryName();
|
||||
|
||||
if (!overrides.contains(id))
|
||||
if (!OVERRIDES.contains(id))
|
||||
return;
|
||||
|
||||
BlockRayTraceResult blockTrace =
|
||||
|
@ -46,6 +46,6 @@ public class ItemUseOverrides {
|
|||
|
||||
event.setCanceled(true);
|
||||
event.setCancellationResult(result);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,8 +4,6 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import com.simibubi.create.foundation.block.IBlockVertexColor;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package com.simibubi.create.foundation.block;
|
||||
package com.simibubi.create.foundation.block.render;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface IBlockVertexColor {
|
|
@ -14,11 +14,11 @@ import com.simibubi.create.CreateClient;
|
|||
import com.simibubi.create.content.AllSections;
|
||||
import com.simibubi.create.content.contraptions.fluids.VirtualFluid;
|
||||
import com.simibubi.create.content.contraptions.relays.encased.CasingConnectivity;
|
||||
import com.simibubi.create.foundation.block.IBlockVertexColor;
|
||||
import com.simibubi.create.foundation.block.connected.CTModel;
|
||||
import com.simibubi.create.foundation.block.connected.ConnectedTextureBehaviour;
|
||||
import com.simibubi.create.foundation.block.render.ColoredVertexModel;
|
||||
import com.simibubi.create.foundation.block.render.CustomRenderedItemModel;
|
||||
import com.simibubi.create.foundation.block.render.IBlockVertexColor;
|
||||
import com.simibubi.create.foundation.item.render.CustomRenderedItemModel;
|
||||
import com.tterrag.registrate.AbstractRegistrate;
|
||||
import com.tterrag.registrate.builders.BlockBuilder;
|
||||
import com.tterrag.registrate.builders.Builder;
|
||||
|
@ -34,14 +34,11 @@ import com.tterrag.registrate.util.nullness.NonNullUnaryOperator;
|
|||
|
||||
import net.minecraft.block.AbstractBlock.Properties;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.color.IBlockColor;
|
||||
import net.minecraft.client.renderer.color.IItemColor;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.fluid.Fluid;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.IItemProvider;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.fluids.FluidAttributes;
|
||||
|
@ -114,7 +111,7 @@ public class CreateRegistrate extends AbstractRegistrate<CreateRegistrate> {
|
|||
|
||||
public <T extends TileEntity> CreateTileEntityBuilder<T, CreateRegistrate> tileEntity(String name,
|
||||
NonNullFunction<TileEntityType<T>, ? extends T> factory) {
|
||||
return this.tileEntity(this.self(), name, (NonNullFunction) factory);
|
||||
return this.tileEntity(this.self(), name, factory);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -177,28 +174,20 @@ public class CreateRegistrate extends AbstractRegistrate<CreateRegistrate> {
|
|||
return entry -> onClient(() -> () -> registerCasingConnectivity(entry, consumer));
|
||||
}
|
||||
|
||||
public static <T extends Block> NonNullConsumer<? super T> blockVertexColors(IBlockVertexColor colorFunc) {
|
||||
return entry -> onClient(() -> () -> registerBlockVertexColor(entry, colorFunc));
|
||||
}
|
||||
|
||||
public static <T extends Block> NonNullConsumer<? super T> blockModel(
|
||||
Supplier<NonNullFunction<IBakedModel, ? extends IBakedModel>> func) {
|
||||
return entry -> onClient(() -> () -> registerBlockModel(entry, func));
|
||||
}
|
||||
|
||||
public static <T extends Block> NonNullConsumer<? super T> blockColors(Supplier<Supplier<IBlockColor>> colorFunc) {
|
||||
return entry -> onClient(() -> () -> registerBlockColor(entry, colorFunc));
|
||||
}
|
||||
|
||||
public static <T extends Block> NonNullConsumer<? super T> blockVertexColors(IBlockVertexColor colorFunc) {
|
||||
return entry -> onClient(() -> () -> registerBlockVertexColor(entry, colorFunc));
|
||||
}
|
||||
|
||||
public static <T extends Item> NonNullConsumer<? super T> itemModel(
|
||||
Supplier<NonNullFunction<IBakedModel, ? extends IBakedModel>> func) {
|
||||
return entry -> onClient(() -> () -> registerItemModel(entry, func));
|
||||
}
|
||||
|
||||
public static <T extends Item> NonNullConsumer<? super T> itemColors(Supplier<Supplier<IItemColor>> colorFunc) {
|
||||
return entry -> onClient(() -> () -> registerItemColor(entry, colorFunc));
|
||||
}
|
||||
|
||||
public static <T extends Item, P> NonNullUnaryOperator<ItemBuilder<T, P>> customRenderedItem(
|
||||
Supplier<NonNullFunction<IBakedModel, ? extends CustomRenderedItemModel>> func) {
|
||||
return b -> b.properties(p -> p.setISTER(() -> () -> func.get()
|
||||
|
@ -250,18 +239,4 @@ public class CreateRegistrate extends AbstractRegistrate<CreateRegistrate> {
|
|||
.register(entry.delegate, func.get());
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
private static void registerBlockColor(Block entry, Supplier<Supplier<IBlockColor>> colorFunc) {
|
||||
CreateClient.getColorHandler()
|
||||
.register(entry, colorFunc.get()
|
||||
.get());
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
private static void registerItemColor(IItemProvider entry, Supplier<Supplier<IItemColor>> colorFunc) {
|
||||
CreateClient.getColorHandler()
|
||||
.register(entry, colorFunc.get()
|
||||
.get());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package com.simibubi.create.foundation.item;
|
||||
package com.simibubi.create.foundation.item.render;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.IdentityHashMap;
|
|
@ -1,4 +1,4 @@
|
|||
package com.simibubi.create.foundation.block.render;
|
||||
package com.simibubi.create.foundation.item.render;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
@ -16,7 +16,6 @@ import net.minecraft.util.ResourceLocation;
|
|||
import net.minecraftforge.client.event.ModelBakeEvent;
|
||||
import net.minecraftforge.client.model.BakedModelWrapper;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public abstract class CustomRenderedItemModel extends BakedModelWrapper<IBakedModel> {
|
||||
|
||||
protected String basePath;
|
||||
|
@ -67,6 +66,7 @@ public abstract class CustomRenderedItemModel extends BakedModelWrapper<IBakedMo
|
|||
return this;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private IBakedModel loadModel(ModelBakeEvent event, String name) {
|
||||
return event.getModelLoader().func_217845_a(getPartialModelLocation(name), ModelRotation.X0_Y0);
|
||||
}
|
|
@ -1,7 +1,6 @@
|
|||
package com.simibubi.create.foundation.block.render;
|
||||
package com.simibubi.create.foundation.item.render;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.simibubi.create.foundation.item.PartialItemModelRenderer;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
|
@ -1,4 +1,4 @@
|
|||
package com.simibubi.create.foundation.item;
|
||||
package com.simibubi.create.foundation.item.render;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.IdentityHashMap;
|
||||
|
@ -8,7 +8,6 @@ import java.util.function.Supplier;
|
|||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import com.simibubi.create.foundation.block.render.CustomRenderedItemModel;
|
||||
import com.tterrag.registrate.util.nullness.NonNullBiConsumer;
|
||||
import com.tterrag.registrate.util.nullness.NonNullFunction;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.simibubi.create.foundation.item;
|
||||
package com.simibubi.create.foundation.item.render;
|
||||
|
||||
import java.util.Random;
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
package com.simibubi.create.foundation.utility;
|
||||
|
||||
import net.minecraft.block.RedstoneWireBlock;
|
||||
import net.minecraft.client.renderer.color.IBlockColor;
|
||||
import net.minecraft.client.renderer.color.IItemColor;
|
||||
import net.minecraft.state.properties.BlockStateProperties;
|
||||
import net.minecraft.world.GrassColors;
|
||||
import net.minecraft.world.biome.BiomeColors;
|
||||
|
||||
public class ColorHandlers {
|
||||
|
||||
public static IBlockColor getGrassyBlock() {
|
||||
return (state, world, pos, layer) -> pos != null && world != null ? BiomeColors.getGrassColor(world, pos)
|
||||
: GrassColors.get(0.5D, 1.0D);
|
||||
}
|
||||
|
||||
public static IItemColor getGrassyItem() {
|
||||
return (stack, layer) -> GrassColors.get(0.5D, 1.0D);
|
||||
}
|
||||
|
||||
public static IBlockColor getRedstonePower() {
|
||||
return (state, world, pos, layer) -> RedstoneWireBlock
|
||||
.getWireColor(pos != null && world != null ? state.get(BlockStateProperties.POWER_0_15) : 0);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue