package micdoodle8.mods.galacticraft.core.tile;
import micdoodle8.mods.galacticraft.core.GCBlocks;
import micdoodle8.mods.galacticraft.core.blocks.BlockLandingPadFull;
import net.minecraft.block.state.IBlockState;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.util.ITickable;
import net.minecraft.world.World;
import java.util.ArrayList;
public class TileEntityBuggyFuelerSingle extends TileEntity implements ITickable
{
@Override
public void update()
{
if (!this.worldObj.isRemote)
{
final ArrayList<TileEntity> attachedLaunchPads = new ArrayList<TileEntity>();
for (int x = this.getPos().getX() - 1; x < this.getPos().getX() + 2; x++)
{
for (int z = this.getPos().getZ() - 1; z < this.getPos().getZ() + 2; z++)
{
final TileEntity tile = this.worldObj.getTileEntity(new BlockPos(x, this.getPos().getY(), z));
if (tile instanceof TileEntityBuggyFuelerSingle)
{
attachedLaunchPads.add(tile);
}
}
}
if (attachedLaunchPads.size() == 9)
{
for (final TileEntity tile : attachedLaunchPads)
{
this.worldObj.markTileEntityForRemoval(tile);
}
this.worldObj.setBlockState(this.getPos(), GCBlocks.landingPadFull.getStateFromMeta(BlockLandingPadFull.EnumLandingPadFullType.BUGGY_PAD.getMeta()), 2);
}
}
}
@Override
public boolean shouldRefresh(World world, BlockPos pos, IBlockState oldState, IBlockState newSate)
{
return oldState.getBlock() != newSate.getBlock();
}
}