2018-09-13 12:03:28 -04:00
|
|
|
package noppes.npcs.client.gui.util;
|
|
|
|
|
|
|
|
|
|
import net.minecraft.client.Minecraft;
|
|
|
|
|
import net.minecraft.client.entity.EntityClientPlayerMP;
|
|
|
|
|
import net.minecraft.client.gui.FontRenderer;
|
|
|
|
|
import net.minecraft.client.gui.GuiButton;
|
|
|
|
|
import net.minecraft.client.gui.GuiScreen;
|
|
|
|
|
import net.minecraft.client.renderer.OpenGlHelper;
|
|
|
|
|
import net.minecraft.client.renderer.RenderHelper;
|
|
|
|
|
import net.minecraft.client.renderer.entity.RenderManager;
|
2024-03-13 17:19:13 -04:00
|
|
|
import net.minecraft.entity.EntityLivingBase;
|
2018-09-13 12:03:28 -04:00
|
|
|
import net.minecraft.util.ResourceLocation;
|
2024-02-18 03:02:02 -06:00
|
|
|
import net.minecraft.util.StatCollector;
|
|
|
|
|
import noppes.npcs.client.CustomNpcResourceListener;
|
|
|
|
|
import noppes.npcs.client.TextBlockClient;
|
2018-09-13 12:03:28 -04:00
|
|
|
import noppes.npcs.entity.EntityNPCInterface;
|
|
|
|
|
import org.lwjgl.input.Keyboard;
|
|
|
|
|
import org.lwjgl.input.Mouse;
|
|
|
|
|
import org.lwjgl.opengl.GL11;
|
|
|
|
|
import org.lwjgl.opengl.GL12;
|
|
|
|
|
|
2023-01-12 21:33:06 -05:00
|
|
|
import java.net.URI;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
|
2024-08-06 21:46:07 +03:00
|
|
|
public abstract class GuiNPCInterface extends GuiScreen {
|
|
|
|
|
public EntityClientPlayerMP player;
|
|
|
|
|
public boolean drawDefaultBackground = true;
|
|
|
|
|
public EntityNPCInterface npc;
|
|
|
|
|
protected HashMap<Integer, GuiNpcButton> buttons = new HashMap<Integer, GuiNpcButton>();
|
|
|
|
|
protected HashMap<Integer, GuiMenuTopButton> topbuttons = new HashMap<Integer, GuiMenuTopButton>();
|
|
|
|
|
protected HashMap<Integer, GuiMenuSideButton> sidebuttons = new HashMap<Integer, GuiMenuSideButton>();
|
|
|
|
|
protected HashMap<Integer, GuiNpcTextField> textfields = new HashMap<Integer, GuiNpcTextField>();
|
|
|
|
|
protected HashMap<Integer, GuiNpcLabel> labels = new HashMap<Integer, GuiNpcLabel>();
|
|
|
|
|
protected HashMap<Integer, GuiCustomScroll> scrolls = new HashMap<Integer, GuiCustomScroll>();
|
|
|
|
|
protected HashMap<Integer, GuiNpcSlider> sliders = new HashMap<Integer, GuiNpcSlider>();
|
|
|
|
|
protected HashMap<Integer, GuiScreen> extra = new HashMap<Integer, GuiScreen>();
|
2024-05-22 18:38:26 -04:00
|
|
|
protected HashMap<Integer, GuiScrollWindow> scrollWindows = new HashMap<>();
|
2024-05-19 02:27:03 +02:00
|
|
|
|
2025-02-03 01:47:47 -05:00
|
|
|
public static boolean resizingActive = false;
|
|
|
|
|
|
2024-08-06 21:46:07 +03:00
|
|
|
public String title;
|
|
|
|
|
private ResourceLocation background = null;
|
|
|
|
|
public boolean closeOnEsc = false;
|
|
|
|
|
public int guiLeft, guiTop, xSize, ySize;
|
|
|
|
|
private SubGuiInterface subgui;
|
|
|
|
|
public int mouseX, mouseY, mouseScroll;
|
|
|
|
|
public float bgScale = 1;
|
|
|
|
|
public float bgScaleX = 1;
|
|
|
|
|
public float bgScaleY = 1;
|
|
|
|
|
public float bgScaleZ = 1;
|
|
|
|
|
public long timeClosedSubGui;
|
|
|
|
|
|
|
|
|
|
public GuiNPCInterface(EntityNPCInterface npc) {
|
|
|
|
|
this.player = Minecraft.getMinecraft().thePlayer;
|
|
|
|
|
this.npc = npc;
|
|
|
|
|
title = "";
|
|
|
|
|
xSize = 200;
|
|
|
|
|
ySize = 222;
|
2018-09-13 12:03:28 -04:00
|
|
|
}
|
2024-08-06 21:46:07 +03:00
|
|
|
|
|
|
|
|
public GuiNPCInterface() {
|
|
|
|
|
this(null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setBackground(String texture) {
|
|
|
|
|
background = new ResourceLocation("customnpcs", "textures/gui/" + texture);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ResourceLocation getResource(String texture) {
|
|
|
|
|
return new ResourceLocation("customnpcs", "textures/gui/" + texture);
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-13 12:03:28 -04:00
|
|
|
@Override
|
2024-08-06 21:46:07 +03:00
|
|
|
public void initGui() {
|
|
|
|
|
super.initGui();
|
|
|
|
|
GuiNpcTextField.unfocus();
|
|
|
|
|
if (subgui != null) {
|
|
|
|
|
subgui.setWorldAndResolution(mc, width, height);
|
|
|
|
|
subgui.initGui();
|
|
|
|
|
}
|
|
|
|
|
guiLeft = (width - xSize) / 2;
|
2018-09-13 12:03:28 -04:00
|
|
|
guiTop = (height - ySize) / 2;
|
|
|
|
|
buttonList.clear();
|
|
|
|
|
labels.clear();
|
|
|
|
|
textfields.clear();
|
|
|
|
|
buttons.clear();
|
|
|
|
|
sidebuttons.clear();
|
|
|
|
|
topbuttons.clear();
|
|
|
|
|
scrolls.clear();
|
|
|
|
|
sliders.clear();
|
2024-05-22 18:38:26 -04:00
|
|
|
scrollWindows.clear();
|
2018-09-13 12:03:28 -04:00
|
|
|
Keyboard.enableRepeatEvents(true);
|
|
|
|
|
}
|
2024-08-06 21:46:07 +03:00
|
|
|
|
2018-09-13 12:03:28 -04:00
|
|
|
@Override
|
2024-08-06 21:46:07 +03:00
|
|
|
public void updateScreen() {
|
|
|
|
|
if (subgui != null)
|
|
|
|
|
subgui.updateScreen();
|
|
|
|
|
else {
|
|
|
|
|
for (GuiNpcTextField tf : textfields.values()) {
|
|
|
|
|
if (tf.enabled)
|
|
|
|
|
tf.updateCursorCounter();
|
|
|
|
|
}
|
|
|
|
|
super.updateScreen();
|
|
|
|
|
}
|
2018-09-13 12:03:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2024-08-06 21:46:07 +03:00
|
|
|
public void addExtra(GuiHoverText gui) {
|
|
|
|
|
gui.setWorldAndResolution(mc, 350, 250);
|
|
|
|
|
extra.put(gui.id, gui);
|
|
|
|
|
}
|
2022-01-27 05:40:51 -06:00
|
|
|
|
2024-08-06 21:46:07 +03:00
|
|
|
public void addScrollableGui(int id, GuiScrollWindow gui) {
|
2024-05-19 02:27:03 +02:00
|
|
|
gui.setWorldAndResolution(mc, width, height);
|
2024-05-19 02:31:37 +02:00
|
|
|
gui.initGui();
|
2024-05-22 18:38:26 -04:00
|
|
|
scrollWindows.put(id, gui);
|
2024-05-19 02:27:03 +02:00
|
|
|
}
|
|
|
|
|
|
2024-08-06 21:46:07 +03:00
|
|
|
public void mouseClicked(int i, int j, int k) {
|
|
|
|
|
if (subgui != null)
|
|
|
|
|
subgui.mouseClicked(i, j, k);
|
|
|
|
|
else {
|
|
|
|
|
for (GuiNpcTextField tf : new ArrayList<GuiNpcTextField>(textfields.values()))
|
|
|
|
|
if (tf.enabled)
|
|
|
|
|
tf.mouseClicked(i, j, k);
|
2024-05-19 02:27:03 +02:00
|
|
|
|
2024-08-06 21:46:07 +03:00
|
|
|
for (GuiScrollWindow guiScrollableComponent : scrollWindows.values()) {
|
|
|
|
|
if (guiScrollableComponent.isMouseOver(i, j))
|
2024-05-21 02:16:25 +02:00
|
|
|
guiScrollableComponent.mouseClicked(i, j, k);
|
2024-05-19 02:27:03 +02:00
|
|
|
}
|
|
|
|
|
|
2024-08-06 21:46:07 +03:00
|
|
|
if (k == 0) {
|
|
|
|
|
for (GuiCustomScroll scroll : new ArrayList<GuiCustomScroll>(scrolls.values())) {
|
|
|
|
|
scroll.mouseClicked(i, j, k);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
mouseEvent(i, j, k);
|
|
|
|
|
super.mouseClicked(i, j, k);
|
|
|
|
|
}
|
2018-09-13 12:03:28 -04:00
|
|
|
}
|
|
|
|
|
|
2024-08-06 21:46:07 +03:00
|
|
|
public void mouseEvent(int i, int j, int k){}
|
2018-09-13 12:03:28 -04:00
|
|
|
|
|
|
|
|
@Override
|
2024-08-06 21:46:07 +03:00
|
|
|
protected void actionPerformed(GuiButton guibutton) {
|
|
|
|
|
if (subgui != null)
|
|
|
|
|
subgui.buttonEvent(guibutton);
|
|
|
|
|
else {
|
|
|
|
|
buttonEvent(guibutton);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void buttonEvent(GuiButton guibutton){}
|
2018-09-13 12:03:28 -04:00
|
|
|
|
|
|
|
|
@Override
|
2024-08-06 21:46:07 +03:00
|
|
|
public void keyTyped(char c, int i) {
|
|
|
|
|
if (subgui != null)
|
|
|
|
|
subgui.keyTyped(c, i);
|
|
|
|
|
for (GuiNpcTextField tf : textfields.values())
|
|
|
|
|
tf.textboxKeyTyped(c, i);
|
2018-09-13 12:03:28 -04:00
|
|
|
|
2024-08-06 21:46:07 +03:00
|
|
|
for (GuiScrollWindow guiScrollableComponent : scrollWindows.values()) {
|
2024-05-22 18:38:26 -04:00
|
|
|
guiScrollableComponent.keyTyped(c, i);
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-06 21:46:07 +03:00
|
|
|
//Fixes closing sub with escape closes all of it's parents
|
|
|
|
|
boolean enoughTimeSinceSubClosed = Minecraft.getSystemTime() - timeClosedSubGui > 50;
|
|
|
|
|
|
|
|
|
|
if (closeOnEsc && enoughTimeSinceSubClosed && (i == 1 || !GuiNpcTextField.isFieldActive() && isInventoryKey(i))) {
|
|
|
|
|
close();
|
2018-09-13 12:03:28 -04:00
|
|
|
}
|
|
|
|
|
}
|
2024-08-06 21:46:07 +03:00
|
|
|
|
|
|
|
|
public void onGuiClosed() {
|
|
|
|
|
GuiNpcTextField.unfocus();
|
2018-09-13 12:03:28 -04:00
|
|
|
}
|
2024-08-06 21:46:07 +03:00
|
|
|
|
|
|
|
|
public void close() {
|
|
|
|
|
Keyboard.enableRepeatEvents(false);
|
2018-09-13 12:03:28 -04:00
|
|
|
displayGuiScreen(null);
|
|
|
|
|
mc.setIngameFocus();
|
|
|
|
|
save();
|
|
|
|
|
}
|
2024-08-06 21:46:07 +03:00
|
|
|
|
|
|
|
|
public void addButton(GuiNpcButton button) {
|
|
|
|
|
buttons.put(button.id, button);
|
|
|
|
|
buttonList.add(button);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void addTopButton(GuiMenuTopButton button) {
|
|
|
|
|
topbuttons.put(button.id, button);
|
|
|
|
|
buttonList.add(button);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void addSideButton(GuiMenuSideButton button) {
|
|
|
|
|
sidebuttons.put(button.id, button);
|
|
|
|
|
buttonList.add(button);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public GuiNpcButton getButton(int i) {
|
|
|
|
|
return buttons.get(i);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public GuiMenuSideButton getSideButton(int i) {
|
|
|
|
|
return sidebuttons.get(i);
|
2018-09-13 12:03:28 -04:00
|
|
|
}
|
2024-08-06 21:46:07 +03:00
|
|
|
|
|
|
|
|
public GuiMenuTopButton getTopButton(int i) {
|
|
|
|
|
return topbuttons.get(i);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void addTextField(GuiNpcTextField tf) {
|
|
|
|
|
textfields.put(tf.id, tf);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public GuiNpcTextField getTextField(int i) {
|
|
|
|
|
return textfields.get(i);
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-13 12:03:28 -04:00
|
|
|
public void addLabel(GuiNpcLabel label) {
|
2024-08-06 21:46:07 +03:00
|
|
|
labels.put(label.id, label);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public GuiNpcLabel getLabel(int i) {
|
|
|
|
|
return labels.get(i);
|
2018-09-13 12:03:28 -04:00
|
|
|
}
|
|
|
|
|
|
2024-05-22 18:38:26 -04:00
|
|
|
public GuiScrollWindow getScrollableGui(int i) {
|
|
|
|
|
return scrollWindows.get(i);
|
2024-05-19 02:27:03 +02:00
|
|
|
}
|
|
|
|
|
|
2024-08-06 21:46:07 +03:00
|
|
|
public void addSlider(GuiNpcSlider slider) {
|
|
|
|
|
sliders.put(slider.id, slider);
|
|
|
|
|
buttonList.add(slider);
|
2018-09-13 12:03:28 -04:00
|
|
|
}
|
2024-08-06 21:46:07 +03:00
|
|
|
|
|
|
|
|
public GuiNpcSlider getSlider(int i) {
|
|
|
|
|
return sliders.get(i);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void addScroll(GuiCustomScroll scroll) {
|
2018-09-13 12:03:28 -04:00
|
|
|
scroll.setWorldAndResolution(mc, 350, 250);
|
|
|
|
|
scrolls.put(scroll.id, scroll);
|
2024-08-06 21:46:07 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public GuiCustomScroll getScroll(int id) {
|
|
|
|
|
return scrolls.get(id);
|
|
|
|
|
}
|
2022-01-27 05:40:51 -06:00
|
|
|
|
2018-09-13 12:03:28 -04:00
|
|
|
public abstract void save();
|
2022-01-27 05:40:51 -06:00
|
|
|
|
2018-09-13 12:03:28 -04:00
|
|
|
@Override
|
2024-08-06 21:46:07 +03:00
|
|
|
public void drawScreen(int i, int j, float f) {
|
|
|
|
|
mouseX = i;
|
|
|
|
|
mouseY = j;
|
|
|
|
|
if (drawDefaultBackground && subgui == null)
|
|
|
|
|
drawDefaultBackground();
|
|
|
|
|
|
|
|
|
|
if (background != null && mc.renderEngine != null) {
|
|
|
|
|
drawBackground();
|
|
|
|
|
}
|
2024-02-15 17:49:48 -05:00
|
|
|
|
2024-03-13 18:40:40 -04:00
|
|
|
boolean subGui = hasSubGui();
|
2018-09-13 12:03:28 -04:00
|
|
|
drawCenteredString(fontRendererObj, title, width / 2, guiTop + 4, 0xffffff);
|
2024-08-06 21:46:07 +03:00
|
|
|
for (GuiNpcLabel label : labels.values())
|
|
|
|
|
label.drawLabel(this, fontRendererObj);
|
|
|
|
|
for (GuiNpcTextField tf : textfields.values()) {
|
|
|
|
|
tf.drawTextBox(i, j);
|
|
|
|
|
}
|
|
|
|
|
for (GuiCustomScroll scroll : scrolls.values()) {
|
2024-03-13 18:40:40 -04:00
|
|
|
scroll.updateSubGUI(subGui);
|
2024-08-06 21:46:07 +03:00
|
|
|
scroll.drawScreen(i, j, f, !subGui && scroll.isMouseOver(i, j) ? Mouse.getDWheel() : 0);
|
2024-03-13 18:40:40 -04:00
|
|
|
}
|
2024-08-06 21:46:07 +03:00
|
|
|
for (GuiScreen gui : extra.values())
|
|
|
|
|
gui.drawScreen(i, j, f);
|
2018-09-13 12:03:28 -04:00
|
|
|
super.drawScreen(i, j, f);
|
2024-08-06 21:46:07 +03:00
|
|
|
for (GuiCustomScroll scroll : scrolls.values())
|
|
|
|
|
if (scroll.hoverableText) {
|
|
|
|
|
scroll.drawHover(i, j);
|
|
|
|
|
}
|
|
|
|
|
for (GuiNpcButton button : buttons.values()) {
|
2024-03-13 18:40:40 -04:00
|
|
|
button.updateSubGUI(subGui);
|
2024-08-06 21:46:07 +03:00
|
|
|
if (!button.hoverableText.isEmpty()) {
|
2024-03-13 18:40:40 -04:00
|
|
|
button.drawHover(i, j, subGui);
|
2024-02-29 20:34:49 -05:00
|
|
|
}
|
2024-03-13 17:19:13 -04:00
|
|
|
}
|
2024-08-06 21:46:07 +03:00
|
|
|
for (GuiScrollWindow guiScrollableComponent : scrollWindows.values()) {
|
|
|
|
|
guiScrollableComponent.drawScreen(i, j, f, !subGui && guiScrollableComponent.isMouseOver(i, j) ? Mouse.getDWheel() : 0);
|
2024-05-19 02:27:03 +02:00
|
|
|
}
|
2024-03-13 17:19:13 -04:00
|
|
|
|
2024-08-06 21:46:07 +03:00
|
|
|
if (subgui != null) {
|
|
|
|
|
subgui.drawScreen(i, j, f);
|
2024-05-26 17:03:19 -04:00
|
|
|
}
|
2018-09-13 12:03:28 -04:00
|
|
|
}
|
2023-11-08 11:58:55 -06:00
|
|
|
|
2024-08-06 21:46:07 +03:00
|
|
|
protected void drawBackground() {
|
|
|
|
|
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
|
|
|
|
GL11.glPushMatrix();
|
|
|
|
|
GL11.glTranslatef(guiLeft, guiTop, 0);
|
|
|
|
|
GL11.glScalef(bgScale * bgScaleX, bgScale * bgScaleY, bgScale * bgScaleZ);
|
|
|
|
|
mc.renderEngine.bindTexture(background);
|
|
|
|
|
if (xSize > 256) {
|
|
|
|
|
drawTexturedModalRect(0, 0, 0, 0, 250, ySize);
|
|
|
|
|
drawTexturedModalRect(250, 0, 256 - (xSize - 250), 0, xSize - 250, ySize);
|
|
|
|
|
} else
|
|
|
|
|
drawTexturedModalRect(0, 0, 0, 0, xSize, ySize);
|
|
|
|
|
GL11.glPopMatrix();
|
|
|
|
|
}
|
2023-11-08 11:58:55 -06:00
|
|
|
|
2024-02-18 03:02:02 -06:00
|
|
|
protected void drawTextBlock(String text, int x, int y, int lineWidth) {
|
|
|
|
|
TextBlockClient block = new TextBlockClient(StatCollector.translateToLocal(text), lineWidth, true, player);
|
2024-08-06 21:46:07 +03:00
|
|
|
for (int line = 0; line < block.lines.size(); line++) {
|
2024-02-18 03:02:02 -06:00
|
|
|
String lineText = block.lines.get(line).getFormattedText();
|
|
|
|
|
fontRendererObj.drawString(lineText, x, y + (line * fontRendererObj.FONT_HEIGHT), CustomNpcResourceListener.DefaultTextColor);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-06 21:46:07 +03:00
|
|
|
public FontRenderer getFontRenderer() {
|
|
|
|
|
return this.fontRendererObj;
|
|
|
|
|
}
|
2024-02-15 17:49:48 -05:00
|
|
|
|
2024-08-06 21:46:07 +03:00
|
|
|
public void elementClicked() {
|
|
|
|
|
if (subgui != null)
|
|
|
|
|
subgui.elementClicked();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean doesGuiPauseGame() {
|
2018-09-13 12:03:28 -04:00
|
|
|
return false;
|
|
|
|
|
}
|
2024-02-15 17:49:48 -05:00
|
|
|
|
2024-08-06 21:46:07 +03:00
|
|
|
public void doubleClicked() {
|
|
|
|
|
}
|
2024-02-15 17:49:48 -05:00
|
|
|
|
2024-08-06 21:46:07 +03:00
|
|
|
public boolean isInventoryKey(int i) {
|
2018-09-13 12:03:28 -04:00
|
|
|
return i == mc.gameSettings.keyBindInventory.getKeyCode(); //inventory key
|
2024-08-06 21:46:07 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void drawDefaultBackground() {
|
|
|
|
|
super.drawDefaultBackground();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void displayGuiScreen(GuiScreen gui) {
|
|
|
|
|
mc.displayGuiScreen(gui);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setSubGui(SubGuiInterface gui) {
|
|
|
|
|
subgui = gui;
|
|
|
|
|
subgui.setWorldAndResolution(mc, width, height);
|
|
|
|
|
subgui.parent = this;
|
|
|
|
|
initGui();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void closeSubGui(SubGuiInterface gui) {
|
|
|
|
|
subgui = null;
|
|
|
|
|
timeClosedSubGui = Minecraft.getSystemTime();
|
|
|
|
|
initGui();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean hasSubGui() {
|
|
|
|
|
return subgui != null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public SubGuiInterface getSubGui() {
|
|
|
|
|
if (hasSubGui() && subgui.hasSubGui())
|
|
|
|
|
return subgui.getSubGui();
|
|
|
|
|
return subgui;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void drawNpc(int x, int y) {
|
2024-03-13 17:19:13 -04:00
|
|
|
drawNpc(npc, x, y, 1, 0);
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-06 21:46:07 +03:00
|
|
|
public void drawNpc(EntityLivingBase entity, int x, int y, float zoomed, int rotation) {
|
2024-03-13 17:19:13 -04:00
|
|
|
EntityNPCInterface npc = null;
|
2024-08-06 21:46:07 +03:00
|
|
|
if (entity instanceof EntityNPCInterface)
|
2024-03-13 17:19:13 -04:00
|
|
|
npc = (EntityNPCInterface) entity;
|
|
|
|
|
|
2024-08-06 21:46:07 +03:00
|
|
|
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
|
|
|
|
if (npc != null)
|
2024-03-13 17:19:13 -04:00
|
|
|
npc.isDrawn = true;
|
2024-08-06 21:46:07 +03:00
|
|
|
GL11.glEnable(GL11.GL_COLOR_MATERIAL);
|
|
|
|
|
GL11.glPushMatrix();
|
|
|
|
|
GL11.glTranslatef(guiLeft + x, guiTop + y, 50F);
|
2018-09-13 12:03:28 -04:00
|
|
|
float scale = 1;
|
2024-08-06 21:46:07 +03:00
|
|
|
if (entity.height > 2.4)
|
|
|
|
|
scale = 2 / npc.height;
|
2024-02-15 17:49:48 -05:00
|
|
|
|
2024-03-13 17:19:13 -04:00
|
|
|
GL11.glScalef(-30 * scale * zoomed, 30 * scale * zoomed, 30 * scale * zoomed);
|
2024-08-06 21:46:07 +03:00
|
|
|
GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
|
2024-02-15 17:49:48 -05:00
|
|
|
|
2024-08-06 21:46:07 +03:00
|
|
|
float f2 = entity.renderYawOffset;
|
|
|
|
|
float f3 = entity.rotationYaw;
|
|
|
|
|
float f4 = entity.rotationPitch;
|
|
|
|
|
float f7 = entity.rotationYawHead;
|
|
|
|
|
float f5 = (float) (guiLeft + x) - mouseX;
|
2024-03-13 17:19:13 -04:00
|
|
|
float f6 = (float) ((guiTop + y) - 50 * scale * zoomed) - mouseY;
|
|
|
|
|
int orientation = 0;
|
2024-08-06 21:46:07 +03:00
|
|
|
if (npc != null) {
|
2024-03-13 17:19:13 -04:00
|
|
|
orientation = npc.ai.orientation;
|
|
|
|
|
npc.ai.orientation = rotation;
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-06 21:46:07 +03:00
|
|
|
GL11.glRotatef(135F, 0.0F, 1.0F, 0.0F);
|
|
|
|
|
RenderHelper.enableStandardItemLighting();
|
|
|
|
|
GL11.glRotatef(-135F, 0.0F, 1.0F, 0.0F);
|
|
|
|
|
GL11.glRotatef(-(float) Math.atan(f6 / 40F) * 20F, 1.0F, 0.0F, 0.0F);
|
2024-03-13 17:19:13 -04:00
|
|
|
entity.renderYawOffset = rotation;
|
2024-08-06 21:46:07 +03:00
|
|
|
entity.rotationYaw = (float) Math.atan(f5 / 80F) * 40F + rotation;
|
2024-03-13 17:19:13 -04:00
|
|
|
entity.rotationPitch = -(float) Math.atan(f6 / 40F) * 20F;
|
|
|
|
|
entity.rotationYawHead = entity.rotationYaw;
|
2024-08-06 21:46:07 +03:00
|
|
|
GL11.glTranslatef(0.0F, entity.yOffset, 0.0F);
|
|
|
|
|
RenderManager.instance.playerViewY = 180F;
|
|
|
|
|
RenderManager.instance.renderEntityWithPosYaw(entity, 0, 0, 0, 0, 1);
|
2024-03-13 17:19:13 -04:00
|
|
|
entity.prevRenderYawOffset = entity.renderYawOffset = f2;
|
|
|
|
|
entity.prevRotationYaw = entity.rotationYaw = f3;
|
|
|
|
|
entity.prevRotationPitch = entity.rotationPitch = f4;
|
|
|
|
|
entity.prevRotationYawHead = entity.rotationYawHead = f7;
|
2024-08-06 21:46:07 +03:00
|
|
|
if (npc != null) {
|
2024-03-13 17:19:13 -04:00
|
|
|
npc.ai.orientation = orientation;
|
|
|
|
|
}
|
2024-08-06 21:46:07 +03:00
|
|
|
GL11.glPopMatrix();
|
|
|
|
|
RenderHelper.disableStandardItemLighting();
|
|
|
|
|
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
|
|
|
|
|
if (npc != null)
|
2024-03-13 17:19:13 -04:00
|
|
|
npc.isDrawn = false;
|
2024-08-06 21:46:07 +03:00
|
|
|
OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit);
|
|
|
|
|
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
|
|
|
|
OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit);
|
|
|
|
|
}
|
2024-02-15 17:49:48 -05:00
|
|
|
|
2024-08-06 21:46:07 +03:00
|
|
|
public void openLink(String link) {
|
|
|
|
|
try {
|
2018-09-13 12:03:28 -04:00
|
|
|
Class oclass = Class.forName("java.awt.Desktop");
|
2024-08-06 21:46:07 +03:00
|
|
|
Object object = oclass.getMethod("getDesktop", new Class[0]).invoke((Object) null, new Object[0]);
|
|
|
|
|
oclass.getMethod("browse", new Class[]{URI.class}).invoke(object, new Object[]{new URI(link)});
|
|
|
|
|
} catch (Throwable throwable) {
|
2018-09-13 12:03:28 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|