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
+81 -79
View File
@@ -18,12 +18,11 @@
package appeng.tile.misc;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import com.google.common.collect.ImmutableList;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
@@ -35,6 +34,8 @@ import net.minecraft.util.Vec3;
import net.minecraft.world.EnumSkyBlock;
import net.minecraftforge.common.util.ForgeDirection;
import com.google.common.collect.ImmutableList;
import appeng.api.util.AEColor;
import appeng.helpers.Splotch;
import appeng.items.misc.ItemPaintBall;
@@ -42,6 +43,7 @@ import appeng.tile.AEBaseTile;
import appeng.tile.TileEvent;
import appeng.tile.events.TileEventType;
public class TilePaint extends AEBaseTile
{
@@ -50,9 +52,18 @@ public class TilePaint extends AEBaseTile
int isLit = 0;
ArrayList<Splotch> dots = null;
void writeBuffer(ByteBuf out)
@TileEvent( TileEventType.WORLD_NBT_WRITE )
public void writeToNBT_TilePaint( NBTTagCompound data )
{
if ( this.dots == null )
ByteBuf myDat = Unpooled.buffer();
this.writeBuffer( myDat );
if( myDat.hasArray() )
data.setByteArray( "dots", myDat.array() );
}
void writeBuffer( ByteBuf out )
{
if( this.dots == null )
{
out.writeByte( 0 );
return;
@@ -60,15 +71,22 @@ public class TilePaint extends AEBaseTile
out.writeByte( this.dots.size() );
for (Splotch s : this.dots)
for( Splotch s : this.dots )
s.writeToStream( out );
}
void readBuffer(ByteBuf in)
@TileEvent( TileEventType.WORLD_NBT_READ )
public void readFromNBT_TilePaint( NBTTagCompound data )
{
if( data.hasKey( "dots" ) )
this.readBuffer( Unpooled.copiedBuffer( data.getByteArray( "dots" ) ) );
}
void readBuffer( ByteBuf in )
{
byte howMany = in.readByte();
if ( howMany == 0 )
if( howMany == 0 )
{
this.isLit = 0;
this.dots = null;
@@ -76,13 +94,13 @@ public class TilePaint extends AEBaseTile
}
this.dots = new ArrayList( howMany );
for (int x = 0; x < howMany; x++)
for( int x = 0; x < howMany; x++ )
this.dots.add( new Splotch( in ) );
this.isLit = 0;
for (Splotch s : this.dots)
for( Splotch s : this.dots )
{
if ( s.lumen )
if( s.lumen )
{
this.isLit += LIGHT_PER_DOT;
}
@@ -91,30 +109,23 @@ public class TilePaint extends AEBaseTile
this.maxLit();
}
@TileEvent(TileEventType.WORLD_NBT_WRITE)
public void writeToNBT_TilePaint(NBTTagCompound data)
private void maxLit()
{
ByteBuf myDat = Unpooled.buffer();
this.writeBuffer( myDat );
if ( myDat.hasArray() )
data.setByteArray( "dots", myDat.array() );
if( this.isLit > 14 )
this.isLit = 14;
if( this.worldObj != null )
this.worldObj.updateLightByType( EnumSkyBlock.Block, this.xCoord, this.yCoord, this.zCoord );
}
@TileEvent(TileEventType.WORLD_NBT_READ)
public void readFromNBT_TilePaint(NBTTagCompound data)
{
if ( data.hasKey( "dots" ) )
this.readBuffer( Unpooled.copiedBuffer( data.getByteArray( "dots" ) ) );
}
@TileEvent(TileEventType.NETWORK_WRITE)
public void writeToStream_TilePaint(ByteBuf data)
@TileEvent( TileEventType.NETWORK_WRITE )
public void writeToStream_TilePaint( ByteBuf data )
{
this.writeBuffer( data );
}
@TileEvent(TileEventType.NETWORK_READ)
public boolean readFromStream_TilePaint(ByteBuf data)
@TileEvent( TileEventType.NETWORK_READ )
public boolean readFromStream_TilePaint( ByteBuf data )
{
this.readBuffer( data );
return true;
@@ -122,61 +133,31 @@ public class TilePaint extends AEBaseTile
public void onNeighborBlockChange()
{
if ( this.dots == null )
if( this.dots == null )
return;
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
for( ForgeDirection side : ForgeDirection.VALID_DIRECTIONS )
{
if ( !this.isSideValid( side ) )
if( !this.isSideValid( side ) )
this.removeSide( side );
}
this.updateData();
}
private void updateData()
{
this.isLit = 0;
for (Splotch s : this.dots)
{
if ( s.lumen )
{
this.isLit += LIGHT_PER_DOT;
}
}
this.maxLit();
if ( this.dots.isEmpty() )
this.dots = null;
if ( this.dots == null )
this.worldObj.setBlock( this.xCoord, this.yCoord, this.zCoord, Blocks.air );
}
public void cleanSide(ForgeDirection side)
{
if ( this.dots == null )
return;
this.removeSide( side );
this.updateData();
}
public boolean isSideValid(ForgeDirection side)
public boolean isSideValid( ForgeDirection side )
{
Block blk = this.worldObj.getBlock( this.xCoord + side.offsetX, this.yCoord + side.offsetY, this.zCoord + side.offsetZ );
return blk.isSideSolid( this.worldObj, this.xCoord + side.offsetX, this.yCoord + side.offsetY, this.zCoord + side.offsetZ, side.getOpposite() );
}
private void removeSide(ForgeDirection side)
private void removeSide( ForgeDirection side )
{
Iterator<Splotch> i = this.dots.iterator();
while (i.hasNext())
while( i.hasNext() )
{
Splotch s = i.next();
if ( s.side == side )
if( s.side == side )
i.remove();
}
@@ -184,29 +165,59 @@ public class TilePaint extends AEBaseTile
this.markDirty();
}
private void updateData()
{
this.isLit = 0;
for( Splotch s : this.dots )
{
if( s.lumen )
{
this.isLit += LIGHT_PER_DOT;
}
}
this.maxLit();
if( this.dots.isEmpty() )
this.dots = null;
if( this.dots == null )
this.worldObj.setBlock( this.xCoord, this.yCoord, this.zCoord, Blocks.air );
}
public void cleanSide( ForgeDirection side )
{
if( this.dots == null )
return;
this.removeSide( side );
this.updateData();
}
public int getLightLevel()
{
return this.isLit;
}
public void addBlot(ItemStack type, ForgeDirection side, Vec3 hitVec)
public void addBlot( ItemStack type, ForgeDirection side, Vec3 hitVec )
{
Block blk = this.worldObj.getBlock( this.xCoord + side.offsetX, this.yCoord + side.offsetY, this.zCoord + side.offsetZ );
if ( blk.isSideSolid( this.worldObj, this.xCoord + side.offsetX, this.yCoord + side.offsetY, this.zCoord + side.offsetZ, side.getOpposite() ) )
if( blk.isSideSolid( this.worldObj, this.xCoord + side.offsetX, this.yCoord + side.offsetY, this.zCoord + side.offsetZ, side.getOpposite() ) )
{
ItemPaintBall ipb = (ItemPaintBall) type.getItem();
AEColor col = ipb.getColor( type );
boolean lit = ipb.isLumen( type );
if ( this.dots == null )
if( this.dots == null )
this.dots = new ArrayList<Splotch>();
if ( this.dots.size() > 20 )
if( this.dots.size() > 20 )
this.dots.remove( 0 );
this.dots.add( new Splotch( col, lit, side, hitVec ) );
if ( lit )
if( lit )
this.isLit += LIGHT_PER_DOT;
this.maxLit();
@@ -215,18 +226,9 @@ public class TilePaint extends AEBaseTile
}
}
private void maxLit()
{
if ( this.isLit > 14 )
this.isLit = 14;
if ( this.worldObj != null )
this.worldObj.updateLightByType( EnumSkyBlock.Block, this.xCoord, this.yCoord, this.zCoord );
}
public Collection<Splotch> getDots()
{
if ( this.dots == null )
if( this.dots == null )
return ImmutableList.of();
return this.dots;