Search in sources :

Example 66 with IExtendedBlockState

use of net.minecraftforge.common.property.IExtendedBlockState in project pnc-repressurized by TeamPneumatic.

the class CamoModel method handleBlockState.

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;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState) BlockPneumaticCraftCamo(me.desht.pneumaticcraft.common.block.BlockPneumaticCraftCamo) BlockModelShapes(net.minecraft.client.renderer.BlockModelShapes)

Example 67 with IExtendedBlockState

use of net.minecraftforge.common.property.IExtendedBlockState in project pnc-repressurized by TeamPneumatic.

the class PressureGlassBakedModel method getQuads.

@Override
public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, long rand) {
    if (!(state instanceof IExtendedBlockState) || side == null) {
        return Collections.emptyList();
    }
    IExtendedBlockState extendedBlockState = (IExtendedBlockState) state;
    List<BakedQuad> quads = new ArrayList<>();
    switch(side) {
        case DOWN:
            int down = extendedBlockState.getValue(BlockPressureChamberGlass.DOWN);
            quads.add(createQuad(new Vec3d(1, 0, 0), new Vec3d(1, 0, 1), new Vec3d(0, 0, 1), new Vec3d(0, 0, 0), SPRITES[down]));
            break;
        case UP:
            int up = extendedBlockState.getValue(BlockPressureChamberGlass.UP);
            quads.add(createQuad(new Vec3d(0, 1, 0), new Vec3d(0, 1, 1), new Vec3d(1, 1, 1), new Vec3d(1, 1, 0), SPRITES[up]));
            break;
        case NORTH:
            int north = extendedBlockState.getValue(BlockPressureChamberGlass.NORTH);
            quads.add(createQuad(new Vec3d(1, 1, 0), new Vec3d(1, 0, 0), new Vec3d(0, 0, 0), new Vec3d(0, 1, 0), SPRITES[north]));
            break;
        case SOUTH:
            int south = extendedBlockState.getValue(BlockPressureChamberGlass.SOUTH);
            quads.add(createQuad(new Vec3d(0, 1, 1), new Vec3d(0, 0, 1), new Vec3d(1, 0, 1), new Vec3d(1, 1, 1), SPRITES[south]));
            break;
        case WEST:
            int west = extendedBlockState.getValue(BlockPressureChamberGlass.WEST);
            quads.add(createQuad(new Vec3d(0, 1, 0), new Vec3d(0, 0, 0), new Vec3d(0, 0, 1), new Vec3d(0, 1, 1), SPRITES[west]));
            break;
        case EAST:
            int east = extendedBlockState.getValue(BlockPressureChamberGlass.EAST);
            quads.add(createQuad(new Vec3d(1, 1, 1), new Vec3d(1, 0, 1), new Vec3d(1, 0, 0), new Vec3d(1, 1, 0), SPRITES[east]));
            break;
    }
    return quads;
}
Also used : BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) UnpackedBakedQuad(net.minecraftforge.client.model.pipeline.UnpackedBakedQuad) IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState) ArrayList(java.util.ArrayList) Vec3d(net.minecraft.util.math.Vec3d)

Example 68 with IExtendedBlockState

use of net.minecraftforge.common.property.IExtendedBlockState in project XNet by McJty.

the class RenderWorldLastEventHandler method renderCablesInt.

