Search in sources :

Example 1 with BlockStainedGlass

use of net.minecraft.block.BlockStainedGlass in project Charset by CharsetMC.

the class ProjectorRenderer method onRender.

@SubscribeEvent
public void onRender(RenderWorldLastEvent event) {
    Minecraft.getMinecraft().mcProfiler.startSection("projectors");
    GlStateManager.enableBlend();
    GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
    GlStateManager.glBlendEquation(GL14.GL_FUNC_ADD);
    GlStateManager.enableTexture2D();
    GlStateManager.enableAlpha();
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder worldrenderer = tessellator.getBuffer();
    worldrenderer.setTranslation(0, 0, 0);
    Entity cameraEntity = Minecraft.getMinecraft().getRenderViewEntity();
    Vec3d cameraPos = EntityUtils.interpolate(cameraEntity, event.getPartialTicks());
    ICamera camera = new Frustum();
    camera.setPosition(cameraPos.x, cameraPos.y, cameraPos.z);
    GlStateManager.pushMatrix();
    GlStateManager.translate(-cameraPos.x, -cameraPos.y, -cameraPos.z);
    for (TileEntity tileEntity : Minecraft.getMinecraft().world.loadedTileEntityList) {
        if (tileEntity instanceof TileProjector) {
            LaserColor color = LaserColor.NONE;
            Orientation orientation = ((TileProjector) tileEntity).getOrientation();
            if (CharsetProjector.useLasers) {
                for (int d = 0; d < 6; d++) {
                    LaserColor color2 = ((TileProjector) tileEntity).colors[d];
                    if (color2 != null && color2 != LaserColor.NONE) {
                        if (d == orientation.facing.getOpposite().ordinal()) {
                            // not rendering anything - laser in the way
                            color = LaserColor.NONE;
                            break;
                        } else {
                            color = color.union(color2);
                        }
                    }
                }
            } else {
                color = ((TileProjector) tileEntity).redstoneLevel > 0 ? LaserColor.WHITE : LaserColor.NONE;
            }
            if (color != LaserColor.NONE) {
                ItemStack stack = ((TileProjector) tileEntity).getStack();
                IProjectorHandler<ItemStack> handler = CharsetProjector.getHandler(stack);
                if (handler == null) {
                    continue;
                }
                Surface surface = getSurface(tileEntity.getWorld(), tileEntity.getPos(), orientation, 0.5f, handler.getAspectRatio(stack));
                if (surface == null) {
                    continue;
                }
                if (!camera.isBoundingBoxInFrustum(new AxisAlignedBB(surface.cornerStart, surface.cornerEnd))) {
                    continue;
                }
                surface.r = color.red ? 1.0f : 0.0f;
                surface.g = color.green ? 1.0f : 0.0f;
                surface.b = color.blue ? 1.0f : 0.0f;
                surface.a = 0.5f;
                if (!CharsetProjector.useLasers) {
                    surface.a *= ((TileProjector) tileEntity).redstoneLevel / 15.0f;
                }
                EnumDyeColor dyeColor = null;
                BlockPos inFrontPos = tileEntity.getPos().offset(((TileProjector) tileEntity).getOrientation().facing);
                IBlockState state = tileEntity.getWorld().getBlockState(inFrontPos);
                if (state.getBlock() instanceof BlockStainedGlass) {
                    dyeColor = state.getValue(BlockStainedGlass.COLOR);
                }
                if (dyeColor != null) {
                    float[] v = dyeColor.getColorComponentValues();
                    surface.r *= v[0];
                    surface.g *= v[1];
                    surface.b *= v[2];
                }
                surface.restoreGLColor();
                handler.render(stack, (IProjector) tileEntity, surface);
            }
        }
    }
    GlStateManager.popMatrix();
    GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GlStateManager.glBlendEquation(GL14.GL_FUNC_ADD);
    GlStateManager.disableBlend();
    Minecraft.getMinecraft().mcProfiler.endSection();
}
Also used : Entity(net.minecraft.entity.Entity) TileEntity(net.minecraft.tileentity.TileEntity) Frustum(net.minecraft.client.renderer.culling.Frustum) Tessellator(net.minecraft.client.renderer.Tessellator) IBlockState(net.minecraft.block.state.IBlockState) BufferBuilder(net.minecraft.client.renderer.BufferBuilder) ICamera(net.minecraft.client.renderer.culling.ICamera) Orientation(pl.asie.charset.lib.utils.Orientation) EnumDyeColor(net.minecraft.item.EnumDyeColor) TileEntity(net.minecraft.tileentity.TileEntity) BlockStainedGlass(net.minecraft.block.BlockStainedGlass) LaserColor(pl.asie.charset.api.laser.LaserColor) ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 2 with BlockStainedGlass

use of net.minecraft.block.BlockStainedGlass in project SpringFestival by TeamCovertDragon.

the class BlockHangingFirecracker method canBlockStay.

public boolean canBlockStay(World worldIn, BlockPos pos) {
    pos = pos.up();
    IBlockState state = worldIn.getBlockState(pos);
    Block block = state.getBlock();
    if (state.isSideSolid(worldIn, pos, EnumFacing.DOWN) || state.getBlockFaceShape(worldIn, pos, EnumFacing.DOWN) == BlockFaceShape.SOLID) {
        return block != Blocks.END_GATEWAY && !(block instanceof BlockPistonBase);
    } else if (block instanceof BlockHangingFirecracker) {
        return state.getValue(COUNT) == 0;
    } else {
        return block.isLeaves(state, worldIn, pos) || block instanceof BlockFence || block instanceof BlockGlass || block instanceof BlockWall || block instanceof BlockStainedGlass;
    }
}
Also used : BlockStainedGlass(net.minecraft.block.BlockStainedGlass) IBlockState(net.minecraft.block.state.IBlockState) BlockWall(net.minecraft.block.BlockWall) BlockPistonBase(net.minecraft.block.BlockPistonBase) BlockGlass(net.minecraft.block.BlockGlass) Block(net.minecraft.block.Block) BlockFence(net.minecraft.block.BlockFence)

Aggregations

BlockStainedGlass (net.minecraft.block.BlockStainedGlass)2 IBlockState (net.minecraft.block.state.IBlockState)2 Block (net.minecraft.block.Block)1 BlockFence (net.minecraft.block.BlockFence)1 BlockGlass (net.minecraft.block.BlockGlass)1 BlockPistonBase (net.minecraft.block.BlockPistonBase)1 BlockWall (net.minecraft.block.BlockWall)1 BufferBuilder (net.minecraft.client.renderer.BufferBuilder)1 Tessellator (net.minecraft.client.renderer.Tessellator)1 Frustum (net.minecraft.client.renderer.culling.Frustum)1 ICamera (net.minecraft.client.renderer.culling.ICamera)1 Entity (net.minecraft.entity.Entity)1 EnumDyeColor (net.minecraft.item.EnumDyeColor)1 ItemStack (net.minecraft.item.ItemStack)1 TileEntity (net.minecraft.tileentity.TileEntity)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1 LaserColor (pl.asie.charset.api.laser.LaserColor)1 Orientation (pl.asie.charset.lib.utils.Orientation)1