Search in sources :

Example 46 with IExtendedBlockState

use of net.minecraftforge.common.property.IExtendedBlockState in project AgriCraft by AgriCraft.

the class RenderBlockCustomWood method renderWorldBlockStatic.

@Override
public void renderWorldBlockStatic(ITessellator tessellator, IBlockState state, B block, EnumFacing side) {
    if (state instanceof IExtendedBlockState) {
        CustomWoodType type = ((IExtendedBlockState) state).getValue(AgriProperties.CUSTOM_WOOD_TYPE);
        this.renderWorldBlockWoodStatic(tessellator, (IExtendedBlockState) state, block, side, type.getIcon());
    }
}
Also used : IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState) CustomWoodType(com.infinityraider.agricraft.utility.CustomWoodType)

Example 47 with IExtendedBlockState

use of net.minecraftforge.common.property.IExtendedBlockState in project ImmersiveEngineering by BluSunrize.

the class TileRenderTurret method renderModelPart.

public static void renderModelPart(final BlockRendererDispatcher blockRenderer, Tessellator tessellator, VertexBuffer worldRenderer, World world, IBlockState state, IBakedModel model, BlockPos pos, String... parts) {
    if (state instanceof IExtendedBlockState)
        state = ((IExtendedBlockState) state).withProperty(Properties.AnimationProperty, new OBJState(Arrays.asList(parts), true));
    RenderHelper.disableStandardItemLighting();
    GlStateManager.blendFunc(770, 771);
    GlStateManager.enableBlend();
    GlStateManager.disableCull();
    if (Minecraft.isAmbientOcclusionEnabled())
        GlStateManager.shadeModel(7425);
    else
        GlStateManager.shadeModel(7424);
    worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
    worldRenderer.setTranslation(-.5 - pos.getX(), -.5 - pos.getY(), -.5 - pos.getZ());
    worldRenderer.color(255, 255, 255, 255);
    blockRenderer.getBlockModelRenderer().renderModel(world, model, state, pos, worldRenderer, true);
    worldRenderer.setTranslation(0.0D, 0.0D, 0.0D);
    tessellator.draw();
}
Also used : IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState) OBJState(net.minecraftforge.client.model.obj.OBJModel.OBJState)

Example 48 with IExtendedBlockState

use of net.minecraftforge.common.property.IExtendedBlockState in project ImmersiveEngineering by BluSunrize.

the class TileRenderAutoWorkbench method renderModelPart.

public static void renderModelPart(final BlockRendererDispatcher blockRenderer, Tessellator tessellator, VertexBuffer worldRenderer, World world, IBlockState state, IBakedModel model, BlockPos pos, String... parts) {
    if (state instanceof IExtendedBlockState)
        state = ((IExtendedBlockState) state).withProperty(Properties.AnimationProperty, new OBJState(Arrays.asList(parts), true));
    RenderHelper.disableStandardItemLighting();
    GlStateManager.blendFunc(770, 771);
    GlStateManager.enableBlend();
    GlStateManager.disableCull();
    if (Minecraft.isAmbientOcclusionEnabled())
        GlStateManager.shadeModel(7425);
    else
        GlStateManager.shadeModel(7424);
    worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
    worldRenderer.setTranslation(-.5 - pos.getX(), -.5 - pos.getY(), -.5 - pos.getZ());
    worldRenderer.color(255, 255, 255, 255);
    blockRenderer.getBlockModelRenderer().renderModel(world, model, state, pos, worldRenderer, true);
    worldRenderer.setTranslation(0.0D, 0.0D, 0.0D);
    tessellator.draw();
}
Also used : IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState) OBJState(net.minecraftforge.client.model.obj.OBJModel.OBJState)

Example 49 with IExtendedBlockState

use of net.minecraftforge.common.property.IExtendedBlockState in project BetterWithAddons by DaedalusGame.

the class BlockRopeSideways method getExtendedState.

@Override
public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) {
    TileEntity te = world instanceof ChunkCache ? ((ChunkCache) world).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK) : world.getTileEntity(pos);
    ItemStack planks = ItemStack.EMPTY;
    if (te instanceof TileEntityRopeSideways) {
        TileEntityRopeSideways tile = (TileEntityRopeSideways) te;
        planks = tile.getPlanks();
    }
    return ((IExtendedBlockState) state).withProperty(HELD_PLANKS, planks);
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityRopeSideways(betterwithaddons.tileentity.TileEntityRopeSideways) ChunkCache(net.minecraft.world.ChunkCache) IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState) ItemStack(net.minecraft.item.ItemStack)

Example 50 with IExtendedBlockState

use of net.minecraftforge.common.property.IExtendedBlockState in project Charset by CharsetMC.

the class RenderTileEntityStacks method getQuads.

