Search in sources :

Example 1 with ModelHolder

use of com.minecolonies.structures.lib.ModelHolder in project minecolonies by Minecolonies.

the class RenderUtils method renderColonyBorder.

/**
     * Render the colony border.
     * @param position the position of the structure.
     * @param clientWorld the world.
     * @param partialTicks the partial ticks.
     * @param thePlayer the player clicking.
     * @param colonyBorder the border of the colony.
     */
public static void renderColonyBorder(final BlockPos position, final WorldClient clientWorld, final float partialTicks, final EntityPlayerSP thePlayer, final List<BlockPos> colonyBorder) {
    if (colonyBorder.isEmpty()) {
        calculateColonyBorder(clientWorld, thePlayer, colonyBorder);
    }
    for (final BlockPos pos : colonyBorder) {
        final Block block = Blocks.DIAMOND_BLOCK;
        final IBlockState iblockstate = block.getDefaultState();
        final IBlockState iBlockExtendedState = block.getExtendedState(iblockstate, clientWorld, pos);
        final IBakedModel ibakedmodel = Minecraft.getMinecraft().getBlockRendererDispatcher().getModelForState(iblockstate);
        final TileEntity tileentity = null;
        final ModelHolder models = new ModelHolder(pos, iblockstate, iBlockExtendedState, tileentity, ibakedmodel);
        Structure.getQuads(models, models.quads);
        Settings.instance.getActiveStructure().renderGhost(clientWorld, models, thePlayer, partialTicks);
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IBlockState(net.minecraft.block.state.IBlockState) ModelHolder(com.minecolonies.structures.lib.ModelHolder) Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.math.BlockPos) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel)

Example 2 with ModelHolder

use of com.minecolonies.structures.lib.ModelHolder in project minecolonies by Minecolonies.

the class Structure method renderStructure.

/**
     * Renders the structure.
     *
     * @param startingPos  the start pos to render.
     * @param clientWorld  the world of the client.
     * @param player       the player object.
     * @param partialTicks the partial ticks.
     */
public void renderStructure(@NotNull final BlockPos startingPos, @NotNull final World clientWorld, @NotNull final EntityPlayer player, final float partialTicks) {
    final Template.BlockInfo[] blockList = this.getBlockInfoWithSettings(this.settings);
    final Entity[] entityList = this.getEntityInfoWithSettings(clientWorld, startingPos, this.settings);
    for (final Template.BlockInfo aBlockList : blockList) {
        Block block = aBlockList.blockState.getBlock();
        IBlockState iblockstate = aBlockList.blockState;
        if (block == ModBlocks.blockSubstitution) {
            continue;
        }
        if (block == ModBlocks.blockSolidSubstitution) {
            iblockstate = BlockUtils.getSubstitutionBlockAtWorld(clientWorld, startingPos);
            block = iblockstate.getBlock();
        }
        final BlockPos blockpos = aBlockList.pos.add(startingPos);
        final IBlockState iBlockExtendedState = block.getExtendedState(iblockstate, clientWorld, blockpos);
        final IBakedModel ibakedmodel = Minecraft.getMinecraft().getBlockRendererDispatcher().getModelForState(iblockstate);
        TileEntity tileentity = null;
        if (block.hasTileEntity(iblockstate) && aBlockList.tileentityData != null) {
            tileentity = block.createTileEntity(clientWorld, iblockstate);
            tileentity.readFromNBT(aBlockList.tileentityData);
        }
        final ModelHolder models = new ModelHolder(blockpos, iblockstate, iBlockExtendedState, tileentity, ibakedmodel);
        getQuads(models, models.quads);
        this.renderGhost(clientWorld, models, player, partialTicks);
    }
    for (final Entity anEntityList : entityList) {
        if (anEntityList != null) {
            Minecraft.getMinecraft().getRenderManager().renderEntityStatic(anEntityList, 0.0F, true);
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) Entity(net.minecraft.entity.Entity) FakeEntity(com.minecolonies.structures.fake.FakeEntity) TileEntity(net.minecraft.tileentity.TileEntity) IBlockState(net.minecraft.block.state.IBlockState) ModelHolder(com.minecolonies.structures.lib.ModelHolder) Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.math.BlockPos) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) Template(net.minecraft.world.gen.structure.template.Template)

Aggregations

ModelHolder (com.minecolonies.structures.lib.ModelHolder)2 Block (net.minecraft.block.Block)2 IBlockState (net.minecraft.block.state.IBlockState)2 IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)2 TileEntity (net.minecraft.tileentity.TileEntity)2 BlockPos (net.minecraft.util.math.BlockPos)2 FakeEntity (com.minecolonies.structures.fake.FakeEntity)1 Entity (net.minecraft.entity.Entity)1 Template (net.minecraft.world.gen.structure.template.Template)1