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

@@ -23,8 +23,7 @@ import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;
@SideOnly(Side.CLIENT)
public class GuiBook extends GuiScreen
{
public class GuiBook extends GuiScreen {
private static final Logger logger = LogManager.getLogger();
private static final ResourceLocation bookGuiTextures = new ResourceLocation("textures/gui/book.png");
/**
@@ -60,33 +59,29 @@ public class GuiBook extends GuiScreen
private int x, y, z;
public GuiBook(EntityPlayer par1EntityPlayer, ItemStack item, int x, int y, int z){
this.x = x;
this.y = y;
this.z = z;
public GuiBook(EntityPlayer par1EntityPlayer, ItemStack item, int x, int y, int z) {
this.x = x;
this.y = y;
this.z = z;
this.editingPlayer = par1EntityPlayer;
this.bookObj = item;
this.bookIsUnsigned = item.getItem() == Items.writable_book;
if (item.hasTagCompound())
{
if (item.hasTagCompound()) {
NBTTagCompound nbttagcompound = item.getTagCompound();
this.bookPages = nbttagcompound.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;
}
}
}
if (this.bookPages == null && bookIsUnsigned)
{
if (this.bookPages == null && bookIsUnsigned) {
this.bookPages = new NBTTagList();
this.bookPages.appendTag(new NBTTagString(""));
this.bookTotalPages = 1;
@@ -96,29 +91,29 @@ public class GuiBook extends GuiScreen
/**
* Called from the main game loop to update the screen.
*/
public void updateScreen(){
public void updateScreen() {
super.updateScreen();
++this.updateCount;
}
@Override
public boolean doesGuiPauseGame(){
public boolean doesGuiPauseGame() {
return false;
}
/**
* Adds the buttons (and other controls) to the screen in question.
*/
public void initGui(){
public void initGui() {
this.buttonList.clear();
Keyboard.enableRepeatEvents(true);
if (this.bookIsUnsigned){
if (this.bookIsUnsigned) {
this.buttonList.add(this.buttonSign = new GuiButton(3, this.width / 2 - 100, 4 + this.bookImageHeight, 98, 20, I18n.format("book.signButton", new Object[0])));
this.buttonList.add(this.buttonDone = new GuiButton(0, this.width / 2 + 2, 4 + this.bookImageHeight, 98, 20, I18n.format("gui.done", new Object[0])));
this.buttonList.add(this.buttonFinalize = new GuiButton(5, this.width / 2 - 100, 4 + this.bookImageHeight, 98, 20, I18n.format("book.finalizeButton", new Object[0])));
this.buttonList.add(this.buttonCancel = new GuiButton(4, this.width / 2 + 2, 4 + this.bookImageHeight, 98, 20, I18n.format("gui.cancel", new Object[0])));
}
else{
} else {
this.buttonList.add(this.buttonDone = new GuiButton(0, this.width / 2 - 100, 4 + this.bookImageHeight, 200, 20, I18n.format("gui.done", new Object[0])));
}
@@ -132,17 +127,16 @@ public class GuiBook extends GuiScreen
/**
* 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.visible = !this.field_146480_s && (this.currPage < this.bookTotalPages - 1 || this.bookIsUnsigned);
this.buttonPreviousPage.visible = !this.field_146480_s && this.currPage > 0;
this.buttonDone.visible = !this.bookIsUnsigned || !this.field_146480_s;
if (this.bookIsUnsigned)
{
if (this.bookIsUnsigned) {
this.buttonSign.visible = !this.field_146480_s;
this.buttonCancel.visible = this.field_146480_s;
this.buttonFinalize.visible = this.field_146480_s;
@@ -150,11 +144,11 @@ public class GuiBook extends GuiScreen
}
}
private void sendBookToServer(boolean sign){
if (this.bookIsUnsigned && this.field_146481_r){
if (this.bookPages != null){
private void sendBookToServer(boolean sign) {
if (this.bookIsUnsigned && this.field_146481_r) {
if (this.bookPages != null) {
while (this.bookPages.tagCount() > 1){
while (this.bookPages.tagCount() > 1) {
String s = this.bookPages.getStringTagAt(this.bookPages.tagCount() - 1);
if (s.length() != 0)
@@ -163,16 +157,14 @@ public class GuiBook extends GuiScreen
this.bookPages.removeTag(this.bookPages.tagCount() - 1);
}
if (this.bookObj.hasTagCompound()){
if (this.bookObj.hasTagCompound()) {
NBTTagCompound nbttagcompound = this.bookObj.getTagCompound();
nbttagcompound.setTag("pages", this.bookPages);
}
else{
} else {
this.bookObj.setTagInfo("pages", this.bookPages);
}
if (sign)
{
if (sign) {
this.bookObj.setTagInfo("author", new NBTTagString(this.editingPlayer.getCommandSenderName()));
this.bookObj.setTagInfo("title", new NBTTagString(this.bookTitle.trim()));
this.bookObj.func_150996_a(Items.written_book);
@@ -184,48 +176,31 @@ public class GuiBook extends GuiScreen
}
}
protected void actionPerformed(GuiButton p_146284_1_){
if (p_146284_1_.enabled)
{
if (p_146284_1_.id == 0)
{
this.mc.displayGuiScreen((GuiScreen)null);
protected void actionPerformed(GuiButton p_146284_1_) {
if (p_146284_1_.enabled) {
if (p_146284_1_.id == 0) {
this.mc.displayGuiScreen((GuiScreen) null);
this.sendBookToServer(false);
}
else if (p_146284_1_.id == 3 && this.bookIsUnsigned)
{
} else if (p_146284_1_.id == 3 && this.bookIsUnsigned) {
this.field_146480_s = true;
}
else if (p_146284_1_.id == 1)
{
if (this.currPage < this.bookTotalPages - 1)
{
} else if (p_146284_1_.id == 1) {
if (this.currPage < this.bookTotalPages - 1) {
++this.currPage;
}
else if (this.bookIsUnsigned)
{
} else if (this.bookIsUnsigned) {
this.addNewPage();
if (this.currPage < this.bookTotalPages - 1)
{
if (this.currPage < this.bookTotalPages - 1) {
++this.currPage;
}
}
}
else if (p_146284_1_.id == 2)
{
if (this.currPage > 0)
{
} else if (p_146284_1_.id == 2) {
if (this.currPage > 0) {
--this.currPage;
}
}
else if (p_146284_1_.id == 5 && this.field_146480_s)
{
} else if (p_146284_1_.id == 5 && this.field_146480_s) {
this.sendBookToServer(true);
this.mc.displayGuiScreen((GuiScreen)null);
}
else if (p_146284_1_.id == 4 && this.field_146480_s)
{
this.mc.displayGuiScreen((GuiScreen) null);
} else if (p_146284_1_.id == 4 && this.field_146480_s) {
this.field_146480_s = false;
}
@@ -233,9 +208,8 @@ public class GuiBook extends GuiScreen
}
}
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;
this.field_146481_r = true;
@@ -245,17 +219,13 @@ public class GuiBook extends GuiScreen
/**
* Fired when a key is typed. This is the equivalent of KeyListener.keyTyped(KeyEvent e).
*/
protected void keyTyped(char par1, int par2){
protected void keyTyped(char par1, int par2) {
super.keyTyped(par1, par2);
if (this.bookIsUnsigned)
{
if (this.field_146480_s)
{
if (this.bookIsUnsigned) {
if (this.field_146480_s) {
this.func_146460_c(par1, par2);
}
else
{
} else {
this.keyTypedInBook(par1, par2);
}
}
@@ -264,20 +234,17 @@ public class GuiBook extends GuiScreen
/**
* Processes keystrokes when editing the text of a book
*/
private void keyTypedInBook(char p_146463_1_, int p_146463_2_){
switch (p_146463_1_)
{
private void keyTypedInBook(char p_146463_1_, int p_146463_2_) {
switch (p_146463_1_) {
case 22:
this.func_146459_b(GuiScreen.getClipboardString());
return;
default:
switch (p_146463_2_)
{
switch (p_146463_2_) {
case 14:
String s = this.func_146456_p();
if (s.length() > 0)
{
if (s.length() > 0) {
this.func_146457_a(s.substring(0, s.length() - 1));
}
@@ -287,20 +254,17 @@ public class GuiBook extends GuiScreen
this.func_146459_b("\n");
return;
default:
if (ChatAllowedCharacters.isAllowedCharacter(p_146463_1_))
{
if (ChatAllowedCharacters.isAllowedCharacter(p_146463_1_)) {
this.func_146459_b(Character.toString(p_146463_1_));
}
}
}
}
private void func_146460_c(char p_146460_1_, int p_146460_2_){
switch (p_146460_2_)
{
private void func_146460_c(char p_146460_1_, int p_146460_2_) {
switch (p_146460_2_) {
case 14:
if (!this.bookTitle.isEmpty())
{
if (!this.bookTitle.isEmpty()) {
this.bookTitle = this.bookTitle.substring(0, this.bookTitle.length() - 1);
this.updateButtons();
}
@@ -308,16 +272,14 @@ public class GuiBook extends GuiScreen
return;
case 28:
case 156:
if (!this.bookTitle.isEmpty())
{
if (!this.bookTitle.isEmpty()) {
this.sendBookToServer(true);
this.mc.displayGuiScreen((GuiScreen)null);
this.mc.displayGuiScreen((GuiScreen) null);
}
return;
default:
if (this.bookTitle.length() < 16 && ChatAllowedCharacters.isAllowedCharacter(p_146460_1_))
{
if (this.bookTitle.length() < 16 && ChatAllowedCharacters.isAllowedCharacter(p_146460_1_)) {
this.bookTitle = this.bookTitle + Character.toString(p_146460_1_);
this.updateButtons();
this.field_146481_r = true;
@@ -325,25 +287,23 @@ public class GuiBook extends GuiScreen
}
}
private String func_146456_p(){
private String func_146456_p() {
return this.bookPages != null && this.currPage >= 0 && this.currPage < this.bookPages.tagCount() ? this.bookPages.getStringTagAt(this.currPage) : "";
}
private void func_146457_a(String p_146457_1_){
if (this.bookPages != null && this.currPage >= 0 && this.currPage < this.bookPages.tagCount())
{
private void func_146457_a(String p_146457_1_) {
if (this.bookPages != null && this.currPage >= 0 && this.currPage < this.bookPages.tagCount()) {
this.bookPages.func_150304_a(this.currPage, new NBTTagString(p_146457_1_));
this.field_146481_r = true;
}
}
private void func_146459_b(String p_146459_1_){
private void func_146459_b(String p_146459_1_) {
String s1 = this.func_146456_p();
String s2 = s1 + p_146459_1_;
int i = this.fontRendererObj.splitStringWidth(s2 + "" + EnumChatFormatting.BLACK + "_", 118);
if (i <= 118 && s2.length() < 256)
{
if (i <= 118 && s2.length() < 256) {
this.func_146457_a(s2);
}
}
@@ -351,7 +311,7 @@ public class GuiBook extends GuiScreen
/**
* 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) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.getTextureManager().bindTexture(bookGuiTextures);
int k = (this.width - this.bookImageWidth) / 2;
@@ -361,18 +321,13 @@ public class GuiBook extends GuiScreen
String s1;
int l;
if (this.field_146480_s)
{
if (this.field_146480_s) {
s = this.bookTitle;
if (this.bookIsUnsigned)
{
if (this.updateCount / 6 % 2 == 0)
{
if (this.bookIsUnsigned) {
if (this.updateCount / 6 % 2 == 0) {
s = s + "" + EnumChatFormatting.BLACK + "_";
}
else
{
} else {
s = s + "" + EnumChatFormatting.GRAY + "_";
}
}
@@ -382,34 +337,25 @@ public class GuiBook extends GuiScreen
this.fontRendererObj.drawString(s1, k + 36 + (116 - l) / 2, b0 + 16 + 16, 0);
int i1 = this.fontRendererObj.getStringWidth(s);
this.fontRendererObj.drawString(s, k + 36 + (116 - i1) / 2, b0 + 48, 0);
String s2 = I18n.format("book.byAuthor", new Object[] {this.editingPlayer.getCommandSenderName()});
String s2 = I18n.format("book.byAuthor", new Object[]{this.editingPlayer.getCommandSenderName()});
int j1 = this.fontRendererObj.getStringWidth(s2);
this.fontRendererObj.drawString(EnumChatFormatting.DARK_GRAY + s2, k + 36 + (116 - j1) / 2, b0 + 48 + 10, 0);
String s3 = I18n.format("book.finalizeWarning", new Object[0]);
this.fontRendererObj.drawSplitString(s3, k + 36, b0 + 80, 116, 0);
}
else
{
s = I18n.format("book.pageIndicator", new Object[] {Integer.valueOf(this.currPage + 1), Integer.valueOf(this.bookTotalPages)});
} else {
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 (this.bookIsUnsigned)
{
if (this.fontRendererObj.getBidiFlag())
{
if (this.bookIsUnsigned) {
if (this.fontRendererObj.getBidiFlag()) {
s1 = s1 + "_";
}
else if (this.updateCount / 6 % 2 == 0)
{
} else if (this.updateCount / 6 % 2 == 0) {
s1 = s1 + "" + EnumChatFormatting.BLACK + "_";
}
else
{
} else {
s1 = s1 + "" + EnumChatFormatting.GRAY + "_";
}
}
@@ -423,41 +369,35 @@ public class GuiBook extends GuiScreen
}
@SideOnly(Side.CLIENT)
static class NextPageButton extends GuiButton
{
private final boolean field_146151_o;
static class NextPageButton extends GuiButton {
private final boolean field_146151_o;
public NextPageButton(int par1, int par2, int par3, boolean par4)
{
super(par1, par2, par3, 23, 13, "");
this.field_146151_o = par4;
}
public NextPageButton(int par1, int par2, int par3, boolean par4) {
super(par1, par2, par3, 23, 13, "");
this.field_146151_o = par4;
}
/**
* Draws this button to the screen.
*/
public void drawButton(Minecraft p_146112_1_, int p_146112_2_, int p_146112_3_)
{
if (this.visible)
{
boolean flag = p_146112_2_ >= this.xPosition && p_146112_3_ >= this.yPosition && p_146112_2_ < this.xPosition + this.width && p_146112_3_ < this.yPosition + this.height;
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
p_146112_1_.getTextureManager().bindTexture(GuiBook.bookGuiTextures);
int k = 0;
int l = 192;
/**
* Draws this button to the screen.
*/
public void drawButton(Minecraft p_146112_1_, int p_146112_2_, int p_146112_3_) {
if (this.visible) {
boolean flag = p_146112_2_ >= this.xPosition && p_146112_3_ >= this.yPosition && p_146112_2_ < this.xPosition + this.width && p_146112_3_ < this.yPosition + this.height;
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
p_146112_1_.getTextureManager().bindTexture(GuiBook.bookGuiTextures);
int k = 0;
int l = 192;
if (flag)
{
k += 23;
}
if (!this.field_146151_o)
{
l += 13;
}
this.drawTexturedModalRect(this.xPosition, this.yPosition, k, l, 23, 13);
if (flag) {
k += 23;
}
if (!this.field_146151_o) {
l += 13;
}
this.drawTexturedModalRect(this.xPosition, this.yPosition, k, l, 23, 13);
}
}
}
}