mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-11-13 11:47:10 +00:00
Converted tabs to spaces throughout
This commit is contained in:
@@ -26,6 +26,6 @@ public class CreativeTabMain extends CreativeTabs
|
||||
@Override
|
||||
public String getTranslatedTabLabel()
|
||||
{
|
||||
return getTabLabel();
|
||||
return getTabLabel();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,6 @@ public class CreativeTabTreasure extends CreativeTabs
|
||||
@Override
|
||||
public String getTranslatedTabLabel()
|
||||
{
|
||||
return getTabLabel();
|
||||
return getTabLabel();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,61 +4,61 @@ import java.io.*;
|
||||
|
||||
public class IDAssigner
|
||||
{
|
||||
private IDAssigner()
|
||||
{
|
||||
}
|
||||
|
||||
public static int getNextIDFromDirectory( File dir )
|
||||
{
|
||||
return getNextID( dir, true );
|
||||
}
|
||||
|
||||
public static int getNextIDFromFile( File file )
|
||||
{
|
||||
return getNextID( file, false );
|
||||
}
|
||||
|
||||
private static int getNextID( File location, boolean directory )
|
||||
{
|
||||
// Determine where to locate ID file
|
||||
File lastidFile = null;
|
||||
if( directory )
|
||||
{
|
||||
location.mkdirs();
|
||||
lastidFile = new File( location, "lastid.txt" );
|
||||
}
|
||||
else
|
||||
{
|
||||
location.getParentFile().mkdirs();
|
||||
lastidFile = location;
|
||||
}
|
||||
|
||||
// Try to determine the id
|
||||
int id = 0;
|
||||
if( !lastidFile.exists() )
|
||||
{
|
||||
// If an ID file doesn't exist, determine it from the file structure
|
||||
if( directory && location.exists() && location.isDirectory() )
|
||||
{
|
||||
String[] contents = location.list();
|
||||
for( int i=0; i<contents.length; ++i )
|
||||
{
|
||||
try {
|
||||
int number = Integer.parseInt( contents[i] );
|
||||
id = Math.max( number + 1, id );
|
||||
} catch( NumberFormatException e ) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// If an ID file does exist, parse the file to get the ID string
|
||||
String idString = "0";
|
||||
try
|
||||
{
|
||||
FileInputStream in = new FileInputStream( lastidFile );
|
||||
private IDAssigner()
|
||||
{
|
||||
}
|
||||
|
||||
public static int getNextIDFromDirectory( File dir )
|
||||
{
|
||||
return getNextID( dir, true );
|
||||
}
|
||||
|
||||
public static int getNextIDFromFile( File file )
|
||||
{
|
||||
return getNextID( file, false );
|
||||
}
|
||||
|
||||
private static int getNextID( File location, boolean directory )
|
||||
{
|
||||
// Determine where to locate ID file
|
||||
File lastidFile = null;
|
||||
if( directory )
|
||||
{
|
||||
location.mkdirs();
|
||||
lastidFile = new File( location, "lastid.txt" );
|
||||
}
|
||||
else
|
||||
{
|
||||
location.getParentFile().mkdirs();
|
||||
lastidFile = location;
|
||||
}
|
||||
|
||||
// Try to determine the id
|
||||
int id = 0;
|
||||
if( !lastidFile.exists() )
|
||||
{
|
||||
// If an ID file doesn't exist, determine it from the file structure
|
||||
if( directory && location.exists() && location.isDirectory() )
|
||||
{
|
||||
String[] contents = location.list();
|
||||
for( int i=0; i<contents.length; ++i )
|
||||
{
|
||||
try {
|
||||
int number = Integer.parseInt( contents[i] );
|
||||
id = Math.max( number + 1, id );
|
||||
} catch( NumberFormatException e ) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// If an ID file does exist, parse the file to get the ID string
|
||||
String idString = "0";
|
||||
try
|
||||
{
|
||||
FileInputStream in = new FileInputStream( lastidFile );
|
||||
InputStreamReader isr;
|
||||
try
|
||||
{
|
||||
@@ -68,7 +68,7 @@ public class IDAssigner
|
||||
{
|
||||
isr = new InputStreamReader( in );
|
||||
}
|
||||
BufferedReader br = new BufferedReader( isr );
|
||||
BufferedReader br = new BufferedReader( isr );
|
||||
try
|
||||
{
|
||||
idString = br.readLine();
|
||||
@@ -77,38 +77,38 @@ public class IDAssigner
|
||||
{
|
||||
br.close();
|
||||
}
|
||||
}
|
||||
catch( IOException e )
|
||||
{
|
||||
e.printStackTrace();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
catch( IOException e )
|
||||
{
|
||||
e.printStackTrace();
|
||||
return 0;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
id = Integer.parseInt( idString ) + 1;
|
||||
}
|
||||
catch( NumberFormatException e )
|
||||
{
|
||||
e.printStackTrace();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Write the lastID file out with the new value
|
||||
try
|
||||
{
|
||||
BufferedWriter out = new BufferedWriter( new FileWriter( lastidFile, false ) );
|
||||
out.write( Integer.toString( id ) );
|
||||
try
|
||||
{
|
||||
id = Integer.parseInt( idString ) + 1;
|
||||
}
|
||||
catch( NumberFormatException e )
|
||||
{
|
||||
e.printStackTrace();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Write the lastID file out with the new value
|
||||
try
|
||||
{
|
||||
BufferedWriter out = new BufferedWriter( new FileWriter( lastidFile, false ) );
|
||||
out.write( Integer.toString( id ) );
|
||||
out.newLine();
|
||||
out.close();
|
||||
}
|
||||
catch( IOException e )
|
||||
{
|
||||
System.out.println( "An error occured while trying to create the computer folder. Please check you have relevant permissions." );
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return id;
|
||||
}
|
||||
out.close();
|
||||
}
|
||||
catch( IOException e )
|
||||
{
|
||||
System.out.println( "An error occured while trying to create the computer folder. Please check you have relevant permissions." );
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,5 +10,5 @@ import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IEntityDropConsumer
|
||||
{
|
||||
public void consumeDrop( Entity dropper, ItemStack drop );
|
||||
public void consumeDrop( Entity dropper, ItemStack drop );
|
||||
}
|
||||
|
||||
@@ -12,20 +12,20 @@ import net.minecraft.world.World;
|
||||
|
||||
public class ImpostorRecipe extends ShapedRecipes
|
||||
{
|
||||
public ImpostorRecipe( int width, int height, ItemStack[] ingredients, ItemStack result )
|
||||
{
|
||||
super( width, height, ingredients, result );
|
||||
}
|
||||
public ImpostorRecipe( int width, int height, ItemStack[] ingredients, ItemStack result )
|
||||
{
|
||||
super( width, height, ingredients, result );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches( InventoryCrafting inv, World world )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public boolean matches( InventoryCrafting inv, World world )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getCraftingResult( InventoryCrafting _inventory )
|
||||
{
|
||||
return null;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,20 +16,20 @@ import java.util.Arrays;
|
||||
|
||||
public class ImpostorShapelessRecipe extends ShapelessRecipes
|
||||
{
|
||||
public ImpostorShapelessRecipe( ItemStack result, Object[] ingredients )
|
||||
{
|
||||
super( result, new ArrayList(Arrays.asList( ingredients )));
|
||||
}
|
||||
public ImpostorShapelessRecipe( ItemStack result, Object[] ingredients )
|
||||
{
|
||||
super( result, new ArrayList(Arrays.asList( ingredients )));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches( InventoryCrafting inv, World world )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean matches( InventoryCrafting inv, World world )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public ItemStack getCraftingResult( InventoryCrafting _inventory )
|
||||
{
|
||||
return null;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
public class InventoryUtil
|
||||
{
|
||||
// Methods for comparing things:
|
||||
// Methods for comparing things:
|
||||
|
||||
public static boolean areItemsEqual( ItemStack a, ItemStack b )
|
||||
{
|
||||
@@ -37,26 +37,26 @@ public class InventoryUtil
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean areItemsStackable( ItemStack a, ItemStack b )
|
||||
{
|
||||
if( a == b )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if( a != null && b != null && a.getItem() == b.getItem() )
|
||||
{
|
||||
if( a.getItemDamage() == b.getItemDamage() )
|
||||
{
|
||||
if( (a.getTagCompound() == null && b.getTagCompound() == null) ||
|
||||
(a.getTagCompound() != null && b.getTagCompound() != null && a.getTagCompound().equals( b.getTagCompound() ) ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static boolean areItemsStackable( ItemStack a, ItemStack b )
|
||||
{
|
||||
if( a == b )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if( a != null && b != null && a.getItem() == b.getItem() )
|
||||
{
|
||||
if( a.getItemDamage() == b.getItemDamage() )
|
||||
{
|
||||
if( (a.getTagCompound() == null && b.getTagCompound() == null) ||
|
||||
(a.getTagCompound() != null && b.getTagCompound() != null && a.getTagCompound().equals( b.getTagCompound() ) ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static ItemStack copyItem( ItemStack a )
|
||||
{
|
||||
@@ -127,17 +127,17 @@ public class InventoryUtil
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Methods for placing into inventories:
|
||||
|
||||
public static ItemStack storeItems( ItemStack itemstack, IInventory inventory, int start, int range, int begin )
|
||||
{
|
||||
|
||||
// Methods for placing into inventories:
|
||||
|
||||
public static ItemStack storeItems( ItemStack itemstack, IInventory inventory, int start, int range, int begin )
|
||||
{
|
||||
int[] slots = makeSlotList( start, range, begin );
|
||||
return storeItems( itemstack, inventory, slots, null );
|
||||
}
|
||||
return storeItems( itemstack, inventory, slots, null );
|
||||
}
|
||||
|
||||
public static ItemStack storeItems( ItemStack itemstack, IInventory inventory, EnumFacing side )
|
||||
{
|
||||
public static ItemStack storeItems( ItemStack itemstack, IInventory inventory, EnumFacing side )
|
||||
{
|
||||
// Try ISidedInventory
|
||||
if( inventory instanceof ISidedInventory )
|
||||
{
|
||||
@@ -147,20 +147,20 @@ public class InventoryUtil
|
||||
return storeItems( itemstack, inventory, slots, side );
|
||||
}
|
||||
|
||||
// No ISidedInventory, store into any slot
|
||||
int[] slots = makeSlotList( 0, inventory.getSizeInventory(), 0 ); // TODO: optimise this out?
|
||||
return storeItems( itemstack, inventory, slots, side );
|
||||
}
|
||||
|
||||
// Methods for taking out of inventories
|
||||
|
||||
// No ISidedInventory, store into any slot
|
||||
int[] slots = makeSlotList( 0, inventory.getSizeInventory(), 0 ); // TODO: optimise this out?
|
||||
return storeItems( itemstack, inventory, slots, side );
|
||||
}
|
||||
|
||||
// Methods for taking out of inventories
|
||||
|
||||
public static ItemStack takeItems( int count, IInventory inventory, int start, int range, int begin )
|
||||
{
|
||||
int[] slots = makeSlotList( start, range, begin );
|
||||
return takeItems( count, inventory, slots, null );
|
||||
return takeItems( count, inventory, slots, null );
|
||||
}
|
||||
|
||||
public static ItemStack takeItems( int count, IInventory inventory, EnumFacing side )
|
||||
|
||||
public static ItemStack takeItems( int count, IInventory inventory, EnumFacing side )
|
||||
{
|
||||
// Try ISidedInventory
|
||||
if( inventory instanceof ISidedInventory )
|
||||
@@ -171,127 +171,127 @@ public class InventoryUtil
|
||||
return takeItems( count, inventory, slots, side );
|
||||
}
|
||||
|
||||
// No ISidedInventory, store into any slot
|
||||
int[] slots = makeSlotList( 0, inventory.getSizeInventory(), 0 );
|
||||
return takeItems( count, inventory, slots, side );
|
||||
// No ISidedInventory, store into any slot
|
||||
int[] slots = makeSlotList( 0, inventory.getSizeInventory(), 0 );
|
||||
return takeItems( count, inventory, slots, side );
|
||||
}
|
||||
|
||||
// Private methods
|
||||
// Private methods
|
||||
|
||||
private static int[] makeSlotList( int start, int range, int begin )
|
||||
{
|
||||
if( start < 0 || range == 0 )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
int[] slots = new int[range];
|
||||
for( int n=0; n<slots.length; ++n )
|
||||
{
|
||||
slots[n] = start + ( (n + (begin - start)) % range );
|
||||
}
|
||||
return slots;
|
||||
}
|
||||
|
||||
private static int[] makeSlotList( int start, int range, int begin )
|
||||
{
|
||||
if( start < 0 || range == 0 )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
int[] slots = new int[range];
|
||||
for( int n=0; n<slots.length; ++n )
|
||||
{
|
||||
slots[n] = start + ( (n + (begin - start)) % range );
|
||||
}
|
||||
return slots;
|
||||
}
|
||||
|
||||
private static ItemStack storeItems( ItemStack stack, IInventory inventory, int[] slots, EnumFacing face )
|
||||
{
|
||||
if( slots == null || slots.length == 0 )
|
||||
{
|
||||
return stack;
|
||||
}
|
||||
if( stack == null || stack.stackSize == 0 )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if( slots == null || slots.length == 0 )
|
||||
{
|
||||
return stack;
|
||||
}
|
||||
if( stack == null || stack.stackSize == 0 )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// Inspect the slots in order and try to find empty or stackable slots
|
||||
// Inspect the slots in order and try to find empty or stackable slots
|
||||
ItemStack remainder = stack;
|
||||
for( int n=0; n<slots.length; ++n )
|
||||
{
|
||||
int slot = slots[n];
|
||||
if( canPlaceItemThroughFace( inventory, slot, remainder, face ) )
|
||||
{
|
||||
ItemStack slotContents = inventory.getStackInSlot(slot);
|
||||
if( slotContents == null )
|
||||
{
|
||||
// Slot is empty
|
||||
int space = inventory.getInventoryStackLimit();
|
||||
if( space >= remainder.stackSize )
|
||||
{
|
||||
for( int n=0; n<slots.length; ++n )
|
||||
{
|
||||
int slot = slots[n];
|
||||
if( canPlaceItemThroughFace( inventory, slot, remainder, face ) )
|
||||
{
|
||||
ItemStack slotContents = inventory.getStackInSlot(slot);
|
||||
if( slotContents == null )
|
||||
{
|
||||
// Slot is empty
|
||||
int space = inventory.getInventoryStackLimit();
|
||||
if( space >= remainder.stackSize )
|
||||
{
|
||||
// Items fit completely in slot
|
||||
inventory.setInventorySlotContents( slot, remainder );
|
||||
inventory.markDirty();
|
||||
return null;
|
||||
}
|
||||
else
|
||||
inventory.setInventorySlotContents( slot, remainder );
|
||||
inventory.markDirty();
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Items fit partially in slot
|
||||
remainder = remainder.copy();
|
||||
inventory.setInventorySlotContents( slot, remainder.splitStack( space ) );
|
||||
inventory.setInventorySlotContents( slot, remainder.splitStack( space ) );
|
||||
}
|
||||
}
|
||||
else if( areItemsStackable( slotContents, remainder ) )
|
||||
{
|
||||
// Slot is occupied, but matching
|
||||
int space = Math.min( slotContents.getMaxStackSize(), inventory.getInventoryStackLimit() ) - slotContents.stackSize;
|
||||
if( space >= remainder.stackSize )
|
||||
{
|
||||
}
|
||||
else if( areItemsStackable( slotContents, remainder ) )
|
||||
{
|
||||
// Slot is occupied, but matching
|
||||
int space = Math.min( slotContents.getMaxStackSize(), inventory.getInventoryStackLimit() ) - slotContents.stackSize;
|
||||
if( space >= remainder.stackSize )
|
||||
{
|
||||
// Items fit completely in slot
|
||||
slotContents.stackSize += remainder.stackSize;
|
||||
inventory.setInventorySlotContents( slot, slotContents );
|
||||
inventory.markDirty();
|
||||
return null;
|
||||
}
|
||||
else if( space > 0 )
|
||||
{
|
||||
slotContents.stackSize += remainder.stackSize;
|
||||
inventory.setInventorySlotContents( slot, slotContents );
|
||||
inventory.markDirty();
|
||||
return null;
|
||||
}
|
||||
else if( space > 0 )
|
||||
{
|
||||
// Items fit partially in slot
|
||||
remainder = remainder.copy();
|
||||
remainder.stackSize -= space;
|
||||
slotContents.stackSize += space;
|
||||
inventory.setInventorySlotContents( slot, slotContents );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
slotContents.stackSize += space;
|
||||
inventory.setInventorySlotContents( slot, slotContents );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If the output isn't the input, inform the change
|
||||
if( remainder != stack )
|
||||
{
|
||||
inventory.markDirty();
|
||||
}
|
||||
if( remainder != stack )
|
||||
{
|
||||
inventory.markDirty();
|
||||
}
|
||||
return remainder;
|
||||
}
|
||||
|
||||
private static boolean canPlaceItemThroughFace( IInventory inventory, int slot, ItemStack itemstack, EnumFacing face )
|
||||
{
|
||||
if( inventory.isItemValidForSlot( slot, itemstack ) )
|
||||
{
|
||||
if( face != null && inventory instanceof ISidedInventory )
|
||||
{
|
||||
ISidedInventory sided = (ISidedInventory)inventory;
|
||||
return sided.canInsertItem( slot, itemstack, face );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
private static boolean canPlaceItemThroughFace( IInventory inventory, int slot, ItemStack itemstack, EnumFacing face )
|
||||
{
|
||||
if( inventory.isItemValidForSlot( slot, itemstack ) )
|
||||
{
|
||||
if( face != null && inventory instanceof ISidedInventory )
|
||||
{
|
||||
ISidedInventory sided = (ISidedInventory)inventory;
|
||||
return sided.canInsertItem( slot, itemstack, face );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static ItemStack takeItems( int count, IInventory inventory, int[] slots, EnumFacing face )
|
||||
{
|
||||
if( slots == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if( slots == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// Combine multiple stacks from inventory into one if necessary
|
||||
// Combine multiple stacks from inventory into one if necessary
|
||||
ItemStack partialStack = null;
|
||||
int countRemaining = count;
|
||||
for( int n=0; n<slots.length; ++n )
|
||||
{
|
||||
int slot = slots[n];
|
||||
for( int n=0; n<slots.length; ++n )
|
||||
{
|
||||
int slot = slots[n];
|
||||
if( countRemaining > 0 )
|
||||
{
|
||||
ItemStack stack = inventory.getStackInSlot( slot );
|
||||
ItemStack stack = inventory.getStackInSlot( slot );
|
||||
if( stack != null && canTakeItemThroughFace( inventory, slot, stack, face ) )
|
||||
{
|
||||
if( partialStack == null || areItemsStackable( stack, partialStack ) )
|
||||
@@ -328,9 +328,9 @@ public class InventoryUtil
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Return the final stack
|
||||
if( partialStack != null )
|
||||
@@ -338,16 +338,16 @@ public class InventoryUtil
|
||||
inventory.markDirty();
|
||||
return partialStack;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static boolean canTakeItemThroughFace( IInventory inventory, int slot, ItemStack itemstack, EnumFacing face )
|
||||
{
|
||||
if( face != null && inventory instanceof ISidedInventory )
|
||||
{
|
||||
ISidedInventory sided = (ISidedInventory)inventory;
|
||||
return sided.canExtractItem( slot, itemstack, face );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
private static boolean canTakeItemThroughFace( IInventory inventory, int slot, ItemStack itemstack, EnumFacing face )
|
||||
{
|
||||
if( face != null && inventory instanceof ISidedInventory )
|
||||
{
|
||||
ISidedInventory sided = (ISidedInventory)inventory;
|
||||
return sided.canExtractItem( slot, itemstack, face );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user