Basic reformat, hit once, hope never again

This commit is contained in:
thatsIch
2015-04-03 08:54:31 +02:00
parent 4ff1631f89
commit d34c988c88
886 changed files with 31400 additions and 30990 deletions
@@ -18,6 +18,7 @@
package appeng.tile.inventory;
import java.util.Iterator;
import net.minecraft.entity.player.EntityPlayer;
@@ -33,58 +34,118 @@ import appeng.util.item.AEItemStack;
import appeng.util.iterators.AEInvIterator;
import appeng.util.iterators.InvIterator;
public class AppEngInternalAEInventory implements IInventory, Iterable<ItemStack>
{
protected final IAEAppEngInventory te;
protected final IAEItemStack[] inv;
final int size;
int maxStack;
protected final IAEItemStack[] inv;
public boolean isEmpty()
public AppEngInternalAEInventory( IAEAppEngInventory _te, int s )
{
for (int x = 0; x < this.size; x++)
if ( this.getStackInSlot( x ) != null )
return false;
return true;
}
public AppEngInternalAEInventory(IAEAppEngInventory _te, int s) {
this.te = _te;
this.size = s;
this.maxStack = 64;
this.inv = new IAEItemStack[s];
}
public void setMaxStackSize(int s)
public boolean isEmpty()
{
for( int x = 0; x < this.size; x++ )
if( this.getStackInSlot( x ) != null )
return false;
return true;
}
public void setMaxStackSize( int s )
{
this.maxStack = s;
}
public IAEItemStack getAEStackInSlot(int var1)
public IAEItemStack getAEStackInSlot( int var1 )
{
return this.inv[var1];
}
@Override
public ItemStack getStackInSlot(int var1)
public void writeToNBT( NBTTagCompound data, String name )
{
if ( this.inv[var1] == null )
NBTTagCompound c = new NBTTagCompound();
this.writeToNBT( c );
data.setTag( name, c );
}
public void writeToNBT( NBTTagCompound target )
{
for( int x = 0; x < this.size; x++ )
{
try
{
NBTTagCompound c = new NBTTagCompound();
if( this.inv[x] != null )
{
this.inv[x].writeToNBT( c );
}
target.setTag( "#" + x, c );
}
catch( Exception ignored )
{
}
}
}
public void readFromNBT( NBTTagCompound data, String name )
{
NBTTagCompound c = data.getCompoundTag( name );
if( c != null )
this.readFromNBT( c );
}
public void readFromNBT( NBTTagCompound target )
{
for( int x = 0; x < this.size; x++ )
{
try
{
NBTTagCompound c = target.getCompoundTag( "#" + x );
if( c != null )
this.inv[x] = AEItemStack.loadItemStackFromNBT( c );
}
catch( Exception e )
{
AELog.error( e );
}
}
}
@Override
public int getSizeInventory()
{
return this.size;
}
@Override
public ItemStack getStackInSlot( int var1 )
{
if( this.inv[var1] == null )
return null;
return this.inv[var1].getItemStack();
}
@Override
public ItemStack decrStackSize(int slot, int qty)
public ItemStack decrStackSize( int slot, int qty )
{
if ( this.inv[slot] != null )
if( this.inv[slot] != null )
{
ItemStack split = this.getStackInSlot( slot );
ItemStack ns = null;
if ( qty >= split.stackSize )
if( qty >= split.stackSize )
{
ns = this.getStackInSlot( slot );
this.inv[slot] = null;
@@ -92,7 +153,7 @@ public class AppEngInternalAEInventory implements IInventory, Iterable<ItemStack
else
ns = split.splitStack( qty );
if ( this.te != null && Platform.isServer() )
if( this.te != null && Platform.isServer() )
{
this.te.onChangeInventory( this, slot, InvOperation.decreaseStackSize, ns, null );
}
@@ -104,31 +165,31 @@ public class AppEngInternalAEInventory implements IInventory, Iterable<ItemStack
}
@Override
public ItemStack getStackInSlotOnClosing(int var1)
public ItemStack getStackInSlotOnClosing( int var1 )
{
return null;
}
@Override
public void setInventorySlotContents(int slot, ItemStack newItemStack)
public void setInventorySlotContents( int slot, ItemStack newItemStack )
{
ItemStack oldStack = this.getStackInSlot( slot );
this.inv[slot] = AEApi.instance().storage().createItemStack( newItemStack );
if ( this.te != null && Platform.isServer() )
if( this.te != null && Platform.isServer() )
{
ItemStack removed = oldStack;
ItemStack added = newItemStack;
if ( oldStack != null && newItemStack != null && Platform.isSameItem( oldStack, newItemStack ) )
if( oldStack != null && newItemStack != null && Platform.isSameItem( oldStack, newItemStack ) )
{
if ( oldStack.stackSize > newItemStack.stackSize )
if( oldStack.stackSize > newItemStack.stackSize )
{
removed = removed.copy();
removed.stackSize -= newItemStack.stackSize;
added = null;
}
else if ( oldStack.stackSize < newItemStack.stackSize )
else if( oldStack.stackSize < newItemStack.stackSize )
{
added = added.copy();
added.stackSize -= oldStack.stackSize;
@@ -145,12 +206,15 @@ public class AppEngInternalAEInventory implements IInventory, Iterable<ItemStack
}
@Override
public void markDirty()
public String getInventoryName()
{
if ( this.te != null && Platform.isServer() )
{
this.te.onChangeInventory( this, -1, InvOperation.markDirty, null, null );
}
return "appeng-internal";
}
@Override
public boolean hasCustomInventoryName()
{
return false;
}
@Override
@@ -160,7 +224,16 @@ public class AppEngInternalAEInventory implements IInventory, Iterable<ItemStack
}
@Override
public boolean isUseableByPlayer(EntityPlayer var1)
public void markDirty()
{
if( this.te != null && Platform.isServer() )
{
this.te.onChangeInventory( this, -1, InvOperation.markDirty, null, null );
}
}
@Override
public boolean isUseableByPlayer( EntityPlayer var1 )
{
return true;
}
@@ -175,80 +248,8 @@ public class AppEngInternalAEInventory implements IInventory, Iterable<ItemStack
{
}
public void writeToNBT(NBTTagCompound target)
{
for (int x = 0; x < this.size; x++)
{
try
{
NBTTagCompound c = new NBTTagCompound();
if ( this.inv[x] != null )
{
this.inv[x].writeToNBT( c );
}
target.setTag( "#" + x, c );
}
catch (Exception ignored)
{
}
}
}
public void readFromNBT(NBTTagCompound target)
{
for (int x = 0; x < this.size; x++)
{
try
{
NBTTagCompound c = target.getCompoundTag( "#" + x );
if ( c != null )
this.inv[x] = AEItemStack.loadItemStackFromNBT( c );
}
catch (Exception e)
{
AELog.error( e );
}
}
}
public void writeToNBT(NBTTagCompound data, String name)
{
NBTTagCompound c = new NBTTagCompound();
this.writeToNBT( c );
data.setTag( name, c );
}
public void readFromNBT(NBTTagCompound data, String name)
{
NBTTagCompound c = data.getCompoundTag( name );
if ( c != null )
this.readFromNBT( c );
}
@Override
public int getSizeInventory()
{
return this.size;
}
@Override
public String getInventoryName()
{
return "appeng-internal";
}
@Override
public boolean hasCustomInventoryName()
{
return false;
}
@Override
public boolean isItemValidForSlot(int i, ItemStack itemstack)
public boolean isItemValidForSlot( int i, ItemStack itemstack )
{
return true;
}
@@ -57,8 +57,8 @@ public class AppEngInternalInventory implements IInventory, Iterable<ItemStack>
public boolean isEmpty()
{
for (int x = 0; x < this.size; x++)
if ( this.getStackInSlot( x ) != null )
for( int x = 0; x < this.size; x++ )
if( this.getStackInSlot( x ) != null )
return false;
return true;
}
@@ -78,12 +78,12 @@ public class AppEngInternalInventory implements IInventory, Iterable<ItemStack>
@Override
public ItemStack decrStackSize( int slot, int qty )
{
if ( this.inv[slot] != null )
if( this.inv[slot] != null )
{
ItemStack split = this.getStackInSlot( slot );
ItemStack ns = null;
if ( qty >= split.stackSize )
if( qty >= split.stackSize )
{
ns = this.inv[slot];
this.inv[slot] = null;
@@ -91,7 +91,7 @@ public class AppEngInternalInventory implements IInventory, Iterable<ItemStack>
else
ns = split.splitStack( qty );
if ( this.te != null && this.eventsEnabled() )
if( this.te != null && this.eventsEnabled() )
{
this.te.onChangeInventory( this, slot, InvOperation.decreaseStackSize, ns, null );
}
@@ -120,20 +120,20 @@ public class AppEngInternalInventory implements IInventory, Iterable<ItemStack>
ItemStack oldStack = this.inv[slot];
this.inv[slot] = newItemStack;
if ( this.te != null && this.eventsEnabled() )
if( this.te != null && this.eventsEnabled() )
{
ItemStack removed = oldStack;
ItemStack added = newItemStack;
if ( oldStack != null && newItemStack != null && Platform.isSameItem( oldStack, newItemStack ) )
if( oldStack != null && newItemStack != null && Platform.isSameItem( oldStack, newItemStack ) )
{
if ( oldStack.stackSize > newItemStack.stackSize )
if( oldStack.stackSize > newItemStack.stackSize )
{
removed = removed.copy();
removed.stackSize -= newItemStack.stackSize;
added = null;
}
else if ( oldStack.stackSize < newItemStack.stackSize )
else if( oldStack.stackSize < newItemStack.stackSize )
{
added = added.copy();
added.stackSize -= oldStack.stackSize;
@@ -172,7 +172,7 @@ public class AppEngInternalInventory implements IInventory, Iterable<ItemStack>
@Override
public void markDirty()
{
if ( this.te != null && this.eventsEnabled() )
if( this.te != null && this.eventsEnabled() )
{
this.te.onChangeInventory( this, -1, InvOperation.markDirty, null, null );
}
@@ -208,7 +208,7 @@ public class AppEngInternalInventory implements IInventory, Iterable<ItemStack>
// for guis...
public void markDirty( int slotIndex )
{
if ( this.te != null && this.eventsEnabled() )
if( this.te != null && this.eventsEnabled() )
{
this.te.onChangeInventory( this, slotIndex, InvOperation.markDirty, null, null );
}
@@ -223,20 +223,20 @@ public class AppEngInternalInventory implements IInventory, Iterable<ItemStack>
public void writeToNBT( NBTTagCompound target )
{
for ( int x = 0; x < this.size; x++ )
for( int x = 0; x < this.size; x++ )
{
try
{
NBTTagCompound c = new NBTTagCompound();
if ( this.inv[x] != null )
if( this.inv[x] != null )
{
this.inv[x].writeToNBT( c );
}
target.setTag( "#" + x, c );
}
catch ( Exception ignored )
catch( Exception ignored )
{
}
}
@@ -245,22 +245,22 @@ public class AppEngInternalInventory implements IInventory, Iterable<ItemStack>
public void readFromNBT( NBTTagCompound data, String name )
{
NBTTagCompound c = data.getCompoundTag( name );
if ( c != null )
if( c != null )
this.readFromNBT( c );
}
public void readFromNBT( NBTTagCompound target )
{
for ( int x = 0; x < this.size; x++ )
for( int x = 0; x < this.size; x++ )
{
try
{
NBTTagCompound c = target.getCompoundTag( "#" + x );
if ( c != null )
if( c != null )
this.inv[x] = ItemStack.loadItemStackFromNBT( c );
}
catch ( Exception e )
catch( Exception e )
{
AELog.error( e );
}
@@ -18,70 +18,21 @@
package appeng.tile.inventory;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
public class AppEngNullInventory implements IInventory
{
public AppEngNullInventory() {
}
@Override
public ItemStack getStackInSlot(int var1)
{
return null;
}
@Override
public ItemStack decrStackSize(int slot, int qty)
{
return null;
}
@Override
public ItemStack getStackInSlotOnClosing(int var1)
{
return null;
}
@Override
public void setInventorySlotContents(int slot, ItemStack newItemStack)
{
}
@Override
public void markDirty()
{
}
@Override
public int getInventoryStackLimit()
{
return 0;
}
@Override
public boolean isUseableByPlayer(EntityPlayer var1)
{
return false;
}
@Override
public void openInventory()
public AppEngNullInventory()
{
}
@Override
public void closeInventory()
{
}
public void writeToNBT(NBTTagCompound target)
public void writeToNBT( NBTTagCompound target )
{
}
@@ -91,6 +42,30 @@ public class AppEngNullInventory implements IInventory
return 0;
}
@Override
public ItemStack getStackInSlot( int var1 )
{
return null;
}
@Override
public ItemStack decrStackSize( int slot, int qty )
{
return null;
}
@Override
public ItemStack getStackInSlotOnClosing( int var1 )
{
return null;
}
@Override
public void setInventorySlotContents( int slot, ItemStack newItemStack )
{
}
@Override
public String getInventoryName()
{
@@ -104,9 +79,36 @@ public class AppEngNullInventory implements IInventory
}
@Override
public boolean isItemValidForSlot(int i, ItemStack itemstack)
public int getInventoryStackLimit()
{
return 0;
}
@Override
public void markDirty()
{
}
@Override
public boolean isUseableByPlayer( EntityPlayer var1 )
{
return false;
}
@Override
public void openInventory()
{
}
@Override
public void closeInventory()
{
}
@Override
public boolean isItemValidForSlot( int i, ItemStack itemstack )
{
return false;
}
}
@@ -18,14 +18,15 @@
package appeng.tile.inventory;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
public interface IAEAppEngInventory
{
void saveChanges();
void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack);
void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack );
}
@@ -18,6 +18,7 @@
package appeng.tile.inventory;
public enum InvOperation
{
decreaseStackSize, setInventorySlotContents, markDirty