Search in sources :

Example 51 with IBakedModel

use of net.minecraft.client.renderer.block.model.IBakedModel in project minecolonies by Minecolonies.

the class RenderUtils method renderSigns.

/**
 * Render informal signs at the citizen.
 *
 * @param clientWorld     the client world.
 * @param partialTicks    the partial ticks.
 * @param citizenDataView the citizen data.
 * @param player          the player.
 * @param citizen         the citizen position
 */
public static void renderSigns(final WorldClient clientWorld, final float partialTicks, final CitizenDataView citizenDataView, final EntityPlayer player, final BlockPos citizen) {
    final Block block = ModBlocks.blockInfoPoster;
    final BlockPos vector = citizen.subtract(player.getPosition());
    final EnumFacing facing = EnumFacing.getFacingFromVector(vector.getX(), 0, vector.getZ()).getOpposite();
    final BlockPos pos = citizen.up(2).offset(facing);
    final IBlockState iblockstate = block.getDefaultState().withProperty(BlockInfoPoster.FACING, facing);
    final IBlockState iBlockExtendedState = block.getExtendedState(iblockstate, clientWorld, pos);
    final IBakedModel ibakedmodel = Minecraft.getMinecraft().getBlockRendererDispatcher().getModelForState(iblockstate);
    final TileEntityInfoPoster sign = new TileEntityInfoPoster();
    sign.setPos(pos);
    for (int i = 0; i < sign.signText.length; i++) {
        if (i < citizenDataView.getLatestStatus().length) {
            sign.signText[i] = citizenDataView.getLatestStatus()[i];
        }
    }
    final ModelHolder models = new ModelHolder(pos, iblockstate, iBlockExtendedState, sign, ibakedmodel);
    Structure.getQuads(models, models.quads);
    new Structure(Minecraft.getMinecraft().world).renderGhost(clientWorld, models, player, partialTicks, false);
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) ModelHolder(com.minecolonies.structures.lib.ModelHolder) EnumFacing(net.minecraft.util.EnumFacing) Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.math.BlockPos) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) Structure(com.minecolonies.structures.helpers.Structure) TileEntityInfoPoster(com.minecolonies.coremod.tileentities.TileEntityInfoPoster)

Example 52 with IBakedModel

use of net.minecraft.client.renderer.block.model.IBakedModel in project YABBA by LatvianModder.

the class RenderItemBarrel method renderIcon.

@Override
public void renderIcon(TileItemBarrel barrel) {
    IBakedModel bakedmodel = ClientUtils.MC.getRenderItem().getItemModelWithOverrides(barrel.getStoredItemType(), barrel.getWorld(), ClientUtils.MC.player);
    GlStateManager.scale(0.4F, -0.4F, -0.02F);
    bakedmodel = ForgeHooksClient.handleCameraTransforms(bakedmodel, ItemCameraTransforms.TransformType.GUI, false);
    ClientUtils.MC.getRenderItem().renderItem(barrel.getStoredItemType(), bakedmodel);
}
Also used : IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel)

Example 53 with IBakedModel

use of net.minecraft.client.renderer.block.model.IBakedModel in project Solar by ArekkuusuJerii.

the class PhenomenaRenderer method renderTileEntityFast.

@Override
public void renderTileEntityFast(@Nonnull TilePhenomena phenomena, double x, double y, double z, float partialTick, int breakStage, float partial, @Nullable BufferBuilder renderer) {
    if (blockRenderer == null)
        blockRenderer = Minecraft.getMinecraft().getBlockRendererDispatcher();
    BlockPos pos = phenomena.getPos();
    IBlockAccess world = MinecraftForgeClient.getRegionRenderCache(phenomena.getWorld(), pos);
    IBlockState state = getState(phenomena, world, pos);
    if (state instanceof IExtendedBlockState) {
        IExtendedBlockState extendedState = (IExtendedBlockState) state;
        if (extendedState.getUnlistedNames().contains(Properties.AnimationProperty)) {
            // Using tile timer instead of world time.
            float time = ((20 - phenomena.timer)) / 20F;
            IAnimationStateMachine capability = phenomena.getCapability(CapabilityAnimation.ANIMATION_CAPABILITY, null);
            if (capability != null) {
                Pair<IModelState, Iterable<Event>> pair = capability.apply(time);
                extendedState = extendedState.withProperty(Properties.AnimationProperty, pair.getLeft());
                IBakedModel model = getModel(state);
                assert renderer != null;
                renderer.setTranslation(x - pos.getX(), y - pos.getY(), z - pos.getZ());
                blockRenderer.getBlockModelRenderer().renderModel(world, model, extendedState, pos, renderer, false);
            }
        }
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState) IBlockAccess(net.minecraft.world.IBlockAccess) IModelState(net.minecraftforge.common.model.IModelState) BlockPos(net.minecraft.util.math.BlockPos) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) IAnimationStateMachine(net.minecraftforge.common.model.animation.IAnimationStateMachine)

Example 54 with IBakedModel

use of net.minecraft.client.renderer.block.model.IBakedModel in project RFTools by McJty.

