1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-10-29 21:02:59 +00:00

Reformat everything

It's been a long time comin'
But tonight is the end of the war, my friend
Tomorrow only one style will remain.
This commit is contained in:
SquidDev
2018-12-23 17:46:58 +00:00
parent 72b9d3d802
commit 2032e7a83a
173 changed files with 2028 additions and 1672 deletions

View File

@@ -35,7 +35,7 @@ public class FixedWidthFontRenderer
private static void greyscaleify( double[] rgb )
{
Arrays.fill( rgb, ( rgb[0] + rgb[1] + rgb[2] ) / 3.0f );
Arrays.fill( rgb, (rgb[0] + rgb[1] + rgb[2]) / 3.0f );
}
private void drawChar( BufferBuilder renderer, double x, double y, int index, int color, Palette p, boolean greyscale )
@@ -44,13 +44,13 @@ public class FixedWidthFontRenderer
int row = index / 16;
double[] colour = p.getColour( 15 - color );
if(greyscale)
if( greyscale )
{
greyscaleify( colour );
}
float r = (float)colour[0];
float g = (float)colour[1];
float b = (float)colour[2];
float r = (float) colour[0];
float g = (float) colour[1];
float b = (float) colour[2];
int xStart = 1 + column * (FONT_WIDTH + 2);
int yStart = 1 + row * (FONT_HEIGHT + 2);
@@ -66,13 +66,13 @@ public class FixedWidthFontRenderer
private void drawQuad( BufferBuilder renderer, double x, double y, int color, double width, Palette p, boolean greyscale )
{
double[] colour = p.getColour( 15 - color );
if(greyscale)
if( greyscale )
{
greyscaleify( colour );
}
float r = (float)colour[0];
float g = (float)colour[1];
float b = (float)colour[2];
float r = (float) colour[0];
float g = (float) colour[1];
float b = (float) colour[2];
renderer.pos( x, y, 0.0 ).color( r, g, b, 1.0f ).endVertex();
renderer.pos( x, y + FONT_HEIGHT, 0.0 ).color( r, g, b, 1.0f ).endVertex();
@@ -96,7 +96,7 @@ public class FixedWidthFontRenderer
if( leftMarginSize > 0.0 )
{
int colour1 = "0123456789abcdef".indexOf( backgroundColour.charAt( 0 ) );
if( colour1 < 0 || (greyScale && !isGreyScale(colour1)) )
if( colour1 < 0 || (greyScale && !isGreyScale( colour1 )) )
{
colour1 = 15;
}
@@ -105,7 +105,7 @@ public class FixedWidthFontRenderer
if( rightMarginSize > 0.0 )
{
int colour2 = "0123456789abcdef".indexOf( backgroundColour.charAt( backgroundColour.length() - 1 ) );
if( colour2 < 0 || (greyScale && !isGreyScale(colour2)) )
if( colour2 < 0 || (greyScale && !isGreyScale( colour2 )) )
{
colour2 = 15;
}
@@ -114,7 +114,7 @@ public class FixedWidthFontRenderer
for( int i = 0; i < backgroundColour.length(); i++ )
{
int colour = "0123456789abcdef".indexOf( backgroundColour.charAt( i ) );
if( colour < 0 || ( greyScale && !isGreyScale( colour ) ) )
if( colour < 0 || (greyScale && !isGreyScale( colour )) )
{
colour = 15;
}
@@ -135,7 +135,7 @@ public class FixedWidthFontRenderer
{
// Switch colour
int colour = "0123456789abcdef".indexOf( textColour.charAt( i ) );
if( colour < 0 || ( greyScale && !isGreyScale( colour ) ) )
if( colour < 0 || (greyScale && !isGreyScale( colour )) )
{
colour = 0;
}
@@ -162,21 +162,21 @@ public class FixedWidthFontRenderer
// Draw the quads
drawStringBackgroundPart( x, y, backgroundColour, leftMarginSize, rightMarginSize, greyScale, p );
}
// Draw text
if( s != null && textColour != null )
{
// Bind the font texture
bindFont();
// Draw the quads
drawStringTextPart( x, y, s, textColour, greyScale, p );
}
}
public int getStringWidth(String s)
public int getStringWidth( String s )
{
if(s == null)
if( s == null )
{
return 0;
}

View File

@@ -87,7 +87,7 @@ public class GuiComputer extends GuiContainer
}
@Override
protected void keyTyped(char c, int k) throws IOException
protected void keyTyped( char c, int k ) throws IOException
{
if( k == 1 )
{
@@ -127,7 +127,7 @@ public class GuiComputer extends GuiContainer
}
@Override
protected void drawGuiContainerForegroundLayer(int par1, int par2)
protected void drawGuiContainerForegroundLayer( int par1, int par2 )
{
}
@@ -148,7 +148,7 @@ public class GuiComputer extends GuiContainer
// Draw background
drawDefaultBackground();
// Draw terminal
// Draw terminal
m_terminal.draw( this.mc, startX, startY, mouseX, mouseY );
// Draw a border around the terminal
@@ -173,15 +173,15 @@ public class GuiComputer extends GuiContainer
}
}
drawTexturedModalRect(startX - 12, startY - 12, 12, 28, 12, 12);
drawTexturedModalRect(startX - 12, endY, 12, 40, 12, 16);
drawTexturedModalRect(endX, startY - 12, 24, 28, 12, 12);
drawTexturedModalRect(endX, endY, 24, 40, 12, 16);
drawTexturedModalRect( startX - 12, startY - 12, 12, 28, 12, 12 );
drawTexturedModalRect( startX - 12, endY, 12, 40, 12, 16 );
drawTexturedModalRect( endX, startY - 12, 24, 28, 12, 12 );
drawTexturedModalRect( endX, endY, 24, 40, 12, 16 );
drawTexturedModalRect(startX, startY-12, 0, 0, endX - startX, 12);
drawTexturedModalRect(startX, endY, 0, 12, endX - startX, 16);
drawTexturedModalRect( startX, startY - 12, 0, 0, endX - startX, 12 );
drawTexturedModalRect( startX, endY, 0, 12, endX - startX, 16 );
drawTexturedModalRect(startX-12, startY, 0, 28, 12, endY - startY);
drawTexturedModalRect(endX, startY, 36, 28, 12, endY - startY);
drawTexturedModalRect( startX - 12, startY, 0, 28, 12, endY - startY );
drawTexturedModalRect( endX, startY, 36, 28, 12, endY - startY );
}
}

