mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-11-26 01:44:48 +00:00
Fix to getPalletteColour
Done as @dan200 specified in #287. Closes #287.
This commit is contained in:
@@ -240,7 +240,7 @@ public class MonitorPeripheral implements IPeripheral
|
||||
{
|
||||
int colour = 15 - dan200.computercraft.core.apis.TermAPI.parseColour( args );
|
||||
int hex = ((Double)args[1]).intValue();
|
||||
float[] rgb = Palette.decodeRGB8( hex );
|
||||
double[] rgb = Palette.decodeRGB8( hex );
|
||||
dan200.computercraft.core.apis.TermAPI.setColour( terminal, colour, rgb[0], rgb[1], rgb[2] );
|
||||
return null;
|
||||
}
|
||||
@@ -248,9 +248,9 @@ public class MonitorPeripheral implements IPeripheral
|
||||
if (args.length >= 4 && args[0] instanceof Double && args[1] instanceof Double && args[2] instanceof Double && args[3] instanceof Double)
|
||||
{
|
||||
int colour = 15 - dan200.computercraft.core.apis.TermAPI.parseColour( args );
|
||||
float r = ((Double)args[1]).floatValue();
|
||||
float g = ((Double)args[2]).floatValue();
|
||||
float b = ((Double)args[3]).floatValue();
|
||||
double r = (Double)args[1];
|
||||
double g = (Double)args[2];
|
||||
double b = (Double)args[3];
|
||||
dan200.computercraft.core.apis.TermAPI.setColour( terminal, colour, r, g, b );
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
public class Palette
|
||||
{
|
||||
private static final int PALETTE_SIZE = 16;
|
||||
private final float[][] colours = new float[PALETTE_SIZE][3];
|
||||
private final double[][] colours = new double[PALETTE_SIZE][3];
|
||||
|
||||
public static final Palette DEFAULT = new Palette();
|
||||
|
||||
@@ -15,7 +15,7 @@ public class Palette
|
||||
resetColours();
|
||||
}
|
||||
|
||||
public void setColour(int i, float r, float g, float b)
|
||||
public void setColour(int i, double r, double g, double b)
|
||||
{
|
||||
if( i >= 0 && i < colours.length )
|
||||
{
|
||||
@@ -30,7 +30,7 @@ public class Palette
|
||||
setColour( i, colour.getR(), colour.getG(), colour.getB() );
|
||||
}
|
||||
|
||||
public float[] getColour( int i )
|
||||
public double[] getColour( int i )
|
||||
{
|
||||
if( i >= 0 && i < colours.length )
|
||||
{
|
||||
@@ -55,7 +55,7 @@ public class Palette
|
||||
}
|
||||
}
|
||||
|
||||
public static int encodeRGB8( float[] rgb )
|
||||
public static int encodeRGB8( double[] rgb )
|
||||
{
|
||||
int r = (int)( rgb[0] * 255 ) & 0xFF;
|
||||
int g = (int)( rgb[1] * 255 ) & 0xFF;
|
||||
@@ -64,9 +64,9 @@ public class Palette
|
||||
return ( r << 16 ) | ( g << 8 ) | b;
|
||||
}
|
||||
|
||||
public static float[] decodeRGB8( int rgb )
|
||||
public static double[] decodeRGB8( int rgb )
|
||||
{
|
||||
return new float[]
|
||||
return new double[]
|
||||
{
|
||||
(( rgb >> 16 ) & 0xFF) / 255.0f,
|
||||
(( rgb >> 8 ) & 0xFF) / 255.0f,
|
||||
|
||||
Reference in New Issue
Block a user