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();
}
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;
}
}
Aggregations