diff --git a/java/src/game/Game.java b/java/src/game/Game.java index 355fc48..8248d54 100755 --- a/java/src/game/Game.java +++ b/java/src/game/Game.java @@ -32,6 +32,7 @@ import java.util.Locale; import java.util.Map; import java.util.Map.Entry; import java.util.Queue; +import java.util.Set; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import java.util.concurrent.Executors; @@ -144,6 +145,7 @@ import game.window.WCF; import game.window.Wheel; import game.window.WindowEvent; import game.world.BlockPos; +import game.world.BoundingBox; import game.world.Chunk; import game.world.Converter; import game.world.Facing; @@ -245,6 +247,7 @@ public class Game implements IThreadListener { public boolean tileOverlay; public boolean itemCheat; public boolean dayCycle = true; + public boolean showHud = true; private int leftClickCounter; private int rightClickTimer; @@ -745,11 +748,16 @@ public class Game implements IThreadListener { public void renderHud() { this.setupOverlay(); - if(this.theWorld != null && this.open == null && this.thirdPersonView == 0) { - Drawing.drawRectColor(this.fb_x / 2 - 1, this.fb_y / 2 - 16, 2, 32, - this.pointed != null && this.pointed.type != ObjectType.MISS ? 0xffffffff : 0xffcfcfcf); - Drawing.drawRectColor(this.fb_x / 2 - 16, this.fb_y / 2 - 1, 32, 2, - this.pointed != null && this.pointed.type != ObjectType.MISS ? 0xffffffff : 0xffcfcfcf); + if(this.theWorld != null && this.open == null && this.thirdPersonView == 0 && this.viewEntity != null) { + if(this.drawDebug) { + this.renderWorldDirections((float)Timing.tick_fraction); + } + else { + Drawing.drawRectColor(this.fb_x / 2 - 1, this.fb_y / 2 - 16, 2, 32, + this.pointed != null && this.pointed.type != ObjectType.MISS ? 0xffffffff : 0xffcfcfcf); + Drawing.drawRectColor(this.fb_x / 2 - 16, this.fb_y / 2 - 1, 32, 2, + this.pointed != null && this.pointed.type != ObjectType.MISS ? 0xffffffff : 0xffcfcfcf); + } } if(this.theWorld != null && this.open == null) { int selected = // this.getRenderViewEntity() != null && this.getRenderViewEntity().isPlayer() ? 9 : 0, @@ -926,6 +934,8 @@ public class Game implements IThreadListener { } if(this.open != null) this.open.render(); + if(Bind.INFO.isDown()) + this.drawInfo(); if(this.hudOverlay && !(this.open instanceof GuiConsole)) this.drawOverlay(); if(this.drawFps) { // && !(this.open instanceof GuiConsole) @@ -2089,9 +2099,9 @@ public class Game implements IThreadListener { // public void complete(String[] comp) { // // } - public void infolist(String[] list, int[] data) { - - } +// public void infolist(String[] list, int[] data) { +// +// } public void disconnected(String msg) { Log.SYSTEM.info("Getrennt: %s", msg); @@ -2511,7 +2521,7 @@ public class Game implements IThreadListener { }); this.registerDebug(Keysym.U, "HUD umschalten", new DebugRunner() { public void execute(Keysym key) { - + Game.this.showHud ^= true; } }); } @@ -2935,6 +2945,75 @@ public class Game implements IThreadListener { log.clear(); } } + + private static String formatPing(int ping) { + TextColor base; + if(ping < 0) { + base = TextColor.GRAY; + } + else if(ping < 80) { + base = TextColor.DGREEN; + } + else if(ping < 160) { + base = TextColor.GREEN; + } + else if(ping < 350) { + base = TextColor.YELLOW; + } + else if(ping < 700) { + base = TextColor.RED; + } + else { + base = TextColor.DRED; + } + return base + (ping < 10000 ? String.format("%d", ping) + "ms" : String.format("%.1f", ((float)ping) / 1000.0f) + "s"); + } + + public void drawInfo() { + NetHandlerPlayClient netHandler = this.getNetHandler(); + if(netHandler != null) { + Set> list = netHandler.getPlayerList(); + int size = list.size(); + int w = size > 80 ? 4 : (size > 40 ? 3 : (size > 10 ? 2 : 1)); + w = Math.min(w, Math.max(1, this.fb_x / 300)); + int bx = 0; + int by = 0; + for(Entry elem : list) { + int x = this.fb_x / 2 - (w * 300) / 2 + bx * 300; + int y = 10 + by * Font.YGLYPH; + Drawing.drawGradient(x, y, 300, Font.YGLYPH, 0x7f404040, 0x7f000000); + Drawing.drawText(elem.getKey(), x + 4, y, 0xffffffff); + Drawing.drawTextRight(formatPing(elem.getValue()), x + 299, y, 0xffffffff); + if(++bx >= w) { + bx = 0; + ++by; + } + } + } + } + + private void renderWorldDirections(float partialTicks) { + GlState.enableBlend(); + GlState.tryBlendFuncSeparate(770, 771, 1, 0); + WCF.glLineWidth(1.0F); + GlState.disableTexture2D(); + GlState.depthMask(false); + GlState.color(1.0f, 1.0f, 1.0f, 1.0f); + WCF.glPushMatrix(); +// WCF.glMatrixMode(5888); +// WCF.glLoadIdentity(); + WCF.glTranslatef(this.fb_x / 2, this.fb_y / 2, 0.0F); + this.entityRenderer.rotateCamera(this.viewEntity, partialTicks); +// WCF.glScalef(-1.0f, -1.0f, -1.0f); +// Drawing.drawRectColor(0, 0, 10, 2, 0xff00ff00); + RenderGlobal.drawOutlinedBoundingBox(new BoundingBox(0.0D, 0.0D, 0.0D, 24D, 1D, 1D), 255, 0, 0, 255); + RenderGlobal.drawOutlinedBoundingBox(new BoundingBox(0.0D, 0.0D, 0.0D, 1D, 1D, 24D), 0, 0, 255, 255); + RenderGlobal.drawOutlinedBoundingBox(new BoundingBox(0.0D, 0.0D, 0.0D, 1D, -20D, 1D), 0, 255, 0, 255); + WCF.glPopMatrix(); + GlState.depthMask(true); + GlState.enableTexture2D(); + GlState.disableBlend(); + } public void showDirDialog(final String title, final String def, final FileCallback callback) { new Thread(new Runnable() { diff --git a/java/src/game/Temp1.java b/java/src/game/Temp1.java index 42d2385..499f142 100644 --- a/java/src/game/Temp1.java +++ b/java/src/game/Temp1.java @@ -1655,28 +1655,6 @@ private static final Random RANDOM = new Random(); - private String formatPing(int ping) { - TextColor base; - if(ping < 0) { - base = TextColor.GRAY; - } - else if(ping < 80) { - base = TextColor.DARK_GREEN; - } - else if(ping < 160) { - base = TextColor.GREEN; - } - else if(ping < 350) { - base = TextColor.YELLOW; - } - else if(ping < 700) { - base = TextColor.RED; - } - else { - base = TextColor.DARK_RED; - } - return base + (ping < 10000 ? String.format("%d", ping) + "ms" : String.format("%.1f", ((float)ping) / 1000.0f) + "s"); - } private void drawPing(int width, int xPos, int yPos, int ping) { GlState.color(1.0F, 1.0F, 1.0F, 1.0F); @@ -2030,30 +2008,6 @@ private void renderBossHealth() { - private void renderWorldDirections(float partialTicks) - { - if (this.gm.showDebugInfo && this.gm.thirdPersonView == 0 && !this.gm.hideGUI) - { - Entity entity = this.gm.getRenderViewEntity(); - GlState.enableBlend(); - GlState.tryBlendFuncSeparate(770, 771, 1, 0); - SKC.glLineWidth(1.0F); - GlState.disableTexture2D(); - GlState.depthMask(false); - SKC.glPushMatrix(); - SKC.glMatrixMode(5888); - SKC.glLoadIdentity(); - this.orientCamera(partialTicks); - SKC.glTranslatef(0.0F, entity.getEyeHeight(), 0.0F); - RenderGlobal.drawOutlinedBoundingBox(new BoundingBox(0.0D, 0.0D, 0.0D, 0.005D, 1.0E-4D, 1.0E-4D), 255, 0, 0, 255); - RenderGlobal.drawOutlinedBoundingBox(new BoundingBox(0.0D, 0.0D, 0.0D, 1.0E-4D, 1.0E-4D, 0.005D), 0, 0, 255, 255); - RenderGlobal.drawOutlinedBoundingBox(new BoundingBox(0.0D, 0.0D, 0.0D, 1.0E-4D, 0.0033D, 1.0E-4D), 0, 255, 0, 255); - SKC.glPopMatrix(); - GlState.depthMask(true); - GlState.enableTexture2D(); - GlState.disableBlend(); - } - } */ diff --git a/java/src/game/network/NetHandlerPlayClient.java b/java/src/game/network/NetHandlerPlayClient.java index 3721ae9..ba3a1c2 100755 --- a/java/src/game/network/NetHandlerPlayClient.java +++ b/java/src/game/network/NetHandlerPlayClient.java @@ -3,6 +3,7 @@ package game.network; import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.Set; import game.Game; import game.audio.PositionedSound; @@ -1492,14 +1493,14 @@ public class NetHandlerPlayClient extends NetHandler else this.playerList.put(data.getKey(), data.getValue()); } - String[] list = new String[this.playerList.size()]; - int[] data = new int[this.playerList.size()]; - int pos = 0; - for(Entry entry : this.playerList.entrySet()) { - list[pos] = entry.getKey(); - data[pos++] = entry.getValue(); - } - this.gameController.infolist(list, data); +// String[] list = new String[this.playerList.size()]; +// int[] data = new int[this.playerList.size()]; +// int pos = 0; +// for(Entry entry : this.playerList.entrySet()) { +// list[pos] = entry.getKey(); +// data[pos++] = entry.getValue(); +// } +// this.gameController.infolist(list, data); } public void handleKeepAlive(SPacketKeepAlive packetIn) @@ -1849,8 +1850,8 @@ public class NetHandlerPlayClient extends NetHandler return this.netManager; } -// public List> getPlayerList() -// { -// return this.players; -// } + public Set> getPlayerList() + { + return this.playerList.entrySet(); + } } diff --git a/java/src/game/renderer/EntityRenderer.java b/java/src/game/renderer/EntityRenderer.java index 243f9fd..5e3dad1 100755 --- a/java/src/game/renderer/EntityRenderer.java +++ b/java/src/game/renderer/EntityRenderer.java @@ -550,6 +550,20 @@ public class EntityRenderer { d2 = entity.prevZ + (entity.posZ - entity.prevZ) * (double)partialTicks; // this.cloudFog = this.gm.renderGlobal.hasCloudFog(d0, d1, d2, partialTicks); } + + public void rotateCamera(Entity entity, float partialTicks) { + WCF.glRotatef(360.0f - (entity.prevPitch + (entity.rotPitch - entity.prevPitch) * partialTicks), 1.0F, 0.0F, 0.0F); + + if (entity instanceof EntityAnimal) + { + EntityAnimal entityanimal = (EntityAnimal)entity; + WCF.glRotatef(entityanimal.prevHeadYaw + (entityanimal.headYaw - entityanimal.prevHeadYaw) * partialTicks + 180.0F, 0.0F, 1.0F, 0.0F); + } + else + { + WCF.glRotatef(entity.prevYaw + (entity.rotYaw - entity.prevYaw) * partialTicks + 180.0F, 0.0F, 1.0F, 0.0F); + } + } /** * sets up projection, view effects, camera position/rotation