Search in sources :

Example 16 with OBJState

use of net.minecraftforge.client.model.obj.OBJModel.OBJState in project ImmersiveEngineering by BluSunrize.

the class TileRenderTurret method renderModelPart.

public static void renderModelPart(final BlockRendererDispatcher blockRenderer, Tessellator tessellator, BufferBuilder worldRenderer, World world, IBlockState state, IBakedModel model, BlockPos pos, boolean isFirst, String... parts) {
    pos = pos.up();
    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();
    Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
    if (Minecraft.isAmbientOcclusionEnabled())
        GlStateManager.shadeModel(7425);
    else
        GlStateManager.shadeModel(7424);
    worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
    worldRenderer.setTranslation(-.5, 0, -.5);
    long randomLong = MathHelper.getPositionRandom(pos);
    int light = world.getCombinedLight(pos, 0);
    List<BakedQuad> quads = model.getQuads(state, null, randomLong);
    ClientUtils.renderModelTESRFancy(quads, worldRenderer, world, pos, !isFirst);
    worldRenderer.setTranslation(0.0D, 0.0D, 0.0D);
    tessellator.draw();
    RenderHelper.enableStandardItemLighting();
    GlStateManager.disableBlend();
    GlStateManager.enableCull();
}
Also used : BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState) OBJState(net.minecraftforge.client.model.obj.OBJModel.OBJState)

Example 17 with OBJState

use of net.minecraftforge.client.model.obj.OBJModel.OBJState in project ImmersiveEngineering by BluSunrize.

the class TileRenderWindmill method render.

@Override
public void render(TileEntityWindmill tile, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
    if (!tile.getWorld().isBlockLoaded(tile.getPos(), false))
        return;
    final BlockRendererDispatcher blockRenderer = Minecraft.getMinecraft().getBlockRendererDispatcher();
    BlockPos blockPos = tile.getPos();
    if (quads[tile.sails] == null) {
        IBlockState state = getWorld().getBlockState(blockPos);
        if (state.getBlock() != IEContent.blockWoodenDevice1)
            return;
        state = state.getActualState(getWorld(), blockPos);
        state = state.withProperty(IEProperties.FACING_ALL, EnumFacing.NORTH);
        IBakedModel model = blockRenderer.getBlockModelShapes().getModelForState(state);
        if (state instanceof IExtendedBlockState) {
            List<String> parts = new ArrayList<>();
            parts.add("base");
            for (int i = 1; i <= tile.sails; i++) parts.add("sail_" + i);
            state = ((IExtendedBlockState) state).withProperty(Properties.AnimationProperty, new OBJState(parts, true));
        }
        quads[tile.sails] = model.getQuads(state, null, 0);
    }
    Tessellator tessellator = Tessellator.getInstance();
    GlStateManager.blendFunc(770, 771);
    GlStateManager.enableBlend();
    GlStateManager.disableCull();
    GlStateManager.pushMatrix();
    GlStateManager.translate(x + .5, y + .5, z + .5);
    float dir = tile.facing == EnumFacing.SOUTH ? 0 : tile.facing == EnumFacing.NORTH ? 180 : tile.facing == EnumFacing.EAST ? 90 : -90;
    float rot = 360 * (tile.rotation + (!tile.canTurn || tile.rotation == 0 ? 0 : partialTicks) * tile.perTick);
    GlStateManager.rotate(rot, tile.facing.getAxis() == Axis.X ? 1 : 0, 0, tile.facing.getAxis() == Axis.Z ? 1 : 0);
    GlStateManager.rotate(dir, 0, 1, 0);
    RenderHelper.disableStandardItemLighting();
    Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
    BufferBuilder worldRenderer = tessellator.getBuffer();
    worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
    worldRenderer.setTranslation(-.5, -.5, -.5);
    ClientUtils.renderModelTESRFast(quads[tile.sails], worldRenderer, tile.getWorld(), blockPos);
    worldRenderer.setTranslation(0, 0, 0);
    tessellator.draw();
    GlStateManager.popMatrix();
    RenderHelper.enableStandardItemLighting();
    GlStateManager.disableBlend();
    GlStateManager.enableCull();
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) ArrayList(java.util.ArrayList) IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState) BlockPos(net.minecraft.util.math.BlockPos) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) OBJState(net.minecraftforge.client.model.obj.OBJModel.OBJState)

Example 18 with OBJState

use of net.minecraftforge.client.model.obj.OBJModel.OBJState in project ImmersiveEngineering by BluSunrize.

the class TileRenderBottlingMachine method renderModelPart.

