mirror of
https://git.webmc.xyz/Starlike-Client/Starlike-Client
synced 2025-06-05 18:32:01 -09:00
compass
This commit is contained in:
parent
ff4d2a7e91
commit
a2073df120
Binary file not shown.
After Width: | Height: | Size: 10 KiB |
@ -20,12 +20,17 @@ import net.lax1dude.eaglercraft.v1_8.Touch;
|
||||
import net.lax1dude.eaglercraft.v1_8.minecraft.EaglerTextureAtlasSprite;
|
||||
import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager;
|
||||
import net.lax1dude.eaglercraft.v1_8.opengl.OpenGlHelper;
|
||||
import net.lax1dude.eaglercraft.v1_8.opengl.RealOpenGLEnums;
|
||||
import net.lax1dude.eaglercraft.v1_8.opengl.WorldRenderer;
|
||||
import net.lax1dude.eaglercraft.v1_8.touch_gui.TouchControls;
|
||||
import net.lax1dude.eaglercraft.v1_8.touch_gui.TouchOverlayRenderer;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.client.gui.inventory.GuiInventory;
|
||||
import net.minecraft.client.multiplayer.WorldClient;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
@ -58,6 +63,7 @@ import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.MovingObjectPosition.MovingObjectType;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StringUtils;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import net.minecraft.world.border.WorldBorder;
|
||||
import net.starlikeclient.StarlikeClient;
|
||||
|
||||
@ -88,6 +94,8 @@ public class GuiIngame extends Gui {
|
||||
private static final ResourceLocation vignetteTexPath = new ResourceLocation("textures/misc/vignette.png");
|
||||
private static final ResourceLocation widgetsTexPath = new ResourceLocation("textures/gui/widgets.png");
|
||||
private static final ResourceLocation pumpkinBlurTexPath = new ResourceLocation("textures/misc/pumpkinblur.png");
|
||||
private static final ResourceLocation compass_needle = new ResourceLocation("starlike:textures/gui/compass_needle.png");
|
||||
|
||||
private final EaglercraftRandom rand = new EaglercraftRandom();
|
||||
private final Minecraft mc;
|
||||
private final RenderItem itemRenderer;
|
||||
@ -102,6 +110,8 @@ public class GuiIngame extends Gui {
|
||||
/**
|
||||
* + Previous frame vignette brightness (slowly changes by 1% each frame)
|
||||
*/
|
||||
|
||||
private final int minimapSize = 80;
|
||||
public float prevVignetteBrightness = 1.0F;
|
||||
private int remainingHighlightTicks;
|
||||
private ItemStack highlightingItemStack;
|
||||
@ -620,7 +630,7 @@ public class GuiIngame extends Gui {
|
||||
} else if (this.mc.playerController.gameIsSurvivalOrAdventure()) {
|
||||
this.renderExpBar(scaledresolution, k1);
|
||||
}
|
||||
|
||||
renderCompass();
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GlStateManager.disableBlend();
|
||||
if (this.mc.gameSettings.heldItemTooltips && !this.mc.playerController.isSpectator()) {
|
||||
@ -1316,4 +1326,62 @@ public class GuiIngame extends Gui {
|
||||
hotbarSlotTouchAlreadySelected = false;
|
||||
}
|
||||
|
||||
private void renderCompass() {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
EntityPlayer player = mc.thePlayer;
|
||||
if (player == null) return;
|
||||
|
||||
ScaledResolution sr = new ScaledResolution(mc);
|
||||
int screenWidth = sr.getScaledWidth();
|
||||
int screenHeight = sr.getScaledHeight();
|
||||
|
||||
float yaw = player.rotationYaw % 360;
|
||||
if (yaw < 0) yaw += 360;
|
||||
|
||||
int compassSize = 40;
|
||||
|
||||
// Calculate the position based on the screen dimensions and the compass size
|
||||
int x = screenWidth - compassSize - 10; // 10px from the right edge
|
||||
int y = screenHeight - compassSize - 10; // 10px from the bottom edge
|
||||
|
||||
// Draw the background rectangle for the compass
|
||||
drawRect(x, y, x + compassSize, y + compassSize, 0x80000000);
|
||||
|
||||
// Calculate the center position of the compass
|
||||
int centerX = x + compassSize / 2;
|
||||
int centerY = y + compassSize / 2;
|
||||
|
||||
// Draw the cardinal directions at their correct positions
|
||||
mc.fontRendererObj.drawStringWithShadow("N", centerX - 3, y + 2, 0xFFFFFF);
|
||||
mc.fontRendererObj.drawStringWithShadow("S", centerX - 3, y + compassSize - 10, 0xFFFFFF);
|
||||
mc.fontRendererObj.drawStringWithShadow("E", x + compassSize - 10, centerY - 3, 0xFFFFFF);
|
||||
mc.fontRendererObj.drawStringWithShadow("W", x + 2, centerY - 3, 0xFFFFFF);
|
||||
|
||||
// Draw the rotating needle
|
||||
drawRotatingNeedle(centerX, centerY, yaw, compassSize);
|
||||
}
|
||||
private void drawRotatingNeedle(int x, int y, float angle, int compassSize) {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
mc.getTextureManager().bindTexture(compass_needle);
|
||||
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.pushMatrix();
|
||||
|
||||
// Move to the center of the compass
|
||||
GlStateManager.translate(x, y, 0);
|
||||
|
||||
// Adjust yaw to correctly rotate the needle: OpenGL rotates clockwise, Minecraft counterclockwise
|
||||
GlStateManager.rotate(angle, 0, 0, 1); // Rotate by the player's yaw (in reverse direction)
|
||||
|
||||
// Calculate the needle size and adjust the drawing position
|
||||
int needleSize = 20; // Adjust for image size
|
||||
int offsetX = -needleSize / 2;
|
||||
int offsetY = -needleSize / 2;
|
||||
|
||||
// Draw the needle at the correct position
|
||||
drawModalRectWithCustomSizedTexture(offsetX, offsetY, 0, 0, needleSize, needleSize, needleSize, needleSize);
|
||||
|
||||
GlStateManager.popMatrix();
|
||||
GlStateManager.disableBlend();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user