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