reformatted all src files (#141)

This commit is contained in:
YoungOnion
2022-09-17 05:08:02 -06:00
committed by GitHub
parent 3328bfcda2
commit 9011273229
1056 changed files with 88127 additions and 110597 deletions
+159 -207
View File
@@ -19,16 +19,12 @@
package appeng.tile.misc;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import appeng.api.util.AEColor;
import appeng.helpers.Splotch;
import appeng.items.misc.ItemPaintBall;
import appeng.tile.AEBaseTile;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@@ -37,245 +33,201 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.EnumSkyBlock;
import appeng.api.util.AEColor;
import appeng.helpers.Splotch;
import appeng.items.misc.ItemPaintBall;
import appeng.tile.AEBaseTile;
import java.io.IOException;
import java.util.*;
public class TilePaint extends AEBaseTile
{
public class TilePaint extends AEBaseTile {
private static final int LIGHT_PER_DOT = 12;
private static final int LIGHT_PER_DOT = 12;
private int isLit = 0;
private List<Splotch> dots = null;
private int isLit = 0;
private List<Splotch> dots = null;
@Override
public boolean canBeRotated()
{
return false;
}
@Override
public boolean canBeRotated() {
return false;
}
@Override
public NBTTagCompound writeToNBT( final NBTTagCompound data )
{
super.writeToNBT( data );
final ByteBuf myDat = Unpooled.buffer();
this.writeBuffer( myDat );
if( myDat.hasArray() )
{
data.setByteArray( "dots", myDat.array() );
}
return data;
}
@Override
public NBTTagCompound writeToNBT(final NBTTagCompound data) {
super.writeToNBT(data);
final ByteBuf myDat = Unpooled.buffer();
this.writeBuffer(myDat);
if (myDat.hasArray()) {
data.setByteArray("dots", myDat.array());
}
return data;
}
private void writeBuffer( final ByteBuf out )
{
if( this.dots == null )
{
out.writeByte( 0 );
return;
}
private void writeBuffer(final ByteBuf out) {
if (this.dots == null) {
out.writeByte(0);
return;
}
out.writeByte( this.dots.size() );
out.writeByte(this.dots.size());
for( final Splotch s : this.dots )
{
s.writeToStream( out );
}
}
for (final Splotch s : this.dots) {
s.writeToStream(out);
}
}
@Override
public void readFromNBT( final NBTTagCompound data )
{
super.readFromNBT( data );
if( data.hasKey( "dots" ) )
{
this.readBuffer( Unpooled.copiedBuffer( data.getByteArray( "dots" ) ) );
}
}
@Override
public void readFromNBT(final NBTTagCompound data) {
super.readFromNBT(data);
if (data.hasKey("dots")) {
this.readBuffer(Unpooled.copiedBuffer(data.getByteArray("dots")));
}
}
private void readBuffer( final ByteBuf in )
{
final byte howMany = in.readByte();
private void readBuffer(final ByteBuf in) {
final byte howMany = in.readByte();
if( howMany == 0 )
{
this.isLit = 0;
this.dots = null;
return;
}
if (howMany == 0) {
this.isLit = 0;
this.dots = null;
return;
}
this.dots = new ArrayList( howMany );
for( int x = 0; x < howMany; x++ )
{
this.dots.add( new Splotch( in ) );
}
this.dots = new ArrayList(howMany);
for (int x = 0; x < howMany; x++) {
this.dots.add(new Splotch(in));
}
this.isLit = 0;
for( final Splotch s : this.dots )
{
if( s.isLumen() )
{
this.isLit += LIGHT_PER_DOT;
}
}
this.isLit = 0;
for (final Splotch s : this.dots) {
if (s.isLumen()) {
this.isLit += LIGHT_PER_DOT;
}
}
this.maxLit();
}
this.maxLit();
}
private void maxLit()
{
if( this.isLit > 14 )
{
this.isLit = 14;
}
private void maxLit() {
if (this.isLit > 14) {
this.isLit = 14;
}
if( this.world != null )
{
this.world.getLightFor( EnumSkyBlock.BLOCK, this.pos );
}
}
if (this.world != null) {
this.world.getLightFor(EnumSkyBlock.BLOCK, this.pos);
}
}
@Override
protected void writeToStream( final ByteBuf data ) throws IOException
{
super.writeToStream( data );
this.writeBuffer( data );
}
@Override
protected void writeToStream(final ByteBuf data) throws IOException {
super.writeToStream(data);
this.writeBuffer(data);
}
@Override
protected boolean readFromStream( final ByteBuf data ) throws IOException
{
super.readFromStream( data );
this.readBuffer( data );
return true;
}
@Override
protected boolean readFromStream(final ByteBuf data) throws IOException {
super.readFromStream(data);
this.readBuffer(data);
return true;
}
public void neighborChanged()
{
if( this.dots == null )
{
return;
}
public void neighborChanged() {
if (this.dots == null) {
return;
}
for( final EnumFacing side : EnumFacing.VALUES )
{
if( !this.isSideValid( side ) )
{
this.removeSide( side );
}
}
for (final EnumFacing side : EnumFacing.VALUES) {
if (!this.isSideValid(side)) {
this.removeSide(side);
}
}
this.updateData();
}
this.updateData();
}
public boolean isSideValid( final EnumFacing side )
{
final BlockPos p = this.pos.offset( side );
final IBlockState blk = this.world.getBlockState( p );
return blk.getBlock().isSideSolid( this.world.getBlockState( p ), this.world, p, side.getOpposite() );
}
public boolean isSideValid(final EnumFacing side) {
final BlockPos p = this.pos.offset(side);
final IBlockState blk = this.world.getBlockState(p);
return blk.getBlock().isSideSolid(this.world.getBlockState(p), this.world, p, side.getOpposite());
}
private void removeSide( final EnumFacing side )
{
final Iterator<Splotch> i = this.dots.iterator();
while( i.hasNext() )
{
final Splotch s = i.next();
if( s.getSide() == side )
{
i.remove();
}
}
private void removeSide(final EnumFacing side) {
final Iterator<Splotch> i = this.dots.iterator();
while (i.hasNext()) {
final Splotch s = i.next();
if (s.getSide() == side) {
i.remove();
}
}
this.markForUpdate();
this.saveChanges();
}
this.markForUpdate();
this.saveChanges();
}
private void updateData()
{
this.isLit = 0;
for( final Splotch s : this.dots )
{
if( s.isLumen() )
{
this.isLit += LIGHT_PER_DOT;
}
}
private void updateData() {
this.isLit = 0;
for (final Splotch s : this.dots) {
if (s.isLumen()) {
this.isLit += LIGHT_PER_DOT;
}
}
this.maxLit();
this.maxLit();
if( this.dots.isEmpty() )
{
this.dots = null;
}
if (this.dots.isEmpty()) {
this.dots = null;
}
if( this.dots == null )
{
this.world.setBlockToAir( this.pos );
}
}
if (this.dots == null) {
this.world.setBlockToAir(this.pos);
}
}
public void cleanSide( final EnumFacing side )
{
if( this.dots == null )
{
return;
}
public void cleanSide(final EnumFacing side) {
if (this.dots == null) {
return;
}
this.removeSide( side );
this.removeSide(side);
this.updateData();
}
this.updateData();
}
public int getLightLevel()
{
return this.isLit;
}
public int getLightLevel() {
return this.isLit;
}
public void addBlot( final ItemStack type, final EnumFacing side, final Vec3d hitVec )
{
final BlockPos p = this.pos.offset( side );
public void addBlot(final ItemStack type, final EnumFacing side, final Vec3d hitVec) {
final BlockPos p = this.pos.offset(side);
final IBlockState blk = this.world.getBlockState( p );
if( blk.getBlock().isSideSolid( this.world.getBlockState( p ), this.world, p, side.getOpposite() ) )
{
final ItemPaintBall ipb = (ItemPaintBall) type.getItem();
final IBlockState blk = this.world.getBlockState(p);
if (blk.getBlock().isSideSolid(this.world.getBlockState(p), this.world, p, side.getOpposite())) {
final ItemPaintBall ipb = (ItemPaintBall) type.getItem();
final AEColor col = ipb.getColor( type );
final boolean lit = ipb.isLumen( type );
final AEColor col = ipb.getColor(type);
final boolean lit = ItemPaintBall.isLumen(type);
if( this.dots == null )
{
this.dots = new ArrayList<>();
}
if (this.dots == null) {
this.dots = new ArrayList<>();
}
if( this.dots.size() > 20 )
{
this.dots.remove( 0 );
}
if (this.dots.size() > 20) {
this.dots.remove(0);
}
this.dots.add( new Splotch( col, lit, side, hitVec ) );
if( lit )
{
this.isLit += LIGHT_PER_DOT;
}
this.dots.add(new Splotch(col, lit, side, hitVec));
if (lit) {
this.isLit += LIGHT_PER_DOT;
}
this.maxLit();
this.markForUpdate();
this.saveChanges();
}
}
this.maxLit();
this.markForUpdate();
this.saveChanges();
}
}
public Collection<Splotch> getDots()
{
if( this.dots == null )
{
return Collections.emptyList();
}
public Collection<Splotch> getDots() {
if (this.dots == null) {
return Collections.emptyList();
}
return this.dots;
}
return this.dots;
}
}