Search in sources :

Example 1 with IMatcher

use of gregtech.common.terminal.app.worldprospector.matcher.IMatcher in project GregTech by GregTechCEu.

the class WorldProspectorARApp method renderAxisAlignedBB.

@SideOnly(Side.CLIENT)
private void renderAxisAlignedBB(float partialTicks) {
    Minecraft mc = Minecraft.getMinecraft();
    Entity entity = mc.getRenderViewEntity();
    if (entity == null)
        return;
    final double posX = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * partialTicks;
    final double posY = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * partialTicks;
    final double posZ = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * partialTicks;
    GlStateManager.disableLighting();
    GlStateManager.disableDepth();
    GlStateManager.enableBlend();
    GlStateManager.disableTexture2D();
    GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
    GlStateManager.pushMatrix();
    GlStateManager.translate(-posX, -posY, -posZ);
    final Tessellator tessellator = Tessellator.getInstance();
    final BufferBuilder buffer = tessellator.getBuffer();
    buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
    for (IMatcher matcher : matchers) {
        int color = matcher.getColor();
        final float r = ((color >> 16) & 0xFF) / 255f;
        final float g = ((color >> 8) & 0xFF) / 255f;
        final float b = (color & 0xFF) / 255f;
        final float a = 1;
        for (AxisAlignedBB bound : founds.get(matcher).keySet()) {
            RenderBufferHelper.renderCubeFace(buffer, bound.minX, bound.minY, bound.minZ, bound.maxX, bound.maxY, bound.maxZ, r, g, b, a);
        }
    }
    tessellator.draw();
    GlStateManager.popMatrix();
    GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GlStateManager.enableTexture2D();
    GlStateManager.disableBlend();
    GlStateManager.enableDepth();
    GlStateManager.enableLighting();
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) Entity(net.minecraft.entity.Entity) Tessellator(net.minecraft.client.renderer.Tessellator) IMatcher(gregtech.common.terminal.app.worldprospector.matcher.IMatcher) BufferBuilder(net.minecraft.client.renderer.BufferBuilder) Minecraft(net.minecraft.client.Minecraft) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 2 with IMatcher

use of gregtech.common.terminal.app.worldprospector.matcher.IMatcher in project GregTech by GregTechCEu.

the class WorldProspectorARApp method tickAR.

@SideOnly(Side.CLIENT)
@Override
public void tickAR(EntityPlayer player) {
    World world = player.world;
    if (radius == 0 || lastPos == null) {
        lastPos = player.getPosition();
    }
    int maxY = Math.min(256, maxRadius + player.getPosition().getY());
    int minY = Math.max(0, -maxRadius + player.getPosition().getY());
    for (BlockPos pos : bresenhamCircle(lastPos.getX(), lastPos.getZ(), radius)) {
        for (int y = minY; y <= maxY; y++) {
            for (IMatcher matcher : matchers) {
                BlockPos blockPos = new BlockPos(pos.getX(), y, pos.getZ());
                if (matcher.match(world.getBlockState(blockPos))) {
                    addCluster(blockPos, founds.get(matcher));
                }
            }
        }
    }
    if (radius == maxRadius) {
        radius = 0;
        for (IMatcher matcher : matchers) {
            Iterator<Map.Entry<AxisAlignedBB, Set<BlockPos>>> it = founds.get(matcher).entrySet().iterator();
            while (it.hasNext()) {
                Map.Entry<AxisAlignedBB, Set<BlockPos>> entry = it.next();
                entry.getValue().removeIf(pos -> !matcher.match(world.getBlockState(pos)));
                if (entry.getValue().isEmpty()) {
                    it.remove();
                }
            }
        }
    } else {
        radius++;
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) IMatcher(gregtech.common.terminal.app.worldprospector.matcher.IMatcher) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

IMatcher (gregtech.common.terminal.app.worldprospector.matcher.IMatcher)2 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)2 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)2 Minecraft (net.minecraft.client.Minecraft)1 BufferBuilder (net.minecraft.client.renderer.BufferBuilder)1 Tessellator (net.minecraft.client.renderer.Tessellator)1 Entity (net.minecraft.entity.Entity)1 BlockPos (net.minecraft.util.math.BlockPos)1 World (net.minecraft.world.World)1