Java 类net.minecraftforge.common.property.IExtendedBlockState 实例源码

项目:Etheric    文件:PipeModel.java   
private List<IBakedModel> getSubModels(IExtendedBlockState state) {
    List<IBakedModel> subModels = new ArrayList<IBakedModel>();

    for (int i = 0; i < 6; i++) {
        if (state.getValue(BlockPipe.CONNECTIONS[i]) > 0) {
            subModels.add(connections[i]);
        } else {
            subModels.add(nodeSides[i]);
        }
        if (state.getValue(BlockPipe.CONNECTIONS[i]) > 1) {
            subModels.add(endings[i]);
        }
    }

    return subModels;
}
项目:SimpleTubes    文件:ItemPaintbrush.java   
@Override
public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) {

    if (!world.isRemote) {

        if (world.getBlockState(pos) instanceof IExtendedBlockState) {

            if(world.getTileEntity(pos) != null && world.getTileEntity(pos) instanceof TileTube) {

                IExtendedBlockState state = (IExtendedBlockState) world.getBlockState(pos);
                ItemStack held = player.getHeldItem(hand);
                int col = held.getItemDamage();

                state = state.withProperty(BlockTube.COLOR, col);
                world.setBlockState(pos, state);

                ((TileTube) world.getTileEntity(pos)).setTubeColor(col);
                PacketHandler.sendToAll(new PacketTubeSync(world.getTileEntity(pos), col));
                return EnumActionResult.SUCCESS;
            }
        }
    }

    return EnumActionResult.PASS;
}
项目:SimpleTubes    文件:BlockTube.java   
@Override
public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) {
    if (state instanceof IExtendedBlockState) {
        IExtendedBlockState result = (IExtendedBlockState) state;
        if (world.getTileEntity(pos) != null && world.getTileEntity(pos) instanceof TileTube) {
            result = result.withProperty(UP, TubeUtil.canConnect(EnumFacing.UP, pos, world));
            result = result.withProperty(DOWN, TubeUtil.canConnect(EnumFacing.DOWN, pos, world));
            result = result.withProperty(NORTH, TubeUtil.canConnect(EnumFacing.NORTH, pos, world));
            result = result.withProperty(SOUTH, TubeUtil.canConnect(EnumFacing.SOUTH, pos, world));
            result = result.withProperty(EAST, TubeUtil.canConnect(EnumFacing.EAST, pos, world));
            result = result.withProperty(WEST, TubeUtil.canConnect(EnumFacing.WEST, pos, world));

            result = result.withProperty(COLOR, ((TileTube) world.getTileEntity(pos)).getTubeColor());
            return result;
        }
    }
    return state;
}
项目:SimpleTubes    文件:BlockTube.java   
@Override
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {

    TileEntity tile = source.getTileEntity(pos);
    if (tile != null && tile instanceof TileTube) {
        state = this.getExtendedState(state, source, pos);
        if (state instanceof IExtendedBlockState) {
            IExtendedBlockState extState = (IExtendedBlockState) state;

            float minX = extState.getValue(WEST) ? MIN_BOUND : LOWER_BOUND;
            float minY = extState.getValue(DOWN) ? MIN_BOUND : LOWER_BOUND;
            float minZ = extState.getValue(NORTH) ? MIN_BOUND : LOWER_BOUND;
            float maxX = extState.getValue(EAST) ? MAX_BOUND : UPPER_BOUND;
            float maxY = extState.getValue(UP) ? MAX_BOUND : UPPER_BOUND;
            float maxZ = extState.getValue(SOUTH) ? MAX_BOUND : UPPER_BOUND;

            return new AxisAlignedBB(minX, minY, minZ, maxX, maxY, maxZ);
        }
    }

    return new AxisAlignedBB(LOWER_BOUND, LOWER_BOUND, LOWER_BOUND, UPPER_BOUND, UPPER_BOUND, UPPER_BOUND);
}
项目:CustomWorldGen    文件:OBJModel.java   
@Override
public List<BakedQuad> getQuads(IBlockState blockState, EnumFacing side, long rand)
{
    if (side != null) return ImmutableList.of();
    if (quads == null)
    {
        quads = buildQuads(this.state);
    }
    if (blockState instanceof IExtendedBlockState)
    {
        IExtendedBlockState exState = (IExtendedBlockState) blockState;
        if (exState.getUnlistedNames().contains(Properties.AnimationProperty))
        {

            IModelState newState = exState.getValue(Properties.AnimationProperty);
            if (newState != null)
            {
                newState = new ModelStateComposition(this.state, newState);
                return buildQuads(newState);
            }
        }
    }
    return quads;
}
项目:CustomWorldGen    文件:ModelFluid.java   
public List<BakedQuad> getQuads(IBlockState state, EnumFacing side, long rand)
{
    BakedFluid model = this;
    if(state instanceof IExtendedBlockState)
    {
        IExtendedBlockState exState = (IExtendedBlockState)state;
        int[] cornerRound = getCorners(Optional.of(exState));
        int flowRound = getFlow(Optional.of(exState));
        long key = flowRound + 1024;
        for(int i = 3; i >= 0; i--)
        {
            key <<= 10;
            key |= cornerRound[i];
        }
        key <<= 1;
        key |= 1;
        model = modelCache.getUnchecked(key);
    }
    if(side == null) return ImmutableList.of();
    return model.faceQuads.get(side);
}
项目:CodeChickenLib    文件:ModelBakery.java   
@SuppressWarnings ({ "unchecked", "deprecation" })
public static Map<BlockRenderLayer, Map<EnumFacing, List<BakedQuad>>> generateLayerFaceQuadMap(IExtendedBlockState state) {
    Map<BlockRenderLayer, Map<EnumFacing, TextureAtlasSprite>> layerFaceSpriteMap = state.getValue(BlockBakeryProperties.LAYER_FACE_SPRITE_MAP);
    Map<BlockRenderLayer, Map<EnumFacing, List<BakedQuad>>> layerFaceQuadMap = new HashMap<>();
    for (BlockRenderLayer layer : layerFaceSpriteMap.keySet()) {
        Map<EnumFacing, TextureAtlasSprite> faceSpriteMap = layerFaceSpriteMap.get(layer);
        Map<EnumFacing, List<BakedQuad>> faceQuadMap = new HashMap<>();
        for (EnumFacing face : faceSpriteMap.keySet()) {
            List<BakedQuad> quads = new LinkedList<>();
            quads.add(PlanarFaceBakery.bakeFace(face, faceSpriteMap.get(face)));
            faceQuadMap.put(face, quads);
        }
        layerFaceQuadMap.put(layer, faceQuadMap);
    }
    return layerFaceQuadMap;
}
项目:CodeChickenLib    文件:SimpleBlockRenderer.java   
@Override
public List<BakedQuad> bakeQuads(EnumFacing face, IExtendedBlockState state) {
    BakingVertexBuffer buffer = BakingVertexBuffer.create();
    Triple<Integer, Integer, UVTransformation> worldData = getWorldTransforms(state);
    CCRenderState ccrs = CCRenderState.instance();
    ccrs.reset();
    ccrs.startDrawing(0x7, DefaultVertexFormats.ITEM, buffer);
    models[worldData.getLeft()][worldData.getMiddle()].render(ccrs, worldData.getRight());
    buffer.finishDrawing();
    List<BakedQuad> quads = buffer.bake();
    if (face == null && !shouldCull()) {
        return quads;
    } else if (face != null) {
        return VertexDataUtils.sortFaceData(quads).get(face);
    }
    return ImmutableList.of();
}
项目:Toms-Mod    文件:ModelHidden.java   
@Override
public List<BakedQuad> getQuads(IBlockState state, EnumFacing side, long rand) {
    if (state instanceof IExtendedBlockState) {
        IBakedModel model;
        IBlockState renderState;
        TileEntityHidden te = ((IExtendedBlockState) state).getValue(BlockHiddenRenderOld.DATA);
        if (te.isRenderOld()) {
            IBlockState old = te.getRenderState();
            model = Minecraft.getMinecraft().getBlockRendererDispatcher().getModelForState(old);
            renderState = old;
        } else {
            model = models.getOrDefault(te.getRender(), missing);
            renderState = Blocks.STONE.getDefaultState();
        }
        return model.getQuads(renderState, side, rand);
    }
    return Collections.emptyList();
}
项目:Toms-Mod    文件:StorageNetworkCable.java   
@Override
public IBlockState getExtendedState(IBlockState state, IBlockAccess worldIn, BlockPos pos, PartDuct<?> duct) {
    if (state instanceof IExtendedBlockState) {
        IExtendedBlockState s = (IExtendedBlockState) state;
        /*state = s.withProperty(TYPE, type).withProperty(COLOR, color)
                .withProperty(DOWN, getPropertyValue(EnumFacing.DOWN))
                .withProperty(UP, getPropertyValue(EnumFacing.UP))
                .withProperty(NORTH, getPropertyValue(EnumFacing.NORTH))
                .withProperty(SOUTH, getPropertyValue(EnumFacing.SOUTH))
                .withProperty(WEST, getPropertyValue(EnumFacing.WEST))
                .withProperty(EAST, getPropertyValue(EnumFacing.EAST))
                .withProperty(CHANNEL, channel);*/
        return s.withProperty(DATA, ((PartStorageNetworkCable) duct).getData());
    }
    return state;
}
项目:Toms-Mod    文件:TerminalBlockModel.java   
@Override
public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, long rand) {
    if (side != null)
        return Collections.emptyList();
    TerminalFacing f = TerminalFacing.NORTH;
    TerminalColor color = new TerminalColor(CableColor.FLUIX);
    TileEntityBasicTerminal.TerminalState termS = TileEntityBasicTerminal.TerminalState.OFF;
    if (state != null) {
        IExtendedBlockState s = (IExtendedBlockState) state;
        f = s.getValue(BasicTerminal.FACING);
        color = s.getValue(BasicTerminal.COLOR);
        termS = s.getValue(BasicTerminal.STATE);
    }
    f = f == null ? TerminalFacing.NORTH : f;
    color = color == null ? new TerminalColor(CableColor.FLUIX) : color;
    termS = termS == null ? TileEntityBasicTerminal.TerminalState.OFF : termS;
    return getQuads(f, color.getColor(), color.getColorAlt(), termS, state, side, rand);
}
项目:Toms-Mod    文件:TerminalPartModel.java   
@Override
public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, long rand) {
    if (side != null)
        return Collections.emptyList();
    TerminalFacing f = TerminalFacing.NORTH;
    TerminalColor color = new TerminalColor(CableColor.FLUIX);
    TileEntityBasicTerminal.TerminalState termS = TileEntityBasicTerminal.TerminalState.OFF;
    int ct = 0;
    if (state != null) {
        IExtendedBlockState s = (IExtendedBlockState) state;
        f = s.getValue(BasicTerminal.FACING);
        color = s.getValue(BasicTerminal.COLOR);
        termS = s.getValue(BasicTerminal.STATE);
        ct = s.getValue(b.STATE);
    }
    f = f == null ? TerminalFacing.NORTH : f;
    color = color == null ? new TerminalColor(CableColor.FLUIX) : color;
    termS = termS == null ? TileEntityBasicTerminal.TerminalState.OFF : termS;
    return getQuads(f, color.getColor(), color.getColorAlt(), termS, state, side, ConnectionType.VALUES[ct], rand);
}
项目:Toms-Mod    文件:AdvRouterModel.java   
@Override
public List<BakedQuad> getQuads(IBlockState state, EnumFacing s, long rand) {
    /*List<BakedQuad>[][] models = new List[3][64];
    for(int i = 0;i<models.length;i++)for(int j = 0;j<models[i].length;j++)models[i][j] = new ArrayList<>();
    for(int st = 0;st<models.length;st++){
        for(int j = 0;j<models[st].length;j++){
            List<EnumFacing> conn = new ArrayList<>();
            for(EnumFacing f : EnumFacing.VALUES){
                if(connects(j, f)){
                    conn.add(f);
                }
            }
            for(EnumFacing side : EnumFacing.VALUES){
                models[st][j].addAll(quads[st].get(side)[getModel(conn, side)]);
            }
        }
    }*/
    int conn = 0;
    if (state instanceof IExtendedBlockState) {
        Byte c = ((IExtendedBlockState) state).getValue(AdvStorageSystemRouter.CONNECTIONS);
        if (c != null)
            conn = c;
    }
    return models[state.getValue(AdvStorageSystemRouter.STATE)][conn];
}
项目:DrawersBits    文件:BitDrawerModel.java   
@Override
protected IBakedModel buildModel (IBlockState state, IBakedModel parent) {
    try {
        EnumCompDrawer drawer = (EnumCompDrawer)state.getValue(BlockBitDrawers.SLOTS);
        EnumFacing dir = state.getValue(BlockDrawers.FACING);

        if (!(state instanceof IExtendedBlockState))
            return parent;

        IExtendedBlockState xstate = (IExtendedBlockState)state;
        DrawerStateModelData stateModel = xstate.getValue(BlockDrawers.STATE_MODEL);

        if (!DrawerDecoratorModel.shouldHandleState(stateModel))
            return parent;

        return new DrawerDecoratorModel(parent, xstate, drawer, dir, stateModel);
    }
    catch (Throwable t) {
        return parent;
    }
}
项目:NordMod    文件:BlockAbstractEnergyCable.java   
@Override
public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) {
    if (state instanceof IExtendedBlockState) {  // avoid crash in case of mismatch
        IExtendedBlockState retval = (IExtendedBlockState) state;
        boolean linkup = canConnectTo(world, pos, EnumFacing.UP, pos.up());
        retval = retval.withProperty(LINK_UP, linkup);

        boolean linkdown = canConnectTo(world, pos, EnumFacing.DOWN, pos.down());
        retval = retval.withProperty(LINK_DOWN, linkdown);

        boolean linkeast = canConnectTo(world, pos, EnumFacing.EAST, pos.east());
        retval = retval.withProperty(LINK_EAST, linkeast);

        boolean linkwest = canConnectTo(world, pos, EnumFacing.WEST, pos.west());
        retval = retval.withProperty(LINK_WEST, linkwest);

        boolean linknorth = canConnectTo(world, pos, EnumFacing.NORTH, pos.north());
        retval = retval.withProperty(LINK_NORTH, linknorth);

        boolean linksouth = canConnectTo(world, pos, EnumFacing.NORTH, pos.south());
        retval = retval.withProperty(LINK_SOUTH, linksouth);

        return retval;
    }
    return state;
}
项目:BuildersGuides    文件:BlockMarker.java   
@Override
public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) {
    if (state instanceof IExtendedBlockState) {
        IExtendedBlockState extendedBlockState = (IExtendedBlockState)state;
        TileEntityMarker te = (TileEntityMarker)world.getTileEntity(pos);
        boolean north = te.isFaceEnabled(EnumFacing.NORTH);
        boolean south = te.isFaceEnabled(EnumFacing.SOUTH);
        boolean east = te.isFaceEnabled(EnumFacing.EAST);
        boolean west = te.isFaceEnabled(EnumFacing.WEST);
        boolean up = te.isFaceEnabled(EnumFacing.UP);
        boolean down = te.isFaceEnabled(EnumFacing.DOWN);
        EnumFacing f = te.getFacing();

        return extendedBlockState
                .withProperty(NORTH, north)
                .withProperty(SOUTH, south)
                .withProperty(EAST, east)
                .withProperty(WEST, west)
                .withProperty(UP, up)
                .withProperty(DOWN, down)
                .withProperty(FACING, f.ordinal());
    }

    return state;
}
项目:AgriCraft    文件:RenderWaterPad.java   
@Override
public void renderWorldBlockStatic(ITessellator tessellator, IBlockState state, BlockWaterPad block, EnumFacing side) {
    // Icon
    final TextureAtlasSprite matIcon = BaseIcons.DIRT.getIcon();
    final TextureAtlasSprite waterIcon = BaseIcons.WATER_STILL.getIcon();

    // Check Full
    SidedConnection connection = state instanceof IExtendedBlockState ? ((IExtendedBlockState) state).getValue(AgriProperties.CONNECTIONS) : DEFAULT;

    // Draw Base
    renderBase(tessellator, matIcon);

    // Render Sides
    for (EnumFacing dir : EnumFacing.HORIZONTALS) {
        if (!connection.isConnected(dir)) {
            renderSide(tessellator, dir, matIcon);
        }
    }

    // Render Water
    if (AgriProperties.POWERED.getValue(state)) {
        renderWater(tessellator, waterIcon);
    }
}
项目:AgriCraft    文件:RenderBlockGrate.java   
@Override
protected void renderWorldBlockWoodStatic(ITessellator tess, IExtendedBlockState state, BlockGrate block, EnumFacing side, TextureAtlasSprite sprite) {
    // Setup
    final float offset = AgriProperties.OFFSET.getValue(state).getOffset();

    // Offset
    tess.translate(0, 0, offset);

    // Draw Grate
    tess.drawScaledPrism(1, 0, 0, 3, 16, 2, sprite);
    tess.drawScaledPrism(5, 0, 0, 7, 16, 2, sprite);
    tess.drawScaledPrism(9, 0, 0, 11, 16, 2, sprite);
    tess.drawScaledPrism(13, 0, 0, 15, 16, 2, sprite);
    tess.drawScaledPrism(0, 1, 0, 16, 3, 2, sprite);
    tess.drawScaledPrism(0, 5, 0, 16, 7, 2, sprite);
    tess.drawScaledPrism(0, 9, 0, 16, 11, 2, sprite);
    tess.drawScaledPrism(0, 13, 0, 16, 15, 2, sprite);

}
项目:AgriCraft    文件:RenderCrop.java   
@Override
public void renderWorldBlockStatic(ITessellator tessellator, IBlockState state, BlockCrop block, EnumFacing side) {
    TextureAtlasSprite sprite = RenderCrop.getIcon(TEXTURE);
    this.renderBaseQuads(tessellator, side, sprite);
    if (state instanceof IExtendedBlockState) {
        IExtendedBlockState extendedState = (IExtendedBlockState) state;
        IAgriPlant plant = extendedState.getValue(AgriProperties.CROP_PLANT);
        int growthstage = extendedState.getValue(AgriProperties.GROWTH_STAGE);
        if (extendedState.getValue(AgriProperties.CROSS_CROP)) {
            tessellator.drawScaledPrism(0, 10, 2, 16, 11, 3, sprite);
            tessellator.drawScaledPrism(0, 10, 13, 16, 11, 14, sprite);
            tessellator.drawScaledPrism(2, 10, 0, 3, 11, 16, sprite);
            tessellator.drawScaledPrism(13, 10, 0, 14, 11, 16, sprite);
        }
        if (plant != null) {
            tessellator.addQuads(plant.getPlantQuads(extendedState, growthstage, side, tessellator));
        }
    }
}
项目:enderutilities    文件:BlockEnderUtilitiesTileEntity.java   
@Override
public IBlockState getExtendedState(IBlockState oldState, IBlockAccess world, BlockPos pos)
{
    if (this.isCamoBlock())
    {
        TileEntityEnderUtilities te = getTileEntitySafely(world, pos, TileEntityEnderUtilities.class);

        if (te != null)
        {
            IExtendedBlockState state = (IExtendedBlockState) oldState;
            state = state.withProperty(CAMOBLOCKSTATE, te.getCamoState());
            state = state.withProperty(CAMOBLOCKSTATEEXTENDED, te.getCamoExtendedState());
            return state;
        }
    }

    return oldState;
}
项目:enderutilities    文件:BlockEnderUtilitiesTileEntity.java   
@SuppressWarnings("deprecation")
@Override
public int getLightValue(IBlockState state, IBlockAccess world, BlockPos pos)
{
    if (this.isCamoBlock())
    {
        IExtendedBlockState extendedState = (IExtendedBlockState) this.getExtendedState(state.getActualState(world, pos), world, pos);
        IBlockState stateCamo = extendedState.getValue(CAMOBLOCKSTATE);

        if (stateCamo != null)
        {
            // Can't call this same world sensitive method here, because it might/will recurse back here!
            return stateCamo.getLightValue();
        }
    }

    return super.getLightValue(state, world, pos);
}
项目:FlowstoneEnergy    文件:BlockMachines.java   
@Override
public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) {
    IExtendedBlockState extendedState = (IExtendedBlockState)state;
    TileEntity tileEntity = world.getTileEntity(pos);
    if (tileEntity != null && tileEntity instanceof TileEntityMachineBase) {

        int front = ((TileEntityMachineBase)tileEntity).facing;
        extendedState = extendedState.withProperty(hiddenProperties[0], front);
        int operating = 0;
        if (((TileEntityMachineBase)tileEntity).ticksLeft != 0) {
            operating = 1;
        }
        extendedState = extendedState.withProperty(hiddenProperties[1], operating);
    }
    return extendedState;
}
项目:Extra-Food    文件:OBJModel.java   
@Override
public List<BakedQuad> getQuads(IBlockState blockState, EnumFacing side, long rand)
{
    if (side != null) return ImmutableList.of();
    if (quads == null)
    {
        quads = buildQuads(this.state);
    }
    if (blockState instanceof IExtendedBlockState)
    {
        IExtendedBlockState exState = (IExtendedBlockState) blockState;
        if (exState.getUnlistedNames().contains(net.minecraftforge.common.property.Properties.AnimationProperty))
        {

            IModelState newState = exState.getValue(net.minecraftforge.common.property.Properties.AnimationProperty);
            if (newState != null)
            {
                newState = new ModelStateComposition(this.state, newState);
                return buildQuads(newState);
            }
        }
    }
    return quads;
}
项目:OpenBlocks    文件:BakedModelCanvas.java   
@Override
public List<BakedQuad> getQuads(IBlockState state, EnumFacing side, long rand) {
    final Optional<IBlockState> maybeInnerBlock;
    final Optional<CanvasState> maybeCanvasState;
    if (state instanceof IExtendedBlockState) {
        final IExtendedBlockState extendedState = (IExtendedBlockState)state;
        final ImmutableMap<IUnlistedProperty<?>, Optional<?>> unlistedProperties = extendedState.getUnlistedProperties();
        maybeInnerBlock = getProperty(unlistedProperties, InnerBlockState.PROPERTY);
        maybeCanvasState = getProperty(unlistedProperties, CanvasState.PROPERTY);

        if (maybeCanvasState.isPresent()) maybeCanvasState.get().onRender();
    } else {
        maybeInnerBlock = Optional.empty();
        maybeCanvasState = Optional.empty();
    }

    final BlockRenderLayer renderLayer = MoreObjects.firstNonNull(MinecraftForgeClient.getRenderLayer(), BlockRenderLayer.CUTOUT);

    return modelTransformer.getQuads(maybeInnerBlock, maybeCanvasState, renderLayer).get(side);

}
项目:OpenBlocks    文件:TileEntityFanRenderer.java   
@Override
public void renderTileEntityFast(TileEntityFan te, double x, double y, double z, float partialTicks, int destroyStage, float alpha, BufferBuilder renderer) {
    if (blockRenderer == null) blockRenderer = Minecraft.getMinecraft().getBlockRendererDispatcher();

    final BlockPos pos = te.getPos();
    final IBlockAccess world = MinecraftForgeClient.getRegionRenderCache(te.getWorld(), pos);
    IBlockState state = world.getBlockState(pos);

    if (state.getPropertyKeys().contains(Properties.StaticProperty)) {
        state = state.withProperty(Properties.StaticProperty, false);
    }

    if (state instanceof IExtendedBlockState) {
        state = state.getBlock().getExtendedState(state, world, pos);

        IExtendedBlockState exState = ((IExtendedBlockState)state).withProperty(EvalModelState.PROPERTY, te.getTesrRenderState(partialTicks));
        final IBakedModel model = blockRenderer.getBlockModelShapes().getModelForState(exState.getClean());
        renderer.setTranslation(x - pos.getX(), y - pos.getY(), z - pos.getZ());
        blockRenderer.getBlockModelRenderer().renderModel(world, model, exState, pos, renderer, false);
        renderer.setTranslation(0, 0, 0);
    }
}
项目:OpenBlocks    文件:TileEntityBearTrapRenderer.java   
@Override
public void renderTileEntityFast(TileEntityBearTrap te, double x, double y, double z, float partialTicks, int destroyStage, float alpha, BufferBuilder renderer) {
    if (blockRenderer == null) blockRenderer = Minecraft.getMinecraft().getBlockRendererDispatcher();

    final BlockPos pos = te.getPos();
    final IBlockAccess world = MinecraftForgeClient.getRegionRenderCache(te.getWorld(), pos);
    IBlockState state = world.getBlockState(pos);

    if (state instanceof IExtendedBlockState) {
        state = state.getBlock().getExtendedState(state, world, pos);

        IExtendedBlockState exState = ((IExtendedBlockState)state).withProperty(EvalModelState.PROPERTY, te.getRenderState(partialTicks));
        final IBakedModel model = blockRenderer.getBlockModelShapes().getModelForState(exState.getClean());
        renderer.setTranslation(x - pos.getX(), y - pos.getY(), z - pos.getZ());
        blockRenderer.getBlockModelRenderer().renderModel(world, model, exState, pos, renderer, false);
        renderer.setTranslation(0, 0, 0);
    }
}
项目:OpenBlocks    文件:BlockPaintMixer.java   
@Override
public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) {
    if (state instanceof IExtendedBlockState) {
        final TileEntityPaintMixer mixer = getTileEntity(world, pos, TileEntityPaintMixer.class);
        if (mixer != null) {
            final int progress = mixer.getProgress().getValue();

            final int currentColor;

            if (progress != 0) {
                final RGB startColor = new RGB(mixer.getCanColor());
                final RGB endColor = new RGB(mixer.getColor().getValue());
                final float scaledProgress = progress / (float)TileEntityPaintMixer.PROGRESS_TICKS;
                currentColor = startColor.interpolate(endColor, scaledProgress).getColor();
            } else {
                currentColor = mixer.getCanColor();
            }
            return ((IExtendedBlockState)state).withProperty(CAN_COLOR, currentColor);
        }
    }

    return state;
}
项目:OpenModsLib    文件:EvalExpandModel.java   
@Override
public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) {
    final IModel model = loadBaseModel(state, format, bakedTextureGetter);

    IBlockState blockState = null;

    if (defaultBlockState.isPresent()) {
        final Block defaultBlock = Block.REGISTRY.getObject(defaultBlockState.get());
        if (defaultBlock != Blocks.AIR) {
            blockState = defaultBlock.getDefaultState();
            if (!(blockState instanceof IExtendedBlockState) ||
                    !((IExtendedBlockState)blockState).getUnlistedNames().contains(EvalModelState.PROPERTY)) {
                Log.warn("State %s does not contain eval state property", blockState);
            }
        } else {
            Log.warn("Can't find default block: %s", defaultBlockState.get());
        }
    }

    final IVarExpander expander = evaluatorFactory.createExpander();
    return new BakedEvalExpandModel(model, state, format, bakedTextureGetter, blockState, expander);
}
项目:pnc-repressurized    文件:CamoModel.java   
private IBakedModel handleBlockState(IBlockState state) {
    if (state instanceof IExtendedBlockState) {
        IExtendedBlockState ext = (IExtendedBlockState) state;
        IBlockState camoState = ext.getValue(BlockPneumaticCraftCamo.CAMO_STATE);
        if (camoState != null && !(camoState.getBlock() instanceof BlockPneumaticCraftCamo)) {
            BlockModelShapes blockModelShapes = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes();
            return blockModelShapes.getModelForState(camoState);
        }
    }

    return originalModel;
}
项目:pnc-repressurized    文件:BlockPressureChamberGlass.java   
@Override
public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) {
    IExtendedBlockState extendedBlockState = (IExtendedBlockState) state;

    return extendedBlockState
            .withProperty(DOWN, getTextureIndex(world, pos, EnumFacing.DOWN))
            .withProperty(UP, getTextureIndex(world, pos, EnumFacing.UP))
            .withProperty(NORTH, getTextureIndex(world, pos, EnumFacing.NORTH))
            .withProperty(SOUTH, getTextureIndex(world, pos, EnumFacing.SOUTH))
            .withProperty(WEST, getTextureIndex(world, pos, EnumFacing.WEST))
            .withProperty(EAST, getTextureIndex(world, pos, EnumFacing.EAST));
}
项目:pnc-repressurized    文件:BlockPneumaticCraftCamo.java   
@Override
public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) {
    TileEntity te = PneumaticCraftUtils.getTileEntitySafely(world, pos);
    if (te instanceof ICamouflageableTE) {
        IBlockState camoState = ((ICamouflageableTE) te).getCamouflage();
        if (camoState != null) {
            return ((IExtendedBlockState) state).withProperty(CAMO_STATE, camoState);
        }
    }
    return state;
}
项目:Etheric    文件:PipeModel.java   
@Override
public List<BakedQuad> getQuads(IBlockState state, EnumFacing side, long rand) {
    if (state instanceof IExtendedBlockState) {
        List<IBakedModel> subModels = getSubModels((IExtendedBlockState) state);
        List<BakedQuad> quads = new ArrayList<BakedQuad>();

        for (IBakedModel model : subModels) {
            quads.addAll(model.getQuads(state, side, rand));
        }

        return quads;
    }
    return Collections.EMPTY_LIST;
}
项目:Etheric    文件:BlockPipe.java   
@Override
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess world, BlockPos pos) {
    IExtendedBlockState extendedState = (IExtendedBlockState) getExtendedState(state, world, pos);

    double min = 0.3125, max = 0.6875;

    double x1 = min, y1 = min, z1 = min;
    double x2 = max, y2 = max, z2 = max;
    if (extendedState.getValue(CONNECTIONS[0]) > 0) {
        y1 = 0;
    }
    if (extendedState.getValue(CONNECTIONS[1]) > 0) {
        y2 = 1;
    }
    if (extendedState.getValue(CONNECTIONS[2]) > 0) {
        z1 = 0;
    }
    if (extendedState.getValue(CONNECTIONS[3]) > 0) {
        z2 = 1;
    }
    if (extendedState.getValue(CONNECTIONS[4]) > 0) {
        x1 = 0;
    }
    if (extendedState.getValue(CONNECTIONS[5]) > 0) {
        x2 = 1;
    }

    return new AxisAlignedBB(x1, y1, z1, x2, y2, z2);
}
项目:Etheric    文件:BlockPipe.java   
@Override
public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox,
        List<AxisAlignedBB> collidingBoxes, @Nullable Entity entityIn, boolean p_185477_7_) {
    addCollisionBoxToList(pos, entityBox, collidingBoxes, NODE_AABB);
    IExtendedBlockState extendedState = (IExtendedBlockState) getExtendedState(state, worldIn, pos);

    for (int i = 0; i < CONNECTIONS.length; i++) {
        if (extendedState.getValue(CONNECTIONS[i]) > 0) {
            addCollisionBoxToList(pos, entityBox, collidingBoxes, CONNECTION_AABB[i]);
        }
    }

}
项目:Etheric    文件:BlockPipe.java   
@Override
public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) {
    IExtendedBlockState extendedState = (IExtendedBlockState) state;
    for (int i = 0; i < CONNECTIONS.length; i++) {
        int connected = getConnection(world, pos, EnumFacing.getFront(i));
        extendedState = extendedState.withProperty(CONNECTIONS[i], connected);
    }
    return extendedState;
}
项目:PurificatiMagicae    文件:BlockAbstractWallIfTablet.java   
@Override
public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos)
{
    if (state instanceof IExtendedBlockState)
    {
        TileEntity te = world.getTileEntity(pos);
        if (te != null && te instanceof TileWallIfTablet)
        {
            return ((IExtendedBlockState) state).withProperty(IF_TIER, ((TileWallIfTablet) te).getTier());
        }
    }
    return state;
}
项目:PurificatiMagicae    文件:BlockCodeStorage.java   
@Override
public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos)
{
    if(state instanceof IExtendedBlockState)
    {
        TileEntity te = world.getTileEntity(pos);
        if(te != null && te instanceof TileCodeStorage)
        {
            return ((IExtendedBlockState) state).withProperty(UNLOCKED_PROPERTY, ((TileCodeStorage) te).isUnlocked());
        }
    }
    return super.getExtendedState(state, world, pos);
}
项目:CustomWorldGen    文件:AnimationTESR.java   
public void renderTileEntityFast(T te, double x, double y, double z, float partialTick, int breakStage, VertexBuffer renderer)
{
    if(!te.hasCapability(CapabilityAnimation.ANIMATION_CAPABILITY, null))
    {
        return;
    }
    if(blockRenderer == null) blockRenderer = Minecraft.getMinecraft().getBlockRendererDispatcher();
    BlockPos pos = te.getPos();
    IBlockAccess world = MinecraftForgeClient.getRegionRenderCache(te.getWorld(), pos);
    IBlockState state = world.getBlockState(pos);
    if(state.getPropertyNames().contains(Properties.StaticProperty))
    {
        state = state.withProperty(Properties.StaticProperty, false);
    }
    if(state instanceof IExtendedBlockState)
    {
        IExtendedBlockState exState = (IExtendedBlockState)state;
        if(exState.getUnlistedNames().contains(Properties.AnimationProperty))
        {
            float time = Animation.getWorldTime(getWorld(), partialTick);
            Pair<IModelState, Iterable<Event>> pair = te.getCapability(CapabilityAnimation.ANIMATION_CAPABILITY, null).apply(time);
            handleEvents(te, time, pair.getRight());

            // TODO: caching?
            IBakedModel model = blockRenderer.getBlockModelShapes().getModelForState(exState.getClean());
            exState = exState.withProperty(Properties.AnimationProperty, pair.getLeft());

            renderer.setTranslation(x - pos.getX(), y - pos.getY(), z - pos.getZ());

            blockRenderer.getBlockModelRenderer().renderModel(world, model, exState, pos, renderer, false);
        }
    }
}
项目:CustomWorldGen    文件:ModelFluid.java   
private static int[] getCorners(Optional<IExtendedBlockState> stateOption)
{
    int[] cornerRound = new int[]{0, 0, 0, 0};
    if(stateOption.isPresent())
    {
        IExtendedBlockState state = stateOption.get();
        for(int i = 0; i < 4; i++)
        {
            Float level = state.getValue(BlockFluidBase.LEVEL_CORNERS[i]);
            cornerRound[i] = Math.round((level == null ? 7f / 8 : level) * 768);
        }
    }
    return cornerRound;
}
项目:CustomWorldGen    文件:ModelFluid.java   
private static int getFlow(Optional<IExtendedBlockState> stateOption)
{
    Float flow = -1000f;
    if(stateOption.isPresent())
    {
        flow = stateOption.get().getValue(BlockFluidBase.FLOW_DIRECTION);
        if(flow == null) flow = -1000f;
    }
    int flowRound = (int)Math.round(Math.toDegrees(flow));
    flowRound = MathHelper.clamp_int(flowRound, -1000, 1000);
    return flowRound;
}