View File

@@ -24,7 +24,7 @@ public class GuiConfigCC extends GuiConfig
private static List<IConfigElement> getConfigElements()
{
ArrayList<IConfigElement> elements = new ArrayList<>();
for (Property property : ComputerCraft.Config.config.getCategory( Configuration.CATEGORY_GENERAL ).getOrderedValues())
for( Property property : ComputerCraft.Config.config.getCategory( Configuration.CATEGORY_GENERAL ).getOrderedValues() )
{
elements.add( new ConfigElement( property ) );
}

View File

@@ -22,33 +22,33 @@ public class GuiDiskDrive extends GuiContainer
public GuiDiskDrive( InventoryPlayer inventoryplayer, TileDiskDrive diskDrive )
{
super( new ContainerDiskDrive(inventoryplayer, diskDrive) );
super( new ContainerDiskDrive( inventoryplayer, diskDrive ) );
m_diskDrive = diskDrive;
}
@Override
protected void drawGuiContainerForegroundLayer(int par1, int par2)
protected void drawGuiContainerForegroundLayer( int par1, int par2 )
{
String title = m_diskDrive.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( title, (xSize - fontRenderer.getStringWidth( title )) / 2, 6, 0x404040 );
fontRenderer.drawString( I18n.format( "container.inventory" ), 8, (ySize - 96) + 2, 0x404040 );
}
@Override
protected void drawGuiContainerBackgroundLayer(float f, int i, int j)
protected void drawGuiContainerBackgroundLayer( float f, int i, int j )
{
GlStateManager.color( 1.0F, 1.0F, 1.0F, 1.0F );
this.mc.getTextureManager().bindTexture( background );
int l = (width - xSize) / 2;
int i1 = (height - ySize) / 2;
drawTexturedModalRect(l, i1, 0, 0, xSize, ySize);
drawTexturedModalRect( l, i1, 0, 0, xSize, ySize );
}
@Override
public void drawScreen( int mouseX, int mouseY, float partialTicks)
public void drawScreen( int mouseX, int mouseY, float partialTicks )
{
drawDefaultBackground();
super.drawScreen(mouseX, mouseY, partialTicks);
renderHoveredToolTip(mouseX, mouseY);
super.drawScreen( mouseX, mouseY, partialTicks );
renderHoveredToolTip( mouseX, mouseY );
}
}

View File