public static void renderModelPart(final BlockRendererDispatcher blockRenderer, Tessellator tessellator, BufferBuilder 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();
    GlStateManager.color(1, 0, 0, 1);
    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 19 with OBJState

use of net.minecraftforge.client.model.obj.OBJModel.OBJState in project ImmersiveEngineering by BluSunrize.

the class BlockIETileProvider method getExtendedState.

@Override
public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) {
    state = super.getExtendedState(state, world, pos);
    if (state instanceof IExtendedBlockState) {
        IExtendedBlockState extended = (IExtendedBlockState) state;
        TileEntity te = world.getTileEntity(pos);
        if (te != null) {
            if (te instanceof IConfigurableSides)
                for (int i = 0; i < 6; i++) if (extended.getUnlistedNames().contains(IEProperties.SIDECONFIG[i]))
                    extended = extended.withProperty(IEProperties.SIDECONFIG[i], ((IConfigurableSides) te).getSideConfig(i));
            if (te instanceof IAdvancedHasObjProperty)
                extended = extended.withProperty(Properties.AnimationProperty, ((IAdvancedHasObjProperty) te).getOBJState());
            else if (te instanceof IHasObjProperty)
                extended = extended.withProperty(Properties.AnimationProperty, new OBJState(((IHasObjProperty) te).compileDisplayList(), true));
            if (te instanceof IDynamicTexture)
                extended = extended.withProperty(IEProperties.OBJ_TEXTURE_REMAP, ((IDynamicTexture) te).getTextureReplacements());
            if (te instanceof IOBJModelCallback)
                extended = extended.withProperty(IOBJModelCallback.PROPERTY, (IOBJModelCallback) te);
            if (te.hasCapability(CapabilityShader.SHADER_CAPABILITY, null))
                extended = extended.withProperty(CapabilityShader.BLOCKSTATE_PROPERTY, te.getCapability(CapabilityShader.SHADER_CAPABILITY, null));
            if (te instanceof IPropertyPassthrough && ((IExtendedBlockState) state).getUnlistedNames().contains(IEProperties.TILEENTITY_PASSTHROUGH))
                extended = extended.withProperty(IEProperties.TILEENTITY_PASSTHROUGH, te);
            if (te instanceof TileEntityImmersiveConnectable && ((IExtendedBlockState) state).getUnlistedNames().contains(IEProperties.CONNECTIONS))
                extended = extended.withProperty(IEProperties.CONNECTIONS, ((TileEntityImmersiveConnectable) te).genConnBlockstate());
        }
        state = extended;
    }
    return state;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityImmersiveConnectable(blusunrize.immersiveengineering.api.energy.wires.TileEntityImmersiveConnectable) IOBJModelCallback(blusunrize.immersiveengineering.client.models.IOBJModelCallback) IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState) OBJState(net.minecraftforge.client.model.obj.OBJModel.OBJState)

Example 20 with OBJState

use of net.minecraftforge.client.model.obj.OBJModel.OBJState in project ImmersiveEngineering by BluSunrize.

the class TileRenderArcFurnace method render.

