diff --git a/src/main/java/com/simibubi/create/AllBlocks.java b/src/main/java/com/simibubi/create/AllBlocks.java index c50c3701e..2d9106b4c 100644 --- a/src/main/java/com/simibubi/create/AllBlocks.java +++ b/src/main/java/com/simibubi/create/AllBlocks.java @@ -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()))) diff --git a/src/main/java/com/simibubi/create/AllColorHandlers.java b/src/main/java/com/simibubi/create/AllColorHandlers.java deleted file mode 100644 index 813f4f3ed..000000000 --- a/src/main/java/com/simibubi/create/AllColorHandlers.java +++ /dev/null @@ -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 coloredBlocks = new HashMap<>(); - private final Map 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)); - } - -} diff --git a/src/main/java/com/simibubi/create/AllItems.java b/src/main/java/com/simibubi/create/AllItems.java index 18c157b7a..28e5c3356 100644 --- a/src/main/java/com/simibubi/create/AllItems.java +++ b/src/main/java/com/simibubi/create/AllItems.java @@ -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 SHADOW_STEEL = REGISTRATE.item("shadow_steel", ShadowSteelItem::new) diff --git a/src/main/java/com/simibubi/create/CreateClient.java b/src/main/java/com/simibubi/create/CreateClient.java index 6bbe40109..05edeb45d 100644 --- a/src/main/java/com/simibubi/create/CreateClient.java +++ b/src/main/java/com/simibubi/create/CreateClient.java @@ -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(); diff --git a/src/main/java/com/simibubi/create/content/contraptions/wrench/WrenchItemRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/wrench/WrenchItemRenderer.java index bde917413..7b9e15cda 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/wrench/WrenchItemRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/wrench/WrenchItemRenderer.java @@ -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; diff --git a/src/main/java/com/simibubi/create/content/contraptions/wrench/WrenchModel.java b/src/main/java/com/simibubi/create/content/contraptions/wrench/WrenchModel.java index 081449d68..7d58c0514 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/wrench/WrenchModel.java +++ b/src/main/java/com/simibubi/create/content/contraptions/wrench/WrenchModel.java @@ -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; diff --git a/src/main/java/com/simibubi/create/content/curiosities/symmetry/client/SymmetryWandItemRenderer.java b/src/main/java/com/simibubi/create/content/curiosities/symmetry/client/SymmetryWandItemRenderer.java index 51cd757ba..0c0461daf 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/symmetry/client/SymmetryWandItemRenderer.java +++ b/src/main/java/com/simibubi/create/content/curiosities/symmetry/client/SymmetryWandItemRenderer.java @@ -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; diff --git a/src/main/java/com/simibubi/create/content/curiosities/symmetry/client/SymmetryWandModel.java b/src/main/java/com/simibubi/create/content/curiosities/symmetry/client/SymmetryWandModel.java index ce5796427..f361c3c9f 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/symmetry/client/SymmetryWandModel.java +++ b/src/main/java/com/simibubi/create/content/curiosities/symmetry/client/SymmetryWandModel.java @@ -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; diff --git a/src/main/java/com/simibubi/create/content/curiosities/tools/ExtendoGripItemRenderer.java b/src/main/java/com/simibubi/create/content/curiosities/tools/ExtendoGripItemRenderer.java index 2869afcea..c604eeb3a 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/tools/ExtendoGripItemRenderer.java +++ b/src/main/java/com/simibubi/create/content/curiosities/tools/ExtendoGripItemRenderer.java @@ -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; diff --git a/src/main/java/com/simibubi/create/content/curiosities/tools/ExtendoGripModel.java b/src/main/java/com/simibubi/create/content/curiosities/tools/ExtendoGripModel.java index aa8718952..cd37439f5 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/tools/ExtendoGripModel.java +++ b/src/main/java/com/simibubi/create/content/curiosities/tools/ExtendoGripModel.java @@ -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; diff --git a/src/main/java/com/simibubi/create/content/curiosities/tools/SandPaperItemRenderer.java b/src/main/java/com/simibubi/create/content/curiosities/tools/SandPaperItemRenderer.java index a5ce27abe..fca6a5c45 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/tools/SandPaperItemRenderer.java +++ b/src/main/java/com/simibubi/create/content/curiosities/tools/SandPaperItemRenderer.java @@ -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; diff --git a/src/main/java/com/simibubi/create/content/curiosities/zapper/ZapperItemRenderer.java b/src/main/java/com/simibubi/create/content/curiosities/zapper/ZapperItemRenderer.java index 9904b6d39..db8beb57b 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/zapper/ZapperItemRenderer.java +++ b/src/main/java/com/simibubi/create/content/curiosities/zapper/ZapperItemRenderer.java @@ -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; diff --git a/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/WorldshaperItemRenderer.java b/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/WorldshaperItemRenderer.java index 9c2369935..3b5886bab 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/WorldshaperItemRenderer.java +++ b/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/WorldshaperItemRenderer.java @@ -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; diff --git a/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/WorldshaperModel.java b/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/WorldshaperModel.java index d28e0a2af..c27b76932 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/WorldshaperModel.java +++ b/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/WorldshaperModel.java @@ -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; diff --git a/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerItemRenderer.java b/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerItemRenderer.java index 2155442ec..a7e524e5a 100644 --- a/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerItemRenderer.java +++ b/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerItemRenderer.java @@ -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; diff --git a/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerModel.java b/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerModel.java index 075880dfd..a900bddf4 100644 --- a/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerModel.java +++ b/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerModel.java @@ -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; diff --git a/src/main/java/com/simibubi/create/content/palettes/PalettesVariantEntry.java b/src/main/java/com/simibubi/create/content/palettes/PalettesVariantEntry.java index 76ab74af3..24736fb2a 100644 --- a/src/main/java/com/simibubi/create/content/palettes/PalettesVariantEntry.java +++ b/src/main/java/com/simibubi/create/content/palettes/PalettesVariantEntry.java @@ -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(); diff --git a/src/main/java/com/simibubi/create/content/palettes/ScoriaVertexColor.java b/src/main/java/com/simibubi/create/content/palettes/ScoriaVertexColor.java index ef93a2872..0629ec035 100644 --- a/src/main/java/com/simibubi/create/content/palettes/ScoriaVertexColor.java +++ b/src/main/java/com/simibubi/create/content/palettes/ScoriaVertexColor.java @@ -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 { diff --git a/src/main/java/com/simibubi/create/foundation/block/ItemUseOverrides.java b/src/main/java/com/simibubi/create/foundation/block/ItemUseOverrides.java index 0337a5d08..662154fd2 100644 --- a/src/main/java/com/simibubi/create/foundation/block/ItemUseOverrides.java +++ b/src/main/java/com/simibubi/create/foundation/block/ItemUseOverrides.java @@ -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 overrides = new HashSet<>(); + private static final Set 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); - } + } diff --git a/src/main/java/com/simibubi/create/foundation/block/render/ColoredVertexModel.java b/src/main/java/com/simibubi/create/foundation/block/render/ColoredVertexModel.java index c860bb29e..e4be4b2ba 100644 --- a/src/main/java/com/simibubi/create/foundation/block/render/ColoredVertexModel.java +++ b/src/main/java/com/simibubi/create/foundation/block/render/ColoredVertexModel.java @@ -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; diff --git a/src/main/java/com/simibubi/create/foundation/block/IBlockVertexColor.java b/src/main/java/com/simibubi/create/foundation/block/render/IBlockVertexColor.java similarity index 67% rename from src/main/java/com/simibubi/create/foundation/block/IBlockVertexColor.java rename to src/main/java/com/simibubi/create/foundation/block/render/IBlockVertexColor.java index 1a4f91dae..f754ed13c 100644 --- a/src/main/java/com/simibubi/create/foundation/block/IBlockVertexColor.java +++ b/src/main/java/com/simibubi/create/foundation/block/render/IBlockVertexColor.java @@ -1,4 +1,4 @@ -package com.simibubi.create.foundation.block; +package com.simibubi.create.foundation.block.render; @FunctionalInterface public interface IBlockVertexColor { diff --git a/src/main/java/com/simibubi/create/foundation/data/CreateRegistrate.java b/src/main/java/com/simibubi/create/foundation/data/CreateRegistrate.java index c9c591f76..a1084beb3 100644 --- a/src/main/java/com/simibubi/create/foundation/data/CreateRegistrate.java +++ b/src/main/java/com/simibubi/create/foundation/data/CreateRegistrate.java @@ -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 { public CreateTileEntityBuilder tileEntity(String name, NonNullFunction, ? 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 { return entry -> onClient(() -> () -> registerCasingConnectivity(entry, consumer)); } + public static NonNullConsumer blockVertexColors(IBlockVertexColor colorFunc) { + return entry -> onClient(() -> () -> registerBlockVertexColor(entry, colorFunc)); + } + public static NonNullConsumer blockModel( Supplier> func) { return entry -> onClient(() -> () -> registerBlockModel(entry, func)); } - public static NonNullConsumer blockColors(Supplier> colorFunc) { - return entry -> onClient(() -> () -> registerBlockColor(entry, colorFunc)); - } - - public static NonNullConsumer blockVertexColors(IBlockVertexColor colorFunc) { - return entry -> onClient(() -> () -> registerBlockVertexColor(entry, colorFunc)); - } - public static NonNullConsumer itemModel( Supplier> func) { return entry -> onClient(() -> () -> registerItemModel(entry, func)); } - public static NonNullConsumer itemColors(Supplier> colorFunc) { - return entry -> onClient(() -> () -> registerItemColor(entry, colorFunc)); - } - public static NonNullUnaryOperator> customRenderedItem( Supplier> func) { return b -> b.properties(p -> p.setISTER(() -> () -> func.get() @@ -250,18 +239,4 @@ public class CreateRegistrate extends AbstractRegistrate { .register(entry.delegate, func.get()); } - @OnlyIn(Dist.CLIENT) - private static void registerBlockColor(Block entry, Supplier> colorFunc) { - CreateClient.getColorHandler() - .register(entry, colorFunc.get() - .get()); - } - - @OnlyIn(Dist.CLIENT) - private static void registerItemColor(IItemProvider entry, Supplier> colorFunc) { - CreateClient.getColorHandler() - .register(entry, colorFunc.get() - .get()); - } - } diff --git a/src/main/java/com/simibubi/create/foundation/item/CustomItemModels.java b/src/main/java/com/simibubi/create/foundation/item/render/CustomItemModels.java similarity index 96% rename from src/main/java/com/simibubi/create/foundation/item/CustomItemModels.java rename to src/main/java/com/simibubi/create/foundation/item/render/CustomItemModels.java index 805d8e3f6..8f7ed04f6 100644 --- a/src/main/java/com/simibubi/create/foundation/item/CustomItemModels.java +++ b/src/main/java/com/simibubi/create/foundation/item/render/CustomItemModels.java @@ -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; diff --git a/src/main/java/com/simibubi/create/foundation/block/render/CustomRenderedItemModel.java b/src/main/java/com/simibubi/create/foundation/item/render/CustomRenderedItemModel.java similarity index 96% rename from src/main/java/com/simibubi/create/foundation/block/render/CustomRenderedItemModel.java rename to src/main/java/com/simibubi/create/foundation/item/render/CustomRenderedItemModel.java index 6df4c426b..6ef18e8cd 100644 --- a/src/main/java/com/simibubi/create/foundation/block/render/CustomRenderedItemModel.java +++ b/src/main/java/com/simibubi/create/foundation/item/render/CustomRenderedItemModel.java @@ -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 { protected String basePath; @@ -67,6 +66,7 @@ public abstract class CustomRenderedItemModel extends BakedModelWrapper 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); + } + +}