mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-10-20 00:17:38 +00:00
Allow dying turtles arbitrary colours
- Makes ITurtleItem implement IColourableItem - Only cache one turtle item model for all colours, rather than one for each colour. - Allow ITurtleAccess to set an arbitrary colour.
This commit is contained in:
@@ -1,10 +1,14 @@
|
||||
package dan200.computercraft.shared.util;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
|
||||
public class ColourUtils
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public final class ColourUtils
|
||||
{
|
||||
private static final String[] DYES = new String[] {
|
||||
"dyeBlack", "dyeRed", "dyeGreen", "dyeBrown",
|
||||
@@ -34,4 +38,37 @@ public class ColourUtils
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static int getHexColour( @Nonnull NBTTagCompound tag )
|
||||
{
|
||||
if( tag.hasKey( "colourIndex", Constants.NBT.TAG_ANY_NUMERIC ) )
|
||||
{
|
||||
return Colour.VALUES[ tag.getInteger( "colourIndex" ) & 0xF ].getHex();
|
||||
}
|
||||
else if( tag.hasKey( "colour", Constants.NBT.TAG_ANY_NUMERIC ) )
|
||||
{
|
||||
return tag.getInteger( "colour" );
|
||||
}
|
||||
else if( tag.hasKey( "color", Constants.NBT.TAG_ANY_NUMERIC ) )
|
||||
{
|
||||
return tag.getInteger( "color" );
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
public static Colour getColour( @Nonnull NBTTagCompound tag )
|
||||
{
|
||||
if( tag.hasKey( "colourIndex", Constants.NBT.TAG_ANY_NUMERIC ) )
|
||||
{
|
||||
return Colour.fromInt( tag.getInteger( "colourIndex" ) & 0xF );
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user