Search in sources :

Example 1 with FacadeBlock

use of mcjty.xnet.blocks.facade.FacadeBlock in project XNet by McJty.

the class ModBlocks method init.

public static void init() {
    controllerBlock = new ControllerBlock();
    routerBlock = new RouterBlock();
    facadeBlock = new FacadeBlock();
    redstoneProxyBlock = new RedstoneProxyBlock();
    redstoneProxyUBlock = new RedstoneProxyUBlock();
    NetCableSetup.init();
}
Also used : FacadeBlock(mcjty.xnet.blocks.facade.FacadeBlock) RedstoneProxyBlock(mcjty.xnet.blocks.redstoneproxy.RedstoneProxyBlock) ControllerBlock(mcjty.xnet.blocks.controller.ControllerBlock) RedstoneProxyUBlock(mcjty.xnet.blocks.redstoneproxy.RedstoneProxyUBlock) RouterBlock(mcjty.xnet.blocks.router.RouterBlock)

Example 2 with FacadeBlock

use of mcjty.xnet.blocks.facade.FacadeBlock 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)

Aggregations

FacadeBlock (mcjty.xnet.blocks.facade.FacadeBlock)2 ConnectorBlock (mcjty.xnet.blocks.cables.ConnectorBlock)1 ControllerBlock (mcjty.xnet.blocks.controller.ControllerBlock)1 FacadeBlockId (mcjty.xnet.blocks.facade.FacadeBlockId)1 CableColor (mcjty.xnet.blocks.generic.CableColor)1 GenericCableBlock (mcjty.xnet.blocks.generic.GenericCableBlock)1 RedstoneProxyBlock (mcjty.xnet.blocks.redstoneproxy.RedstoneProxyBlock)1 RedstoneProxyUBlock (mcjty.xnet.blocks.redstoneproxy.RedstoneProxyUBlock)1 RouterBlock (mcjty.xnet.blocks.router.RouterBlock)1 Block (net.minecraft.block.Block)1 IBlockState (net.minecraft.block.state.IBlockState)1 EntityPlayerSP (net.minecraft.client.entity.EntityPlayerSP)1 WorldClient (net.minecraft.client.multiplayer.WorldClient)1 BufferBuilder (net.minecraft.client.renderer.BufferBuilder)1 Tessellator (net.minecraft.client.renderer.Tessellator)1 ItemBlock (net.minecraft.item.ItemBlock)1 BlockPos (net.minecraft.util.math.BlockPos)1 IExtendedBlockState (net.minecraftforge.common.property.IExtendedBlockState)1