@Override
public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, long rand) {
    if (side != null || !(state instanceof IExtendedBlockState)) {
        return Collections.emptyList();
    }
    TileEntityStacks stacks = ((IExtendedBlockState) state).getValue(BlockStacks.PROPERTY_TILE);
    if (stacks == null || stacks.stacks.isEmpty()) {
        return Collections.emptyList();
    }
    List<BakedQuad> list = new ArrayList<>();
    int i = 0;
    for (ItemMaterial material : stacks.stacks) {
        Vec3d[] vecs = INGOT_POSITIONS[i];
        ItemMaterial blockMaterial = material.getRelated("block");
        TextureAtlasSprite sprite;
        int c;
        if (blockMaterial == null) {
            ItemStack ingotStack = material.getStack();
            sprite = RenderUtils.getItemSprite(new ItemStack(Blocks.IRON_BLOCK));
            c = ColorLookupHandler.INSTANCE.getColor(ingotStack, RenderUtils.AveragingMode.FULL) | 0xFF000000;
        } else {
            sprite = RenderUtils.getItemSprite(blockMaterial.getStack());
            c = Minecraft.getMinecraft().getItemColors().colorMultiplier(blockMaterial.getStack(), 0);
        }
        float[] color = new float[] { MathHelper.clamp(((c >> 16) & 0xFF) / 255.0f, 0, 1), MathHelper.clamp(((c >> 8) & 0xFF) / 255.0f, 0, 1), MathHelper.clamp(((c) & 0xFF) / 255.0f, 0, 1), 1.0f };
        int j = 0;
        int yOff = (i >> 3) & 1;
        for (int[] vecOrder : QUAD_ORDERS[yOff]) {
            UnpackedBakedQuad.Builder builder = new UnpackedBakedQuad.Builder(DefaultVertexFormats.ITEM);
            EnumFacing face = QUAD_FACES[yOff][j];
            builder.setTexture(sprite);
            builder.setApplyDiffuseLighting(isAmbientOcclusion());
            builder.setContractUVs(false);
            builder.setQuadOrientation(face);
            int uv_offset = j < 4 ? 1 : 0;
            if (yOff == 1)
                uv_offset = 1 - uv_offset;
            for (int k = 0; k < vecOrder.length; k++) {
                Vec3d vec = vecs[vecOrder[k]];
                int[] uv = QUAD_UVS[(k + uv_offset) & 3];
                for (int e = 0; e < builder.getVertexFormat().getElementCount(); e++) {
                    VertexFormatElement el = builder.getVertexFormat().getElement(e);
                    switch(el.getUsage()) {
                        case POSITION:
                            builder.put(e, (float) vec.x / 16f, (float) vec.y / 16f, (float) vec.z / 16f, 1);
                            break;
                        case COLOR:
                            builder.put(e, color);
                            break;
                        case NORMAL:
                            builder.put(e, face.getFrontOffsetX(), face.getFrontOffsetY(), face.getFrontOffsetZ(), 0);
                            break;
                        case UV:
                            float u = sprite.getInterpolatedU(uv[0]);
                            float v = sprite.getInterpolatedV(uv[1]);
                            builder.put(e, u, v, 0, 1);
                            break;
                        default:
                            builder.put(e);
                    }
                }
            }
            list.add(builder.build());
            j++;
        }
        i++;
    }
    return list;
}
Also used : BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) UnpackedBakedQuad(net.minecraftforge.client.model.pipeline.UnpackedBakedQuad) UnpackedBakedQuad(net.minecraftforge.client.model.pipeline.UnpackedBakedQuad) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) EnumFacing(net.minecraft.util.EnumFacing) ArrayList(java.util.ArrayList) ItemMaterial(pl.asie.charset.lib.material.ItemMaterial) Vec3d(net.minecraft.util.math.Vec3d) IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState) VertexFormatElement(net.minecraft.client.renderer.vertex.VertexFormatElement) ItemStack(net.minecraft.item.ItemStack)

Aggregations

IExtendedBlockState (net.minecraftforge.common.property.IExtendedBlockState)96 IBlockState (net.minecraft.block.state.IBlockState)27 BlockPos (net.minecraft.util.math.BlockPos)24 IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)17 EnumFacing (net.minecraft.util.EnumFacing)17 OBJState (net.minecraftforge.client.model.obj.OBJModel.OBJState)17 TileEntity (net.minecraft.tileentity.TileEntity)16 BakedQuad (net.minecraft.client.renderer.block.model.BakedQuad)14 ArrayList (java.util.ArrayList)13 IBlockAccess (net.minecraft.world.IBlockAccess)13 UnlistedBlockPos (forestry.core.blocks.properties.UnlistedBlockPos)10 TileEntityImmersiveConnectable (blusunrize.immersiveengineering.api.energy.wires.TileEntityImmersiveConnectable)7 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)7 Block (net.minecraft.block.Block)6 ItemStack (net.minecraft.item.ItemStack)6 Nonnull (javax.annotation.Nonnull)4 ResourceLocation (net.minecraft.util.ResourceLocation)4 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)4 Minecraft (net.minecraft.client.Minecraft)3 Vec3d (net.minecraft.util.math.Vec3d)3