Proper Reformating

This commit is contained in:
Kam committed 2025-03-13 17:14:45 -04:00
1 parent ce75880aba
commit 180d257024
1179 files changed
+59847 -61583

No files matched your search

@@ -21,14 +21,15 @@ import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;
@SideOnly(Side.CLIENT)
public class GuiMailmanWrite extends GuiContainerNPCInterface implements ITextfieldListener, IGuiError, IGuiClose, GuiYesNoCallback
{
public class GuiMailmanWrite extends GuiContainerNPCInterface implements ITextfieldListener, IGuiError, IGuiClose, GuiYesNoCallback {
private static final ResourceLocation bookGuiTextures = new ResourceLocation("textures/gui/book.png");
private static final ResourceLocation bookWidgets = new ResourceLocation("textures/gui/widgets.png");
private static final ResourceLocation bookInventory = new ResourceLocation("textures/gui/container/inventory.png");
/** Update ticks since the gui was opened */
/**
* Update ticks since the gui was opened
*/
private int updateCount;
private int bookImageWidth = 192;
private int bookImageHeight = 192;
@@ -41,38 +42,35 @@ public class GuiMailmanWrite extends GuiContainerNPCInterface implements ITextfi
private boolean canEdit;
private boolean canSend;
/** The GuiButton to sign this book. */
/**
* The GuiButton to sign this book.
*/
public static GuiScreen parent;
public static PlayerMail mail = new PlayerMail();
public static PlayerMail mail = new PlayerMail();
private Minecraft mc = Minecraft.getMinecraft();
private String username = "";
private GuiNpcLabel error;
private String username = "";
private GuiNpcLabel error;
public GuiMailmanWrite(ContainerMail container, boolean canEdit, boolean canSend)
{
super(null, container);
title = "";
public GuiMailmanWrite(ContainerMail container, boolean canEdit, boolean canSend) {
super(null, container);
title = "";
this.canEdit = canEdit;
this.canSend = canSend;
if(mail.message.hasKey("pages"))
this.bookPages = mail.message.getTagList("pages", 8);
if (mail.message.hasKey("pages"))
this.bookPages = mail.message.getTagList("pages", 8);
if (this.bookPages != null)
{
this.bookPages = (NBTTagList)this.bookPages.copy();
if (this.bookPages != null) {
this.bookPages = (NBTTagList) this.bookPages.copy();
this.bookTotalPages = this.bookPages.tagCount();
if (this.bookTotalPages < 1)
{
if (this.bookTotalPages < 1) {
this.bookTotalPages = 1;
}
}
else
{
} else {
this.bookPages = new NBTTagList();
this.bookPages.appendTag(new NBTTagString(""));
this.bookTotalPages = 1;
@@ -82,11 +80,11 @@ public class GuiMailmanWrite extends GuiContainerNPCInterface implements ITextfi
drawDefaultBackground = false;
closeOnEsc = true;
}
/**
* Called from the main game loop to update the screen.
*/
public void updateScreen()
{
public void updateScreen() {
super.updateScreen();
++this.updateCount;
}
@@ -94,40 +92,39 @@ public class GuiMailmanWrite extends GuiContainerNPCInterface implements ITextfi
/**
* Adds the buttons (and other controls) to the screen in question.
*/
public void initGui()
{
super.initGui();
public void initGui() {
super.initGui();
this.buttonList.clear();
Keyboard.enableRepeatEvents(true);
if(canEdit && !canSend)
addLabel(new GuiNpcLabel(0, "mailbox.sender", guiLeft + 170, guiTop + 32, 0));
else
addLabel(new GuiNpcLabel(0, "mailbox.username", guiLeft + 170, guiTop + 32, 0));
if (canEdit && !canSend)
addLabel(new GuiNpcLabel(0, "mailbox.sender", guiLeft + 170, guiTop + 32, 0));
else
addLabel(new GuiNpcLabel(0, "mailbox.username", guiLeft + 170, guiTop + 32, 0));
if(canEdit && !canSend)
addTextField(new GuiNpcTextField(2, this, fontRendererObj, guiLeft + 170, guiTop + 42, 114, 20, mail.sender));
else if(canEdit)
addTextField(new GuiNpcTextField(0, this, fontRendererObj, guiLeft + 170, guiTop + 42, 114, 20, username));
else
addLabel(new GuiNpcLabel(10, mail.sender, guiLeft + 170, guiTop + 42, 0));
if (canEdit && !canSend)
addTextField(new GuiNpcTextField(2, this, fontRendererObj, guiLeft + 170, guiTop + 42, 114, 20, mail.sender));
else if (canEdit)
addTextField(new GuiNpcTextField(0, this, fontRendererObj, guiLeft + 170, guiTop + 42, 114, 20, username));
else
addLabel(new GuiNpcLabel(10, mail.sender, guiLeft + 170, guiTop + 42, 0));
addLabel(new GuiNpcLabel(1, "mailbox.subject", guiLeft + 170, guiTop + 72, 0));
if(canEdit)
addTextField(new GuiNpcTextField(1, this, fontRendererObj, guiLeft + 170, guiTop + 82, 114, 20, mail.subject));
else
addLabel(new GuiNpcLabel(11, mail.subject, guiLeft + 170, guiTop + 82, 0));
addLabel(new GuiNpcLabel(1, "mailbox.subject", guiLeft + 170, guiTop + 72, 0));
if (canEdit)
addTextField(new GuiNpcTextField(1, this, fontRendererObj, guiLeft + 170, guiTop + 82, 114, 20, mail.subject));
else
addLabel(new GuiNpcLabel(11, mail.subject, guiLeft + 170, guiTop + 82, 0));
addLabel(error = new GuiNpcLabel(2, "", guiLeft + 170, guiTop + 114, 0xFF0000));
if(canEdit && !canSend)
addButton(new GuiNpcButton(0, this.guiLeft + 200, guiTop + 171, 60, 20, "gui.done"));
else if(canEdit)
addButton(new GuiNpcButton(0, this.guiLeft + 200, guiTop + 171, 60, 20, "mailbox.send"));
addLabel(error = new GuiNpcLabel(2, "", guiLeft + 170, guiTop + 114, 0xFF0000));
if (canEdit && !canSend)
addButton(new GuiNpcButton(0, this.guiLeft + 200, guiTop + 171, 60, 20, "gui.done"));
else if (canEdit)
addButton(new GuiNpcButton(0, this.guiLeft + 200, guiTop + 171, 60, 20, "mailbox.send"));
if(!canEdit && !canSend)
addButton(new GuiNpcButton(4, this.guiLeft + 200, guiTop + 171, 60, 20, "selectWorld.deleteButton"));
if(!canEdit || canSend)
addButton(new GuiNpcButton(3, this.guiLeft + 200, guiTop + 194, 60, 20, "gui.cancel"));
if (!canEdit && !canSend)
addButton(new GuiNpcButton(4, this.guiLeft + 200, guiTop + 171, 60, 20, "selectWorld.deleteButton"));
if (!canEdit || canSend)
addButton(new GuiNpcButton(3, this.guiLeft + 200, guiTop + 194, 60, 20, "gui.cancel"));
this.buttonList.add(this.buttonNextPage = new GuiButtonNextPage(1, guiLeft + 120, guiTop + 156, true));
this.buttonList.add(this.buttonPreviousPage = new GuiButtonNextPage(2, guiLeft + 38, guiTop + 156, false));
@@ -137,73 +134,56 @@ public class GuiMailmanWrite extends GuiContainerNPCInterface implements ITextfi
/**
* Called when the screen is unloaded. Used to disable keyboard repeat events
*/
public void onGuiClosed()
{
public void onGuiClosed() {
Keyboard.enableRepeatEvents(false);
}
private void updateButtons()
{
private void updateButtons() {
this.buttonNextPage.setVisible(this.currPage < this.bookTotalPages - 1 || this.canEdit);
this.buttonPreviousPage.setVisible(this.currPage > 0);
}
@Override
public void confirmClicked(boolean flag, int i)
{
if(flag){
@Override
public void confirmClicked(boolean flag, int i) {
if (flag) {
MailActionPacket.DeleteMail(mail.time, mail.sender);
close();
}
else
NoppesUtil.openGUI(player, this);
close();
} else
NoppesUtil.openGUI(player, this);
}
/**
* Fired when a control is clicked. This is the equivalent of ActionListener.actionPerformed(ActionEvent e).
*/
@Override
protected void actionPerformed(GuiButton par1GuiButton)
{
if (par1GuiButton.enabled)
{
int id = par1GuiButton.id;
if(id == 0){
mail.message.setTag("pages", bookPages);
if(canSend)
protected void actionPerformed(GuiButton par1GuiButton) {
if (par1GuiButton.enabled) {
int id = par1GuiButton.id;
if (id == 0) {
mail.message.setTag("pages", bookPages);
if (canSend)
MailActionPacket.SendMail(this.username, mail.writeNBT());
else
close();
}
if (id == 3)
{
else
close();
}
if (id == 3) {
close();
}
if (id == 4)
{
if (id == 4) {
GuiYesNo guiyesno = new GuiYesNo(this, "Confirm", StatCollector.translateToLocal("gui.delete"), 0);
displayGuiScreen(guiyesno);
}
else if (id == 1)
{
if (this.currPage < this.bookTotalPages - 1)
{
} else if (id == 1) {
if (this.currPage < this.bookTotalPages - 1) {
++this.currPage;
}
else if (this.canEdit)
{
} else if (this.canEdit) {
this.addNewPage();
if (this.currPage < this.bookTotalPages - 1)
{
if (this.currPage < this.bookTotalPages - 1) {
++this.currPage;
}
}
}
else if (id == 2)
{
if (this.currPage > 0)
{
} else if (id == 2) {
if (this.currPage > 0) {
--this.currPage;
}
}
@@ -212,10 +192,8 @@ public class GuiMailmanWrite extends GuiContainerNPCInterface implements ITextfi
}
}
private void addNewPage()
{
if (this.bookPages != null && this.bookPages.tagCount() < 50)
{
private void addNewPage() {
if (this.bookPages != null && this.bookPages.tagCount() < 50) {
this.bookPages.appendTag(new NBTTagString(""));
++this.bookTotalPages;
}
@@ -224,32 +202,27 @@ public class GuiMailmanWrite extends GuiContainerNPCInterface implements ITextfi
/**
* Fired when a key is typed. This is the equivalent of KeyListener.keyTyped(KeyEvent e).
*/
public void keyTyped(char par1, int par2)
{
if(!GuiNpcTextField.isFieldActive() && canEdit)
this.keyTypedInBook(par1, par2);
else
super.keyTyped(par1, par2);
public void keyTyped(char par1, int par2) {
if (!GuiNpcTextField.isFieldActive() && canEdit)
this.keyTypedInBook(par1, par2);
else
super.keyTyped(par1, par2);
}
/**
* Processes keystrokes when editing the text of a book
*/
private void keyTypedInBook(char par1, int par2)
{
switch (par1)
{
private void keyTypedInBook(char par1, int par2) {
switch (par1) {
case 22:
this.func_74160_b(GuiScreen.getClipboardString());//getClipboardString
return;
default:
switch (par2)
{
switch (par2) {
case 14:
String s = this.func_74158_i();
if (s.length() > 0)
{
if (s.length() > 0) {
this.func_74159_a(s.substring(0, s.length() - 1));
}
@@ -259,42 +232,33 @@ public class GuiMailmanWrite extends GuiContainerNPCInterface implements ITextfi
this.func_74160_b("\n");
return;
default:
if (ChatAllowedCharacters.isAllowedCharacter(par1))
{
if (ChatAllowedCharacters.isAllowedCharacter(par1)) {
this.func_74160_b(Character.toString(par1));
}
}
}
}
private String func_74158_i()
{
if (this.bookPages != null && this.currPage >= 0 && this.currPage < this.bookPages.tagCount())
{
private String func_74158_i() {
if (this.bookPages != null && this.currPage >= 0 && this.currPage < this.bookPages.tagCount()) {
return this.bookPages.getStringTagAt(this.currPage);
}
else
{
} else {
return "";
}
}
private void func_74159_a(String par1Str)
{
if (this.bookPages != null && this.currPage >= 0 && this.currPage < this.bookPages.tagCount())
{
bookPages.func_150304_a(currPage, new NBTTagString(par1Str));
private void func_74159_a(String par1Str) {
if (this.bookPages != null && this.currPage >= 0 && this.currPage < this.bookPages.tagCount()) {
bookPages.func_150304_a(currPage, new NBTTagString(par1Str));
}
}
private void func_74160_b(String par1Str)
{
private void func_74160_b(String par1Str) {
String s1 = this.func_74158_i();
String s2 = s1 + par1Str;
int i = mc.fontRenderer.splitStringWidth(s2 + "" + EnumChatFormatting.BLACK + "_", 118);
if (i <= 118 && s2.length() < 256)
{
if (i <= 118 && s2.length() < 256) {
this.func_74159_a(s2);
}
}
@@ -302,13 +266,12 @@ public class GuiMailmanWrite extends GuiContainerNPCInterface implements ITextfi
/**
* Draws the screen and all the components in it.
*/
public void drawScreen(int par1, int par2, float par3)
{
public void drawScreen(int par1, int par2, float par3) {
this.drawWorldBackground(0);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.getTextureManager().bindTexture(bookGuiTextures);
this.drawTexturedModalRect(guiLeft + 130, guiTop + 22, 0, 0, this.bookImageWidth, this.bookImageHeight / 3);
this.drawTexturedModalRect(guiLeft + 130, guiTop + 22 + bookImageHeight/3, 0, bookImageHeight / 2, this.bookImageWidth, this.bookImageHeight / 2);
this.drawTexturedModalRect(guiLeft + 130, guiTop + 22 + bookImageHeight / 3, 0, bookImageHeight / 2, this.bookImageWidth, this.bookImageHeight / 2);
this.drawTexturedModalRect(guiLeft, guiTop + 2, 0, 0, this.bookImageWidth, this.bookImageHeight);
@@ -319,27 +282,21 @@ public class GuiMailmanWrite extends GuiContainerNPCInterface implements ITextfi
String s1;
int l;
s = I18n.format("book.pageIndicator", new Object[] {Integer.valueOf(this.currPage + 1), Integer.valueOf(this.bookTotalPages)});
s = I18n.format("book.pageIndicator", new Object[]{Integer.valueOf(this.currPage + 1), Integer.valueOf(this.bookTotalPages)});
s1 = "";
if (this.bookPages != null && this.currPage >= 0 && this.currPage < this.bookPages.tagCount())
{
if (this.bookPages != null && this.currPage >= 0 && this.currPage < this.bookPages.tagCount()) {
s1 = this.bookPages.getStringTagAt(this.currPage);
}
if(canEdit){
if (mc.fontRenderer.getBidiFlag())
{
s1 = s1 + "_";
}
else if (this.updateCount / 6 % 2 == 0)
{
s1 = s1 + "" + EnumChatFormatting.BLACK + "_";
}
else
{
s1 = s1 + "" + EnumChatFormatting.GRAY + "_";
}
if (canEdit) {
if (mc.fontRenderer.getBidiFlag()) {
s1 = s1 + "_";
} else if (this.updateCount / 6 % 2 == 0) {
s1 = s1 + "" + EnumChatFormatting.BLACK + "_";
} else {
s1 = s1 + "" + EnumChatFormatting.GRAY + "_";
}
}
l = mc.fontRenderer.getStringWidth(s);
@@ -351,44 +308,44 @@ public class GuiMailmanWrite extends GuiContainerNPCInterface implements ITextfi
this.mc.getTextureManager().bindTexture(bookWidgets);
for(int i = 0; i < 4; i++)
this.drawTexturedModalRect(guiLeft + 175 + i * 24, guiTop + 134, 0, 22, 24, 24);
for (int i = 0; i < 4; i++)
this.drawTexturedModalRect(guiLeft + 175 + i * 24, guiTop + 134, 0, 22, 24, 24);
super.drawScreen(par1, par2, par3);
}
public void close(){
mc.displayGuiScreen(parent);
parent = null;
mail = new PlayerMail();
public void close() {
mc.displayGuiScreen(parent);
parent = null;
mail = new PlayerMail();
}
@Override
public void unFocused(GuiNpcTextField textField) {
if(textField.id == 0)
username = textField.getText();
if(textField.id == 1)
mail.subject = textField.getText();
if(textField.id == 2)
mail.sender = textField.getText();
}
@Override
public void unFocused(GuiNpcTextField textField) {
if (textField.id == 0)
username = textField.getText();
if (textField.id == 1)
mail.subject = textField.getText();
if (textField.id == 2)
mail.sender = textField.getText();
}
@Override
public void setError(int i, NBTTagCompound data) {
if(i == 0)
error.label = StatCollector.translateToLocal("mailbox.errorUsername");
if(i == 1)
error.label = StatCollector.translateToLocal("mailbox.errorSubject");
}
@Override
public void setError(int i, NBTTagCompound data) {
if (i == 0)
error.label = StatCollector.translateToLocal("mailbox.errorUsername");
if (i == 1)
error.label = StatCollector.translateToLocal("mailbox.errorSubject");
}
@Override
public void setClose(int i, NBTTagCompound data) {
player.addChatMessage(new ChatComponentTranslation("mailbox.succes", data.getString("username")));
}
@Override
public void setClose(int i, NBTTagCompound data) {
player.addChatMessage(new ChatComponentTranslation("mailbox.succes", data.getString("username")));
}
@Override
public void save() {
@Override
public void save() {
}
}
}