Search in sources :

Example 1 with TileEntityInfoPoster

use of com.minecolonies.coremod.tileentities.TileEntityInfoPoster 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)

Aggregations

TileEntityInfoPoster (com.minecolonies.coremod.tileentities.TileEntityInfoPoster)1 Structure (com.minecolonies.structures.helpers.Structure)1 ModelHolder (com.minecolonies.structures.lib.ModelHolder)1 Block (net.minecraft.block.Block)1 IBlockState (net.minecraft.block.state.IBlockState)1 IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)1 EnumFacing (net.minecraft.util.EnumFacing)1 BlockPos (net.minecraft.util.math.BlockPos)1