Search in sources :

Example 36 with IExtendedBlockState

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

the class BlockClothDevice method getExtendedState.

@Override
public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) {
    state = super.getExtendedState(state, world, pos);
    if (state instanceof IExtendedBlockState) {
        IExtendedBlockState ext = (IExtendedBlockState) state;
        TileEntity te = world.getTileEntity(pos);
        if (te instanceof TileEntityImmersiveConnectable)
            ext = ext.withProperty(IEProperties.CONNECTIONS, ((TileEntityImmersiveConnectable) te).genConnBlockstate());
        state = ext;
    }
    return state;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityImmersiveConnectable(blusunrize.immersiveengineering.api.energy.wires.TileEntityImmersiveConnectable) IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState)

Example 37 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, 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();
    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 38 with IExtendedBlockState

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

the class TileRenderSampleDrill method render.

@Override
public void render(TileEntitySampleDrill tile, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
    if (tile.isDummy() || !tile.getWorld().isBlockLoaded(tile.getPos(), false))
        return;
    final BlockRendererDispatcher blockRenderer = Minecraft.getMinecraft().getBlockRendererDispatcher();
    IBlockState state = tile.getWorld().getBlockState(tile.getPos());
    BlockPos blockPos = tile.getPos();
    IBakedModel model = blockRenderer.getModelForState(state);
    if (state.getBlock() != IEContent.blockMetalDevice1)
        return;
    // .getModelFromBlockState(state, getWorld(), blockPos);
    if (state instanceof IExtendedBlockState)
        state = ((IExtendedBlockState) state).withProperty(Properties.AnimationProperty, new OBJState(Lists.newArrayList("drill"), true));
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder worldRenderer = tessellator.getBuffer();
    bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
    RenderHelper.disableStandardItemLighting();
    GlStateManager.blendFunc(770, 771);
    GlStateManager.enableBlend();
    GlStateManager.disableCull();
    if (Minecraft.isAmbientOcclusionEnabled())
        GlStateManager.shadeModel(7425);
    else
        GlStateManager.shadeModel(7424);
    GlStateManager.pushMatrix();
    GlStateManager.translate(x + .5, y + .5, z + .5);
    // float rot = 360*tile.rotation-(!tile.canTurn||tile.rotation==0||tile.rotation-tile.prevRotation<4?0:tile.facing.getAxis()==Axis.X?-f:f);
    // GlStateManager.rotate(rot, 0,0,1);
    int max = IEConfig.Machines.coredrill_time;
    if (tile.process > 0 && tile.process < max) {
        GlStateManager.rotate(((tile.process + partialTicks) * 22.5f) % 360f, 0, 1, 0);
        float push = tile.process / (float) max;
        if (tile.process > max / 2)
            push = 1 - push;
        GlStateManager.translate(0, -2.8f * push, 0);
    }
    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(tile.getWorld(), model, state, tile.getPos(), worldRenderer, true);
    worldRenderer.setTranslation(0.0D, 0.0D, 0.0D);
    tessellator.draw();
    GlStateManager.popMatrix();
    RenderHelper.enableStandardItemLighting();
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) 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 39 with IExtendedBlockState

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

the class BlockMetalDevice1 method getExtendedState.

@Override
public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) {
    state = super.getExtendedState(state, world, pos);
    TileEntity tile = world.getTileEntity(pos);
    if (tile instanceof TileEntityImmersiveConnectable && state instanceof IExtendedBlockState)
        state = ((IExtendedBlockState) state).withProperty(IEProperties.CONNECTIONS, ((TileEntityImmersiveConnectable) tile).genConnBlockstate());
    if (tile instanceof TileEntityElectricLantern)
        state = state.withProperty(IEProperties.BOOLEANS[0], ((TileEntityElectricLantern) tile).active);
    if (tile instanceof TileEntityFloodlight)
        state = state.withProperty(IEProperties.BOOLEANS[0], ((TileEntityFloodlight) tile).active);
    return state;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityImmersiveConnectable(blusunrize.immersiveengineering.api.energy.wires.TileEntityImmersiveConnectable) IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState)

Example 40 with IExtendedBlockState

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

the class IESmartObjModel method getQuads.

@Override
public List<BakedQuad> getQuads(IBlockState blockState, EnumFacing side, long rand) {
    if (side != null)
        return ImmutableList.of();
    OBJState objState = null;
    Map<String, String> tex = null;
    if (blockState instanceof IExtendedBlockState) {
        IExtendedBlockState ext = (IExtendedBlockState) blockState;
        if (ext.getUnlistedNames().contains(Properties.AnimationProperty)) {
            IModelState modState = ext.getValue(Properties.AnimationProperty);
            if (modState instanceof OBJState)
                objState = (OBJState) modState;
        }
        if (ext.getUnlistedNames().contains(IEProperties.OBJ_TEXTURE_REMAP))
            tex = ext.getValue(IEProperties.OBJ_TEXTURE_REMAP);
    }
    return getQuads(blockState, side, rand, objState, tex, false);
}
Also used : IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState) IModelState(net.minecraftforge.common.model.IModelState)

Aggregations

IExtendedBlockState (net.minecraftforge.common.property.IExtendedBlockState)98 IBlockState (net.minecraft.block.state.IBlockState)29 BlockPos (net.minecraft.util.math.BlockPos)25 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 IBlockAccess (net.minecraft.world.IBlockAccess)14 ArrayList (java.util.ArrayList)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 BlockRenderLayer (net.minecraft.util.BlockRenderLayer)4 ResourceLocation (net.minecraft.util.ResourceLocation)4 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)4 Minecraft (net.minecraft.client.Minecraft)3