1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-12-12 19:20:29 +00:00

Remove getColour and setColour methods from ITurtleAccess

This allows us to remove the m_Colour field from TurtleBrain
This commit is contained in:
SquidDev 2017-05-13 22:42:31 +01:00
parent 8c36eccfef
commit 6426255bd4
2 changed files with 15 additions and 48 deletions

View File

@ -117,31 +117,12 @@ public interface ITurtleAccess
*/
void setSelectedSlot( int slot );
/**
* Sets the colour of the turtle, as if the player had dyed it with a dye item.
*
* @param dyeColour 0-15 to dye the turtle one of the 16 standard Minecraft <em>dye</em> colours, or -1 to remove
* the dye from the turtle.
* @see #getDyeColour()
* @see #setColour(int)
*/
void setDyeColour( int dyeColour );
/**
* Gets the colour the turtle has been dyed.
*
* @return 0-15 if the turtle has been dyed one of the 16 standard Minecraft <em>dye</em> colours, -1 if the turtle
* is clean or has no corresponding dye.
* @see #setDyeColour(int)
* @see #getColour()
*/
int getDyeColour();
/**
* Set the colour of the turtle to a RGB number.
*
* @param colour The colour this turtle should be changed to. This should be a RGB colour between {@code 0x000000}
* and {@code 0xFFFFFF} or -1 to reset to the default colour.
* @see #getColour()
*/
void setColour( int colour );
@ -150,6 +131,7 @@ public interface ITurtleAccess
*
* @return The colour this turtle is. This will be a RGB colour between {@code 0x000000} and {@code 0xFFFFFF} or
* -1 if it has no colour.
* @see #setColour(int)
*/
int getColour();

View File

@ -113,7 +113,6 @@ public class TurtleBrain implements ITurtleAccess
private int m_selectedSlot;
private int m_fuelLevel;
private Colour m_colour;
private int m_colourHex;
private ResourceLocation m_overlay;
@ -136,7 +135,6 @@ public class TurtleBrain implements ITurtleAccess
m_selectedSlot = 0;
m_fuelLevel = 0;
m_colour = null;
m_colourHex = -1;
m_overlay = null;
@ -217,7 +215,6 @@ public class TurtleBrain implements ITurtleAccess
}
// Read colour
m_colour = ColourUtils.getColour( nbttagcompound );
m_colourHex = ColourUtils.getHexColour( nbttagcompound );
// Read overlay
@ -317,11 +314,7 @@ public class TurtleBrain implements ITurtleAccess
}
// Write colour
if( m_colour != null )
{
nbttagcompound.setInteger( "colourIndex", m_colour.ordinal() );
}
else if( m_colourHex != -1 )
if( m_colourHex != -1 )
{
nbttagcompound.setInteger( "colour", m_colourHex );
}
@ -380,11 +373,7 @@ public class TurtleBrain implements ITurtleAccess
}
// Colour
if( m_colour != null )
{
nbttagcompound.setInteger( "colourIndex", m_colour.ordinal() );
}
else if( m_colourHex != -1 )
if( m_colourHex != -1 )
{
nbttagcompound.setInteger( "colour", m_colourHex );
}
@ -440,7 +429,6 @@ public class TurtleBrain implements ITurtleAccess
// Colour
m_colourHex = ColourUtils.getHexColour( nbttagcompound );
m_colour = ColourUtils.getColour( nbttagcompound );
// Overlay
if( nbttagcompound.hasKey( "overlay_mod" ) && nbttagcompound.hasKey( "overlay_path" ) )
@ -771,12 +759,6 @@ public class TurtleBrain implements ITurtleAccess
m_owner.updateBlock();
}
@Override
public int getDyeColour()
{
return m_colour != null ? m_colour.ordinal() : -1;
}
public ResourceLocation getOverlay()
{
return m_overlay;
@ -791,18 +773,23 @@ public class TurtleBrain implements ITurtleAccess
}
}
@Override
public int getDyeColour()
{
if( m_colourHex == -1 ) return -1;
Colour colour = Colour.fromHex( m_colourHex );
return colour == null ? -1 : colour.ordinal();
}
public void setDyeColour( int dyeColour )
{
Colour newColour = null;
int newColour = -1;
if( dyeColour >= 0 && dyeColour < 16 )
{
newColour = Colour.values()[ dyeColour ];
newColour = Colour.values()[ dyeColour ].getHex();
}
if( m_colour != newColour )
if( m_colourHex != newColour )
{
m_colour = newColour;
m_colourHex = newColour == null ? -1 : newColour.getHex();
m_colourHex = newColour;
m_owner.updateBlock();
}
}
@ -815,14 +802,12 @@ public class TurtleBrain implements ITurtleAccess
if( m_colourHex != colour )
{
m_colourHex = colour;
m_colour = Colour.fromHex( colour );
m_owner.updateBlock();
}
}
else if( m_colourHex != -1 )
{
m_colourHex = -1;
m_colour = null;
m_owner.updateBlock();
}
}