| 1 | package net.minecraft.client.renderer.block;
|
| 2 |
|
| 3 | import com.mojang.math.Axis;
|
| 4 | import com.mojang.math.Transformation;
|
| 5 | import java.util.HashMap;
|
| 6 | import java.util.List;
|
| 7 | import java.util.Map;
|
| 8 | import java.util.Optional;
|
| 9 | import java.util.function.BiFunction;
|
| 10 | import java.util.function.Function;
|
| 11 | import net.fabricmc.api.EnvType;
|
| 12 | import net.fabricmc.api.Environment;
|
| 13 | import net.minecraft.client.color.block.BlockColors;
|
| 14 | import net.minecraft.client.color.block.BlockTintSource;
|
| 15 | import net.minecraft.client.renderer.MultiblockChestResources;
|
| 16 | import net.minecraft.client.renderer.block.model.BlockModel;
|
| 17 | import net.minecraft.client.renderer.block.model.BlockStateModelWrapper;
|
| 18 | import net.minecraft.client.renderer.block.model.CompositeBlockModel;
|
| 19 | import net.minecraft.client.renderer.block.model.ConditionalBlockModel;
|
| 20 | import net.minecraft.client.renderer.block.model.EmptyBlockModel;
|
| 21 | import net.minecraft.client.renderer.block.model.SpecialBlockModelWrapper;
|
| 22 | import net.minecraft.client.renderer.block.model.properties.conditional.IsXmas;
|
| 23 | import net.minecraft.client.renderer.block.model.properties.select.DisplayContext;
|
| 24 | import net.minecraft.client.renderer.blockentity.BannerRenderer;
|
| 25 | import net.minecraft.client.renderer.blockentity.ChestRenderer;
|
| 26 | import net.minecraft.client.renderer.blockentity.ConduitRenderer;
|
| 27 | import net.minecraft.client.renderer.blockentity.CopperGolemStatueBlockRenderer;
|
| 28 | import net.minecraft.client.renderer.blockentity.DecoratedPotRenderer;
|
| 29 | import net.minecraft.client.renderer.blockentity.ShulkerBoxRenderer;
|
| 30 | import net.minecraft.client.renderer.blockentity.SkullBlockRenderer;
|
| 31 | import net.minecraft.client.renderer.blockentity.TheEndPortalRenderer;
|
| 32 | import net.minecraft.client.renderer.entity.CopperGolemRenderer;
|
| 33 | import net.minecraft.client.renderer.special.BannerSpecialRenderer;
|
| 34 | import net.minecraft.client.renderer.special.BellSpecialRenderer;
|
| 35 | import net.minecraft.client.renderer.special.BookSpecialRenderer;
|
| 36 | import net.minecraft.client.renderer.special.ChestSpecialRenderer;
|
| 37 | import net.minecraft.client.renderer.special.ConduitSpecialRenderer;
|
| 38 | import net.minecraft.client.renderer.special.CopperGolemStatueSpecialRenderer;
|
| 39 | import net.minecraft.client.renderer.special.DecoratedPotSpecialRenderer;
|
| 40 | import net.minecraft.client.renderer.special.EndCubeSpecialRenderer;
|
| 41 | import net.minecraft.client.renderer.special.PlayerHeadSpecialRenderer;
|
| 42 | import net.minecraft.client.renderer.special.ShulkerBoxSpecialRenderer;
|
| 43 | import net.minecraft.client.renderer.special.SkullSpecialRenderer;
|
| 44 | import net.minecraft.client.renderer.special.SpecialModelRenderer;
|
| 45 | import net.minecraft.core.Direction;
|
| 46 | import net.minecraft.resources.Identifier;
|
| 47 | import net.minecraft.world.item.DyeColor;
|
| 48 | import net.minecraft.world.level.block.BannerBlock;
|
| 49 | import net.minecraft.world.level.block.Block;
|
| 50 | import net.minecraft.world.level.block.Blocks;
|
| 51 | import net.minecraft.world.level.block.ChestBlock;
|
| 52 | import net.minecraft.world.level.block.ColorCollection;
|
| 53 | import net.minecraft.world.level.block.CopperGolemStatueBlock;
|
| 54 | import net.minecraft.world.level.block.DecoratedPotBlock;
|
| 55 | import net.minecraft.world.level.block.PlayerHeadBlock;
|
| 56 | import net.minecraft.world.level.block.PlayerWallHeadBlock;
|
| 57 | import net.minecraft.world.level.block.ShulkerBoxBlock;
|
| 58 | import net.minecraft.world.level.block.SkullBlock;
|
| 59 | import net.minecraft.world.level.block.WallBannerBlock;
|
| 60 | import net.minecraft.world.level.block.WallSkullBlock;
|
| 61 | import net.minecraft.world.level.block.BannerBlock.AttachmentType;
|
| 62 | import net.minecraft.world.level.block.SkullBlock.Types;
|
| 63 | import net.minecraft.world.level.block.WeatheringCopper.WeatherState;
|
| 64 | import net.minecraft.world.level.block.state.BlockState;
|
| 65 | import net.minecraft.world.level.block.state.properties.ChestType;
|
| 66 | import net.minecraft.world.level.block.state.properties.Property;
|
| 67 | import org.joml.Vector3f;
|
| 68 |
|
| 69 | /**
|
| 70 | * Access widened by fabric-rendering-v1 to accessible
|
| 71 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 72 | */
|
| 73 | @Environment(EnvType.CLIENT)
|
| 74 | public class BuiltInBlockModels {
|
| 75 | /**
|
| 76 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 77 | */
|
| 78 | public static void addDefaults(final BuiltInBlockModels.Builder builder) {
|
| 79 | createAir(builder, Blocks.AIR);
|
| 80 | createAir(builder, Blocks.CAVE_AIR);
|
| 81 | createAir(builder, Blocks.VOID_AIR);
|
| 82 | createMobHeads(builder, Types.SKELETON, Blocks.SKELETON_SKULL, Blocks.SKELETON_WALL_SKULL);
|
| 83 | createMobHeads(builder, Types.ZOMBIE, Blocks.ZOMBIE_HEAD, Blocks.ZOMBIE_WALL_HEAD);
|
| 84 | createMobHeads(builder, Types.CREEPER, Blocks.CREEPER_HEAD, Blocks.CREEPER_WALL_HEAD);
|
| 85 | createMobHeads(builder, Types.DRAGON, Blocks.DRAGON_HEAD, Blocks.DRAGON_WALL_HEAD);
|
| 86 | createMobHeads(builder, Types.PIGLIN, Blocks.PIGLIN_HEAD, Blocks.PIGLIN_WALL_HEAD);
|
| 87 | createMobHeads(builder, Types.WITHER_SKELETON, Blocks.WITHER_SKELETON_SKULL, Blocks.WITHER_SKELETON_WALL_SKULL);
|
| 88 | builder.put(createPlayerHead(), Blocks.PLAYER_HEAD);
|
| 89 | builder.put(createPlayerWallHead(), Blocks.PLAYER_WALL_HEAD);
|
| 90 | ColorCollection.zipApply(ColorCollection.VALUES, Blocks.BANNER, (color, banner) -> builder.put(createBanner(color), banner));
|
| 91 | ColorCollection.zipApply(ColorCollection.VALUES, Blocks.WALL_BANNER, (color, wallBanner) -> builder.put(createWallBanner(color), wallBanner));
|
| 92 | builder.put(createShulkerBox(), Blocks.SHULKER_BOX);
|
| 93 | ColorCollection.zipApply(ColorCollection.VALUES, Blocks.DYED_SHULKER_BOX, (color, box) -> builder.put(createDyedShulkerBox(color), box));
|
| 94 | builder.put(createSingletonChest(ChestSpecialRenderer.ENDER_CHEST), Blocks.ENDER_CHEST);
|
| 95 | builder.put(createXmasChest(ChestSpecialRenderer.REGULAR), Blocks.CHEST);
|
| 96 | builder.put(createXmasChest(ChestSpecialRenderer.TRAPPED), Blocks.TRAPPED_CHEST);
|
| 97 | WeatherState.forEach(state -> {
|
| 98 | builder.put(createChest(ChestSpecialRenderer.COPPER.pick(state)), Blocks.COPPER_CHEST.weathering().pick(state), Blocks.COPPER_CHEST.waxed().pick(state));
|
| 99 | builder.put(createCopperGolem(state), Blocks.COPPER_GOLEM_STATUE.weathering().pick(state), Blocks.COPPER_GOLEM_STATUE.waxed().pick(state));
|
| 100 | });
|
| 101 | builder.put(special(new BellSpecialRenderer.Unbaked()), Blocks.BELL);
|
| 102 | builder.put(special(new ConduitSpecialRenderer.Unbaked(), ConduitRenderer.DEFAULT_TRANSFORMATION), Blocks.CONDUIT);
|
| 103 | builder.put(createDecoratedPot(), Blocks.DECORATED_POT);
|
| 104 | builder.put(createEnchantingTable(), Blocks.ENCHANTING_TABLE);
|
| 105 | builder.put(special(new EndCubeSpecialRenderer.Unbaked(EndCubeSpecialRenderer.Type.GATEWAY)), Blocks.END_GATEWAY);
|
| 106 | builder.put(special(new EndCubeSpecialRenderer.Unbaked(EndCubeSpecialRenderer.Type.PORTAL), TheEndPortalRenderer.TRANSFORMATION), Blocks.END_PORTAL);
|
| 107 | builder.put(BuiltInBlockModels::createFlowerBedModel, Blocks.WILDFLOWERS, Blocks.PINK_PETALS);
|
| 108 | }
|
| 109 |
|
| 110 | /**
|
| 111 | * Access widened by fabric-rendering-v1 to accessible
|
| 112 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 113 | */
|
| 114 | public static void createAir(final BuiltInBlockModels.Builder builder, final Block block) {
|
| 115 | builder.put(new EmptyBlockModel.Unbaked(), block);
|
| 116 | }
|
| 117 |
|
| 118 | /**
|
| 119 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 120 | */
|
| 121 | public static BlockModel.Unbaked special(final SpecialModelRenderer.Unbaked<?> model) {
|
| 122 | return new SpecialBlockModelWrapper.Unbaked<>(model, Optional.empty());
|
| 123 | }
|
| 124 |
|
| 125 | /**
|
| 126 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 127 | */
|
| 128 | public static BlockModel.Unbaked special(final SpecialModelRenderer.Unbaked<?> model, final Transformation transformation) {
|
| 129 | return new SpecialBlockModelWrapper.Unbaked<>(model, Optional.of(transformation));
|
| 130 | }
|
| 131 |
|
| 132 | /**
|
| 133 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 134 | */
|
| 135 | public static BuiltInBlockModels.SpecialModelFactory createMobHead(final Types type) {
|
| 136 | return specialModelWithPropertyDispatch(
|
| 137 | SkullBlock.ROTATION, rotation -> special(new SkullSpecialRenderer.Unbaked(type), SkullBlockRenderer.TRANSFORMATIONS.freeTransformations(rotation))
|
| 138 | );
|
| 139 | }
|
| 140 |
|
| 141 | /**
|
| 142 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 143 | */
|
| 144 | public static BuiltInBlockModels.SpecialModelFactory createMobWallHead(final Types type) {
|
| 145 | return specialModelWithPropertyDispatch(
|
| 146 | WallSkullBlock.FACING, facing -> special(new SkullSpecialRenderer.Unbaked(type), SkullBlockRenderer.TRANSFORMATIONS.wallTransformation(facing))
|
| 147 | );
|
| 148 | }
|
| 149 |
|
| 150 | /**
|
| 151 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 152 | */
|
| 153 | public static void createMobHeads(final BuiltInBlockModels.Builder builder, final Types type, final Block ground, final Block wall) {
|
| 154 | builder.put(createMobHead(type), ground);
|
| 155 | builder.put(createMobWallHead(type), wall);
|
| 156 | }
|
| 157 |
|
| 158 | /**
|
| 159 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 160 | */
|
| 161 | public static BuiltInBlockModels.SpecialModelFactory createPlayerHead() {
|
| 162 | return specialModelWithPropertyDispatch(
|
| 163 | PlayerHeadBlock.ROTATION, rotation -> special(new PlayerHeadSpecialRenderer.Unbaked(), SkullBlockRenderer.TRANSFORMATIONS.freeTransformations(rotation))
|
| 164 | );
|
| 165 | }
|
| 166 |
|
| 167 | /**
|
| 168 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 169 | */
|
| 170 | public static BuiltInBlockModels.SpecialModelFactory createPlayerWallHead() {
|
| 171 | return specialModelWithPropertyDispatch(
|
| 172 | PlayerWallHeadBlock.FACING, facing -> special(new PlayerHeadSpecialRenderer.Unbaked(), SkullBlockRenderer.TRANSFORMATIONS.wallTransformation(facing))
|
| 173 | );
|
| 174 | }
|
| 175 |
|
| 176 | /**
|
| 177 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 178 | */
|
| 179 | public static BuiltInBlockModels.SpecialModelFactory createBanner(final DyeColor color) {
|
| 180 | return specialModelWithPropertyDispatch(
|
| 181 | BannerBlock.ROTATION,
|
| 182 | rotation -> special(new BannerSpecialRenderer.Unbaked(color, AttachmentType.GROUND), BannerRenderer.TRANSFORMATIONS.freeTransformations(rotation))
|
| 183 | );
|
| 184 | }
|
| 185 |
|
| 186 | /**
|
| 187 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 188 | */
|
| 189 | public static BuiltInBlockModels.SpecialModelFactory createWallBanner(final DyeColor color) {
|
| 190 | return specialModelWithPropertyDispatch(
|
| 191 | WallBannerBlock.FACING,
|
| 192 | facing -> special(new BannerSpecialRenderer.Unbaked(color, AttachmentType.WALL), BannerRenderer.TRANSFORMATIONS.wallTransformation(facing))
|
| 193 | );
|
| 194 | }
|
| 195 |
|
| 196 | /**
|
| 197 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 198 | */
|
| 199 | public static BuiltInBlockModels.SpecialModelFactory createShulkerBox() {
|
| 200 | return specialModelWithPropertyDispatch(
|
| 201 | ShulkerBoxBlock.FACING, facing -> special(new ShulkerBoxSpecialRenderer.Unbaked(), ShulkerBoxRenderer.modelTransform(facing))
|
| 202 | );
|
| 203 | }
|
| 204 |
|
| 205 | /**
|
| 206 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 207 | */
|
| 208 | public static BuiltInBlockModels.SpecialModelFactory createDyedShulkerBox(final DyeColor color) {
|
| 209 | return specialModelWithPropertyDispatch(
|
| 210 | ShulkerBoxBlock.FACING, facing -> special(new ShulkerBoxSpecialRenderer.Unbaked(color), ShulkerBoxRenderer.modelTransform(facing))
|
| 211 | );
|
| 212 | }
|
| 213 |
|
| 214 | /**
|
| 215 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 216 | */
|
| 217 | public static BlockModel.Unbaked createChest(final Identifier texture, final ChestType chestType, final Direction facing) {
|
| 218 | return special(new ChestSpecialRenderer.Unbaked(texture, chestType), ChestRenderer.modelTransformation(facing));
|
| 219 | }
|
| 220 |
|
| 221 | /**
|
| 222 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 223 | */
|
| 224 | public static BuiltInBlockModels.SpecialModelFactory createSingletonChest(final Identifier texture) {
|
| 225 | return specialModelWithPropertyDispatch(ChestBlock.FACING, facing -> createChest(texture, ChestType.SINGLE, facing));
|
| 226 | }
|
| 227 |
|
| 228 | /**
|
| 229 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 230 | */
|
| 231 | public static BuiltInBlockModels.SpecialModelFactory createChest(final MultiblockChestResources<Identifier> textures) {
|
| 232 | return specialModelWithPropertyDispatch(ChestBlock.FACING, ChestBlock.TYPE, (facing, type) -> createChest(textures.select(type), type, facing));
|
| 233 | }
|
| 234 |
|
| 235 | /**
|
| 236 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 237 | */
|
| 238 | public static BuiltInBlockModels.SpecialModelFactory createXmasChest(final MultiblockChestResources<Identifier> textures) {
|
| 239 | return specialModelWithPropertyDispatch(
|
| 240 | ChestBlock.FACING,
|
| 241 | ChestBlock.TYPE,
|
| 242 | (facing, type) -> new ConditionalBlockModel.Unbaked(
|
| 243 | Optional.empty(), new IsXmas(), createChest(ChestSpecialRenderer.CHRISTMAS.select(type), type, facing), createChest(textures.select(type), type, facing)
|
| 244 | )
|
| 245 | );
|
| 246 | }
|
| 247 |
|
| 248 | /**
|
| 249 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 250 | */
|
| 251 | public static BuiltInBlockModels.SpecialModelFactory createCopperGolem(final WeatherState weatherState) {
|
| 252 | return specialModelWithPropertyDispatch(
|
| 253 | CopperGolemStatueBlock.FACING,
|
| 254 | CopperGolemStatueBlock.POSE,
|
| 255 | (facing, pose) -> special(new CopperGolemStatueSpecialRenderer.Unbaked(weatherState, pose), CopperGolemStatueBlockRenderer.modelTransformation(facing))
|
| 256 | );
|
| 257 | }
|
| 258 |
|
| 259 | /**
|
| 260 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 261 | */
|
| 262 | public static BuiltInBlockModels.SpecialModelFactory createDecoratedPot() {
|
| 263 | return specialModelWithPropertyDispatch(
|
| 264 | DecoratedPotBlock.HORIZONTAL_FACING, facing -> special(new DecoratedPotSpecialRenderer.Unbaked(), DecoratedPotRenderer.modelTransformation(facing))
|
| 265 | );
|
| 266 | }
|
| 267 |
|
| 268 | /**
|
| 269 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 270 | */
|
| 271 | public static BlockStateModelWrapper.Unbaked createBlockStateModelWrapper(final BlockColors blockColors, final BlockState blockState) {
|
| 272 | return new BlockStateModelWrapper.Unbaked(blockState, blockColors.getTintSources(blockState), Optional.empty());
|
| 273 | }
|
| 274 |
|
| 275 | /**
|
| 276 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 277 | */
|
| 278 | public static CompositeBlockModel.Unbaked combineSpecialAndBlockModels(
|
| 279 | final BlockModel.Unbaked specialModel, final BlockColors blockColors, final BlockState blockState
|
| 280 | ) {
|
| 281 | return new CompositeBlockModel.Unbaked(createBlockStateModelWrapper(blockColors, blockState), specialModel, Optional.empty());
|
| 282 | }
|
| 283 |
|
| 284 | /**
|
| 285 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 286 | */
|
| 287 | public static SelectBlockModel.Unbaked createFlowerBedModel(final BlockColors blockColors, final BlockState blockState) {
|
| 288 | List<BlockTintSource> tintSources = blockColors.getTintSources(blockState);
|
| 289 | Transformation customFlowerTransform = new Transformation(new Vector3f(0.25F, 0.0F, 0.25F), null, null, null);
|
| 290 | BlockStateModelWrapper.Unbaked customTransformModel = new BlockStateModelWrapper.Unbaked(blockState, tintSources, Optional.of(customFlowerTransform));
|
| 291 | BlockStateModelWrapper.Unbaked normalTransformModel = new BlockStateModelWrapper.Unbaked(blockState, tintSources, Optional.empty());
|
| 292 | return new SelectBlockModel.Unbaked(
|
| 293 | Optional.empty(),
|
| 294 | new SelectBlockModel.UnbakedSwitch<>(
|
| 295 | new DisplayContext(), List.of(new SelectBlockModel.SwitchCase<>(List.of(CopperGolemRenderer.BLOCK_DISPLAY_CONTEXT), customTransformModel))
|
| 296 | ),
|
| 297 | Optional.of(normalTransformModel)
|
| 298 | );
|
| 299 | }
|
| 300 |
|
| 301 | /**
|
| 302 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 303 | */
|
| 304 | public static BlockModel.Unbaked createEnchantingTable() {
|
| 305 | return special(
|
| 306 | new BookSpecialRenderer.Unbaked(0.0F, 0.0F, 0.0F),
|
| 307 | new Transformation(new Vector3f(0.5F, 0.8125F, 0.5F), Axis.ZP.rotationDegrees(180.0F), null, Axis.XP.rotationDegrees(90.0F))
|
| 308 | );
|
| 309 | }
|
| 310 |
|
| 311 | /**
|
| 312 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 313 | */
|
| 314 | public static <P extends Comparable<P>> BuiltInBlockModels.SpecialModelFactory specialModelWithPropertyDispatch(
|
| 315 | final Property<P> property, final Function<P, BlockModel.Unbaked> blockModel
|
| 316 | ) {
|
| 317 | return state -> {
|
| 318 | P value = state.getValue(property);
|
| 319 | return blockModel.apply(value);
|
| 320 | };
|
| 321 | }
|
| 322 |
|
| 323 | /**
|
| 324 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 325 | */
|
| 326 | public static <P1 extends Comparable<P1>, P2 extends Comparable<P2>> BuiltInBlockModels.SpecialModelFactory specialModelWithPropertyDispatch(
|
| 327 | final Property<P1> property1, final Property<P2> property2, final BiFunction<P1, P2, BlockModel.Unbaked> blockModel
|
| 328 | ) {
|
| 329 | return state -> {
|
| 330 | P1 value1 = state.getValue(property1);
|
| 331 | P2 value2 = state.getValue(property2);
|
| 332 | return blockModel.apply(value1, value2);
|
| 333 | };
|
| 334 | }
|
| 335 |
|
| 336 | public static Map<BlockState, BlockModel.Unbaked> createBlockModels(final BlockColors blockColors) {
|
| 337 | BuiltInBlockModels.Builder builder = new BuiltInBlockModels.Builder(blockColors);
|
| 338 | addDefaults(builder);
|
| 339 | return builder.build();
|
| 340 | }
|
| 341 |
|
| 342 | /**
|
| 343 | * Access widened by fabric-rendering-v1 to accessible
|
| 344 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 345 | */
|
| 346 | @Environment(EnvType.CLIENT)
|
| 347 | public static class Builder {
|
| 348 | private final BlockColors blockColors;
|
| 349 | private final Map<BlockState, BlockModel.Unbaked> result = new HashMap<>();
|
| 350 |
|
| 351 | /**
|
| 352 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 353 | */
|
| 354 | public Builder(final BlockColors blockColors) {
|
| 355 | this.blockColors = blockColors;
|
| 356 | }
|
| 357 |
|
| 358 | /**
|
| 359 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 360 | */
|
| 361 | public final void put(final BuiltInBlockModels.ModelFactory factory, final Block a, final Block b) {
|
| 362 | this.put(factory, a);
|
| 363 | this.put(factory, b);
|
| 364 | }
|
| 365 |
|
| 366 | /**
|
| 367 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 368 | */
|
| 369 | public final void put(final BlockModel.Unbaked specialModel, final Block block) {
|
| 370 | this.put((BuiltInBlockModels.SpecialModelFactory)var1 -> specialModel, block);
|
| 371 | }
|
| 372 |
|
| 373 | /**
|
| 374 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 375 | */
|
| 376 | public final void put(final BuiltInBlockModels.ModelFactory factory, final Block block) {
|
| 377 | for (BlockState blockState : block.getStateDefinition().getPossibleStates()) {
|
| 378 | this.result.put(blockState, factory.create(this.blockColors, blockState));
|
| 379 | }
|
| 380 | }
|
| 381 |
|
| 382 | public Map<BlockState, BlockModel.Unbaked> build() {
|
| 383 | return Map.copyOf(this.result);
|
| 384 | }
|
| 385 | }
|
| 386 |
|
| 387 | /**
|
| 388 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 389 | */
|
| 390 | @FunctionalInterface
|
| 391 | @Environment(EnvType.CLIENT)
|
| 392 | public interface ModelFactory {
|
| 393 | BlockModel.Unbaked create(BlockColors colors, BlockState state);
|
| 394 | }
|
| 395 |
|
| 396 | /**
|
| 397 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 398 | */
|
| 399 | @FunctionalInterface
|
| 400 | @Environment(EnvType.CLIENT)
|
| 401 | public interface SpecialModelFactory extends BuiltInBlockModels.ModelFactory {
|
| 402 | @Override
|
| 403 | default BlockModel.Unbaked create(final BlockColors colors, final BlockState state) {
|
| 404 | return BuiltInBlockModels.combineSpecialAndBlockModels(this.createSpecial(state), colors, state);
|
| 405 | }
|
| 406 |
|
| 407 | BlockModel.Unbaked createSpecial(BlockState state);
|
| 408 | }
|
| 409 | }
|
| 410 |
|