Merge pull request #32 from c0508383/master

Bug fixes & GUI rotations
This commit is contained in:
Kamron Vaswani authored and GitHub committed 2022-02-02 15:43:23 -05:00
commit 19ccdd60d2
26 files changed
+215 -97

No files matched your search

@@ -78,7 +78,18 @@ public class ClientTickHandler{
boolean isAltPressed = Keyboard.isKeyDown(184) || Keyboard.isKeyDown(56);
boolean isMetaPressed = Keyboard.isKeyDown(220) || Keyboard.isKeyDown(219);
boolean keyDown = Keyboard.isKeyDown(key);
NoppesUtilPlayer.sendData(EnumPlayerPacket.KeyPressed, new Object[]{Integer.valueOf(key), Boolean.valueOf(isCtrlPressed), Boolean.valueOf(isShiftPressed), Boolean.valueOf(isAltPressed), Boolean.valueOf(isMetaPressed), Boolean.valueOf(keyDown)});
StringBuilder keysDownString = new StringBuilder();
for(int i = 0; i < Keyboard.getKeyCount(); i++){//Creates a comma separated string of the integer IDs of held keys
if(Keyboard.isKeyDown(i)){
keysDownString.append(Integer.valueOf(i)).append(",");
}
}
if(keysDownString.length() > 0){//Removes last comma for later parsing
keysDownString.deleteCharAt(keysDownString.length()-1);
}
NoppesUtilPlayer.sendData(EnumPlayerPacket.KeyPressed, new Object[]{Integer.valueOf(key), Boolean.valueOf(isCtrlPressed), Boolean.valueOf(isShiftPressed), Boolean.valueOf(isAltPressed), Boolean.valueOf(isMetaPressed), Boolean.valueOf(keyDown), keysDownString.toString()});
}
}
@@ -40,6 +40,7 @@ public class CustomGuiLabel extends Gui implements IGuiComponent {
int color;
float alpha;
float rotation;
protected int field_146167_a;
protected int field_146161_f;
@@ -144,6 +145,7 @@ public class CustomGuiLabel extends Gui implements IGuiComponent {
lbl.labelShadowEnabled = component.hasShadow();
lbl.color = component.getColor();
lbl.alpha = component.getAlpha();
lbl.rotation = component.getRotation();
return lbl;
}
@@ -154,6 +156,7 @@ public class CustomGuiLabel extends Gui implements IGuiComponent {
component.enableShadow(this.labelShadowEnabled);
component.setColor(this.color);
component.setAlpha(this.alpha);
component.setRotation(this.rotation);
return component;
}
@@ -165,6 +168,7 @@ public class CustomGuiLabel extends Gui implements IGuiComponent {
blue = (color & 255) / 255f;
GL11.glTranslatef(this.x,this.y,0.0F);
GL11.glRotated(rotation,0.0D,0.0D,1.0D);
GL11.glScalef(this.scale, this.scale, this.scale);
this.drawString(fullLabel, 0, 0, this.color, this.labelShadowEnabled);
GL11.glPopMatrix();
@@ -21,14 +21,15 @@ public class CustomGuiLine extends Gui implements IGuiComponent {
int y2;
int color;
float alpha;
float rotation;
int thickness;
public CustomGuiLine(int id, int x1, int y1, int x2, int y2, int color, int thickness){
this.id = id;
this.x1 = GuiCustom.guiLeft + x1;
this.y1 = GuiCustom.guiTop + y1;
this.x2 = GuiCustom.guiLeft + x2;
this.y2 = GuiCustom.guiTop + y2;
this.x1 = x1;
this.y1 = y1;
this.x2 = x2;
this.y2 = y2;
this.color = color;
this.thickness = thickness;
}
@@ -52,8 +53,9 @@ public class CustomGuiLine extends Gui implements IGuiComponent {
float blue = (color & 255) / 255f;
GL11.glColor4f(red,green,blue,this.alpha);
GL11.glTranslatef(this.x1,this.y1,0.0F);
GL11.glTranslatef(GuiCustom.guiLeft+this.x1,GuiCustom.guiTop+this.y1,0.0F);
GL11.glRotated(-Math.toDegrees(Math.atan2(x2-x1,y2-y1)),0.0F,0.0F,1.0F);
GL11.glRotated(rotation,0.0D,0.0D,1.0D);
GL11.glScaled(thickness, distance,0.0D);
this.drawTexturedModalRect(0,0,0,0, 1, 1);
GL11.glPopMatrix();
@@ -63,6 +65,7 @@ public class CustomGuiLine extends Gui implements IGuiComponent {
ScriptGuiLine line = new ScriptGuiLine(this.id, this.x1,this.y1,this.x2,this.y2,this.color,this.thickness);
line.setColor(this.color);
line.setAlpha(this.alpha);
line.setRotation(this.rotation);
return line;
}
@@ -70,6 +73,7 @@ public class CustomGuiLine extends Gui implements IGuiComponent {
CustomGuiLine line = new CustomGuiLine(component.getID(), component.getX1(), component.getY1(), component.getX2(), component.getY2(), component.getColor(), component.getThickness());
line.color = component.getColor();
line.alpha = component.getAlpha();
line.rotation = component.getRotation();
return line;
}
}
@@ -38,6 +38,7 @@ public class CustomGuiTexturedRect extends Gui implements IGuiComponent {
int color;
float alpha;
float rotation;
public CustomGuiTexturedRect(int id, String texture, int x, int y, int width, int height) {
this(id, texture, x, y, width, height, 0, 0);
@@ -47,8 +48,8 @@ public class CustomGuiTexturedRect extends Gui implements IGuiComponent {
this.scale = 1.0F;
this.id = id;
this.texture = new ResourceLocation(texture);
this.x = GuiCustom.guiLeft + x;
this.y = GuiCustom.guiTop + y;
this.x = x;
this.y = y;
this.width = width;
this.height = height;
this.textureX = textureX;
@@ -80,7 +81,28 @@ public class CustomGuiTexturedRect extends Gui implements IGuiComponent {
GL11.glColor4f(red,green,blue,this.alpha);
GL11.glScalef(this.scale, this.scale, this.scale);
this.drawTexturedModalRect((int) (this.x/this.scale), (int) (this.y/this.scale), this.textureX, this.textureY, (int)(this.width), (int)(this.height));
GL11.glTranslatef(GuiCustom.guiLeft,GuiCustom.guiTop,0.0F);
GL11.glRotatef(this.rotation,0.0F,0.0F,1.0F);
int p_73729_1_ = (int) (this.x/this.scale);
int p_73729_2_ = (int) (this.y/this.scale);
int p_73729_3_ = this.textureX;
int p_73729_4_ = this.textureY;
int p_73729_5_ = (int)(this.width);
int p_73729_6_ = (int)(this.height);
float f = 0.00390625F;
float f1 = 0.00390625F;
Tessellator tessellator = Tessellator.instance;
tessellator.startDrawingQuads();
tessellator.setColorOpaque_F(1, 1, 1);
tessellator.setColorRGBA_F(red, green, blue, alpha);
tessellator.addVertexWithUV((double)(p_73729_1_ + 0), (double)(p_73729_2_ + p_73729_6_), (double)this.zLevel, (double)((float)(p_73729_3_ + 0) * f), (double)((float)(p_73729_4_ + p_73729_6_) * f1));
tessellator.addVertexWithUV((double)(p_73729_1_ + p_73729_5_), (double)(p_73729_2_ + p_73729_6_), (double)this.zLevel, (double)((float)(p_73729_3_ + p_73729_5_) * f), (double)((float)(p_73729_4_ + p_73729_6_) * f1));
tessellator.addVertexWithUV((double)(p_73729_1_ + p_73729_5_), (double)(p_73729_2_ + 0), (double)this.zLevel, (double)((float)(p_73729_3_ + p_73729_5_) * f), (double)((float)(p_73729_4_ + 0) * f1));
tessellator.addVertexWithUV((double)(p_73729_1_ + 0), (double)(p_73729_2_ + 0), (double)this.zLevel, (double)((float)(p_73729_3_ + 0) * f), (double)((float)(p_73729_4_ + 0) * f1));
tessellator.draw();
GL11.glPopMatrix();
if (hovered && this.hoverText != null && this.hoverText.length > 0) {
@@ -94,6 +116,7 @@ public class CustomGuiTexturedRect extends Gui implements IGuiComponent {
component.setScale(this.scale);
component.setColor(color);
component.setAlpha(alpha);
component.setRotation(rotation);
return component;
}
@@ -112,6 +135,7 @@ public class CustomGuiTexturedRect extends Gui implements IGuiComponent {
rect.color = component.getColor();
rect.alpha = component.getAlpha();
rect.rotation = component.getRotation();
return rect;
}
@@ -4,12 +4,9 @@ import com.ibm.icu.text.ArabicShaping;
import com.ibm.icu.text.ArabicShapingException;
import com.ibm.icu.text.Bidi;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.util.ResourceLocation;
import noppes.npcs.client.gui.custom.GuiCustom;
import noppes.npcs.client.gui.customoverlay.OverlayCustom;
import noppes.npcs.client.gui.customoverlay.interfaces.IOverlayComponent;
import noppes.npcs.scripted.interfaces.ICustomOverlayComponent;
@@ -20,10 +17,6 @@ import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import static org.lwjgl.opengl.GL11.GL_ONE_MINUS_SRC_ALPHA;
import static org.lwjgl.opengl.GL11.GL_SRC_ALPHA;
public class CustomOverlayLabel extends Gui implements IOverlayComponent {
OverlayCustom parent;
@@ -141,7 +141,7 @@ public class GuiNpcAI extends GuiNPCInterface2 implements ITextfieldListener, IG
}
else if (button.id == 17) {
ai.tacticalVariant = EnumNavType.values()[button.getValue()];
ai.directLOS = EnumNavType.values()[button.getValue()] == EnumNavType.Stalk ? false : this.ai.directLOS;
ai.directLOS = EnumNavType.values()[button.getValue()] != EnumNavType.Stalk && this.ai.directLOS;
initGui();
}
else if (button.id == 22) {