@Override
public void render(TileEntityArcFurnace te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
    if (!te.formed || te.isDummy() || !te.getWorld().isBlockLoaded(te.getPos(), false))
        return;
    List<String> renderedParts = null;
    for (int i = 0; i < 3; i++) if (!te.getInventory().get(23 + i).isEmpty()) {
        if (renderedParts == null)
            renderedParts = Lists.newArrayList("electrode" + (i + 1));
        else
            renderedParts.add("electrode" + (i + 1));
    }
    if (renderedParts == null)
        return;
    if (te.shouldRenderAsActive())
        renderedParts.add("active");
    final BlockRendererDispatcher blockRenderer = Minecraft.getMinecraft().getBlockRendererDispatcher();
    BlockPos blockPos = te.getPos();
    IBlockState state = getWorld().getBlockState(blockPos);
    if (state.getBlock() != IEContent.blockMetalMultiblock)
        return;
    state = state.getBlock().getActualState(state, getWorld(), blockPos);
    state = state.withProperty(IEProperties.DYNAMICRENDER, true);
    IBakedModel model = blockRenderer.getBlockModelShapes().getModelForState(state);
    if (state instanceof IExtendedBlockState)
        state = ((IExtendedBlockState) state).withProperty(Properties.AnimationProperty, new OBJState(renderedParts, true));
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder worldRenderer = tessellator.getBuffer();
    ClientUtils.bindAtlas();
    GlStateManager.pushMatrix();
    GlStateManager.translate(x, y, z);
    GlStateManager.translate(.5, .5, .5);
    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 - blockPos.getX(), -.5 - blockPos.getY(), -.5 - blockPos.getZ());
    worldRenderer.color(255, 255, 255, 255);
    blockRenderer.getBlockModelRenderer().renderModel(te.getWorld(), model, state, blockPos, worldRenderer, true);
    worldRenderer.setTranslation(0.0D, 0.0D, 0.0D);
    tessellator.draw();
    RenderHelper.enableStandardItemLighting();
    if (te.pouringMetal > 0) {
        if (hotMetal_flow == null) {
            hotMetal_still = ApiUtils.getRegisterSprite(ClientUtils.mc().getTextureMapBlocks(), "immersiveengineering:blocks/fluid/hot_metal_still");
            hotMetal_flow = ApiUtils.getRegisterSprite(ClientUtils.mc().getTextureMapBlocks(), "immersiveengineering:blocks/fluid/hot_metal_flow");
        }
        GlStateManager.rotate(-te.facing.getHorizontalAngle() + 180, 0, 1, 0);
        int process = 40;
        float speed = 5f;
        int pour = process - te.pouringMetal;
        Vector3f tmp = new Vector3f();
        float h = (pour > (process - speed) ? ((process - pour) / speed * 27) : pour > speed ? 27 : (pour / speed * 27)) / 16f;
        GlStateManager.translate(-.5f, 1.25 - .6875f, 1.5f);
        worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
        GlStateManager.disableLighting();
        setLightmapDisabled(true);
        if (pour > (process - speed))
            addTranslation(tmp, worldRenderer, 0, -1.6875f + h, 0);
        if (h > 1) {
            addTranslation(tmp, worldRenderer, 0, -h, 0);
            ClientUtils.renderTexturedBox(worldRenderer, .375, 0, .375, .625, 1, .625, hotMetal_flow, true);
            addTranslation(tmp, worldRenderer, 0, 1, 0);
            ClientUtils.renderTexturedBox(worldRenderer, .375, 0, .375, .625, h - 1, .625, hotMetal_flow, true);
            addTranslation(tmp, worldRenderer, 0, -1, 0);
            addTranslation(tmp, worldRenderer, 0, h, 0);
        } else {
            addTranslation(tmp, worldRenderer, 0, -h, 0);
            ClientUtils.renderTexturedBox(worldRenderer, .375, 0, .375, .625, h, .625, hotMetal_flow, true);
            addTranslation(tmp, worldRenderer, 0, h, 0);
        }
        if (pour > (process - speed))
            addTranslation(tmp, worldRenderer, 0, 1.6875f - h, 0);
        if (pour > speed) {
            float h2 = (pour > (process - speed) ? .625f : pour / (process - speed) * .625f);
            addTranslation(tmp, worldRenderer, 0, -1.6875f, 0);
            ClientUtils.renderTexturedBox(worldRenderer, .125, 0, .125, .875, h2, .875, hotMetal_still, false);
            addTranslation(tmp, worldRenderer, 0, 1.6875f, 0);
        }
        worldRenderer.setTranslation(0, 0, 0);
        tessellator.draw();
        setLightmapDisabled(false);
        GlStateManager.enableLighting();
    }
    GlStateManager.popMatrix();
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState) Vector3f(org.lwjgl.util.vector.Vector3f) BlockPos(net.minecraft.util.math.BlockPos) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) OBJState(net.minecraftforge.client.model.obj.OBJModel.OBJState)

Aggregations

OBJState (net.minecraftforge.client.model.obj.OBJModel.OBJState)20 IExtendedBlockState (net.minecraftforge.common.property.IExtendedBlockState)17 IBlockState (net.minecraft.block.state.IBlockState)10 IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)10 BlockPos (net.minecraft.util.math.BlockPos)7 BakedQuad (net.minecraft.client.renderer.block.model.BakedQuad)6 EnumFacing (net.minecraft.util.EnumFacing)5 Matrix4 (blusunrize.immersiveengineering.common.util.chickenbones.Matrix4)3 Block (net.minecraft.block.Block)3 TileEntity (net.minecraft.tileentity.TileEntity)3 TileEntityImmersiveConnectable (blusunrize.immersiveengineering.api.energy.wires.TileEntityImmersiveConnectable)2 IPlantHandler (blusunrize.immersiveengineering.api.tool.BelljarHandler.IPlantHandler)2 IESmartObjModel (blusunrize.immersiveengineering.client.models.IESmartObjModel)2 IOBJModelCallback (blusunrize.immersiveengineering.client.models.IOBJModelCallback)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 ItemStack (net.minecraft.item.ItemStack)2 TRSRTransformation (net.minecraftforge.common.model.TRSRTransformation)2 ConveyorHandler (blusunrize.immersiveengineering.api.tool.ConveyorHandler)1 IConveyorTile (blusunrize.immersiveengineering.api.tool.ConveyorHandler.IConveyorTile)1