Use tags to check if something is a dye

We half did this already, just needed to change a couple of checks.
Closes #541.
This commit is contained in:
SquidDev 2020-09-16 21:27:59 +01:00
parent 275ca58a82
commit 6f868849ab
3 changed files with 8 additions and 7 deletions

View File

@ -13,7 +13,6 @@
import net.minecraft.inventory.Inventory;
import net.minecraft.inventory.container.Container;
import net.minecraft.inventory.container.Slot;
import net.minecraft.item.DyeItem;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIntArray;
import net.minecraft.util.IntArray;
@ -95,7 +94,7 @@ public ItemStack transferStackInSlot( @Nonnull PlayerEntity player, int index )
else
{
// Transfer from inventory to printer
if( stack.getItem() instanceof DyeItem )
if( TilePrinter.isInk( stack ) )
{
if( !mergeItemStack( stack, 0, 1, false ) ) return ItemStack.EMPTY;
}

View File

@ -300,9 +300,9 @@ void setPageTitle( String title )
}
}
private static boolean isInk( @Nonnull ItemStack stack )
static boolean isInk( @Nonnull ItemStack stack )
{
return stack.getItem() instanceof DyeItem;
return ColourUtils.getStackColour( stack ) != null;
}
private static boolean isPaper( @Nonnull ItemStack stack )
@ -321,7 +321,8 @@ private boolean canInputPage()
private boolean inputPage()
{
ItemStack inkStack = m_inventory.get( 0 );
if( !isInk( inkStack ) ) return false;
DyeColor dye = ColourUtils.getStackColour( inkStack );
if( dye == null ) return false;
for( int i = 1; i < 7; i++ )
{
@ -329,8 +330,7 @@ private boolean inputPage()
if( paperStack.isEmpty() || !isPaper( paperStack ) ) continue;
// Setup the new page
DyeColor dye = ColourUtils.getStackColour( inkStack );
m_page.setTextColour( dye != null ? dye.getId() : 15 );
m_page.setTextColour( dye.getId() );
m_page.clear();
if( paperStack.getItem() instanceof ItemPrintout )

View File

@ -40,6 +40,8 @@ private ColourUtils() {}
public static DyeColor getStackColour( ItemStack stack )
{
if( stack.isEmpty() ) return null;
for( int i = 0; i < DYES.length; i++ )
{
Tag<Item> dye = DYES[i];