我爲我的世界編碼了一些東西......並且試圖改變某些基於文本的GUI位置......我的問題涉及到更改X位置對於基於關遊戲桂規模文本...我的代碼是:根據不同變量的值修改靜態整數
public int scale = Wrapper.mc.gameSettings.guiScale;
public static int XScale = 865;{
if(scale == 0){
int XScale = 405;
}else if(scale == 1){
int XScale = 1835;
}else if(scale == 2){
int XScale = 865;
}else if(scale == 3){
int XScale = 565;
}
}
我的問題是,無論什麼我的GUI規模,XScale處理器變量似乎並沒有改變,而且它需要靜態,因爲當它不是靜態的單個事物呈現要它是靜態的...所以我讓他們不靜態...然後渲染類想要他們靜態...得到的想法?
---編輯--- 我試過了@AntonH說,無濟於事...結果沒有改變...我應該把它放在一個循環內嗎?新的代碼:
public int scale = Wrapper.mc.gameSettings.guiScale;
public static int XScale = 865;{
if(scale == 0){
GUIIngameHook.XScale = 405;
}else if(scale == 1){
GUIIngameHook.XScale = 1835;
}else if(scale == 2){
GUIIngameHook.XScale = 865;
}else if(scale == 3){
GUIIngameHook.XScale = 565;
}
}
---整個腳本--- 不知道如何幫助這將是...但它應該提供上下文..
package me.zach.frostwave.UI;
public class GUIIngameHook {
public static void StartHud(){
renderClientName();
renderCoords();
renderFPS();
renderMods();
renderArrayList();
renderModLine();
}
public int scale = Wrapper.mc.gameSettings.guiScale;
public static int XScale = 865;{
if(scale == 0){
GUIIngameHook.XScale = 405;
}else if(scale == 1){
GUIIngameHook.XScale = 1835;
}else if(scale == 2){
GUIIngameHook.XScale = 865;
}else if(scale == 3){
GUIIngameHook.XScale = 565;
}
}
public static void renderClientName() {
Wrapper.fr.drawString("Frost Wave [MCV: 1.10, V: 0.05A]", 5, 5, 0x0011FF);
FrostWave.Frostwave.getGuiManager().renderPinned();
FrostWave.Frostwave.getGuiManager().update();
}
public static void renderFPS() {
Wrapper.fr.drawStringWithShadow("[FPS:" + Wrapper.mc.getDebugFPS() + "]", 5, 15, 0x7AA7FF);
FrostWave.Frostwave.getGuiManager().renderPinned();
FrostWave.Frostwave.getGuiManager().update();
}
public static void renderCoords() {
Wrapper.fr.drawStringWithShadow("[Coords: X: " + (int) Wrapper.mc.thePlayer.posX + " Y: " + (int) Wrapper.mc.thePlayer.posY + " Z: " + (int) Wrapper.mc.thePlayer.posZ + "]" , 5, 25, 0x10F0DA);
FrostWave.Frostwave.getGuiManager().renderPinned();
FrostWave.Frostwave.getGuiManager().update();
}
public static void renderMods() {
Wrapper.fr.drawString(" [Active Mods]" , XScale, 5, 0x5A47FF);
FrostWave.Frostwave.getGuiManager().renderPinned();
FrostWave.Frostwave.getGuiManager().update();
}
public static void renderModLine() {
Wrapper.fr.drawString("-------------" , XScale, 11, 0x5A47FF);
FrostWave.Frostwave.getGuiManager().renderPinned();
FrostWave.Frostwave.getGuiManager().update();
}
public static void renderArrayList() {
int yCount = 17;
for(Module m : FrostWave.manager.activeModules){
m.onRender();
if(m.getState() && !m.isCategory(Category.GUI)){
Wrapper.fr.drawString(m.getName(), XScale, yCount, m.getColor());
yCount = yCount + 10;
}
}
}
}
所以你使用的是一個實例初始值設定項。那真的是你想要的嗎? – MeBigFatGuy
你所做的只是聲明新的本地整數併爲它們分配一個值,然後在你離開它的範圍時丟棄本地變量。我會想象你可以做一些像'MyClass.XScale = 405;'等等,等等。 – AntonH
你會不會在我的問題上遇到一些問題? –