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
@@ -37,6 +37,7 @@ import appeng.tile.TileEvent;
import appeng.tile.events.TileEventType;
import appeng.util.Platform;
public class TileCrank extends AEBaseTile implements ICustomCollision
{
@@ -49,18 +50,18 @@ public class TileCrank extends AEBaseTile implements ICustomCollision
public int hits = 0;
public int rotation = 0;
@TileEvent(TileEventType.TICK)
@TileEvent( TileEventType.TICK )
public void Tick_TileCrank()
{
if ( this.rotation > 0 )
if( this.rotation > 0 )
{
this.visibleRotation -= 360 / (this.ticksPerRotation);
this.visibleRotation -= 360 / ( this.ticksPerRotation );
this.charge++;
if ( this.charge >= this.ticksPerRotation )
if( this.charge >= this.ticksPerRotation )
{
this.charge -= this.ticksPerRotation;
ICrankable g = this.getGrinder();
if ( g != null )
if( g != null )
g.applyTurn();
}
@@ -68,52 +69,58 @@ public class TileCrank extends AEBaseTile implements ICustomCollision
}
}
@TileEvent(TileEventType.NETWORK_READ)
public boolean readFromStream_TileCrank(ByteBuf data)
public ICrankable getGrinder()
{
if( Platform.isClient() )
return null;
ForgeDirection grinder = this.getUp().getOpposite();
TileEntity te = this.worldObj.getTileEntity( this.xCoord + grinder.offsetX, this.yCoord + grinder.offsetY, this.zCoord + grinder.offsetZ );
if( te instanceof ICrankable )
return (ICrankable) te;
return null;
}
@TileEvent( TileEventType.NETWORK_READ )
public boolean readFromStream_TileCrank( ByteBuf data )
{
this.rotation = data.readInt();
return false;
}
@TileEvent(TileEventType.NETWORK_WRITE)
public void writeToStream_TileCrank(ByteBuf data)
@TileEvent( TileEventType.NETWORK_WRITE )
public void writeToStream_TileCrank( ByteBuf data )
{
data.writeInt( this.rotation );
}
public ICrankable getGrinder()
{
if ( Platform.isClient() )
return null;
ForgeDirection grinder = this.getUp().getOpposite();
TileEntity te = this.worldObj.getTileEntity( this.xCoord + grinder.offsetX, this.yCoord + grinder.offsetY, this.zCoord + grinder.offsetZ );
if ( te instanceof ICrankable )
return (ICrankable) te;
return null;
}
@Override
public void setOrientation(ForgeDirection inForward, ForgeDirection inUp)
public void setOrientation( ForgeDirection inForward, ForgeDirection inUp )
{
super.setOrientation( inForward, inUp );
this.getBlockType().onNeighborBlockChange( this.worldObj, this.xCoord, this.yCoord, this.zCoord, Platform.AIR );
}
@Override
public boolean requiresTESR()
{
return true;
}
/**
* return true if this should count towards stats.
*/
public boolean power()
{
if ( Platform.isClient() )
if( Platform.isClient() )
return false;
if ( this.rotation < 3 )
if( this.rotation < 3 )
{
ICrankable g = this.getGrinder();
if ( g != null )
if( g != null )
{
if ( g.canTurn() )
if( g.canTurn() )
{
this.hits = 0;
this.rotation += this.ticksPerRotation;
@@ -123,7 +130,7 @@ public class TileCrank extends AEBaseTile implements ICustomCollision
else
{
this.hits++;
if ( this.hits > 10 )
if( this.hits > 10 )
{
this.worldObj.func_147480_a( this.xCoord, this.yCoord, this.zCoord, false );
// worldObj.destroyBlock( xCoord, yCoord, zCoord, false );
@@ -136,7 +143,7 @@ public class TileCrank extends AEBaseTile implements ICustomCollision
}
@Override
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool(World w, int x, int y, int z, Entity e, boolean isVisual)
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool( World w, int x, int y, int z, Entity e, boolean isVisual )
{
double xOff = -0.15 * this.getUp().offsetX;
double yOff = -0.15 * this.getUp().offsetY;
@@ -145,7 +152,7 @@ public class TileCrank extends AEBaseTile implements ICustomCollision
}
@Override
public void addCollidingBlockToList(World w, int x, int y, int z, AxisAlignedBB bb, List<AxisAlignedBB> out, Entity e)
public void addCollidingBlockToList( World w, int x, int y, int z, AxisAlignedBB bb, List<AxisAlignedBB> out, Entity e )
{
double xOff = -0.15 * this.getUp().offsetX;
double yOff = -0.15 * this.getUp().offsetY;
@@ -153,10 +160,4 @@ public class TileCrank extends AEBaseTile implements ICustomCollision
out.add( AxisAlignedBB.getBoundingBox( xOff + 0.15, yOff + 0.15, zOff + 0.15,// ahh
xOff + 0.85, yOff + 0.85, zOff + 0.85 ) );
}
@Override
public boolean requiresTESR()
{
return true;
}
}
@@ -18,6 +18,7 @@
package appeng.tile.grindstone;
import java.util.ArrayList;
import java.util.List;
@@ -36,56 +37,22 @@ import appeng.util.InventoryAdaptor;
import appeng.util.Platform;
import appeng.util.inv.WrapperInventoryRange;
public class TileGrinder extends AEBaseInvTile implements ICrankable
{
int points;
final int[] inputs = new int[] { 0, 1, 2 };
final int[] sides = new int[] { 0, 1, 2, 3, 4, 5 };
final AppEngInternalInventory inv = new AppEngInternalInventory( this, 7 );
int points;
@Override
public void setOrientation(ForgeDirection inForward, ForgeDirection inUp)
public void setOrientation( ForgeDirection inForward, ForgeDirection inUp )
{
super.setOrientation( inForward, inUp );
this.getBlockType().onNeighborBlockChange( this.worldObj, this.xCoord, this.yCoord, this.zCoord, Platform.AIR );
}
private void addItem(InventoryAdaptor sia, ItemStack output)
{
if ( output == null )
return;
ItemStack notAdded = sia.addItems( output );
if ( notAdded != null )
{
WorldCoord wc = new WorldCoord( this.xCoord, this.yCoord, this.zCoord );
wc.add( this.getForward(), 1 );
List<ItemStack> out = new ArrayList<ItemStack>();
out.add( notAdded );
Platform.spawnDrops( this.worldObj, wc.x, wc.y, wc.z, out );
}
}
@Override
public boolean canInsertItem(int slotIndex, ItemStack insertingItem, int side )
{
if ( AEApi.instance().registries().grinder().getRecipeForInput( insertingItem ) == null )
return false;
return slotIndex >= 0 && slotIndex <= 2;
}
@Override
public boolean canExtractItem(int slotIndex, ItemStack extractedItem, int side )
{
return slotIndex >= 3 && slotIndex <= 5;
}
@Override
public IInventory getInternalInventory()
{
@@ -93,42 +60,57 @@ public class TileGrinder extends AEBaseInvTile implements ICrankable
}
@Override
public int[] getAccessibleSlotsBySide(ForgeDirection side)
public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removed, ItemStack added )
{
}
@Override
public boolean canInsertItem( int slotIndex, ItemStack insertingItem, int side )
{
if( AEApi.instance().registries().grinder().getRecipeForInput( insertingItem ) == null )
return false;
return slotIndex >= 0 && slotIndex <= 2;
}
@Override
public boolean canExtractItem( int slotIndex, ItemStack extractedItem, int side )
{
return slotIndex >= 3 && slotIndex <= 5;
}
@Override
public int[] getAccessibleSlotsBySide( ForgeDirection side )
{
return this.sides;
}
@Override
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removed, ItemStack added)
{
}
@Override
public boolean canTurn()
{
if ( Platform.isClient() )
if( Platform.isClient() )
return false;
if ( null == this.getStackInSlot( 6 ) ) // Add if there isn't one...
if( null == this.getStackInSlot( 6 ) ) // Add if there isn't one...
{
IInventory src = new WrapperInventoryRange( this, this.inputs, true );
for (int x = 0; x < src.getSizeInventory(); x++)
for( int x = 0; x < src.getSizeInventory(); x++ )
{
ItemStack item = src.getStackInSlot( x );
if ( item == null )
if( item == null )
continue;
IGrinderEntry r = AEApi.instance().registries().grinder().getRecipeForInput( item );
if ( r != null )
if( r != null )
{
if ( item.stackSize >= r.getInput().stackSize )
if( item.stackSize >= r.getInput().stackSize )
{
item.stackSize -= r.getInput().stackSize;
ItemStack ais = item.copy();
ais.stackSize = r.getInput().stackSize;
if ( item.stackSize <= 0 )
if( item.stackSize <= 0 )
item = null;
src.setInventorySlotContents( x, item );
@@ -145,16 +127,16 @@ public class TileGrinder extends AEBaseInvTile implements ICrankable
@Override
public void applyTurn()
{
if ( Platform.isClient() )
if( Platform.isClient() )
return;
this.points++;
ItemStack processing = this.getStackInSlot( 6 );
IGrinderEntry r = AEApi.instance().registries().grinder().getRecipeForInput( processing );
if ( r != null )
if( r != null )
{
if ( r.getEnergyCost() > this.points )
if( r.getEnergyCost() > this.points )
return;
this.points = 0;
@@ -162,22 +144,40 @@ public class TileGrinder extends AEBaseInvTile implements ICrankable
this.addItem( sia, r.getOutput() );
float chance = (Platform.getRandomInt() % 2000) / 2000.0f;
if ( chance <= r.getOptionalChance() )
float chance = ( Platform.getRandomInt() % 2000 ) / 2000.0f;
if( chance <= r.getOptionalChance() )
this.addItem( sia, r.getOptionalOutput() );
chance = (Platform.getRandomInt() % 2000) / 2000.0f;
if ( chance <= r.getSecondOptionalChance() )
chance = ( Platform.getRandomInt() % 2000 ) / 2000.0f;
if( chance <= r.getSecondOptionalChance() )
this.addItem( sia, r.getSecondOptionalOutput() );
this.setInventorySlotContents( 6, null );
}
}
private void addItem( InventoryAdaptor sia, ItemStack output )
{
if( output == null )
return;
ItemStack notAdded = sia.addItems( output );
if( notAdded != null )
{
WorldCoord wc = new WorldCoord( this.xCoord, this.yCoord, this.zCoord );
wc.add( this.getForward(), 1 );
List<ItemStack> out = new ArrayList<ItemStack>();
out.add( notAdded );
Platform.spawnDrops( this.worldObj, wc.x, wc.y, wc.z, out );
}
}
@Override
public boolean canCrankAttach(ForgeDirection directionToCrank)
public boolean canCrankAttach( ForgeDirection directionToCrank )
{
return this.getUp() == directionToCrank;
}
}