private static void renderCablesInt(RenderWorldLastEvent evt, Minecraft mc) {
    EntityPlayerSP p = mc.player;
    WorldClient world = mc.world;
    double doubleX = p.lastTickPosX + (p.posX - p.lastTickPosX) * evt.getPartialTicks();
    double doubleY = p.lastTickPosY + (p.posY - p.lastTickPosY) * evt.getPartialTicks();
    double doubleZ = p.lastTickPosZ + (p.posZ - p.lastTickPosZ) * evt.getPartialTicks();
    GlStateManager.pushMatrix();
    GlStateManager.color(1.0f, 0, 0);
    GlStateManager.glLineWidth(2);
    GlStateManager.translate(-doubleX, -doubleY, -doubleZ);
    GlStateManager.disableDepth();
    GlStateManager.disableTexture2D();
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder buffer = tessellator.getBuffer();
    buffer.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION_COLOR);
    for (int dx = -20; dx <= 20; dx++) {
        for (int dy = -20; dy <= 20; dy++) {
            for (int dz = -20; dz <= 20; dz++) {
                BlockPos c = p.getPosition().add(dx, dy, dz);
                IBlockState state = world.getBlockState(c);
                Block block = state.getBlock();
                if (block instanceof FacadeBlock || block instanceof ConnectorBlock || block instanceof GenericCableBlock) {
                    IExtendedBlockState extendedBlockState;
                    if (state.getBlock() instanceof FacadeBlock) {
                        extendedBlockState = (IExtendedBlockState) ((FacadeBlock) state.getBlock()).getStateInternal(state, world, c);
                    } else {
                        extendedBlockState = (IExtendedBlockState) state.getBlock().getExtendedState(state, world, c);
                    }
                    FacadeBlockId facadeId = extendedBlockState.getValue(GenericCableBlock.FACADEID);
                    if (((!GeneralConfiguration.showNonFacadedCablesWhileSneaking) || (!p.isSneaking())) && facadeId == null && !(block instanceof FacadeBlock)) {
                        continue;
                    }
                    CableColor color = extendedBlockState.getValue(GenericCableBlock.COLOR);
                    float r = 0;
                    float g = 0;
                    float b = 0;
                    switch(color) {
                        case BLUE:
                            r = .4f;
                            g = .4f;
                            b = 1f;
                            break;
                        case RED:
                            r = 1f;
                            g = .4f;
                            b = .4f;
                            break;
                        case YELLOW:
                            r = 1f;
                            g = 1f;
                            b = .4f;
                            break;
                        case GREEN:
                            r = .4f;
                            g = 1f;
                            b = .4f;
                            break;
                        case ROUTING:
                            r = .7f;
                            g = .7f;
                            b = .7f;
                            break;
                    }
                    List<Rect> quads = getQuads(extendedBlockState);
                    for (Rect quad : quads) {
                        renderRect(buffer, quad, c, r, g, b, 0.5f);
                    }
                }
            }
        }
    }
    tessellator.draw();
    GlStateManager.enableTexture2D();
    GlStateManager.popMatrix();
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) IBlockState(net.minecraft.block.state.IBlockState) FacadeBlockId(mcjty.xnet.blocks.facade.FacadeBlockId) GenericCableBlock(mcjty.xnet.blocks.generic.GenericCableBlock) BufferBuilder(net.minecraft.client.renderer.BufferBuilder) WorldClient(net.minecraft.client.multiplayer.WorldClient) FacadeBlock(mcjty.xnet.blocks.facade.FacadeBlock) IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState) FacadeBlock(mcjty.xnet.blocks.facade.FacadeBlock) GenericCableBlock(mcjty.xnet.blocks.generic.GenericCableBlock) Block(net.minecraft.block.Block) ConnectorBlock(mcjty.xnet.blocks.cables.ConnectorBlock) ItemBlock(net.minecraft.item.ItemBlock) BlockPos(net.minecraft.util.math.BlockPos) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) CableColor(mcjty.xnet.blocks.generic.CableColor) ConnectorBlock(mcjty.xnet.blocks.cables.ConnectorBlock)

Example 69 with IExtendedBlockState

use of net.minecraftforge.common.property.IExtendedBlockState in project XNet by McJty.

the class GenericCableBakedModel method getQuads.

