diff --git a/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/storage/diskdrive/DiskDriveBakedModel.java b/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/storage/diskdrive/DiskDriveBakedModel.java index 8816c67f4..9918af879 100644 --- a/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/storage/diskdrive/DiskDriveBakedModel.java +++ b/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/storage/diskdrive/DiskDriveBakedModel.java @@ -5,21 +5,23 @@ import com.refinedmods.refinedstorage2.platform.common.storage.diskdrive.AbstractDiskDriveBlockEntity; import com.refinedmods.refinedstorage2.platform.common.storage.diskdrive.DiskDriveBlock; import com.refinedmods.refinedstorage2.platform.common.support.direction.BiDirection; +import com.refinedmods.refinedstorage2.platform.forge.support.render.DiskModelBaker; +import com.refinedmods.refinedstorage2.platform.forge.support.render.ItemBakedModel; +import com.refinedmods.refinedstorage2.platform.forge.support.render.RotationTranslationModelBaker; +import com.refinedmods.refinedstorage2.platform.forge.support.render.TransformationBuilder; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; -import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; -import java.util.function.BiFunction; -import java.util.function.Function; import javax.annotation.Nullable; import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheLoader; import com.google.common.cache.LoadingCache; +import com.mojang.math.Transformation; import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.block.model.BakedQuad; @@ -38,50 +40,46 @@ import org.joml.Vector3f; class DiskDriveBakedModel extends BakedModelWrapper { - private static final Vector3f[] TRANSLATORS = new Vector3f[8]; - - static { + private final LoadingCache> cache; + private final ItemOverrides itemOverrides = new DiskDriveItemOverrides(); + private final Vector3f[] diskTranslations = new Vector3f[8]; + + DiskDriveBakedModel(final BakedModel baseModel, + final RotationTranslationModelBaker baseModelBaker, + final DiskModelBaker diskModelBaker, + final RotationTranslationModelBaker ledInactiveModelBaker) { + super(baseModel); int i = 0; for (int y = 0; y < 4; ++y) { for (int x = 0; x < 2; ++x) { - TRANSLATORS[i++] = new Vector3f( - x == 0 ? -(2F / 16F) : -(9F / 16F), - -((y * 3F) / 16F) - (2F / 16F), - 0 - ); + this.diskTranslations[i++] = getDiskTranslation(x, y); } } - } - - private final BakedModel baseModel; - private final Function baseModelBakery; - private final Map> diskModelBakeries; - private final Map> diskItemModelBakeries; - private final Function ledInactiveModelBakery; - - private final ItemOverrides overrides = new DiskDriveItemOverrides(); - - private final LoadingCache> cache = CacheBuilder - .newBuilder() - .build(new DiskDriveCacheLoader()); - private final Map, DiskDriveItemBakedModel> itemCache = new HashMap<>(); - - DiskDriveBakedModel(final Function baseModelBakery, - final BakedModel baseModel, - final Map> diskModelBakeries, - final Map> diskItemModelBakeries, - final Function ledInactiveModelBakery) { - super(baseModel); - this.baseModel = baseModel; - this.baseModelBakery = baseModelBakery; - this.diskModelBakeries = diskModelBakeries; - this.diskItemModelBakeries = diskItemModelBakeries; - this.ledInactiveModelBakery = ledInactiveModelBakery; + this.cache = CacheBuilder.newBuilder().build(CacheLoader.from(cacheKey -> { + final Transformation rotation = TransformationBuilder.create().rotate(cacheKey.direction).build(); + final RandomSource rand = RandomSource.create(); + final List quads = new ArrayList<>( + baseModelBaker.bake(rotation).getQuads(null, cacheKey.side, rand) + ); + for (int j = 0; j < diskTranslations.length; ++j) { + final Disk disk = cacheKey.disks[j]; + quads.addAll(getDiskQuads(diskModelBaker, cacheKey, disk, j)); + if (cacheKey.withInactiveLed && disk.state() == StorageState.INACTIVE) { + final Transformation ledTransform = TransformationBuilder + .create() + .rotate(cacheKey.direction) + .translate(diskTranslations[j]) + .build(); + quads.addAll(ledInactiveModelBaker.bake(ledTransform).getQuads(null, cacheKey.side, rand)); + } + } + return quads; + })); } @Override public ItemOverrides getOverrides() { - return overrides; + return itemOverrides; } @Override @@ -101,17 +99,51 @@ public List getQuads(@Nullable final BlockState state, if (disks == null) { return super.getQuads(state, side, rand); } - final DiskDriveStateCacheKey cacheKey = new DiskDriveStateCacheKey( - state, - side, - disks, - rand, - direction + return cache.getUnchecked(new CacheKey(side, false, direction, disks)); + } + + private List getDiskQuads(final DiskModelBaker diskBakers, + final CacheKey cacheKey, + final Disk disk, + final int index) { + if (disk.state() == StorageState.NONE || disk.item() == null) { + return Collections.emptyList(); + } + final RotationTranslationModelBaker diskBaker = diskBakers.forDisk(disk.item()); + if (diskBaker == null) { + return Collections.emptyList(); + } + final Transformation diskTransform = TransformationBuilder.create() + .rotate(cacheKey.direction) + .translate(diskTranslations[index]) + .build(); + return diskBaker.bake(diskTransform).getQuads(null, cacheKey.side, RandomSource.create()); + } + + private static Vector3f getDiskTranslation(final int x, final int y) { + return new Vector3f( + x == 0 ? -(2F / 16F) : -(9F / 16F), + -((y * 3F) / 16F) - (2F / 16F), + 0 ); - return cache.getUnchecked(cacheKey); } private class DiskDriveItemOverrides extends ItemOverrides { + private final LoadingCache itemCache = CacheBuilder.newBuilder().build( + CacheLoader.from(cacheKey -> new ItemBakedModel( + originalModel, + cache.getUnchecked(cacheKey), + Map.of( + Direction.NORTH, cache.getUnchecked(cacheKey.withSide(Direction.NORTH)), + Direction.EAST, cache.getUnchecked(cacheKey.withSide(Direction.EAST)), + Direction.SOUTH, cache.getUnchecked(cacheKey.withSide(Direction.SOUTH)), + Direction.WEST, cache.getUnchecked(cacheKey.withSide(Direction.WEST)), + Direction.UP, cache.getUnchecked(cacheKey.withSide(Direction.UP)), + Direction.DOWN, cache.getUnchecked(cacheKey.withSide(Direction.DOWN)) + ) + )) + ); + @Nullable @Override public BakedModel resolve(final BakedModel bakedModel, @@ -121,41 +153,20 @@ public BakedModel resolve(final BakedModel bakedModel, final int seed) { final CompoundTag tag = BlockItem.getBlockEntityData(stack); if (tag == null) { - return baseModel.getOverrides().resolve(bakedModel, stack, level, entity, seed); + return originalModel.getOverrides().resolve(bakedModel, stack, level, entity, seed); } - final List disks = new ArrayList<>(); - for (int i = 0; i < TRANSLATORS.length; ++i) { - final Item disk = AbstractDiskDriveBlockEntity.getDisk(tag, i); - disks.add(disk); + final Disk[] disks = new Disk[8]; + for (int i = 0; i < diskTranslations.length; ++i) { + final Item diskItem = AbstractDiskDriveBlockEntity.getDisk(tag, i); + disks[i] = new Disk(diskItem, diskItem == null ? StorageState.NONE : StorageState.INACTIVE); } - return itemCache.computeIfAbsent(disks, key -> new DiskDriveItemBakedModel( - bakedModel, - diskItemModelBakeries, - ledInactiveModelBakery, - TRANSLATORS, - disks - )); + return itemCache.getUnchecked(new CacheKey(null, true, BiDirection.NORTH, disks)); } } - private static final class DiskDriveStateCacheKey { - private final BlockState state; - @Nullable - private final Direction side; - private final Disk[] disks; - private final RandomSource random; - private final BiDirection direction; - - DiskDriveStateCacheKey(final BlockState state, - @Nullable final Direction side, - final Disk[] disks, - final RandomSource random, - final BiDirection direction) { - this.state = state; - this.side = side; - this.disks = disks; - this.random = random; - this.direction = direction; + private record CacheKey(@Nullable Direction side, boolean withInactiveLed, BiDirection direction, Disk[] disks) { + CacheKey withSide(final Direction newSide) { + return new CacheKey(newSide, withInactiveLed, direction, disks); } @Override @@ -166,57 +177,26 @@ public boolean equals(final Object o) { if (o == null || getClass() != o.getClass()) { return false; } - final DiskDriveStateCacheKey that = (DiskDriveStateCacheKey) o; - return state.equals(that.state) && side == that.side && Arrays.equals(disks, that.disks); + final CacheKey cacheKey = (CacheKey) o; + return side == cacheKey.side && direction == cacheKey.direction && Arrays.equals(disks, cacheKey.disks) + && withInactiveLed == cacheKey.withInactiveLed; } @Override public int hashCode() { - int result = Objects.hash(state, side); + int result = Objects.hash(side, direction, withInactiveLed); result = 31 * result + Arrays.hashCode(disks); return result; } - } - private class DiskDriveCacheLoader extends CacheLoader> { @Override - public List load(final DiskDriveStateCacheKey key) { - final List quads = new ArrayList<>(getBaseQuads(key.state, key.random, key.side, key.direction)); - for (int i = 0; i < TRANSLATORS.length; ++i) { - final Disk disk = key.disks[i]; - quads.addAll(getDiskQuads(key, disk, i)); - } - return quads; - } - - @SuppressWarnings("deprecation") - private List getDiskQuads(final DiskDriveStateCacheKey key, - final Disk disk, - final int index) { - if (disk.state() == StorageState.NONE) { - return Collections.emptyList(); - } - final var diskModelBakery = diskModelBakeries.get(disk.item()); - if (diskModelBakery == null) { - return Collections.emptyList(); - } - return diskModelBakery.apply(key.direction, TRANSLATORS[index]).getQuads( - key.state, - key.side, - key.random - ); - } - - @SuppressWarnings("deprecation") - private List getBaseQuads(final BlockState state, - final RandomSource rand, - @Nullable final Direction side, - final BiDirection direction) { - return baseModelBakery.apply(direction).getQuads( - state, - side, - rand - ); + public String toString() { + return "CacheKey{" + + "side=" + side + + ", withInactiveLed=" + withInactiveLed + + ", direction=" + direction + + ", disks=" + Arrays.toString(disks) + + '}'; } } } diff --git a/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/storage/diskdrive/DiskDriveItemBakedModel.java b/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/storage/diskdrive/DiskDriveItemBakedModel.java deleted file mode 100644 index e4c106763..000000000 --- a/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/storage/diskdrive/DiskDriveItemBakedModel.java +++ /dev/null @@ -1,113 +0,0 @@ -package com.refinedmods.refinedstorage2.platform.forge.storage.diskdrive; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.EnumMap; -import java.util.List; -import java.util.Map; -import java.util.function.Function; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -import com.mojang.blaze3d.vertex.PoseStack; -import net.minecraft.client.renderer.block.model.BakedQuad; -import net.minecraft.client.renderer.block.model.ItemOverrides; -import net.minecraft.client.resources.model.BakedModel; -import net.minecraft.core.Direction; -import net.minecraft.util.RandomSource; -import net.minecraft.world.item.Item; -import net.minecraft.world.item.ItemDisplayContext; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraftforge.client.model.BakedModelWrapper; -import org.joml.Vector3f; - -class DiskDriveItemBakedModel extends BakedModelWrapper { - private final BakedModel baseModel; - private final Map> diskItemModelBakeries; - private final Function inactiveLedBakery; - private final Vector3f[] translators; - private final Map> cache = new EnumMap<>(Direction.class); - @Nullable - private List noSideCache; - private final List disks; - - DiskDriveItemBakedModel(final BakedModel baseModel, - final Map> diskItemModelBakeries, - final Function inactiveLedBakery, - final Vector3f[] translators, - final List disks) { - super(baseModel); - this.baseModel = baseModel; - this.diskItemModelBakeries = diskItemModelBakeries; - this.inactiveLedBakery = inactiveLedBakery; - this.translators = translators; - this.disks = disks; - } - - @Override - public ItemOverrides getOverrides() { - return ItemOverrides.EMPTY; - } - - @Override - @Nonnull - public List getQuads(@Nullable final BlockState state, - @Nullable final Direction side, - @Nonnull final RandomSource rand) { - if (side == null) { - if (noSideCache == null) { - noSideCache = createQuads(state, null, rand); - } - return noSideCache; - } - return cache.computeIfAbsent(side, key -> createQuads(state, side, rand)); - } - - @SuppressWarnings("deprecation") - private List createQuads(@Nullable final BlockState state, - @Nullable final Direction side, - final RandomSource rand) { - final List quads = new ArrayList<>(super.getQuads( - state, - side, - rand - )); - for (int i = 0; i < translators.length; ++i) { - final Item disk = disks.get(i); - final List diskQuads = getDiskQuads(state, side, rand, disk, i); - quads.addAll(diskQuads); - quads.addAll(inactiveLedBakery.apply(translators[i]).getQuads(state, side, rand)); - } - return quads; - } - - @SuppressWarnings("deprecation") - private List getDiskQuads(@Nullable final BlockState state, - @Nullable final Direction side, - final RandomSource rand, - @Nullable final Item diskItem, - final int i) { - if (diskItem == null) { - return Collections.emptyList(); - } - final Function diskModelBakery = diskItemModelBakeries.get(diskItem); - if (diskModelBakery == null) { - return Collections.emptyList(); - } - return diskModelBakery.apply(translators[i]).getQuads(state, side, rand); - } - - @Override - public List getRenderPasses(final ItemStack itemStack, final boolean fabulous) { - return List.of(this); - } - - @Override - public BakedModel applyTransform(final ItemDisplayContext cameraTransformType, - final PoseStack poseStack, - final boolean applyLeftHandTransform) { - baseModel.applyTransform(cameraTransformType, poseStack, applyLeftHandTransform); - return this; - } -} diff --git a/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/storage/diskdrive/DiskDriveUnbakedGeometry.java b/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/storage/diskdrive/DiskDriveUnbakedGeometry.java index b97915ade..481de4f96 100644 --- a/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/storage/diskdrive/DiskDriveUnbakedGeometry.java +++ b/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/storage/diskdrive/DiskDriveUnbakedGeometry.java @@ -1,15 +1,11 @@ package com.refinedmods.refinedstorage2.platform.forge.storage.diskdrive; import com.refinedmods.refinedstorage2.platform.api.PlatformApi; -import com.refinedmods.refinedstorage2.platform.common.support.direction.BiDirection; +import com.refinedmods.refinedstorage2.platform.forge.support.render.DiskModelBaker; +import com.refinedmods.refinedstorage2.platform.forge.support.render.RotationTranslationModelBaker; -import java.util.Map; -import java.util.Objects; -import java.util.function.BiFunction; import java.util.function.Function; -import java.util.stream.Collectors; -import com.mojang.math.Transformation; import net.minecraft.client.renderer.block.model.ItemOverrides; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.resources.model.BakedModel; @@ -18,12 +14,11 @@ import net.minecraft.client.resources.model.ModelState; import net.minecraft.client.resources.model.UnbakedModel; import net.minecraft.resources.ResourceLocation; -import net.minecraftforge.client.model.SimpleModelState; import net.minecraftforge.client.model.geometry.IGeometryBakingContext; import net.minecraftforge.client.model.geometry.IUnbakedGeometry; -import org.joml.Vector3f; import static com.refinedmods.refinedstorage2.platform.common.util.IdentifierUtil.createIdentifier; +import static java.util.Objects.requireNonNull; public class DiskDriveUnbakedGeometry implements IUnbakedGeometry { private static final ResourceLocation BASE_MODEL = createIdentifier("block/disk_drive/base"); @@ -49,62 +44,11 @@ public BakedModel bake(final IGeometryBakingContext context, final ModelState modelState, final ItemOverrides overrides, final ResourceLocation modelLocation) { - final var diskModelBakeries = PlatformApi.INSTANCE.getStorageContainerItemHelper() - .getDiskModelsByItem() - .entrySet() - .stream() - .collect(Collectors.toMap( - Map.Entry::getKey, - entry -> getDiskModelBakery(modelState, baker, spriteGetter, entry.getValue()) - )); - final var diskItemModelBakeries = PlatformApi.INSTANCE.getStorageContainerItemHelper() - .getDiskModelsByItem() - .entrySet() - .stream() - .collect(Collectors.toMap( - Map.Entry::getKey, - entry -> getItemModelBakery(modelState, baker, spriteGetter, entry.getValue()) - )); return new DiskDriveBakedModel( - getBaseModelBakery(modelState, baker, spriteGetter), - Objects.requireNonNull(baker.bake(BASE_MODEL, modelState, spriteGetter)), - diskModelBakeries, - diskItemModelBakeries, - getItemModelBakery(modelState, baker, spriteGetter, LED_INACTIVE_MODEL) + requireNonNull(baker.bake(BASE_MODEL, modelState, spriteGetter)), + new RotationTranslationModelBaker(modelState, baker, spriteGetter, BASE_MODEL), + new DiskModelBaker(modelState, baker, spriteGetter), + new RotationTranslationModelBaker(modelState, baker, spriteGetter, LED_INACTIVE_MODEL) ); } - - private Function getBaseModelBakery(final ModelState state, - final ModelBaker baker, - final Function sg) { - return direction -> { - final Transformation rotation = new Transformation(null, direction.getQuaternion(), null, null); - final ModelState wrappedState = new SimpleModelState(rotation, state.isUvLocked()); - return baker.bake(BASE_MODEL, wrappedState, sg); - }; - } - - private BiFunction getDiskModelBakery(final ModelState state, - final ModelBaker baker, - final Function - sg, - final ResourceLocation model) { - return (direction, trans) -> { - final Transformation translation = new Transformation(trans, null, null, null); - final Transformation rotation = new Transformation(null, direction.getQuaternion(), null, null); - final ModelState wrappedState = new SimpleModelState(rotation.compose(translation), state.isUvLocked()); - return baker.bake(model, wrappedState, sg); - }; - } - - private Function getItemModelBakery(final ModelState state, - final ModelBaker baker, - final Function sg, - final ResourceLocation model) { - return trans -> { - final Transformation translation = new Transformation(trans, null, null, null); - final ModelState wrappedState = new SimpleModelState(translation, state.isUvLocked()); - return baker.bake(model, wrappedState, sg); - }; - } } diff --git a/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/storage/portablegrid/PortableGridBakedModel.java b/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/storage/portablegrid/PortableGridBakedModel.java index 7e87ec907..fa805b886 100644 --- a/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/storage/portablegrid/PortableGridBakedModel.java +++ b/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/storage/portablegrid/PortableGridBakedModel.java @@ -12,6 +12,7 @@ import com.refinedmods.refinedstorage2.platform.forge.support.render.TransformationBuilder; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import javax.annotation.Nullable; @@ -32,36 +33,34 @@ import net.minecraftforge.client.model.data.ModelData; import org.joml.Vector3f; -public class PortableGridBakedModel extends BakedModelWrapper { +class PortableGridBakedModel extends BakedModelWrapper { private static final Vector3f MOVE_TO_DISK_LOCATION = new Vector3f(0, -12 / 16F, 9 / 16F); private final LoadingCache> cache; private final PortableGridItemOverrides itemOverrides = new PortableGridItemOverrides(); - public PortableGridBakedModel(final BakedModel baseModel, - final RotationTranslationModelBaker activeModelBaker, - final RotationTranslationModelBaker inactiveModelBaker, - final DiskModelBaker diskModelBaker) { + PortableGridBakedModel(final BakedModel baseModel, + final RotationTranslationModelBaker activeModelBaker, + final RotationTranslationModelBaker inactiveModelBaker, + final DiskModelBaker diskModelBaker) { super(baseModel); this.cache = CacheBuilder.newBuilder().build(CacheLoader.from(cacheKey -> { final RotationTranslationModelBaker baseModelBaker = cacheKey.active ? activeModelBaker : inactiveModelBaker; final List quads = new ArrayList<>(baseModelBaker.bake(TransformationBuilder.create() - .rotate(cacheKey.direction) - .build()) - .getQuads(null, cacheKey.side(), RandomSource.create(0))); + .rotate(cacheKey.direction) + .build()).getQuads(null, cacheKey.side(), RandomSource.create())); if (cacheKey.disk.item() == null) { return quads; } final RotationTranslationModelBaker diskBaker = diskModelBaker.forDisk(cacheKey.disk.item()); if (diskBaker != null) { quads.addAll(diskBaker.bake(TransformationBuilder.create() - .rotate(cacheKey.direction) - .translate(MOVE_TO_DISK_LOCATION) - .rotate(BiDirection.WEST) - .build()) - .getQuads(null, cacheKey.side(), RandomSource.create(0))); + .rotate(cacheKey.direction) + .translate(MOVE_TO_DISK_LOCATION) + .rotate(BiDirection.WEST) + .build()).getQuads(null, cacheKey.side(), RandomSource.create())); } return quads; })); @@ -94,7 +93,11 @@ public ItemOverrides getOverrides() { private class PortableGridItemOverrides extends ItemOverrides { private final LoadingCache itemCache = CacheBuilder.newBuilder().build( - CacheLoader.from(cacheKey -> new ItemBakedModel(originalModel, cache.getUnchecked(cacheKey))) + CacheLoader.from(cacheKey -> new ItemBakedModel( + originalModel, + cache.getUnchecked(cacheKey), + Collections.emptyMap() + )) ); @Override diff --git a/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/storage/portablegrid/PortableGridUnbakedGeometry.java b/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/storage/portablegrid/PortableGridUnbakedGeometry.java index ad9581f4f..c031be700 100644 --- a/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/storage/portablegrid/PortableGridUnbakedGeometry.java +++ b/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/storage/portablegrid/PortableGridUnbakedGeometry.java @@ -20,7 +20,6 @@ import static com.refinedmods.refinedstorage2.platform.common.util.IdentifierUtil.createIdentifier; import static java.util.Objects.requireNonNull; -// TODO: Cleanup model rendering code. public class PortableGridUnbakedGeometry implements IUnbakedGeometry { private static final ResourceLocation ACTIVE_MODEL = createIdentifier("block/portable_grid/active"); private static final ResourceLocation INACTIVE_MODEL = createIdentifier("block/portable_grid/inactive"); diff --git a/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/support/render/ItemBakedModel.java b/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/support/render/ItemBakedModel.java index 75d2fae71..8ea0e223f 100644 --- a/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/support/render/ItemBakedModel.java +++ b/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/support/render/ItemBakedModel.java @@ -1,6 +1,8 @@ package com.refinedmods.refinedstorage2.platform.forge.support.render; +import java.util.Collections; import java.util.List; +import java.util.Map; import javax.annotation.Nullable; import com.mojang.blaze3d.vertex.PoseStack; @@ -15,18 +17,22 @@ import net.minecraftforge.client.model.BakedModelWrapper; public class ItemBakedModel extends BakedModelWrapper { - private final List quads; + private final List unculledFaces; + private final Map> faces; - public ItemBakedModel(final BakedModel originalModel, final List quads) { + public ItemBakedModel(final BakedModel originalModel, + final List unculledFaces, + final Map> faces) { super(originalModel); - this.quads = quads; + this.unculledFaces = unculledFaces; + this.faces = faces; } @Override public List getQuads(@Nullable final BlockState state, @Nullable final Direction side, final RandomSource rand) { - return quads; + return side == null ? unculledFaces : faces.getOrDefault(side, Collections.emptyList()); } @Override