1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-10-31 05:33:00 +00:00

Turn inspections up to 11

OK, so let's get this out of the way, there's some actual changes mixed
in here too. I'm really sorry:
 - Turtles can now not be renamed with unnamed item tags (previously it
   would clear the name, this seemed a little unideal).
 - commands.getBlock(s)Data will also include NBT.

Now, onto the horror story which is these inspection changes:
 - Make a lot of methods static
 - Typo fixes
 - Make utility classes final + private constructor
 - Lots of reformatting (ifs -> ternary, invert control flow, etc...)
 - ???
 - Profit!

I'm so going to regret this - can pretty much guarantee this is going to
break something.
This commit is contained in:
SquidDev
2019-03-29 21:21:39 +00:00
parent 1230cabcb0
commit 173ea72001
205 changed files with 3653 additions and 1888 deletions

View File

@@ -19,7 +19,7 @@ import org.lwjgl.opengl.GL11;
import java.util.Arrays;
public class FixedWidthFontRenderer
public final class FixedWidthFontRenderer
{
private static final ResourceLocation FONT = new ResourceLocation( "computercraft", "textures/gui/term_font.png" );
public static final ResourceLocation BACKGROUND = new ResourceLocation( "computercraft", "textures/gui/term_background.png" );
@@ -93,7 +93,7 @@ public class FixedWidthFontRenderer
private boolean isGreyScale( int colour )
{
return (colour == 0 || colour == 15 || colour == 7 || colour == 8);
return colour == 0 || colour == 15 || colour == 7 || colour == 8;
}
public void drawStringBackgroundPart( int x, int y, TextBuffer backgroundColour, double leftMarginSize, double rightMarginSize, boolean greyScale, Palette p )

View File

@@ -80,12 +80,6 @@ public class GuiComputer extends GuiContainer
Keyboard.enableRepeatEvents( false );
}
@Override
public boolean doesGuiPauseGame()
{
return false;
}
@Override
public void updateScreen()
{

View File

@@ -22,10 +22,8 @@ public class GuiConfigCC extends GuiConfig
super( parentScreen, Config.getConfigElements(), ComputerCraft.MOD_ID, false, false, "CC: Tweaked" );
}
public static class Factory
implements IModGuiFactory
public static class Factory implements IModGuiFactory
{
@Override
public void initialize( Minecraft minecraft )
{

View File

@@ -29,7 +29,7 @@ public class GuiDiskDrive extends GuiContainer
{
String title = m_container.getDiskDrive().getDisplayName().getUnformattedText();
fontRenderer.drawString( title, (xSize - fontRenderer.getStringWidth( title )) / 2, 6, 0x404040 );
fontRenderer.drawString( I18n.format( "container.inventory" ), 8, (ySize - 96) + 2, 0x404040 );
fontRenderer.drawString( I18n.format( "container.inventory" ), 8, ySize - 96 + 2, 0x404040 );
}
@Override

View File

@@ -8,6 +8,7 @@ package dan200.computercraft.client.gui;
import dan200.computercraft.ComputerCraft;
import dan200.computercraft.shared.media.inventory.ContainerHeldItem;
import dan200.computercraft.shared.pocket.items.ItemPocketComputer;
public class GuiPocketComputer extends GuiComputer
{
@@ -16,7 +17,7 @@ public class GuiPocketComputer extends GuiComputer
super(
container,
ComputerCraft.Items.pocketComputer.getFamily( container.getStack() ),
ComputerCraft.Items.pocketComputer.createClientComputer( container.getStack() ),
ItemPocketComputer.createClientComputer( container.getStack() ),
ComputerCraft.terminalWidth_pocketComputer,
ComputerCraft.terminalHeight_pocketComputer
);

View File

@@ -29,7 +29,7 @@ public class GuiPrinter extends GuiContainer
{
String title = container.getPrinter().getDisplayName().getUnformattedText();
fontRenderer.drawString( title, (xSize - fontRenderer.getStringWidth( title )) / 2, 6, 0x404040 );
fontRenderer.drawString( I18n.format( "container.inventory" ), 8, (ySize - 96) + 2, 0x404040 );
fontRenderer.drawString( I18n.format( "container.inventory" ), 8, ySize - 96 + 2, 0x404040 );
}
@Override

View File

@@ -44,12 +44,6 @@ public class GuiPrintout extends GuiContainer
m_book = ItemPrintout.getType( container.getStack() ) == ItemPrintout.Type.Book;
}
@Override
public boolean doesGuiPauseGame()
{
return false;
}
@Override
protected void keyTyped( char c, int k ) throws IOException
{
@@ -80,7 +74,7 @@ public class GuiPrintout extends GuiContainer
}
else if( mouseWheelChange > 0 )
{
// Scroll down goes to the next page
// Scroll down goes to the previous page
if( m_page > 0 ) m_page--;
}
}
@@ -99,9 +93,9 @@ public class GuiPrintout extends GuiContainer
public void drawScreen( int mouseX, int mouseY, float partialTicks )
{
// We must take the background further back in order to not overlap with our printed pages.
zLevel = zLevel - 1;
zLevel--;
drawDefaultBackground();
zLevel = zLevel + 1;
zLevel++;
super.drawScreen( mouseX, mouseY, partialTicks );
renderHoveredToolTip( mouseX, mouseY );

View File

@@ -98,8 +98,8 @@ public class GuiTurtle extends GuiContainer
public void handleMouseInput() throws IOException
{
super.handleMouseInput();
int x = Mouse.getEventX() * this.width / mc.displayWidth;
int y = this.height - Mouse.getEventY() * this.height / mc.displayHeight - 1;
int x = Mouse.getEventX() * width / mc.displayWidth;
int y = height - Mouse.getEventY() * height / mc.displayHeight - 1;
m_terminalGui.handleMouseInput( x, y );
}
@@ -117,8 +117,8 @@ public class GuiTurtle extends GuiContainer
if( slot >= 0 )
{
GlStateManager.color( 1.0F, 1.0F, 1.0F, 1.0F );
int slotX = (slot % 4);
int slotY = (slot / 4);
int slotX = slot % 4;
int slotY = slot / 4;
mc.getTextureManager().bindTexture( advanced ? BACKGROUND_ADVANCED : BACKGROUND_NORMAL );
drawTexturedModalRect( guiLeft + m_container.m_turtleInvStartX - 2 + slotX * 18, guiTop + m_container.m_playerInvStartY - 2 + slotY * 18, 0, 217, 24, 24 );
}
@@ -128,7 +128,7 @@ public class GuiTurtle extends GuiContainer
protected void drawGuiContainerBackgroundLayer( float partialTicks, int mouseX, int mouseY )
{
// Draw term
boolean advanced = (m_family == ComputerFamily.Advanced);
boolean advanced = m_family == ComputerFamily.Advanced;
m_terminalGui.draw( Minecraft.getMinecraft(), 0, 0, mouseX, mouseY );
// Draw border/inventory

View File

@@ -82,9 +82,9 @@ public class WidgetTerminal extends Widget
String clipboard = GuiScreen.getClipboardString();
if( clipboard != null )
{
// Clip to the first occurance of \r or \n
int newLineIndex1 = clipboard.indexOf( "\r" );
int newLineIndex2 = clipboard.indexOf( "\n" );
// Clip to the first occurrence of \r or \n
int newLineIndex1 = clipboard.indexOf( '\r' );
int newLineIndex2 = clipboard.indexOf( '\n' );
if( newLineIndex1 >= 0 && newLineIndex2 >= 0 )
{
clipboard = clipboard.substring( 0, Math.min( newLineIndex1, newLineIndex2 ) );
@@ -274,11 +274,8 @@ public class WidgetTerminal extends Widget
{
if( m_terminateTimer < TERMINATE_TIME )
{
m_terminateTimer = m_terminateTimer + 0.05f;
if( m_terminateTimer >= TERMINATE_TIME )
{
queueEvent( "terminate" );
}
m_terminateTimer += 0.05f;
if( m_terminateTimer >= TERMINATE_TIME ) queueEvent( "terminate" );
}
}
else
@@ -291,14 +288,11 @@ public class WidgetTerminal extends Widget
{
if( m_rebootTimer < TERMINATE_TIME )
{
m_rebootTimer = m_rebootTimer + 0.05f;
m_rebootTimer += 0.05f;
if( m_rebootTimer >= TERMINATE_TIME )
{
IComputer computer = m_computer.getComputer();
if( computer != null )
{
computer.reboot();
}
if( computer != null ) computer.reboot();
}
}
}
@@ -312,14 +306,11 @@ public class WidgetTerminal extends Widget
{
if( m_shutdownTimer < TERMINATE_TIME )
{
m_shutdownTimer = m_shutdownTimer + 0.05f;
m_shutdownTimer += 0.05f;
if( m_shutdownTimer >= TERMINATE_TIME )
{
IComputer computer = m_computer.getComputer();
if( computer != null )
{
computer.shutdown();
}
if( computer != null ) computer.shutdown();
}
}
}
@@ -346,7 +337,7 @@ public class WidgetTerminal extends Widget
{
// Draw the screen contents
IComputer computer = m_computer.getComputer();
Terminal terminal = (computer != null) ? computer.getTerminal() : null;
Terminal terminal = computer != null ? computer.getTerminal() : null;
if( terminal != null )
{
// Draw the terminal