@Override
public List<BakedQuad> getQuads(IBlockState state, EnumFacing side, long rand) {
    IExtendedBlockState extendedBlockState = (IExtendedBlockState) state;
    FacadeBlockId facadeId = extendedBlockState.getValue(GenericCableBlock.FACADEID);
    if (facadeId != null) {
        IBlockState facadeState = facadeId.getBlockState();
        if (!facadeState.getBlock().canRenderInLayer(facadeState, MinecraftForgeClient.getRenderLayer())) {
            return Collections.emptyList();
        }
        IBakedModel model = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getModelForState(facadeState);
        try {
            return model.getQuads(state, side, rand);
        } catch (Exception e) {
            return Collections.emptyList();
        }
    }
    if (side != null || (state.getBlock() instanceof ConnectorBlock && MinecraftForgeClient.getRenderLayer() != BlockRenderLayer.CUTOUT_MIPPED)) {
        return Collections.emptyList();
    }
    // Called with the blockstate from our block. Here we get the values of the six properties and pass that to
    // our baked model implementation.
    ConnectorType north = extendedBlockState.getValue(GenericCableBlock.NORTH);
    ConnectorType south = extendedBlockState.getValue(GenericCableBlock.SOUTH);
    ConnectorType west = extendedBlockState.getValue(GenericCableBlock.WEST);
    ConnectorType east = extendedBlockState.getValue(GenericCableBlock.EAST);
    ConnectorType up = extendedBlockState.getValue(GenericCableBlock.UP);
    ConnectorType down = extendedBlockState.getValue(GenericCableBlock.DOWN);
    CableColor cableColor = extendedBlockState.getValue(GenericCableBlock.COLOR);
    int index = cableColor.ordinal();
    initTextures();
    CableTextures ct = cableTextures[index];
    spriteCable = ct.spriteNormalCable;
    GenericCableBlock block = (GenericCableBlock) state.getBlock();
    if (block.isAdvancedConnector()) {
        spriteConnector = ct.spriteAdvancedConnector;
    } else {
        spriteConnector = ct.spriteConnector;
    }
    Function<CablePatterns.SpriteIdx, TextureAtlasSprite> getSprite = idx -> getSpriteNormal(idx, index);
    float hilight = 1.0f;
    if (block instanceof ConnectorBlock) {
        if (north != BLOCK && south != BLOCK && west != BLOCK && east != BLOCK && up != BLOCK && down != BLOCK) {
            // To make connectors with no actual connections visible
            hilight = 0.5f;
        }
    }
    List<BakedQuad> quads = new ArrayList<>();
    // Thickness of the cable. .0 would be full block, .5 is infinitely thin.
    double o = .4;
    // Thickness of the connector as it is put on the connecting block
    double p = .1;
    // The wideness of the connector
    double q = .2;
    if (up == CABLE) {
        quads.add(createQuad(v(1 - o, 1, o), v(1 - o, 1, 1 - o), v(1 - o, 1 - o, 1 - o), v(1 - o, 1 - o, o), spriteCable, hilight));
        quads.add(createQuad(v(o, 1, 1 - o), v(o, 1, o), v(o, 1 - o, o), v(o, 1 - o, 1 - o), spriteCable, hilight));
        quads.add(createQuad(v(o, 1, o), v(1 - o, 1, o), v(1 - o, 1 - o, o), v(o, 1 - o, o), spriteCable, hilight));
        quads.add(createQuad(v(o, 1 - o, 1 - o), v(1 - o, 1 - o, 1 - o), v(1 - o, 1, 1 - o), v(o, 1, 1 - o), spriteCable, hilight));
    } else if (up == BLOCK) {
        quads.add(createQuad(v(1 - o, 1 - p, o), v(1 - o, 1 - p, 1 - o), v(1 - o, 1 - o, 1 - o), v(1 - o, 1 - o, o), spriteCable, hilight));
        quads.add(createQuad(v(o, 1 - p, 1 - o), v(o, 1 - p, o), v(o, 1 - o, o), v(o, 1 - o, 1 - o), spriteCable, hilight));
        quads.add(createQuad(v(o, 1 - p, o), v(1 - o, 1 - p, o), v(1 - o, 1 - o, o), v(o, 1 - o, o), spriteCable, hilight));
        quads.add(createQuad(v(o, 1 - o, 1 - o), v(1 - o, 1 - o, 1 - o), v(1 - o, 1 - p, 1 - o), v(o, 1 - p, 1 - o), spriteCable, hilight));
        quads.add(createQuad(v(1 - q, 1 - p, q), v(1 - q, 1, q), v(1 - q, 1, 1 - q), v(1 - q, 1 - p, 1 - q), spriteSide, hilight));
        quads.add(createQuad(v(q, 1 - p, 1 - q), v(q, 1, 1 - q), v(q, 1, q), v(q, 1 - p, q), spriteSide, hilight));
        quads.add(createQuad(v(q, 1, q), v(1 - q, 1, q), v(1 - q, 1 - p, q), v(q, 1 - p, q), spriteSide, hilight));
        quads.add(createQuad(v(q, 1 - p, 1 - q), v(1 - q, 1 - p, 1 - q), v(1 - q, 1, 1 - q), v(q, 1, 1 - q), spriteSide, hilight));
        quads.add(createQuad(v(q, 1 - p, q), v(1 - q, 1 - p, q), v(1 - q, 1 - p, 1 - q), v(q, 1 - p, 1 - q), spriteConnector, hilight));
        quads.add(createQuad(v(q, 1, q), v(q, 1, 1 - q), v(1 - q, 1, 1 - q), v(1 - q, 1, q), spriteSide, hilight));
    } else {
        CablePatterns.QuadSetting pattern = CablePatterns.findPattern(west, south, east, north);
        quads.add(createQuad(v(o, 1 - o, 1 - o), v(1 - o, 1 - o, 1 - o), v(1 - o, 1 - o, o), v(o, 1 - o, o), getSprite.apply(pattern.getSprite()), pattern.getRotation(), hilight));
    }
    if (down == CABLE) {
        quads.add(createQuad(v(1 - o, o, o), v(1 - o, o, 1 - o), v(1 - o, 0, 1 - o), v(1 - o, 0, o), spriteCable, hilight));
        quads.add(createQuad(v(o, o, 1 - o), v(o, o, o), v(o, 0, o), v(o, 0, 1 - o), spriteCable, hilight));
        quads.add(createQuad(v(o, o, o), v(1 - o, o, o), v(1 - o, 0, o), v(o, 0, o), spriteCable, hilight));
        quads.add(createQuad(v(o, 0, 1 - o), v(1 - o, 0, 1 - o), v(1 - o, o, 1 - o), v(o, o, 1 - o), spriteCable, hilight));
    } else if (down == BLOCK) {
        quads.add(createQuad(v(1 - o, o, o), v(1 - o, o, 1 - o), v(1 - o, p, 1 - o), v(1 - o, p, o), spriteCable, hilight));
        quads.add(createQuad(v(o, o, 1 - o), v(o, o, o), v(o, p, o), v(o, p, 1 - o), spriteCable, hilight));
        quads.add(createQuad(v(o, o, o), v(1 - o, o, o), v(1 - o, p, o), v(o, p, o), spriteCable, hilight));
        quads.add(createQuad(v(o, p, 1 - o), v(1 - o, p, 1 - o), v(1 - o, o, 1 - o), v(o, o, 1 - o), spriteCable, hilight));
        quads.add(createQuad(v(1 - q, 0, q), v(1 - q, p, q), v(1 - q, p, 1 - q), v(1 - q, 0, 1 - q), spriteSide, hilight));
        quads.add(createQuad(v(q, 0, 1 - q), v(q, p, 1 - q), v(q, p, q), v(q, 0, q), spriteSide, hilight));
        quads.add(createQuad(v(q, p, q), v(1 - q, p, q), v(1 - q, 0, q), v(q, 0, q), spriteSide, hilight));
        quads.add(createQuad(v(q, 0, 1 - q), v(1 - q, 0, 1 - q), v(1 - q, p, 1 - q), v(q, p, 1 - q), spriteSide, hilight));
        quads.add(createQuad(v(q, p, 1 - q), v(1 - q, p, 1 - q), v(1 - q, p, q), v(q, p, q), spriteConnector, hilight));
        quads.add(createQuad(v(q, 0, 1 - q), v(q, 0, q), v(1 - q, 0, q), v(1 - q, 0, 1 - q), spriteSide, hilight));
    } else {
        CablePatterns.QuadSetting pattern = CablePatterns.findPattern(west, north, east, south);
        quads.add(createQuad(v(o, o, o), v(1 - o, o, o), v(1 - o, o, 1 - o), v(o, o, 1 - o), getSprite.apply(pattern.getSprite()), pattern.getRotation(), hilight));
    }
    if (east == CABLE) {
        quads.add(createQuad(v(1, 1 - o, 1 - o), v(1, 1 - o, o), v(1 - o, 1 - o, o), v(1 - o, 1 - o, 1 - o), spriteCable, hilight));
        quads.add(createQuad(v(1, o, o), v(1, o, 1 - o), v(1 - o, o, 1 - o), v(1 - o, o, o), spriteCable, hilight));
        quads.add(createQuad(v(1, 1 - o, o), v(1, o, o), v(1 - o, o, o), v(1 - o, 1 - o, o), spriteCable, hilight));
        quads.add(createQuad(v(1, o, 1 - o), v(1, 1 - o, 1 - o), v(1 - o, 1 - o, 1 - o), v(1 - o, o, 1 - o), spriteCable, hilight));
    } else if (east == BLOCK) {
        quads.add(createQuad(v(1 - p, 1 - o, 1 - o), v(1 - p, 1 - o, o), v(1 - o, 1 - o, o), v(1 - o, 1 - o, 1 - o), spriteCable, hilight));
        quads.add(createQuad(v(1 - p, o, o), v(1 - p, o, 1 - o), v(1 - o, o, 1 - o), v(1 - o, o, o), spriteCable, hilight));
        quads.add(createQuad(v(1 - p, 1 - o, o), v(1 - p, o, o), v(1 - o, o, o), v(1 - o, 1 - o, o), spriteCable, hilight));
        quads.add(createQuad(v(1 - p, o, 1 - o), v(1 - p, 1 - o, 1 - o), v(1 - o, 1 - o, 1 - o), v(1 - o, o, 1 - o), spriteCable, hilight));
        quads.add(createQuad(v(1 - p, 1 - q, 1 - q), v(1, 1 - q, 1 - q), v(1, 1 - q, q), v(1 - p, 1 - q, q), spriteSide, hilight));
        quads.add(createQuad(v(1 - p, q, q), v(1, q, q), v(1, q, 1 - q), v(1 - p, q, 1 - q), spriteSide, hilight));
        quads.add(createQuad(v(1 - p, 1 - q, q), v(1, 1 - q, q), v(1, q, q), v(1 - p, q, q), spriteSide, hilight));
        quads.add(createQuad(v(1 - p, q, 1 - q), v(1, q, 1 - q), v(1, 1 - q, 1 - q), v(1 - p, 1 - q, 1 - q), spriteSide, hilight));
        quads.add(createQuad(v(1 - p, q, 1 - q), v(1 - p, 1 - q, 1 - q), v(1 - p, 1 - q, q), v(1 - p, q, q), spriteConnector, hilight));
        quads.add(createQuad(v(1, q, 1 - q), v(1, q, q), v(1, 1 - q, q), v(1, 1 - q, 1 - q), spriteSide, hilight));
    } else {
        CablePatterns.QuadSetting pattern = CablePatterns.findPattern(down, north, up, south);
        quads.add(createQuad(v(1 - o, o, o), v(1 - o, 1 - o, o), v(1 - o, 1 - o, 1 - o), v(1 - o, o, 1 - o), getSprite.apply(pattern.getSprite()), pattern.getRotation(), hilight));
    }
    if (west == CABLE) {
        quads.add(createQuad(v(o, 1 - o, 1 - o), v(o, 1 - o, o), v(0, 1 - o, o), v(0, 1 - o, 1 - o), spriteCable, hilight));
        quads.add(createQuad(v(o, o, o), v(o, o, 1 - o), v(0, o, 1 - o), v(0, o, o), spriteCable, hilight));
        quads.add(createQuad(v(o, 1 - o, o), v(o, o, o), v(0, o, o), v(0, 1 - o, o), spriteCable, hilight));
        quads.add(createQuad(v(o, o, 1 - o), v(o, 1 - o, 1 - o), v(0, 1 - o, 1 - o), v(0, o, 1 - o), spriteCable, hilight));
    } else if (west == BLOCK) {
        quads.add(createQuad(v(o, 1 - o, 1 - o), v(o, 1 - o, o), v(p, 1 - o, o), v(p, 1 - o, 1 - o), spriteCable, hilight));
        quads.add(createQuad(v(o, o, o), v(o, o, 1 - o), v(p, o, 1 - o), v(p, o, o), spriteCable, hilight));
        quads.add(createQuad(v(o, 1 - o, o), v(o, o, o), v(p, o, o), v(p, 1 - o, o), spriteCable, hilight));
        quads.add(createQuad(v(o, o, 1 - o), v(o, 1 - o, 1 - o), v(p, 1 - o, 1 - o), v(p, o, 1 - o), spriteCable, hilight));
        quads.add(createQuad(v(0, 1 - q, 1 - q), v(p, 1 - q, 1 - q), v(p, 1 - q, q), v(0, 1 - q, q), spriteSide, hilight));
        quads.add(createQuad(v(0, q, q), v(p, q, q), v(p, q, 1 - q), v(0, q, 1 - q), spriteSide, hilight));
        quads.add(createQuad(v(0, 1 - q, q), v(p, 1 - q, q), v(p, q, q), v(0, q, q), spriteSide, hilight));
        quads.add(createQuad(v(0, q, 1 - q), v(p, q, 1 - q), v(p, 1 - q, 1 - q), v(0, 1 - q, 1 - q), spriteSide, hilight));
        quads.add(createQuad(v(p, q, q), v(p, 1 - q, q), v(p, 1 - q, 1 - q), v(p, q, 1 - q), spriteConnector, hilight));
        quads.add(createQuad(v(0, q, q), v(0, q, 1 - q), v(0, 1 - q, 1 - q), v(0, 1 - q, q), spriteSide, hilight));
    } else {
        CablePatterns.QuadSetting pattern = CablePatterns.findPattern(down, south, up, north);
        quads.add(createQuad(v(o, o, 1 - o), v(o, 1 - o, 1 - o), v(o, 1 - o, o), v(o, o, o), getSprite.apply(pattern.getSprite()), pattern.getRotation(), hilight));
    }
    if (north == CABLE) {
        quads.add(createQuad(v(o, 1 - o, o), v(1 - o, 1 - o, o), v(1 - o, 1 - o, 0), v(o, 1 - o, 0), spriteCable, hilight));
        quads.add(createQuad(v(o, o, 0), v(1 - o, o, 0), v(1 - o, o, o), v(o, o, o), spriteCable, hilight));
        quads.add(createQuad(v(1 - o, o, 0), v(1 - o, 1 - o, 0), v(1 - o, 1 - o, o), v(1 - o, o, o), spriteCable, hilight));
        quads.add(createQuad(v(o, o, o), v(o, 1 - o, o), v(o, 1 - o, 0), v(o, o, 0), spriteCable, hilight));
    } else if (north == BLOCK) {
        quads.add(createQuad(v(o, 1 - o, o), v(1 - o, 1 - o, o), v(1 - o, 1 - o, p), v(o, 1 - o, p), spriteCable, hilight));
        quads.add(createQuad(v(o, o, p), v(1 - o, o, p), v(1 - o, o, o), v(o, o, o), spriteCable, hilight));
        quads.add(createQuad(v(1 - o, o, p), v(1 - o, 1 - o, p), v(1 - o, 1 - o, o), v(1 - o, o, o), spriteCable, hilight));
        quads.add(createQuad(v(o, o, o), v(o, 1 - o, o), v(o, 1 - o, p), v(o, o, p), spriteCable, hilight));
        quads.add(createQuad(v(q, 1 - q, p), v(1 - q, 1 - q, p), v(1 - q, 1 - q, 0), v(q, 1 - q, 0), spriteSide, hilight));
        quads.add(createQuad(v(q, q, 0), v(1 - q, q, 0), v(1 - q, q, p), v(q, q, p), spriteSide, hilight));
        quads.add(createQuad(v(1 - q, q, 0), v(1 - q, 1 - q, 0), v(1 - q, 1 - q, p), v(1 - q, q, p), spriteSide, hilight));
        quads.add(createQuad(v(q, q, p), v(q, 1 - q, p), v(q, 1 - q, 0), v(q, q, 0), spriteSide, hilight));
        quads.add(createQuad(v(q, q, p), v(1 - q, q, p), v(1 - q, 1 - q, p), v(q, 1 - q, p), spriteConnector, hilight));
        quads.add(createQuad(v(q, q, 0), v(q, 1 - q, 0), v(1 - q, 1 - q, 0), v(1 - q, q, 0), spriteSide, hilight));
    } else {
        CablePatterns.QuadSetting pattern = CablePatterns.findPattern(west, up, east, down);
        quads.add(createQuad(v(o, 1 - o, o), v(1 - o, 1 - o, o), v(1 - o, o, o), v(o, o, o), getSprite.apply(pattern.getSprite()), pattern.getRotation(), hilight));
    }
    if (south == CABLE) {
        quads.add(createQuad(v(o, 1 - o, 1), v(1 - o, 1 - o, 1), v(1 - o, 1 - o, 1 - o), v(o, 1 - o, 1 - o), spriteCable, hilight));
        quads.add(createQuad(v(o, o, 1 - o), v(1 - o, o, 1 - o), v(1 - o, o, 1), v(o, o, 1), spriteCable, hilight));
        quads.add(createQuad(v(1 - o, o, 1 - o), v(1 - o, 1 - o, 1 - o), v(1 - o, 1 - o, 1), v(1 - o, o, 1), spriteCable, hilight));
        quads.add(createQuad(v(o, o, 1), v(o, 1 - o, 1), v(o, 1 - o, 1 - o), v(o, o, 1 - o), spriteCable, hilight));
    } else if (south == BLOCK) {
        quads.add(createQuad(v(o, 1 - o, 1 - p), v(1 - o, 1 - o, 1 - p), v(1 - o, 1 - o, 1 - o), v(o, 1 - o, 1 - o), spriteCable, hilight));
        quads.add(createQuad(v(o, o, 1 - o), v(1 - o, o, 1 - o), v(1 - o, o, 1 - p), v(o, o, 1 - p), spriteCable, hilight));
        quads.add(createQuad(v(1 - o, o, 1 - o), v(1 - o, 1 - o, 1 - o), v(1 - o, 1 - o, 1 - p), v(1 - o, o, 1 - p), spriteCable, hilight));
        quads.add(createQuad(v(o, o, 1 - p), v(o, 1 - o, 1 - p), v(o, 1 - o, 1 - o), v(o, o, 1 - o), spriteCable, hilight));
        quads.add(createQuad(v(q, 1 - q, 1), v(1 - q, 1 - q, 1), v(1 - q, 1 - q, 1 - p), v(q, 1 - q, 1 - p), spriteSide, hilight));
        quads.add(createQuad(v(q, q, 1 - p), v(1 - q, q, 1 - p), v(1 - q, q, 1), v(q, q, 1), spriteSide, hilight));
        quads.add(createQuad(v(1 - q, q, 1 - p), v(1 - q, 1 - q, 1 - p), v(1 - q, 1 - q, 1), v(1 - q, q, 1), spriteSide, hilight));
        quads.add(createQuad(v(q, q, 1), v(q, 1 - q, 1), v(q, 1 - q, 1 - p), v(q, q, 1 - p), spriteSide, hilight));
        quads.add(createQuad(v(q, 1 - q, 1 - p), v(1 - q, 1 - q, 1 - p), v(1 - q, q, 1 - p), v(q, q, 1 - p), spriteConnector, hilight));
        quads.add(createQuad(v(q, 1 - q, 1), v(q, q, 1), v(1 - q, q, 1), v(1 - q, 1 - q, 1), spriteSide, hilight));
    } else {
        CablePatterns.QuadSetting pattern = CablePatterns.findPattern(west, down, east, up);
        quads.add(createQuad(v(o, o, 1 - o), v(1 - o, o, 1 - o), v(1 - o, 1 - o, 1 - o), v(o, 1 - o, 1 - o), getSprite.apply(pattern.getSprite()), pattern.getRotation(), hilight));
    }
    return quads;
}
Also used : SpriteIdx(mcjty.xnet.blocks.generic.CablePatterns.SpriteIdx) IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState) BLOCK(mcjty.xnet.blocks.cables.ConnectorType.BLOCK) MinecraftForgeClient(net.minecraftforge.client.MinecraftForgeClient) ArrayList(java.util.ArrayList) SpriteIdx(mcjty.xnet.blocks.generic.CablePatterns.SpriteIdx) NetCableBlock(mcjty.xnet.blocks.cables.NetCableBlock) Block(net.minecraft.block.Block) Vec3d(net.minecraft.util.math.Vec3d) Minecraft(net.minecraft.client.Minecraft) ConnectorType(mcjty.xnet.blocks.cables.ConnectorType) FacadeBlockId(mcjty.xnet.blocks.facade.FacadeBlockId) VertexFormat(net.minecraft.client.renderer.vertex.VertexFormat) net.minecraft.client.renderer.block.model(net.minecraft.client.renderer.block.model) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) Function(com.google.common.base.Function) CABLE(mcjty.xnet.blocks.cables.ConnectorType.CABLE) EnumFacing(net.minecraft.util.EnumFacing) BlockRenderLayer(net.minecraft.util.BlockRenderLayer) XNet(mcjty.xnet.XNet) IBlockState(net.minecraft.block.state.IBlockState) List(java.util.List) UnpackedBakedQuad(net.minecraftforge.client.model.pipeline.UnpackedBakedQuad) ForgeRegistries(net.minecraftforge.fml.common.registry.ForgeRegistries) ResourceLocation(net.minecraft.util.ResourceLocation) ConnectorBlock(mcjty.xnet.blocks.cables.ConnectorBlock) Collections(java.util.Collections) UnpackedBakedQuad(net.minecraftforge.client.model.pipeline.UnpackedBakedQuad) IBlockState(net.minecraft.block.state.IBlockState) ConnectorType(mcjty.xnet.blocks.cables.ConnectorType) FacadeBlockId(mcjty.xnet.blocks.facade.FacadeBlockId) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) ArrayList(java.util.ArrayList) IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState) ConnectorBlock(mcjty.xnet.blocks.cables.ConnectorBlock)

Example 70 with IExtendedBlockState

use of net.minecraftforge.common.property.IExtendedBlockState in project XNet by McJty.

the class GenericCableBlock method getStateInternal.

public IBlockState getStateInternal(IBlockState state, IBlockAccess world, BlockPos pos) {
    IExtendedBlockState extendedBlockState = (IExtendedBlockState) state;
    CableColor color = state.getValue(COLOR);
    ConnectorType north = getConnectorType(color, world, pos, EnumFacing.NORTH);
    ConnectorType south = getConnectorType(color, world, pos, EnumFacing.SOUTH);
    ConnectorType west = getConnectorType(color, world, pos, EnumFacing.WEST);
    ConnectorType east = getConnectorType(color, world, pos, EnumFacing.EAST);
    ConnectorType up = getConnectorType(color, world, pos, EnumFacing.UP);
    ConnectorType down = getConnectorType(color, world, pos, EnumFacing.DOWN);
    return extendedBlockState.withProperty(NORTH, north).withProperty(SOUTH, south).withProperty(WEST, west).withProperty(EAST, east).withProperty(UP, up).withProperty(DOWN, down);
}
Also used : ConnectorType(mcjty.xnet.blocks.cables.ConnectorType) IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState)

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