@@ -17,46 +17,46 @@ import net.minecraft.util.ResourceLocation;
public class GuiPrinter extends GuiContainer
{
private static final ResourceLocation background = new ResourceLocation( "computercraft", "textures/gui/printer.png" );
private TilePrinter m_printer;
private ContainerPrinter m_container;
public GuiPrinter(InventoryPlayer inventoryplayer, TilePrinter printer)
public GuiPrinter( InventoryPlayer inventoryplayer, TilePrinter printer )
{
super(new ContainerPrinter(inventoryplayer, printer));
super( new ContainerPrinter( inventoryplayer, printer ) );
m_printer = printer;
m_container = (ContainerPrinter)inventorySlots;
m_container = (ContainerPrinter) inventorySlots;
}
@Override
protected void drawGuiContainerForegroundLayer(int par1, int par2)
protected void drawGuiContainerForegroundLayer( int par1, int par2 )
{
String title = m_printer.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( title, (xSize - fontRenderer.getStringWidth( title )) / 2, 6, 0x404040 );
fontRenderer.drawString( I18n.format( "container.inventory" ), 8, (ySize - 96) + 2, 0x404040 );
}
@Override
protected void drawGuiContainerBackgroundLayer(float f, int i, int j)
protected void drawGuiContainerBackgroundLayer( float f, int i, int j )
{
GlStateManager.color( 1.0F, 1.0F, 1.0F, 1.0F );
this.mc.getTextureManager().bindTexture( background );
int startX = (width - xSize) / 2;
int startY = (height - ySize) / 2;
drawTexturedModalRect(startX, startY, 0, 0, xSize, ySize);
drawTexturedModalRect( startX, startY, 0, 0, xSize, ySize );
boolean printing = m_container.isPrinting();
if( printing )
{
drawTexturedModalRect(startX + 34, startY + 21, 176, 0, 25, 45);
drawTexturedModalRect( startX + 34, startY + 21, 176, 0, 25, 45 );
}
}
@Override
public void drawScreen( int mouseX, int mouseY, float partialTicks)
public void drawScreen( int mouseX, int mouseY, float partialTicks )
{
drawDefaultBackground();
super.drawScreen(mouseX, mouseY, partialTicks);
renderHoveredToolTip(mouseX, mouseY);
super.drawScreen( mouseX, mouseY, partialTicks );
renderHoveredToolTip( mouseX, mouseY );
}
}

View File

@@ -30,12 +30,12 @@ public class GuiPrintout extends GuiContainer
super( container );
String[] text = ItemPrintout.getText( container.getStack() );
m_text = new TextBuffer[ text.length ];
for( int i = 0; i < m_text.length; ++i ) m_text[ i ] = new TextBuffer( text[ i ] );
m_text = new TextBuffer[text.length];
for( int i = 0; i < m_text.length; i++ ) m_text[i] = new TextBuffer( text[i] );
String[] colours = ItemPrintout.getColours( container.getStack() );
m_colours = new TextBuffer[ colours.length ];
for( int i = 0; i < m_colours.length; ++i ) m_colours[ i ] = new TextBuffer( colours[ i ] );
m_colours = new TextBuffer[colours.length];
for( int i = 0; i < m_colours.length; i++ ) m_colours[i] = new TextBuffer( colours[i] );
m_page = 0;
m_pages = Math.max( m_text.length / ItemPrintout.LINES_PER_PAGE, 1 );

View File