the class ElevatorTESR method renderBlock.

private static boolean renderBlock(BlockRendererDispatcher dispatcher, IBlockState state, BlockPos pos, IBlockAccess blockAccess, BufferBuilder worldRendererIn) {
    try {
        EnumBlockRenderType enumblockrendertype = state.getRenderType();
        if (enumblockrendertype == EnumBlockRenderType.INVISIBLE) {
            return false;
        } else {
            if (blockAccess.getWorldType() != WorldType.DEBUG_ALL_BLOCK_STATES) {
                try {
                    state = state.getActualState(blockAccess, pos);
                } catch (Exception var8) {
                }
            }
            switch(enumblockrendertype) {
                case MODEL:
                    IBakedModel model = dispatcher.getModelForState(state);
                    state = state.getBlock().getExtendedState(state, blockAccess, pos);
                    return dispatcher.getBlockModelRenderer().renderModel(blockAccess, model, state, pos, worldRendererIn, false);
                case ENTITYBLOCK_ANIMATED:
                    return false;
                default:
                    return false;
            }
        }
    } catch (Throwable throwable) {
        CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Tesselating block in world");
        CrashReportCategory crashreportcategory = crashreport.makeCategory("Block being tesselated");
        CrashReportCategory.addBlockInfo(crashreportcategory, pos, state.getBlock(), state.getBlock().getMetaFromState(state));
        throw new ReportedException(crashreport);
    }
}
Also used : CrashReport(net.minecraft.crash.CrashReport) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) ReportedException(net.minecraft.util.ReportedException) CrashReportCategory(net.minecraft.crash.CrashReportCategory) EnumBlockRenderType(net.minecraft.util.EnumBlockRenderType) ReportedException(net.minecraft.util.ReportedException)

Example 55 with IBakedModel

use of net.minecraft.client.renderer.block.model.IBakedModel in project Binnie by ForestryMC.

the class AABBModelBaker method bakeModel.

@Override
public IModelBakerModel bakeModel(boolean flip) {
    ModelRotation mr = ModelRotation.X0_Y0;
    if (flip) {
        mr = ModelRotation.X0_Y180;
    }
    // Add baked models to the current model.
    for (Pair<IBlockState, IBakedModel> bakedModel : bakedModels) {
        currentModel.addModelQuads(bakedModel);
    }
    for (Pair<IBlockState, IBakedModel> bakedModel : bakedModelsPost) {
        currentModel.addModelQuadsPost(bakedModel);
    }
    for (BoundModelBakerFace face : faces) {
        final AxisAlignedBB modelBounds = face.modelBounds;
        final Vector3f from = new Vector3f((float) modelBounds.minX * 16.0f, (float) modelBounds.minY * 16.0f, (float) modelBounds.minZ * 16.0f);
        final Vector3f to = new Vector3f((float) modelBounds.maxX * 16.0f, (float) modelBounds.maxY * 16.0f, (float) modelBounds.maxZ * 16.0f);
        final EnumFacing myFace = face.face;
        final float[] uvs = getFaceUvs(myFace, to, from);
        final BlockFaceUV uv = new BlockFaceUV(uvs, 0);
        final BlockPartFace bpf = new BlockPartFace(myFace, face.colorIndex, "", uv);
        BakedQuad bf = faceBakery.makeBakedQuad(from, to, bpf, face.spite, myFace, mr, null, true, true);
        currentModel.addQuad(myFace, bf);
    }
    return currentModel;
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) IBlockState(net.minecraft.block.state.IBlockState) ModelRotation(net.minecraft.client.renderer.block.model.ModelRotation) Vector3f(org.lwjgl.util.vector.Vector3f) EnumFacing(net.minecraft.util.EnumFacing) BlockPartFace(net.minecraft.client.renderer.block.model.BlockPartFace) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) BlockFaceUV(net.minecraft.client.renderer.block.model.BlockFaceUV)

Aggregations

IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)197 IBlockState (net.minecraft.block.state.IBlockState)94 BakedQuad (net.minecraft.client.renderer.block.model.BakedQuad)42 BlockPos (net.minecraft.util.math.BlockPos)40 ModelResourceLocation (net.minecraft.client.renderer.block.model.ModelResourceLocation)38 EnumFacing (net.minecraft.util.EnumFacing)38 ResourceLocation (net.minecraft.util.ResourceLocation)36 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)30 ItemStack (net.minecraft.item.ItemStack)27 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)24 Block (net.minecraft.block.Block)23 IModel (net.minecraftforge.client.model.IModel)22 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)22 ArrayList (java.util.ArrayList)20 IExtendedBlockState (net.minecraftforge.common.property.IExtendedBlockState)17 Minecraft (net.minecraft.client.Minecraft)15 BlockRendererDispatcher (net.minecraft.client.renderer.BlockRendererDispatcher)15 List (java.util.List)14 ItemOverride (net.minecraft.client.renderer.block.model.ItemOverride)14 ImmutableList (com.google.common.collect.ImmutableList)13