Fix NetworkToolViewer stack overflow, saveguard against markDirty recursion.
fixes #3199
This commit is contained in:
parent
be65edbd5b
commit
56a5363528
3 changed files with 14 additions and 4 deletions
|
@ -54,13 +54,12 @@ public class NetworkToolViewer implements INetworkTool, IAEAppEngInventory
|
|||
@Override
|
||||
public void saveChanges()
|
||||
{
|
||||
this.inv.markDirty( -1 );
|
||||
this.inv.writeToNBT( Platform.openNbtData( this.is ), "inv" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory( IItemHandler inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack )
|
||||
{
|
||||
this.inv.writeToNBT( Platform.openNbtData( this.is ), "inv" );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -46,6 +46,7 @@ public class AppEngInternalAEInventory implements IInternalItemHandler, Iterable
|
|||
private final IAEItemStack[] inv;
|
||||
private final int size;
|
||||
private int maxStack;
|
||||
private boolean dirtyFlag = false;
|
||||
|
||||
public AppEngInternalAEInventory( final IAEAppEngInventory te, final int s )
|
||||
{
|
||||
|
@ -252,8 +253,10 @@ public class AppEngInternalAEInventory implements IInternalItemHandler, Iterable
|
|||
{
|
||||
if( this.te != null && Platform.isServer() )
|
||||
{
|
||||
this.dirtyFlag = true;
|
||||
this.te.onChangeInventory( this, slot, op, removed, inserted );
|
||||
this.te.saveChanges();
|
||||
this.dirtyFlag = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -282,7 +285,10 @@ public class AppEngInternalAEInventory implements IInternalItemHandler, Iterable
|
|||
|
||||
@Override
|
||||
public void markDirty( int slot )
|
||||
{
|
||||
if( !this.dirtyFlag )
|
||||
{
|
||||
this.fireOnChangeInventory( slot, InvOperation.DIRTY, ItemStack.EMPTY, ItemStack.EMPTY );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,6 +43,7 @@ public class AppEngInternalInventory extends ItemStackHandler implements IIntern
|
|||
private final int[] maxStack;
|
||||
private ItemStack previousStack = ItemStack.EMPTY;
|
||||
private IAEItemFilter filter;
|
||||
private boolean dirtyFlag = false;
|
||||
|
||||
public AppEngInternalInventory( final IAEAppEngInventory inventory, final int size, final int maxStack, IAEItemFilter filter )
|
||||
{
|
||||
|
@ -118,6 +119,7 @@ public class AppEngInternalInventory extends ItemStackHandler implements IIntern
|
|||
{
|
||||
if( this.getTileEntity() != null && this.eventsEnabled() )
|
||||
{
|
||||
this.dirtyFlag = true;
|
||||
ItemStack newStack = this.getStackInSlot( slot ).copy();
|
||||
ItemStack oldStack = this.previousStack;
|
||||
InvOperation op = InvOperation.SET;
|
||||
|
@ -141,6 +143,7 @@ public class AppEngInternalInventory extends ItemStackHandler implements IIntern
|
|||
this.getTileEntity().onChangeInventory( this, slot, op, oldStack, newStack );
|
||||
this.getTileEntity().saveChanges();
|
||||
this.previousStack = ItemStack.EMPTY;
|
||||
this.dirtyFlag = false;
|
||||
}
|
||||
super.onContentsChanged( slot );
|
||||
}
|
||||
|
@ -158,10 +161,12 @@ public class AppEngInternalInventory extends ItemStackHandler implements IIntern
|
|||
@Override
|
||||
public void markDirty( final int slot )
|
||||
{
|
||||
if( this.getTileEntity() != null && this.eventsEnabled() )
|
||||
if( this.getTileEntity() != null && this.eventsEnabled() && !this.dirtyFlag )
|
||||
{
|
||||
this.dirtyFlag = true;
|
||||
this.getTileEntity().onChangeInventory( this, slot, InvOperation.DIRTY, ItemStack.EMPTY, ItemStack.EMPTY );
|
||||
this.getTileEntity().saveChanges();
|
||||
this.dirtyFlag = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue