use of blusunrize.immersiveengineering.common.blocks.metal.TileEntitySampleDrill in project ImmersiveEngineering by BluSunrize.
the class ClientEventHandler method onRenderWorldLastEvent.
@SubscribeEvent
public void onRenderWorldLastEvent(RenderWorldLastEvent event) {
EntityPlayer player = ClientUtils.mc().player;
// Overlay renderer for the sample drill
int[] chunkBorders = null;
if (sampleDrill.isEmpty())
sampleDrill = new ItemStack(IEContent.blockMetalDevice1, 1, BlockTypes_MetalDevice1.SAMPLE_DRILL.getMeta());
if (coreSample.isEmpty())
coreSample = new ItemStack(IEContent.itemCoresample);
for (EnumHand hand : EnumHand.values()) {
ItemStack heldItem = player.getHeldItem(hand);
if (OreDictionary.itemMatches(sampleDrill, heldItem, true)) {
chunkBorders = new int[] { (int) player.posX >> 4 << 4, (int) player.posZ >> 4 << 4 };
break;
} else if (OreDictionary.itemMatches(coreSample, heldItem, true) && ItemNBTHelper.hasKey(heldItem, "coords")) {
int[] coords = ItemNBTHelper.getIntArray(heldItem, "coords");
if (coords[0] == player.getEntityWorld().provider.getDimension()) {
chunkBorders = new int[] { coords[1] << 4, coords[2] << 4 };
break;
}
}
}
if (chunkBorders == null && ClientUtils.mc().objectMouseOver != null && ClientUtils.mc().objectMouseOver.typeOfHit == Type.BLOCK && ClientUtils.mc().world.getTileEntity(ClientUtils.mc().objectMouseOver.getBlockPos()) instanceof TileEntitySampleDrill)
chunkBorders = new int[] { (int) player.posX >> 4 << 4, (int) player.posZ >> 4 << 4 };
float partial = event.getPartialTicks();
if (!ParticleFractal.PARTICLE_FRACTAL_DEQUE.isEmpty()) {
double px = TileEntityRendererDispatcher.staticPlayerX;
double py = TileEntityRendererDispatcher.staticPlayerY;
double pz = TileEntityRendererDispatcher.staticPlayerZ;
Tessellator tessellator = Tessellator.getInstance();
GlStateManager.disableTexture2D();
GlStateManager.enableBlend();
GlStateManager.disableCull();
GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
GlStateManager.shadeModel(GL11.GL_SMOOTH);
tessellator.getBuffer().setTranslation(-px, -py, -pz);
ParticleFractal part;
while ((part = ParticleFractal.PARTICLE_FRACTAL_DEQUE.pollFirst()) != null) part.render(tessellator, tessellator.getBuffer(), partial);
tessellator.getBuffer().setTranslation(0, 0, 0);
GlStateManager.shadeModel(GL11.GL_FLAT);
GlStateManager.enableCull();
GlStateManager.disableBlend();
GlStateManager.enableTexture2D();
}
if (chunkBorders != null) {
renderChunkBorders(player, chunkBorders[0], chunkBorders[1]);
}
if (!FAILED_CONNECTIONS.isEmpty()) {
Entity viewer = ClientUtils.mc().getRenderViewEntity();
if (viewer == null)
viewer = player;
double dx = viewer.lastTickPosX + (viewer.posX - viewer.lastTickPosX) * partial;
double dy = viewer.lastTickPosY + (viewer.posY - viewer.lastTickPosY) * partial;
double dz = viewer.lastTickPosZ + (viewer.posZ - viewer.lastTickPosZ) * partial;
Tessellator tes = Tessellator.getInstance();
BufferBuilder bb = tes.getBuffer();
float oldLineWidth = GL11.glGetFloat(GL11.GL_LINE_WIDTH);
GlStateManager.glLineWidth(5);
GlStateManager.disableTexture2D();
GlStateManager.enableBlend();
bb.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION_COLOR);
for (Entry<Connection, Pair<BlockPos, AtomicInteger>> entry : FAILED_CONNECTIONS.entrySet()) {
Connection conn = entry.getKey();
bb.setTranslation(conn.start.getX() - dx, conn.start.getY() - dy, conn.start.getZ() - dz);
Vec3d[] points = conn.getSubVertices(ClientUtils.mc().world);
int time = entry.getValue().getValue().get();
float alpha = (float) Math.min((2 + Math.sin(time * Math.PI / 40)) / 3, time / 20F);
for (int i = 0; i < points.length - 1; i++) {
bb.pos(points[i].x, points[i].y, points[i].z).color(1, 0, 0, alpha).endVertex();
alpha = (float) Math.min((2 + Math.sin((time + (i + 1) * 8) * Math.PI / 40)) / 3, time / 20F);
bb.pos(points[i + 1].x, points[i + 1].y, points[i + 1].z).color(1, 0, 0, alpha).endVertex();
}
}
bb.setTranslation(0, 0, 0);
tes.draw();
GlStateManager.glLineWidth(oldLineWidth);
GlStateManager.enableBlend();
GlStateManager.color(1, 0, 0, .5F);
renderObstructingBlocks(bb, tes, dx, dy, dz);
// Code to render the obstructing block through other blocks
// GlStateManager.color(1, 0, 0, .25F);
// GlStateManager.depthFunc(GL11.GL_GREATER);
// renderObstructingBlocks(bb, tes, dx, dy, dz);
// GlStateManager.depthFunc(GL11.GL_LEQUAL);
GlStateManager.disableBlend();
GlStateManager.enableTexture2D();
}
}
Aggregations