package slimeknights.mantle.client.model; import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.model.BakedQuad; import net.minecraft.client.renderer.model.IBakedModel; import net.minecraft.client.renderer.model.ItemCameraTransforms; import net.minecraft.client.renderer.model.ItemOverrideList; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.util.EnumFacing; import org.apache.commons.lang3.tuple.Pair; import java.util.List; import java.util.Random; import javax.annotation.Nonnull; import javax.annotation.Nullable; import javax.vecmath.Matrix4f; import slimeknights.mantle.client.ModelHelper; /** * Takes a blockmodel and applies the standard-block-perspective for third_person to it */ public class BlockItemModelWrapper implements IBakedModel { private final IBakedModel parent; public BlockItemModelWrapper(IBakedModel parent) { this.parent = parent; } @Override public Pair handlePerspective(ItemCameraTransforms.TransformType cameraTransformType) { Matrix4f matrix = null; // fix transformation in hand if(cameraTransformType == ItemCameraTransforms.TransformType.THIRD_PERSON_RIGHT_HAND) { matrix = ModelHelper.BLOCK_THIRD_PERSON_RIGHT.getMatrixVec(); } else if(cameraTransformType == ItemCameraTransforms.TransformType.THIRD_PERSON_LEFT_HAND) { matrix = ModelHelper.BLOCK_THIRD_PERSON_LEFT.getMatrixVec(); } return Pair.of(this, matrix); } @Nonnull @Override public List getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, Random rand) { return parent.getQuads(state, side, rand); } @Override public boolean isAmbientOcclusion() { return false; } @Override public boolean isGui3d() { return parent.isGui3d(); } @Override public boolean isBuiltInRenderer() { return parent.isBuiltInRenderer(); } @Nonnull @Override public TextureAtlasSprite getParticleTexture() { return parent.getParticleTexture(); } @Nonnull @Override public ItemCameraTransforms getItemCameraTransforms() { return parent.getItemCameraTransforms(); } @Nonnull @Override public ItemOverrideList getOverrides() { return ItemOverrideList.EMPTY; } }