Java Code Examples for net.minecraftforge.client.event.RenderWorldLastEvent#getPartialTicks()
The following examples show how to use
net.minecraftforge.client.event.RenderWorldLastEvent#getPartialTicks() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ItemEspHack.java From ForgeWurst with GNU General Public License v3.0 | 5 votes |
@SubscribeEvent public void onRenderWorldLast(RenderWorldLastEvent event) { // GL settings GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glEnable(GL11.GL_LINE_SMOOTH); GL11.glLineWidth(2); GL11.glPushMatrix(); GL11.glTranslated(-TileEntityRendererDispatcher.staticPlayerX, -TileEntityRendererDispatcher.staticPlayerY, -TileEntityRendererDispatcher.staticPlayerZ); double partialTicks = event.getPartialTicks(); renderBoxes(partialTicks); if(style.getSelected().lines) renderTracers(partialTicks); GL11.glPopMatrix(); // GL resets GL11.glColor4f(1, 1, 1, 1); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_LINE_SMOOTH); }
Example 2
Source File: PlayerEspHack.java From ForgeWurst with GNU General Public License v3.0 | 5 votes |
@SubscribeEvent public void onRenderWorldLast(RenderWorldLastEvent event) { // GL settings GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glEnable(GL11.GL_LINE_SMOOTH); GL11.glLineWidth(2); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glPushMatrix(); GL11.glTranslated(-TileEntityRendererDispatcher.staticPlayerX, -TileEntityRendererDispatcher.staticPlayerY, -TileEntityRendererDispatcher.staticPlayerZ); double partialTicks = event.getPartialTicks(); if(style.getSelected().boxes) renderBoxes(partialTicks); if(style.getSelected().lines) renderLines(partialTicks); GL11.glPopMatrix(); // GL resets GL11.glColor4f(1, 1, 1, 1); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_LINE_SMOOTH); }
Example 3
Source File: MobEspHack.java From ForgeWurst with GNU General Public License v3.0 | 5 votes |
@SubscribeEvent public void onRenderWorldLast(RenderWorldLastEvent event) { // GL settings GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glEnable(GL11.GL_LINE_SMOOTH); GL11.glLineWidth(2); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glPushMatrix(); GL11.glTranslated(-TileEntityRendererDispatcher.staticPlayerX, -TileEntityRendererDispatcher.staticPlayerY, -TileEntityRendererDispatcher.staticPlayerZ); double partialTicks = event.getPartialTicks(); if(style.getSelected().boxes) renderBoxes(partialTicks); if(style.getSelected().lines) renderTracers(partialTicks); GL11.glPopMatrix(); // GL resets GL11.glColor4f(1, 1, 1, 1); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_LINE_SMOOTH); }
Example 4
Source File: RenderEventService.java From ForgeHax with MIT License | 5 votes |
@SubscribeEvent public void onRenderWorld(RenderWorldLastEvent event) { GlStateManager.pushMatrix(); GlStateManager.disableTexture2D(); GlStateManager.enableBlend(); GlStateManager.disableAlpha(); GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); GlStateManager.shadeModel(GL11.GL_SMOOTH); GlStateManager.disableDepth(); GlStateManager.glLineWidth(1.f); Vec3d renderPos = EntityUtils.getInterpolatedPos(getRenderEntity(), event.getPartialTicks()); RenderEvent e = new RenderEvent(TESSELLATOR, renderPos, event.getPartialTicks()); e.resetTranslation(); MinecraftForge.EVENT_BUS.post(e); GlStateManager.glLineWidth(1.f); GlStateManager.shadeModel(GL11.GL_FLAT); GlStateManager.disableBlend(); GlStateManager.enableAlpha(); GlStateManager.enableTexture2D(); GlStateManager.enableDepth(); GlStateManager.enableCull(); GlStateManager.popMatrix(); }
Example 5
Source File: AutoFarmHack.java From ForgeWurst with GNU General Public License v3.0 | 4 votes |
@SubscribeEvent public void onRenderWorldLast(RenderWorldLastEvent event) { // GL settings GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glEnable(GL11.GL_LINE_SMOOTH); GL11.glLineWidth(2); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glPushMatrix(); GL11.glTranslated(-TileEntityRendererDispatcher.staticPlayerX, -TileEntityRendererDispatcher.staticPlayerY, -TileEntityRendererDispatcher.staticPlayerZ); GL11.glCallList(displayList); if(currentBlock != null) { GL11.glPushMatrix(); AxisAlignedBB box = new AxisAlignedBB(BlockPos.ORIGIN); float p = prevProgress + (progress - prevProgress) * event.getPartialTicks(); float red = p * 2F; float green = 2 - red; GL11.glTranslated(currentBlock.getX(), currentBlock.getY(), currentBlock.getZ()); if(p < 1) { GL11.glTranslated(0.5, 0.5, 0.5); GL11.glScaled(p, p, p); GL11.glTranslated(-0.5, -0.5, -0.5); } GL11.glColor4f(red, green, 0, 0.25F); GL11.glBegin(GL11.GL_QUADS); RenderUtils.drawSolidBox(box); GL11.glEnd(); GL11.glColor4f(red, green, 0, 0.5F); GL11.glBegin(GL11.GL_LINES); RenderUtils.drawOutlinedBox(box); GL11.glEnd(); GL11.glPopMatrix(); } GL11.glPopMatrix(); // GL resets GL11.glColor4f(1, 1, 1, 1); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_LINE_SMOOTH); }
Example 6
Source File: TunnellerHack.java From ForgeWurst with GNU General Public License v3.0 | 4 votes |
@SubscribeEvent public void onRenderWorldLast(RenderWorldLastEvent event) { // GL settings GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glEnable(GL11.GL_LINE_SMOOTH); GL11.glLineWidth(2); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glPushMatrix(); GL11.glTranslated(-TileEntityRendererDispatcher.staticPlayerX, -TileEntityRendererDispatcher.staticPlayerY, -TileEntityRendererDispatcher.staticPlayerZ); for(int displayList : displayLists) GL11.glCallList(displayList); if(currentBlock != null) { float p = prevProgress + (progress - prevProgress) * event.getPartialTicks(); float red = p * 2F; float green = 2 - red; GL11.glTranslated(currentBlock.getX(), currentBlock.getY(), currentBlock.getZ()); if(p < 1) { GL11.glTranslated(0.5, 0.5, 0.5); GL11.glScaled(p, p, p); GL11.glTranslated(-0.5, -0.5, -0.5); } AxisAlignedBB box2 = new AxisAlignedBB(BlockPos.ORIGIN); GL11.glColor4f(red, green, 0, 0.25F); GL11.glBegin(GL11.GL_QUADS); RenderUtils.drawSolidBox(box2); GL11.glEnd(); GL11.glColor4f(red, green, 0, 0.5F); GL11.glBegin(GL11.GL_LINES); RenderUtils.drawOutlinedBox(box2); GL11.glEnd(); } GL11.glPopMatrix(); // GL resets GL11.glColor4f(1, 1, 1, 1); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_LINE_SMOOTH); }
Example 7
Source File: ChestEspHack.java From ForgeWurst with GNU General Public License v3.0 | 4 votes |
@SubscribeEvent public void onRenderWorldLast(RenderWorldLastEvent event) { // GL settings GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glEnable(GL11.GL_LINE_SMOOTH); GL11.glLineWidth(2); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glPushMatrix(); GL11.glTranslated(-TileEntityRendererDispatcher.staticPlayerX, -TileEntityRendererDispatcher.staticPlayerY, -TileEntityRendererDispatcher.staticPlayerZ); // minecart interpolation double partialTicks = event.getPartialTicks(); ArrayList<AxisAlignedBB> minecartBoxes = new ArrayList<>(minecarts.size()); minecarts.forEach(e -> { double offsetX = -(e.posX - e.lastTickPosX) + (e.posX - e.lastTickPosX) * partialTicks; double offsetY = -(e.posY - e.lastTickPosY) + (e.posY - e.lastTickPosY) * partialTicks; double offsetZ = -(e.posZ - e.lastTickPosZ) + (e.posZ - e.lastTickPosZ) * partialTicks; minecartBoxes.add( e.getRenderBoundingBox().offset(offsetX, offsetY, offsetZ)); }); if(style.getSelected().boxes) { GL11.glCallList(normalChests); renderBoxes(minecartBoxes, greenBox); } if(style.getSelected().lines) { Vec3d start = RotationUtils.getClientLookVec() .addVector(0, WMinecraft.getPlayer().getEyeHeight(), 0) .addVector(TileEntityRendererDispatcher.staticPlayerX, TileEntityRendererDispatcher.staticPlayerY, TileEntityRendererDispatcher.staticPlayerZ); GL11.glBegin(GL11.GL_LINES); GL11.glColor4f(0, 1, 0, 0.5F); renderLines(start, basicChests); renderLines(start, minecartBoxes); GL11.glColor4f(1, 0.5F, 0, 0.5F); renderLines(start, trappedChests); GL11.glColor4f(0, 1, 1, 0.5F); renderLines(start, enderChests); GL11.glEnd(); } GL11.glPopMatrix(); // GL resets GL11.glColor4f(1, 1, 1, 1); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_LINE_SMOOTH); }
Example 8
Source File: NukerHack.java From ForgeWurst with GNU General Public License v3.0 | 4 votes |
@SubscribeEvent public void onRenderWorldLast(RenderWorldLastEvent event) { if(currentBlock == null) return; // GL settings GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glEnable(GL11.GL_LINE_SMOOTH); GL11.glLineWidth(2); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glPushMatrix(); GL11.glTranslated(-TileEntityRendererDispatcher.staticPlayerX, -TileEntityRendererDispatcher.staticPlayerY, -TileEntityRendererDispatcher.staticPlayerZ); AxisAlignedBB box = new AxisAlignedBB(BlockPos.ORIGIN); float p = prevProgress + (progress - prevProgress) * event.getPartialTicks(); float red = p * 2F; float green = 2 - red; GL11.glTranslated(currentBlock.getX(), currentBlock.getY(), currentBlock.getZ()); if(p < 1) { GL11.glTranslated(0.5, 0.5, 0.5); GL11.glScaled(p, p, p); GL11.glTranslated(-0.5, -0.5, -0.5); } GL11.glColor4f(red, green, 0, 0.25F); GL11.glBegin(GL11.GL_QUADS); RenderUtils.drawSolidBox(box); GL11.glEnd(); GL11.glColor4f(red, green, 0, 0.5F); GL11.glBegin(GL11.GL_LINES); RenderUtils.drawOutlinedBox(box); GL11.glEnd(); GL11.glPopMatrix(); // GL resets GL11.glColor4f(1, 1, 1, 1); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_LINE_SMOOTH); }
Example 9
Source File: UnicornTrailRenderer.java From Wizardry with GNU Lesser General Public License v3.0 | 4 votes |
@SubscribeEvent @SideOnly(Side.CLIENT) public static void render(RenderWorldLastEvent event) { World world = Minecraft.getMinecraft().world; EntityPlayer player = Minecraft.getMinecraft().player; if (player == null || world == null) return; GlStateManager.pushMatrix(); double interpPosX = player.lastTickPosX + (player.posX - player.lastTickPosX) * event.getPartialTicks(); double interpPosY = player.lastTickPosY + (player.posY - player.lastTickPosY) * event.getPartialTicks(); double interpPosZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * event.getPartialTicks(); GlStateManager.translate(-interpPosX, -interpPosY + 0.1, -interpPosZ); GlStateManager.disableCull(); GlStateManager.depthMask(false); GlStateManager.enableBlend(); GlStateManager.disableTexture2D(); GlStateManager.shadeModel(GL11.GL_SMOOTH); GlStateManager.blendFunc(GL_SRC_ALPHA, GL_ONE); GlStateManager.enableColorMaterial(); GlStateManager.disableLighting(); Tessellator tessellator = Tessellator.getInstance(); BufferBuilder vb = tessellator.getBuffer(); Set<EntityUnicorn> corns = new HashSet<>(positions.keySet()); for (EntityUnicorn corn : corns) { if (corn.world.provider.getDimension() != world.provider.getDimension()) continue; List<Point> points = new ArrayList<>(positions.getOrDefault(corn, new ArrayList<>())); boolean q = false; vb.begin(GL11.GL_TRIANGLE_STRIP, DefaultVertexFormats.POSITION_COLOR); for (Point pos : points) { if (pos == null) continue; float sub = (world.getTotalWorldTime() - pos.time); Color color = Color.getHSBColor(sub % 360.0f / 360.0f, 1f, 1f); int alpha; if (sub < 500) { alpha = (int) (MathHelper.clamp(Math.log(sub + 1) / 2.0, 0, 1) * 80.0); } else { alpha = (int) (MathHelper.clamp(1 - (Math.log(sub) / 2.0), 0, 1) * 80.0); } pos(vb, pos.origin.subtract(pos.normal.scale(1.5))).color(color.getRed(), color.getGreen(), color.getBlue(), alpha).endVertex(); pos(vb, pos.origin.add(pos.normal.scale(1.5))).color(color.getRed(), color.getGreen(), color.getBlue(), alpha).endVertex(); q = !q; } tessellator.draw(); } GlStateManager.enableCull(); GlStateManager.depthMask(true); GlStateManager.disableBlend(); GlStateManager.enableTexture2D(); GlStateManager.shadeModel(GL11.GL_FLAT); GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO); GlStateManager.popMatrix(); }
Example 10
Source File: VideoHook.java From malmo with MIT License | 4 votes |
/** * Called when the world has been rendered but not yet the GUI or player hand. * * @param event * Contains information about the event (not used). */ @SubscribeEvent public void postRender(RenderWorldLastEvent event) { // Check that the video producer and frame type match - eg if this is a colourmap frame, then // only the colourmap videoproducer needs to do anything. boolean colourmapFrame = TextureHelper.colourmapFrame; boolean colourmapVideoProducer = this.videoProducer.getVideoType() == VideoType.COLOUR_MAP; if (colourmapFrame != colourmapVideoProducer) return; EntityPlayerSP player = Minecraft.getMinecraft().player; float x = (float) (player.lastTickPosX + (player.posX - player.lastTickPosX) * event.getPartialTicks()); float y = (float) (player.lastTickPosY + (player.posY - player.lastTickPosY) * event.getPartialTicks()); float z = (float) (player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * event.getPartialTicks()); float yaw = player.prevRotationYaw + (player.rotationYaw - player.prevRotationYaw) * event.getPartialTicks(); float pitch = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * event.getPartialTicks(); long time_before_ns = System.nanoTime(); if (observer != null) observer.frameProduced(); if (time_before_ns < retry_time_ns) return; boolean success = false; long time_after_render_ns; try { int size = this.videoProducer.getRequiredBufferSize(); if (AddressHelper.getMissionControlPort() == 0) { success = true; if (envServer != null) { // Write the obs data into a newly allocated buffer: byte[] data = new byte[size]; this.buffer.clear(); this.videoProducer.getFrame(this.missionInit, this.buffer); this.buffer.get(data); // Avoiding copy not simple as data is kept & written to a stream later. time_after_render_ns = System.nanoTime(); envServer.addFrame(data); } else { time_after_render_ns = System.nanoTime(); } } else { // Get buffer ready for writing to: this.buffer.clear(); this.headerbuffer.clear(); // Write the pos data: this.headerbuffer.putFloat(x); this.headerbuffer.putFloat(y); this.headerbuffer.putFloat(z); this.headerbuffer.putFloat(yaw); this.headerbuffer.putFloat(pitch); // Write the frame data: this.videoProducer.getFrame(this.missionInit, this.buffer); // The buffer gets flipped by getFrame(), but we need to flip our header buffer ourselves: this.headerbuffer.flip(); ByteBuffer[] buffers = {this.headerbuffer, this.buffer}; time_after_render_ns = System.nanoTime(); success = this.connection.sendTCPBytes(buffers, size + POS_HEADER_SIZE); } long time_after_ns = System.nanoTime(); float ms_send = (time_after_ns - time_after_render_ns) / 1000000.0f; float ms_render = (time_after_render_ns - time_before_ns) / 1000000.0f; if (success) { this.failedTCPSendCount = 0; // Reset count of failed sends. this.timeOfLastFrame = System.currentTimeMillis(); if (this.timeOfFirstFrame == 0) this.timeOfFirstFrame = this.timeOfLastFrame; this.framesSent++; // System.out.format("Total: %.2fms; collecting took %.2fms; sending %d bytes took %.2fms\n", ms_send + ms_render, ms_render, size, ms_send); // System.out.println("Collect: " + ms_render + "; Send: " + ms_send); } } catch (Exception e) { System.out.format(e.getMessage()); } if (!success) { System.out.format("Failed to send frame - will retry in %d seconds\n", RETRY_GAP_NS / 1000000000L); retry_time_ns = time_before_ns + RETRY_GAP_NS; this.failedTCPSendCount++; } }
Example 11
Source File: ClientEventHandler.java From Signals with GNU General Public License v3.0 | 4 votes |
@SubscribeEvent public void onWorldRender(RenderWorldLastEvent event){ Tessellator t = Tessellator.getInstance(); BufferBuilder b = t.getBuffer(); EntityPlayer player = Minecraft.getMinecraft().player; if(!shouldRender()) return; double playerX = player.prevPosX + (player.posX - player.prevPosX) * event.getPartialTicks(); double playerY = player.prevPosY + (player.posY - player.prevPosY) * event.getPartialTicks(); double playerZ = player.prevPosZ + (player.posZ - player.prevPosZ) * event.getPartialTicks(); int dimensionID = player.world.provider.getDimension(); GL11.glPushMatrix(); GL11.glTranslated(-playerX, -playerY, -playerZ); GL11.glPointSize(10); GlStateManager.disableTexture2D(); GlStateManager.disableLighting(); b.setTranslation(0, 0, 0); NetworkVisualizationSettings visualizationSettings = player.isSneaking() ? SignalsConfig.client.networkVisualization.sneaking : SignalsConfig.client.networkVisualization.notSneaking; switch(visualizationSettings.renderType){ case EDGES: edgeRenderer.render(dimensionID, b); break; case PATHS: pathRenderer.render(dimensionID, b); break; case SECTION: blockSectionRenderer.render(dimensionID, b); break; } //claimRenderer.render(b); if(visualizationSettings.renderDirectionality) { directionalityRenderer.render(dimensionID, b); } b.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION_COLOR); List<NetworkStation<MCPos>> stations = RailNetworkManager.getClientInstance().getNetwork().railObjects.getStations(); for(int i = 0; i < stations.size(); i++) { NetworkStation<MCPos> station1 = stations.get(i); if(station1.getPos().getDimID() != dimensionID) continue; for(int j = 0; j < i; j++) { NetworkStation<MCPos> station2 = stations.get(j); if(station2.getPos().getDimID() != dimensionID) continue; if(station1.stationName.equals(station2.stationName) && station1.getPos().getDimID() == station2.getPos().getDimID()) { drawBetween(b, station1.getPos().getPos(), station2.getPos().getPos(), 1, 0, 1, 0, 1); } } } t.draw(); GlStateManager.enableTexture2D(); GlStateManager.enableLighting(); GL11.glPopMatrix(); }