2024-02-18 17:27:10 +03:00
|
|
|
package noppes.npcs.client.gui;
|
|
|
|
|
|
|
|
|
|
import net.minecraft.client.gui.GuiButton;
|
|
|
|
|
import noppes.npcs.client.gui.util.*;
|
2024-02-29 22:20:35 -05:00
|
|
|
import noppes.npcs.controllers.data.HitboxData;
|
2024-02-18 17:27:10 +03:00
|
|
|
|
2025-03-12 20:12:01 -04:00
|
|
|
public class SubGuiCustomHitbox extends SubGuiInterface implements ITextfieldListener {
|
2024-02-29 22:41:58 -05:00
|
|
|
private final HitboxData hitboxData;
|
2025-03-12 20:12:01 -04:00
|
|
|
|
|
|
|
|
public SubGuiCustomHitbox(HitboxData hitboxData) {
|
2024-02-18 17:27:10 +03:00
|
|
|
this.hitboxData = hitboxData;
|
|
|
|
|
setBackground("menubg.png");
|
|
|
|
|
xSize = 256;
|
|
|
|
|
ySize = 216;
|
|
|
|
|
closeOnEsc = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2025-03-12 20:12:01 -04:00
|
|
|
public void initGui() {
|
2024-02-18 17:27:10 +03:00
|
|
|
super.initGui();
|
2025-03-12 20:12:01 -04:00
|
|
|
addLabel(new GuiNpcLabel(0, "hitbox.hitbox", guiLeft + 5, guiTop + 35));
|
|
|
|
|
addButton(new GuiNpcButtonYesNo(0, guiLeft + 122, guiTop + 30, 56, 20, hitboxData.isHitboxEnabled()));
|
|
|
|
|
if (hitboxData.isHitboxEnabled()) {
|
|
|
|
|
addLabel(new GuiNpcLabel(3, "hitbox.width", guiLeft + 5, guiTop + 57));
|
|
|
|
|
addTextField(new GuiNpcTextField(2, this, fontRendererObj, guiLeft + 122, guiTop + 53, 50, 18, hitboxData.getWidthScale() + ""));
|
2024-02-18 17:27:10 +03:00
|
|
|
getTextField(2).floatsOnly = true;
|
2024-03-08 01:49:31 -05:00
|
|
|
getTextField(2).setMinMaxDefaultFloat(0, Float.MAX_VALUE, 1);
|
2024-02-18 17:27:10 +03:00
|
|
|
|
2025-03-12 20:12:01 -04:00
|
|
|
addLabel(new GuiNpcLabel(4, "hitbox.height", guiLeft + 5, guiTop + 79));
|
|
|
|
|
addTextField(new GuiNpcTextField(3, this, fontRendererObj, guiLeft + 122, guiTop + 75, 50, 18, hitboxData.getHeightScale() + ""));
|
2024-02-18 17:27:10 +03:00
|
|
|
getTextField(3).floatsOnly = true;
|
2024-03-08 01:49:31 -05:00
|
|
|
getTextField(3).setMinMaxDefaultFloat(0, Float.MAX_VALUE, 1);
|
2024-02-18 17:27:10 +03:00
|
|
|
}
|
2025-03-12 20:12:01 -04:00
|
|
|
addButton(new GuiNpcButton(66, guiLeft + 82, guiTop + 190, 98, 20, "gui.done"));
|
2024-02-18 17:27:10 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2025-03-12 20:12:01 -04:00
|
|
|
protected void actionPerformed(GuiButton guibutton) {
|
2024-02-18 17:27:10 +03:00
|
|
|
int id = guibutton.id;
|
|
|
|
|
GuiNpcButton button = (GuiNpcButton) guibutton;
|
2025-03-12 20:12:01 -04:00
|
|
|
if (button.id == 0) {
|
|
|
|
|
hitboxData.setHitboxEnabled(((GuiNpcButtonYesNo) button).getBoolean());
|
2024-02-18 17:27:10 +03:00
|
|
|
initGui();
|
|
|
|
|
}
|
2025-03-12 20:12:01 -04:00
|
|
|
if (id == 66) {
|
2024-02-18 17:27:10 +03:00
|
|
|
close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void unFocused(GuiNpcTextField textfield) {
|
2025-03-12 20:12:01 -04:00
|
|
|
if (textfield.id == 2) {
|
2024-02-29 22:41:58 -05:00
|
|
|
hitboxData.setWidthScale(textfield.getFloat());
|
2024-02-18 17:27:10 +03:00
|
|
|
}
|
2025-03-12 20:12:01 -04:00
|
|
|
if (textfield.id == 3) {
|
2024-02-29 22:41:58 -05:00
|
|
|
hitboxData.setHeightScale(textfield.getFloat());
|
2024-02-18 17:27:10 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|