@@ -60,10 +60,10 @@ public class GuiTurtle extends GuiContainer
public void initGui()
{
super.initGui();
Keyboard.enableRepeatEvents(true);
Keyboard.enableRepeatEvents( true );
m_terminalGui = new WidgetTerminal(
( width - xSize ) / 2 + 8,
( height - ySize ) / 2 + 8,
(width - xSize) / 2 + 8,
(height - ySize) / 2 + 8,
ComputerCraft.terminalWidth_turtle,
ComputerCraft.terminalHeight_turtle,
() -> m_computer,
@@ -76,7 +76,7 @@ public class GuiTurtle extends GuiContainer
public void onGuiClosed()
{
super.onGuiClosed();
Keyboard.enableRepeatEvents(false);
Keyboard.enableRepeatEvents( false );
}
@Override
@@ -87,7 +87,7 @@ public class GuiTurtle extends GuiContainer
}
@Override
protected void keyTyped(char c, int k) throws IOException
protected void keyTyped( char c, int k ) throws IOException
{
if( k == 1 )
{
@@ -100,7 +100,7 @@ public class GuiTurtle extends GuiContainer
}
@Override
protected void mouseClicked(int x, int y, int button) throws IOException
protected void mouseClicked( int x, int y, int button ) throws IOException
{
super.mouseClicked( x, y, button );
m_terminalGui.mouseClicked( x, y, button );
@@ -132,10 +132,10 @@ 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);
this.mc.getTextureManager().bindTexture( advanced ? backgroundAdvanced : background );
drawTexturedModalRect(x + m_container.m_turtleInvStartX - 2 + slotX * 18, y + m_container.m_playerInvStartY - 2 + slotY * 18, 0, 217, 24, 24);
drawTexturedModalRect( x + m_container.m_turtleInvStartX - 2 + slotX * 18, y + m_container.m_playerInvStartY - 2 + slotY * 18, 0, 217, 24, 24 );
}
}
@@ -151,16 +151,16 @@ public class GuiTurtle extends GuiContainer
this.mc.getTextureManager().bindTexture( advanced ? backgroundAdvanced : background );
int x = (width - xSize) / 2;
int y = (height - ySize) / 2;
drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
drawTexturedModalRect( x, y, 0, 0, xSize, ySize );
drawSelectionSlot( advanced );
}
@Override
public void drawScreen( int mouseX, int mouseY, float partialTicks)
public void drawScreen( int mouseX, int mouseY, float partialTicks )
{
drawDefaultBackground();
super.drawScreen(mouseX, mouseY, partialTicks);
renderHoveredToolTip(mouseX, mouseY);
super.drawScreen( mouseX, mouseY, partialTicks );
renderHoveredToolTip( mouseX, mouseY );
}
}

View File

