我正在为Minecraft编写一些东西...并且我正在尝试根据GUI缩放更改某些文本的位置...我的问题与更改基于游戏的文本的X位置Gui Scale ...我的代码是:
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变量似乎不会改变,它需要是静态的,因为当它不是静态的时候被渲染的个别事物想要它是静态的...所以我让它们不是静态的...然后渲染类想要它们是静态的...获取想法?
--- --- EDIT 我试过了@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;
}
}
}
}
答案 0 :(得分:1)
所以你正在使用实例初始化器。那真的是你想要的吗?鉴于此变量是静态的,似乎是一个错误。也许你想做
static {
if(scale == 0 ){
XScale = 405;
}else if(scale == 1 ){
XScale = 1835;
}else if(scale == 2){
XScale = 865;
}else if(scale == 3){
XScale = 565;
}
}