From bfb4f88304a52d4beabc1252f0b7450dbca318c8 Mon Sep 17 00:00:00 2001 From: SquidDev Date: Fri, 6 Oct 2017 12:04:49 +0100 Subject: [PATCH] Fix the printer clearing the previous page When printing on top of an already printed page, the previous contents should be preserved. However, this did not occur as the stack had been shrunk and so the item was no longer considered a printout. Closes SquidDev-CC/ComputerCraft#2 --- .../peripheral/printer/TilePrinter.java | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/main/java/dan200/computercraft/shared/peripheral/printer/TilePrinter.java b/src/main/java/dan200/computercraft/shared/peripheral/printer/TilePrinter.java index ad1442aad..2aa6c7c98 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/printer/TilePrinter.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/printer/TilePrinter.java @@ -493,21 +493,6 @@ public class TilePrinter extends TilePeripheralBase ItemStack paperStack = m_inventory.get( i ); if( !paperStack.isEmpty() && isPaper(paperStack) ) { - // Decrement ink - inkStack.shrink( 1 ); - if( inkStack.isEmpty() ) - { - m_inventory.set( 0, ItemStack.EMPTY ); - } - - // Decrement paper - paperStack.shrink( 1 ); - if( paperStack.isEmpty() ) - { - m_inventory.set( i, ItemStack.EMPTY ); - updateAnim(); - } - // Setup the new page int colour = inkStack.getItemDamage(); if( colour >= 0 && colour < 16 ) { @@ -532,6 +517,21 @@ public class TilePrinter extends TilePeripheralBase m_pageTitle = ""; } m_page.setCursorPos( 0, 0 ); + + // Decrement ink + inkStack.shrink( 1 ); + if( inkStack.isEmpty() ) + { + m_inventory.set( 0, ItemStack.EMPTY ); + } + + // Decrement paper + paperStack.shrink( 1 ); + if( paperStack.isEmpty() ) + { + m_inventory.set( i, ItemStack.EMPTY ); + updateAnim(); + } markDirty(); m_printing = true;