@@ -122,8 +122,8 @@ public class WidgetTerminal extends Widget
}
// Queue the "paste" event
queueEvent( "paste", new Object[]{
clipboard
queueEvent( "paste", new Object[] {
clipboard
} );
}
}
@@ -143,7 +143,7 @@ public class WidgetTerminal extends Widget
}
// Queue the "key" event
queueEvent( "key", new Object[]{
queueEvent( "key", new Object[] {
key, repeat
} );
handled = true;
@@ -152,7 +152,7 @@ public class WidgetTerminal extends Widget
if( (ch >= 32 && ch <= 126) || (ch >= 160 && ch <= 255) ) // printable chars in byte range
{
// Queue the "char" event
queueEvent( "char", new Object[]{
queueEvent( "char", new Object[] {
Character.toString( ch )
} );
handled = true;
@@ -171,7 +171,7 @@ public class WidgetTerminal extends Widget
if( mouseX >= getXPosition() && mouseX < getXPosition() + getWidth() &&
mouseY >= getYPosition() && mouseY < getYPosition() + getHeight() )
{
if( !m_focus && button == 0)
if( !m_focus && button == 0 )
{
m_focus = true;
}
@@ -184,12 +184,12 @@ public class WidgetTerminal extends Widget
Terminal term = computer.getTerminal();
if( term != null )
{
int charX = ( mouseX - ( getXPosition() + m_leftMargin ) ) / FixedWidthFontRenderer.FONT_WIDTH;
int charY = ( mouseY - ( getYPosition() + m_topMargin ) ) / FixedWidthFontRenderer.FONT_HEIGHT;
int charX = (mouseX - (getXPosition() + m_leftMargin)) / FixedWidthFontRenderer.FONT_WIDTH;
int charY = (mouseY - (getYPosition() + m_topMargin)) / FixedWidthFontRenderer.FONT_HEIGHT;
charX = Math.min( Math.max( charX, 0 ), term.getWidth() - 1 );
charY = Math.min( Math.max( charY, 0 ), term.getHeight() - 1 );
computer.queueEvent( "mouse_click", new Object[]{
computer.queueEvent( "mouse_click", new Object[] {
button + 1, charX + 1, charY + 1
} );
@@ -222,7 +222,7 @@ public class WidgetTerminal extends Widget
if( m_focus )
{
// Queue the "key_up" event
queueEvent( "key_up", new Object[]{
queueEvent( "key_up", new Object[] {
key
} );
handled = true;
@@ -244,8 +244,8 @@ public class WidgetTerminal extends Widget
Terminal term = computer.getTerminal();
if( term != null )
{
int charX = ( mouseX - (getXPosition() + m_leftMargin)) / FixedWidthFontRenderer.FONT_WIDTH;
int charY = ( mouseY - (getYPosition() + m_topMargin)) / FixedWidthFontRenderer.FONT_HEIGHT;
int charX = (mouseX - (getXPosition() + m_leftMargin)) / FixedWidthFontRenderer.FONT_WIDTH;
int charY = (mouseY - (getYPosition() + m_topMargin)) / FixedWidthFontRenderer.FONT_HEIGHT;
charX = Math.min( Math.max( charX, 0 ), term.getWidth() - 1 );
charY = Math.min( Math.max( charY, 0 ), term.getHeight() - 1 );
@@ -253,7 +253,7 @@ public class WidgetTerminal extends Widget
{
if( m_focus )
{
computer.queueEvent( "mouse_up", new Object[]{
computer.queueEvent( "mouse_up", new Object[] {
m_lastClickButton + 1, charX + 1, charY + 1
} );
}
@@ -270,20 +270,20 @@ public class WidgetTerminal extends Widget
{
if( wheelChange < 0 )
{
computer.queueEvent( "mouse_scroll", new Object[]{
1, charX + 1, charY + 1
computer.queueEvent( "mouse_scroll", new Object[] {
1, charX + 1, charY + 1
} );
}
else if( wheelChange > 0 )
{
computer.queueEvent( "mouse_scroll", new Object[]{
-1, charX + 1, charY + 1
computer.queueEvent( "mouse_scroll", new Object[] {
-1, charX + 1, charY + 1
} );
}
if( m_lastClickButton >= 0 && ( charX != m_lastClickX || charY != m_lastClickY ) )
if( m_lastClickButton >= 0 && (charX != m_lastClickX || charY != m_lastClickY) )
{
computer.queueEvent( "mouse_drag", new Object[]{
computer.queueEvent( "mouse_drag", new Object[] {
m_lastClickButton + 1, charX + 1, charY + 1
} );
m_lastClickX = charX;
@@ -318,7 +318,7 @@ public class WidgetTerminal extends Widget
}
// Ctrl+R for reboot
if( Keyboard.isKeyDown(19) )
if( Keyboard.isKeyDown( 19 ) )
{
if( m_rebootTimer < TERMINATE_TIME )
{
@@ -339,7 +339,7 @@ public class WidgetTerminal extends Widget
}
// Ctrl+S for shutdown
if( Keyboard.isKeyDown(31) )
if( Keyboard.isKeyDown( 31 ) )
{
if( m_shutdownTimer < TERMINATE_TIME )
{
@@ -377,7 +377,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
@@ -405,7 +405,7 @@ public class WidgetTerminal extends Widget
}
if( m_bottomMargin > 0 )
{
fontRenderer.drawString( emptyLine, x, startY + 2 * m_bottomMargin + ( th - 1 ) * FixedWidthFontRenderer.FONT_HEIGHT, terminal.getTextColourLine( th - 1 ), terminal.getBackgroundColourLine( th - 1 ), m_leftMargin, m_rightMargin, greyscale, palette );
fontRenderer.drawString( emptyLine, x, startY + 2 * m_bottomMargin + (th - 1) * FixedWidthFontRenderer.FONT_HEIGHT, terminal.getTextColourLine( th - 1 ), terminal.getBackgroundColourLine( th - 1 ), m_leftMargin, m_rightMargin, greyscale, palette );
}
// Draw lines
@@ -424,16 +424,17 @@ public class WidgetTerminal extends Widget
TextBuffer cursorColour = new TextBuffer( "0123456789abcdef".charAt( terminal.getTextColour() ), 1 );
fontRenderer.drawString(
cursor,
x + FixedWidthFontRenderer.FONT_WIDTH * tx,
startY + m_topMargin + FixedWidthFontRenderer.FONT_HEIGHT * ty,
cursorColour, null,
0, 0,
greyscale,
palette
cursor,
x + FixedWidthFontRenderer.FONT_WIDTH * tx,
startY + m_topMargin + FixedWidthFontRenderer.FONT_HEIGHT * ty,
cursorColour, null,
0, 0,
greyscale,
palette
);
}
} else
}
else
{
// Draw a black background
mc.getTextureManager().bindTexture( background );
@@ -442,7 +443,8 @@ public class WidgetTerminal extends Widget
try
{
drawTexturedModalRect( startX, startY, 0, 0, getWidth(), getHeight() );
} finally
}
finally
{
GlStateManager.color( 1.0f, 1.0f, 1.0f, 1.0f );
}