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