Search in sources :

Example 21 with ModelResourceLocation

use of net.minecraft.client.resources.model.ModelResourceLocation in project Tropicraft by Tropicraft.

the class BambooItemFrameRenderer method render.

@Override
public void render(BambooItemFrame entityIn, float entityYaw, float partialTicks, PoseStack matrixStackIn, MultiBufferSource bufferIn, int packedLightIn) {
    super.render(entityIn, entityYaw, partialTicks, matrixStackIn, bufferIn, packedLightIn);
    matrixStackIn.pushPose();
    Direction direction = entityIn.getDirection();
    Vec3 Vector3d = this.getRenderOffset(entityIn, partialTicks);
    matrixStackIn.translate(-Vector3d.x, -Vector3d.y, -Vector3d.z);
    double d0 = 0.46875D;
    matrixStackIn.translate((double) direction.getStepX() * 0.46875D, (double) direction.getStepY() * 0.46875D, (double) direction.getStepZ() * 0.46875D);
    matrixStackIn.mulPose(Vector3f.XP.rotationDegrees(entityIn.getXRot()));
    matrixStackIn.mulPose(Vector3f.YP.rotationDegrees(180.0F - entityIn.getYRot()));
    BlockRenderDispatcher blockrendererdispatcher = this.mc.getBlockRenderer();
    ModelManager modelmanager = blockrendererdispatcher.getBlockModelShaper().getModelManager();
    ModelResourceLocation modelresourcelocation = entityIn.getItem().getItem() instanceof MapItem ? LOCATION_MODEL_MAP : LOCATION_MODEL;
    matrixStackIn.pushPose();
    matrixStackIn.translate(-0.5D, -0.5D, -0.5D);
    blockrendererdispatcher.getModelRenderer().renderModel(matrixStackIn.last(), bufferIn.getBuffer(Sheets.solidBlockSheet()), null, modelmanager.getModel(modelresourcelocation), 1.0F, 1.0F, 1.0F, packedLightIn, OverlayTexture.NO_OVERLAY);
    matrixStackIn.popPose();
    ItemStack itemstack = entityIn.getItem();
    if (!itemstack.isEmpty()) {
        MapItemSavedData mapdata = MapItem.getSavedData(itemstack, entityIn.level);
        matrixStackIn.translate(0.0D, 0.0D, 0.4375D);
        int i = mapdata != null ? entityIn.getRotation() % 4 * 2 : entityIn.getRotation();
        matrixStackIn.mulPose(Vector3f.ZP.rotationDegrees((float) i * 360.0F / 8.0F));
        if (mapdata != null) {
            matrixStackIn.mulPose(Vector3f.ZP.rotationDegrees(180.0F));
            float f = 0.0078125F;
            matrixStackIn.scale(0.0078125F, 0.0078125F, 0.0078125F);
            matrixStackIn.translate(-64.0D, -64.0D, 0.0D);
            matrixStackIn.translate(0.0D, 0.0D, -1.0D);
            Integer id = MapItem.getMapId(itemstack);
            if (mapdata != null && id != null) {
                this.mc.gameRenderer.getMapRenderer().render(matrixStackIn, bufferIn, id, mapdata, true, packedLightIn);
            }
        } else {
            matrixStackIn.scale(0.5F, 0.5F, 0.5F);
            this.itemRenderer.renderStatic(itemstack, ItemTransforms.TransformType.FIXED, packedLightIn, OverlayTexture.NO_OVERLAY, matrixStackIn, bufferIn, entityIn.getId());
        }
    }
    matrixStackIn.popPose();
}
Also used : MapItemSavedData(net.minecraft.world.level.saveddata.maps.MapItemSavedData) BlockRenderDispatcher(net.minecraft.client.renderer.block.BlockRenderDispatcher) Vec3(net.minecraft.world.phys.Vec3) ModelResourceLocation(net.minecraft.client.resources.model.ModelResourceLocation) ModelManager(net.minecraft.client.resources.model.ModelManager) MapItem(net.minecraft.world.item.MapItem) ItemStack(net.minecraft.world.item.ItemStack) Direction(net.minecraft.core.Direction)

Aggregations

ModelResourceLocation (net.minecraft.client.resources.model.ModelResourceLocation)21 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)14 ItemMeshDefinition (net.minecraft.client.renderer.ItemMeshDefinition)8 ItemStack (net.minecraft.item.ItemStack)8 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)5 DimletType (mcjty.rftoolsdim.dimensions.dimlets.types.DimletType)2 IBlockState (net.minecraft.block.state.IBlockState)2 StateMapperBase (net.minecraft.client.renderer.block.statemap.StateMapperBase)2 IBakedModel (net.minecraft.client.resources.model.IBakedModel)2 Joiner (com.google.common.base.Joiner)1 HashMultimap (com.google.common.collect.HashMultimap)1 Multimap (com.google.common.collect.Multimap)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Minecraft (net.minecraft.client.Minecraft)1 BlockModelShaper (net.minecraft.client.renderer.block.BlockModelShaper)1 BlockRenderDispatcher (net.minecraft.client.renderer.block.BlockRenderDispatcher)1 BakedModel (net.minecraft.client.resources.model.BakedModel)1 ModelManager (net.minecraft.client.resources.model.ModelManager)1