Search in sources :

Example 6 with MapItemSavedData

use of net.minecraft.world.level.saveddata.maps.MapItemSavedData 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

MapItemSavedData (net.minecraft.world.level.saveddata.maps.MapItemSavedData)6 BlockRenderDispatcher (net.minecraft.client.renderer.block.BlockRenderDispatcher)1 ModelManager (net.minecraft.client.resources.model.ModelManager)1 ModelResourceLocation (net.minecraft.client.resources.model.ModelResourceLocation)1 Direction (net.minecraft.core.Direction)1 ServerLevel (net.minecraft.server.level.ServerLevel)1 ItemStack (net.minecraft.world.item.ItemStack)1 MapItem (net.minecraft.world.item.MapItem)1 Vec3 (net.minecraft.world.phys.Vec3)1 CraftServer (org.bukkit.craftbukkit.v1_17_R1.CraftServer)1 CraftServer (org.bukkit.craftbukkit.v1_18_R1.CraftServer)1 CreateMapEvent (org.spongepowered.api.event.action.CreateMapEvent)1 MapInfo (org.spongepowered.api.map.MapInfo)1 MapIdTrackerBridge (org.spongepowered.common.bridge.map.MapIdTrackerBridge)1 SpongeMapStorage (org.spongepowered.common.map.SpongeMapStorage)1